Skip to content

Commit

Permalink
Avoid generation of rarely used specialized handler
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Feb 15, 2018
1 parent 23da83c commit 27d7671
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 97 deletions.
9 changes: 2 additions & 7 deletions Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -8926,19 +8926,14 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_SEND_VAR, (op1_info & (MAY_BE_UNDEF|MAY_BE_RE
ZEND_VM_NEXT_OPCODE();
}

ZEND_VM_HOT_SEND_TYPE_SPEC_HANDLER(ZEND_SEND_VAR_EX, (op1_info & (MAY_BE_UNDEF|MAY_BE_REF)) == 0, ZEND_SEND_VAR_EX_SIMPLE, CV|VAR, NUM, SPEC(QUICK_ARG))
ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_SEND_VAR_EX, op->op2.num <= MAX_ARG_FLAG_NUM && (op1_info & (MAY_BE_UNDEF|MAY_BE_REF)) == 0, ZEND_SEND_VAR_EX_SIMPLE, CV|VAR, NUM)
{
USE_OPLINE
zval *varptr, *arg;
zend_free_op free_op1;
uint32_t arg_num = opline->op2.num;

if (EXPECTED(arg_num <= MAX_ARG_FLAG_NUM)) {
if (QUICK_ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
ZEND_VM_C_GOTO(send_var_by_ref_simple);
}
} else if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
ZEND_VM_C_LABEL(send_var_by_ref_simple):
if (QUICK_ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_REF);
}

Expand Down
98 changes: 8 additions & 90 deletions Zend/zend_vm_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -22903,47 +22903,14 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SIMPLE_SP
ZEND_VM_NEXT_OPCODE();
}

static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SIMPLE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SIMPLE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
zval *varptr, *arg;
zend_free_op free_op1;
uint32_t arg_num = opline->op2.num;

if (EXPECTED(0)) {
if (QUICK_ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
goto send_var_by_ref_simple;
}
} else if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
send_var_by_ref_simple:
ZEND_VM_TAIL_CALL(ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
}

varptr = _get_zval_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC);
arg = ZEND_CALL_VAR(EX(call), opline->result.var);

if (IS_VAR == IS_CV) {
ZVAL_COPY(arg, varptr);
} else /* if (IS_VAR == IS_VAR) */ {
ZVAL_COPY_VALUE(arg, varptr);
}

ZEND_VM_NEXT_OPCODE();
}

static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SIMPLE_SPEC_VAR_QUICK_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
zval *varptr, *arg;
zend_free_op free_op1;
uint32_t arg_num = opline->op2.num;

if (EXPECTED(1)) {
if (QUICK_ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
goto send_var_by_ref_simple;
}
} else if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
send_var_by_ref_simple:
if (QUICK_ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
ZEND_VM_TAIL_CALL(ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
}

Expand Down Expand Up @@ -39888,47 +39855,14 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SIMPLE_SP
ZEND_VM_NEXT_OPCODE();
}

static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SIMPLE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SIMPLE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
zval *varptr, *arg;

uint32_t arg_num = opline->op2.num;

if (EXPECTED(0)) {
if (QUICK_ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
goto send_var_by_ref_simple;
}
} else if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
send_var_by_ref_simple:
ZEND_VM_TAIL_CALL(ZEND_SEND_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
}

varptr = _get_zval_ptr_cv_undef(opline->op1.var EXECUTE_DATA_CC);
arg = ZEND_CALL_VAR(EX(call), opline->result.var);

if (IS_CV == IS_CV) {
ZVAL_COPY(arg, varptr);
} else /* if (IS_CV == IS_VAR) */ {
ZVAL_COPY_VALUE(arg, varptr);
}

ZEND_VM_NEXT_OPCODE();
}

static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SIMPLE_SPEC_CV_QUICK_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
zval *varptr, *arg;

uint32_t arg_num = opline->op2.num;

