1999-04-08 02:10:10 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2019-01-30 17:23:29 +08:00
|
|
|
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
|
1999-04-08 02:10:10 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2001-12-11 23:16:21 +08:00
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
2015-01-03 17:22:58 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-11 04:04:29 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
2001-12-11 23:16:21 +08:00
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
1999-07-16 22:58:16 +08:00
|
|
|
| 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. |
|
1999-04-08 02:10:10 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2018-11-01 23:20:07 +08:00
|
|
|
| Authors: Andi Gutmans <andi@php.net> |
|
|
|
|
| Zeev Suraski <zeev@php.net> |
|
|
|
|
| Dmitry Stogov <dmitry@php.net> |
|
1999-04-08 02:10:10 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "zend.h"
|
|
|
|
#include "zend_alloc.h"
|
|
|
|
#include "zend_compile.h"
|
|
|
|
#include "zend_extensions.h"
|
|
|
|
#include "zend_API.h"
|
2018-02-17 04:47:00 +08:00
|
|
|
#include "zend_sort.h"
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2004-09-24 05:43:32 +08:00
|
|
|
#include "zend_vm.h"
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static void zend_extension_op_array_ctor_handler(zend_extension *extension, zend_op_array *op_array)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
|
|
|
if (extension->op_array_ctor) {
|
2000-04-29 19:55:20 +08:00
|
|
|
extension->op_array_ctor(op_array);
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static void zend_extension_op_array_dtor_handler(zend_extension *extension, zend_op_array *op_array)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
|
|
|
if (extension->op_array_dtor) {
|
2000-04-29 19:55:20 +08:00
|
|
|
extension->op_array_dtor(op_array);
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
2000-04-29 09:30:17 +08:00
|
|
|
op_array->type = type;
|
2015-04-23 02:46:13 +08:00
|
|
|
op_array->arg_flags[0] = 0;
|
|
|
|
op_array->arg_flags[1] = 0;
|
|
|
|
op_array->arg_flags[2] = 0;
|
2001-07-15 22:08:58 +08:00
|
|
|
|
2014-08-26 01:28:33 +08:00
|
|
|
op_array->refcount = (uint32_t *) emalloc(sizeof(uint32_t));
|
1999-04-08 02:10:10 +08:00
|
|
|
*op_array->refcount = 1;
|
|
|
|
op_array->last = 0;
|
2018-07-26 08:47:56 +08:00
|
|
|
op_array->opcodes = emalloc(initial_ops_size * sizeof(zend_op));
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2004-10-05 03:54:35 +08:00
|
|
|
op_array->last_var = 0;
|
|
|
|
op_array->vars = NULL;
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
op_array->T = 0;
|
|
|
|
|
|
|
|
op_array->function_name = NULL;
|
2014-12-14 06:06:14 +08:00
|
|
|
op_array->filename = zend_get_compiled_filename();
|
2004-02-20 14:59:37 +08:00
|
|
|
op_array->doc_comment = NULL;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
ntroduce infrastructure for supplying information about arguments,
including:
- Whether or not to pass by ref (replaces the old arg_types, with arg_info)
- Argument name (for future use, maybe introspection)
- Class/Interface name (for type hints)
- If a class/interface name is available, whether to allow a null instance
Both user and builtin functions share the same data structures.
To declare a builtin function that expects its first arg to be an instance
of class 'Person', its second argument as a regular arg, and its third by
reference, use:
ZEND_BEGIN_ARG_INFO(my_func_arg_info, 0)
ZEND_ARG_OBJ_INFO(0, someone, Person, 1)
ZEND_ARG_PASS_INFO(0)
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO();
and use my_func_arg_info as the arg_info parameter to the ZEND_FE() family
of macros.
The first arg to each ZEND_ARG_*() macro is whether or not to pass by ref.
The boolean arg to ZEND_BEGIN_ARG_INFO() tells the engine whether to treat
the arguments for which there's no explicit information as pass by reference
or not.
The boolean argument to ZEND_ARG_OBJ_INFO() (4th arg) is whether or not to allownull values.
2003-08-04 01:40:44 +08:00
|
|
|
op_array->arg_info = NULL;
|
|
|
|
op_array->num_args = 0;
|
2004-02-25 17:25:37 +08:00
|
|
|
op_array->required_num_args = 0;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2002-03-01 22:04:51 +08:00
|
|
|
op_array->scope = NULL;
|
2014-07-16 06:06:41 +08:00
|
|
|
op_array->prototype = NULL;
|
2002-03-01 22:04:51 +08:00
|
|
|
|
2015-11-11 02:48:03 +08:00
|
|
|
op_array->live_range = NULL;
|
2004-02-03 20:17:09 +08:00
|
|
|
op_array->try_catch_array = NULL;
|
2015-11-11 02:48:03 +08:00
|
|
|
op_array->last_live_range = 0;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
|
|
|
op_array->static_variables = NULL;
|
2018-10-17 20:52:50 +08:00
|
|
|
ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, &op_array->static_variables);
|
2004-02-03 20:17:09 +08:00
|
|
|
op_array->last_try_catch = 0;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2014-08-26 05:45:02 +08:00
|
|
|
op_array->fn_flags = 0;
|
2007-02-15 18:38:28 +08:00
|
|
|
|
2010-04-20 18:57:45 +08:00
|
|
|
op_array->last_literal = 0;
|
|
|
|
op_array->literals = NULL;
|
|
|
|
|
2018-10-17 20:52:50 +08:00
|
|
|
ZEND_MAP_PTR_INIT(op_array->run_time_cache, NULL);
|
|
|
|
op_array->cache_size = zend_op_array_extension_handles * sizeof(void*);
|
2010-05-24 22:11:39 +08:00
|
|
|
|
2007-11-19 05:29:55 +08:00
|
|
|
memset(op_array->reserved, 0, ZEND_MAX_RESERVED_RESOURCES * sizeof(void*));
|
|
|
|
|
2015-09-25 16:50:38 +08:00
|
|
|
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);
|
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API void destroy_zend_function(zend_function *function)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
2018-06-27 19:54:42 +08:00
|
|
|
zval tmp;
|
|
|
|
|
|
|
|
ZVAL_PTR(&tmp, function);
|
|
|
|
zend_function_dtor(&tmp);
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
|
2014-02-17 21:59:18 +08:00
|
|
|
ZEND_API void zend_function_dtor(zval *zv)
|
2004-06-06 16:37:12 +08:00
|
|
|
{
|
2014-02-17 21:59:18 +08:00
|
|
|
zend_function *function = Z_PTR_P(zv);
|
2004-06-06 16:37:12 +08:00
|
|
|
|
2014-09-23 16:35:42 +08:00
|
|
|
if (function->type == ZEND_USER_FUNCTION) {
|
|
|
|
ZEND_ASSERT(function->common.function_name);
|
2014-12-14 06:06:14 +08:00
|
|
|
destroy_op_array(&function->op_array);
|
2014-09-23 16:35:42 +08:00
|
|
|
/* 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);
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(function->common.function_name, 1);
|
2018-03-06 19:59:30 +08:00
|
|
|
|
2017-09-13 06:44:19 +08:00
|
|
|
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)) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(ZEND_TYPE_NAME(arg_info[i].type), 1);
|
2017-09-13 06:44:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
free(arg_info);
|
|
|
|
}
|
2018-03-06 19:59:30 +08:00
|
|
|
|
2014-09-23 16:35:42 +08:00
|
|
|
if (!(function->common.fn_flags & ZEND_ACC_ARENA_ALLOCATED)) {
|
|
|
|
pefree(function, 1);
|
|
|
|
}
|
2014-06-18 06:47:01 +08:00
|
|
|
}
|
2004-06-06 16:37:12 +08:00
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce)
|
2010-07-06 19:40:17 +08:00
|
|
|
{
|
|
|
|
if (CE_STATIC_MEMBERS(ce)) {
|
2015-01-13 08:32:51 +08:00
|
|
|
zval *static_members = CE_STATIC_MEMBERS(ce);
|
2015-04-29 00:11:45 +08:00
|
|
|
zval *p = static_members;
|
|
|
|
zval *end = p + ce->default_static_members_count;
|
2015-01-03 17:22:58 +08:00
|
|
|
|
2018-10-17 20:52:50 +08:00
|
|
|
ZEND_MAP_PTR_SET(ce->static_members_table, NULL);
|
2015-04-29 00:11:45 +08:00
|
|
|
while (p != end) {
|
2019-01-07 19:28:51 +08:00
|
|
|
if (UNEXPECTED(Z_ISREF_P(p))) {
|
|
|
|
zend_property_info *prop_info;
|
|
|
|
ZEND_REF_FOREACH_TYPE_SOURCES(Z_REF_P(p), prop_info) {
|
|
|
|
if (prop_info->ce == ce && p - static_members == prop_info->offset) {
|
|
|
|
ZEND_REF_DEL_TYPE_SOURCE(Z_REF_P(p), prop_info);
|
|
|
|
break; /* stop iteration here, the array might be realloc()'ed */
|
|
|
|
}
|
|
|
|
} ZEND_REF_FOREACH_TYPE_SOURCES_END();
|
|
|
|
}
|
2018-09-16 23:12:44 +08:00
|
|
|
i_zval_ptr_dtor(p);
|
2015-04-29 00:11:45 +08:00
|
|
|
p++;
|
2015-01-13 08:32:51 +08:00
|
|
|
}
|
|
|
|
efree(static_members);
|
2003-01-30 01:54:48 +08:00
|
|
|
}
|
2010-07-06 19:40:17 +08:00
|
|
|
}
|
|
|
|
|
2018-08-23 07:02:26 +08:00
|
|
|
static void _destroy_zend_class_traits_info(zend_class_entry *ce)
|
2010-05-03 00:32:25 +08:00
|
|
|
{
|
2018-08-23 07:02:26 +08:00
|
|
|
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);
|
2010-05-03 00:32:25 +08:00
|
|
|
}
|
2018-08-23 07:02:26 +08:00
|
|
|
efree(ce->trait_names);
|
2015-01-03 17:22:58 +08:00
|
|
|
|
2010-05-03 00:32:25 +08:00
|
|
|
if (ce->trait_aliases) {
|
2018-08-23 07:02:26 +08:00
|
|
|
i = 0;
|
2010-05-03 00:32:25 +08:00
|
|
|
while (ce->trait_aliases[i]) {
|
2018-07-11 23:56:10 +08:00
|
|
|
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);
|
2010-05-03 00:32:25 +08:00
|
|
|
}
|
2015-01-03 17:22:58 +08:00
|
|
|
|
2010-05-03 00:32:25 +08:00
|
|
|
if (ce->trait_aliases[i]->alias) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(ce->trait_aliases[i]->alias, 0);
|
2010-05-03 00:32:25 +08:00
|
|
|
}
|
2015-01-03 17:22:58 +08:00
|
|
|
|
2010-05-03 00:32:25 +08:00
|
|
|
efree(ce->trait_aliases[i]);
|
|
|
|
i++;
|
|
|
|
}
|
2015-01-03 17:22:58 +08:00
|
|
|
|
2010-05-03 00:32:25 +08:00
|
|
|
efree(ce->trait_aliases);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ce->trait_precedences) {
|
2019-01-09 05:08:40 +08:00
|
|
|
uint32_t j;
|
2015-01-03 17:22:58 +08:00
|
|
|
|
2018-08-23 07:02:26 +08:00
|
|
|
i = 0;
|
2010-05-03 00:32:25 +08:00
|
|
|
while (ce->trait_precedences[i]) {
|
2018-07-11 23:56:10 +08:00
|
|
|
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);
|
2010-05-03 00:32:25 +08:00
|
|
|
}
|
|
|
|
efree(ce->trait_precedences[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
efree(ce->trait_precedences);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-17 21:59:18 +08:00
|
|
|
ZEND_API void destroy_zend_class(zval *zv)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
2015-03-04 22:41:01 +08:00
|
|
|
zend_property_info *prop_info;
|
2014-02-17 21:59:18 +08:00
|
|
|
zend_class_entry *ce = Z_PTR_P(zv);
|
2017-09-13 06:44:19 +08:00
|
|
|
zend_function *fn;
|
2015-01-03 17:22:58 +08:00
|
|
|
|
2018-10-17 20:52:50 +08:00
|
|
|
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) {
|
2000-01-18 01:33:37 +08:00
|
|
|
return;
|
1999-04-18 23:11:52 +08:00
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
switch (ce->type) {
|
|
|
|
case ZEND_USER_CLASS:
|
2018-09-18 16:41:40 +08:00
|
|
|
if (ce->parent_name && !(ce->ce_flags & ZEND_ACC_LINKED)) {
|
2018-08-24 05:20:57 +08:00
|
|
|
zend_string_release_ex(ce->parent_name, 0);
|
|
|
|
}
|
2010-05-24 22:11:39 +08:00
|
|
|
if (ce->default_properties_table) {
|
2015-04-29 00:11:45 +08:00
|
|
|
zval *p = ce->default_properties_table;
|
|
|
|
zval *end = p + ce->default_properties_count;
|
2010-05-24 22:11:39 +08:00
|
|
|
|
2015-04-29 00:11:45 +08:00
|
|
|
while (p != end) {
|
2018-09-16 23:12:44 +08:00
|
|
|
i_zval_ptr_dtor(p);
|
2015-04-29 00:11:45 +08:00
|
|
|
p++;
|
2010-05-24 22:11:39 +08:00
|
|
|
}
|
|
|
|
efree(ce->default_properties_table);
|
|
|
|
}
|
|
|
|
if (ce->default_static_members_table) {
|
2015-04-29 00:11:45 +08:00
|
|
|
zval *p = ce->default_static_members_table;
|
|
|
|
zval *end = p + ce->default_static_members_count;
|
2010-05-24 22:11:39 +08:00
|
|
|
|
2015-04-29 00:11:45 +08:00
|
|
|
while (p != end) {
|
2019-01-07 19:28:51 +08:00
|
|
|
if (UNEXPECTED(Z_ISREF_P(p))) {
|
|
|
|
zend_property_info *prop_info;
|
|
|
|
ZEND_REF_FOREACH_TYPE_SOURCES(Z_REF_P(p), prop_info) {
|
|
|
|
if (prop_info->ce == ce && p - ce->default_static_members_table == prop_info->offset) {
|
|
|
|
ZEND_REF_DEL_TYPE_SOURCE(Z_REF_P(p), prop_info);
|
|
|
|
break; /* stop iteration here, the array might be realloc()'ed */
|
|
|
|
}
|
|
|
|
} ZEND_REF_FOREACH_TYPE_SOURCES_END();
|
|
|
|
}
|
2018-09-16 23:12:44 +08:00
|
|
|
i_zval_ptr_dtor(p);
|
2015-04-29 00:11:45 +08:00
|
|
|
p++;
|
2010-05-24 22:11:39 +08:00
|
|
|
}
|
|
|
|
efree(ce->default_static_members_table);
|
|
|
|
}
|
2015-03-04 22:41:01 +08:00
|
|
|
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) {
|
2018-09-11 16:56:45 +08:00
|
|
|
if (prop_info->ce == ce) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(prop_info->name, 0);
|
2015-03-04 22:41:01 +08:00
|
|
|
if (prop_info->doc_comment) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(prop_info->doc_comment, 0);
|
2015-03-04 22:41:01 +08:00
|
|
|
}
|
2019-01-07 19:28:51 +08:00
|
|
|
if (ZEND_TYPE_IS_NAME(prop_info->type)) {
|
|
|
|
zend_string_release(ZEND_TYPE_NAME(prop_info->type));
|
|
|
|
}
|
2015-03-04 22:41:01 +08:00
|
|
|
}
|
|
|
|
} ZEND_HASH_FOREACH_END();
|
2003-02-05 21:35:52 +08:00
|
|
|
zend_hash_destroy(&ce->properties_info);
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(ce->name, 0);
|
1999-04-08 02:10:10 +08:00
|
|
|
zend_hash_destroy(&ce->function_table);
|
2015-12-08 17:40:42 +08:00
|
|
|
if (zend_hash_num_elements(&ce->constants_table)) {
|
|
|
|
zend_class_constant *c;
|
|
|
|
|
|
|
|
ZEND_HASH_FOREACH_PTR(&ce->constants_table, c) {
|
2016-01-22 11:22:37 +08:00
|
|
|
if (c->ce == ce) {
|
2017-10-09 17:24:11 +08:00
|
|
|
zval_ptr_dtor_nogc(&c->value);
|
2016-01-22 11:22:37 +08:00
|
|
|
if (c->doc_comment) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(c->doc_comment, 0);
|
2016-01-22 11:22:37 +08:00
|
|
|
}
|
2015-12-08 17:40:42 +08:00
|
|
|
}
|
|
|
|
} ZEND_HASH_FOREACH_END();
|
|
|
|
}
|
2018-08-17 13:35:15 +08:00
|
|
|
zend_hash_destroy(&ce->constants_table);
|
2018-08-23 22:16:28 +08:00
|
|
|
if (ce->num_interfaces > 0) {
|
2018-09-18 16:41:40 +08:00
|
|
|
if (!(ce->ce_flags & ZEND_ACC_LINKED)) {
|
2018-08-23 22:16:28 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2003-03-05 19:14:44 +08:00
|
|
|
efree(ce->interfaces);
|
|
|
|
}
|
2010-09-15 15:38:52 +08:00
|
|
|
if (ce->info.user.doc_comment) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(ce->info.user.doc_comment, 0);
|
2003-04-01 04:42:01 +08:00
|
|
|
}
|
2015-01-03 17:22:58 +08:00
|
|
|
|
2018-08-23 07:02:26 +08:00
|
|
|
if (ce->num_traits > 0) {
|
|
|
|
_destroy_zend_class_traits_info(ce);
|
|
|
|
}
|
2015-01-03 17:22:58 +08:00
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
|
|
|
case ZEND_INTERNAL_CLASS:
|
2010-05-24 22:11:39 +08:00
|
|
|
if (ce->default_properties_table) {
|
2015-04-29 00:11:45 +08:00
|
|
|
zval *p = ce->default_properties_table;
|
|
|
|
zval *end = p + ce->default_properties_count;
|
2010-05-24 22:11:39 +08:00
|
|
|
|
2015-04-29 00:11:45 +08:00
|
|
|
while (p != end) {
|
|
|
|
zval_internal_ptr_dtor(p);
|
|
|
|
p++;
|
2010-05-24 22:11:39 +08:00
|
|
|
}
|
|
|
|
free(ce->default_properties_table);
|
|
|
|
}
|
|
|
|
if (ce->default_static_members_table) {
|
2015-04-29 00:11:45 +08:00
|
|
|
zval *p = ce->default_static_members_table;
|
|
|
|
zval *end = p + ce->default_static_members_count;
|
2010-05-24 22:11:39 +08:00
|
|
|
|
2015-04-29 00:11:45 +08:00
|
|
|
while (p != end) {
|
|
|
|
zval_internal_ptr_dtor(p);
|
|
|
|
p++;
|
2010-05-24 22:11:39 +08:00
|
|
|
}
|
|
|
|
free(ce->default_static_members_table);
|
2018-10-17 20:52:50 +08:00
|
|
|
if (ZEND_MAP_PTR(ce->static_members_table) != &ce->default_static_members_table) {
|
|
|
|
zend_cleanup_internal_class_data(ce);
|
|
|
|
}
|
2010-05-24 22:11:39 +08:00
|
|
|
}
|
2003-02-05 21:35:52 +08:00
|
|
|
zend_hash_destroy(&ce->properties_info);
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(ce->name, 1);
|
2018-03-06 19:59:30 +08:00
|
|
|
|
|
|
|
/* TODO: eliminate this loop for classes without functions with arg_info */
|
2017-09-13 06:44:19 +08:00
|
|
|
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();
|
2018-03-06 19:59:30 +08:00
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
zend_hash_destroy(&ce->function_table);
|
2015-12-08 17:40:42 +08:00
|
|
|
if (zend_hash_num_elements(&ce->constants_table)) {
|
|
|
|
zend_class_constant *c;
|
|
|
|
|
|
|
|
ZEND_HASH_FOREACH_PTR(&ce->constants_table, c) {
|
2017-10-31 04:13:10 +08:00
|
|
|
if (c->ce == ce) {
|
|
|
|
zval_internal_ptr_dtor(&c->value);
|
|
|
|
if (c->doc_comment) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(c->doc_comment, 1);
|
2017-10-31 04:13:10 +08:00
|
|
|
}
|
2015-12-08 17:40:42 +08:00
|
|
|
}
|
2017-10-31 06:20:38 +08:00
|
|
|
free(c);
|
2015-12-08 17:40:42 +08:00
|
|
|
} ZEND_HASH_FOREACH_END();
|
|
|
|
zend_hash_destroy(&ce->constants_table);
|
|
|
|
}
|
2018-07-12 19:04:14 +08:00
|
|
|
if (ce->iterator_funcs_ptr) {
|
|
|
|
free(ce->iterator_funcs_ptr);
|
|
|
|
}
|
2003-04-19 02:40:53 +08:00
|
|
|
if (ce->num_interfaces > 0) {
|
|
|
|
free(ce->interfaces);
|
|
|
|
}
|
2019-01-07 19:28:51 +08:00
|
|
|
if (ce->properties_info_table) {
|
|
|
|
free(ce->properties_info_table);
|
|
|
|
}
|
2002-03-12 18:08:47 +08:00
|
|
|
free(ce);
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
2003-04-01 04:42:01 +08:00
|
|
|
}
|
2003-02-16 19:12:43 +08:00
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2014-02-17 21:59:18 +08:00
|
|
|
void zend_class_add_ref(zval *zv)
|
1999-04-26 22:10:42 +08:00
|
|
|
{
|
2014-02-17 21:59:18 +08:00
|
|
|
zend_class_entry *ce = Z_PTR_P(zv);
|
|
|
|
|
Implemented preloading RFC: https://wiki.php.net/rfc/preload.
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: d516139abf ba99aa133c
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
...
commit 45fdd034ceceb68e8fb23bd6e70d627f17dfd411
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.
commit 34645aeb4272b71a81a7e0d91f27eded557b78be
Author: Dmitry Stogov <dmitry@zend.com>
Date: Thu Nov 8 15:29:17 2018 +0300
Don't preload constants defined during preload script excution.
commit cef0d67c3e5aac89b3d606fbd8d445225c07c83f
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Nov 7 15:56:54 2018 +0300
Support for class aliasses
commit 08ffc9a552c7cf4fbff1a4b3d2de4e7c33f4120d
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Nov 7 15:34:39 2018 +0300
Resolve constants only in linked classes
commit 8d3429cda83c87646eef0006d5cda075f2400b24
Author: Dmitry Stogov <dmitry@zend.com>
Date: Tue Nov 6 11:56:39 2018 +0300
Fixed preloading of references to internal classes.
commit 7ae3a47d20e83f7d804506c6d50f6a392199260b
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
Backport 7f5f4601 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
commit 9b0a53ed1cd5995efae0d71e1941d1db4ef6ba39
Author: Dmitry Stogov <dmitry@zend.com>
Date: Fri Nov 2 14:54:44 2018 +0300
We don't need preload_restart() here
commit 0bd17bd43890423e1e98a5925f11cea93da3df55
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(*).
commit b610467051d8a3687a60ffc2957bc353cb6b3bd4
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...
commit 3a9d90f74a3d890cb59658d604d5a202e3aee256
Author: Dmitry Stogov <dmitry@zend.com>
Date: Thu Nov 1 15:19:48 2018 +0300
Fexed resolution of method clones
commit aea85c65bd1795d0750dee6ac0e476acd2ac9dd7
Author: Dmitry Stogov <dmitry@zend.com>
Date: Thu Nov 1 11:45:50 2018 +0300
Prevent inlining of method copied from trait
commit 36b644fbb738e7548ccb436e5d04d653d93cce14
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
commit 7a20781d2ee694262f913a612d8b0b6a24ceff7b
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Oct 31 00:52:46 2018 +0300
Added test
commit 4a57b5d563f9c9616f3c236f57ccd09d8a66f146
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Oct 31 00:50:21 2018 +0300
Fixed preloading of classes linked with traits
commit 68c4f99e23695e74eafa43097ecab62392bad3ee
Author: Dmitry Stogov <dmitry@zend.com>
Date: Tue Oct 30 16:25:14 2018 +0300
Added test
commit 38ab7ef4cf429dcfd5dfb18f844242cdf3a4d61f
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"
commit eb6e2c529f8cedf6823346387dd8b0ba6a4f045b
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.
commit 562049510f605c21cd46fc3b6f97ed15bfe7b0dc
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
commit e806cb732a2a3f1e409528988a0571421c541078
Author: Dmitry Stogov <dmitry@zend.com>
Date: Mon Oct 29 22:32:15 2018 +0300
Fixed double-free
commit 2f697ef8af0e7b21c47707b2d688880e8c987a8b
Author: Dmitry Stogov <dmitry@zend.com>
Date: Mon Oct 29 22:07:32 2018 +0300
typo
commit c559f22b3e61b38761831d9610889d28ba6875e0
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
commit 310631cc0565ac87091c4f1a8a9f739a13e7e778
Author: Dmitry Stogov <dmitry@zend.com>
Date: Mon Oct 29 16:48:42 2018 +0300
Stop Apache if PHP wasn't started successful.
commit 0a24d7ba8f3280507c9663b32e14030212cf8491
Author: Dmitry Stogov <dmitry@zend.com>
Date: Mon Oct 29 16:25:49 2018 +0300
Avoid use-after-free in main thread
commit 17a3cb4a2ab271c2b2357c04e36efa64e02444ff
Author: Dmitry Stogov <dmitry@zend.com>
Date: Mon Oct 29 15:25:17 2018 +0300
Execute zend_post_startup() with module_initialized flag set.
commit 6d4b22c518bec956e9632fad4329360304d17fd7
Author: Dmitry Stogov <dmitry@zend.com>
Date: Mon Oct 29 14:12:20 2018 +0300
Override SAPI.ub_write and SAPI.flush for preloading
commit 386c9d3470168f70afe5d3b72a58ea0c0da1519c
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
commit d7fbb4d402a18c8fd1c49e0c92afd9f9e513bc7a
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.
commit 0fe9ea1c07822b5d4672cece2c180bf9795e16e4
Author: Dmitry Stogov <dmitry@zend.com>
Date: Fri Oct 26 12:29:06 2018 +0300
Removed dead code
commit 3a2d1bcc1fd27b6983522c262931fc0187c0afef
Author: Dmitry Stogov <dmitry@zend.com>
Date: Fri Oct 26 00:19:40 2018 +0300
Support for builds without ZEND_SIGNALS
commit e6b76ecb4beea3b922bf7529050e3828f745dedb
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.
commit 4531fbf9310bfb7bb579134cc84e8c10c5d42059
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.
commit a594a618ce98242c1d273eb9ede75b4f6b4635d8
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
commit ab9a40f63cfa1a205b8f853b7e0c2ce61edabb32
Author: Dmitry Stogov <dmitry@zend.com>
Date: Thu Oct 25 20:52:51 2018 +0300
Added support for preloaded classes/functions in ZTS build
commit e3c65db099517082b66dd20ea57e1bda649a7aa5
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
commit 4f57c1e029ce9c24bd699ea61b05973c4665bc32
Author: Dmitry Stogov <dmitry@zend.com>
Date: Thu Oct 25 15:29:58 2018 +0300
Cleanup (move preload_shutdown() call to better place)
commit 26587a95c071cf9dd098199eb3708fca8adae243
Author: Dmitry Stogov <dmitry@zend.com>
Date: Thu Oct 25 14:30:51 2018 +0300
eol
commit d70cb10480fdc7d814495150cd48e43d4147138f
Author: Dmitry Stogov <dmitry@zend.com>
Date: Thu Oct 25 14:30:20 2018 +0300
cleanup
commit aabe685dbb887e91c240b6c5553193889bcfc540
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
commit d9fc51bc3bdfbd7f4149a884b09e3c09a41f7a8d
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.
commit b5ffba0fafb4d940336d5f5fe93950dad1d8d779
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
commit e4a7ef0c431ec97cdd00e44dfa0ef17887d1e5e3
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 by 9c144e0d8217d1ef7a83c2498214308b21af749f
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
...
commit 811f20aaa5030035666d9f325dd7c64632c70a50
Author: Dmitry Stogov <dmitry@zend.com>
Date: Mon Oct 22 14:10:49 2018 +0300
Added information about preloading to opcache_get_status()
commit 093e8b1bbffdc07d217a543613ea14c3eeac710e
Author: Dmitry Stogov <dmitry@zend.com>
Date: Fri Oct 19 13:46:23 2018 +0300
Added warning message
commit a2ba970ce3d0ac51ebfbe1bfc2dc7b99b9750a75
Author: Dmitry Stogov <dmitry@zend.com>
Date: Fri Oct 19 13:35:40 2018 +0300
Added test
commit b67e28367c11db50360e664a7ad6ac95b393f2e4
Author: Dmitry Stogov <dmitry@zend.com>
Date: Fri Oct 19 13:33:12 2018 +0300
Don't preload functions declared at run-time.
commit b0139dc22854ee000586ef83c149d7d25181da60
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
commit a609520adbc0bf12701d467bae4a016fde43231e
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
commit ac8f45f61b561af9aee629232bc3705143ceaac3
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.
commit 632b30b5451c8fdf0879a3ba4d937ff4ecfc8ce7
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
commit cd0c36c3f943849e5b97a8dbe2dd029fbeab3df9
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
commit d33908a99a3c746f188e268df3db541591f6fcc2
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.
commit 4740dabb843c6d4f7f866b4a2456073c9eaf4c77
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.
commit 21e0bebca3e6fff3c3484ee46f9aa3ac4e98eaeb
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
commit ad7a78b253be970db70c2251e66f9297d8e7f829
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Oct 17 11:46:30 2018 +0300
Added comment
commit 0276ea51875bab37be01a4dc5e5a047c5698c571
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Oct 17 11:42:43 2018 +0300
Added type cast
commit c63fc5d5f19c58498108d1698055b2b442227eb3
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Oct 17 11:36:51 2018 +0300
Moved static class members initialization into the proper place.
commit b945548e9306b1826c881918858b5e5aa3eb3002
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Oct 17 11:21:03 2018 +0300
Removed redundand assertion
commit d5a41088401814c829847db212488f8aae39bcd2
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Oct 17 11:19:13 2018 +0300
Removed duplicate code
commit 8dadca8864e66de70a24bdf1181bcf7dd8fb27d7
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.
commit 9ef07c88bd76801e2d4fbfeab3ebfd6e6a67ac5f
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Oct 17 10:48:29 2018 +0300
typo
commit a06f0f3d3aba53e766046221ee44fb9720389ecc
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
commit c78277ae84b21067744d1701949e4e1fadd8872a
Author: Dmitry Stogov <dmitry@zend.com>
Date: Tue Oct 16 17:25:35 2018 +0300
Preloadsing support for opcache restart
commit f76a955c02f6a033d4656d5e0d9dad9a8e83cc86
Author: Dmitry Stogov <dmitry@zend.com>
Date: Tue Oct 16 13:52:36 2018 +0300
Fixed incorrect signal handlers overriding
commit 0810ce0d8165d4b752267f035f9fa0aaa1698ceb
Author: Dmitry Stogov <dmitry@zend.com>
Date: Mon Oct 15 23:38:48 2018 +0300
An attempt to implemnt "preloading" ability.
commit 94099586ec599117581ca01c15b1f6c5f749e23a
Author: Dmitry Stogov <dmitry@zend.com>
Date: Mon Oct 15 23:34:01 2018 +0300
Immutable clases and op_arrays
2018-11-14 21:46:05 +08:00
|
|
|
if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
|
|
|
|
ce->refcount++;
|
|
|
|
}
|
1999-04-26 22:10:42 +08:00
|
|
|
}
|
|
|
|
|
2015-08-04 06:00:10 +08:00
|
|
|
ZEND_API void destroy_op_array(zend_op_array *op_array)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
2014-08-26 01:28:33 +08:00
|
|
|
uint32_t i;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2018-10-17 20:52:50 +08:00
|
|
|
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);
|
|
|
|
}
|
2015-02-20 18:28:26 +08:00
|
|
|
}
|
1999-12-24 03:23:36 +08:00
|
|
|
}
|
|
|
|
|
2018-10-17 20:52:50 +08:00
|
|
|
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));
|
2010-05-24 22:11:39 +08:00
|
|
|
}
|
|
|
|
|
2015-08-04 06:00:10 +08:00
|
|
|
if (!op_array->refcount || --(*op_array->refcount) > 0) {
|
|
|
|
return;
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
|
2014-08-28 00:49:56 +08:00
|
|
|
efree_size(op_array->refcount, sizeof(*(op_array->refcount)));
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2004-10-05 03:54:35 +08:00
|
|
|
if (op_array->vars) {
|
|
|
|
i = op_array->last_var;
|
|
|
|
while (i > 0) {
|
|
|
|
i--;
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(op_array->vars[i], 0);
|
2004-10-05 03:54:35 +08:00
|
|
|
}
|
|
|
|
efree(op_array->vars);
|
|
|
|
}
|
|
|
|
|
2018-01-11 17:15:34 +08:00
|
|
|
if (op_array->literals) {
|
|
|
|
zval *literal = op_array->literals;
|
|
|
|
zval *end = literal + op_array->last_literal;
|
2010-04-20 18:57:45 +08:00
|
|
|
while (literal < end) {
|
2014-09-03 21:16:32 +08:00
|
|
|
zval_ptr_dtor_nogc(literal);
|
2010-04-20 18:57:45 +08:00
|
|
|
literal++;
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
2017-10-04 21:53:01 +08:00
|
|
|
if (ZEND_USE_ABS_CONST_ADDR
|
|
|
|
|| !(op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO)) {
|
|
|
|
efree(op_array->literals);
|
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
efree(op_array->opcodes);
|
2004-07-29 23:23:47 +08:00
|
|
|
|
2012-12-25 14:23:08 +08:00
|
|
|
if (op_array->function_name) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(op_array->function_name, 0);
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
2004-02-20 14:59:37 +08:00
|
|
|
if (op_array->doc_comment) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(op_array->doc_comment, 0);
|
2004-02-20 14:59:37 +08:00
|
|
|
}
|
2015-11-11 02:48:03 +08:00
|
|
|
if (op_array->live_range) {
|
|
|
|
efree(op_array->live_range);
|
2015-07-10 08:31:52 +08:00
|
|
|
}
|
2004-02-03 20:17:09 +08:00
|
|
|
if (op_array->try_catch_array) {
|
|
|
|
efree(op_array->try_catch_array);
|
|
|
|
}
|
2015-09-25 16:50:38 +08:00
|
|
|
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);
|
|
|
|
}
|
2000-04-29 10:56:44 +08:00
|
|
|
}
|
ntroduce infrastructure for supplying information about arguments,
including:
- Whether or not to pass by ref (replaces the old arg_types, with arg_info)
- Argument name (for future use, maybe introspection)
- Class/Interface name (for type hints)
- If a class/interface name is available, whether to allow a null instance
Both user and builtin functions share the same data structures.
To declare a builtin function that expects its first arg to be an instance
of class 'Person', its second argument as a regular arg, and its third by
reference, use:
ZEND_BEGIN_ARG_INFO(my_func_arg_info, 0)
ZEND_ARG_OBJ_INFO(0, someone, Person, 1)
ZEND_ARG_PASS_INFO(0)
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO();
and use my_func_arg_info as the arg_info parameter to the ZEND_FE() family
of macros.
The first arg to each ZEND_ARG_*() macro is whether or not to pass by ref.
The boolean arg to ZEND_BEGIN_ARG_INFO() tells the engine whether to treat
the arguments for which there's no explicit information as pass by reference
or not.
The boolean argument to ZEND_ARG_OBJ_INFO() (4th arg) is whether or not to allownull values.
2003-08-04 01:40:44 +08:00
|
|
|
if (op_array->arg_info) {
|
2016-01-03 14:06:52 +08:00
|
|
|
uint32_t num_args = op_array->num_args;
|
2015-01-28 11:56:19 +08:00
|
|
|
zend_arg_info *arg_info = op_array->arg_info;
|
2014-12-22 21:44:39 +08:00
|
|
|
|
2015-01-28 11:56:19 +08:00
|
|
|
if (op_array->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
|
|
|
|
arg_info--;
|
|
|
|
num_args++;
|
|
|
|
}
|
2014-12-22 21:44:39 +08:00
|
|
|
if (op_array->fn_flags & ZEND_ACC_VARIADIC) {
|
|
|
|
num_args++;
|
|
|
|
}
|
2015-01-28 11:56:19 +08:00
|
|
|
for (i = 0 ; i < num_args; i++) {
|
|
|
|
if (arg_info[i].name) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(arg_info[i].name, 0);
|
2015-01-28 11:56:19 +08:00
|
|
|
}
|
2017-01-13 16:37:46 +08:00
|
|
|
if (ZEND_TYPE_IS_CLASS(arg_info[i].type)) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(ZEND_TYPE_NAME(arg_info[i].type), 0);
|
2003-08-04 06:28:14 +08:00
|
|
|
}
|
ntroduce infrastructure for supplying information about arguments,
including:
- Whether or not to pass by ref (replaces the old arg_types, with arg_info)
- Argument name (for future use, maybe introspection)
- Class/Interface name (for type hints)
- If a class/interface name is available, whether to allow a null instance
Both user and builtin functions share the same data structures.
To declare a builtin function that expects its first arg to be an instance
of class 'Person', its second argument as a regular arg, and its third by
reference, use:
ZEND_BEGIN_ARG_INFO(my_func_arg_info, 0)
ZEND_ARG_OBJ_INFO(0, someone, Person, 1)
ZEND_ARG_PASS_INFO(0)
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO();
and use my_func_arg_info as the arg_info parameter to the ZEND_FE() family
of macros.
The first arg to each ZEND_ARG_*() macro is whether or not to pass by ref.
The boolean arg to ZEND_BEGIN_ARG_INFO() tells the engine whether to treat
the arguments for which there's no explicit information as pass by reference
or not.
The boolean argument to ZEND_ARG_OBJ_INFO() (4th arg) is whether or not to allownull values.
2003-08-04 01:40:44 +08:00
|
|
|
}
|
2015-01-28 11:56:19 +08:00
|
|
|
efree(arg_info);
|
ntroduce infrastructure for supplying information about arguments,
including:
- Whether or not to pass by ref (replaces the old arg_types, with arg_info)
- Argument name (for future use, maybe introspection)
- Class/Interface name (for type hints)
- If a class/interface name is available, whether to allow a null instance
Both user and builtin functions share the same data structures.
To declare a builtin function that expects its first arg to be an instance
of class 'Person', its second argument as a regular arg, and its third by
reference, use:
ZEND_BEGIN_ARG_INFO(my_func_arg_info, 0)
ZEND_ARG_OBJ_INFO(0, someone, Person, 1)
ZEND_ARG_PASS_INFO(0)
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO();
and use my_func_arg_info as the arg_info parameter to the ZEND_FE() family
of macros.
The first arg to each ZEND_ARG_*() macro is whether or not to pass by ref.
The boolean arg to ZEND_BEGIN_ARG_INFO() tells the engine whether to treat
the arguments for which there's no explicit information as pass by reference
or not.
The boolean argument to ZEND_ARG_OBJ_INFO() (4th arg) is whether or not to allownull values.
2003-08-04 01:40:44 +08:00
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static void zend_update_extended_info(zend_op_array *op_array)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2000-12-30 23:32:12 +08:00
|
|
|
if (opline+1<end) {
|
|
|
|
opline->lineno = (opline+1)->lineno;
|
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
} else {
|
|
|
|
opline->opcode = ZEND_NOP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
opline++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static void zend_extension_op_array_handler(zend_extension *extension, zend_op_array *op_array)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
|
|
|
if (extension->op_array_handler) {
|
|
|
|
extension->op_array_handler(op_array);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static void zend_check_finally_breakout(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num)
|
2012-11-22 19:17:05 +08:00
|
|
|
{
|
2014-09-15 22:52:19 +08:00
|
|
|
int i;
|
2012-11-22 19:17:05 +08:00
|
|
|
|
|
|
|
for (i = 0; i < op_array->last_try_catch; i++) {
|
2013-12-13 00:15:50 +08:00
|
|
|
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;
|
2013-12-13 10:56:35 +08:00
|
|
|
zend_error_noreturn(E_COMPILE_ERROR, "jump into a finally block is disallowed");
|
2015-01-03 17:22:58 +08:00
|
|
|
} else if ((op_num >= op_array->try_catch_array[i].finally_op
|
2012-11-22 19:17:05 +08:00
|
|
|
&& op_num <= op_array->try_catch_array[i].finally_end)
|
2015-01-03 17:22:58 +08:00
|
|
|
&& (dst_num > op_array->try_catch_array[i].finally_end
|
2012-08-18 11:44:09 +08:00
|
|
|
|| dst_num < op_array->try_catch_array[i].finally_op)) {
|
|
|
|
CG(in_compilation) = 1;
|
|
|
|
CG(active_op_array) = op_array;
|
2012-11-22 19:17:05 +08:00
|
|
|
CG(zend_lineno) = op_array->opcodes[op_num].lineno;
|
2013-10-20 05:22:20 +08:00
|
|
|
zend_error_noreturn(E_COMPILE_ERROR, "jump out of a finally block is disallowed");
|
2012-08-18 11:44:09 +08:00
|
|
|
}
|
2015-01-03 17:22:58 +08:00
|
|
|
}
|
2012-08-18 11:44:09 +08:00
|
|
|
}
|
|
|
|
|
2015-05-23 04:17:40 +08:00
|
|
|
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 {
|
2015-11-11 02:48:03 +08:00
|
|
|
jmp_to = &CG(context).brk_cont_array[array_offset];
|
2015-05-23 04:17:40 +08:00
|
|
|
if (nest_levels > 1) {
|
|
|
|
array_offset = jmp_to->parent;
|
|
|
|
}
|
|
|
|
} while (--nest_levels > 0);
|
|
|
|
|
|
|
|
return opline->opcode == ZEND_BRK ? jmp_to->brk : jmp_to->cont;
|
|
|
|
}
|
|
|
|
|
2019-01-16 00:04:24 +08:00
|
|
|
static void emit_live_range_raw(
|
|
|
|
zend_op_array *op_array, uint32_t var_num, uint32_t kind, uint32_t start, uint32_t end) {
|
|
|
|
zend_live_range *range;
|
|
|
|
|
|
|
|
op_array->last_live_range++;
|
|
|
|
op_array->live_range = erealloc(op_array->live_range,
|
|
|
|
sizeof(zend_live_range) * op_array->last_live_range);
|
|
|
|
|
|
|
|
ZEND_ASSERT(start < end);
|
|
|
|
range = &op_array->live_range[op_array->last_live_range - 1];
|
|
|
|
range->var = (uint32_t) (intptr_t) ZEND_CALL_VAR_NUM(NULL, op_array->last_var + var_num);
|
|
|
|
range->var |= kind;
|
|
|
|
range->start = start;
|
|
|
|
range->end = end;
|
|
|
|
}
|
|
|
|
|
2019-01-17 23:07:17 +08:00
|
|
|
static void emit_live_range(
|
|
|
|
zend_op_array *op_array, uint32_t var_num, uint32_t start, uint32_t end,
|
|
|
|
zend_needs_live_range_cb needs_live_range) {
|
|
|
|
zend_op *def_opline = &op_array->opcodes[start], *orig_def_opline = def_opline;
|
|
|
|
zend_op *use_opline = &op_array->opcodes[end];
|
2019-01-21 22:25:24 +08:00
|
|
|
uint32_t kind;
|
2019-01-17 23:07:17 +08:00
|
|
|
|
|
|
|
switch (def_opline->opcode) {
|
|
|
|
/* These should never be the first def. */
|
|
|
|
case ZEND_ADD_ARRAY_ELEMENT:
|
|
|
|
case ZEND_ROPE_ADD:
|
|
|
|
ZEND_ASSERT(0);
|
|
|
|
return;
|
|
|
|
/* Result is boolean, it doesn't have to be destroyed. */
|
|
|
|
case ZEND_JMPZ_EX:
|
|
|
|
case ZEND_JMPNZ_EX:
|
|
|
|
case ZEND_BOOL:
|
|
|
|
case ZEND_BOOL_NOT:
|
|
|
|
/* Classes don't have to be destroyed. */
|
|
|
|
case ZEND_FETCH_CLASS:
|
|
|
|
case ZEND_DECLARE_ANON_CLASS:
|
|
|
|
case ZEND_DECLARE_ANON_INHERITED_CLASS:
|
|
|
|
/* FAST_CALLs don't have to be destroyed. */
|
|
|
|
case ZEND_FAST_CALL:
|
|
|
|
return;
|
|
|
|
case ZEND_BEGIN_SILENCE:
|
|
|
|
kind = ZEND_LIVE_SILENCE;
|
2019-01-21 22:25:24 +08:00
|
|
|
start++;
|
2019-01-17 23:07:17 +08:00
|
|
|
break;
|
|
|
|
case ZEND_ROPE_INIT:
|
|
|
|
kind = ZEND_LIVE_ROPE;
|
|
|
|
/* ROPE live ranges include the generating opcode. */
|
|
|
|
def_opline--;
|
|
|
|
break;
|
|
|
|
case ZEND_FE_RESET_R:
|
|
|
|
case ZEND_FE_RESET_RW:
|
|
|
|
kind = ZEND_LIVE_LOOP;
|
2019-01-21 22:25:24 +08:00
|
|
|
start++;
|
2019-01-17 23:07:17 +08:00
|
|
|
break;
|
|
|
|
/* Objects created via ZEND_NEW are only fully initialized
|
|
|
|
* after the DO_FCALL (constructor call). */
|
2019-01-16 00:04:24 +08:00
|
|
|
case ZEND_NEW:
|
|
|
|
{
|
2019-01-17 23:07:17 +08:00
|
|
|
int level = 0;
|
|
|
|
while (def_opline + 1 < use_opline) {
|
|
|
|
def_opline++;
|
2019-01-21 22:25:24 +08:00
|
|
|
start++;
|
2019-01-17 23:07:17 +08:00
|
|
|
if (def_opline->opcode == ZEND_DO_FCALL) {
|
|
|
|
if (level == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
level--;
|
|
|
|
} else {
|
|
|
|
switch (def_opline->opcode) {
|
|
|
|
case ZEND_INIT_FCALL:
|
|
|
|
case ZEND_INIT_FCALL_BY_NAME:
|
|
|
|
case ZEND_INIT_NS_FCALL_BY_NAME:
|
|
|
|
case ZEND_INIT_DYNAMIC_CALL:
|
|
|
|
case ZEND_INIT_USER_CALL:
|
|
|
|
case ZEND_INIT_METHOD_CALL:
|
|
|
|
case ZEND_INIT_STATIC_METHOD_CALL:
|
|
|
|
case ZEND_NEW:
|
|
|
|
level++;
|
|
|
|
break;
|
|
|
|
case ZEND_DO_ICALL:
|
|
|
|
case ZEND_DO_UCALL:
|
|
|
|
case ZEND_DO_FCALL_BY_NAME:
|
|
|
|
level--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-21 22:25:24 +08:00
|
|
|
if (start + 1 == end) {
|
|
|
|
/* Trivial live-range, no need to store it. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* break missing intentionally */
|
|
|
|
default:
|
|
|
|
start++;
|
|
|
|
kind = ZEND_LIVE_TMPVAR;
|
2019-01-17 23:07:17 +08:00
|
|
|
break;
|
|
|
|
}
|
2019-01-16 00:04:24 +08:00
|
|
|
case ZEND_COPY_TMP:
|
|
|
|
{
|
|
|
|
/* COPY_TMP has a split live-range: One from the definition until the use in
|
|
|
|
* "null" branch, and another from the start of the "non-null" branch to the
|
|
|
|
* FREE opcode. */
|
|
|
|
uint32_t rt_var_num =
|
|
|
|
(uint32_t) (intptr_t) ZEND_CALL_VAR_NUM(NULL, op_array->last_var + var_num);
|
|
|
|
zend_op *block_start_op = use_opline;
|
|
|
|
|
|
|
|
if (needs_live_range && !needs_live_range(op_array, orig_def_opline)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((block_start_op-1)->opcode == ZEND_FREE) {
|
|
|
|
block_start_op--;
|
|
|
|
}
|
|
|
|
|
|
|
|
kind = ZEND_LIVE_TMPVAR;
|
|
|
|
start = block_start_op - op_array->opcodes;
|
|
|
|
if (start != end) {
|
|
|
|
emit_live_range_raw(op_array, var_num, kind, start, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
use_opline--;
|
|
|
|
} while (!(
|
|
|
|
((use_opline->op1_type & (IS_TMP_VAR|IS_VAR)) && use_opline->op1.var == rt_var_num) ||
|
|
|
|
((use_opline->op2_type & (IS_TMP_VAR|IS_VAR)) && use_opline->op2.var == rt_var_num)
|
|
|
|
));
|
|
|
|
|
|
|
|
start = def_opline + 1 - op_array->opcodes;
|
|
|
|
end = use_opline - op_array->opcodes;
|
|
|
|
emit_live_range_raw(op_array, var_num, kind, start, end);
|
|
|
|
return;
|
|
|
|
}
|
2019-01-17 23:07:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check hook to determine whether a live range is necessary, e.g. based on type info. */
|
|
|
|
if (needs_live_range && !needs_live_range(op_array, orig_def_opline)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-16 00:04:24 +08:00
|
|
|
emit_live_range_raw(op_array, var_num, kind, start, end);
|
2019-01-17 23:07:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static zend_bool is_fake_def(zend_op *opline) {
|
|
|
|
/* These opcodes only modify the result, not create it. */
|
|
|
|
return opline->opcode == ZEND_ROPE_ADD
|
|
|
|
|| opline->opcode == ZEND_ADD_ARRAY_ELEMENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static zend_bool keeps_op1_alive(zend_op *opline) {
|
|
|
|
/* These opcodes don't consume their OP1 operand,
|
|
|
|
* it is later freed by something else. */
|
2019-01-22 07:11:50 +08:00
|
|
|
if (opline->opcode == ZEND_CASE
|
|
|
|
|| opline->opcode == ZEND_SWITCH_LONG
|
2019-01-16 00:04:24 +08:00
|
|
|
|| opline->opcode == ZEND_FETCH_LIST_R
|
|
|
|
|| opline->opcode == ZEND_COPY_TMP) {
|
2019-01-22 07:11:50 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
ZEND_ASSERT(opline->opcode != ZEND_SWITCH_STRING
|
|
|
|
&& opline->opcode != ZEND_FE_FETCH_R
|
|
|
|
&& opline->opcode != ZEND_FE_FETCH_RW
|
|
|
|
&& opline->opcode != ZEND_FETCH_LIST_W
|
|
|
|
&& opline->opcode != ZEND_VERIFY_RETURN_TYPE
|
|
|
|
&& opline->opcode != ZEND_BIND_LEXICAL
|
|
|
|
&& opline->opcode != ZEND_ROPE_ADD);
|
|
|
|
return 0;
|
2019-01-17 23:07:17 +08:00
|
|
|
}
|
|
|
|
|
2018-02-17 04:47:00 +08:00
|
|
|
/* 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) {
|
2019-01-21 22:25:24 +08:00
|
|
|
uint32_t tmp;
|
|
|
|
tmp = a->var;
|
|
|
|
a->var = b->var;
|
|
|
|
b->var = tmp;
|
|
|
|
tmp = a->start;
|
|
|
|
a->start = b->start;
|
|
|
|
b->start = tmp;
|
|
|
|
tmp = a->end;
|
|
|
|
a->end = b->end;
|
|
|
|
b->end = tmp;
|
2018-02-17 04:47:00 +08:00
|
|
|
}
|
2019-01-17 23:07:17 +08:00
|
|
|
|
|
|
|
static void zend_calc_live_ranges(
|
|
|
|
zend_op_array *op_array, zend_needs_live_range_cb needs_live_range) {
|
2019-01-21 22:25:24 +08:00
|
|
|
uint32_t opnum = op_array->last;
|
|
|
|
zend_op *opline = &op_array->opcodes[opnum];
|
2019-01-17 23:07:17 +08:00
|
|
|
ALLOCA_FLAG(use_heap)
|
|
|
|
uint32_t var_offset = op_array->last_var;
|
|
|
|
uint32_t *last_use = do_alloca(sizeof(uint32_t) * op_array->T, use_heap);
|
|
|
|
memset(last_use, -1, sizeof(uint32_t) * op_array->T);
|
|
|
|
|
|
|
|
ZEND_ASSERT(!op_array->live_range);
|
2019-01-21 22:25:24 +08:00
|
|
|
while (opnum > 0) {
|
|
|
|
opnum--;
|
|
|
|
opline--;
|
2019-01-17 23:07:17 +08:00
|
|
|
|
|
|
|
if ((opline->result_type & (IS_TMP_VAR|IS_VAR)) && !is_fake_def(opline)) {
|
|
|
|
uint32_t var_num = EX_VAR_TO_NUM(opline->result.var) - var_offset;
|
|
|
|
/* Defs without uses can occur for two reasons: Either because the result is
|
|
|
|
* genuinely unused (e.g. omitted FREE opcode for an unused boolean result), or
|
|
|
|
* because there are multiple defining opcodes (e.g. JMPZ_EX and QM_ASSIGN), in
|
|
|
|
* which case the last one starts the live range. As such, we can simply ignore
|
|
|
|
* missing uses here. */
|
2019-01-22 07:11:50 +08:00
|
|
|
if (EXPECTED(last_use[var_num] != (uint32_t) -1)) {
|
2019-01-21 22:25:24 +08:00
|
|
|
/* Skip trivial live-range */
|
|
|
|
if (opnum + 1 != last_use[var_num]) {
|
|
|
|
uint32_t num;
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
/* OP_DATA uses only op1 operand */
|
|
|
|
ZEND_ASSERT(opline->opcode != ZEND_OP_DATA);
|
|
|
|
num = opnum;
|
|
|
|
#else
|
|
|
|
/* OP_DATA is really part of the previous opcode. */
|
|
|
|
num = opnum - (opline->opcode == ZEND_OP_DATA);
|
|
|
|
#endif
|
|
|
|
emit_live_range(op_array, var_num, num, last_use[var_num], needs_live_range);
|
|
|
|
}
|
2019-01-17 23:07:17 +08:00
|
|
|
last_use[var_num] = (uint32_t) -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-22 07:11:50 +08:00
|
|
|
if ((opline->op1_type & (IS_TMP_VAR|IS_VAR))) {
|
2019-01-17 23:07:17 +08:00
|
|
|
uint32_t var_num = EX_VAR_TO_NUM(opline->op1.var) - var_offset;
|
2019-01-22 07:11:50 +08:00
|
|
|
if (EXPECTED(last_use[var_num] == (uint32_t) -1)) {
|
|
|
|
if (EXPECTED(!keeps_op1_alive(opline))) {
|
|
|
|
/* OP_DATA is really part of the previous opcode. */
|
|
|
|
last_use[var_num] = opnum - (opline->opcode == ZEND_OP_DATA);
|
|
|
|
}
|
2019-01-17 23:07:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (opline->op2_type & (IS_TMP_VAR|IS_VAR)) {
|
|
|
|
uint32_t var_num = EX_VAR_TO_NUM(opline->op2.var) - var_offset;
|
2019-01-22 07:11:50 +08:00
|
|
|
if (EXPECTED(last_use[var_num] == (uint32_t) -1)) {
|
2019-01-21 22:25:24 +08:00
|
|
|
#if 1
|
|
|
|
/* OP_DATA uses only op1 operand */
|
|
|
|
ZEND_ASSERT(opline->opcode != ZEND_OP_DATA);
|
2019-01-17 23:07:17 +08:00
|
|
|
last_use[var_num] = opnum;
|
2019-01-21 22:25:24 +08:00
|
|
|
#else
|
|
|
|
/* OP_DATA is really part of the previous opcode. */
|
|
|
|
last_use[var_num] = opnum - (opline->opcode == ZEND_OP_DATA);
|
|
|
|
#endif
|
2019-01-17 23:07:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 22:25:24 +08:00
|
|
|
if (op_array->last_live_range > 1) {
|
|
|
|
zend_live_range *r1 = op_array->live_range;
|
|
|
|
zend_live_range *r2 = r1 + op_array->last_live_range - 1;
|
|
|
|
|
|
|
|
/* In most cases we need just revert the array */
|
|
|
|
while (r1 < r2) {
|
|
|
|
swap_live_range(r1, r2);
|
|
|
|
r1++;
|
|
|
|
r2--;
|
|
|
|
}
|
|
|
|
|
|
|
|
r1 = op_array->live_range;
|
|
|
|
r2 = r1 + op_array->last_live_range - 1;
|
|
|
|
while (r1 < r2) {
|
|
|
|
if (r1->start > (r1+1)->start) {
|
|
|
|
zend_sort(r1, r2 - r1 + 1, sizeof(zend_live_range),
|
|
|
|
(compare_func_t) cmp_live_range, (swap_func_t) swap_live_range);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
r1++;
|
|
|
|
}
|
2019-01-17 23:07:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
free_alloca(last_use, use_heap);
|
|
|
|
}
|
|
|
|
|
|
|
|
ZEND_API void zend_recalc_live_ranges(
|
|
|
|
zend_op_array *op_array, zend_needs_live_range_cb needs_live_range) {
|
|
|
|
/* We assume that we never create live-ranges where there were none before. */
|
2019-01-21 22:25:24 +08:00
|
|
|
ZEND_ASSERT(op_array->live_range);
|
2019-01-17 23:07:17 +08:00
|
|
|
efree(op_array->live_range);
|
|
|
|
op_array->live_range = NULL;
|
|
|
|
op_array->last_live_range = 0;
|
|
|
|
zend_calc_live_ranges(op_array, needs_live_range);
|
2018-02-17 04:47:00 +08:00
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API int pass_two(zend_op_array *op_array)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
2001-05-11 22:29:06 +08:00
|
|
|
zend_op *opline, *end;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2014-06-30 19:43:45 +08:00
|
|
|
if (!ZEND_USER_CODE(op_array->type)) {
|
1999-04-08 02:10:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2008-03-18 16:36:30 +08:00
|
|
|
if (CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO) {
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_update_extended_info(op_array);
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
2008-03-18 16:36:30 +08:00
|
|
|
if (CG(compiler_options) & ZEND_COMPILE_HANDLE_OP_ARRAY) {
|
2016-01-12 22:19:14 +08:00
|
|
|
if (zend_extension_flags & ZEND_EXTENSIONS_HAVE_OP_ARRAY_HANDLER) {
|
2015-09-25 16:50:38 +08:00
|
|
|
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_handler, op_array);
|
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
2001-05-11 22:29:06 +08:00
|
|
|
|
2014-08-26 05:45:02 +08:00
|
|
|
if (CG(context).vars_size != op_array->last_var) {
|
2014-02-10 14:04:30 +08:00
|
|
|
op_array->vars = (zend_string**) erealloc(op_array->vars, sizeof(zend_string*)*op_array->last_var);
|
2010-09-15 15:38:52 +08:00
|
|
|
CG(context).vars_size = op_array->last_var;
|
|
|
|
}
|
2017-10-04 21:53:01 +08:00
|
|
|
|
|
|
|
#if ZEND_USE_ABS_CONST_ADDR
|
2014-08-26 05:45:02 +08:00
|
|
|
if (CG(context).opcodes_size != op_array->last) {
|
2006-04-10 20:26:53 +08:00
|
|
|
op_array->opcodes = (zend_op *) erealloc(op_array->opcodes, sizeof(zend_op)*op_array->last);
|
2010-09-15 15:38:52 +08:00
|
|
|
CG(context).opcodes_size = op_array->last;
|
2006-04-10 20:26:53 +08:00
|
|
|
}
|
2014-08-26 05:45:02 +08:00
|
|
|
if (CG(context).literals_size != op_array->last_literal) {
|
2014-04-17 19:40:45 +08:00
|
|
|
op_array->literals = (zval*)erealloc(op_array->literals, sizeof(zval) * op_array->last_literal);
|
2010-09-15 15:38:52 +08:00
|
|
|
CG(context).literals_size = op_array->last_literal;
|
2010-04-20 18:57:45 +08:00
|
|
|
}
|
2017-10-04 21:53:01 +08:00
|
|
|
#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
|
|
|
|
|
2018-09-04 14:08:39 +08:00
|
|
|
/* 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;
|
|
|
|
|
2001-05-11 22:29:06 +08:00
|
|
|
opline = op_array->opcodes;
|
|
|
|
end = opline + op_array->last;
|
|
|
|
while (opline < end) {
|
2002-10-25 02:24:55 +08:00
|
|
|
switch (opline->opcode) {
|
2018-05-03 19:40:18 +08:00
|
|
|
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;
|
2015-08-04 12:37:06 +08:00
|
|
|
case ZEND_FAST_CALL:
|
2015-08-04 13:35:40 +08:00
|
|
|
opline->op1.opline_num = op_array->try_catch_array[opline->op1.num].finally_op;
|
2015-08-04 12:37:06 +08:00
|
|
|
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1);
|
|
|
|
break;
|
2015-05-23 04:17:40 +08:00
|
|
|
case ZEND_BRK:
|
|
|
|
case ZEND_CONT:
|
|
|
|
{
|
|
|
|
uint32_t jmp_target = zend_get_brk_cont_target(op_array, opline);
|
2015-08-04 12:37:06 +08:00
|
|
|
|
|
|
|
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
|
|
|
|
zend_check_finally_breakout(op_array, opline - op_array->opcodes, jmp_target);
|
|
|
|
}
|
2015-05-23 04:17:40 +08:00
|
|
|
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;
|
2008-03-28 22:35:01 +08:00
|
|
|
case ZEND_GOTO:
|
2015-08-04 12:37:06 +08:00
|
|
|
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);
|
|
|
|
}
|
2008-03-28 22:35:01 +08:00
|
|
|
/* break omitted intentionally */
|
2002-10-25 02:24:55 +08:00
|
|
|
case ZEND_JMP:
|
2014-12-12 15:19:41 +08:00
|
|
|
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1);
|
2002-10-25 02:24:55 +08:00
|
|
|
break;
|
2014-04-30 15:23:19 +08:00
|
|
|
case ZEND_JMPZNZ:
|
|
|
|
/* absolute index to relative offset */
|
2014-12-12 15:19:41 +08:00
|
|
|
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
|
2014-04-30 15:23:19 +08:00
|
|
|
/* break omitted intentionally */
|
2002-10-25 02:24:55 +08:00
|
|
|
case ZEND_JMPZ:
|
|
|
|
case ZEND_JMPNZ:
|
|
|
|
case ZEND_JMPZ_EX:
|
|
|
|
case ZEND_JMPNZ_EX:
|
2007-11-21 17:41:35 +08:00
|
|
|
case ZEND_JMP_SET:
|
2014-09-17 02:14:46 +08:00
|
|
|
case ZEND_COALESCE:
|
2015-02-12 18:57:12 +08:00
|
|
|
case ZEND_FE_RESET_R:
|
|
|
|
case ZEND_FE_RESET_RW:
|
2015-12-14 19:31:00 +08:00
|
|
|
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2);
|
|
|
|
break;
|
2015-03-02 17:25:40 +08:00
|
|
|
case ZEND_ASSERT_CHECK:
|
2016-03-26 02:27:20 +08:00
|
|
|
{
|
2015-12-14 19:31:00 +08:00
|
|
|
/* If result of assert is unused, result of check is unused as well */
|
2016-03-26 02:27:20 +08:00
|
|
|
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) {
|
2016-02-05 22:23:23 +08:00
|
|
|
opline->result_type = IS_UNUSED;
|
2015-12-14 19:31:00 +08:00
|
|
|
}
|
2014-12-12 15:19:41 +08:00
|
|
|
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2);
|
2002-10-25 02:24:55 +08:00
|
|
|
break;
|
2016-03-26 02:27:20 +08:00
|
|
|
}
|
2015-12-20 20:42:26 +08:00
|
|
|
case ZEND_DECLARE_ANON_CLASS:
|
|
|
|
case ZEND_DECLARE_ANON_INHERITED_CLASS:
|
2015-05-13 17:55:42 +08:00
|
|
|
case ZEND_FE_FETCH_R:
|
|
|
|
case ZEND_FE_FETCH_RW:
|
2015-12-20 20:42:26 +08:00
|
|
|
/* absolute index to relative offset */
|
2015-05-13 17:55:42 +08:00
|
|
|
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
|
|
|
|
break;
|
2018-02-01 03:39:30 +08:00
|
|
|
case ZEND_CATCH:
|
2018-02-06 00:41:47 +08:00
|
|
|
if (!(opline->extended_value & ZEND_LAST_CATCH)) {
|
2018-02-01 03:39:30 +08:00
|
|
|
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2);
|
|
|
|
}
|
|
|
|
break;
|
2012-07-23 02:11:09 +08:00
|
|
|
case ZEND_RETURN:
|
|
|
|
case ZEND_RETURN_BY_REF:
|
|
|
|
if (op_array->fn_flags & ZEND_ACC_GENERATOR) {
|
2012-08-24 19:51:39 +08:00
|
|
|
opline->opcode = ZEND_GENERATOR_RETURN;
|
2012-07-23 02:11:09 +08:00
|
|
|
}
|
|
|
|
break;
|
2017-03-18 06:45:05 +08:00
|
|
|
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;
|
|
|
|
}
|
2002-10-25 02:04:12 +08:00
|
|
|
}
|
2015-07-25 04:03:05 +08:00
|
|
|
if (opline->op1_type == IS_CONST) {
|
2017-10-04 21:53:01 +08:00
|
|
|
ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, opline->op1);
|
2015-07-25 04:03:05 +08:00
|
|
|
} 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) {
|
2017-10-04 21:53:01 +08:00
|
|
|
ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, opline->op2);
|
2015-07-25 04:03:05 +08:00
|
|
|
} 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);
|
|
|
|
}
|
2004-09-24 05:43:32 +08:00
|
|
|
ZEND_VM_SET_OPCODE_HANDLER(opline);
|
1999-04-08 02:10:10 +08:00
|
|
|
opline++;
|
|
|
|
}
|
2010-04-20 18:57:45 +08:00
|
|
|
|
2019-01-17 23:07:17 +08:00
|
|
|
zend_calc_live_ranges(op_array, NULL);
|
2015-11-13 20:35:07 +08:00
|
|
|
|
2000-08-10 03:22:35 +08:00
|
|
|
return 0;
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
|
1999-05-30 21:28:56 +08:00
|
|
|
ZEND_API unary_op_type get_unary_op(int opcode)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
2002-11-30 19:20:25 +08:00
|
|
|
switch (opcode) {
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_BW_NOT:
|
1999-06-04 19:44:02 +08:00
|
|
|
return (unary_op_type) bitwise_not_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_BOOL_NOT:
|
1999-06-04 19:44:02 +08:00
|
|
|
return (unary_op_type) boolean_not_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
default:
|
1999-05-30 21:28:56 +08:00
|
|
|
return (unary_op_type) NULL;
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-30 02:12:47 +08:00
|
|
|
ZEND_API binary_op_type get_binary_op(int opcode)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
|
|
|
switch (opcode) {
|
|
|
|
case ZEND_ADD:
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_ASSIGN_ADD:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) add_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_SUB:
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_ASSIGN_SUB:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) sub_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_MUL:
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_ASSIGN_MUL:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) mul_function;
|
2013-11-19 15:36:06 +08:00
|
|
|
case ZEND_POW:
|
2017-07-04 02:26:44 +08:00
|
|
|
case ZEND_ASSIGN_POW:
|
2013-11-19 15:36:06 +08:00
|
|
|
return (binary_op_type) pow_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_DIV:
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_ASSIGN_DIV:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) div_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_MOD:
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_ASSIGN_MOD:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) mod_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_SL:
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_ASSIGN_SL:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) shift_left_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_SR:
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_ASSIGN_SR:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) shift_right_function;
|
2015-03-25 03:47:21 +08:00
|
|
|
case ZEND_FAST_CONCAT:
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_CONCAT:
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_ASSIGN_CONCAT:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) concat_function;
|
1999-10-19 21:33:17 +08:00
|
|
|
case ZEND_IS_IDENTICAL:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) is_identical_function;
|
2000-03-30 06:05:19 +08:00
|
|
|
case ZEND_IS_NOT_IDENTICAL:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) is_not_identical_function;
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_IS_EQUAL:
|
2017-07-04 02:26:44 +08:00
|
|
|
case ZEND_CASE:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) is_equal_function;
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_IS_NOT_EQUAL:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) is_not_equal_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_IS_SMALLER:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) is_smaller_function;
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_IS_SMALLER_OR_EQUAL:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) is_smaller_or_equal_function;
|
2015-01-19 15:12:39 +08:00
|
|
|
case ZEND_SPACESHIP:
|
|
|
|
return (binary_op_type) compare_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_BW_OR:
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_ASSIGN_BW_OR:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) bitwise_or_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_BW_AND:
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_ASSIGN_BW_AND:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) bitwise_and_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
case ZEND_BW_XOR:
|
1999-04-24 08:12:55 +08:00
|
|
|
case ZEND_ASSIGN_BW_XOR:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) bitwise_xor_function;
|
|
|
|
case ZEND_BOOL_XOR:
|
|
|
|
return (binary_op_type) boolean_xor_function;
|
1999-04-08 02:10:10 +08:00
|
|
|
default:
|
2008-08-30 02:12:47 +08:00
|
|
|
return (binary_op_type) NULL;
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
}
|