Commit Graph

1916 Commits

Author SHA1 Message Date
Dmitry Stogov
67b4c3379a Uze ZVAL_COPY_DEREF() instead of ZVAL_DEREF() and ZVAL_COPY() 2018-07-09 12:46:46 +03:00
Xinchen Hui
9d1e9b73c5 rename ref_dtor_func to rc_dtor_func 2018-07-06 19:15:26 +08:00
Xinchen Hui
f9297387f4 Rename zval_dtor_func and ref_dotr_func 2018-07-06 18:47:30 +08:00
Xinchen Hui
e3355ac5ec Revert "Rename _zval_dtor_func to _ref_dtor_func"
This reverts commit a362ae6b12.
2018-07-06 18:37:45 +08:00
Xinchen Hui
a362ae6b12 Rename _zval_dtor_func to _ref_dtor_func 2018-07-06 18:32:27 +08:00
Dmitry Stogov
dcf7592076 Optimize array to object casting 2018-07-06 03:10:05 +03:00
Dmitry Stogov
85b2bc38e1 Optimize object to array casting 2018-07-06 01:25:24 +03:00
Dmitry Stogov
3a8f26060c Argument unpacking with Traversables and non-integer keys.
Changed error message, added UPGRADING note and test.
2018-07-04 22:34:36 +03:00
Dmitry Stogov
af341213f7 se zval_ptr_dtor_str() instead of zend_string_release_ex(Z_STR(*), 0) 2018-07-04 12:08:07 +03:00
Dmitry Stogov
d84ef96742 SEND_UNPACK should throw exception on Traversable with non-integer keys 2018-07-04 09:35:12 +03:00
Dmitry Stogov
7eb045d31a API cleanup. Removed unused functions (kept compatibility macros). 2018-07-04 00:50:57 +03:00
Dmitry Stogov
004a0568f4 Eliminated REFCOUNTED checks on persistent constant operands in SEND_VAL[_EX] and QM_ASSIGN. 2018-07-03 13:10:22 +03:00
Dmitry Stogov
177c7e3a72 Merge branch 'bug63217'
* bug63217:
  Another fix for bug #63217
  Partial revert of 30156d588c
2018-07-03 12:58:50 +03:00
Dmitry Stogov
3fd97a5b1f Better hot/cold code splitting 2018-07-03 11:07:39 +03:00
Dmitry Stogov
28b03f9605 Another fix for bug #63217 2018-07-03 01:09:58 +03:00
Dmitry Stogov
57af94c8b9 Partial revert of 30156d588c 2018-07-02 20:54:44 +03:00
Rudi Theunissen
30156d588c Fixed bug #63217
Don't automatically convert literal string keys to integers on
array access, as we may be dealing with an ArrayAccess object,
rather than a plain array.
2018-07-02 16:41:59 +02:00
Dmitry Stogov
d6ab163be8 cleanup 2018-06-29 12:35:14 +03:00
Dmitry Stogov
56450c6e65 Moved very rare exception check into a single place. 2018-06-27 13:34:15 +03:00
Xinchen Hui
3d8c82c353 Merge branch 'PHP-7.2'
* PHP-7.2:
  Update NEWS
  Fixed bug #76534 (PHP hangs on 'illegal string offset on string references with an error handler)

Conflicts:
	Zend/zend_vm_execute.h
2018-06-27 13:08:47 +08:00
Xinchen Hui
3521661bd1 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fixed bug #76534 (PHP hangs on 'illegal string offset on string references with an error handler)

Conflicts:
	Zend/zend_execute.c
	Zend/zend_vm_def.h
	Zend/zend_vm_execute.h
2018-06-27 13:07:36 +08:00
Xinchen Hui
d1b1866a3a Fixed bug #76534 (PHP hangs on 'illegal string offset on string references with an error handler) 2018-06-27 13:05:11 +08:00
Dmitry Stogov
7f67513ca3 Lazy function copying from op_cache SHM into process memory 2018-06-25 19:53:58 +03:00
Nikita Popov
61d00a6cf3
Use COPY_DEREF instead of COPY_UNREF
This fixes the behavior when the storage location of the fetch is
modified before the operand is dereferenced by the using VM opcode.

Furthermore it elimiates references as a possible return value from
*_R opcodes, which will give us more opportunities for inferences,
in particular in regard to typed properties.
2018-06-25 11:23:59 +02:00
Dmitry Stogov
4418d61ca3 Avoid reusing zend_function.common.prototype for magic things (use reserved fields instead). 2018-06-21 13:09:25 +03:00
Nikita Popov
0b04938c87 Fix unspecialized executor
If we conditionally fetch a value, we also need to conditionally
free it.
2018-06-14 23:26:27 +02:00
Nikita Popov
95a0709935 Fix handling of ERROR zval in op1 of ASSIGN_REF
If op1 is ERROR the behavior is to not perform any assignment and
return NULL. However, if the RHS was a by-value returning function,
we'd instead emit a notice and return the RHS as the return value
(even though the value was not assigned to anything -- the temporary
is immediately destroyed).

