Skip to content

Commit

Permalink
Load constant value only if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Jul 2, 2020
1 parent 66a5f9f commit fe9b5ce
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -4804,8 +4804,10 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
| // if (EXPECTED(Z_TYPE_P(dim) == IS_LONG))
| IF_NOT_ZVAL_TYPE op2_addr, IS_LONG, >3
}
| // hval = Z_LVAL_P(dim);
| GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr
if (type == BP_VAR_W || type == BP_VAR_RW) {
| // hval = Z_LVAL_P(dim);
| GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr
}
if (op1_info & MAY_BE_ARRAY_KEY_LONG) {
if (Z_MODE(op2_addr) == IS_CONST_ZVAL) {
zend_long val = Z_LVAL_P(Z_ZV(op2_addr));
Expand Down Expand Up @@ -4843,6 +4845,10 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
}
}
} else {
if (type != BP_VAR_W && type != BP_VAR_RW) {
| // hval = Z_LVAL_P(dim);
| GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr
}
| // ZEND_HASH_INDEX_FIND(ht, hval, retval, num_undef);
| test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED
| jz >4 // HASH_FIND
Expand Down Expand Up @@ -4880,6 +4886,10 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
if (op1_info & MAY_BE_ARRAY_KEY_LONG) {
|4:
}
if (Z_MODE(op2_addr) == IS_CONST_ZVAL) {
| // hval = Z_LVAL_P(dim);
| GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr
}
| EXT_CALL _zend_hash_index_find, r0
| test r0, r0
| jz >9 // NOT_FOUND
Expand Down Expand Up @@ -4907,6 +4917,10 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
}
|4:
}
if (Z_MODE(op2_addr) == IS_CONST_ZVAL) {
| // hval = Z_LVAL_P(dim);
| GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr
}
| EXT_CALL _zend_hash_index_find, r0
| test r0, r0
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) {
Expand Down

0 comments on commit fe9b5ce

Please sign in to comment.