Commit Graph

510 Commits

Author SHA1 Message Date
Bob Weinand
94722e12cf Introduce ArithmeticError 2015-07-02 20:47:44 +02:00
Xinchen Hui
ba91bc36cd Same here 2015-07-02 12:23:50 +08:00
Xinchen Hui
ba711aec30 Use one_char_string 2015-07-02 12:19:55 +08:00
Xinchen Hui
0e68e27854 Use one_char_string 2015-07-02 12:18:23 +08:00
Bob Weinand
007d7ac7ca Use DivisionByZeroError instead of exception for %/intdiv() 2015-07-02 02:20:58 +02:00
Bob Weinand
f9724b93f6 Remove warning upon division by zero 2015-07-02 02:20:58 +02:00
Dmitry Stogov
d2d326a381 Cleanup (avoid reallocatios and side effects in php_strip_tags) 2015-07-01 19:04:18 +03:00
Dmitry Stogov
7aa7627172 Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 13:59:27 +03:00
Dmitry Stogov
4bd22cf1c1 Improved zend_string API (Francois Laupretre)
Squashed commit of the following:

commit d96eab8d79
Author: Francois Laupretre <francois@tekwire.net>
Date:   Fri Jun 26 01:23:31 2015 +0200

    Use the new 'ZSTR' macros in the rest of the code.

    Does not change anything to the generated code (thanks to compat macros) but cleaner.

commit b352643910
Author: Francois Laupretre <francois@tekwire.net>
Date:   Thu Jun 25 13:45:06 2015 +0200

    Improve zend_string API

    Add missing methods
2015-06-29 16:44:54 +03:00
Dmitry Stogov
1bba4452e7 Reverted wrong fb08798c9f 2015-06-29 12:20:09 +03:00
Bob Weinand
fb08798c9f Fix bug #69957 (Different ways of handling div/mod by zero) 2015-06-28 18:22:59 +02:00
Nikita Popov
8a83aed458 Drop duplicate object-to-type notices
We already generate a recoverable fatal for these earlier, no need
to throw an additional notice.
2015-06-22 16:25:32 +02:00
Dmitry Stogov
b97df475df Fixed crash in Zend/tests/bug69891.phpt on x86 (32-bit).
compare_function() now has to be compatible with binary_op_type (use fastcall convention).
Introduced new zval_compare_function() to be used as zval comparison callback instead of compare_function().
2015-06-22 12:53:52 +03:00
Dmitry Stogov
4a6e1345e2 Use COW to prevent unnecessary duplication of dynamic propertyes of stdClass (and other classes without predefined properties). 2015-06-17 12:50:16 +03:00
Nikita Popov
fb346c8f93 Support references in convert_to_*
conver_to_* functions now accept REFERENCE values, which will be
unwrapped before performing the usual conversion. This is consistent
with convert_scalar_to_number and matches the expected behavior in
a couple random use-sites I checked.

Also includes a couple fixes/cleanups elsewhere and two tests for
cases that previously didn't work (though the reference issue existed
all over the place).
2015-06-16 19:55:33 +02:00
Nikita Popov
183c00ddb6 Fix references handling in convert_scalar_to_number 2015-06-16 18:02:45 +02:00
Nikita Popov
5d3cf577aa Make convert_to_* safe with rc>1
This only involves switching zval_dtor to zval_ptr_dtor for arrays
and making the convert_to_object for arrays a bit more generic.

All the other changes outside zend_operators.c just make use of
this new ability (use COPY instead of DUP).

What's still missing: Proper references handling. I've seen many
convert_to* calls that will break when a reference is used.

