Commit Graph

1035 Commits

Author SHA1 Message Date
Dmitry Stogov
b3b616cf7e Introduced immutable arrays. They don't need to be copyed and may be used directly from SHM. 2014-05-29 18:21:56 +04:00
Nikita Popov
47e85b1b35 Improve class constant fetch fix
Dereference the cached constant for Test::TEST as well (and not just
self::TEST).

Also improve the phpt file to test this case as well - previously
this only manifested with opcache enabled, due to literal sharing.

Additionally the Z_TYPE_P != IS_REFERENCE assertion is now moved
into the TMP_VAR fetching code (as it applies to more than just
property assignments.)
2014-05-29 11:17:33 +02:00
Nikita Popov
d9a35c7e97 Fix class constant fetching
If a class is extended after the constant fetch has been cached
the cached value will be turned into a reference. On the next
fetch the polymorphic cache will return this reference, which
will be directly returned. The object assignment code then
dereferences this result and performs a shallow copy, which is
invalid for references. This subsequently leads to the constant
value being prematurely freed.

This is fixed by dereferencing the value returned from the
polymorphic cache. Furthermore the incorrect dereference from
in the object assignment code is replaced with an assertion that
we're dealing with a non-reference, so ensure that this kind of
problem cannot go unnoticed in the future.
2014-05-29 00:15:50 +02:00
Dmitry Stogov
e34a6e9211 Use new zend_hash API 2014-05-27 00:38:58 +04:00
Dmitry Stogov
40256e0f9c Use specialized functions instead of macros 2014-05-26 17:16:16 +04:00
Xinchen Hui
c2082ece52 Fixed apply_func_t (they should be broken before) 2014-05-25 18:32:35 +08:00
Nikita Popov
65f488ece3 Add STR_ALLOCA_* API, use in get_method and verify_arg
This avoid unnecessary allocations when using dynamic method
dispatch and class typehints.

