mirror of
https://github.com/php/php-src.git
synced 2024-11-28 20:34:29 +08:00
Remove most uses of the ERROR type
It is now only used to signal exceptions for property reads. ERROR zvals are never returned back to the VM anymore, so there's no need to check for them when receiving a VAR. Also return MAY_BE_ERROR, as ERROR is now no longer relevant for inference.
This commit is contained in:
parent
7e77617533
commit
01fc1a3057
@ -1,16 +0,0 @@
|
||||
--TEST--
|
||||
Bug #36303 (foreach on error_zval produces segfault)
|
||||
--XFAIL--
|
||||
TODO: ERROR zval still possible?
|
||||
--FILE--
|
||||
<?php
|
||||
$x = [];
|
||||
foreach ($x[[]] as &$v) {
|
||||
}
|
||||
echo "ok\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Illegal offset type in %s on line %d
|
||||
|
||||
Warning: Invalid argument supplied for foreach() in %s on line %d
|
||||
ok
|
@ -1,13 +0,0 @@
|
||||
--TEST--
|
||||
Bug #52237 (Crash when passing the reference of the property of a non-object)
|
||||
--XFAIL--
|
||||
TODO: ERROR zval still possible?
|
||||
--FILE--
|
||||
<?php
|
||||
$data = [];
|
||||
preg_match('//', '', $data[[]]);
|
||||
var_dump(count($data));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Illegal offset type in %s on line %d
|
||||
int(0)
|
@ -617,30 +617,27 @@ static zend_never_inline zend_bool zend_verify_ref_array_assignable(zend_referen
|
||||
/* this should modify object only if it's empty */
|
||||
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_throw_non_object_error(zval *object, zval *property OPLINE_DC EXECUTE_DATA_DC)
|
||||
{
|
||||
/* TODO: What about the ERROR case? */
|
||||
if (EXPECTED(!Z_ISERROR_P(object))) {
|
||||
zend_string *tmp_property_name;
|
||||
zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name);
|
||||
zend_string *tmp_property_name;
|
||||
zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name);
|
||||
|
||||
if (opline->opcode == ZEND_PRE_INC_OBJ
|
||||
|| opline->opcode == ZEND_PRE_DEC_OBJ
|
||||
|| opline->opcode == ZEND_POST_INC_OBJ
|
||||
|| opline->opcode == ZEND_POST_DEC_OBJ) {
|
||||
zend_throw_error(NULL,
|
||||
"Attempt to increment/decrement property '%s' of non-object",
|
||||
ZSTR_VAL(property_name));
|
||||
} else if (opline->opcode == ZEND_FETCH_OBJ_W
|
||||
|| opline->opcode == ZEND_FETCH_OBJ_RW
|
||||
|| opline->opcode == ZEND_FETCH_OBJ_FUNC_ARG
|
||||
|| opline->opcode == ZEND_ASSIGN_OBJ_REF) {
|
||||
zend_throw_error(NULL,
|
||||
"Attempt to modify property '%s' of non-object", ZSTR_VAL(property_name));
|
||||
} else {
|
||||
zend_throw_error(NULL,
|
||||
"Attempt to assign property '%s' of non-object", ZSTR_VAL(property_name));
|
||||
}
|
||||
zend_tmp_string_release(tmp_property_name);
|
||||
if (opline->opcode == ZEND_PRE_INC_OBJ
|
||||
|| opline->opcode == ZEND_PRE_DEC_OBJ
|
||||
|| opline->opcode == ZEND_POST_INC_OBJ
|
||||
|| opline->opcode == ZEND_POST_DEC_OBJ) {
|
||||
zend_throw_error(NULL,
|
||||
"Attempt to increment/decrement property '%s' of non-object",
|
||||
ZSTR_VAL(property_name));
|
||||
} else if (opline->opcode == ZEND_FETCH_OBJ_W
|
||||
|| opline->opcode == ZEND_FETCH_OBJ_RW
|
||||
|| opline->opcode == ZEND_FETCH_OBJ_FUNC_ARG
|
||||
|| opline->opcode == ZEND_ASSIGN_OBJ_REF) {
|
||||
zend_throw_error(NULL,
|
||||
"Attempt to modify property '%s' of non-object", ZSTR_VAL(property_name));
|
||||
} else {
|
||||
zend_throw_error(NULL,
|
||||
"Attempt to assign property '%s' of non-object", ZSTR_VAL(property_name));
|
||||
}
|
||||
zend_tmp_string_release(tmp_property_name);
|
||||
|
||||
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ZVAL_NULL(EX_VAR(opline->result.var));
|
||||
@ -1914,7 +1911,7 @@ static ZEND_COLD void zend_binary_assign_op_dim_slow(zval *container, zval *dim
|
||||
zend_check_string_offset(dim, BP_VAR_RW EXECUTE_DATA_CC);
|
||||
zend_wrong_string_offset(EXECUTE_DATA_C);
|
||||
}
|
||||
} else if (EXPECTED(!Z_ISERROR_P(container))) {
|
||||
} else {
|
||||
zend_use_scalar_as_array();
|
||||
}
|
||||
FREE_OP((opline+1)->op1_type, (opline+1)->op1.var);
|
||||
@ -2079,13 +2076,13 @@ fetch_from_array:
|
||||
retval = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
|
||||
if (UNEXPECTED(retval == NULL)) {
|
||||
zend_cannot_add_element();
|
||||
ZVAL_ERROR(result);
|
||||
ZVAL_UNDEF(result);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(!retval)) {
|
||||
ZVAL_ERROR(result);
|
||||
ZVAL_UNDEF(result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2100,7 +2097,7 @@ fetch_from_array:
|
||||
if (type != BP_VAR_UNSET) {
|
||||
if (ZEND_REF_HAS_TYPE_SOURCES(ref)) {
|
||||
if (UNEXPECTED(!zend_verify_ref_array_assignable(ref))) {
|
||||
ZVAL_ERROR(result);
|
||||
ZVAL_UNDEF(result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2118,7 +2115,7 @@ fetch_from_array:
|
||||
zend_check_string_offset(dim, type EXECUTE_DATA_CC);
|
||||
zend_wrong_string_offset(EXECUTE_DATA_C);
|
||||
}
|
||||
ZVAL_ERROR(result);
|
||||
ZVAL_UNDEF(result);
|
||||
} else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
|
||||
if (ZEND_CONST_COND(dim_type == IS_CV, dim != NULL) && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
|
||||
dim = ZVAL_UNDEFINED_OP2();
|
||||
@ -2150,7 +2147,8 @@ fetch_from_array:
|
||||
ZVAL_INDIRECT(result, retval);
|
||||
}
|
||||
} else {
|
||||
ZVAL_ERROR(result);
|
||||
ZEND_ASSERT(EG(exception) && "read_dimension() returned NULL without exception");
|
||||
ZVAL_UNDEF(result);
|
||||
}
|
||||
} else {
|
||||
if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
|
||||
@ -2168,15 +2166,13 @@ return_null:
|
||||
}
|
||||
ZVAL_NULL(result);
|
||||
}
|
||||
} else if (EXPECTED(Z_ISERROR_P(container))) {
|
||||
ZVAL_ERROR(result);
|
||||
} else {
|
||||
if (type == BP_VAR_UNSET) {
|
||||
zend_throw_error(NULL, "Cannot unset offset in a non-array variable");
|
||||
ZVAL_NULL(result);
|
||||
ZVAL_UNDEF(result);
|
||||
} else {
|
||||
zend_use_scalar_as_array();
|
||||
ZVAL_ERROR(result);
|
||||
ZVAL_UNDEF(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2698,13 +2694,12 @@ static zend_always_inline void zend_assign_to_property_reference(zval *container
|
||||
variable_ptr = Z_INDIRECT_P(variable_ptr);
|
||||
}
|
||||
|
||||
/* variable_ptr may be ERROR if fetching the property threw an exception. */
|
||||
if (UNEXPECTED(Z_ISERROR_P(variable_ptr))) {
|
||||
variable_ptr = &EG(uninitialized_zval);
|
||||
} else if (UNEXPECTED(Z_TYPE(variable) != IS_INDIRECT)) {
|
||||
zend_throw_error(NULL, "Cannot assign by reference to overloaded object");
|
||||
variable_ptr = &EG(uninitialized_zval);
|
||||
} else if (/*OP_DATA_TYPE == IS_VAR &&*/ UNEXPECTED(Z_ISERROR_P(value_ptr))) {
|
||||
variable_ptr = &EG(uninitialized_zval);
|
||||
} else if (/*OP_DATA_TYPE == IS_VAR &&*/
|
||||
(opline->extended_value & ZEND_RETURNS_FUNCTION) &&
|
||||
UNEXPECTED(!Z_ISREF_P(value_ptr))) {
|
||||
|
@ -57,7 +57,7 @@
|
||||
#define MAY_BE_ARRAY_KEY_STRING (1<<26)
|
||||
#define MAY_BE_ARRAY_KEY_ANY (MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_KEY_STRING)
|
||||
|
||||
#define MAY_BE_ERROR (1<<27)
|
||||
/* Bit 27 unused */
|
||||
#define MAY_BE_CLASS (1<<28)
|
||||
|
||||
#endif /* ZEND_TYPE_INFO_H */
|
||||
|
@ -1279,26 +1279,20 @@ ZEND_VM_HANDLER(26, ZEND_ASSIGN_OP, VAR|CV, CONST|TMPVAR|CV, OP)
|
||||
value = GET_OP2_ZVAL_PTR(BP_VAR_R);
|
||||
var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW);
|
||||
|
||||
if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(var_ptr))) {
|
||||
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ZVAL_NULL(EX_VAR(opline->result.var));
|
||||
}
|
||||
} else {
|
||||
do {
|
||||
if (UNEXPECTED(Z_TYPE_P(var_ptr) == IS_REFERENCE)) {
|
||||
zend_reference *ref = Z_REF_P(var_ptr);
|
||||
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
|
||||
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
|
||||
break;
|
||||
}
|
||||
var_ptr = Z_REFVAL_P(var_ptr);
|
||||
do {
|
||||
if (UNEXPECTED(Z_TYPE_P(var_ptr) == IS_REFERENCE)) {
|
||||
zend_reference *ref = Z_REF_P(var_ptr);
|
||||
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
|
||||
zend_binary_assign_op_typed_ref(ref, value OPLINE_CC EXECUTE_DATA_CC);
|
||||
break;
|
||||
}
|
||||
zend_binary_op(var_ptr, var_ptr, value OPLINE_CC);
|
||||
} while (0);
|
||||
|
||||
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
|
||||
var_ptr = Z_REFVAL_P(var_ptr);
|
||||
}
|
||||
zend_binary_op(var_ptr, var_ptr, value OPLINE_CC);
|
||||
} while (0);
|
||||
|
||||
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
|
||||
}
|
||||
|
||||
FREE_OP2();
|
||||
@ -1520,13 +1514,6 @@ ZEND_VM_HELPER(zend_pre_inc_helper, VAR|CV, ANY)
|
||||
|
||||
var_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
|
||||
|
||||
if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(var_ptr))) {
|
||||
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ZVAL_NULL(EX_VAR(opline->result.var));
|
||||
}
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
SAVE_OPLINE();
|
||||
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
|
||||
ZVAL_NULL(var_ptr);
|
||||
@ -1578,13 +1565,6 @@ ZEND_VM_HELPER(zend_pre_dec_helper, VAR|CV, ANY)
|
||||
|
||||
var_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
|
||||
|
||||
if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(var_ptr))) {
|
||||
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ZVAL_NULL(EX_VAR(opline->result.var));
|
||||
}
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
SAVE_OPLINE();
|
||||
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
|
||||
ZVAL_NULL(var_ptr);
|
||||
@ -1637,11 +1617,6 @@ ZEND_VM_HELPER(zend_post_inc_helper, VAR|CV, ANY)
|
||||
|
||||
var_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
|
||||
|
||||
if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(var_ptr))) {
|
||||
ZVAL_NULL(EX_VAR(opline->result.var));
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
SAVE_OPLINE();
|
||||
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
|
||||
ZVAL_NULL(var_ptr);
|
||||
@ -1690,11 +1665,6 @@ ZEND_VM_HELPER(zend_post_dec_helper, VAR|CV, ANY)
|
||||
|
||||
var_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
|
||||
|
||||
if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(var_ptr))) {
|
||||
ZVAL_NULL(EX_VAR(opline->result.var));
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
SAVE_OPLINE();
|
||||
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
|
||||
ZVAL_NULL(var_ptr);
|
||||
@ -2718,9 +2688,7 @@ ZEND_VM_C_LABEL(try_assign_dim_array):
|
||||
ZEND_VM_C_GOTO(try_assign_dim_array);
|
||||
}
|
||||
} else {
|
||||
if (OP1_TYPE != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) {
|
||||
zend_use_scalar_as_array();
|
||||
}
|
||||
zend_use_scalar_as_array();
|
||||
dim = GET_OP2_ZVAL_PTR(BP_VAR_R);
|
||||
ZEND_VM_C_LABEL(assign_dim_error):
|
||||
FREE_UNFETCHED_OP_DATA();
|
||||
@ -2747,19 +2715,12 @@ ZEND_VM_HANDLER(22, ZEND_ASSIGN, VAR|CV, CONST|TMP|VAR|CV, SPEC(RETVAL))
|
||||
value = GET_OP2_ZVAL_PTR(BP_VAR_R);
|
||||
variable_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
|
||||
|
||||
if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(variable_ptr))) {
|
||||
FREE_OP2();
|
||||
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ZVAL_NULL(EX_VAR(opline->result.var));
|
||||
}
|
||||
} else {
|
||||
value = zend_assign_to_variable(variable_ptr, value, OP2_TYPE, EX_USES_STRICT_TYPES());
|
||||
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ZVAL_COPY(EX_VAR(opline->result.var), value);
|
||||
}
|
||||
FREE_OP1_VAR_PTR();
|
||||
/* zend_assign_to_variable() always takes care of op2, never free it! */
|
||||
value = zend_assign_to_variable(variable_ptr, value, OP2_TYPE, EX_USES_STRICT_TYPES());
|
||||
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ZVAL_COPY(EX_VAR(opline->result.var), value);
|
||||
}
|
||||
FREE_OP1_VAR_PTR();
|
||||
/* zend_assign_to_variable() always takes care of op2, never free it! */
|
||||
|
||||
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
|
||||
}
|
||||
@ -2774,15 +2735,11 @@ ZEND_VM_HANDLER(30, ZEND_ASSIGN_REF, VAR|CV, VAR|CV, SRC)
|
||||
value_ptr = GET_OP2_ZVAL_PTR_PTR(BP_VAR_W);
|
||||
variable_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
|
||||
|
||||
if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(variable_ptr))) {
|
||||
variable_ptr = &EG(uninitialized_zval);
|
||||
} else if (OP1_TYPE == IS_VAR &&
|
||||
if (OP1_TYPE == IS_VAR &&
|
||||
UNEXPECTED(Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_INDIRECT)) {
|
||||
|
||||
zend_throw_error(NULL, "Cannot assign by reference to an array dimension of an object");
|
||||
variable_ptr = &EG(uninitialized_zval);
|
||||
} else if (OP2_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(value_ptr))) {
|
||||
variable_ptr = &EG(uninitialized_zval);
|
||||
} else if (OP2_TYPE == IS_VAR &&
|
||||
opline->extended_value == ZEND_RETURNS_FUNCTION &&
|
||||
UNEXPECTED(!Z_ISREF_P(value_ptr))) {
|
||||
@ -2861,9 +2818,7 @@ ZEND_VM_HANDLER(33, ZEND_ASSIGN_STATIC_PROP_REF, ANY, ANY, CACHE_SLOT|SRC)
|
||||
|
||||
value_ptr = GET_OP_DATA_ZVAL_PTR_PTR(BP_VAR_W);
|
||||
|
||||
if (OP_DATA_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(value_ptr))) {
|
||||
prop = &EG(uninitialized_zval);
|
||||
} else if (OP_DATA_TYPE == IS_VAR && (opline->extended_value & ZEND_RETURNS_FUNCTION) && UNEXPECTED(!Z_ISREF_P(value_ptr))) {
|
||||
if (OP_DATA_TYPE == IS_VAR && (opline->extended_value & ZEND_RETURNS_FUNCTION) && UNEXPECTED(!Z_ISREF_P(value_ptr))) {
|
||||
if (UNEXPECTED(!zend_wrong_assign_to_variable_reference(prop, value_ptr OPLINE_CC EXECUTE_DATA_CC))) {
|
||||
prop = &EG(uninitialized_zval);
|
||||
}
|
||||
@ -4789,12 +4744,6 @@ ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, NUM)
|
||||
varptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
|
||||
|
||||
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
|
||||
if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(varptr))) {
|
||||
ZVAL_NEW_EMPTY_REF(arg);
|
||||
ZVAL_NULL(Z_REFVAL_P(arg));
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
if (Z_ISREF_P(varptr)) {
|
||||
Z_ADDREF_P(varptr);
|
||||
} else {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1450,6 +1450,7 @@ static zval *dom_nodelist_read_dimension(zend_object *object, zval *offset, int
|
||||
zval offset_copy;
|
||||
|
||||
if (!offset) {
|
||||
zend_throw_error(NULL, "Cannot access node list without offset");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,11 @@ var_dump(isset($nodes[$offset]), $nodes[$offset]->textContent);
|
||||
var_dump($offset);
|
||||
|
||||
echo "testing read_dimension with null offset\n";
|
||||
var_dump($nodes[][] = 1);
|
||||
try {
|
||||
var_dump($nodes[][] = 1);
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
echo "testing attribute access\n";
|
||||
$anchor = $doc->getElementsByTagName('a')[0];
|
||||
@ -82,7 +86,7 @@ bool(true)
|
||||
string(4) "data"
|
||||
string(4) "test"
|
||||
testing read_dimension with null offset
|
||||
NULL
|
||||
Cannot access node list without offset
|
||||
testing attribute access
|
||||
string(4) "href"
|
||||
==DONE==
|
||||
|
@ -311,10 +311,6 @@ static void zend_dump_type_info(uint32_t info, zend_class_entry *ce, int is_inst
|
||||
fprintf(stderr, "resource");
|
||||
}
|
||||
}
|
||||
if (info & MAY_BE_ERROR) {
|
||||
if (first) first = 0; else fprintf(stderr, ", ");
|
||||
fprintf(stderr, "error");
|
||||
}
|
||||
//TODO: this is useful only for JIT???
|
||||
if (info & MAY_BE_IN_REG) {
|
||||
if (first) first = 0; else fprintf(stderr, ", ");
|
||||
|
@ -2065,16 +2065,10 @@ uint32_t zend_array_element_type(uint32_t t1, int write, int insert)
|
||||
}
|
||||
if (t1 & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
|
||||
tmp |= MAY_BE_NULL;
|
||||
if (t1 & MAY_BE_ERROR) {
|
||||
if (write) {
|
||||
tmp |= MAY_BE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t1 & (MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_RESOURCE)) {
|
||||
tmp |= MAY_BE_NULL;
|
||||
if (write) {
|
||||
tmp |= MAY_BE_ERROR;
|
||||
if (!write) {
|
||||
tmp |= MAY_BE_NULL;
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
@ -2425,8 +2419,8 @@ static int zend_update_type_info(const zend_op_array *op_array,
|
||||
/* If one of the operands cannot have any type, this means the operand derives from
|
||||
* unreachable code. Propagate the empty result early, so that that the following
|
||||
* code may assume that operands have at least one type. */
|
||||
if (!(t1 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS|MAY_BE_ERROR))
|
||||
|| !(t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS|MAY_BE_ERROR))) {
|
||||
if (!(t1 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))
|
||||
|| !(t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))) {
|
||||
tmp = 0;
|
||||
if (ssa_ops[i].result_def >= 0) {
|
||||
UPDATE_SSA_TYPE(tmp, ssa_ops[i].result_def);
|
||||
@ -2717,9 +2711,6 @@ static int zend_update_type_info(const zend_op_array *op_array,
|
||||
tmp |= MAY_BE_LONG;
|
||||
}
|
||||
} else {
|
||||
if (t1 & MAY_BE_ERROR) {
|
||||
tmp |= MAY_BE_NULL;
|
||||
}
|
||||
if (t1 & (MAY_BE_UNDEF | MAY_BE_NULL)) {
|
||||
if (opline->opcode == ZEND_PRE_INC) {
|
||||
tmp |= MAY_BE_LONG;
|
||||
@ -2752,7 +2743,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
|
||||
if (t1 & (MAY_BE_RC1|MAY_BE_RCN)) {
|
||||
tmp |= MAY_BE_RC1|MAY_BE_RCN;
|
||||
}
|
||||
tmp |= t1 & ~(MAY_BE_UNDEF|MAY_BE_ERROR|MAY_BE_REF|MAY_BE_RCN);
|
||||
tmp |= t1 & ~(MAY_BE_UNDEF|MAY_BE_REF|MAY_BE_RCN);
|
||||
if (t1 & MAY_BE_UNDEF) {
|
||||
tmp |= MAY_BE_NULL;
|
||||
}
|
||||
@ -2779,9 +2770,6 @@ static int zend_update_type_info(const zend_op_array *op_array,
|
||||
tmp |= MAY_BE_LONG;
|
||||
}
|
||||
} else {
|
||||
if (t1 & MAY_BE_ERROR) {
|
||||
tmp |= MAY_BE_NULL;
|
||||
}
|
||||
if (t1 & (MAY_BE_UNDEF | MAY_BE_NULL)) {
|
||||
if (opline->opcode == ZEND_POST_INC) {
|
||||
tmp |= MAY_BE_LONG;
|
||||
@ -2959,7 +2947,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
|
||||
if (opline->op2_type == IS_VAR && opline->extended_value == ZEND_RETURNS_FUNCTION) {
|
||||
tmp = (MAY_BE_REF | MAY_BE_RCN | MAY_BE_RC1 | t2) & ~MAY_BE_UNDEF;
|
||||
} else {
|
||||
tmp = (MAY_BE_REF | t2) & ~(MAY_BE_UNDEF|MAY_BE_ERROR|MAY_BE_RC1|MAY_BE_RCN);
|
||||
tmp = (MAY_BE_REF | t2) & ~(MAY_BE_UNDEF|MAY_BE_RC1|MAY_BE_RCN);
|
||||
}
|
||||
if (t2 & MAY_BE_UNDEF) {
|
||||
tmp |= MAY_BE_NULL;
|
||||
@ -2987,7 +2975,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
|
||||
if ((opline+1)->op1_type == IS_VAR && (opline->extended_value & ZEND_RETURNS_FUNCTION)) {
|
||||
tmp = (MAY_BE_REF | MAY_BE_RCN | MAY_BE_RC1 | t2) & ~MAY_BE_UNDEF;
|
||||
} else {
|
||||
tmp = (MAY_BE_REF | t2) & ~(MAY_BE_UNDEF|MAY_BE_ERROR|MAY_BE_RC1|MAY_BE_RCN);
|
||||
tmp = (MAY_BE_REF | t2) & ~(MAY_BE_UNDEF|MAY_BE_RC1|MAY_BE_RCN);
|
||||
}
|
||||
if (t2 & MAY_BE_UNDEF) {
|
||||
tmp |= MAY_BE_NULL;
|
||||
@ -3484,18 +3472,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
|
||||
opline->opcode != ZEND_FETCH_LIST_R ? t1 : ((t1 & ~MAY_BE_STRING) | MAY_BE_NULL),
|
||||
opline->result_type == IS_VAR,
|
||||
opline->op2_type == IS_UNUSED);
|
||||
if (opline->opcode == ZEND_FETCH_DIM_W ||
|
||||
opline->opcode == ZEND_FETCH_DIM_RW ||
|
||||
opline->opcode == ZEND_FETCH_DIM_FUNC_ARG ||
|
||||
opline->opcode == ZEND_FETCH_LIST_W) {
|
||||
if (t1 & (MAY_BE_ERROR|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_RESOURCE|MAY_BE_OBJECT)) {
|
||||
tmp |= MAY_BE_ERROR;
|
||||
} else if (opline->op2_type == IS_UNUSED) {
|
||||
tmp |= MAY_BE_ERROR;
|
||||
} else if (t2 & (MAY_BE_ARRAY|MAY_BE_OBJECT)) {
|
||||
tmp |= MAY_BE_ERROR;
|
||||
}
|
||||
} else if (opline->opcode == ZEND_FETCH_DIM_IS && (t1 & MAY_BE_STRING)) {
|
||||
if (opline->opcode == ZEND_FETCH_DIM_IS && (t1 & MAY_BE_STRING)) {
|
||||
tmp |= MAY_BE_NULL;
|
||||
}
|
||||
UPDATE_SSA_TYPE(tmp, ssa_ops[i].result_def);
|
||||
@ -3514,7 +3491,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
|
||||
tmp = zend_fetch_prop_type(script,
|
||||
zend_fetch_prop_info(op_array, ssa, opline, i), &ce);
|
||||
if (opline->result_type != IS_TMP_VAR) {
|
||||
tmp |= MAY_BE_REF | MAY_BE_ERROR;
|
||||
tmp |= MAY_BE_REF;
|
||||
}
|
||||
UPDATE_SSA_TYPE(tmp, ssa_ops[i].result_def);
|
||||
if (ce) {
|
||||
@ -3531,7 +3508,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
|
||||
tmp = zend_fetch_prop_type(script,
|
||||
zend_fetch_static_prop_info(script, op_array, ssa, opline), &ce);
|
||||
if (opline->result_type != IS_TMP_VAR) {
|
||||
tmp |= MAY_BE_REF | MAY_BE_ERROR;
|
||||
tmp |= MAY_BE_REF;
|
||||
}
|
||||
UPDATE_SSA_TYPE(tmp, ssa_ops[i].result_def);
|
||||
if (ce) {
|
||||
|
@ -199,7 +199,7 @@ static zend_always_inline uint32_t get_ssa_var_info(const zend_ssa *ssa, int ssa
|
||||
if (ssa->var_info && ssa_var_num >= 0) {
|
||||
return ssa->var_info[ssa_var_num].type;
|
||||
} else {
|
||||
return MAY_BE_UNDEF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ERROR;
|
||||
return MAY_BE_UNDEF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -930,9 +930,7 @@ static void ZEND_FASTCALL zend_jit_assign_dim_helper(zval *object_ptr, zval *dim
|
||||
zend_assign_to_string_offset(object_ptr, dim, value, result);
|
||||
}
|
||||
} else {
|
||||
//??? if (OP1_TYPE != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) {
|
||||
zend_throw_error(NULL, "Cannot use a scalar value as an array");
|
||||
//??? }
|
||||
zend_throw_error(NULL, "Cannot use a scalar value as an array");
|
||||
if (result) {
|
||||
ZVAL_UNDEF(result);
|
||||
}
|
||||
@ -977,9 +975,7 @@ static void ZEND_FASTCALL zend_jit_assign_dim_op_helper(zval *container, zval *d
|
||||
//??? } else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
|
||||
//??? ZEND_VM_C_GOTO(assign_dim_op_convert_to_array);
|
||||
} else {
|
||||
//??? if (UNEXPECTED(OP1_TYPE != IS_VAR || EXPECTED(!Z_ISERROR_P(container)))) {
|
||||
zend_throw_error(NULL, "Cannot use a scalar value as an array");
|
||||
//??? }
|
||||
zend_throw_error(NULL, "Cannot use a scalar value as an array");
|
||||
//??? if (retval) {
|
||||
//??? ZVAL_NULL(retval);
|
||||
//??? }
|
||||
|
@ -7542,37 +7542,6 @@ static int zend_jit_send_ref(dasm_State **Dst, const zend_op *opline, zend_op_ar
|
||||
| // ret = Z_INDIRECT_P(ret);
|
||||
| GET_Z_PTR r0, r0
|
||||
|1:
|
||||
if (op1_info & MAY_BE_ERROR) {
|
||||
if (op1_info & (MAY_BE_ANY|MAY_BE_REF)) {
|
||||
if (cold) {
|
||||
| IF_NOT_Z_TYPE r0, _IS_ERROR, >1
|
||||
} else {
|
||||
| IF_Z_TYPE r0, _IS_ERROR, >1
|
||||
|.cold_code
|
||||
|1:
|
||||
}
|
||||
}
|
||||
|
||||
| // ZVAL_NEW_EMPTY_REF(arg);
|
||||
| EMALLOC sizeof(zend_reference), op_array, opline
|
||||
| SET_ZVAL_PTR arg_addr, r0
|
||||
| SET_ZVAL_TYPE_INFO arg_addr, IS_REFERENCE_EX
|
||||
| mov dword [r0], 1
|
||||
| mov dword [r0 + offsetof(zend_reference, gc.u.type_info)], IS_REFERENCE
|
||||
| mov aword [r0 + offsetof(zend_reference, sources.ptr)], 0
|
||||
ref_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 8);
|
||||
| // ZVAL_NULL(Z_REFVAL_P(arg));
|
||||
| SET_ZVAL_TYPE_INFO ref_addr, IS_NULL
|
||||
|
||||
if (op1_info & (MAY_BE_ANY|MAY_BE_REF)) {
|
||||
| jmp >7
|
||||
if (cold) {
|
||||
|1:
|
||||
} else {
|
||||
|.code
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (opline->op1_type == IS_CV) {
|
||||
if (op1_info & MAY_BE_UNDEF) {
|
||||
if (op1_info & (MAY_BE_ANY|MAY_BE_REF)) {
|
||||
|
Loading…
Reference in New Issue
Block a user