Skip to content

Commit 828d8e6

Browse files
committed
Fix ZEND_VM_SPEC=0 build
1 parent 6b25819 commit 828d8e6

File tree

4 files changed

+150
-111
lines changed

4 files changed

+150
-111
lines changed

Zend/zend_execute.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ typedef int (ZEND_FASTCALL *incdec_t)(zval *);
105105
#define get_zval_ptr_deref(op_type, node, should_free, type) _get_zval_ptr_deref(op_type, node, should_free, type EXECUTE_DATA_CC OPLINE_CC)
106106
#define get_zval_ptr_undef(op_type, node, should_free, type) _get_zval_ptr_undef(op_type, node, should_free, type EXECUTE_DATA_CC OPLINE_CC)
107107
#define get_op_data_zval_ptr_r(op_type, node, should_free) _get_op_data_zval_ptr_r(op_type, node, should_free EXECUTE_DATA_CC OPLINE_CC)
108+
#define get_op_data_zval_ptr_deref_r(op_type, node, should_free) _get_op_data_zval_ptr_deref_r(op_type, node, should_free EXECUTE_DATA_CC OPLINE_CC)
108109
#define get_zval_ptr_ptr(op_type, node, should_free, type) _get_zval_ptr_ptr(op_type, node, should_free, type EXECUTE_DATA_CC)
109110
#define get_zval_ptr_ptr_undef(op_type, node, should_free, type) _get_zval_ptr_ptr(op_type, node, should_free, type EXECUTE_DATA_CC)
110111
#define get_obj_zval_ptr(op_type, node, should_free, type) _get_obj_zval_ptr(op_type, node, should_free, type EXECUTE_DATA_CC OPLINE_CC)
@@ -503,6 +504,27 @@ static zend_always_inline zval *_get_zval_ptr_deref(int op_type, znode_op node,
503504
}
504505
}
505506

507+
static zend_always_inline zval *_get_op_data_zval_ptr_deref_r(int op_type, znode_op node, zend_free_op *should_free EXECUTE_DATA_DC OPLINE_DC)
508+
{
509+
if (op_type & (IS_TMP_VAR|IS_VAR)) {
510+
if (op_type == IS_TMP_VAR) {
511+
return _get_zval_ptr_tmp(node.var, should_free EXECUTE_DATA_CC);
512+
} else {
513+
ZEND_ASSERT(op_type == IS_VAR);
514+
return _get_zval_ptr_var_deref(node.var, should_free EXECUTE_DATA_CC);
515+
}
516+
} else {
517+
*should_free = NULL;
518+
if (op_type == IS_CONST) {
519+
return RT_CONSTANT(opline + 1, node);
520+
} else if (op_type == IS_CV) {
521+
return _get_zval_ptr_cv_deref_BP_VAR_R(node.var EXECUTE_DATA_CC);
522+
} else {
523+
return NULL;
524+
}
525+
}
526+
}
527+
506528
static zend_always_inline zval *_get_zval_ptr_undef(int op_type, znode_op node, zend_free_op *should_free, int type EXECUTE_DATA_DC OPLINE_DC)
507529
{
508530
if (op_type & (IS_TMP_VAR|IS_VAR)) {

Zend/zend_vm_def.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -862,15 +862,14 @@ ZEND_VM_HELPER(zend_binary_assign_op_dim_helper, VAR|CV, CONST|TMPVAR|UNUSED|CV,
862862
ZEND_VM_C_LABEL(assign_dim_op_array):
863863
SEPARATE_ARRAY(container);
864864
ZEND_VM_C_LABEL(assign_dim_op_new_array):
865+
dim = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
865866
if (OP2_TYPE == IS_UNUSED) {
866867
var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
867868
if (UNEXPECTED(!var_ptr)) {
868869
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
869870
ZEND_VM_C_GOTO(assign_dim_op_ret_null);
870871
}
871872
} else {
872-
dim = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
873-
874873
if (OP2_TYPE == IS_CONST) {
875874
var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim EXECUTE_DATA_CC);
876875
} else {
@@ -2008,18 +2007,18 @@ ZEND_VM_HANDLER(94, ZEND_FETCH_OBJ_FUNC_ARG, CONST|TMP|VAR|UNUSED|THIS|CV, CONST
20082007
zval *property;
20092008

20102009
SAVE_OPLINE();
2011-
container = GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
2012-
2013-
if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
2014-
ZEND_VM_DISPATCH_TO_HELPER(zend_this_not_in_object_context_helper);
2015-
}
20162010
if ((OP1_TYPE & (IS_CONST|IS_TMP_VAR))) {
20172011
zend_throw_error(NULL, "Cannot use temporary expression in write context");
20182012
FREE_UNFETCHED_OP2();
2019-
FREE_OP1_VAR_PTR();
2013+
FREE_UNFETCHED_OP1();
20202014
ZVAL_UNDEF(EX_VAR(opline->result.var));
20212015
HANDLE_EXCEPTION();
20222016
}
2017+
2018+
container = GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
2019+
if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
2020+
ZEND_VM_DISPATCH_TO_HELPER(zend_this_not_in_object_context_helper);
2021+
}
20232022
property = GET_OP2_ZVAL_PTR(BP_VAR_R);
20242023
zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W);
20252024
FREE_OP2();
@@ -5799,7 +5798,9 @@ ZEND_VM_HANDLER(125, ZEND_FE_RESET_RW, CONST|TMP|VAR|CV, JMP_ADDR)
57995798
}
58005799
Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(Z_ARRVAL_P(array_ptr), 0);
58015800

5802-
FREE_OP1_VAR_PTR();
5801+
if (OP1_TYPE == IS_VAR) {
5802+
FREE_OP1_VAR_PTR();
5803+
}
58035804
ZEND_VM_NEXT_OPCODE();
58045805
} else if (OP1_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(array_ptr) == IS_OBJECT)) {
58055806
if (!Z_OBJCE_P(array_ptr)->get_iterator) {
@@ -5823,7 +5824,9 @@ ZEND_VM_HANDLER(125, ZEND_FE_RESET_RW, CONST|TMP|VAR|CV, JMP_ADDR)
58235824
}
58245825
Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(Z_OBJPROP_P(array_ptr), 0);
58255826

5826-
FREE_OP1_VAR_PTR();
5827+
if (OP1_TYPE == IS_VAR) {
5828+
FREE_OP1_VAR_PTR();
5829+
}
58275830
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
58285831
} else {
58295832
zend_class_entry *ce = Z_OBJCE_P(array_ptr);

0 commit comments

Comments
 (0)