This normalized the behavior to always check for an ERROR in op1
first.
2018-06-09 21:31:30 +02:00
Nikita Popov
d877d18676 Error on by-ref assign to overloaded prop returning ref
This error was already thrown if __get() was used -- however not
if it returned by reference. This is incorrect, because the
reference return makes no difference to a by-reference assignment,
which has reference-breaking semantics. The result was that the
assignment was accepted silently, even though it didn't do anything
(not even the value was assigned, let alone the reference).
2018-06-09 18:42:22 +02:00
Dmitry Stogov
1597b56619 Inline few small opcode handlers into hybrid executor 2018-06-07 16:30:53 +03:00
Dmitry Stogov
59c2ff2543 Embed zend_leave_helper() into hybrid executor to avoid call overhead. 2018-06-05 11:33:19 +03:00
Dmitry Stogov
b6a2ae3a5b Cleanup 2018-06-05 11:26:15 +03:00
Dmitry Stogov
9e0f131d2b Fixed ISSET/ISEMPTY bit meaning to simplify run-time checks 2018-05-31 19:02:51 +03:00
Dmitry Stogov
84aab1d4e1 Marked rarely used opcodes as "cold" (e.g. ADD_CONST_CONST ususaly optimized out). 2018-05-30 01:50:44 +03:00
Dmitry Stogov
da5a44c1c0 Revert "Avoid reference-counting"
This reverts commit ea26ab3393.
2018-05-29 18:04:16 +03:00
Anatol Belski
6f4a01da21 Fix build without global registers 2018-05-28 20:44:58 +02:00
Dmitry Stogov
c27dda709c Removed dead code 2018-05-28 18:29:43 +03:00
Dmitry Stogov
c9df8ac6c5 Separate common code into helper function 2018-05-28 18:11:43 +03:00
Dmitry Stogov
ea26ab3393 Avoid reference-counting 2018-05-28 17:10:58 +03:00
Dmitry Stogov
5eb1f92f31 Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence. 2018-05-28 16:27:12 +03:00
Dmitry Stogov
e9e2d068b6 Fixed conditions 2018-05-14 17:23:37 +03:00
Dmitry Stogov
b8a91ac50b Use "fastcall" calling convention 2018-05-08 01:31:49 +03:00
Dmitry Stogov
1a63fa6ec9 Implemented Request #76178 (Class constants are slow: they should be inlined at runtime)
Run-time cache is used to eliminate recalculation of constant expression in RECV_INIT opcode (only non reference countable values are cached).
2018-05-03 14:40:18 +03:00
Dmitry Stogov
c88be6aee1 Bit check micro-optimization 2018-04-28 14:13:12 +03:00
Dmitry Stogov
d4aba32d8c Cache negative defined() results 2018-03-30 16:41:02 +03:00
Dmitry Stogov
4aa9505b6e Merge identical handlers 2018-03-29 11:13:17 +03:00
Dmitry Stogov
91ba1f2085 Remove "hot" mark from JMP(Z|NZ|ZNZ) with IS_CONST operand 2018-03-23 16:11:27 +03:00
Dmitry Stogov
295b233bfd Mark few more opcode handlers as "hot". 2018-03-23 13:59:47 +03:00
Dmitry Stogov
a795bd8265 Optimize zend_hash_real_init() 2018-03-23 00:13:45 +03:00
Dmitry Stogov
e791e93b55 Make ZEND_ISSET_ISEMPTY_CV specialised across ISSET/ISEMPTY and HOT (the handler is really small, so inlining affects executor size insignificantly) 2018-03-22 13:03:45 +03:00
Dmitry Stogov
e6c179834b Allow extra specialisation for ISSET/ISEMPTY handlers 2018-03-22 13:02:49 +03:00
Dmitry Stogov
1735e29b7f Reduce overhead of extra-specialization for opcode handler selection. 2018-03-22 11:33:17 +03:00
Dmitry Stogov
d7f2dc4ec6 Improve HashTable iterators handling:
- Avoid iterators check/update on each HashTable update opration
- Keep position equal (or above) nNumUsed instead of HT_INVALID_IDX
- Fixed iterators handling in array_unshift()
2018-03-22 02:41:49 +03:00
Dmitry Stogov
9dc6661976 Merge branch 'PHP-7.2'
* PHP-7.2:
  Fixed user-opcode support
