3 /**********************************************************************
5 rjit.h - Interface to RJIT
7 Copyright (C) 2023 Takashi Kokubun <k0kubun@ruby-lang.org>.
9 **********************************************************************/
11 #include "ruby/internal/config.h" // defines USE_RJIT
12 #include "ruby/internal/stdbool.h"
20 // RJIT options which can be defined on the MRI command line.
21 struct rb_rjit_options
{
22 // Converted from "rjit" feature flag to tell the enablement
23 // information to ruby_show_version().
25 // Size of executable memory block in MiB
26 unsigned int exec_mem_size
;
27 // Number of calls to trigger JIT compilation
28 unsigned int call_threshold
;
29 // Collect RJIT statistics
31 // Do not start RJIT until RJIT.enable is called
33 // Allow TracePoint during JIT compilation
35 // Trace side exit locations
37 // Enable disasm of all JIT code
39 // Verify context objects
43 RUBY_SYMBOL_EXPORT_BEGIN
44 RUBY_EXTERN
struct rb_rjit_options rb_rjit_opts
;
45 RUBY_EXTERN
bool rb_rjit_call_p
;
47 #define rb_rjit_call_threshold() rb_rjit_opts.call_threshold
49 extern void rb_rjit_compile(const rb_iseq_t
*iseq
);
50 RUBY_SYMBOL_EXPORT_END
52 extern void rb_rjit_cancel_all(const char *reason
);
53 extern void rb_rjit_init(const struct rb_rjit_options
*opts
);
54 extern void rb_rjit_free_iseq(const rb_iseq_t
*iseq
);
55 extern void rb_rjit_iseq_update_references(struct rb_iseq_constant_body
*const body
);
56 extern void rb_rjit_mark(void);
57 extern void rb_rjit_iseq_mark(VALUE rjit_blocks
);
58 extern void rjit_notify_waitpid(int exit_code
);
60 extern void rb_rjit_bop_redefined(int redefined_flag
, enum ruby_basic_operators bop
);
61 extern void rb_rjit_cme_invalidate(rb_callable_method_entry_t
*cme
);
62 extern void rb_rjit_before_ractor_spawn(void);
63 extern void rb_rjit_constant_state_changed(ID id
);
64 extern void rb_rjit_constant_ic_update(const rb_iseq_t
*const iseq
, IC ic
, unsigned insn_idx
);
65 extern void rb_rjit_tracing_invalidate_all(rb_event_flag_t new_iseq_events
);
67 extern void rb_rjit_bop_redefined(int redefined_flag
, enum ruby_basic_operators bop
);
68 extern void rb_rjit_before_ractor_spawn(void);
69 extern void rb_rjit_tracing_invalidate_all(rb_event_flag_t new_iseq_events
);
70 extern void rb_rjit_collect_vm_usage_insn(int insn
);
72 extern bool rb_rjit_enabled
;
73 extern bool rb_rjit_stats_enabled
;
74 extern bool rb_rjit_trace_exits_enabled
;
78 static inline void rb_rjit_compile(const rb_iseq_t
*iseq
){}
80 static inline void rb_rjit_cancel_all(const char *reason
){}
81 static inline void rb_rjit_free_iseq(const rb_iseq_t
*iseq
){}
82 static inline void rb_rjit_mark(void){}
84 static inline void rb_rjit_bop_redefined(int redefined_flag
, enum ruby_basic_operators bop
) {}
85 static inline void rb_rjit_cme_invalidate(rb_callable_method_entry_t
*cme
) {}
86 static inline void rb_rjit_before_ractor_spawn(void) {}
87 static inline void rb_rjit_constant_state_changed(ID id
) {}
88 static inline void rb_rjit_constant_ic_update(const rb_iseq_t
*const iseq
, IC ic
, unsigned insn_idx
) {}
89 static inline void rb_rjit_tracing_invalidate_all(rb_event_flag_t new_iseq_events
) {}
91 #define rb_rjit_enabled false
92 #define rb_rjit_call_p false
93 #define rb_rjit_stats_enabled false
94 #define rb_rjit_trace_exits_enabled false
96 #define rb_rjit_call_threshold() UINT_MAX
98 static inline void rb_rjit_collect_vm_usage_insn(int insn
) {}
101 #endif // RUBY_RJIT_H