mirror of
https://github.com/php/php-src.git
synced 2025-01-12 05:54:13 +08:00
f6d227ed4f
Squashed commit of the following: commit 106c815fffb8eb3efe00a27a5229cb1f8ffc9736 Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Nov 14 16:36:44 2018 +0300 Added NEWS entry commit 1dacd5e20b7043368ef9e80db296d1781134b6fd Merge: d516139abfba99aa133c
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Nov 14 16:33:37 2018 +0300 Merge branch 'master' into preload * master: Fixed issues related to optimization and persitence of classes linked with interfaces, traits or internal classes. Added possiblity to avoid signal handlers reinitialization on each request. commit d516139abf5ffbd495ee6037f1dc04a1cfe588a7 Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Nov 14 16:13:15 2018 +0300 Override opcache.preload for testing commit 162b154d0bbfbaf8ef93975f7e56a1353236903d Merge:45fdd034ce
8bda22592e
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Nov 14 15:38:09 2018 +0300 Merge branch 'master' into preload * master: (34 commits) Eliminate useless $this related check Eliminate useless $this related checks Replace zend_parse_method_parameters() by zend_parse_parameters() and avoid useless checks. Replace getThis() by EX(This), when additional check is not necessary. Fixed tests Validate length on socket_write Fix compilation on x32 Fix #77141: Signedness issue in SOAP when precision=-1 Support SQLite3 @name notation Remove lexer files generated by RE2C Update libmagic.patch [ci skip] Update libmagic.patch [ci skip] Fork test with pcre.jit=0 Rework magic data Fix regex Fix regex Rework magic data Sync one more upstream libmagic piece Suppress already used warning Ignore getaddrinfo failed message ... commit45fdd034ce
Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Nov 9 13:07:03 2018 +0300 Properly resolve magic method of preloaded classes inherited from internal ones. commit34645aeb42
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Nov 8 15:29:17 2018 +0300 Don't preload constants defined during preload script excution. commitcef0d67c3e
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Nov 7 15:56:54 2018 +0300 Support for class aliasses commit08ffc9a552
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Nov 7 15:34:39 2018 +0300 Resolve constants only in linked classes commit8d3429cda8
Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Nov 6 11:56:39 2018 +0300 Fixed preloading of references to internal classes. commit7ae3a47d20
Merge:9b0a53ed1c
049f239cfc
Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Nov 6 11:37:15 2018 +0300 Merge branch 'master' into preload * master: Update NEWS [ci skip] Update NEWS [ci skip] Update libmagic.patch [ci skip] Update libmagic.patch [ci skip] Declare function proto in header Declare function proto in header Fix #76825: Undefined symbols ___cpuid_count NEWS Fix: #77110 undefined symbol zend_string_equal_val in C++ build Fix #77105: Use position:sticky for <th> in `phpinfo()` Implement handling for JIT recognition when cross compiling Backport7f5f4601
for 7.2 Fix #76348: WSDL_CACHE_MEMORY causes Segmentation fault Rework places in libmagic regarding previous CVE-2014-3538 fixes Change the way JIT availability is checked Fix a test for ldap extension Fixed bug #77092 Future-proof email addresses commit9b0a53ed1c
Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Nov 2 14:54:44 2018 +0300 We don't need preload_restart() here commit0bd17bd438
Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Nov 2 14:44:30 2018 +0300 EG(*) may be not initializd at this point - use CG(*). commitb610467051
Merge:3a9d90f74a
67e0138c0d
Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Nov 2 11:33:37 2018 +0300 Merge branch 'master' into preload * master: Future-proof email addresses... Update email addresses. We're still @Zend, but future proofing it... commit3a9d90f74a
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Nov 1 15:19:48 2018 +0300 Fexed resolution of method clones commitaea85c65bd
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Nov 1 11:45:50 2018 +0300 Prevent inlining of method copied from trait commit36b644fbb7
Merge:7a20781d2e
b91690c892
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Nov 1 10:56:02 2018 +0300 Merge branch 'master' into preload * master: Fix stray newline that caused this test to fail Fix session tests that fail if error_log is set This test needs to log to stdout Fix error condition Fixed bug #77081 ftruncate() changes seek pointer in c mode Fix and improve test case commit7a20781d2e
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 31 00:52:46 2018 +0300 Added test commit4a57b5d563
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 31 00:50:21 2018 +0300 Fixed preloading of classes linked with traits commit68c4f99e23
Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Oct 30 16:25:14 2018 +0300 Added test commit38ab7ef4cf
Merge:eb6e2c529f
bf38e6c10a
Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Oct 30 16:14:39 2018 +0300 Merge branch 'master' into preload * master: Keep original value of "prototype" commiteb6e2c529f
Merge:562049510f
2fefa8c61e
Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Oct 30 15:35:39 2018 +0300 Merge branch 'master' into preload * master: Call function_add_ref() in proper place Updated to version 2018.7 (2018g) Updated to version 2018.7 (2018g) Updated to version 2018.7 (2018g) Reslove inherited op_array references once afrer all optimizations. commit562049510f
Merge:e806cb732a
4828fb7b6b
Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Oct 30 10:29:49 2018 +0300 Merge branch 'master' into preload * master: [ci skip] Update NEWS [ci skip] Update NEWS [ci skip] Update NEWS fix bug #77079 Add missing null initialization Remove redundant mbfl_string_init calls Use zend_string for mbstring last encoding cache commite806cb732a
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 29 22:32:15 2018 +0300 Fixed double-free commit2f697ef8af
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 29 22:07:32 2018 +0300 typo commitc559f22b3e
Merge:310631cc05
ea2e67876a
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 29 21:59:27 2018 +0300 Merge branch 'master' into preload * master: Stop Apache if PHP wasn't started successful. Execute zend_post_startup() with module_initialized flag set. Removed dead code Fix mb_strrpos() with encoding passed as 3rd param commit310631cc05
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 29 16:48:42 2018 +0300 Stop Apache if PHP wasn't started successful. commit0a24d7ba8f
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 29 16:25:49 2018 +0300 Avoid use-after-free in main thread commit17a3cb4a2a
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 29 15:25:17 2018 +0300 Execute zend_post_startup() with module_initialized flag set. commit6d4b22c518
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 29 14:12:20 2018 +0300 Override SAPI.ub_write and SAPI.flush for preloading commit386c9d3470
Merge:d7fbb4d402
359f19edc9
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 29 13:49:24 2018 +0300 Merge branch 'master' into preload * master: Optimize substr() edge-case conditions [ci skip] Update UPGRADING Fix #71592: External entity processing never fails Add TIDY_TAG_* constants supported by libtidy 5 Add is_iterable to opcache Optimizer commitd7fbb4d402
Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Oct 26 13:11:54 2018 +0300 Restore preload state if it was already loaded in another process. commit0fe9ea1c07
Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Oct 26 12:29:06 2018 +0300 Removed dead code commit3a2d1bcc1f
Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Oct 26 00:19:40 2018 +0300 Support for builds without ZEND_SIGNALS commite6b76ecb4b
Merge:4531fbf931
68694c9997
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Oct 25 23:43:25 2018 +0300 Merge branch 'master' into preload * master: Don't wrap php_module_shutdown() with zend_try. executor_globals are released in ZTS build, and this leads to crash. [ci skip] Fix indentation in UPGRADING. commit4531fbf931
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Oct 25 22:44:49 2018 +0300 Disable linking and preloading of classes those parent or one of interface or trait is an internal class. commita594a618ce
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Oct 25 22:30:51 2018 +0300 Cleanup - remove useless ZCSG(saved_map_ptr_last) - move preloaded classes/functions clean-up code back into better place commitab9a40f63c
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Oct 25 20:52:51 2018 +0300 Added support for preloaded classes/functions in ZTS build commite3c65db099
Merge:4f57c1e029
33e777acbf
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Oct 25 20:52:26 2018 +0300 Merge branch 'master' into preload * master: Improved shared interned strings handling. The previous implementation worked incorrectly in ZTS build. It changed strings only in function/class tables of one thread. Now all threads gets the same shared interned strings. Also, on shutdown, we don't try to replace SHM interned strings back to process strings, but delay dettachment of SHM instead. Don't use request heap at shutdown Don't optimize function if inference failed Fixed bug #77058 Improve "narrowing" error message bump versions commit4f57c1e029
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Oct 25 15:29:58 2018 +0300 Cleanup (move preload_shutdown() call to better place) commit26587a95c0
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Oct 25 14:30:51 2018 +0300 eol commitd70cb10480
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Oct 25 14:30:20 2018 +0300 cleanup commitaabe685dbb
Merge:d9fc51bc3b
40808ac41e
Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Oct 25 12:42:51 2018 +0300 Merge branch 'master' into preload * master: Remove unused var Remove ext/json parser files generated by bison Fix run-tests.php for running phpdbg and certain test sections Normalize .gitignore commitd9fc51bc3b
Merge:b5ffba0faf
b6ef8998d5
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 24 15:59:24 2018 +0300 Merge branch 'master' into preload * master: Fixed reseting of interned strings buffer. commitb5ffba0faf
Merge:e4a7ef0c43
a404383118
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 24 12:46:28 2018 +0300 Merge branch 'master' into preload * master: Fixed build in directory different from source commite4a7ef0c43
Merge:811f20aaa5
d1e14e2cc0
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 24 11:59:43 2018 +0300 Merge branch 'master' into preload * master: (29 commits) Make php_plain_files_wrapper to be writable (workaround for swoole) Remove phpdbg parser files generated by bison Fix conflicts in phpdbg parser Refetetch function name on exceptional path to allow better code on fast code path. fix typo in sysvsem.c Fixed bug #50675 bump to 7.2.13-dev [ci skip] Update NEWS wrt. php-7.3.0RC4 tagging Inlining in the most frequently used code paths Fixed test failurs introduced by9c144e0d82
Use persistent strings only for persistent connections Fix accessibility checks for dynamic properties Updated to version 2018.6 (2018f) Updated to version 2018.6 (2018f) Updated to version 2018.6 (2018f) Fix arginfo and clean up fpm_get_status Defragment two Zend related Makefile fragments together [ci skip] Remove automake and aclocal in comments Fix #75282: xmlrpc_encode_request() crashes Fix tests for ICU 63.1 ... commit811f20aaa5
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 22 14:10:49 2018 +0300 Added information about preloading to opcache_get_status() commit093e8b1bbf
Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Oct 19 13:46:23 2018 +0300 Added warning message commita2ba970ce3
Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Oct 19 13:35:40 2018 +0300 Added test commitb67e28367c
Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Oct 19 13:33:12 2018 +0300 Don't preload functions declared at run-time. commitb0139dc228
Merge:a609520adb
3fe698b904
Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Oct 19 13:23:14 2018 +0300 Merge branch 'master' into preload * master: Mark "top-level" functions. Don't initialize static_member_tables during start-up, when inherit internal classes. [ci skip] Update NEWS [ci skip] Update NEWS [ci skip] Update NEWS Fix #77035: The phpize and ./configure create redundant .deps file Remove outdated PEAR artefacts Fix tests/output/bug74815.phpt generating errors.log Revert "Use C++ symbols, when C++11 or upper is compiled" Use C++ symbols, when C++11 or upper is compiled Added new line Remove stamp-h Move all testing docs to qa.php.net Fix a typo in UPGRADING.INTERNALS Fix test when it's run on another drive [ci skip] Update UPGRADING wrt. tidyp support Fixed incorrect reallocation Fix #77027: tidy::getOptDoc() not available on Windows Run CI tests under opcache.protect_memory=1 commita609520adb
Merge:ac8f45f61b
b6ac50f9e6
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 17:01:05 2018 +0300 Merge branch 'master' into preload * master: Fixed comment Micro optimizations Mark "top-level" classes commitac8f45f61b
Merge:632b30b545
d57cd36e47
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 15:53:41 2018 +0300 Merge branch 'master' into preload * master: Immutable clases and op_arrays. commit632b30b545
Merge:d33908a99a
cd0c36c3f9
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 15:04:43 2018 +0300 Merge branch 'immutable' into preload * immutable: Remove the "auto" encoding Fixed bug #77025 Add vtbls for EUC-TW encoding commitcd0c36c3f9
Merge:4740dabb84
ad6738e886
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 14:43:38 2018 +0300 Merge branch 'master' into immutable * master: Remove the "auto" encoding Fixed bug #77025 Add vtbls for EUC-TW encoding commitd33908a99a
Merge:21e0bebca3
4740dabb84
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 14:14:23 2018 +0300 Merge branch 'immutable' into preload * immutable: Reverted back ce->iterator_funcs_ptr. Initialize ce->iterator_funcs_ptr fields in immutable classes. commit4740dabb84
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 14:12:28 2018 +0300 Reverted back ce->iterator_funcs_ptr. Initialize ce->iterator_funcs_ptr fields in immutable classes. commit21e0bebca3
Merge:c78277ae84
ad7a78b253
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 12:29:59 2018 +0300 Merge branch 'immutable' into preload * immutable: Added comment Added type cast Moved static class members initialization into the proper place. Removed redundand assertion Removed duplicate code Hide offset encoding magic in ZEND_MAP_PTR_IS_OFFSET(), ZEND_MAP_PTR_OFFSET2PTR() and ZEND_MAP_PTR_PTR2OFFSET() macros. typo Remove unused variable makefile_am_files Classify object handlers are required/optional Add support for getting SKIP_TAGSTART and SKIP_WHITE options Remove some obsolete config_vars.mk occurrences Remove bsd_converted from .gitignore Remove configuration parser and scanners ignores Remove obsolete buildconf.stamp from .gitignore [ci skip] Add magicdata.patch exception to .gitignore Remove outdated ext/spl/examples items from .gitignore Remove unused test.inc in ext/iconv/tests commitad7a78b253
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 11:46:30 2018 +0300 Added comment commit0276ea5187
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 11:42:43 2018 +0300 Added type cast commitc63fc5d5f1
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 11:36:51 2018 +0300 Moved static class members initialization into the proper place. commitb945548e93
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 11:21:03 2018 +0300 Removed redundand assertion commitd5a4108840
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 11:19:13 2018 +0300 Removed duplicate code commit8dadca8864
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 11:05:43 2018 +0300 Hide offset encoding magic in ZEND_MAP_PTR_IS_OFFSET(), ZEND_MAP_PTR_OFFSET2PTR() and ZEND_MAP_PTR_PTR2OFFSET() macros. commit9ef07c88bd
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 10:48:29 2018 +0300 typo commita06f0f3d3a
Merge:94099586ec
3412345ffe
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 10:47:07 2018 +0300 Merge branch 'master' into immutable * master: Remove unused variable makefile_am_files Classify object handlers are required/optional Add support for getting SKIP_TAGSTART and SKIP_WHITE options Remove some obsolete config_vars.mk occurrences Remove bsd_converted from .gitignore Remove configuration parser and scanners ignores Remove obsolete buildconf.stamp from .gitignore [ci skip] Add magicdata.patch exception to .gitignore Remove outdated ext/spl/examples items from .gitignore Remove unused test.inc in ext/iconv/tests commitc78277ae84
Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Oct 16 17:25:35 2018 +0300 Preloadsing support for opcache restart commitf76a955c02
Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Oct 16 13:52:36 2018 +0300 Fixed incorrect signal handlers overriding commit0810ce0d81
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 15 23:38:48 2018 +0300 An attempt to implemnt "preloading" ability. commit94099586ec
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 15 23:34:01 2018 +0300 Immutable clases and op_arrays
802 lines
24 KiB
C
802 lines
24 KiB
C
/*
|
|
+----------------------------------------------------------------------+
|
|
| Zend Engine |
|
|
+----------------------------------------------------------------------+
|
|
| Copyright (c) 1998-2018 Zend Technologies Ltd. (http://www.zend.com) |
|
|
+----------------------------------------------------------------------+
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
| available through the world-wide-web at the following url: |
|
|
| http://www.zend.com/license/2_00.txt. |
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
| license@zend.com so we can mail you a copy immediately. |
|
|
+----------------------------------------------------------------------+
|
|
| Authors: Andi Gutmans <andi@php.net> |
|
|
| Zeev Suraski <zeev@php.net> |
|
|
| Dmitry Stogov <dmitry@php.net> |
|
|
+----------------------------------------------------------------------+
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "zend.h"
|
|
#include "zend_alloc.h"
|
|
#include "zend_compile.h"
|
|
#include "zend_extensions.h"
|
|
#include "zend_API.h"
|
|
#include "zend_sort.h"
|
|
|
|
#include "zend_vm.h"
|
|
|
|
static void zend_extension_op_array_ctor_handler(zend_extension *extension, zend_op_array *op_array)
|
|
{
|
|
if (extension->op_array_ctor) {
|
|
extension->op_array_ctor(op_array);
|
|
}
|
|
}
|
|
|
|
static void zend_extension_op_array_dtor_handler(zend_extension *extension, zend_op_array *op_array)
|
|
{
|
|
if (extension->op_array_dtor) {
|
|
extension->op_array_dtor(op_array);
|
|
}
|
|
}
|
|
|
|
void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size)
|
|
{
|
|
op_array->type = type;
|
|
op_array->arg_flags[0] = 0;
|
|
op_array->arg_flags[1] = 0;
|
|
op_array->arg_flags[2] = 0;
|
|
|
|
op_array->refcount = (uint32_t *) emalloc(sizeof(uint32_t));
|
|
*op_array->refcount = 1;
|
|
op_array->last = 0;
|
|
op_array->opcodes = emalloc(initial_ops_size * sizeof(zend_op));
|
|
|
|
op_array->last_var = 0;
|
|
op_array->vars = NULL;
|
|
|
|
op_array->T = 0;
|
|
|
|
op_array->function_name = NULL;
|
|
op_array->filename = zend_get_compiled_filename();
|
|
op_array->doc_comment = NULL;
|
|
|
|
op_array->arg_info = NULL;
|
|
op_array->num_args = 0;
|
|
op_array->required_num_args = 0;
|
|
|
|
op_array->scope = NULL;
|
|
op_array->prototype = NULL;
|
|
|
|
op_array->live_range = NULL;
|
|
op_array->try_catch_array = NULL;
|
|
op_array->last_live_range = 0;
|
|
|
|
op_array->static_variables = NULL;
|
|
ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, &op_array->static_variables);
|
|
op_array->last_try_catch = 0;
|
|
|
|
op_array->fn_flags = 0;
|
|
|
|
op_array->last_literal = 0;
|
|
op_array->literals = NULL;
|
|
|
|
ZEND_MAP_PTR_INIT(op_array->run_time_cache, NULL);
|
|
op_array->cache_size = zend_op_array_extension_handles * sizeof(void*);
|
|
|
|
memset(op_array->reserved, 0, ZEND_MAX_RESERVED_RESOURCES * sizeof(void*));
|
|
|
|
if (zend_extension_flags & ZEND_EXTENSIONS_HAVE_OP_ARRAY_CTOR) {
|
|
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_ctor_handler, op_array);
|
|
}
|
|
}
|
|
|
|
ZEND_API void destroy_zend_function(zend_function *function)
|
|
{
|
|
zval tmp;
|
|
|
|
ZVAL_PTR(&tmp, function);
|
|
zend_function_dtor(&tmp);
|
|
}
|
|
|
|
ZEND_API void zend_function_dtor(zval *zv)
|
|
{
|
|
zend_function *function = Z_PTR_P(zv);
|
|
|
|
if (function->type == ZEND_USER_FUNCTION) {
|
|
ZEND_ASSERT(function->common.function_name);
|
|
destroy_op_array(&function->op_array);
|
|
/* op_arrays are allocated on arena, so we don't have to free them */
|
|
} else {
|
|
ZEND_ASSERT(function->type == ZEND_INTERNAL_FUNCTION);
|
|
ZEND_ASSERT(function->common.function_name);
|
|
zend_string_release_ex(function->common.function_name, 1);
|
|
|
|
if ((function->common.fn_flags & (ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_HAS_TYPE_HINTS)) &&
|
|
!function->common.scope && function->common.arg_info) {
|
|
|
|
uint32_t i;
|
|
uint32_t num_args = function->common.num_args + 1;
|
|
zend_arg_info *arg_info = function->common.arg_info - 1;
|
|
|
|
if (function->common.fn_flags & ZEND_ACC_VARIADIC) {
|
|
num_args++;
|
|
}
|
|
for (i = 0 ; i < num_args; i++) {
|
|
if (ZEND_TYPE_IS_CLASS(arg_info[i].type)) {
|
|
zend_string_release_ex(ZEND_TYPE_NAME(arg_info[i].type), 1);
|
|
}
|
|
}
|
|
free(arg_info);
|
|
}
|
|
|
|
if (!(function->common.fn_flags & ZEND_ACC_ARENA_ALLOCATED)) {
|
|
pefree(function, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce)
|
|
{
|
|
if (CE_STATIC_MEMBERS(ce)) {
|
|
zval *static_members = CE_STATIC_MEMBERS(ce);
|
|
zval *p = static_members;
|
|
zval *end = p + ce->default_static_members_count;
|
|
|
|
ZEND_MAP_PTR_SET(ce->static_members_table, NULL);
|
|
while (p != end) {
|
|
i_zval_ptr_dtor(p);
|
|
p++;
|
|
}
|
|
efree(static_members);
|
|
}
|
|
}
|
|
|
|
static void _destroy_zend_class_traits_info(zend_class_entry *ce)
|
|
{
|
|
uint32_t i;
|
|
|
|
for (i = 0; i < ce->num_traits; i++) {
|
|
zend_string_release_ex(ce->trait_names[i].name, 0);
|
|
zend_string_release_ex(ce->trait_names[i].lc_name, 0);
|
|
}
|
|
efree(ce->trait_names);
|
|
|
|
if (ce->trait_aliases) {
|
|
i = 0;
|
|
while (ce->trait_aliases[i]) {
|
|
if (ce->trait_aliases[i]->trait_method.method_name) {
|
|
zend_string_release_ex(ce->trait_aliases[i]->trait_method.method_name, 0);
|
|
}
|
|
if (ce->trait_aliases[i]->trait_method.class_name) {
|
|
zend_string_release_ex(ce->trait_aliases[i]->trait_method.class_name, 0);
|
|
}
|
|
|
|
if (ce->trait_aliases[i]->alias) {
|
|
zend_string_release_ex(ce->trait_aliases[i]->alias, 0);
|
|
}
|
|
|
|
efree(ce->trait_aliases[i]);
|
|
i++;
|
|
}
|
|
|
|
efree(ce->trait_aliases);
|
|
}
|
|
|
|
if (ce->trait_precedences) {
|
|
int j;
|
|
|
|
i = 0;
|
|
while (ce->trait_precedences[i]) {
|
|
zend_string_release_ex(ce->trait_precedences[i]->trait_method.method_name, 0);
|
|
zend_string_release_ex(ce->trait_precedences[i]->trait_method.class_name, 0);
|
|
|
|
for (j = 0; j < ce->trait_precedences[i]->num_excludes; j++) {
|
|
zend_string_release_ex(ce->trait_precedences[i]->exclude_class_names[j], 0);
|
|
}
|
|
efree(ce->trait_precedences[i]);
|
|
i++;
|
|
}
|
|
efree(ce->trait_precedences);
|
|
}
|
|
}
|
|
|
|
ZEND_API void destroy_zend_class(zval *zv)
|
|
{
|
|
zend_property_info *prop_info;
|
|
zend_class_entry *ce = Z_PTR_P(zv);
|
|
zend_function *fn;
|
|
|
|
if (ce->ce_flags & ZEND_ACC_IMMUTABLE) {
|
|
zend_op_array *op_array;
|
|
|
|
if (ce->default_static_members_count) {
|
|
zend_cleanup_internal_class_data(ce);
|
|
}
|
|
if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
|
|
ZEND_HASH_FOREACH_PTR(&ce->function_table, op_array) {
|
|
if (op_array->type == ZEND_USER_FUNCTION) {
|
|
destroy_op_array(op_array);
|
|
}
|
|
} ZEND_HASH_FOREACH_END();
|
|
}
|
|
return;
|
|
} else if (--ce->refcount > 0) {
|
|
return;
|
|
}
|
|
switch (ce->type) {
|
|
case ZEND_USER_CLASS:
|
|
if (ce->parent_name && !(ce->ce_flags & ZEND_ACC_LINKED)) {
|
|
zend_string_release_ex(ce->parent_name, 0);
|
|
}
|
|
if (ce->default_properties_table) {
|
|
zval *p = ce->default_properties_table;
|
|
zval *end = p + ce->default_properties_count;
|
|
|
|
while (p != end) {
|
|
i_zval_ptr_dtor(p);
|
|
p++;
|
|
}
|
|
efree(ce->default_properties_table);
|
|
}
|
|
if (ce->default_static_members_table) {
|
|
zval *p = ce->default_static_members_table;
|
|
zval *end = p + ce->default_static_members_count;
|
|
|
|
while (p != end) {
|
|
i_zval_ptr_dtor(p);
|
|
p++;
|
|
}
|
|
efree(ce->default_static_members_table);
|
|
}
|
|
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) {
|
|
if (prop_info->ce == ce) {
|
|
zend_string_release_ex(prop_info->name, 0);
|
|
if (prop_info->doc_comment) {
|
|
zend_string_release_ex(prop_info->doc_comment, 0);
|
|
}
|
|
}
|
|
} ZEND_HASH_FOREACH_END();
|
|
zend_hash_destroy(&ce->properties_info);
|
|
zend_string_release_ex(ce->name, 0);
|
|
zend_hash_destroy(&ce->function_table);
|
|
if (zend_hash_num_elements(&ce->constants_table)) {
|
|
zend_class_constant *c;
|
|
|
|
ZEND_HASH_FOREACH_PTR(&ce->constants_table, c) {
|
|
if (c->ce == ce) {
|
|
zval_ptr_dtor_nogc(&c->value);
|
|
if (c->doc_comment) {
|
|
zend_string_release_ex(c->doc_comment, 0);
|
|
}
|
|
}
|
|
} ZEND_HASH_FOREACH_END();
|
|
}
|
|
zend_hash_destroy(&ce->constants_table);
|
|
if (ce->num_interfaces > 0) {
|
|
if (!(ce->ce_flags & ZEND_ACC_LINKED)) {
|
|
uint32_t i;
|
|
|
|
for (i = 0; i < ce->num_interfaces; i++) {
|
|
zend_string_release_ex(ce->interface_names[i].name, 0);
|
|
zend_string_release_ex(ce->interface_names[i].lc_name, 0);
|
|
}
|
|
}
|
|
efree(ce->interfaces);
|
|
}
|
|
if (ce->info.user.doc_comment) {
|
|
zend_string_release_ex(ce->info.user.doc_comment, 0);
|
|
}
|
|
|
|
if (ce->num_traits > 0) {
|
|
_destroy_zend_class_traits_info(ce);
|
|
}
|
|
|
|
break;
|
|
case ZEND_INTERNAL_CLASS:
|
|
if (ce->default_properties_table) {
|
|
zval *p = ce->default_properties_table;
|
|
zval *end = p + ce->default_properties_count;
|
|
|
|
while (p != end) {
|
|
zval_internal_ptr_dtor(p);
|
|
p++;
|
|
}
|
|
free(ce->default_properties_table);
|
|
}
|
|
if (ce->default_static_members_table) {
|
|
zval *p = ce->default_static_members_table;
|
|
zval *end = p + ce->default_static_members_count;
|
|
|
|
while (p != end) {
|
|
zval_internal_ptr_dtor(p);
|
|
p++;
|
|
}
|
|
free(ce->default_static_members_table);
|
|
if (ZEND_MAP_PTR(ce->static_members_table) != &ce->default_static_members_table) {
|
|
zend_cleanup_internal_class_data(ce);
|
|
}
|
|
}
|
|
zend_hash_destroy(&ce->properties_info);
|
|
zend_string_release_ex(ce->name, 1);
|
|
|
|
/* TODO: eliminate this loop for classes without functions with arg_info */
|
|
ZEND_HASH_FOREACH_PTR(&ce->function_table, fn) {
|
|
if ((fn->common.fn_flags & (ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_HAS_TYPE_HINTS)) &&
|
|
fn->common.scope == ce) {
|
|
/* reset function scope to allow arg_info removing */
|
|
fn->common.scope = NULL;
|
|
}
|
|
} ZEND_HASH_FOREACH_END();
|
|
|
|
zend_hash_destroy(&ce->function_table);
|
|
if (zend_hash_num_elements(&ce->constants_table)) {
|
|
zend_class_constant *c;
|
|
|
|
ZEND_HASH_FOREACH_PTR(&ce->constants_table, c) {
|
|
if (c->ce == ce) {
|
|
zval_internal_ptr_dtor(&c->value);
|
|
if (c->doc_comment) {
|
|
zend_string_release_ex(c->doc_comment, 1);
|
|
}
|
|
}
|
|
free(c);
|
|
} ZEND_HASH_FOREACH_END();
|
|
zend_hash_destroy(&ce->constants_table);
|
|
}
|
|
if (ce->iterator_funcs_ptr) {
|
|
free(ce->iterator_funcs_ptr);
|
|
}
|
|
if (ce->num_interfaces > 0) {
|
|
free(ce->interfaces);
|
|
}
|
|
free(ce);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void zend_class_add_ref(zval *zv)
|
|
{
|
|
zend_class_entry *ce = Z_PTR_P(zv);
|
|
|
|
if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
|
|
ce->refcount++;
|
|
}
|
|
}
|
|
|
|
ZEND_API void destroy_op_array(zend_op_array *op_array)
|
|
{
|
|
uint32_t i;
|
|
|
|
if (op_array->static_variables) {
|
|
HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr);
|
|
if (ht && !(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE)) {
|
|
if (GC_DELREF(ht) == 0) {
|
|
zend_array_destroy(ht);
|
|
}
|
|
}
|
|
}
|
|
|
|
if ((op_array->fn_flags & ZEND_ACC_HEAP_RT_CACHE)
|
|
&& ZEND_MAP_PTR(op_array->run_time_cache)) {
|
|
efree(ZEND_MAP_PTR(op_array->run_time_cache));
|
|
}
|
|
|
|
if (!op_array->refcount || --(*op_array->refcount) > 0) {
|
|
return;
|
|
}
|
|
|
|
efree_size(op_array->refcount, sizeof(*(op_array->refcount)));
|
|
|
|
if (op_array->vars) {
|
|
i = op_array->last_var;
|
|
while (i > 0) {
|
|
i--;
|
|
zend_string_release_ex(op_array->vars[i], 0);
|
|
}
|
|
efree(op_array->vars);
|
|
}
|
|
|
|
if (op_array->literals) {
|
|
zval *literal = op_array->literals;
|
|
zval *end = literal + op_array->last_literal;
|
|
while (literal < end) {
|
|
zval_ptr_dtor_nogc(literal);
|
|
literal++;
|
|
}
|
|
if (ZEND_USE_ABS_CONST_ADDR
|
|
|| !(op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO)) {
|
|
efree(op_array->literals);
|
|
}
|
|
}
|
|
efree(op_array->opcodes);
|
|
|
|
if (op_array->function_name) {
|
|
zend_string_release_ex(op_array->function_name, 0);
|
|
}
|
|
if (op_array->doc_comment) {
|
|
zend_string_release_ex(op_array->doc_comment, 0);
|
|
}
|
|
if (op_array->live_range) {
|
|
efree(op_array->live_range);
|
|
}
|
|
if (op_array->try_catch_array) {
|
|
efree(op_array->try_catch_array);
|
|
}
|
|
if (zend_extension_flags & ZEND_EXTENSIONS_HAVE_OP_ARRAY_DTOR) {
|
|
if (op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO) {
|
|
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_dtor_handler, op_array);
|
|
}
|
|
}
|
|
if (op_array->arg_info) {
|
|
uint32_t num_args = op_array->num_args;
|
|
zend_arg_info *arg_info = op_array->arg_info;
|
|
|
|
if (op_array->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
|
|
arg_info--;
|
|
num_args++;
|
|
}
|
|
if (op_array->fn_flags & ZEND_ACC_VARIADIC) {
|
|
num_args++;
|
|
}
|
|
for (i = 0 ; i < num_args; i++) {
|
|
if (arg_info[i].name) {
|
|
zend_string_release_ex(arg_info[i].name, 0);
|
|
}
|
|
if (ZEND_TYPE_IS_CLASS(arg_info[i].type)) {
|
|
zend_string_release_ex(ZEND_TYPE_NAME(arg_info[i].type), 0);
|
|
}
|
|
}
|
|
efree(arg_info);
|
|
}
|
|
}
|
|
|
|
static void zend_update_extended_info(zend_op_array *op_array)
|
|
{
|
|
zend_op *opline = op_array->opcodes, *end=opline+op_array->last;
|
|
|
|
while (opline<end) {
|
|
if (opline->opcode == ZEND_EXT_STMT) {
|
|
if (opline+1<end) {
|
|
if ((opline+1)->opcode == ZEND_EXT_STMT) {
|
|
opline->opcode = ZEND_NOP;
|
|
opline++;
|
|
continue;
|
|
}
|
|
if (opline+1<end) {
|
|
opline->lineno = (opline+1)->lineno;
|
|
}
|
|
} else {
|
|
opline->opcode = ZEND_NOP;
|
|
}
|
|
}
|
|
opline++;
|
|
}
|
|
}
|
|
|
|
static void zend_extension_op_array_handler(zend_extension *extension, zend_op_array *op_array)
|
|
{
|
|
if (extension->op_array_handler) {
|
|
extension->op_array_handler(op_array);
|
|
}
|
|
}
|
|
|
|
static void zend_check_finally_breakout(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < op_array->last_try_catch; i++) {
|
|
if ((op_num < op_array->try_catch_array[i].finally_op ||
|
|
op_num >= op_array->try_catch_array[i].finally_end)
|
|
&& (dst_num >= op_array->try_catch_array[i].finally_op &&
|
|
dst_num <= op_array->try_catch_array[i].finally_end)) {
|
|
CG(in_compilation) = 1;
|
|
CG(active_op_array) = op_array;
|
|
CG(zend_lineno) = op_array->opcodes[op_num].lineno;
|
|
zend_error_noreturn(E_COMPILE_ERROR, "jump into a finally block is disallowed");
|
|
} else if ((op_num >= op_array->try_catch_array[i].finally_op
|
|
&& op_num <= op_array->try_catch_array[i].finally_end)
|
|
&& (dst_num > op_array->try_catch_array[i].finally_end
|
|
|| dst_num < op_array->try_catch_array[i].finally_op)) {
|
|
CG(in_compilation) = 1;
|
|
CG(active_op_array) = op_array;
|
|
CG(zend_lineno) = op_array->opcodes[op_num].lineno;
|
|
zend_error_noreturn(E_COMPILE_ERROR, "jump out of a finally block is disallowed");
|
|
}
|
|
}
|
|
}
|
|
|
|
static uint32_t zend_get_brk_cont_target(const zend_op_array *op_array, const zend_op *opline) {
|
|
int nest_levels = opline->op2.num;
|
|
int array_offset = opline->op1.num;
|
|
zend_brk_cont_element *jmp_to;
|
|
do {
|
|
jmp_to = &CG(context).brk_cont_array[array_offset];
|
|
if (nest_levels > 1) {
|
|
array_offset = jmp_to->parent;
|
|
}
|
|
} while (--nest_levels > 0);
|
|
|
|
return opline->opcode == ZEND_BRK ? jmp_to->brk : jmp_to->cont;
|
|
}
|
|
|
|
/* Live ranges must be sorted by increasing start opline */
|
|
static int cmp_live_range(const zend_live_range *a, const zend_live_range *b) {
|
|
return a->start - b->start;
|
|
}
|
|
static void swap_live_range(zend_live_range *a, zend_live_range *b) {
|
|
zend_live_range tmp = *a;
|
|
*a = *b;
|
|
*b = tmp;
|
|
}
|
|
static void zend_sort_live_ranges(zend_op_array *op_array) {
|
|
zend_sort(op_array->live_range, op_array->last_live_range, sizeof(zend_live_range),
|
|
(compare_func_t) cmp_live_range, (swap_func_t) swap_live_range);
|
|
}
|
|
|
|
ZEND_API int pass_two(zend_op_array *op_array)
|
|
{
|
|
zend_op *opline, *end;
|
|
|
|
if (!ZEND_USER_CODE(op_array->type)) {
|
|
return 0;
|
|
}
|
|
if (CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO) {
|
|
zend_update_extended_info(op_array);
|
|
}
|
|
if (CG(compiler_options) & ZEND_COMPILE_HANDLE_OP_ARRAY) {
|
|
if (zend_extension_flags & ZEND_EXTENSIONS_HAVE_OP_ARRAY_HANDLER) {
|
|
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_handler, op_array);
|
|
}
|
|
}
|
|
|
|
if (CG(context).vars_size != op_array->last_var) {
|
|
op_array->vars = (zend_string**) erealloc(op_array->vars, sizeof(zend_string*)*op_array->last_var);
|
|
CG(context).vars_size = op_array->last_var;
|
|
}
|
|
|
|
#if ZEND_USE_ABS_CONST_ADDR
|
|
if (CG(context).opcodes_size != op_array->last) {
|
|
op_array->opcodes = (zend_op *) erealloc(op_array->opcodes, sizeof(zend_op)*op_array->last);
|
|
CG(context).opcodes_size = op_array->last;
|
|
}
|
|
if (CG(context).literals_size != op_array->last_literal) {
|
|
op_array->literals = (zval*)erealloc(op_array->literals, sizeof(zval) * op_array->last_literal);
|
|
CG(context).literals_size = op_array->last_literal;
|
|
}
|
|
#else
|
|
op_array->opcodes = (zend_op *) erealloc(op_array->opcodes,
|
|
ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_op) * op_array->last, 16) +
|
|
sizeof(zval) * op_array->last_literal);
|
|
if (op_array->literals) {
|
|
memcpy(((char*)op_array->opcodes) + ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_op) * op_array->last, 16),
|
|
op_array->literals, sizeof(zval) * op_array->last_literal);
|
|
efree(op_array->literals);
|
|
op_array->literals = (zval*)(((char*)op_array->opcodes) + ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_op) * op_array->last, 16));
|
|
}
|
|
CG(context).opcodes_size = op_array->last;
|
|
CG(context).literals_size = op_array->last_literal;
|
|
#endif
|
|
|
|
/* Needs to be set directly after the opcode/literal reallocation, to ensure destruction
|
|
* happens correctly if any of the following fixups generate a fatal error. */
|
|
op_array->fn_flags |= ZEND_ACC_DONE_PASS_TWO;
|
|
|
|
opline = op_array->opcodes;
|
|
end = opline + op_array->last;
|
|
while (opline < end) {
|
|
switch (opline->opcode) {
|
|
case ZEND_RECV_INIT:
|
|
{
|
|
zval *val = CT_CONSTANT(opline->op2);
|
|
if (Z_TYPE_P(val) == IS_CONSTANT_AST) {
|
|
uint32_t slot = ZEND_MM_ALIGNED_SIZE_EX(op_array->cache_size, 8);
|
|
Z_CACHE_SLOT_P(val) = slot;
|
|
op_array->cache_size += sizeof(zval);
|
|
}
|
|
}
|
|
break;
|
|
case ZEND_FAST_CALL:
|
|
opline->op1.opline_num = op_array->try_catch_array[opline->op1.num].finally_op;
|
|
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1);
|
|
break;
|
|
case ZEND_BRK:
|
|
case ZEND_CONT:
|
|
{
|
|
uint32_t jmp_target = zend_get_brk_cont_target(op_array, opline);
|
|
|
|
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
|
|
zend_check_finally_breakout(op_array, opline - op_array->opcodes, jmp_target);
|
|
}
|
|
opline->opcode = ZEND_JMP;
|
|
opline->op1.opline_num = jmp_target;
|
|
opline->op2.num = 0;
|
|
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1);
|
|
}
|
|
break;
|
|
case ZEND_GOTO:
|
|
zend_resolve_goto_label(op_array, opline);
|
|
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
|
|
zend_check_finally_breakout(op_array, opline - op_array->opcodes, opline->op1.opline_num);
|
|
}
|
|
/* break omitted intentionally */
|
|
case ZEND_JMP:
|
|
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1);
|
|
break;
|
|
case ZEND_JMPZNZ:
|
|
/* absolute index to relative offset */
|
|
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
|
|
/* break omitted intentionally */
|
|
case ZEND_JMPZ:
|
|
case ZEND_JMPNZ:
|
|
case ZEND_JMPZ_EX:
|
|
case ZEND_JMPNZ_EX:
|
|
case ZEND_JMP_SET:
|
|
case ZEND_COALESCE:
|
|
case ZEND_FE_RESET_R:
|
|
case ZEND_FE_RESET_RW:
|
|
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2);
|
|
break;
|
|
case ZEND_ASSERT_CHECK:
|
|
{
|
|
/* If result of assert is unused, result of check is unused as well */
|
|
zend_op *call = &op_array->opcodes[opline->op2.opline_num - 1];
|
|
if (call->opcode == ZEND_EXT_FCALL_END) {
|
|
call--;
|
|
}
|
|
if (call->result_type == IS_UNUSED) {
|
|
opline->result_type = IS_UNUSED;
|
|
}
|
|
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2);
|
|
break;
|
|
}
|
|
case ZEND_DECLARE_ANON_CLASS:
|
|
case ZEND_DECLARE_ANON_INHERITED_CLASS:
|
|
case ZEND_FE_FETCH_R:
|
|
case ZEND_FE_FETCH_RW:
|
|
/* absolute index to relative offset */
|
|
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
|
|
break;
|
|
case ZEND_CATCH:
|
|
if (!(opline->extended_value & ZEND_LAST_CATCH)) {
|
|
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2);
|
|
}
|
|
break;
|
|
case ZEND_RETURN:
|
|
case ZEND_RETURN_BY_REF:
|
|
if (op_array->fn_flags & ZEND_ACC_GENERATOR) {
|
|
opline->opcode = ZEND_GENERATOR_RETURN;
|
|
}
|
|
break;
|
|
case ZEND_SWITCH_LONG:
|
|
case ZEND_SWITCH_STRING:
|
|
{
|
|
/* absolute indexes to relative offsets */
|
|
HashTable *jumptable = Z_ARRVAL_P(CT_CONSTANT(opline->op2));
|
|
zval *zv;
|
|
ZEND_HASH_FOREACH_VAL(jumptable, zv) {
|
|
Z_LVAL_P(zv) = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, Z_LVAL_P(zv));
|
|
} ZEND_HASH_FOREACH_END();
|
|
|
|
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
|
|
break;
|
|
}
|
|
}
|
|
if (opline->op1_type == IS_CONST) {
|
|
ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, opline->op1);
|
|
} else if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
|
|
opline->op1.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->op1.var);
|
|
}
|
|
if (opline->op2_type == IS_CONST) {
|
|
ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, opline->op2);
|
|
} else if (opline->op2_type & (IS_VAR|IS_TMP_VAR)) {
|
|
opline->op2.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->op2.var);
|
|
}
|
|
if (opline->result_type & (IS_VAR|IS_TMP_VAR)) {
|
|
opline->result.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->result.var);
|
|
}
|
|
ZEND_VM_SET_OPCODE_HANDLER(opline);
|
|
opline++;
|
|
}
|
|
|
|
if (op_array->live_range) {
|
|
int i;
|
|
|
|
zend_sort_live_ranges(op_array);
|
|
for (i = 0; i < op_array->last_live_range; i++) {
|
|
op_array->live_range[i].var =
|
|
(uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + (op_array->live_range[i].var / sizeof(zval))) |
|
|
(op_array->live_range[i].var & ZEND_LIVE_MASK);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
ZEND_API unary_op_type get_unary_op(int opcode)
|
|
{
|
|
switch (opcode) {
|
|
case ZEND_BW_NOT:
|
|
return (unary_op_type) bitwise_not_function;
|
|
case ZEND_BOOL_NOT:
|
|
return (unary_op_type) boolean_not_function;
|
|
default:
|
|
return (unary_op_type) NULL;
|
|
}
|
|
}
|
|
|
|
ZEND_API binary_op_type get_binary_op(int opcode)
|
|
{
|
|
switch (opcode) {
|
|
case ZEND_ADD:
|
|
case ZEND_ASSIGN_ADD:
|
|
return (binary_op_type) add_function;
|
|
case ZEND_SUB:
|
|
case ZEND_ASSIGN_SUB:
|
|
return (binary_op_type) sub_function;
|
|
case ZEND_MUL:
|
|
case ZEND_ASSIGN_MUL:
|
|
return (binary_op_type) mul_function;
|
|
case ZEND_POW:
|
|
case ZEND_ASSIGN_POW:
|
|
return (binary_op_type) pow_function;
|
|
case ZEND_DIV:
|
|
case ZEND_ASSIGN_DIV:
|
|
return (binary_op_type) div_function;
|
|
case ZEND_MOD:
|
|
case ZEND_ASSIGN_MOD:
|
|
return (binary_op_type) mod_function;
|
|
case ZEND_SL:
|
|
case ZEND_ASSIGN_SL:
|
|
return (binary_op_type) shift_left_function;
|
|
case ZEND_SR:
|
|
case ZEND_ASSIGN_SR:
|
|
return (binary_op_type) shift_right_function;
|
|
case ZEND_FAST_CONCAT:
|
|
case ZEND_CONCAT:
|
|
case ZEND_ASSIGN_CONCAT:
|
|
return (binary_op_type) concat_function;
|
|
case ZEND_IS_IDENTICAL:
|
|
return (binary_op_type) is_identical_function;
|
|
case ZEND_IS_NOT_IDENTICAL:
|
|
return (binary_op_type) is_not_identical_function;
|
|
case ZEND_IS_EQUAL:
|
|
case ZEND_CASE:
|
|
return (binary_op_type) is_equal_function;
|
|
case ZEND_IS_NOT_EQUAL:
|
|
return (binary_op_type) is_not_equal_function;
|
|
case ZEND_IS_SMALLER:
|
|
return (binary_op_type) is_smaller_function;
|
|
case ZEND_IS_SMALLER_OR_EQUAL:
|
|
return (binary_op_type) is_smaller_or_equal_function;
|
|
case ZEND_SPACESHIP:
|
|
return (binary_op_type) compare_function;
|
|
case ZEND_BW_OR:
|
|
case ZEND_ASSIGN_BW_OR:
|
|
return (binary_op_type) bitwise_or_function;
|
|
case ZEND_BW_AND:
|
|
case ZEND_ASSIGN_BW_AND:
|
|
return (binary_op_type) bitwise_and_function;
|
|
case ZEND_BW_XOR:
|
|
case ZEND_ASSIGN_BW_XOR:
|
|
return (binary_op_type) bitwise_xor_function;
|
|
case ZEND_BOOL_XOR:
|
|
return (binary_op_type) boolean_xor_function;
|
|
default:
|
|
return (binary_op_type) NULL;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Local variables:
|
|
* tab-width: 4
|
|
* c-basic-offset: 4
|
|
* indent-tabs-mode: t
|
|
* End:
|
|
* vim600: sw=4 ts=4 fdm=marker
|
|
* vim<600: sw=4 ts=4
|
|
*/
|