]> granicus.if.org Git - php/commitdiff
Delay IS_UNDEF check for FETCH_DIM_W and family
authorDmitry Stogov <dmitry@zend.com>
Tue, 12 Apr 2016 22:19:20 +0000 (01:19 +0300)
committerDmitry Stogov <dmitry@zend.com>
Tue, 12 Apr 2016 22:19:20 +0000 (01:19 +0300)
Zend/zend_execute.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index d95b3b493989d10b4d00a96234f097299c9414ae..71991ad77406c8723e6b81a160a513ed056ebd55 100644 (file)
@@ -385,6 +385,11 @@ static zend_always_inline zval *_get_zval_ptr_cv_undef_BP_VAR_RW(const zend_exec
        return EX_VAR(var);
 }
 
+static zend_always_inline zval *_get_zval_ptr_cv_undef_BP_VAR_UNSET(const zend_execute_data *execute_data, uint32_t var)
+{
+       return EX_VAR(var);
+}
+
 static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var)
 {
        zval *ret = EX_VAR(var);
@@ -1145,6 +1150,8 @@ try_again:
                                        zend_error(E_WARNING, "Illegal string offset '%s'", Z_STRVAL_P(dim));
                                }
                                break;
+                       case IS_UNDEF:
+                               zval_undefined_cv(EG(current_execute_data)->opline->op2.var, EG(current_execute_data));
                        case IS_DOUBLE:
                        case IS_NULL:
                        case IS_FALSE:
@@ -1159,7 +1166,7 @@ try_again:
                                break;
                }
 
-               offset = zval_get_long(dim);
+               offset = _zval_get_long_func(dim);
        } else {
                offset = Z_LVAL_P(dim);
        }
@@ -1692,6 +1699,10 @@ convert_to_array:
                }
                ZVAL_ERROR(result);
        } else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+               if (/*dim_type == IS_CV &&*/ dim && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                       zval_undefined_cv(EG(current_execute_data)->opline->op2.var, EG(current_execute_data));
+                       dim = &EG(uninitialized_zval);
+               }
                if (!Z_OBJ_HT_P(container)->read_dimension) {
                        zend_throw_error(NULL, "Cannot use object as array");
                        ZVAL_ERROR(result);
@@ -1730,22 +1741,30 @@ convert_to_array:
                                ZVAL_ERROR(result);
                        }
                }
-       } else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
-               if (type != BP_VAR_UNSET) {
-                       goto convert_to_array;
-               } else {
-                       /* for read-mode only */
-                       ZVAL_NULL(result);
-               }
-       } else if (EXPECTED(Z_ISERROR_P(container))) {
-               ZVAL_ERROR(result);
        } else {
-               if (type == BP_VAR_UNSET) {
-                       zend_error(E_WARNING, "Cannot unset offset in a non-array variable");
-                       ZVAL_NULL(result);
-               } else {
-                       zend_error(E_WARNING, "Cannot use a scalar value as an array");
+               if (type != BP_VAR_W && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
+                       zval_undefined_cv(EG(current_execute_data)->opline->op1.var, EG(current_execute_data));
+               }
+               if (/*dim_type == IS_CV &&*/ dim && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                       zval_undefined_cv(EG(current_execute_data)->opline->op2.var, EG(current_execute_data));
+               }
+               if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+                       if (type != BP_VAR_UNSET) {
+                               goto convert_to_array;
+                       } else {
+                               /* for read-mode only */
+                               ZVAL_NULL(result);
+                       }
+               } else if (EXPECTED(Z_ISERROR_P(container))) {
                        ZVAL_ERROR(result);
+               } else {
+                       if (type == BP_VAR_UNSET) {
+                               zend_error(E_WARNING, "Cannot unset offset in a non-array variable");
+                               ZVAL_NULL(result);
+                       } else {
+                               zend_error(E_WARNING, "Cannot use a scalar value as an array");
+                               ZVAL_ERROR(result);
+                       }
                }
        }
 }