if (EXPECTED(1)) {
if (QUICK_ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
goto send_var_by_ref_simple;
}
} else if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
send_var_by_ref_simple:
if (QUICK_ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
ZEND_VM_TAIL_CALL(ZEND_SEND_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
}

Expand Down Expand Up @@ -57363,14 +57297,9 @@ ZEND_API void execute_ex(zend_execute_data *ex)
(void*)&&ZEND_SEND_VAR_SIMPLE_SPEC_CV_LABEL,
(void*)&&ZEND_NULL_LABEL,
(void*)&&ZEND_NULL_LABEL,
(void*)&&ZEND_NULL_LABEL,
(void*)&&ZEND_NULL_LABEL,
(void*)&&ZEND_SEND_VAR_EX_SIMPLE_SPEC_VAR_LABEL,
(void*)&&ZEND_SEND_VAR_EX_SIMPLE_SPEC_VAR_QUICK_LABEL,
(void*)&&ZEND_NULL_LABEL,
(void*)&&ZEND_NULL_LABEL,
(void*)&&ZEND_SEND_VAR_EX_SIMPLE_SPEC_CV_LABEL,
(void*)&&ZEND_SEND_VAR_EX_SIMPLE_SPEC_CV_QUICK_LABEL,
(void*)&&ZEND_FE_FETCH_R_SIMPLE_SPEC_VAR_CV_RETVAL_UNUSED_LABEL,
(void*)&&ZEND_FE_FETCH_R_SIMPLE_SPEC_VAR_CV_RETVAL_USED_LABEL,
(void*)&&ZEND_NULL_LABEL
Expand Down Expand Up @@ -59015,9 +58944,6 @@ ZEND_API void execute_ex(zend_execute_data *ex)
HYBRID_CASE(ZEND_SEND_VAR_EX_SIMPLE_SPEC_VAR):
ZEND_SEND_VAR_EX_SIMPLE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
HYBRID_BREAK();
HYBRID_CASE(ZEND_SEND_VAR_EX_SIMPLE_SPEC_VAR_QUICK):
ZEND_SEND_VAR_EX_SIMPLE_SPEC_VAR_QUICK_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
HYBRID_BREAK();
HYBRID_CASE(ZEND_IS_IDENTICAL_SPEC_VAR_CONST):
ZEND_IS_IDENTICAL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
HYBRID_BREAK();
Expand Down Expand Up @@ -60206,9 +60132,6 @@ ZEND_API void execute_ex(zend_execute_data *ex)
HYBRID_CASE(ZEND_SEND_VAR_EX_SIMPLE_SPEC_CV):
ZEND_SEND_VAR_EX_SIMPLE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
HYBRID_BREAK();
HYBRID_CASE(ZEND_SEND_VAR_EX_SIMPLE_SPEC_CV_QUICK):
ZEND_SEND_VAR_EX_SIMPLE_SPEC_CV_QUICK_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
HYBRID_BREAK();
HYBRID_CASE(ZEND_ADD_SPEC_CV_CONST):
ZEND_ADD_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
HYBRID_BREAK();
Expand Down Expand Up @@ -65260,14 +65183,9 @@ void zend_init_opcodes_handlers(void)
ZEND_SEND_VAR_SIMPLE_SPEC_CV_HANDLER,
ZEND_NULL_HANDLER,
ZEND_NULL_HANDLER,
ZEND_NULL_HANDLER,
ZEND_NULL_HANDLER,
ZEND_SEND_VAR_EX_SIMPLE_SPEC_VAR_HANDLER,
ZEND_SEND_VAR_EX_SIMPLE_SPEC_VAR_QUICK_HANDLER,
ZEND_NULL_HANDLER,
ZEND_NULL_HANDLER,
ZEND_SEND_VAR_EX_SIMPLE_SPEC_CV_HANDLER,
ZEND_SEND_VAR_EX_SIMPLE_SPEC_CV_QUICK_HANDLER,
ZEND_FE_FETCH_R_SIMPLE_SPEC_VAR_CV_RETVAL_UNUSED_HANDLER,
ZEND_FE_FETCH_R_SIMPLE_SPEC_VAR_CV_RETVAL_USED_HANDLER,
ZEND_NULL_HANDLER
Expand Down Expand Up @@ -65472,7 +65390,7 @@ void zend_init_opcodes_handlers(void)
3019,
3020,
3021 | SPEC_RULE_OP1 | SPEC_RULE_OP2,
3942
3937
};
#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID)
zend_opcode_handler_funcs = labels;
Expand Down Expand Up @@ -65828,13 +65746,13 @@ ZEND_API void ZEND_FASTCALL zend_vm_set_opcode_handler_ex(zend_op* op, uint32_t
}
break;
case ZEND_SEND_VAR_EX:
if ((op1_info & (MAY_BE_UNDEF|MAY_BE_REF)) == 0) {
spec = 3930 | SPEC_RULE_OP1 | SPEC_RULE_QUICK_ARG;
if (op->op2.num <= MAX_ARG_FLAG_NUM && (op1_info & (MAY_BE_UNDEF|MAY_BE_REF)) == 0) {
spec = 3930 | SPEC_RULE_OP1;
}
break;
case ZEND_FE_FETCH_R:
if (op->op2_type == IS_CV && (op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) == MAY_BE_ARRAY) {
spec = 3940 | SPEC_RULE_RETVAL;
spec = 3935 | SPEC_RULE_RETVAL;
}
break;
case ZEND_FETCH_DIM_R:
Expand Down

0 comments on commit 27d7671

Please sign in to comment.