diff options
| author | Dmitry Stogov <dmitry@zend.com> | 2017-10-10 10:11:05 +0300 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@zend.com> | 2017-10-10 10:11:05 +0300 |
| commit | ef5ea48741a1d227a10a6654c1a8cc2f02dd414f (patch) | |
| tree | b00f4e9dd2ea42355c860a0ea57a0d9f4b926091 /ext | |
| parent | 08c0998b1ff1fa1a105eda1540a90ddb8ee4b16a (diff) | |
| download | php-git-ef5ea48741a1d227a10a6654c1a8cc2f02dd414f.tar.gz | |
Always use IS_CONSTANT_AST (IS_CONSTANT is removed).
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/com_dotnet/com_variant.c | 1 | ||||
| -rw-r--r-- | ext/opcache/Optimizer/compact_literals.c | 1 | ||||
| -rw-r--r-- | ext/opcache/Optimizer/optimize_func_calls.c | 2 | ||||
| -rw-r--r-- | ext/opcache/Optimizer/pass1_5.c | 11 | ||||
| -rw-r--r-- | ext/opcache/Optimizer/zend_dump.c | 3 | ||||
| -rw-r--r-- | ext/opcache/Optimizer/zend_inference.c | 4 | ||||
| -rw-r--r-- | ext/opcache/Optimizer/zend_inference.h | 4 | ||||
| -rw-r--r-- | ext/opcache/zend_file_cache.c | 8 | ||||
| -rw-r--r-- | ext/opcache/zend_persist.c | 7 | ||||
| -rw-r--r-- | ext/opcache/zend_persist_calc.c | 5 | ||||
| -rw-r--r-- | ext/reflection/php_reflection.c | 25 | ||||
| -rw-r--r-- | ext/soap/php_encoding.c | 1 | ||||
| -rw-r--r-- | ext/standard/basic_functions.c | 2 | ||||
| -rw-r--r-- | ext/xmlrpc/xmlrpc-epi-php.c | 3 |
14 files changed, 34 insertions, 43 deletions
diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c index b74e977f0e..04c7d5f8c1 100644 --- a/ext/com_dotnet/com_variant.c +++ b/ext/com_dotnet/com_variant.c @@ -176,7 +176,6 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codep break; case IS_RESOURCE: - case IS_CONSTANT: case IS_CONSTANT_AST: default: V_VT(v) = VT_NULL; diff --git a/ext/opcache/Optimizer/compact_literals.c b/ext/opcache/Optimizer/compact_literals.c index 0b98da054d..a8457c9405 100644 --- a/ext/opcache/Optimizer/compact_literals.c +++ b/ext/opcache/Optimizer/compact_literals.c @@ -422,7 +422,6 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx } break; case IS_STRING: - case IS_CONSTANT: if (info[i].flags & LITERAL_MAY_MERGE) { if (info[i].flags & LITERAL_EX_OBJ) { int key_len = sizeof("$this->") - 1 + Z_STRLEN(op_array->literals[i]); diff --git a/ext/opcache/Optimizer/optimize_func_calls.c b/ext/opcache/Optimizer/optimize_func_calls.c index 1548260b60..81d62ca171 100644 --- a/ext/opcache/Optimizer/optimize_func_calls.c +++ b/ext/opcache/Optimizer/optimize_func_calls.c @@ -123,7 +123,7 @@ static void zend_try_inline_call(zend_op_array *op_array, zend_op *fcall, zend_o i = fcall->extended_value; do { - if (Z_CONSTANT_P(RT_CONSTANT(&func->op_array.opcodes[i], func->op_array.opcodes[i].op2))) { + if (Z_TYPE_P(RT_CONSTANT(&func->op_array.opcodes[i], func->op_array.opcodes[i].op2)) == IS_CONSTANT_AST) { return; } i++; diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c index 7697fb1943..9f28019013 100644 --- a/ext/opcache/Optimizer/pass1_5.c +++ b/ext/opcache/Optimizer/pass1_5.c @@ -35,8 +35,6 @@ #include "zend_execute.h" #include "zend_vm.h" -#define ZEND_IS_CONSTANT_TYPE(t) ((t) == IS_CONSTANT) - void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) { int i = 0; @@ -305,11 +303,10 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) (Z_ACCESS_FLAGS(cc->value) & ZEND_ACC_PPP_MASK) == ZEND_ACC_PUBLIC) { c = &cc->value; if (Z_TYPE_P(c) == IS_CONSTANT_AST) { - break; - } - if (ZEND_IS_CONSTANT_TYPE(Z_TYPE_P(c))) { - if (!zend_optimizer_get_persistent_constant(Z_STR_P(c), &t, 1) || - ZEND_IS_CONSTANT_TYPE(Z_TYPE(t))) { + zend_ast *ast = Z_ASTVAL_P(c); + if (ast->kind != ZEND_AST_CONSTANT + || !zend_optimizer_get_persistent_constant(zend_ast_get_constant_name(ast), &t, 1) + || Z_TYPE(t) == IS_CONSTANT_AST) { break; } } else { diff --git a/ext/opcache/Optimizer/zend_dump.c b/ext/opcache/Optimizer/zend_dump.c index 1b77eae74e..ac13187624 100644 --- a/ext/opcache/Optimizer/zend_dump.c +++ b/ext/opcache/Optimizer/zend_dump.c @@ -455,9 +455,6 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * if (opline->extended_value & IS_CONSTANT_UNQUALIFIED) { fprintf(stderr, " (unqualified)"); } - if (opline->extended_value & IS_CONSTANT_CLASS) { - fprintf(stderr, " (__class__)"); - } if (opline->extended_value & IS_CONSTANT_IN_NAMESPACE) { fprintf(stderr, " (in-namespace)"); } diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index 2e7b00a03a..7bb906d4a6 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -2748,7 +2748,7 @@ static int zend_update_type_info(const zend_op_array *op_array, if (arg_info) { tmp = zend_fetch_arg_info(script, arg_info, &ce); if (opline->opcode == ZEND_RECV_INIT && - Z_CONSTANT_P(CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants))) { + Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants)) == IS_CONSTANT_AST) { /* The constant may resolve to NULL */ tmp |= MAY_BE_NULL; } @@ -4260,7 +4260,7 @@ int zend_may_throw(const zend_op *opline, zend_op_array *op_array, zend_ssa *ssa case ZEND_COUNT: return (t1 & MAY_BE_ANY) != MAY_BE_ARRAY; case ZEND_RECV_INIT: - if (Z_CONSTANT_P(CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants))) { + if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline, opline->op2, ssa->rt_constants)) == IS_CONSTANT_AST) { return 1; } if (op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) { diff --git a/ext/opcache/Optimizer/zend_inference.h b/ext/opcache/Optimizer/zend_inference.h index d7a6f97901..6bd9706fa8 100644 --- a/ext/opcache/Optimizer/zend_inference.h +++ b/ext/opcache/Optimizer/zend_inference.h @@ -159,9 +159,7 @@ DEFINE_SSA_OP_RANGE_OVERFLOW(op2) #define OP2_RANGE_OVERFLOW() (_ssa_op2_range_overflow (op_array, ssa, opline)) static zend_always_inline uint32_t _const_op_type(const zval *zv) { - if (Z_TYPE_P(zv) == IS_CONSTANT) { - return MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY; - } else if (Z_TYPE_P(zv) == IS_CONSTANT_AST) { + if (Z_TYPE_P(zv) == IS_CONSTANT_AST) { return MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY; } else if (Z_TYPE_P(zv) == IS_ARRAY) { HashTable *ht = Z_ARRVAL_P(zv); diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index a7758058de..0b95212693 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -278,7 +278,7 @@ static zend_ast *zend_file_cache_serialize_ast(zend_ast *ast, ret = ast; UNSERIALIZE_PTR(ast); - if (ast->kind == ZEND_AST_ZVAL) { + if (ast->kind == ZEND_AST_ZVAL || ast->kind == ZEND_AST_CONSTANT) { zend_file_cache_serialize_zval(&((zend_ast_zval*)ast)->val, script, info, buf); } else if (zend_ast_is_list(ast)) { zend_ast_list *list = zend_ast_get_list(ast); @@ -305,7 +305,6 @@ static void zend_file_cache_serialize_zval(zval *zv, { switch (Z_TYPE_P(zv)) { case IS_STRING: - case IS_CONSTANT: if (!IS_SERIALIZED(Z_STR_P(zv))) { SERIALIZE_STR(Z_STR_P(zv)); } @@ -893,7 +892,7 @@ static zend_ast *zend_file_cache_unserialize_ast(zend_ast *ast, UNSERIALIZE_PTR(ast); - if (ast->kind == ZEND_AST_ZVAL) { + if (ast->kind == ZEND_AST_ZVAL || ast->kind == ZEND_AST_CONSTANT) { zend_file_cache_unserialize_zval(&((zend_ast_zval*)ast)->val, script, buf); } else if (zend_ast_is_list(ast)) { zend_ast_list *list = zend_ast_get_list(ast); @@ -919,7 +918,6 @@ static void zend_file_cache_unserialize_zval(zval *zv, { switch (Z_TYPE_P(zv)) { case IS_STRING: - case IS_CONSTANT: if (!IS_UNSERIALIZED(Z_STR_P(zv))) { UNSERIALIZE_STR(Z_STR_P(zv)); } @@ -945,8 +943,6 @@ static void zend_file_cache_unserialize_zval(zval *zv, break; case IS_CONSTANT_AST: if (!IS_UNSERIALIZED(Z_AST_P(zv))) { - zend_ast_ref *ast; - UNSERIALIZE_PTR(Z_AST_P(zv)); zend_file_cache_unserialize_ast(Z_ASTVAL_P(zv), script, buf); } diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index c21842b66f..8fb7f41e3e 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -249,7 +249,7 @@ static zend_ast *zend_persist_ast(zend_ast *ast) uint32_t i; zend_ast *node; - if (ast->kind == ZEND_AST_ZVAL) { + if (ast->kind == ZEND_AST_ZVAL || ast->kind == ZEND_AST_CONSTANT) { zend_ast_zval *copy = zend_accel_memdup(ast, sizeof(zend_ast_zval)); zend_persist_zval(©->val); node = (zend_ast *) copy; @@ -282,7 +282,6 @@ static void zend_persist_zval(zval *z) switch (Z_TYPE_P(z)) { case IS_STRING: - case IS_CONSTANT: zend_accel_store_interned_string(Z_STR_P(z)); Z_TYPE_FLAGS_P(z) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE); break; @@ -320,12 +319,12 @@ static void zend_persist_zval(zval *z) new_ptr = zend_shared_alloc_get_xlat_entry(Z_AST_P(z)); if (new_ptr) { Z_AST_P(z) = new_ptr; - Z_TYPE_FLAGS_P(z) = IS_TYPE_CONSTANT | IS_TYPE_COPYABLE; + Z_TYPE_FLAGS_P(z) = IS_TYPE_COPYABLE; } else { zend_ast_ref *old_ref = Z_AST_P(z); Z_ARR_P(z) = zend_accel_memdup(Z_AST_P(z), sizeof(zend_ast_ref)); zend_persist_ast(GC_AST(old_ref)); - Z_TYPE_FLAGS_P(z) = IS_TYPE_CONSTANT | IS_TYPE_COPYABLE; + Z_TYPE_FLAGS_P(z) = IS_TYPE_COPYABLE; GC_REFCOUNT(Z_COUNTED_P(z)) = 2; efree(old_ref); } diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c index cb7eb11b7a..0c600daef5 100644 --- a/ext/opcache/zend_persist_calc.c +++ b/ext/opcache/zend_persist_calc.c @@ -94,9 +94,9 @@ static void zend_persist_ast_calc(zend_ast *ast) { uint32_t i; - if (ast->kind == ZEND_AST_ZVAL) { + if (ast->kind == ZEND_AST_ZVAL || ast->kind == ZEND_AST_CONSTANT) { ADD_SIZE(sizeof(zend_ast_zval)); - zend_persist_zval_calc(zend_ast_get_zval(ast)); + zend_persist_zval_calc(&((zend_ast_zval*)(ast))->val); } else if (zend_ast_is_list(ast)) { zend_ast_list *list = zend_ast_get_list(ast); ADD_SIZE(sizeof(zend_ast_list) - sizeof(zend_ast *) + sizeof(zend_ast *) * list->children); @@ -122,7 +122,6 @@ static void zend_persist_zval_calc(zval *z) switch (Z_TYPE_P(z)) { case IS_STRING: - case IS_CONSTANT: ADD_INTERNED_STRING(Z_STR_P(z), 0); if (ZSTR_IS_INTERNED(Z_STR_P(z))) { Z_TYPE_FLAGS_P(z) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index d42299f55d..6a19940686 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2806,7 +2806,7 @@ ZEND_METHOD(reflection_parameter, getDefaultValue) } ZVAL_DUP(return_value, RT_CONSTANT(precv, precv->op2)); - if (Z_CONSTANT_P(return_value)) { + if (Z_TYPE_P(return_value) == IS_CONSTANT_AST) { zval_update_constant_ex(return_value, param->fptr->common.scope); } } @@ -2829,8 +2829,13 @@ ZEND_METHOD(reflection_parameter, isDefaultValueConstant) } precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param); - if (precv && Z_TYPE_P(RT_CONSTANT(precv, precv->op2)) == IS_CONSTANT) { - RETURN_TRUE; + if (precv && Z_TYPE_P(RT_CONSTANT(precv, precv->op2)) == IS_CONSTANT_AST) { + zend_ast *ast = Z_ASTVAL_P(RT_CONSTANT(precv, precv->op2)); + + if (ast->kind == ZEND_AST_CONSTANT + || ast->kind == ZEND_AST_CONSTANT_CLASS) { + RETURN_TRUE; + } } RETURN_FALSE; @@ -2854,8 +2859,14 @@ ZEND_METHOD(reflection_parameter, getDefaultValueConstantName) } precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param); - if (precv && Z_TYPE_P(RT_CONSTANT(precv, precv->op2)) == IS_CONSTANT) { - RETURN_STR_COPY(Z_STR_P(RT_CONSTANT(precv, precv->op2))); + if (precv && Z_TYPE_P(RT_CONSTANT(precv, precv->op2)) == IS_CONSTANT_AST) { + zend_ast *ast = Z_ASTVAL_P(RT_CONSTANT(precv, precv->op2)); + + if (ast->kind == ZEND_AST_CONSTANT) { + RETURN_STR_COPY(zend_ast_get_constant_name(ast)); + } else if (ast->kind == ZEND_AST_CONSTANT_CLASS) { + RETURN_STRINGL("__CLASS__", sizeof("__CLASS__")-1); + } } } /* }}} */ @@ -3698,7 +3709,7 @@ ZEND_METHOD(reflection_class_constant, getValue) GET_REFLECTION_OBJECT_PTR(ref); ZVAL_DUP(return_value, &ref->value); - if (Z_CONSTANT_P(return_value)) { + if (Z_TYPE_P(return_value) == IS_CONSTANT_AST) { zval_update_constant_ex(return_value, ref->ce); } } @@ -3834,7 +3845,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value /* this is necessary to make it able to work with default array * properties, returned to user */ - if (Z_CONSTANT(prop_copy)) { + if (Z_TYPE(prop_copy) == IS_CONSTANT_AST) { if (UNEXPECTED(zval_update_constant_ex(&prop_copy, NULL) != SUCCESS)) { return; } diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 6d69d81c33..16b15698c5 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -149,7 +149,6 @@ encode defaultEncoding[] = { {{IS_DOUBLE, XSD_FLOAT_STRING, XSD_NAMESPACE, NULL, NULL}, to_zval_double, to_xml_double}, {{IS_FALSE, XSD_BOOLEAN_STRING, XSD_NAMESPACE, NULL, NULL}, to_zval_bool, to_xml_bool}, {{IS_TRUE, XSD_BOOLEAN_STRING, XSD_NAMESPACE, NULL, NULL}, to_zval_bool, to_xml_bool}, - {{IS_CONSTANT, XSD_STRING_STRING, XSD_NAMESPACE, NULL, NULL}, to_zval_string, to_xml_string}, {{IS_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_1_ENC_NAMESPACE, NULL, NULL}, to_zval_array, guess_array_map}, {{IS_OBJECT, SOAP_ENC_OBJECT_STRING, SOAP_1_1_ENC_NAMESPACE, NULL, NULL}, to_zval_object, to_xml_object}, {{IS_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_2_ENC_NAMESPACE, NULL, NULL}, to_zval_array, guess_array_map}, diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index fdcc50b860..93d469168b 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3880,7 +3880,7 @@ PHP_FUNCTION(constant) c = zend_get_constant_ex(const_name, scope, ZEND_FETCH_CLASS_SILENT); if (c) { ZVAL_DUP(return_value, c); - if (Z_CONSTANT_P(return_value)) { + if (Z_TYPE_P(return_value) == IS_CONSTANT_AST) { if (UNEXPECTED(zval_update_constant_ex(return_value, scope) != SUCCESS)) { return; } diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c index e20b6d6872..88f52519d0 100644 --- a/ext/xmlrpc/xmlrpc-epi-php.c +++ b/ext/xmlrpc/xmlrpc-epi-php.c @@ -1339,9 +1339,6 @@ XMLRPC_VALUE_TYPE get_zval_xmlrpc_type(zval* value, zval* newvalue) /* {{{ */ case IS_DOUBLE: type = xmlrpc_double; break; - case IS_CONSTANT: - type = xmlrpc_string; - break; case IS_STRING: type = xmlrpc_string; break; |
