summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2023-03-16 10:41:12 -0700
committerTakashi Kokubun <[email protected]>2023-03-16 10:42:17 -0700
commit9947574b9cad74fbf04fa44d49647c591590c511 ()
tree0a36aa340dc9747c8ef277f96f9712cce8d69b26
parenta8e7fee80129b0ba360c2671582117c8e18a6464 (diff)
Refactor jit_func_t and jit_exec
I closed https://.com/ruby/ruby/pull/7543, but part of the diff seems useful regardless, so I extracted it.
-rw-r--r--insns.def28
-rw-r--r--vm.c4
-rw-r--r--vm_core.h6
-rw-r--r--vm_exec.h8
-rw-r--r--yjit.c5
5 files changed, 18 insertions, 33 deletions
@@ -813,12 +813,7 @@ send
{
VALUE bh = vm_caller_setup_arg_block(ec, GET_CFP(), cd->ci, blockiseq, false);
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_method);
-
- jit_func_t func;
- if (val == Qundef && (func = jit_compile(ec))) {
- val = func(ec, ec->cfp);
- if (ec->tag->state) THROW_EXCEPTION(val);
- }
if (val == Qundef) {
RESTORE_REGS();
@@ -838,12 +833,7 @@ opt_send_without_block
{
VALUE bh = VM_BLOCK_HANDLER_NONE;
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_method);
-
- jit_func_t func;
- if (val == Qundef && (func = jit_compile(ec))) {
- val = func(ec, ec->cfp);
- if (ec->tag->state) THROW_EXCEPTION(val);
- }
if (val == Qundef) {
RESTORE_REGS();
@@ -946,12 +936,7 @@ invokesuper
{
VALUE bh = vm_caller_setup_arg_block(ec, GET_CFP(), cd->ci, blockiseq, true);
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_super);
-
- jit_func_t func;
- if (val == Qundef && (func = jit_compile(ec))) {
- val = func(ec, ec->cfp);
- if (ec->tag->state) THROW_EXCEPTION(val);
- }
if (val == Qundef) {
RESTORE_REGS();
@@ -971,12 +956,7 @@ invokeblock
{
VALUE bh = VM_BLOCK_HANDLER_NONE;
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_invokeblock);
-
- jit_func_t func;
- if (val == Qundef && (func = jit_compile(ec))) {
- val = func(ec, ec->cfp);
- if (ec->tag->state) THROW_EXCEPTION(val);
- }
if (val == Qundef) {
RESTORE_REGS();
@@ -370,7 +370,7 @@ static VALUE vm_invoke_proc(rb_execution_context_t *ec, rb_proc_t *proc, VALUE s
#if USE_RJIT || USE_YJIT
// Try to compile the current ISeq in ec. Return 0 if not compiled.
-static inline jit_func_t
jit_compile(rb_execution_context_t *ec)
{
// Increment the ISEQ's call counter
@@ -405,7 +405,7 @@ jit_compile(rb_execution_context_t *ec)
static inline VALUE
jit_exec(rb_execution_context_t *ec)
{
- jit_func_t func = jit_compile(ec);
if (func) {
// Call the JIT code
return func(ec, ec->cfp);
@@ -373,6 +373,8 @@ enum rb_builtin_attr {
BUILTIN_ATTR_NO_GC = 0x02,
};
struct rb_iseq_constant_body {
enum rb_iseq_type type;
@@ -505,7 +507,7 @@ struct rb_iseq_constant_body {
#if USE_RJIT || USE_YJIT
// Function pointer for JIT code
- VALUE (*jit_func)(struct rb_execution_context_struct *, struct rb_control_frame_struct *);
// Number of total calls with jit_exec()
long unsigned total_calls;
#endif
@@ -521,8 +523,6 @@ struct rb_iseq_constant_body {
#endif
};
-typedef VALUE (*jit_func_t)(struct rb_execution_context_struct *, struct rb_control_frame_struct *);
-
/* T_IMEMO/iseq */
/* typedef rb_iseq_t is in method.h */
struct rb_iseq_struct {
@@ -174,6 +174,14 @@ default: \
#define THROW_EXCEPTION(exc) return (VALUE)(exc)
#endif
#define SCREG(r) (reg_##r)
#define VM_DEBUG_STACKOVERFLOW 0
@@ -1023,9 +1023,6 @@ rb_yjit_vm_unlock(unsigned int *recursive_lock_level, const char *file, int line
rb_vm_lock_leave(recursive_lock_level, file, line);
}
-// Pointer to a YJIT entry point (machine code generated by YJIT)
-typedef VALUE (*yjit_func_t)(rb_execution_context_t *, rb_control_frame_t *);
-
bool
rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec)
{
@@ -1038,7 +1035,7 @@ rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec)
uint8_t *code_ptr = rb_yjit_iseq_gen_entry_point(iseq, ec);
if (code_ptr) {
- iseq->body->jit_func = (yjit_func_t)code_ptr;
}
else {
iseq->body->jit_func = 0;