-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] Pass opline as argument to opcode handlers in CALL VM #17952
base: master
Are you sure you want to change the base?
Changes from all commits
04bff56
1f12382
6ebf91b
a773fbe
5a63362
919e1a0
dc1a571
46de8b2
841f0ea
cb83679
f382249
fad6772
5ae328d
44f0a90
0da3e5f
a5b9f66
e00982e
42f60ba
64f27cc
91284db
93317c0
f4f9ec5
54cd812
ad3c920
f013aa1
d50c5d1
8637220
ced459a
23a1cb4
d31339f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,7 @@ static const void *zend_jit_func_trace_counter_handler = NULL; | |
static const void *zend_jit_ret_trace_counter_handler = NULL; | ||
static const void *zend_jit_loop_trace_counter_handler = NULL; | ||
|
||
static int ZEND_FASTCALL zend_runtime_jit(void); | ||
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_runtime_jit(ZEND_OPCODE_HANDLER_ARGS); | ||
|
||
static int zend_jit_trace_op_len(const zend_op *opline); | ||
static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op *opline); | ||
|
@@ -2871,7 +2871,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op | |
if (GCC_GLOBAL_REGS) { | ||
ir_TAILCALL(IR_VOID, ir_LOAD_A(jit_IP(jit))); | ||
} else { | ||
ir_RETURN(ir_CONST_I32(1)); /* ZEND_VM_ENTER */ | ||
zend_jit_vm_enter(jit, jit_IP(jit)); | ||
} | ||
ir_IF_TRUE(if_hook_enter); | ||
} | ||
|
@@ -3074,11 +3074,18 @@ static int zend_real_jit_func(zend_op_array *op_array, zend_script *script, cons | |
} | ||
|
||
/* Run-time JIT handler */ | ||
static int ZEND_FASTCALL zend_runtime_jit(void) | ||
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_runtime_jit(ZEND_OPCODE_HANDLER_ARGS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ops. It looks like the previous prototype was wrong. |
||
{ | ||
zend_execute_data *execute_data = EG(current_execute_data); | ||
#if GCC_GLOBAL_REGS | ||
zend_execute_data *execute_data; | ||
zend_op *opline; | ||
#else | ||
const zend_op *orig_opline = opline; | ||
#endif | ||
|
||
execute_data = EG(current_execute_data); | ||
zend_op_array *op_array = &EX(func)->op_array; | ||
zend_op *opline = op_array->opcodes; | ||
opline = op_array->opcodes; | ||
zend_jit_op_array_extension *jit_extension; | ||
bool do_bailout = 0; | ||
|
||
|
@@ -3097,7 +3104,7 @@ static int ZEND_FASTCALL zend_runtime_jit(void) | |
} | ||
} | ||
jit_extension = (zend_jit_op_array_extension*)ZEND_FUNC_INFO(op_array); | ||
opline->handler = jit_extension->orig_handler; | ||
((zend_op*)opline)->handler = jit_extension->orig_handler; | ||
|
||
/* perform real JIT for this function */ | ||
zend_real_jit_func(op_array, NULL, NULL, ZEND_JIT_ON_FIRST_EXEC); | ||
|
@@ -3116,7 +3123,11 @@ static int ZEND_FASTCALL zend_runtime_jit(void) | |
} | ||
|
||
/* JIT-ed code is going to be called by VM */ | ||
return 0; | ||
#if GCC_GLOBAL_REGS | ||
return; // ZEND_VM_CONTINUE | ||
#else | ||
return orig_opline; // ZEND_VM_CONTINUE | ||
#endif | ||
} | ||
|
||
void zend_jit_check_funcs(HashTable *function_table, bool is_method) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,12 @@ | |
#ifndef ZEND_JIT_INTERNAL_H | ||
#define ZEND_JIT_INTERNAL_H | ||
|
||
#include "Zend/zend_types.h" | ||
#include "Zend/zend_compile.h" | ||
#include "Zend/zend_constants.h" | ||
#include "Zend/Optimizer/zend_func_info.h" | ||
#include "Zend/Optimizer/zend_call_graph.h" | ||
|
||
/* Address Encoding */ | ||
typedef uintptr_t zend_jit_addr; | ||
|
||
|
@@ -183,17 +189,19 @@ extern const zend_op *zend_jit_halt_op; | |
# define ZEND_OPCODE_HANDLER_RET void | ||
# define ZEND_OPCODE_HANDLER_ARGS EXECUTE_DATA_D | ||
# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU | ||
# define ZEND_OPCODE_HANDLER_ARGS_DC | ||
# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC | ||
# define ZEND_OPCODE_HANDLER_ARGS_EX | ||
# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_EX | ||
# define ZEND_OPCODE_RETURN() return | ||
# define ZEND_OPCODE_TAIL_CALL(handler) do { \ | ||
handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \ | ||
return; \ | ||
} while(0) | ||
# define ZEND_OPCODE_TAIL_CALL_EX(handler, arg) do { \ | ||
handler(arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC); \ | ||
handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_EX arg); \ | ||
return; \ | ||
} while(0) | ||
# define ZEND_VM_ENTER_BIT 0 | ||
# define ZEND_VM_RETURN_VAL 0 | ||
#else | ||
# define EXECUTE_DATA_D zend_execute_data* execute_data | ||
# define EXECUTE_DATA_C execute_data | ||
|
@@ -203,27 +211,34 @@ extern const zend_op *zend_jit_halt_op; | |
# define OPLINE_C opline | ||
# define OPLINE_DC , OPLINE_D | ||
# define OPLINE_CC , OPLINE_C | ||
# define ZEND_OPCODE_HANDLER_RET int | ||
# define ZEND_OPCODE_HANDLER_ARGS EXECUTE_DATA_D | ||
# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU EXECUTE_DATA_C | ||
# define ZEND_OPCODE_HANDLER_ARGS_DC EXECUTE_DATA_DC | ||
# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC EXECUTE_DATA_CC | ||
# define ZEND_OPCODE_RETURN() return 0 | ||
# define ZEND_OPCODE_HANDLER_RET const zend_op * | ||
# define ZEND_OPCODE_HANDLER_ARGS EXECUTE_DATA_D OPLINE_DC | ||
# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU EXECUTE_DATA_C OPLINE_CC | ||
# define ZEND_OPCODE_HANDLER_ARGS_EX EXECUTE_DATA_D OPLINE_DC, | ||
# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_EX EXECUTE_DATA_C OPLINE_CC, | ||
# define ZEND_OPCODE_RETURN() return opline | ||
# define ZEND_OPCODE_TAIL_CALL(handler) do { \ | ||
return handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \ | ||
} while(0) | ||
# define ZEND_OPCODE_TAIL_CALL_EX(handler, arg) do { \ | ||
return handler(arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC); \ | ||
return handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_EX arg); \ | ||
} while(0) | ||
# ifdef ZEND_HIGH_HALF_KERNEL | ||
# define ZEND_VM_ENTER_BIT (1ULL<<(UINTPTR_WIDTH-1)) | ||
# define ZEND_VM_RETURN_VAL 0 | ||
# else | ||
# define ZEND_VM_ENTER_BIT 1ULL | ||
# define ZEND_VM_RETURN_VAL ZEND_VM_ENTER_BIT | ||
# endif | ||
Comment on lines
+226
to
+232
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we redifine |
||
#endif | ||
|
||
/* VM handlers */ | ||
typedef ZEND_OPCODE_HANDLER_RET (ZEND_FASTCALL *zend_vm_opcode_handler_t)(ZEND_OPCODE_HANDLER_ARGS); | ||
|
||
/* VM helpers */ | ||
ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_leave_nested_func_helper(uint32_t call_info EXECUTE_DATA_DC); | ||
ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_leave_top_func_helper(uint32_t call_info EXECUTE_DATA_DC); | ||
ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_leave_func_helper(EXECUTE_DATA_D); | ||
ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_leave_nested_func_helper(ZEND_OPCODE_HANDLER_ARGS_EX uint32_t call_info); | ||
ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_leave_top_func_helper(ZEND_OPCODE_HANDLER_ARGS_EX uint32_t call_info); | ||
ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_leave_func_helper(ZEND_OPCODE_HANDLER_ARGS); | ||
|
||
ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_profile_helper(ZEND_OPCODE_HANDLER_ARGS); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes
EX(opline) = opline
whenZEND_VM_IP_GLOBAL_REG
is defined.This may cause output of incorrect line number in error message.
May be I miss something?