index 0e3c3cbeb097383825e8af7bb5e1a5a8ef37dc63..664c19e5ed0fb841f2777cbd222278d1497828d7 100644 (file)
@@ -770,7 +770,7 @@ ZEND_VM_HELPER(zend_binary_assign_op_dim_helper, VAR|UNUSED|CV, CONST|TMPVAR|UNU
        zval *value, *container, *dim;
 
        SAVE_OPLINE();
-       container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW);
+       container = GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
        if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
                FREE_UNFETCHED_OP((opline+1)->op1_type, (opline+1)->op1.var);
@@ -778,7 +778,7 @@ ZEND_VM_HELPER(zend_binary_assign_op_dim_helper, VAR|UNUSED|CV, CONST|TMPVAR|UNU
                HANDLE_EXCEPTION();
        }
 
-       dim = GET_OP2_ZVAL_PTR(BP_VAR_R);
+       dim = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
 
        do {
                if (OP1_TYPE == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
@@ -786,6 +786,9 @@ ZEND_VM_HELPER(zend_binary_assign_op_dim_helper, VAR|UNUSED|CV, CONST|TMPVAR|UNU
                                ZVAL_DEREF(container);
                        }
                        if (OP1_TYPE == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -1706,7 +1709,7 @@ ZEND_VM_HANDLER(84, ZEND_FETCH_DIM_W, VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV)
        SAVE_OPLINE();
        container = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
 
-       zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE);
+       zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE);
        FREE_OP2();
        if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
                EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@@ -1722,9 +1725,9 @@ ZEND_VM_HANDLER(87, ZEND_FETCH_DIM_RW, VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV)
        zval *container;
 
        SAVE_OPLINE();
-       container = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW);
+       container = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
 
-       zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE);
+       zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE);
        FREE_OP2();
        if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
                EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@@ -1763,7 +1766,7 @@ ZEND_VM_HANDLER(93, ZEND_FETCH_DIM_FUNC_ARG, CONST|TMP|VAR|CV, CONST|TMPVAR|UNUS
                        HANDLE_EXCEPTION();
         }
                container = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
-               zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE);
+               zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE);
                if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
                        EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
                }
@@ -1791,9 +1794,9 @@ ZEND_VM_HANDLER(96, ZEND_FETCH_DIM_UNSET, VAR|CV, CONST|TMPVAR|CV)
        zval *container;
 
        SAVE_OPLINE();
-       container = GET_OP1_ZVAL_PTR_PTR(BP_VAR_UNSET);
+       container = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_UNSET);
 
-       zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE);
+       zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE);
        FREE_OP2();
        if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
                EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@@ -5634,7 +5637,7 @@ ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
        zend_string *key;
 
        SAVE_OPLINE();
-       container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET);
+       container = GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF(BP_VAR_UNSET);
        if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
                FREE_UNFETCHED_OP2();
@@ -5699,6 +5702,9 @@ ZEND_VM_C_LABEL(num_index_dim):
                                ZEND_VM_C_GOTO(unset_dim_array);
                        }
                }
+               if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
+                       container = GET_OP1_UNDEF_CV(container, BP_VAR_R);
+               }
                if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                        offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
                }
@@ -6549,7 +6555,7 @@ ZEND_VM_HANDLER(115, ZEND_ISSET_ISEMPTY_DIM_OBJ, CONST|TMPVAR|UNUSED|THIS|CV, CO
        zval *offset;
 
        SAVE_OPLINE();
-       container = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_IS);
+       container = GET_OP1_OBJ_ZVAL_PTR_UNDEF(BP_VAR_IS);
 
        if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
index a6ebb3a578237857d5e080c4db45dbdb955efa12..c2daf4d0cdf500b9a1827b0a5a547d63df4497cc 100644 (file)
@@ -8852,7 +8852,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CONST_
                        HANDLE_EXCEPTION();
         }
                container = NULL;
-               zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV);
+               zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV);
                if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1)) {
                        EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
                }