Also fixes bug #69788.
2015-06-11 23:23:57 +02:00
Bob Weinand
9ca564d5f3 fix bitwise object operations 2015-06-04 16:09:22 +02:00
Bob Weinand
8a1c5d15d2 Use CG(one_char_string) if possible in bitwise string operations
emalloc() is not cheap... Also, a good part of bitwise string ops out there are on single bytes.
2015-06-03 02:57:16 +02:00
Dmitry Stogov
5fc88a9968 Inline IS_LONG value calculation and avoid strtol() call. 2015-05-05 11:09:18 +03:00
Dmitry Stogov
d880ead8a7 Improve fast_is_[not_]identical() functions to teturn value instead of takeing additional arguments.
Pair INSTANCEOF with the following JMPZ/JMPNZ.
2015-04-29 16:43:23 +03:00
Nikita Popov
23c7f19e41 Undef results for new arithmetic exceptions
For the compound assing case (e.g. $a <<= $b) the result is going
to be dtored, so we have to set *some* value.
2015-04-06 21:52:20 +02:00
Dmitry Stogov
5820be029a 0.0 / 0.0 = NaN 2015-04-06 22:03:44 +03:00
Anatol Belski
f0c533f421 fix build 2015-04-06 13:56:47 +02:00
Dmitry Stogov
cae0147ed3 Fixed weird operators behavior. Division by zero now emits warning and returns +/-INF, modulo by zero and intdid() throws an exception, shifts by negative offset throw exceptions. Compile-time evaluation of division by zero is disabled. 2015-04-06 14:30:05 +03:00
Dmitry Stogov
53d20140fb Fixed performance degradation introduced with lateast EnfineException related changes.
Restore original errors order in executor.
2015-04-02 03:56:42 +03:00
Dmitry Stogov
ec760d8fff Convert fatal errors into EngineExceptions 2015-04-01 20:01:57 +03:00
Dmitry Stogov
780a8123fe Convert fatal errors into EngineExceptions 2015-04-01 16:48:15 +03:00
Dmitry Stogov
e8672deefc Convert "Unsupported operands" fatal error into EngineException (exceptions can't be thrown at compile-time yet, so unsuported operands in constant expressions are still lead to fatal error). 2015-03-31 13:25:26 +03:00
Dmitry Stogov
0ce7b4c8c6 Removed unused functions 2015-03-24 23:40:20 +03:00
Dmitry Stogov
d146d15003 Optimize zend_string_realloc() add more specialized versions zend_string_extend() and zend_string_truncate() 2015-03-20 02:02:42 +03:00
Dmitry Stogov
4d4a5336f1 Embed "fast" operator functions (add, sub, increment, etc) into executor with additional optimizations 2015-03-17 18:53:19 +03:00
Dmitry Stogov
f42ebdd4e9 Fixed inconsistency 2015-03-14 15:11:55 +03:00
Dmitry Stogov
db10b72523 Use fastcall calling convention for most critical ZE subsystems. 2015-03-13 21:10:09 +03:00
Dmitry Stogov
716da71446 Don't inline slow path 2015-02-26 01:28:47 +03:00
Dmitry Stogov
e10e151e9b Merged zend_array and HashTable into the single data structure.
Now each HashTable is also zend_array, so it's refcounted and may be a subject for Copy on Write
zend_array_dup() was changed to allocate and return HashTable, instead of taking preallocated HashTable as argument.
2015-02-13 22:20:39 +03:00
Nikita Popov
d133e68bab Remove support for hex number from is_numeric_string 2015-01-28 22:54:17 +01:00
Nikita Popov
6093c9370b Fix resource leak when casting to string 2015-01-24 23:18:26 +01:00
Xinchen Hui
fc33f52d8c bump year 2015-01-15 23:27:30 +08:00
Dmitry Stogov
90c20b4c24 Fixed typo 2015-01-14 21:09:06 +03:00
Dmitry Stogov
2325758624 Improve "instanceof". Interfaces of the left operand should be checked only if the right operand is interafce itself. 2015-01-14 15:06:26 +03:00
Xinchen Hui
2d8fd4b335 Add hinting 2015-01-12 22:06:40 -05:00
Xinchen Hui
2f1ddff2a5 Faster strrpos implementation 2015-01-12 17:24:37 +08:00
Xinchen Hui
31817447cc Faster zend_memnstr for long text 2015-01-12 15:34:46 +08:00
Stanislav Malyshev
b7a7b1a624 trailing whitespace removal 2015-01-10 15:07:38 -08:00
Nikita Popov
3e826c9736 Fix the same leak with %= 2015-01-07 23:21:12 +01:00
Nikita Popov
98c2ceacf8 Fix leak for compound shift self-assign error cases 2015-01-07 23:13:45 +01:00
Dmitry Stogov
c42ac09518 Added new API function 'zend_string* zend_string_tolower(zend_string*)'.
It simplifies code and avoids unnecessary allocation and copying if string is already in lower case.
2014-12-24 15:04:51 +03:00
Xinchen Hui
4b26c5d004 Please becareful with the tailed space after slash 2014-12-22 22:59:17 -05:00
Andrea Faulds
b2853e7494 share that hunk of code 2014-12-23 01:51:19 +00:00
Xinchen Hui
b5b617674e Micro optimaztion (yeah, I know compiler supposed to do that) 2014-12-22 00:10:46 -05:00
Xinchen Hui
c24125e2f9 Micro optimization 2014-12-21 23:16:25 -05:00
Xinchen Hui
201e1b8a8d Micro optimizations 2014-12-21 22:35:25 -05:00
Andrea Faulds
e5eb9530ab Use "float" and "integer" in typehint and zpp errors 2014-12-21 13:23:02 +00:00
Anatol Belski
a857f3a147 Merge remote-tracking branch 'origin/master' into native-tls
* origin/master:
  Fix bug #67106 split main fpm config
  split fpm config to two parts. PR#903
  fix typo
  Fix undefined behaviour in strnatcmp
  Fix undefined behaviour in strnatcmp
  Fixed memory leak introduced by 73458e8f
  update NEWS
  move the test to the right place
  Fixed bug #68545 NULL pointer dereference in unserialize.c
2014-12-14 19:44:24 +01:00
Anatol Belski
bdeb220f48 first shot remove TSRMLS_* things 2014-12-13 23:06:14 +01:00
Andrea Faulds
8c99b65c4d Fixed memory leak introduced by 73458e8f 2014-12-13 21:11:09 +00:00
Dmitry Stogov
2ea5f7aea4 Removed unused variables 2014-12-12 08:09:42 +03:00
Dmitry Stogov
73458e8f19 Replaced zendi_convert_to_long() with _zval_get_long_func() 2014-12-11 15:01:06 +03:00
Dmitry Stogov
27dc5986df Moved zend_is_true() from zend_execute.h/zend_execute_API.c into zend_operators.h/zend_operators.c.
Splited the most expensive part of inline i_zend_is_true() into a separate zend_object_is_true().
Replaced zendi_convert_to_long() with cals to zend_is_true().
2014-12-11 13:18:40 +03:00
Dmitry Stogov
5ba4ae7f67 Move checks for references into slow paths of operator functions. Remove duplicate opcode handlers. 2014-12-06 02:14:45 +03:00
Anatol Belski
ac964fbe30 fix datatype mismatches 2014-10-27 16:38:41 +01:00
Xinchen Hui
c584798b05 Useless assignment 2014-10-22 17:30:19 +08:00
Dmitry Stogov
089f496799 Moved proxy object support in ASSIGN_ADD (and family) from VM to slow paths of corresponding operators 2014-10-21 03:24:20 +04:00
Anatol Belski
c1e92d9fed fix C89 compat 2014-09-25 20:28:34 +02:00
krakjoe
eabad90acb fix indentation 2014-09-25 16:31:39 +01:00
krakjoe
abdc8c3061 fix zts build 2014-09-25 16:15:02 +01:00
Dmitry Stogov
8b034ec69a Optimized (PRE|POST)_(INC|DEC) handlers. Moved proxy object handling into helper function. 2014-09-25 13:42:46 +04:00
Xinchen Hui
e029042c36 It is not likely a string 2014-09-23 13:50:00 +08:00
Andrea Faulds
12b15e5ca4 Merge branch 'master' into integer_semantics 2014-09-21 00:29:48 +01:00
Nikita Popov
31e842472f Make number printing functions less generic
Now that zend_ulong is 64bit on 64bit platforms, it should be
sufficient to always use it, rather than supporting multiple
types.

API changes:
 * _zend_print_unsigned_to_buf and _zend_print_signed_to_buf
   no longer exist.
 * smart_str(ing)_print_long and smart_str(ing)_print_unsigned
   no longer exist.
 * Instead of all these, zend_print_ulong_to_buf and
   zend_print_long_to_buf should be used.
 * smart_str_append_generic_ex no longer exists.
 * smart_str(ing)_append_off_t(_ex) no longer exists, use
   smart_str(ing)_append_long(_ex) instead.
2014-09-19 23:39:07 +02:00
Dmitry Stogov
3bc8a958c5 Fixed useless or duplicated IS_INTERNED() checks 2014-09-19 15:41:01 +04:00
Dmitry Stogov
db6306dd0e Split is_numeric_string_ex() into inline and non-inline parts 2014-09-18 22:19:51 +04:00
Andrea Faulds
db72160e5a Merge branch 'master' into integer_semantics
Conflicts:
	Zend/zend_operators.h
2014-09-16 13:45:06 +01:00
Andrea Faulds
be88d0e5d4 Use SIZEOF_ZEND_LONG instead of SIZEOF_LONG 2014-09-16 10:24:33 +01:00
Dmitry Stogov
d17487f827 We don't have to check for undefined CV if we fetch it for isset() operation 2014-09-16 09:15:47 +04:00
Nikita Popov
29397f8fd2 Fix $x .= $x
Also add a nice comment pointing out that concat runs on magic.
2014-09-06 12:26:41 +02:00
Nikita Popov
828fe35381 Fix string increment 2014-09-05 12:45:42 +02:00
Nikita Popov
08ca9e6d11 Fix overflow check for string concatenation
Also do the overflow check for both branches, not just the realloc
one.

And clean up the code a bit - move common parts outside of the
realloc/alloc branches.
2014-09-05 11:58:32 +02:00
Nikita Popov
f915b44070 Remove old zend_string_to_double function 2014-09-05 11:20:06 +02:00
Anatol Belski
d7700588a9 use portable strtol 2014-09-02 15:56:15 +02:00
Dmitry Stogov
b1f53ca415 Use efree_size() instead of efree() where posible 2014-08-27 20:49:56 +04:00
Nikita Popov
28e7beea66 Fix zend_longo_str 2014-08-25 22:47:04 +02:00
Anatol Belski
af59e92b24 master renames phase 7 2014-08-25 21:51:49 +02:00
Anatol Belski
455741fce3 master renames phase 4 2014-08-25 20:57:25 +02:00
Anatol Belski
4d997f63d9 master renames phase 3 2014-08-25 20:22:49 +02:00
Anatol Belski
6f9f0bf205 master renames phase 2 2014-08-25 19:28:33 +02:00
Anatol Belski
c3e3c98ec6 master renames phase 1 2014-08-25 19:24:55 +02:00
Anatol Belski
70de6180d5 fixes to %pd format usage 2014-08-24 02:35:34 +02:00
Andrea Faulds
b3ba0f6ab0 Prevent bit shift count wrapping quirkiness on some CPUs for left shift 2014-08-19 20:21:23 +01:00
Andrea Faulds
38bc0a05c0 Prevent bit shift count wrapping quirkiness on some CPUs for right shift 2014-08-19 20:21:23 +01:00
Andrea Faulds
6a94568f82 Return FALSE on bit shift by negative number 2014-08-19 20:21:22 +01:00
Anatol Belski
f2182ab845 some more pure naming replacements 2014-08-17 21:16:27 +02:00
Anatol Belski
864172d9a4 further fixes to ext/standard and zend 2014-08-16 17:31:40 +02:00
Anatol Belski
8ee2a4a9b5 first shot on merging the core fro the int64 branch 2014-08-16 11:16:11 +02:00
Dmitry Stogov
6463bc5b55 Fixed mode 2014-08-14 23:54:32 +04:00
Dmitry Stogov
c78a1734c2 Fixed compilation warnings 2014-08-14 23:53:27 +04:00
Dmitry Stogov
e430948581 Fixed reference handling 2014-08-14 15:07:39 +04:00
krakjoe
1d01e2334c fix incorrect cast of comparison function and signature of function 2014-08-11 06:47:09 +01:00
krakjoe
dc70139d85 update zend_make_printable_zval to take TSRM context 2014-08-11 06:09:46 +01:00