Skip to content

Commit 45441b3

Browse files
committed
Pass arguments to cdecl functions through preallocated stack slots
1 parent db7a773 commit 45441b3

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@
8787
|.define T3, [r4+0x18] // Used to store old value of IP (CALL VM only)
8888
|.define T2, [r4+0x14] // Used to store old value of FP (CALL VM only)
8989
|.define T1, [r4]
90+
|.define A4, [r4+0xC] // preallocated slots for arguments of "cdecl" functions (intersect with T1)
91+
|.define A3, [r4+0x8]
92+
|.define A2, [r4+0x4]
93+
|.define A1, [r4]
9094
|.endif
9195

9296
|.define HYBRID_SPAD, 16 // padding for stack alignment
@@ -1734,10 +1738,8 @@ static int zend_jit_interrupt_handler_stub(dasm_State **Dst)
17341738
| mov CARG1, FP
17351739
| EXT_CALL zend_interrupt_function, r0
17361740
|.else
1737-
| sub r4, 12
1738-
| push FP
1741+
| mov aword A1, FP
17391742
| EXT_CALL zend_interrupt_function, r0
1740-
| add r4, 16
17411743
|.endif
17421744
| //ZEND_VM_ENTER();
17431745
| //execute_data = EG(current_execute_data);
@@ -2143,15 +2145,13 @@ static int zend_jit_undefined_function_stub(dasm_State **Dst)
21432145
| add CARG3, offsetof(zend_string, val)
21442146
| EXT_CALL zend_throw_error, r0
21452147
|.else
2146-
| sub r4, 4
21472148
| mov r0, aword [r0 + offsetof(zend_op, op2.zv)]
21482149
| mov r0, aword [r0]
21492150
| add r0, offsetof(zend_string, val)
2150-
| push r0
2151-
| push "Call to undefined function %s()"
2152-
| push 0
2151+
| mov aword A3, r0
2152+
| mov aword A2, "Call to undefined function %s()"
2153+
| mov aword A1, 0
21532154
| EXT_CALL zend_throw_error, r0
2154-
| add r4, 16
21552155
|.endif
21562156
| jmp ->exception_handler
21572157
return 1;
@@ -12417,8 +12417,7 @@ static int zend_jit_recv_init(dasm_State **Dst, const zend_op *opline, const zen
1241712417
| sub r4, 8
1241812418
| mov r0, EX->func
1241912419
| push dword [r0 + offsetof(zend_op_array, scope)]
12420-
| LOAD_ZVAL_ADDR r0, res_addr
12421-
| push r0
12420+
| PUSH_ZVAL_ADDR res_addr, r0
1242212421
| EXT_CALL zval_update_constant_ex, r0
1242312422
| add r4, 16
1242412423
|.endif
@@ -13989,11 +13988,9 @@ static int zend_jit_echo(dasm_State **Dst, const zend_op *opline, uint32_t op1_i
1398913988
| LOAD_ADDR CARG2, len
1399013989
| EXT_CALL zend_write, r0
1399113990
|.else
13992-
| sub r4, 8
13993-
| push len
13994-
| push str
13991+
| mov aword A2, len
13992+
| mov aword A1, str
1399513993
| EXT_CALL zend_write, r0
13996-
| add r4, 16
1399713994
|.endif
1399813995
if (!zend_jit_check_exception(Dst)) {
1399913996
return 0;
@@ -14011,12 +14008,11 @@ static int zend_jit_echo(dasm_State **Dst, const zend_op *opline, uint32_t op1_i
1401114008
| mov CARG2, aword [r0 + offsetof(zend_string, len)]
1401214009
| EXT_CALL zend_write, r0
1401314010
|.else
14014-
| sub r4, 8
14015-
| push aword [r0 + offsetof(zend_string, len)]
1401614011
| add r0, offsetof(zend_string, val)
14017-
| push r0
14012+
| mov aword A1, r0
14013+
| mov r0, aword [r0 + (offsetof(zend_string, len)-offsetof(zend_string, val))]
14014+
| mov aword A2, r0
1401814015
| EXT_CALL zend_write, r0
14019-
| add r4, 16
1402014016
|.endif
1402114017
if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
1402214018
| ZVAL_PTR_DTOR op1_addr, op1_info, 0, 0, opline

0 commit comments

Comments
 (0)