@@ -14323,7 +14323,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_TMP_CV
                        HANDLE_EXCEPTION();
         }
                container = NULL;
-               zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV);
+               zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV);
                if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) {
                        EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
                }
@@ -17049,6 +17049,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -19383,6 +19386,9 @@ num_index_dim:
                                goto unset_dim_array;
                        }
                }
+               if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
+                       container = GET_OP1_UNDEF_CV(container, BP_VAR_R);
+               }
                if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                        offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
                }
@@ -20111,6 +20117,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -21487,7 +21496,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                HANDLE_EXCEPTION();
        }
 
-       dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
+       dim = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
 
        do {
                if (IS_VAR == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
@@ -21495,6 +21504,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -21957,7 +21969,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_CV_HANDLE
        SAVE_OPLINE();
        container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1);
 
-       zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV);
+       zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV);
 
        if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) {
                EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@@ -21975,7 +21987,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_CV_HANDL
        SAVE_OPLINE();
        container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1);
 
-       zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV);
+       zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV);
 
        if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) {
                EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@@ -22000,7 +22012,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_CV
                        HANDLE_EXCEPTION();
         }
                container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1);
-               zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV);
+               zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV);
                if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) {
                        EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
                }
@@ -22030,7 +22042,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_CV_HA
        SAVE_OPLINE();
        container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1);
 
-       zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV);
+       zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV);
 
        if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) {
                EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@@ -23802,6 +23814,9 @@ num_index_dim:
                                goto unset_dim_array;
                        }
                }
+               if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
+                       container = GET_OP1_UNDEF_CV(container, BP_VAR_R);
+               }
                if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                        offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
                }
@@ -24081,6 +24096,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -26282,6 +26300,9 @@ num_index_dim:
                                goto unset_dim_array;
                        }
                }
+               if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
+                       container = GET_OP1_UNDEF_CV(container, BP_VAR_R);
+               }
                if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                        offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
                }
@@ -26595,6 +26616,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -28505,6 +28529,9 @@ num_index_dim:
                                goto unset_dim_array;
                        }
                }
+               if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
+                       container = GET_OP1_UNDEF_CV(container, BP_VAR_R);
+               }
                if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                        offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
                }
@@ -29176,6 +29203,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -29906,7 +29936,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                HANDLE_EXCEPTION();
        }
 
-       dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
+       dim = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
 
        do {
                if (IS_UNUSED == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
@@ -29914,6 +29944,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -31698,6 +31731,9 @@ num_index_dim:
                                goto unset_dim_array;
                        }
                }
+               if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
+                       container = GET_OP1_UNDEF_CV(container, BP_VAR_R);
+               }
                if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                        offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
                }
@@ -32162,6 +32198,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -33952,6 +33991,9 @@ num_index_dim:
                                goto unset_dim_array;
                        }
                }
+               if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
+                       container = GET_OP1_UNDEF_CV(container, BP_VAR_R);
+               }
                if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                        offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
                }
@@ -36708,7 +36750,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
        zval *value, *container, *dim;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_RW(execute_data, opline->op1.var);
        if (IS_CV == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
                FREE_UNFETCHED_OP((opline+1)->op1_type, (opline+1)->op1.var);
@@ -36724,6 +36766,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -37355,7 +37400,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_CONST_HAN
        zval *container;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_RW(execute_data, opline->op1.var);
 
        zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, EX_CONSTANT(opline->op2), IS_CONST);
 
@@ -37424,7 +37469,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_CONST_
        zval *container;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_UNSET(execute_data, opline->op1.var);
 
        zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, EX_CONSTANT(opline->op2), IS_CONST);
 
@@ -39326,7 +39371,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLE
        zend_string *key;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_UNSET(execute_data, opline->op1.var);
        if (IS_CV == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
 
@@ -39391,6 +39436,9 @@ num_index_dim:
                                goto unset_dim_array;
                        }
                }
+               if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
+                       container = GET_OP1_UNDEF_CV(container, BP_VAR_R);
+               }
                if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                        offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
                }
