Skip to content

Commit 416b3bb

Browse files
committed
Use better code for trace exits. Don't store CPU registers that can't be used by deoptimizer.
1 parent b61697e commit 416b3bb

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,24 +2313,24 @@ static int zend_jit_trace_exit_stub(dasm_State **Dst)
23132313
| stp d20, d21, [sp, #-16]!
23142314
| stp d18, d19, [sp, #-16]!
23152315
| stp d16, d17, [sp, #-16]!
2316-
| stp d14, d15, [sp, #-16]!
2317-
| stp d12, d13, [sp, #-16]!
2318-
| stp d10, d11, [sp, #-16]!
2319-
| stp d8, d9, [sp, #-16]!
2320-
| stp d6, d7, [sp, #-16]!
2316+
| //stp d14, d15, [sp, #-16]! // we don't use preserved registers yet
2317+
| //stp d12, d13, [sp, #-16]!
2318+
| //stp d10, d11, [sp, #-16]!
2319+
| //stp d8, d9, [sp, #-16]!
2320+
| stp d6, d7, [sp, #(-16*5)]!
23212321
| stp d4, d5, [sp, #-16]!
23222322
| stp d2, d3, [sp, #-16]!
23232323
| stp d0, d1, [sp, #-16]!
23242324
|
2325-
| str x30, [sp, #-16]! // x31 can be omitted
2326-
| stp x28, x29, [sp, #-16]!
2327-
| stp x26, x27, [sp, #-16]!
2328-
| stp x24, x25, [sp, #-16]!
2329-
| stp x22, x23, [sp, #-16]!
2330-
| stp x20, x21, [sp, #-16]!
2331-
| stp x18, x19, [sp, #-16]!
2332-
| stp x16, x17, [sp, #-16]!
2333-
| stp x14, x15, [sp, #-16]!
2325+
| //str x30, [sp, #-16]! // we don't use callee-saved registers yet (x31 can be omitted)
2326+
| stp x28, x29, [sp, #(-16*2)]! // we have to store RX (x28)
2327+
| //stp x26, x27, [sp, #-16]! // we don't use callee-saved registers yet
2328+
| //stp x24, x25, [sp, #-16]!
2329+
| //stp x22, x23, [sp, #-16]!
2330+
| //stp x20, x21, [sp, #-16]!
2331+
| //stp x18, x19, [sp, #-16]!
2332+
| //stp x16, x17, [sp, #-16]! // we don't need temporary registers
2333+
| stp x14, x15, [sp, #-(16*7)]!
23342334
| stp x12, x13, [sp, #-16]!
23352335
| stp x10, x11, [sp, #-16]!
23362336
| stp x8, x9, [sp, #-16]!
@@ -2339,15 +2339,15 @@ static int zend_jit_trace_exit_stub(dasm_State **Dst)
23392339
| stp x2, x3, [sp, #-16]!
23402340
| stp x0, x1, [sp, #-16]!
23412341
|
2342-
| ldr FCARG1w, [sp, #(32 * 16)] // exit_num = POP
2342+
| mov FCARG1w, TMP1w // exit_num
23432343
| mov FCARG2x, sp
23442344
|
23452345
| // EX(opline) = opline
23462346
| SAVE_IP
23472347
| // zend_jit_trace_exit(trace_num, exit_num)
23482348
| EXT_CALL zend_jit_trace_exit, REG0
23492349
|
2350-
| add sp, sp, #(33 * 16) // including the pre-allocated 16 bytes
2350+
| add sp, sp, #(32 * 16) // restore sp
23512351
|
23522352

23532353
| tst RETVALw, RETVALw
@@ -2442,25 +2442,26 @@ static int zend_jit_trace_escape_stub(dasm_State **Dst)
24422442
}
24432443

24442444
/* Keep 32 exit points in a single code block */
2445-
#define ZEND_JIT_EXIT_POINTS_SPACING 12 // mov + strb + b = bytes
2445+
#define ZEND_JIT_EXIT_POINTS_SPACING 4 // bl = bytes
24462446
#define ZEND_JIT_EXIT_POINTS_PER_GROUP 32 // number of continuous exit points
24472447

24482448
static int zend_jit_trace_exit_group_stub(dasm_State **Dst, uint32_t n)
24492449
{
24502450
uint32_t i;
24512451

2452-
for (i = 0; i < ZEND_JIT_EXIT_POINTS_PER_GROUP - 1; i++) {
2453-
| mov TMP1w, #i
2454-
| strb TMP1w, [sp, #-16]!
2455-
| b >1
2456-
}
2457-
| mov TMP1w, #i
2458-
| strb TMP1w, [sp, #-16]!
2452+
| bl >2
24592453
|1:
2460-
| ldrb TMP1w, [sp]
2461-
| ADD_SUB_32_WITH_CONST add, TMP1w, TMP1w, n, TMP2w
2462-
| str TMP1w, [sp]
2463-
| b ->trace_exit
2454+
for (i = 1; i < ZEND_JIT_EXIT_POINTS_PER_GROUP; i++) {
2455+
| bl >2
2456+
}
2457+
|2:
2458+
| adr TMP1, <1
2459+
| sub TMP1, lr, TMP1
2460+
| lsr TMP1, TMP1, #2
2461+
if (n) {
2462+
| ADD_SUB_32_WITH_CONST add, TMP1w, TMP1w, n, TMP2w
2463+
}
2464+
| b ->trace_exit // pass exit_num in TMP1w
24642465

24652466
return 1;
24662467
}

0 commit comments

Comments
 (0)