RJIT: Prefix rjit_options with rb_

This commit is contained in:
Takashi Kokubun 2023-03-18 21:27:07 -07:00
parent 4e440d6990
commit d189f8d870
6 changed files with 23 additions and 23 deletions

View File

@ -24,7 +24,7 @@ typedef struct ruby_cmdline_options {
ruby_features_t warn; ruby_features_t warn;
unsigned int dump; unsigned int dump;
#if USE_RJIT #if USE_RJIT
struct rjit_options rjit; struct rb_rjit_options rjit;
#endif #endif
int sflag, xflag; int sflag, xflag;

6
rjit.c
View File

@ -63,7 +63,7 @@
// A copy of RJIT portion of MRI options since RJIT initialization. We // A copy of RJIT portion of MRI options since RJIT initialization. We
// need them as RJIT threads still can work when the most MRI data were // need them as RJIT threads still can work when the most MRI data were
// freed. // freed.
struct rjit_options rb_rjit_opts; struct rb_rjit_options rb_rjit_opts;
// true if RJIT is enabled. // true if RJIT is enabled.
bool rb_rjit_enabled = false; bool rb_rjit_enabled = false;
@ -112,7 +112,7 @@ VALUE rb_rjit_line_samples = 0;
opt_match(s, l, name) && (*(s) ? 1 : (rb_raise(rb_eRuntimeError, "--rjit-" name " needs an argument"), 0)) opt_match(s, l, name) && (*(s) ? 1 : (rb_raise(rb_eRuntimeError, "--rjit-" name " needs an argument"), 0))
void void
rb_rjit_setup_options(const char *s, struct rjit_options *rjit_opt) rb_rjit_setup_options(const char *s, struct rb_rjit_options *rjit_opt)
{ {
const size_t l = strlen(s); const size_t l = strlen(s);
if (l == 0) { if (l == 0) {
@ -384,7 +384,7 @@ rb_rjit_branch_stub_hit(VALUE branch_stub, int sp_offset, int target0_p)
} }
void void
rb_rjit_init(const struct rjit_options *opts) rb_rjit_init(const struct rb_rjit_options *opts)
{ {
VM_ASSERT(rb_rjit_enabled); VM_ASSERT(rb_rjit_enabled);

6
rjit.h
View File

@ -22,7 +22,7 @@
#include "vm_core.h" #include "vm_core.h"
// RJIT options which can be defined on the MRI command line. // RJIT options which can be defined on the MRI command line.
struct rjit_options { struct rb_rjit_options {
// Converted from "rjit" feature flag to tell the enablement // Converted from "rjit" feature flag to tell the enablement
// information to ruby_show_version(). // information to ruby_show_version().
bool on; bool on;
@ -41,7 +41,7 @@ struct rjit_options {
}; };
RUBY_SYMBOL_EXPORT_BEGIN RUBY_SYMBOL_EXPORT_BEGIN
RUBY_EXTERN struct rjit_options rb_rjit_opts; RUBY_EXTERN struct rb_rjit_options rb_rjit_opts;
RUBY_EXTERN bool rb_rjit_call_p; RUBY_EXTERN bool rb_rjit_call_p;
#define rb_rjit_call_threshold() rb_rjit_opts.call_threshold #define rb_rjit_call_threshold() rb_rjit_opts.call_threshold
@ -50,7 +50,7 @@ extern void rb_rjit_compile(const rb_iseq_t *iseq);
RUBY_SYMBOL_EXPORT_END RUBY_SYMBOL_EXPORT_END
extern void rb_rjit_cancel_all(const char *reason); extern void rb_rjit_cancel_all(const char *reason);
extern void rb_rjit_init(const struct rjit_options *opts); extern void rb_rjit_init(const struct rb_rjit_options *opts);
extern void rb_rjit_free_iseq(const rb_iseq_t *iseq); extern void rb_rjit_free_iseq(const rb_iseq_t *iseq);
extern void rb_rjit_iseq_update_references(struct rb_iseq_constant_body *const body); extern void rb_rjit_iseq_update_references(struct rb_iseq_constant_body *const body);
extern void rb_rjit_mark(void); extern void rb_rjit_mark(void);

View File

@ -251,7 +251,7 @@ module RubyVM::RJIT # :nodoc: all
def rjit_opts def rjit_opts
addr = Primitive.cexpr! 'SIZET2NUM((VALUE)&rb_rjit_opts)' addr = Primitive.cexpr! 'SIZET2NUM((VALUE)&rb_rjit_opts)'
rjit_options.new(addr) rb_rjit_options.new(addr)
end end
def rjit_cancel_all(reason) def rjit_cancel_all(reason)
@ -1139,6 +1139,19 @@ module RubyVM::RJIT # :nodoc: all
) )
end end
def C.rb_rjit_options
@rb_rjit_options ||= CType::Struct.new(
"rb_rjit_options", Primitive.cexpr!("SIZEOF(struct rb_rjit_options)"),
on: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), on)")],
call_threshold: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), call_threshold)")],
exec_mem_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), exec_mem_size)")],
stats: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), stats)")],
trace_exits: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), trace_exits)")],
dump_disasm: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), dump_disasm)")],
pause: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_options *)NULL)), pause)")],
)
end
def C.rb_rjit_runtime_counters def C.rb_rjit_runtime_counters
@rb_rjit_runtime_counters ||= CType::Struct.new( @rb_rjit_runtime_counters ||= CType::Struct.new(
"rb_rjit_runtime_counters", Primitive.cexpr!("SIZEOF(struct rb_rjit_runtime_counters)"), "rb_rjit_runtime_counters", Primitive.cexpr!("SIZEOF(struct rb_rjit_runtime_counters)"),
@ -1301,19 +1314,6 @@ module RubyVM::RJIT # :nodoc: all
) )
end end
def C.rjit_options
@rjit_options ||= CType::Struct.new(
"rjit_options", Primitive.cexpr!("SIZEOF(struct rjit_options)"),
on: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), on)")],
call_threshold: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), call_threshold)")],
exec_mem_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), exec_mem_size)")],
stats: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), stats)")],
trace_exits: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), trace_exits)")],
dump_disasm: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), dump_disasm)")],
pause: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rjit_options *)NULL)), pause)")],
)
end
def C.VALUE def C.VALUE
@VALUE ||= CType::Immediate.find(Primitive.cexpr!("SIZEOF(VALUE)"), Primitive.cexpr!("SIGNED_TYPE_P(VALUE)")) @VALUE ||= CType::Immediate.find(Primitive.cexpr!("SIZEOF(VALUE)"), Primitive.cexpr!("SIGNED_TYPE_P(VALUE)"))
end end

2
ruby.c
View File

@ -1494,7 +1494,7 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
} }
else if (is_option_with_optarg("rjit", '-', true, false, false)) { else if (is_option_with_optarg("rjit", '-', true, false, false)) {
#if USE_RJIT #if USE_RJIT
extern void rb_rjit_setup_options(const char *s, struct rjit_options *rjit_opt); extern void rb_rjit_setup_options(const char *s, struct rb_rjit_options *rjit_opt);
FEATURE_SET(opt->features, FEATURE_BIT(rjit)); FEATURE_SET(opt->features, FEATURE_BIT(rjit));
rb_rjit_setup_options(s, &opt->rjit); rb_rjit_setup_options(s, &opt->rjit);
#else #else

View File

@ -588,7 +588,7 @@ generator = BindingGenerator.new(
rb_thread_struct rb_thread_struct
rb_jit_func_t rb_jit_func_t
rb_iseq_param_keyword rb_iseq_param_keyword
rjit_options rb_rjit_options
], ],
# #ifdef-dependent immediate types, which need Primitive.cexpr! for type detection # #ifdef-dependent immediate types, which need Primitive.cexpr! for type detection
dynamic_types: %w[ dynamic_types: %w[