Probably there are other places where this should be done as well,
those just stood out for my usage.
2014-05-03 10:43:45 +02:00
Dmitry Stogov
17d027ed47 Split IS_BOOL into IS_FALSE and IS_TRUE 2014-04-30 18:32:42 +04:00
Dmitry Stogov
6a911e833f Optimized JMPZNZ to avoid multiplication at runtime (may be it makes sense to use relative addresses everywere it'll lead to Position Independent Code) 2014-04-30 11:23:19 +04:00
Dmitry Stogov
f9927a6c97 Merge mainstream 'master' branch into refactoring
During merge I had to revert:
	Nikita's patch for php_splice() (it probably needs to be applyed again)
	Bob Weinand's patches related to constant expression handling (we need to review them carefully)
	I also reverted all our attempts to support sapi/phpdbg (we didn't test it anyway)

Conflicts:
	Zend/zend.h
	Zend/zend_API.c
	Zend/zend_ast.c
	Zend/zend_compile.c
	Zend/zend_compile.h
	Zend/zend_constants.c
	Zend/zend_exceptions.c
	Zend/zend_execute.c
	Zend/zend_execute.h
	Zend/zend_execute_API.c
	Zend/zend_hash.c
	Zend/zend_highlight.c
	Zend/zend_language_parser.y
	Zend/zend_language_scanner.c
	Zend/zend_language_scanner_defs.h
	Zend/zend_variables.c
	Zend/zend_vm_def.h
	Zend/zend_vm_execute.h
	ext/date/php_date.c
	ext/dom/documenttype.c
	ext/hash/hash.c
	ext/iconv/iconv.c
	ext/mbstring/tests/zend_multibyte-10.phpt
	ext/mbstring/tests/zend_multibyte-11.phpt
	ext/mbstring/tests/zend_multibyte-12.phpt
	ext/mysql/php_mysql.c
	ext/mysqli/mysqli.c
	ext/mysqlnd/mysqlnd_reverse_api.c
	ext/mysqlnd/php_mysqlnd.c
	ext/opcache/ZendAccelerator.c
	ext/opcache/zend_accelerator_util_funcs.c
	ext/opcache/zend_persist.c
	ext/opcache/zend_persist_calc.c
	ext/pcre/php_pcre.c
	ext/pdo/pdo_dbh.c
	ext/pdo/pdo_stmt.c
	ext/pdo_pgsql/pgsql_driver.c
	ext/pgsql/pgsql.c
	ext/reflection/php_reflection.c
	ext/session/session.c
	ext/spl/spl_array.c
	ext/spl/spl_observer.c
	ext/standard/array.c
	ext/standard/basic_functions.c
	ext/standard/html.c
	ext/standard/mail.c
	ext/standard/php_array.h
	ext/standard/proc_open.c
	ext/standard/streamsfuncs.c
	ext/standard/user_filters.c
	ext/standard/var_unserializer.c
	ext/standard/var_unserializer.re
	main/php_variables.c
	sapi/phpdbg/phpdbg.c
	sapi/phpdbg/phpdbg_bp.c
	sapi/phpdbg/phpdbg_frame.c
	sapi/phpdbg/phpdbg_help.c
	sapi/phpdbg/phpdbg_list.c
	sapi/phpdbg/phpdbg_print.c
	sapi/phpdbg/phpdbg_prompt.c
2014-04-26 00:32:51 +04:00
Dmitry Stogov
4e7cbf3f58 Use appropriate macros 2014-04-25 11:54:10 +04:00
Dmitry Stogov
65e2ed6e50 Redesigned zend_execute_data layout now EX(object), EX(scope) and EX(called_scope) arr properties of the current function execution co
ntext. They are set during zend_execute_data initialization and never changed.
2014-04-24 15:53:20 +04:00
Dmitry Stogov
5864ce8a44 Fixed compilation warnings 2014-04-22 17:46:34 +04:00
Dmitry Stogov
fd24614cd9 Inline simple function 2014-04-21 15:18:05 +04:00
Dmitry Stogov
ea2e1bb1eb Optimized zend_leave_helper() 2014-04-18 13:46:36 +04:00
Dmitry Stogov
5c02e0fc5f Cache op_array->run_time_cache in zend_execute_data for faster access 2014-04-17 16:36:04 +04:00
Dmitry Stogov
e96073b1e4 Moved zend_literal->cache_slot right into zval.
It should be accessed using Z_CACHE_SLOT() macro.
zend_literal structure is removed.
API functions that accepted pointer to zend_literal now accept pointer to zval or cache_slot directly.
Calls of such functiond that now accept cache_slot need to be changed to pass -1 instead of NULL.
2014-04-17 15:40:45 +04:00
Dmitry Stogov
6976eb2919 Fixed support for unspecialized and GOTO and SWITCH executor 2014-04-17 02:12:06 +04:00
Dmitry Stogov
f9b26bc39a Cleanup (2-nd round) 2014-04-15 21:56:30 +04:00
Dmitry Stogov
050d7e38ad Cleanup (1-st round) 2014-04-15 15:40:40 +04:00
Nikita Popov
2c6ee5dcb5 Fix argument unpacking 2014-04-11 19:53:14 +02:00
Bob Weinand
ee2a7c7d41 Fixed disallowal of array usage in constants at run-time
Added at the same time the possibility of array dereferencing
to complete the set of features (useful application of arrays in constants)
2014-04-11 18:21:46 +02:00
Nikita Popov
f449b04713 Fix some ZTS issues and leaks 2014-04-10 13:50:25 +02:00
Dmitry Stogov
29f068779f Fixed ext/spl/tests/iterator_035.phpt 2014-04-09 23:49:58 +04:00
Dmitry Stogov
8732f5e5d7 Removed useless code 2014-04-09 17:55:40 +04:00
Dmitry Stogov
3d0b32b3db IS_CONST can't be a reference 2014-04-08 00:52:07 +04:00
Dmitry Stogov
f3c57716f7 Optimized ZEND_FETCH_R and family 2014-04-08 00:38:54 +04:00
Dmitry Stogov
df7293b072 don't use memset() for array of zval initialization 2014-04-07 12:14:44 +04:00
Dmitry Stogov
a80e945835 Optimized ZEND_FETCH_DIM_* 2014-04-05 01:56:51 +04:00
Dmitry Stogov
c11dc75b4e Refactored IS_INDIRECT IS_VAR passing between opcodes to avoid reference counting 2014-04-04 19:01:53 +04:00
Dmitry Stogov
eaeb3c39b4 Optimized RECV_* opcodes 2014-04-04 14:36:34 +04:00
Dmitry Stogov
58f0f2503c Various VM optimizations 2014-04-04 02:52:53 +04:00
Dmitry Stogov
58871730c8 ASSIGN_REF optimization 2014-04-03 16:53:30 +04:00
Dmitry Stogov
76cc99fe60 Refactored ZVAL flags usage to simplify various checks (e.g. Z_REFCOUNTED(), candidate for GC, etc) 2014-04-03 15:26:23 +04:00
Dmitry Stogov
d8099d0468 Changed data layout to allow more efficient operations 2014-04-02 14:34:44 +04:00
Dmitry Stogov
8dedaf8512 Use interned strings for one character strings 2014-04-01 18:06:50 +04:00
Dmitry Stogov
a25a1ba0ef STR_DUP() doesn't duplicate interned strings anymore. In case new string is required STR_INIT() or STR_ALLOC() should be used. 2014-04-01 16:31:03 +04:00
Dmitry Stogov
ea85451b65 Refactored data structures to keep zend_object* instead of a whole zval in some places 2014-03-28 02:11:22 +04:00
Dmitry Stogov
9a8fbdf2f4 Use CV variable offset instead of CV variable number 2014-03-27 16:00:25 +04:00
Dmitry Stogov
d83d34ba6d Cleanup 2014-03-27 14:55:52 +04:00
Dmitry Stogov
c6cba55454 Use ZVAL_DEREF() macro 2014-03-27 13:39:09 +04:00
Dmitry Stogov
54d559d893 Replaced (Z_TYPE(x) == IS_REFERENCE) with (Z_ISREF(x)) 2014-03-27 11:50:45 +04:00
Dmitry Stogov
36f24c512e Inlined "slow" CV lookup code (now it's cheap)
Removed expectations for undefined CV acess for BP_VAR_W and BP_VAR_IS modes
2014-03-27 11:19:34 +04:00
Dmitry Stogov
887189ca31 Refactored IS_INDIRECT usage for CV and object properties to support HashTable resizing 2014-03-26 18:07:31 +04:00
Dmitry Stogov
130e48d375 Typo 2014-03-21 16:37:53 +04:00
Dmitry Stogov
37db857734 Fixed CV IS_INDIRECT support 2014-03-21 15:43:53 +04:00
Dmitry Stogov
2f4e8aa5d7 Fixed refcounting 2014-03-21 11:33:20 +04:00
Dmitry Stogov
e884d5d8e3 Fixed assignment reference to itself 2014-03-19 22:43:06 +04:00
Dmitry Stogov
b7938ab1bd Refactored GC (incomplete) 2014-03-19 17:00:28 +04:00
Dmitry Stogov
aa5f55306b Refactored EG(active_symbol_table) to be zend_array* instead of HashTable* 2014-03-17 23:15:22 +04:00
Dmitry Stogov
b8089696c4 Fixed support for references 2014-03-13 22:56:18 +04:00
Dmitry Stogov
918866da5f Fixed autoconversion from reference to ordinal value 2014-03-13 14:24:08 +04:00
Dmitry Stogov
e0dd8a4f4b Fixed IS_INDIRECT handling when assign array element by reference.
This might cause passing invalid pointer if the array could be resized before IS_INDIRECT usage.
Now we use IS_REFERENCE instead of IS_INDIRECT.
The following test crashed before:
<?php $a = array(0,1,2,3,4,5,6,7); $a[8] = &$a[7]; ?>
2014-03-13 00:30:53 +04:00
Xinchen Hui
53e312c663 Review ended
Revert "An demo(for review) to show how to fix the problem(symbol table resize)"

This reverts commit 60c354510b.
2014-03-11 14:23:14 +08:00
Xinchen Hui
60c354510b An demo(for review) to show how to fix the problem(symbol table resize) 2014-03-10 16:25:05 +08:00
Xinchen Hui
80625f20e5 Revert "An demo(for review) to show how to fix the problem we meet"
This reverts commit 4aeae15706.
2014-03-10 16:24:35 +08:00
Xinchen Hui
4aeae15706 An demo(for review) to show how to fix the problem we meet 2014-03-10 11:29:28 +08:00
Dmitry Stogov
7cd78822ab Fixed assignment to reference 2014-03-08 00:02:12 +04:00
Xinchen Hui
7003e76512 Fixed numeric string handling length 2014-03-07 14:35:14 +08:00
Dmitry Stogov
9ed631a4d0 Fixed ArrayAccess behavior 2014-03-06 17:59:17 +04:00
Dmitry Stogov
9727b47418 Fixed ArrayAccess handling 2014-03-06 13:11:23 +04:00
Dmitry Stogov
3733737328 Handle interned strings as non-refcounted scalars 2014-03-05 13:55:56 +04:00
Dmitry Stogov
38151a38ec Fixed dereferencing of value returned from function (foo()[1] = ...) 2014-03-04 17:23:23 +04:00
Dmitry Stogov
ba30f1e946 Fixed assign by reference 2014-03-04 17:04:46 +04:00
Dmitry Stogov
dbb6837627 EG(error_zval) must be passed as IS_INDIRECT 2014-03-04 16:32:40 +04:00
Dmitry Stogov
1be0df935f Fixed destruction of VM handler operands (FREE_OP1 and family) 2014-03-04 12:27:50 +04:00
Dmitry Stogov
53128644f3 Redesigned SRR_OFFSET handling 2014-02-28 17:39:08 +04:00
Dmitry Stogov
855a030b7b Fixed return value handling in ZEND_ASSIGN_OBJ 2014-02-28 10:41:28 +04:00
Dmitry Stogov
08da14adac Fixed support for IS_REFERENCE 2014-02-28 00:21:12 +04:00
Dmitry Stogov
5e4a97f365 Fixed ASSIGN_OBJ with IS_TMP and IS_CONST operand 2014-02-27 22:53:56 +04:00
Dmitry Stogov
0e44e0611d Fixed ASSIGN of IS_REFERENCE (it should be separated) 2014-02-27 22:16:15 +04:00
Dmitry Stogov
1c3ba95bb5 Refactored read_property() and read_dimension() handlers 2014-02-27 15:40:13 +04:00
Nikita Popov
95c73f99d3 Don't add num_additional_args in SEND opcodes
Now that trailing positional args are disallowed,
num_additional_args will always be zero in SEND opcodes (and
FUNC_ARG fetches).
2014-02-26 16:40:25 +01:00
Dmitry Stogov
d062fb3344 Generator related fixes 2014-02-26 13:58:59 +04:00
Dmitry Stogov
329a576f39 Fixed EG(error_zval) handling 2014-02-25 23:39:25 +04:00
Dmitry Stogov
068ea84a84 THIS MAY BE A REAL PROBLEM 2014-02-25 16:38:18 +04:00
Dmitry Stogov
fea971e1e4 Better IS_REFERENCE handling 2014-02-25 00:17:13 +04:00
Dmitry Stogov
55bca5868a Fixed $this handling 2014-02-24 17:07:44 +04:00
Dmitry Stogov
a3448b7cfa Support for IS_REFERENCE 2014-02-24 16:51:38 +04:00
Dmitry Stogov
844887ed56 Fixed IS_RESOURCE handling 2014-02-24 13:12:53 +04:00
Dmitry Stogov
f1dcbf4750 ASSIGN_REF related fixes 2014-02-24 12:15:11 +04:00
Dmitry Stogov
52bd62eca8 Fixed assertions 2014-02-21 20:35:40 +04:00
Xinchen Hui
47fb198533 Revert "Use zend_string for arg_info to fixed segfault in Zend/tests/argument_restriction_003.phpt"
This reverts commit b96318105b.
2014-02-21 23:02:24 +08:00
Xinchen Hui
b96318105b Use zend_string for arg_info to fixed segfault in Zend/tests/argument_restriction_003.phpt 2014-02-21 22:34:30 +08:00
Xinchen Hui
b917458490 Fixed segfault (Zend/tests/026.phpt now pass) 2014-02-20 15:39:46 +08:00
Dmitry Stogov
9067dbcd0d Use better data structures (incomplete) 2014-02-19 12:03:01 +04:00
Dmitry Stogov
557994d50d Use better data structures (incomplete) 2014-02-19 01:12:05 +04:00
Dmitry Stogov
bb58ea348c Use better data structures (incomplete) 2014-02-18 18:10:54 +04:00
Dmitry Stogov
5de7115679 Use better data structures (incomplete; able to run bench.php) 2014-02-18 16:27:38 +04:00
Dmitry Stogov
1c4f3d39a8 Use better data structures (incomplete) 2014-02-18 11:44:58 +04:00
Dmitry Stogov
a0fe8e5a91 Use better data structures (incomplete) 2014-02-18 01:41:23 +04:00
Dmitry Stogov
2b9b9afa7a Use better data structures (incomplete) 2014-02-17 17:59:18 +04:00
Dmitry Stogov
4e66abad54 Use better data structures (incomplete) - refactored return_value handling 2014-02-12 14:29:51 +04:00
Dmitry Stogov
f4cfaf36e2 Use better data structures (incomplete) 2014-02-10 10:04:30 +04:00
Nikita Popov
31a2ac470c Fix argument unpacking across stack pages
If multiple unpacks were used (or mixed with normal arguments)
parts of the arguments could land on different stack pages. If
this occurs the arguments will now be copied to a new stack page.

The code used to do this is copied verbatim from the PHP 5.4 branch
and only modified to reduce the amount of inlined code.
2014-01-18 14:41:33 +01:00
Bob Weinand
69edad213a Fixed build (making zend_is_by_ref_func_arg_fetch function static) 2014-01-12 01:59:22 +01:00
Nikita Popov
2c47dfbaeb Implement argument unpacking
RFC: https://wiki.php.net/rfc/argument_unpacking
2014-01-11 12:42:08 +01:00
Xinchen Hui
c081ce628f Bump year 2014-01-03 11:08:10 +08:00
Xinchen Hui
794a888a48 Fixed bug #65784 (Segfault with finally). 2013-12-13 00:16:08 +08:00
Dmitry Stogov
43e3933fa3 Removed deprecated AI_SET_PTR()s 2013-11-27 20:30:35 +04:00