2018-03-14 09:41:55 +03:00
Dmitry Stogov
975d144027 Fixed user-opcode support 2018-03-14 09:41:25 +03:00
Dmitry Stogov
a2d1f2df46 Eliminate conditional branches 2018-03-07 00:03:13 +03:00
Dmitry Stogov
6fb9e24218 Allow generation of VM map 2018-02-22 15:31:00 +03:00
Dmitry Stogov
bd908f6145 Fixed build without global register variables 2018-02-22 11:00:29 +03:00
Dmitry Stogov
927748b271 Reorganize make_real_object() related code 2018-02-21 18:43:38 +03:00
Dmitry Stogov
ecb52b8b3b Move exceprional code into helper & zend_fetch_var_address_helper() micro-optimization. 2018-02-21 17:09:42 +03:00
Dmitry Stogov
7559b1c50c Move result address calculation from specialized handlers to less specialized helpers 2018-02-21 16:06:29 +03:00
Dmitry Stogov
9c0427cada Mark exceptional helpers as "cold" 2018-02-21 12:07:29 +03:00
Dmitry Stogov
e1b1cff48d Move exceptional code into helpers 2018-02-21 10:10:04 +03:00
Dmitry Stogov
41eb70a493 Added expectation 2018-02-21 02:49:40 +03:00
Dmitry Stogov
b53f5cc92d Move exceptional code into helpers 2018-02-21 01:27:39 +03:00
Dmitry Stogov
a00286921e Move cold code, duplicated by specializer, into helper functions 2018-02-20 23:44:25 +03:00
Dmitry Stogov
b46f10b43f Fixed build without global register variables 2018-02-20 20:39:02 +03:00
Dmitry Stogov
8b7cdbaa49 Separate slow path with make_real_object() and related code into "cold" function. 2018-02-20 17:22:11 +03:00
Dmitry Stogov
cbf2d91911 Separate cold paths of ISSET_ISEMPTY_DIM_OBJ 2018-02-20 14:42:53 +03:00
Haitao Lv
764e231cc5 fix ZEND_VM_SET_OPCODE_HANDLER cannot set user opcode handler 2018-02-20 10:46:41 +03:00
Dmitry Stogov
050d62484b Fixed typo 2018-02-19 17:57:46 +03:00
Dmitry Stogov
6d3e1bd124 Added VM instrumentation ability 2018-02-19 16:42:02 +03:00
Dmitry Stogov
190a970dd6 Elimintate duplicate error message 2018-02-19 16:11:28 +03:00
Nikita Popov
b0af9ac733 Avoid live range references in opcodes
Don't store the live range of the freed variable for FREE_ON_RETURN
frees, instead look it up at runtime. As this is an extremely
unlikely codepath (in particular, it requires a loop variable with
a throwing destructor), saving the runtime lookup of the live range
is not worth the extra complexity this adds everywhere else.
2018-02-16 21:30:48 +01:00
Nikita Popov
f61c01eeb1 Fix unused variable warning 2018-02-16 15:31:54 +01:00
Dmitry Stogov
b4112ea288 Don't make expectations about non-constant zval refcauntability 2018-02-16 15:37:04 +03:00
Dmitry Stogov
6fadb72c0b Move exceptional code into "cold" helpers 2018-02-16 02:45:31 +03:00
Dmitry Stogov
02aea893fb Use Z_TYPE_INFO_REFCOUNTED() macro 2018-02-15 21:54:49 +03:00
Dmitry Stogov
285bfb96fe Optimize "backup" functions of inlined opcode handlers for size 2018-02-15 17:04:41 +03:00
Dmitry Stogov
633d037ed5 Added simple VM instrumentation ability 2018-02-15 15:55:19 +03:00
Dmitry Stogov
27d7671603 Avoid generation of rarely used specialized handler 2018-02-15 14:50:42 +03:00
Dmitry Stogov
23da83c8ca Avoid inlining of rarely used handlers 2018-02-15 13:48:04 +03:00
Nikita Popov
db2475cec2 Fix unused variable compiler warnings 2018-02-05 20:58:15 +01:00
Nikita Popov
ef20d2990f Remove unnecessary CE_STATIC_MEMBERS() checks
CE_STATIC_MEMBERS(ce) is destroyed after EG(active)=0 is set, so we
should never run into a situation where it is NULL inside the VM.
2018-02-05 18:54:17 +01:00
Dmitry Stogov
752d684971 Removed "dead" code 2018-02-05 20:43:08 +03:00
Dmitry Stogov
ca035f26aa Moved "zval.u2.cache_slot" into free room of "zend_op" 2018-02-05 19:41:47 +03:00
Dmitry Stogov
3a794d39f0 Avoid repeatable ARG_SHOULD_BE_SENT_BY_REF() checks in FETCH_*FUNC_ARG and following SEND_VAR_EX. Perform the check once in a new CHECK_FUNC_ARG opcode and reuse in the following FETCH_*FUNC_ARG and SEND_FUNC_ARG (SEND_VAR_EX replacement). 2018-02-05 19:40:06 +03:00
Nikita Popov
e0171ed9d0 Avoid another unused opline warning
The unconditional opline load here used to be necessary for freeing
the return value in case of exception. However, this is no longer
the case, so using LOAD_OPLINE() should be sufficient now.
2018-02-03 17:43:41 +01:00
Nikita Popov
24e744d8a2 Avoid VM warning if building without global regs 2018-02-03 17:43:41 +01:00
Dmitry Stogov
ba298725d1 Changed CATCH instruction format (extended_value moved into op2, op2 into result, result into extended_value) 2018-01-31 22:39:30 +03:00
Dmitry Stogov
9c7fb529ce Changed FETCH_CONSTANT instruction format (extended_value moved into op1) 2018-01-31 18:15:25 +03:00
Dmitry Stogov
f67f455ef7 Changed FETCH_CLASS instruction format (extended_value moved into op1) 2018-01-31 18:14:43 +03:00
Dmitry Stogov
9701b644fa Compress handlers table 2018-01-31 16:46:30 +03:00
Dmitry Stogov
59ede4c82b Avoid redundand mask extraction 2018-01-31 13:47:43 +03:00
Dmitry Stogov
1d7eab12e6 Avoid redundand mask extraction 2018-01-31 13:34:34 +03:00
Dmitry Stogov
17a3b48454 Make IS_UNUSED to be zero. 2018-01-31 11:18:41 +03:00
Dmitry Stogov
7141631cc8 Change FETCH/ISSET instruction modifiers:
- Get rid of ZEND_ISEMPTY and ZEND_ISSET_ISEMPTY_MASK. Use just single ZEND_ISSET bit to make distinct between isset() and empty()
- Use ZEND_FETCH_GLOBAL, ZEND_FETCH_LOCAL and ZEND_FETCH_GLOBAL_LOCK as bitmask
- Removed unused ZEND_FETCH_STANDARD
- Extended ZEND_FETCH_ARG_MASK
2018-01-30 22:06:05 +03:00
Dmitry Stogov
5e8aa036f2 Access extra data stored in zval through macros 2018-01-23 12:56:22 +03:00
Dmitry Stogov
a87a2f464b Send by reference without duplication 2018-01-17 18:50:18 +03:00
Dmitry Stogov
dd51cb1e34 More effecient array duplication 2018-01-17 17:56:04 +03:00
Dmitry Stogov
0bfc4f34ca Avoid EG(vm_interrupt) check on forward JMP 2018-01-16 13:50:36 +03:00
Dmitry Stogov
267b78550e Use fastcall calling convention 2018-01-16 10:33:41 +03:00
Dmitry Stogov
12c386f5b9 Use ZEND_CLOSURE_OBJECT() macro to resolve closure op_array to closure object through address calculation, instead of op_array->prototype reuse. (reapply 781e1573af, now it should be OK). 2018-01-11 22:15:45 +03:00
Dmitry Stogov
6ba10a03e7 Revert "Use ZEND_CLOSURE_OBJECT() macro to resolve closure op_array to closure object through address calculation, instead of op_array->prototype reuse." (this patch is incomplete or wrong)
This reverts commit 781e1573af.
2018-01-11 17:27:26 +03:00
Dmitry Stogov
781e1573af Use ZEND_CLOSURE_OBJECT() macro to resolve closure op_array to closure object through address calculation, instead of op_array->prototype reuse. 2018-01-11 16:25:28 +03:00
Dmitry Stogov
f09c012ebe Mark FETCH_OBJ_R and INIT_METHOD_CALL as HOT_OBJ for (UNUSED+CONST and CV+CONST) 2018-01-10 19:14:52 +03:00
Dmitry Stogov
94508cdc3f Fixed whitespaces 2018-01-10 02:22:07 +03:00
Nikita Popov
d9c706f28d Merge branch 'PHP-7.2' 2018-01-09 20:25:19 +01:00
Nikita Popov
2dd80a0782 Merge branch 'PHP-7.1' into PHP-7.2 2018-01-09 20:24:48 +01:00
Nikita Popov
fd30c59e04 Fixed bug #75786
SEND_UNPACK on iterators was duplicating references in-place,
which effectively leaks the original value and causes an off-by-one
refcount on the duplicated value.

