php-src/Zend/zend_opcode.c

785 lines
23 KiB
C
Raw Normal View History

1999-04-08 02:10:10 +08:00
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
2018-01-02 12:57:58 +08:00
| Copyright (c) 1998-2018 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 |
| 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
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@zend.com> |
| Zeev Suraski <zeev@zend.com> |
| Dmitry Stogov <dmitry@zend.com> |
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"
#include "zend_sort.h"
1999-04-08 02:10:10 +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) {
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) {
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;
op_array->arg_flags[0] = 0;
op_array->arg_flags[1] = 0;
op_array->arg_flags[2] = 0;
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
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
op_array->arg_info = NULL;
op_array->num_args = 0;
op_array->required_num_args = 0;
1999-04-08 02:10:10 +08:00
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;
1999-04-08 02:10:10 +08:00
op_array->static_variables = NULL;
op_array->last_try_catch = 0;
1999-04-08 02:10:10 +08:00
op_array->fn_flags = 0;
op_array->last_literal = 0;
op_array->literals = NULL;
op_array->run_time_cache = NULL;
op_array->cache_size = 0;
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);
}
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
{
zval tmp;
ZVAL_PTR(&tmp, function);
zend_function_dtor(&tmp);
1999-04-08 02:10:10 +08:00
}
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);
2014-12-14 06:06:14 +08:00
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);
}
}
}
2014-12-14 06:06:14 +08:00
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce)
{
if (CE_STATIC_MEMBERS(ce)) {
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
#ifdef ZTS
CG(static_members_table)[ce->static_members_table_idx] = NULL;
#else
ce->static_members_table = NULL;
#endif
2015-04-29 00:11:45 +08:00
while (p != end) {
i_zval_ptr_dtor(p);
2015-04-29 00:11:45 +08:00
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);
2015-01-03 17:22:58 +08:00
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);
}
2015-01-03 17:22:58 +08:00
if (ce->trait_aliases[i]->alias) {
zend_string_release_ex(ce->trait_aliases[i]->alias, 0);
}
2015-01-03 17:22:58 +08:00
efree(ce->trait_aliases[i]);
i++;
}
2015-01-03 17:22:58 +08:00
efree(ce->trait_aliases);
}
if (ce->trait_precedences) {
int j;
2015-01-03 17:22:58 +08:00
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)
1999-04-08 02:10:10 +08:00
{
zend_property_info *prop_info;
zend_class_entry *ce = Z_PTR_P(zv);
zend_function *fn;
2015-01-03 17:22:58 +08:00
if (--ce->refcount > 0) {
return;
}
1999-04-08 02:10:10 +08:00
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) {
2015-04-29 00:11:45 +08:00
zval *p = ce->default_properties_table;
zval *end = p + ce->default_properties_count;
2015-04-29 00:11:45 +08:00
while (p != end) {
i_zval_ptr_dtor(p);
2015-04-29 00:11:45 +08:00
p++;
}
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;
2015-04-29 00:11:45 +08:00
while (p != end) {
i_zval_ptr_dtor(p);
2015-04-29 00:11:45 +08:00
p++;
}
efree(ce->default_static_members_table);
}
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) {
Squashed commit of the following: commit 2d3cac9e005d6bef9aa73ab57cc674aa53125954 Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Sep 11 11:54:47 2018 +0300 Fixed static property access commit 31786ee27282f319f3ef2a07635b1f325cbd67c6 Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Sep 11 11:05:29 2018 +0300 Avoid duplicate checks commit 5ae502b979ea33d058d01a9421eec5afd0084e8d Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Sep 11 10:39:17 2018 +0300 Optimization commit 82c17f0e8af02c9cf7d1bbdae4e3158330148203 Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Sep 11 09:26:50 2018 +0300 Removed unused zend_duplicate_property_info() commit ba53d1d0dd91d5530328a11cac93ff9e75c462b5 Merge: eacc11b8fd c4b14370cf Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Sep 11 09:24:13 2018 +0300 Merge branch 'master' into shadow * master: 7.0.33 next Sync NEWS [ci skip] add NEWS for 76582 Enforce ordering of property compare in object comparisons Fixed wrong assertion Skip test on unsuitable env commit eacc11b8fdeb002ee6a149defd8b5a8c3412896a Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Sep 10 13:12:39 2018 +0300 Fixed failure of ext/spl/tests/array_017.phpt commit 62d1871430a1b81c84b790460afff0682648689a Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Sep 10 11:55:07 2018 +0300 Fixed issues commit 1d37e3a40e4d07c4b933ed6f9d2e649dd01180f0 Merge: d6c3f098b6 1e550e6f7e Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Sep 10 10:21:20 2018 +0300 Merge branch 'master' into shadow * master: Update NEWS Fix for bug #76582 Fix ssl stream reneg limit test to print only after first renegotiation Make a copy unconditionally Fix memory leak in pcre cache Remove not needed checking for <errno.h> Remove HAVE_ASSERT_H Add test for bug #76850 Fixed bug #76850 Exit code mangled by set locale/preg_match Remove empty PHP tags from test Fix #75273: php_zlib_inflate_filter() may not update bytes_consumed Fix PCRE2 exclusion and remove dead libs in Makefile.gcov Report mem leaks to stderr if no Win debugger is present Use combined assignment contanation operator Fixed bug #76796 Support fixed address mmap without replacement commit d6c3f098b6015e76d042691de0af2e1426c66829 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Sep 7 13:56:30 2018 +0300 Get rid of ZEND_ACC_SHADOW
2018-09-11 16:56:45 +08:00
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);
1999-04-08 02:10:10 +08:00
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);
}
}
2003-03-05 19:14:44 +08:00
efree(ce->interfaces);
}
if (ce->info.user.doc_comment) {
zend_string_release_ex(ce->info.user.doc_comment, 0);
}
2015-01-03 17:22:58 +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:
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;
2015-04-29 00:11:45 +08:00
while (p != end) {
zval_internal_ptr_dtor(p);
p++;
}
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;
2015-04-29 00:11:45 +08:00
while (p != end) {
zval_internal_ptr_dtor(p);
p++;
}
free(ce->default_static_members_table);
}
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();
1999-04-08 02:10:10 +08:00
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);
1999-04-08 02:10:10 +08:00
break;
}
}
1999-04-08 02:10:10 +08:00
void zend_class_add_ref(zval *zv)
{
zend_class_entry *ce = Z_PTR_P(zv);
ce->refcount++;
}
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
if (op_array->static_variables &&
!(GC_FLAGS(op_array->static_variables) & IS_ARRAY_IMMUTABLE)) {
if (GC_DELREF(op_array->static_variables) == 0) {
zend_array_destroy(op_array->static_variables);
}
}
if (op_array->run_time_cache
&& (op_array->fn_flags & ZEND_ACC_HEAP_RT_CACHE)) {
efree(op_array->run_time_cache);
op_array->run_time_cache = NULL;
}
if (!op_array->refcount || --(*op_array->refcount) > 0) {
return;
1999-04-08 02:10:10 +08:00
}
efree_size(op_array->refcount, sizeof(*(op_array->refcount)));
1999-04-08 02:10:10 +08:00
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++;
1999-04-08 02:10:10 +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) {
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) {
zend_string_release_ex(op_array->doc_comment, 0);
2004-02-20 14:59:37 +08:00
}
if (op_array->live_range) {
efree(op_array->live_range);
Squashed commit of the following: commit 03cf871f1576f08b2348c141b209894a7bf17a86 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jul 10 02:45:31 2015 +0300 Revert "Fixed bug #62210 (Exceptions can leak temporary variables. As a part of the fix serious refactoring was done. op_array->brk_cont_array was removed, and replaced with more general and speed efficient op_array->T_liveliness. ZEND_GOTO opcode is always replaced by ZEND_JMP at compile time). (Bob, Dmitry, Laruence)" This reverts commit 5ee841325901a4b040cfea56292a24702fe224d9. commit 285a68227ce3d380e821a24fa389aa5239bd3fe1 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jul 10 02:45:26 2015 +0300 Revert "Tuned off dubugging of live ranges" This reverts commit 404dc93d35f7061fc4b1b41ad6cb0721b9b52bcc. commit 93d9d11157301ee2ec99afb6f5744b126d17f637 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jul 10 02:45:17 2015 +0300 Revert "Remove loop_var_stack" This reverts commit b3a4c05071c3786e27e1326fa1b4d5acad62fccd. commit ede68ebbc284aec79e3f719f2c8dbf9da6907752 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jul 10 02:45:12 2015 +0300 Revert "ZEND_SEPARATE reuses temporaries" This reverts commit 1852f538b9f8d5e7d67fe5a4f6080396d8b10034. commit 96d8995dc1f517fb01b481736273767509f76c47 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jul 10 02:45:10 2015 +0300 Revert "Add assertion in liveliness computation" This reverts commit ed14019e8c0c852480eebc6fc552d8c3d939dce1. commit 0649d7bfef152e6cc8e67b922534e9946c634d9c Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jul 10 02:45:07 2015 +0300 Revert "Fixed invalid live-range detection" This reverts commit 54f367ee2a2e4cb7c952b17915c226fdc56038ab. commit dfe8f3851f6b04595eb089323e3492115a59363e Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jul 10 02:45:04 2015 +0300 Revert "Add test guaranteeing that loop vars are only freed after potential return type exceptions" This reverts commit f5db5a558d550bf441373febebbb02f3884209d1. commit 52a94aad6f48a199358cc07f7e4f56bb73050504 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jul 10 02:45:01 2015 +0300 Revert "Fixed exception habdling on "return" statement." This reverts commit 17c5315bdf8f8087979aeb55f6d3a512ba197cf5. commit 6e90ad7331901711e89c2ceb2bcab5023e5cee60 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jul 10 02:44:58 2015 +0300 Revert "Fix too early terminated temporary range with break/cont/goto" This reverts commit cc876c04b420589cb1f62b650d0c0e24975dd4af. commit 7b766e44b1970e4031f75109c302c07ead2c05cb Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jul 10 02:44:55 2015 +0300 Revert "Fixed exception catching on break/continue" This reverts commit 8c3f701eebfa92d761bb368cfa8c2d1ccf821b9d.
2015-07-10 08:31:52 +08:00
}
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) {
2016-01-03 14:06:52 +08:00
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);
2003-08-04 06:28:14 +08:00
}
}
efree(arg_info);
}
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;
}
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++) {
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
|| 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;
zend_error_noreturn(E_COMPILE_ERROR, "jump out of a finally block is disallowed");
}
2015-01-03 17:22:58 +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 {
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);
}
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
{
zend_op *opline, *end;
1999-04-08 02:10:10 +08:00
if (!ZEND_USER_CODE(op_array->type)) {
1999-04-08 02:10:10 +08:00
return 0;
}
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
}
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);
}
1999-04-08 02:10:10 +08:00
}
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) {
2002-10-25 02:24:55 +08:00
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:
2015-08-04 13:35:40 +08:00
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 */
2002-10-25 02:24:55 +08:00
case ZEND_JMP:
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1);
2002-10-25 02:24:55 +08:00
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 */
2002-10-25 02:24:55 +08:00
case ZEND_JMPZ:
case ZEND_JMPNZ:
case ZEND_JMPZ_EX:
case ZEND_JMPNZ_EX:
case ZEND_JMP_SET:
case ZEND_COALESCE:
Fix "forech" statemt behaviour according to https://wiki.php.net/rfc/php7_foreach Squashed commit of the following: commit 1e41295097576dbce6c197ddb7507c07ccae3cbe Author: Dmitry Stogov <dmitry@zend.com> Date: Sat Jan 31 07:28:58 2015 +0300 Generalize HashTableIterator API to allows its usage without involvement of HashTable.nInternalPonter commit 5406f21b11e563069d64045e599693b51c444b63 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jan 30 18:08:43 2015 +0300 Reduced alghorithms complexity commit b37f1d58d2a141b6e1d980a461ccb588d4317d2e Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jan 30 18:08:30 2015 +0300 Fixed test name commit fb2d079645829b12ed4e55a461034df6400bc430 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jan 30 18:08:05 2015 +0300 API cleanup commit 08302c0d6d1cab279b9f2129df03a057baddf2ff Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jan 30 14:20:46 2015 +0300 Make array_splice() to preserve foreach hash position commit cc4b7be41e2e2b9b0d7a3c8e98466b8886692e6e Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jan 30 12:24:31 2015 +0300 Make internal function, operation on array passed by reference, to preserve foreach hash position commit 5aa9712b0a30303aadfe3bdd8ae1f072ca3e6ba1 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jan 30 09:49:35 2015 +0300 Implement consistent behavior for foreach by value over plain object commit 4c5b385ff53ae9f0b52572e98c4db801f56603b0 Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Jan 30 07:56:37 2015 +0300 More careful iterators update. commit 721fc9e80d2ee8f2cd79c8c3cdceffae2c72de92 Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Jan 29 21:43:28 2015 +0300 Added new test commit 15a23b1218b3e38630d677751a975907daa2cd54 Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Jan 29 21:05:02 2015 +0300 Reimplement iteration magic with HashTableIterators (see https://wiki.php.net/rfc/php7_foreach#implementation_details) commit 10a3260b1f16b6075fd8140f673dfef4d5efea91 Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Jan 29 21:04:44 2015 +0300 New test commit eef80c583762d1e98d177cdbb27e3a8a6b0c4539 Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Jan 28 16:52:21 2015 +0300 Fixed foreach by reference iteration over constant array commit 61e739187391661e2d541947bec25d7dcc4479f3 Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Jan 28 14:59:54 2015 +0300 Fixed temporary variable re-allocation pass commit 92e90c09f085c22707ff4a59201f016f56e0ef8b Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Jan 28 12:44:57 2015 +0300 Fixed operand destruction in case of exceptions in iterator commit dd2a36a2074bbb0cb31de00b66dcf2812d6d753f Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Jan 28 10:02:34 2015 +0300 Use GET_OP1_ZVAL_PTR_DEREF() (IS_TMP_VAR and IS_CONST can't be IS_REFERENCE) commit 4638f7b91407c48710007af82a68da0007c820f2 Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Jan 28 07:43:28 2015 +0300 Change "foreach" statement behavior (this is just a PoC yet) - "foreach by value" don't relay on internal array/object pointer and doesnt perform array duplication. It just locks it incrementing reference counter. If the original array is modified by some code, the copy on write is performed and "foreach" still work with the old copy. - it makes no difference if array given to "foreach by value" is reference itself - "foreach by reference" still use internal array/object pointer and should work similar to PHP-5. (This id not completely implemented)
2015-02-12 18:57:12 +08:00
case ZEND_FE_RESET_R:
case ZEND_FE_RESET_RW:
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2);
break;
Improved assert() according to expectations RFC. See https://wiki.php.net/rfc/expectations Squashed commit of the following: commit 3f3651a7870738e35ec541e53b53069152135b24 Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Mar 2 11:56:33 2015 +0300 opcode 137 is used for ZEND_OP_DATA and con't be reused for ZEND_ASSERT_CHECK commit ca8ecabf2a5f97f9116839c33396c9a7037e4368 Merge: 24328ac 9dac923 Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Mar 2 10:49:23 2015 +0300 Merge branch 'master' into assert * master: Update NEWS Fixed bug #69139 (Crash in gc_zval_possible_root on unserialize) windows only test Align entries format Align entries format for 5.6.7 Align entries format for 5.5.23 Bump header year Fixed bug #69144 (strtr not replacing with partly matching replace pairs) Fixed test? Revert mktime()/gmmktime()'s arginfo Update NEWS Fixed bug #69141 Missing arguments in reflection info for some builtin functions Add NEWS entry Remove useless date warning Fix ARG_INFO for levenshtein Fix ARG_INFO for levenshtein fix dir separator in tests Update NEWS Fixed bug #69085 (SoapClient's __call() type confusion through unserialize()). commit 24328ac03f79a0f3b19be7411bf9e173f392abda Merge: 021fd94 1cdee9a Author: Dmitry Stogov <dmitry@zend.com> Date: Fri Feb 27 15:57:13 2015 +0300 Merge branch 'master' into assert * master: Fixed C++ support Fixed bug #69115 crash in mail Reorder Update NEWs Fixed bug #69121 (Segfault in get_current_user when script owner is not in passwd with ZTS build) Update News Fixed bug #69125 (Array numeric string as key) fix bug#68942's patch Fixed ability to build unspecialized executor Fixed bug #69124 (method name could not be used when by ref) Fixed a bug that header value is not terminated by '\0' when accessed through getenv(). Fixed a bug that header value is not terminated by '\0' when accessed through getenv(). commit 021fd94ed1d692d212e6e30c6c1a9767c3f16f7f Merge: 49963eb ace1f82 Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Feb 26 11:26:03 2015 +0300 Merge branch 'master' into assert * master: (59 commits) Improved ASSIGN_DIM handler Don't inline slow path Revert a part committted by mistake Fixed compilation warnings Fixed a bug that header value is not terminated by '\0' when accessed through getenv(). better name Improve fix for #69038 Update NEWs Fixed bug #69108 ("Segmentation fault" when (de)serializing SplObjectStorage) Added specialized versions of DO_FCALL handler: DO_ICALL - for internal functions DO_UCALL - for user functions DO_FCALL_BY_NAME - plain, most probably user, funcstions (not methods) Use cache_slot offsets instead of indexes (simplify run-time instructions) Split INIT_FCALL_BY_NAME inti INIT_FCALL_BY_NAME(CONST+STRING) and INIT_DYNAMIC_CALL(CONST-STRING|TMPVAR|CV) Support list($a, $b) = $a Avoid unnecassary check Make zend_array_destroy() to free the corresponding zend_array Eliminate check on the fast path Make current() and key() receive argument by value. Use Firebird default home folder, replace Interbase with Firebird Updated NEWS updated NEWS ... Conflicts: Zend/zend_vm_execute.h Zend/zend_vm_opcodes.c Zend/zend_vm_opcodes.h commit 49963ebf9d2bcd6d2670203dd72884f6ba6c8a4b Merge: 07b1f92 6b77959 Author: Dmitry Stogov <dmitry@zend.com> Date: Thu Feb 19 11:13:08 2015 +0300 Merge branch 'master' into assert * master: Implemented AST pretty-printer update NEWS to match the actual stuff in 5.6.6 update NEWS to match the actual stuff in 5.5.22 update NEWS(add missing entry for the enchant fix, and reorder the entries a bit) fix typo in bug# update NEWS fix email format update NEWS update 5.6.6 release date in NEWS Fix bug #69033 (Request may get env. variables from previous requests if PHP works as FastCGI) BFN fix test fix test fix test Fixed bug #65593 (Segfault when calling ob_start from output buffering callback) Updated NEWS add CVE 5.4.39 next Fix associativity to match Perl Blast off to space. Conflicts: Zend/zend_ast.c commit 07b1f92ed662f6fa9309e679b83aff328362c98b Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Feb 18 23:06:32 2015 +0300 fixed pretty-printer (support for "elseif") commit 5a976c8d85078502b48379996ab066e57533a0c3 Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Feb 18 19:50:08 2015 +0300 Fixed vaeious ptetty-printer issues commit 69491e8e8e692030b0585aab485146906c0fedaf Merge: 8473157 3ddc246 Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Feb 18 10:18:32 2015 +0300 Merge branch 'master' into assert * master: Set PHP_JSON_VERSION to 1.4.0 Remove unnecessary resource checks in openssl ext JSON is now maintained commit 8473157fbb12d03fff8d5b602865a4b667522a4d Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Feb 18 10:17:26 2015 +0300 Fixed typo and white spaces commit 96de5ffc8d604df9797d0141ae5ad9c15e1d6c32 Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Feb 18 00:28:39 2015 +0300 Fixed assert() in namesapaces commit 5eba069c28e7b6590618707e0b21cdb2dd62a192 Merge: 4a2d9c0 d428bf2 Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Feb 17 22:45:55 2015 +0300 Merge branch 'master' into assert * master: (25 commits) improve debugability in TS debug builds More UPGRADING, in particular on foreach Fixed bug #69038 (switch(SOMECONSTANT) misbehaves) for master Replace var is introduced abstain from using xmlCleanupParser fix TS build Fix bug #68942 (Use after free vulnerability in unserialize() with DateTimeZone) update news Fix bug #68942 (Use after free vulnerability in unserialize() with DateTimeZone) Port for for bug #68552 Fix bug #68942 (Use after free vulnerability in unserialize() with DateTimeZone) Update NEWS Fixed bug #69038 (switch(SOMECONSTANT) misbehaves) - BFN Don't read the local php.ini when Generating Phar When building phar shared, you can end up loading a previous phar.so that isn't compatible with the php cli being used to generate Phar here. - Fixed bug #67827 (broken detection of system crypt sha256/sha512 support) Delete json outdated package.xml made ZEND_TSRMLS_CACHE_* macros look like function calls - Fix merge - Fixed bug #67427 (SoapServer cannot handle large messages) patch by: brandt at docoloc dot de ... commit 4a2d9c0953dccd9e78ebee9291e1213419eb9136 Author: Dmitry Stogov <dmitry@zend.com> Date: Tue Feb 17 22:45:10 2015 +0300 Implemented AST pretty-printer to capture expression passed to assert() commit 7a059b66d51a65159801bd826346721325b89fec Merge: 9973df7 3892eba Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Feb 16 18:42:28 2015 +0300 Merge branch 'expect' of github.com:krakjoe/php-src into assert * 'expect' of github.com:krakjoe/php-src: import expect Conflicts: Zend/zend_compile.c Zend/zend_execute_API.c Zend/zend_globals.h Zend/zend_vm_def.h Zend/zend_vm_execute.h Zend/zend_vm_opcodes.c Zend/zend_vm_opcodes.h ext/opcache/Optimizer/block_pass.c ext/opcache/Optimizer/pass1_5.c ext/standard/assert.c ext/standard/tests/assert/assert_error3.phpt commit 3892eba2bf56a7699453855c995404106322718d Author: krakjoe <joe.watkins@live.co.uk> Date: Sun Feb 2 12:49:35 2014 +0000 import expect
2015-03-02 17:25:40 +08:00
case ZEND_ASSERT_CHECK:
2016-03-26 02:27:20 +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) {
opline->result_type = IS_UNUSED;
}
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
}
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;
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;
}
}
2015-07-25 04:03:05 +08:00
if (opline->op1_type == IS_CONST) {
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) {
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);
}
ZEND_VM_SET_OPCODE_HANDLER(opline);
1999-04-08 02:10:10 +08:00
opline++;
}
if (op_array->live_range) {
2016-04-29 19:44:56 +08:00
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;
1999-04-08 02:10:10 +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:
return (unary_op_type) bitwise_not_function;
1999-04-08 02:10:10 +08:00
case ZEND_BOOL_NOT:
return (unary_op_type) boolean_not_function;
1999-04-08 02:10:10 +08:00
default:
return (unary_op_type) NULL;
1999-04-08 02:10:10 +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:
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:
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:
return (binary_op_type) mul_function;
case ZEND_POW:
2017-07-04 02:26:44 +08:00
case ZEND_ASSIGN_POW:
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:
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:
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:
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:
return (binary_op_type) shift_right_function;
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:
return (binary_op_type) concat_function;
case ZEND_IS_IDENTICAL:
return (binary_op_type) is_identical_function;
2000-03-30 06:05:19 +08:00
case ZEND_IS_NOT_IDENTICAL:
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:
return (binary_op_type) is_equal_function;
1999-04-24 08:12:55 +08:00
case ZEND_IS_NOT_EQUAL:
return (binary_op_type) is_not_equal_function;
1999-04-08 02:10:10 +08:00
case ZEND_IS_SMALLER:
return (binary_op_type) is_smaller_function;
1999-04-24 08:12:55 +08:00
case ZEND_IS_SMALLER_OR_EQUAL:
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:
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:
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:
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:
return (binary_op_type) NULL;
1999-04-08 02:10:10 +08:00
}
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: t
* End:
2017-07-05 00:12:45 +08:00
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/