Skip to content

Commit d1a0b93

Browse files
committed
JIT: Improve $this->property access in closures
1 parent eac6568 commit d1a0b93

File tree

5 files changed

+282
-94
lines changed

5 files changed

+282
-94
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2693,6 +2693,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
26932693
zend_jit_addr op1_addr, op1_def_addr, op2_addr, op2_def_addr, res_addr;
26942694
zend_class_entry *ce;
26952695
bool ce_is_instanceof;
2696+
bool on_this;
26962697

26972698
if (JIT_G(bisect_limit)) {
26982699
jit_bisect_pos++;
@@ -3153,11 +3154,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
31533154
}
31543155
ce = NULL;
31553156
ce_is_instanceof = 0;
3157+
on_this = 0;
31563158
if (opline->op1_type == IS_UNUSED) {
31573159
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
31583160
ce = op_array->scope;
31593161
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
31603162
op1_addr = 0;
3163+
on_this = 1;
31613164
} else {
31623165
op1_info = OP1_INFO();
31633166
if (!(op1_info & MAY_BE_OBJECT)) {
@@ -3174,10 +3177,18 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
31743177
}
31753178
}
31763179
}
3180+
if (ssa->ops && ssa->vars) {
3181+
zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes];
3182+
if (ssa_op->op1_use >= 0) {
3183+
if (ssa->vars[ssa_op->op1_use].definition >= 0) {
3184+
on_this = op_array->opcodes[ssa->vars[ssa_op->op1_use].definition].opcode == ZEND_FETCH_THIS;
3185+
}
3186+
}
3187+
}
31773188
}
31783189
if (!zend_jit_incdec_obj(&dasm_state, opline, op_array, ssa, ssa_op,
31793190
op1_info, op1_addr,
3180-
0, ce, ce_is_instanceof, 0, NULL, IS_UNKNOWN,
3191+
0, ce, ce_is_instanceof, on_this, 0, NULL, IS_UNKNOWN,
31813192
zend_may_throw(opline, ssa_op, op_array, ssa))) {
31823193
goto jit_failure;
31833194
}
@@ -3200,11 +3211,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
32003211
}
32013212
ce = NULL;
32023213
ce_is_instanceof = 0;
3214+
on_this = 0;
32033215
if (opline->op1_type == IS_UNUSED) {
32043216
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
32053217
ce = op_array->scope;
32063218
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
32073219
op1_addr = 0;
3220+
on_this = 1;
32083221
} else {
32093222
op1_info = OP1_INFO();
32103223
if (!(op1_info & MAY_BE_OBJECT)) {
@@ -3221,10 +3234,18 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
32213234
}
32223235
}
32233236
}
3237+
if (ssa->ops && ssa->vars) {
3238+
zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes];
3239+
if (ssa_op->op1_use >= 0) {
3240+
if (ssa->vars[ssa_op->op1_use].definition >= 0) {
3241+
on_this = op_array->opcodes[ssa->vars[ssa_op->op1_use].definition].opcode == ZEND_FETCH_THIS;
3242+
}
3243+
}
3244+
}
32243245
}
32253246
if (!zend_jit_assign_obj_op(&dasm_state, opline, op_array, ssa, ssa_op,
32263247
op1_info, op1_addr, OP1_DATA_INFO(), OP1_DATA_RANGE(),
3227-
0, ce, ce_is_instanceof, 0, NULL, IS_UNKNOWN,
3248+
0, ce, ce_is_instanceof, on_this, 0, NULL, IS_UNKNOWN,
32283249
zend_may_throw(opline, ssa_op, op_array, ssa))) {
32293250
goto jit_failure;
32303251
}
@@ -3240,11 +3261,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
32403261
}
32413262
ce = NULL;
32423263
ce_is_instanceof = 0;
3264+
on_this = 0;
32433265
if (opline->op1_type == IS_UNUSED) {
32443266
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
32453267
ce = op_array->scope;
32463268
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
32473269
op1_addr = 0;
3270+
on_this = 1;
32483271
} else {
32493272
op1_info = OP1_INFO();
32503273
if (!(op1_info & MAY_BE_OBJECT)) {
@@ -3261,10 +3284,18 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
32613284
}
32623285
}
32633286
}
3287+
if (ssa->ops && ssa->vars) {
3288+
zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes];
3289+
if (ssa_op->op1_use >= 0) {
3290+
if (ssa->vars[ssa_op->op1_use].definition >= 0) {
3291+
on_this = op_array->opcodes[ssa->vars[ssa_op->op1_use].definition].opcode == ZEND_FETCH_THIS;
3292+
}
3293+
}
3294+
}
32643295
}
32653296
if (!zend_jit_assign_obj(&dasm_state, opline, op_array, ssa, ssa_op,
32663297
op1_info, op1_addr, OP1_DATA_INFO(),
3267-
0, ce, ce_is_instanceof, 0, NULL, IS_UNKNOWN,
3298+
0, ce, ce_is_instanceof, on_this, 0, NULL, IS_UNKNOWN,
32683299
zend_may_throw(opline, ssa_op, op_array, ssa))) {
32693300
goto jit_failure;
32703301
}
@@ -3748,11 +3779,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
37483779
}
37493780
ce = NULL;
37503781
ce_is_instanceof = 0;
3782+
on_this = 0;
37513783
if (opline->op1_type == IS_UNUSED) {
37523784
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
37533785
op1_addr = 0;
37543786
ce = op_array->scope;
37553787
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
3788+
on_this = 1;
37563789
} else {
37573790
op1_info = OP1_INFO();
37583791
if (!(op1_info & MAY_BE_OBJECT)) {
@@ -3769,9 +3802,17 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
37693802
}
37703803
}
37713804
}
3805+
if (ssa->ops && ssa->vars) {
3806+
zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes];
3807+
if (ssa_op->op1_use >= 0) {
3808+
if (ssa->vars[ssa_op->op1_use].definition >= 0) {
3809+
on_this = op_array->opcodes[ssa->vars[ssa_op->op1_use].definition].opcode == ZEND_FETCH_THIS;
3810+
}
3811+
}
3812+
}
37723813
}
37733814
if (!zend_jit_fetch_obj(&dasm_state, opline, op_array, ssa, ssa_op,
3774-
op1_info, op1_addr, 0, ce, ce_is_instanceof, 0, 0, NULL,
3815+
op1_info, op1_addr, 0, ce, ce_is_instanceof, on_this, 0, 0, NULL,
37753816
IS_UNKNOWN,
37763817
zend_may_throw(opline, ssa_op, op_array, ssa))) {
37773818
goto jit_failure;
@@ -3897,11 +3938,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
38973938
}
38983939
ce = NULL;
38993940
ce_is_instanceof = 0;
3941+
on_this = 0;
39003942
if (opline->op1_type == IS_UNUSED) {
39013943
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
39023944
op1_addr = 0;
39033945
ce = op_array->scope;
39043946
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
3947+
on_this = 1;
39053948
} else {
39063949
op1_info = OP1_INFO();
39073950
if (!(op1_info & MAY_BE_OBJECT)) {
@@ -3918,9 +3961,17 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
39183961
}
39193962
}
39203963
}
3964+
if (ssa->ops && ssa->vars) {
3965+
zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes];
3966+
if (ssa_op->op1_use >= 0) {
3967+
if (ssa->vars[ssa_op->op1_use].definition >= 0) {
3968+
on_this = op_array->opcodes[ssa->vars[ssa_op->op1_use].definition].opcode == ZEND_FETCH_THIS;
3969+
}
3970+
}
3971+
}
39213972
}
39223973
if (!zend_jit_init_method_call(&dasm_state, opline, b, op_array, ssa, ssa_op, call_level,
3923-
op1_info, op1_addr, ce, ce_is_instanceof, 0, NULL,
3974+
op1_info, op1_addr, ce, ce_is_instanceof, on_this, 0, NULL,
39243975
NULL, 0, 0)) {
39253976
goto jit_failure;
39263977
}

0 commit comments

Comments
 (0)