Replace this with a deref, as an actual duplication is not even
needed in this case.
2018-01-09 20:20:31 +01:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Xinchen Hui
7a7ec01a49 year++ 2018-01-02 12:55:14 +08:00
Xinchen Hui
ccd4716ec7 year++ 2018-01-02 12:53:31 +08:00
Dmitry Stogov
5c8f8f8fce Use ZEND_FAST_CONCAT instead of ZEND_CONCAT for CONST operands. 2017-12-29 13:54:18 +03:00
Dmitry Stogov
f010423335 Use IS_EQUAL instead of CASE when first operand is CV or CONST. Removed CASE handlers that duplicated IS_EQUAL. 2017-12-29 12:57:58 +03:00
Dmitry Stogov
27206f9cc5 Removed useless specialization 2017-12-29 12:02:50 +03:00
Dmitry Stogov
6e4d18924b Combine READY_TO_DESTROY, EXTRACT_ZVAL_PTR and FREE_OP_VAR_PTR into single, better optimized, macro. 2017-12-26 16:50:34 +03:00
Dmitry Stogov
6e23e84332 Use zval constructors instead ZVAL_COPY if we know the types 2017-12-26 16:49:34 +03:00
Dmitry Stogov
efcbea4345 Cheaper reference construction 2017-12-26 13:30:25 +03:00
Dmitry Stogov
35b3fdfd0a Separate exceptional code into cold functions. 2017-12-22 16:35:52 +03:00
Dmitry Stogov
f860ae451a fixed "unused function" compilation warning 2017-12-18 11:43:12 +03:00
Nikita Popov
93c7a3803f Fix const qualifier warning 2017-12-15 21:58:52 +01:00
Dmitry Stogov
66a604171c Array addition is not commutative 2017-12-15 14:40:19 +03:00
Dmitry Stogov
588f1df7a2 Remove duplicate handlers for commutative operations 2017-12-15 13:42:54 +03:00
Dmitry Stogov
9e709e2fa0 Move constants into read-only data segment 2017-12-14 18:43:44 +03:00
David Walker
6d4de4cf05 Implement list() reference assignments
Support list() reference assignments of the form:

    list(&$a, list(&$b, $c)) = $d;

