Skip to content

Commit

Permalink
RJIT: Prefix rjit_options with rb_
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Mar 19, 2023
1 parent 4e440d6 commit d189f8d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion internal/cmdlineopt.h
Expand Up @@ -24,7 +24,7 @@ typedef struct ruby_cmdline_options {
ruby_features_t warn;
unsigned int dump;
#if USE_RJIT
struct rjit_options rjit;
struct rb_rjit_options rjit;
#endif

int sflag, xflag;
Expand Down
6 changes: 3 additions & 3 deletions rjit.c
Expand Up @@ -63,7 +63,7 @@
// 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
// freed.
struct rjit_options rb_rjit_opts;
struct rb_rjit_options rb_rjit_opts;

// true if RJIT is enabled.
bool rb_rjit_enabled = false;
Expand Down Expand Up @@ -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))

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);
if (l == 0) {
Expand Down Expand Up @@ -384,7 +384,7 @@ rb_rjit_branch_stub_hit(VALUE branch_stub, int sp_offset, int target0_p)
}

void
rb_rjit_init(const struct rjit_options *opts)
rb_rjit_init(const struct rb_rjit_options *opts)
{
VM_ASSERT(rb_rjit_enabled);

Expand Down
6 changes: 3 additions & 3 deletions rjit.h
Expand Up @@ -22,7 +22,7 @@
#include "vm_core.h"

// 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
// information to ruby_show_version().
bool on;
Expand All @@ -41,7 +41,7 @@ struct rjit_options {
};

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;

#define rb_rjit_call_threshold() rb_rjit_opts.call_threshold
Expand All @@ -50,7 +50,7 @@ extern void rb_rjit_compile(const rb_iseq_t *iseq);
RUBY_SYMBOL_EXPORT_END

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_iseq_update_references(struct rb_iseq_constant_body *const body);
extern void rb_rjit_mark(void);
Expand Down
28 changes: 14 additions & 14 deletions rjit_c.rb
Expand Up @@ -251,7 +251,7 @@ def vm_ci_mid(ci)

def rjit_opts
addr = Primitive.cexpr! 'SIZET2NUM((VALUE)&rb_rjit_opts)'
rjit_options.new(addr)
rb_rjit_options.new(addr)
end

def rjit_cancel_all(reason)
Expand Down Expand Up @@ -1139,6 +1139,19 @@ def C.rb_proc_t
)
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
@rb_rjit_runtime_counters ||= CType::Struct.new(
"rb_rjit_runtime_counters", Primitive.cexpr!("SIZEOF(struct rb_rjit_runtime_counters)"),
Expand Down Expand Up @@ -1301,19 +1314,6 @@ def C.rb_thread_struct
)
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
@VALUE ||= CType::Immediate.find(Primitive.cexpr!("SIZEOF(VALUE)"), Primitive.cexpr!("SIGNED_TYPE_P(VALUE)"))
end
Expand Down
2 changes: 1 addition & 1 deletion ruby.c
Expand Up @@ -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)) {
#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));
rb_rjit_setup_options(s, &opt->rjit);
#else
Expand Down
2 changes: 1 addition & 1 deletion tool/rjit/bindgen.rb
Expand Up @@ -588,7 +588,7 @@ def push_target(target)
rb_thread_struct
rb_jit_func_t
rb_iseq_param_keyword
rjit_options
rb_rjit_options
],
# #ifdef-dependent immediate types, which need Primitive.cexpr! for type detection
dynamic_types: %w[
Expand Down

0 comments on commit d189f8d

Please sign in to comment.