@@ -39540,7 +39588,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_
        zval *offset;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var);
 
        if (IS_CV == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
@@ -40892,7 +40940,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
        zval *value, *container, *dim;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_RW(execute_data, opline->op1.var);
        if (IS_CV == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
                FREE_UNFETCHED_OP((opline+1)->op1_type, (opline+1)->op1.var);
@@ -40908,6 +40956,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -41467,7 +41518,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_UNUSED_HA
        zval *container;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_RW(execute_data, opline->op1.var);
 
        zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, NULL, IS_UNUSED);
 
@@ -43266,7 +43317,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
        zval *value, *container, *dim;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_RW(execute_data, opline->op1.var);
        if (IS_CV == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
                FREE_UNFETCHED_OP((opline+1)->op1_type, (opline+1)->op1.var);
@@ -43274,7 +43325,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                HANDLE_EXCEPTION();
        }
 
-       dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
+       dim = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
 
        do {
                if (IS_CV == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
@@ -43282,6 +43333,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -43758,7 +43812,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_CV_CV_HANDLER
        SAVE_OPLINE();
        container = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->op1.var);
 
-       zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV);
+       zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV);
 
        if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) {
                EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@@ -43774,9 +43828,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_CV_HANDLE
        zval *container;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_RW(execute_data, opline->op1.var);
 
-       zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV);
+       zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV);
 
        if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) {
                EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@@ -43815,7 +43869,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_CV_
                        HANDLE_EXCEPTION();
         }
                container = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->op1.var);
-               zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV);
+               zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV);
                if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) {
                        EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
                }
@@ -43843,9 +43897,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_CV_HAN
        zval *container;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_UNSET(execute_data, opline->op1.var);
 
-       zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV);
+       zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV);
 
        if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) {
                EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
@@ -45741,7 +45795,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(Z
        zend_string *key;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_UNSET(execute_data, opline->op1.var);
        if (IS_CV == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
 
@@ -45806,6 +45860,9 @@ num_index_dim:
                                goto unset_dim_array;
                        }
                }
+               if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
+                       container = GET_OP1_UNDEF_CV(container, BP_VAR_R);
+               }
                if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                        offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
                }
@@ -45872,7 +45929,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_
        zval *offset;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var);
 
        if (IS_CV == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
@@ -46855,7 +46912,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
        zval *value, *container, *dim;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_RW(execute_data, opline->op1.var);
        if (IS_CV == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
                FREE_UNFETCHED_OP((opline+1)->op1_type, (opline+1)->op1.var);
@@ -46871,6 +46928,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_dim_helper_SP
                                ZVAL_DEREF(container);
                        }
                        if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+                               if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
+                                       dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
+                               }
                                value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
                                zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
                                break;
@@ -47367,7 +47427,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_TMPVAR_HA
        zval *container;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_RW(execute_data, opline->op1.var);
 
        zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2), (IS_TMP_VAR|IS_VAR));
        zval_ptr_dtor_nogc(free_op2);
@@ -47436,7 +47496,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_TMPVAR
        zval *container;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_UNSET(execute_data, opline->op1.var);
 
        zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2), (IS_TMP_VAR|IS_VAR));
        zval_ptr_dtor_nogc(free_op2);
@@ -49227,7 +49287,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMPVAR_HANDL
        zend_string *key;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef_BP_VAR_UNSET(execute_data, opline->op1.var);
        if (IS_CV == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");
                zval_ptr_dtor_nogc(EX_VAR(opline->op2.var));
@@ -49292,6 +49352,9 @@ num_index_dim:
                                goto unset_dim_array;
                        }
                }
+               if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
+                       container = GET_OP1_UNDEF_CV(container, BP_VAR_R);
+               }
                if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                        offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
                }
@@ -49360,7 +49423,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_
        zval *offset;
 
        SAVE_OPLINE();
-       container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var);
+       container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var);
 
        if (IS_CV == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
                zend_throw_error(NULL, "Using $this when not in object context");