RFC: https://wiki.php.net/rfc/list_reference_assignment
2017-12-09 13:39:52 +01:00
Dmitry Stogov
2d8f238318 Avoid duplication 2017-12-07 14:59:42 +03:00
Dmitry Stogov
3f6b46f331 typo 2017-12-07 12:26:48 +03:00
Dmitry Stogov
2ded0d2c0e Avoid unnecessary duplication 2017-12-07 12:00:41 +03:00
Dmitry Stogov
91507ba6e8 Reduced VM code size.
Made FETCH_DIM/OBJ_FUNC_ARG to dispatch ro corresponding FETCH_DIM/OBJ_R/_W handlers.
Merged TMP and VAR specializations of ZEND_FETCH_OBJ_R.
Allowed dispatching to less specialized handelrs and helpers. (e.g. from OP_TMP_CONST to OP_TMPVAR_CONST).
2017-12-07 01:52:27 +03:00
Dmitry Stogov
d1d1aff4e5 Optimization of init_func_execute_data() 2017-12-06 02:53:30 +03:00
Dmitry Stogov
7a136cd3dd Removed useless LOAD_OPLINE() 2017-12-05 17:40:39 +03:00
Dmitry Stogov
74c84cd7f0 Use zend_string_equal*() API for zend_string equality check instead of direct memcmp() usage. 2017-12-04 17:17:02 +03:00
Dmitry Stogov
6a2738c713 CONCAT/FAST_CONCAT micro-optimization 2017-11-28 14:11:40 +03:00
Nikita Popov
828d8e635b Fix ZEND_VM_SPEC=0 build 2017-11-24 23:06:01 +01:00
Dmitry Stogov
ec2dde0c0b Introduced zend_hash_find_ex() that may avoid unnecessary hash value check. 2017-11-24 14:01:19 +03:00
Dmitry Stogov
33b094479b TYPE_CHECK instruction changed. Now it keeps in extended_value a type mask.
This makes check for "boolean" cheaper and allows check combination e.g. (is_string($a) || is_null($a))
2017-11-23 15:58:34 +03:00
Dmitry Stogov
d5dd27987f Don't mix TYPE and TYPE_INFO 2017-11-23 13:45:21 +03:00
Dmitry Stogov
8349268fa0 Delayed unlikely checks for uninitialized variables 2017-11-23 13:18:52 +03:00
Alessandro Chitolina
23b61f78a6 Fix segfault in token_get_all_variation19.phpt 2017-11-19 00:48:48 +01:00
Dmitry Stogov
aa7bf41502 Use cheaper checks 2017-11-17 13:23:22 +03:00
Dmitry Stogov
ccc12b82da Avoid unnecessary reference-counting on strings. 2017-11-16 17:09:32 +03:00
Dmitry Stogov
ce18738a30 Removed "_" from API functions. 2017-11-16 17:09:01 +03:00
Nikita Popov
1e3f625aa5 Merge branch 'PHP-7.2' 2017-11-15 23:01:52 +01:00
Nikita Popov
6640e03df8 Merge branch 'PHP-7.1' into PHP-7.2 2017-11-15 23:01:25 +01:00
DanielCiochiu
dba5a798a2 Fixed #74862: Unable to clone instance when private __clone defined
Even though __clone was implemented as private and called only from
parent class, child extending class instance could not be cloned.
2017-11-15 23:00:26 +01:00
Xinchen Hui
d56a534acc RC manipulation cleanup 2 2017-11-02 12:13:35 +08:00
Xinchen Hui
a8a17a72b0 RC manipulation cleanup 2017-11-01 10:25:10 +08:00
Dmitry Stogov
fcc08ce19f Prevent reference-counting on persistent zvals (internal constants, default properties and constants of internal classes).
New macro ZVAL_COPY_OR_DUP() is used perform duplication, if necessary.
This should eliminate related race-coditions in ZTS build and prevent reference-counting bugs after unclean shutdown.
2017-10-30 23:13:10 +03:00
Dmitry Stogov
49ea143bbd Encapsulate reference-counting primitives.
Prohibit direct update of GC_REFCOUNT(), GC_SET_REFCOUNT(), GC_ADDREF() and GC_DELREF() shoukf be instead.
Added mactros to validate reference-counting (disabled for now).
These macros are going to be used to eliminate race-condintions during reference-counting on data shared between threads.
2017-10-27 01:28:58 +03:00
Dmitry Stogov
aeca761856 Removed useless reallocations 2017-10-26 19:13:53 +03:00
Dmitry Stogov
6a034be2c6 Fixed signed/unsigned comparisons 2017-10-25 11:45:17 +03:00
Dmitry Stogov
9cf87aa196 Avoid HashTable allocations for empty arrays (using zend_empty_array). 2017-10-24 17:27:31 +03:00
Dmitry Stogov
59a7944bc6 Made run_time_cache to keep "offset" to dynamic properties Buckets (instead of index). 2017-10-24 10:28:19 +03:00
Dmitry Stogov
193adbdf30 Use run-time cache to keep position of dynamic properties in HashTable to access them without hash lookup. 2017-10-23 18:29:13 +03:00
Dmitry Stogov
d0f4dbfd96 Make assertions in DO_ICALL and CALL_TRAMPOLINE to be consistent with DO_FCALL. 2017-10-17 13:35:59 +03:00
Dmitry Stogov
61ef91bf0d Revert "Allow internal functions to return values by reference (this was disabled in implementation of DO_ICALL, but enabled in DO_FCALL)."
This reverts commit da781a5ac2.
2017-10-17 13:25:19 +03:00
Dmitry Stogov
da781a5ac2 Allow internal functions to return values by reference (this was disabled in implementation of DO_ICALL, but enabled in DO_FCALL).
However, don't require internal functions returning by reference to return a reference.
Mark unserialize() as returning by reference and remove unwrap_reference hack, to allow proper returning of self referenced arrays using a reference.
Currently unserialize() is the only internal function that may return a reference.
2017-10-17 11:50:34 +03:00
Dmitry Stogov
ef5ea48741 Always use IS_CONSTANT_AST (IS_CONSTANT is removed). 2017-10-10 10:11:05 +03:00
Dmitry Stogov
fcccb0d6ea Use zval_ptr_dtor_nogc() in places where circular zvals are not possible 2017-10-09 12:24:11 +03:00
Dmitry Stogov
e70618aff6 Changed the way VM accesses constant operands in 64-bit builds. 2017-10-04 16:53:01 +03:00
Dmitry Stogov
44e0b79ac6 Refactored array creation API. array_init() and array_init_size() are converted into macros calling zend_new_array(). They are not functions anymore and don't return any values. 2017-09-20 02:25:56 +03:00
Dmitry Stogov
0fb05f1487 Property access micro-optimization. (ZEND_WRONG_PROPERTY_OFFSET and ZEND_DYNAMIC_PROPERTY_OFFSET are hidden, use one comparison instead of two on fast paths. "Negative" offsets are reserved for future optimizations). 2017-09-18 13:13:24 +03:00
Dmitry Stogov
cd6893aed1 Fixed attempt to free invalid structure (result of ROPE_INIT is not a zval) 2017-08-14 12:11:25 +03:00
Xinchen Hui
9b87b73fec Req #74963 (Improved error message on fetching property of non-object) 2017-07-31 11:51:23 +08:00
Dmitry Stogov
112eda7525 Separate the fast-patch 2017-07-19 15:42:32 +03:00
Nikita Popov
ecb67e59d7 Don't reuse compare_function operands
If the same zval is used for the result and one operand, then the
function thinks it is responsible for freeing the value in case of
a type conversion.
2017-07-19 01:04:36 +02:00
Dmitry Stogov
f49ee79e95 gc_check_possible_root() may throw exception. 2017-07-17 23:17:16 +03:00
Dmitry Stogov
1180d8c801 Separate ISSET_ISEMPTY_CV/UNSET_CV from ISSET_ISEMPTY_VAR/UNSET_VAR 2017-07-17 14:11:50 +03:00
Dmitry Stogov
02ef5d3803 Revert "Avoid run-time checks performed at compile-time."
This reverts commit 8fe47a47cf.
2017-07-04 07:15:42 +03:00
Dmitry Stogov
bbb786c85b Split zend_init_execute_data() into zend_init_func_execute_data() and zend_init_code_execute_data() 2017-06-29 10:10:57 +03:00
Tom Van Looy
60d032d65e Remove unused variable op2. It is redeclared later. 2017-06-25 22:31:00 +02:00
Nikita Popov
c136afa2be Fix FE_FETCH_* exception check
Only applying this for 7.2, because handling this would be ugly
under the old retval freeing semantics.
2017-06-25 16:45:17 +02:00
Nikita Popov
ed37ca7369 Fixed bug #74810
And also did some general cleanup in ZEND_FUNC_GET_ARGS.
2017-06-25 16:00:24 +02:00
Nikita Popov
191f154d40 Merge branch 'PHP-7.1' 2017-06-25 15:32:38 +02:00
Dmitry Stogov
7802cf8c1a Added specialized FE_FETCH_R handler for iteration over array 2017-06-20 23:25:09 +03:00
Dmitry Stogov
31a2198fd9 FE_RESER/FE_FETCH optimisation 2017-06-20 22:26:46 +03:00
Dmitry Stogov
bfa154448d VM refactoring, to avoid passing "execute_data" into helper functions that can access it using global register variable. 2017-06-16 01:42:49 +03:00
Dmitry Stogov
76db01d9ff Moved "Using $this when not in object context" exception code into single VM helper. 2017-06-15 16:23:05 +03:00
Dmitry Stogov
8fe47a47cf Avoid run-time checks performed at compile-time. 2017-06-13 13:48:58 +03:00
Dmitry Stogov
6a024146bb Removed unused variable. 2017-06-06 16:08:44 +03:00
Dmitry Stogov
02e6c9c757 ZVAL_COPY_UNREF() micro-optimization 2017-06-02 00:38:09 +03:00
Dmitry Stogov
33d42802d3 Fixed support for C compilers that don't support global register variables. 2017-05-30 13:31:58 +03:00
Dmitry Stogov
6043f76ad7 Added ZEND_FUNC_NUM_ARGS, ZEND_FUNC_GET_ARGS instructions, to implement corresponding builtin functions.
Special optimisation for "array_slice(INT, func_get_args())" pattern.
2017-05-30 13:23:17 +03:00
Dmitry Stogov
017d65d74a Extend ZEND_SEND_ARRAY to eliminate array_slice() call for "call_user_func_array(_, array_slice(_, LONG, _))" pattern. 2017-05-30 12:25:46 +03:00
Dmitry Stogov
f00d1c72b4 Added ZEND_GET_CLASS, ZEMD_GET_CALLED_CLASS, ZEND_GET_TYPE instructions, to implement corresponding builtin functions. 2017-05-25 18:41:28 +03:00
Dmitry Stogov
cd953269d3 Added ZEND_COUNT instruction, to implement corresponding builtin. 2017-05-25 12:52:34 +03:00
Dmitry Stogov
44ec732752 Fixed ZEND_IN_ARRAY related issues 2017-05-25 10:26:42 +03:00
Dmitry Stogov
7c7383067f Added ZEND_IN_ARRAY instruction, implementing optimized in_array() builtin function, through hash lookup in flipped array 2017-05-24 23:00:48 +03:00
Xinchen Hui
26a6d20ab5 Fixed segfult in JIT (emalloc may trigger memory limitation)
Zend/tests/bug68412.phpt
2017-05-21 20:48:07 +08:00
Dmitry Stogov
8203a175b1 Remove unused opcode handlers 2017-05-18 13:18:08 +03:00
Dmitry Stogov
fc927dc263 Switch to HYBRID VM 2017-05-17 15:07:33 +03:00
Dmitry Stogov
7640e0a5f9 HYBRID VM cleanup 2017-05-16 09:24:23 +03:00
Dmitry Stogov
69b4f8ed79 Fixed USER_OPCODE handling in HYBRID VM. 2017-05-15 21:17:58 +03:00
Dmitry Stogov
c8f073d0d7 Avoid useless checks 2017-05-10 13:27:37 +03:00
Dmitry Stogov
27e01cd918 Implemented HYBRID VM instruction dispatch method that takes advantages of both CALL and GOTO VMs. 2017-05-03 10:01:22 +03:00
Nikita Popov
cfa6fa1525 Initialize retval in INCLUDE_OR_EVAL
In case the eval'd code throws.
2017-04-15 12:11:30 +02:00
Nikita Popov
ad8652818a Implement jumptable optimization 2017-04-10 22:23:14 +02:00
Nikita Popov
3895aa2f77 Merge branch 'PHP-7.1' 2017-04-09 15:51:38 +02:00
Nikita Popov
515e1e0cea Merge branch 'PHP-7.0' into PHP-7.1 2017-04-09 15:35:44 +02:00
Thomas Punt
744c4a5592 Resolve bug #74188 (undefined statics raising with ?? operator) 2017-04-09 15:29:31 +02:00
Rowan Collins
1b565f1393 Change 'undefined constant' from E_NOTICE to E_WARNING and mention deprecation
Implements RFC "Deprecate and Remove Bareword (Unquoted) Strings"
[https://wiki.php.net/rfc/deprecate-bareword-strings]
2017-03-23 18:52:43 +01:00
Nikita Popov
6ad0a6fb04 Merge branch 'PHP-7.1' 2017-03-15 19:50:26 +01:00
Nikita Popov
2bba4a0d7f Fix bug #69676 2017-03-15 19:49:02 +01:00
Anatol Belski
c698299550 Interned strings unification for TS/NTS
Hereby, interned strings are supported in thread safe PHP. The patch
implements two types of interned strings

- interning per process, strings are not freed till process end
- interning per request, strings are freed at request end

There is no runtime interning.

With Opcache, all the permanent iterned strings are copied into SHM on
startup, additional copying into SHM might happen on demand.
2017-03-04 10:39:13 +01:00
Xinchen Hui
6a584cf318 Fixed bug #74157 (Segfault with nested generators) 2017-02-26 12:05:56 +08:00
Dmitry Stogov
3d84aef55d Separate zend_fetch_static_property_address() into an inline function 2017-01-17 11:11:12 +03:00
Bob Weinand
9e3c35b6d1 Fix small mistake in generator creation introduced in 9a159f37 2017-01-15 19:26:15 +01:00
Dmitry Stogov
141d1ba980 Introduced "zend_type" - an abstraction for type-hinting representation. 2017-01-13 11:37:46 +03:00
Dmitry Stogov
15040b47f0 Merge branch 'PHP-7.1'
* PHP-7.1:
  Improved GENERATOR_CREATE opcode handler.
2017-01-09 22:25:25 +03:00
Dmitry Stogov
9a159f37e1 Improved GENERATOR_CREATE opcode handler. 2017-01-09 22:24:21 +03:00
Sammy Kaye Powers
dac6c639bb Update copyright headers to 2017 2017-01-04 11:23:42 -06:00
Sammy Kaye Powers
478f119ab9 Update copyright headers to 2017 2017-01-04 11:14:55 -06:00
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00
Sara Golemon
16758a3c66 Merge branch 'PHP-7.1'
* PHP-7.1:
  Remove extraneous parentheses in conditions
2016-12-25 22:18:27 -08:00
Sébastien Santoro
5d7c774bea Remove extraneous parentheses in conditions
The zend_vm_gen.php generator now checks if the condition is already
enclosed by parentheses, and them only if needed.

This fixes nine clang/llvm parentheses-equality warnings.
2016-12-25 22:17:46 -08:00
Dmitry Stogov
3c6a2fb08c Fixed bug #73792 (invalid foreach loop hangs script) 2016-12-20 16:48:57 +03:00
Dmitry Stogov
fb73c1084c Few micro-optimizations 2016-12-19 15:36:37 +03:00
Dmitry Stogov
fac95658b3 Improved VM stack unwinding on exception.
Now zend_throw_exception_hook() is going to be called only when exception is actually thrown and not going to be recalled for each unwinded finction.
2016-12-12 10:55:32 +03:00
Xinchen Hui
7695fba388 Merge branch 'PHP-7.1'
* PHP-7.1:
  Fix the bug in ZEND_ASSIGN_DIM (as nikic suggest)
  Revert "Refix bug #73686"
2016-12-09 22:30:41 +08:00
Xinchen Hui
09b36113b0 Fix the bug in ZEND_ASSIGN_DIM (as nikic suggest) 2016-12-09 22:30:24 +08:00
Dmitry Stogov
a3526cd9b7 Regenerated zend_vm_execute.h (fixed white spaces) 2016-12-08 13:37:57 +03:00
Kalle Sommer Nielsen
cf24a61735 Disable C4101 warnings entirely on Windows 2016-12-08 03:50:31 +01:00
Dmitry Stogov
5011a11a6d Fixed memory leaks caused by exceptions thrown from destructors (one more case). 2016-12-07 01:43:13 +03:00
Dmitry Stogov
e8109e09aa Fixed memory leaks caused by exceptions thrown from destructors. 2016-12-07 00:41:07 +03:00
Dmitry Stogov
b4ad6d6d1b COALESCE can't throw exception 2016-12-06 10:21:44 +03:00
Dmitry Stogov
a722970033 Merge branch 'PHP-7.1'
* PHP-7.1:
  Micro optimizations
2016-12-06 10:01:38 +03:00
Dmitry Stogov
547b735d34 Micro optimizations 2016-12-06 10:01:18 +03:00
Bob Weinand
444d612b62 Use an inline handler instead of repeating logic for calling assign op helpers each time 2016-12-05 10:55:11 +01:00
Bob Weinand
46d708a1b6 Fix PHP-7.0 build (wrong fix for the branch) 2016-12-03 23:39:54 +01:00
Bob Weinand
f74890bcf5 Merge branch 'PHP-7.1' 2016-12-03 18:29:11 +01:00
Bob Weinand
146b68e022 Merge branch 'PHP-7.0' into PHP-7.1 2016-12-03 18:28:47 +01:00
Bob Weinand
ffc1ef1eed Fix leak when using $this outside of object context 2016-12-03 18:28:08 +01:00
Dmitry Stogov
56fd01e230 Eliminated useless exception check 2016-12-02 16:04:18 +03:00
Dmitry Stogov
3e31ba8014 Eliminated useless exception checks (FE_RESET with array argument can't throw exception) 2016-12-02 15:58:47 +03:00
Dmitry Stogov
1660117799 Merge branch 'PHP-7.1'
* PHP-7.1:
  Eliminated useless exception check
2016-12-02 15:40:11 +03:00
Dmitry Stogov
af2d47c9c7 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Eliminated useless exception check
2016-12-02 15:40:04 +03:00
Dmitry Stogov
68558ab71d Eliminated useless exception check 2016-12-02 15:39:33 +03:00
Dmitry Stogov
22cebaf89a Revert "Fix return value memory leaks upon exceptions in opcode operand freeing"
This reverts commit 9ad9d7ae37.
2016-12-02 11:58:41 +03:00
Dmitry Stogov
9c1920d9e8 Revert "Fix memory leaks with FE_RESET upon empty iterator"
This reverts commit 00e516e575.
2016-12-02 11:58:36 +03:00
Dmitry Stogov
9774e32dbb Revert "Fix accidental zval_ptr_dtor()ing of object"
This reverts commit ae2f68d8a5.
2016-12-02 11:58:33 +03:00
Dmitry Stogov
8fa691ea8a Revert "Fix a few valgrind warnings with undefing result"
This reverts commit 8f4e100f21.
2016-12-02 11:58:25 +03:00
Bob Weinand
8f4e100f21 Fix a few valgrind warnings with undefing result 2016-12-01 10:15:07 +01:00
Bob Weinand
ae2f68d8a5 Fix accidental zval_ptr_dtor()ing of object 2016-11-30 23:57:22 +01:00
Bob Weinand
00e516e575 Fix memory leaks with FE_RESET upon empty iterator
Solved by manually freeing and jumping to the opcode *after* FE_FREE
2016-11-30 17:44:34 +01:00
Bob Weinand
9ad9d7ae37 Fix return value memory leaks upon exceptions in opcode operand freeing 2016-11-30 17:44:34 +01:00
Dmitry Stogov
3b4c9f18e0 Merge branch 'PHP-7.1'
* PHP-7.1:
  Fixed calling generators through magic __call()
2016-11-28 12:30:16 +03:00
Dmitry Stogov
458c732ed4 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fixed calling generators through magic __call()
2016-11-28 12:30:01 +03:00
Dmitry Stogov
970f21be97 Fixed calling generators through magic __call() 2016-11-28 12:20:19 +03:00
Nikita Popov
7dbdf2db83 Fix foreach object property visibility checks
Again, check_property_access() does not correctly work for properties
that look like mangled private propert names (but aren't). Fix this
by only checking visibility for INDIRECT properties.

foreach currently still unmangles property names, even if they don't
correspond to declared properties. HHVM does not do this (and I think
this is correct.) As this is done consistently, leaving it alone
for now.
2016-11-22 21:01:15 +01:00
Dmitry Stogov
1ab44223bf Export zend_do_fcall_overloaded() 2016-11-22 18:36:27 +03:00