Skip to content

Commit a4c3aee

Browse files
committed
Support for reference
1 parent a351da5 commit a4c3aee

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3114,7 +3114,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
31143114
if ((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_STRING) {
31153115
break;
31163116
}
3117-
if (!zend_jit_strlen(&dasm_state, opline, op1_info)) {
3117+
if (!zend_jit_strlen(&dasm_state, opline, op1_info, OP1_REG_ADDR())) {
31183118
goto jit_failure;
31193119
}
31203120
goto done;

ext/opcache/jit/zend_jit_trace.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4860,11 +4860,23 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
48604860
goto done;
48614861
case ZEND_STRLEN:
48624862
op1_info = OP1_INFO();
4863-
CHECK_OP1_TRACE_TYPE();
4864-
if ((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_STRING) {
4865-
break;
4863+
op1_addr = OP1_REG_ADDR();
4864+
if (orig_op1_type == (IS_TRACE_REFERENCE|IS_STRING)) {
4865+
if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op1_type, &op1_info, &op1_addr,
4866+
!ssa->var_info[ssa_op->op1_use].guarded_reference, 1)) {
4867+
goto jit_failure;
4868+
}
4869+
if (opline->op1_type == IS_CV
4870+
&& zend_jit_var_may_alias(op_array, op_array_ssa, EX_VAR_TO_NUM(opline->op1.var)) == NO_ALIAS) {
4871+
ssa->var_info[ssa_op->op1_use].guarded_reference = 1;
4872+
}
4873+
} else {
4874+
CHECK_OP1_TRACE_TYPE();
4875+
if ((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_STRING) {
4876+
break;
4877+
}
48664878
}
4867-
if (!zend_jit_strlen(&dasm_state, opline, op1_info)) {
4879+
if (!zend_jit_strlen(&dasm_state, opline, op1_info, op1_addr)) {
48684880
goto jit_failure;
48694881
}
48704882
goto done;

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13396,7 +13396,7 @@ static int zend_jit_echo(dasm_State **Dst, const zend_op *opline, uint32_t op1_i
1339613396
return 1;
1339713397
}
1339813398

13399-
static int zend_jit_strlen(dasm_State **Dst, const zend_op *opline, uint32_t op1_info)
13399+
static int zend_jit_strlen(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr)
1340013400
{
1340113401
zend_jit_addr res_addr = RES_ADDR();
1340213402

@@ -13411,17 +13411,13 @@ static int zend_jit_strlen(dasm_State **Dst, const zend_op *opline, uint32_t op1
1341113411
| SET_ZVAL_LVAL res_addr, len
1341213412
| SET_ZVAL_TYPE_INFO res_addr, IS_LONG
1341313413
} else {
13414-
zend_jit_addr op1_addr = OP1_ADDR();
13415-
1341613414
ZEND_ASSERT((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) == MAY_BE_STRING);
1341713415

1341813416
| GET_ZVAL_PTR r0, op1_addr
1341913417
| mov r0, aword [r0 + offsetof(zend_string, len)]
1342013418
| SET_ZVAL_LVAL res_addr, r0
1342113419
| SET_ZVAL_TYPE_INFO res_addr, IS_LONG
13422-
if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
13423-
| ZVAL_PTR_DTOR op1_addr, op1_info, 0, 0, opline
13424-
}
13420+
| FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline
1342513421
}
1342613422
return 1;
1342713423
}

0 commit comments

Comments
 (0)