YJIT: Move help descriptions to options.rs
This commit is contained in:
parent
49d27435d0
commit
01c462ce6a
15
ruby.c
15
ruby.c
@ -391,18 +391,6 @@ usage(const char *name, int help, int highlight, int columns)
|
|||||||
M("experimental", "", "experimental features"),
|
M("experimental", "", "experimental features"),
|
||||||
M("performance", "", "performance issues"),
|
M("performance", "", "performance issues"),
|
||||||
};
|
};
|
||||||
#if USE_YJIT
|
|
||||||
static const struct ruby_opt_message yjit_options[] = {
|
|
||||||
M("--yjit-stats", "", "Enable collecting YJIT statistics"),
|
|
||||||
M("--yjit-trace-exits", "", "Record Ruby source location when exiting from generated code"),
|
|
||||||
M("--yjit-trace-exits-sample-rate", "", "Trace exit locations only every Nth occurrence"),
|
|
||||||
M("--yjit-exec-mem-size=num", "", "Size of executable memory block in MiB (default: 128)"),
|
|
||||||
M("--yjit-call-threshold=num", "", "Number of calls to trigger JIT (default: 30)"),
|
|
||||||
M("--yjit-cold-threshold=num", "", "Global call after which ISEQs not compiled (default: 200K)"),
|
|
||||||
M("--yjit-max-versions=num", "", "Maximum number of versions per basic block (default: 4)"),
|
|
||||||
M("--yjit-greedy-versioning", "", "Greedy versioning mode (default: disabled)"),
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
#if USE_RJIT
|
#if USE_RJIT
|
||||||
extern const struct ruby_opt_message rb_rjit_option_messages[];
|
extern const struct ruby_opt_message rb_rjit_option_messages[];
|
||||||
#endif
|
#endif
|
||||||
@ -434,8 +422,7 @@ usage(const char *name, int help, int highlight, int columns)
|
|||||||
SHOW(warn_categories[i]);
|
SHOW(warn_categories[i]);
|
||||||
#if USE_YJIT
|
#if USE_YJIT
|
||||||
printf("%s""YJIT options:%s\n", sb, se);
|
printf("%s""YJIT options:%s\n", sb, se);
|
||||||
for (i = 0; i < numberof(yjit_options); ++i)
|
rb_yjit_print_options(help, highlight, w, columns);
|
||||||
SHOW(yjit_options[i]);
|
|
||||||
#endif
|
#endif
|
||||||
#if USE_RJIT
|
#if USE_RJIT
|
||||||
printf("%s""RJIT options (experimental):%s\n", sb, se);
|
printf("%s""RJIT options (experimental):%s\n", sb, se);
|
||||||
|
1
yjit.h
1
yjit.h
@ -43,6 +43,7 @@ void rb_yjit_iseq_free(void *payload);
|
|||||||
void rb_yjit_before_ractor_spawn(void);
|
void rb_yjit_before_ractor_spawn(void);
|
||||||
void rb_yjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx);
|
void rb_yjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx);
|
||||||
void rb_yjit_tracing_invalidate_all(void);
|
void rb_yjit_tracing_invalidate_all(void);
|
||||||
|
void rb_yjit_print_options(int help, int highlight, unsigned int w, int columns);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// !USE_YJIT
|
// !USE_YJIT
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use std::ffi::CStr;
|
use std::{ffi::{CStr, CString}, ptr::null};
|
||||||
use crate::backend::current::TEMP_REGS;
|
use crate::backend::current::TEMP_REGS;
|
||||||
|
use std::os::raw::{c_char, c_int, c_uint};
|
||||||
|
|
||||||
// Command-line options
|
// Command-line options
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
@ -79,6 +80,17 @@ pub static mut OPTIONS: Options = Options {
|
|||||||
dump_iseq_disasm: None,
|
dump_iseq_disasm: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static YJIT_OPTIONS: [(&str, &str); 8] = [
|
||||||
|
("--yjit-stats", "Enable collecting YJIT statistics"),
|
||||||
|
("--yjit-trace-exits", "Record Ruby source location when exiting from generated code"),
|
||||||
|
("--yjit-trace-exits-sample-rate", "Trace exit locations only every Nth occurrence"),
|
||||||
|
("--yjit-exec-mem-size=num", "Size of executable memory block in MiB (default: 128)"),
|
||||||
|
("--yjit-call-threshold=num", "Number of calls to trigger JIT (default: 30)"),
|
||||||
|
("--yjit-cold-threshold=num", "Global call after which ISEQs not compiled (default: 200K)"),
|
||||||
|
("--yjit-max-versions=num", "Maximum number of versions per basic block (default: 4)"),
|
||||||
|
("--yjit-greedy-versioning", "Greedy versioning mode (default: disabled)"),
|
||||||
|
];
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub enum DumpDisasm {
|
pub enum DumpDisasm {
|
||||||
// Dump to stdout
|
// Dump to stdout
|
||||||
@ -231,3 +243,17 @@ pub fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> {
|
|||||||
// Option successfully parsed
|
// Option successfully parsed
|
||||||
return Some(());
|
return Some(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Print YJIT options for `ruby --help`.
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn rb_yjit_print_options(help: c_int, highlight: c_int, w: c_uint, columns: c_int) {
|
||||||
|
for &(name, description) in YJIT_OPTIONS.iter() {
|
||||||
|
extern "C" {
|
||||||
|
fn ruby_show_usage_line(name: *const c_char, secondary: *const c_char, description: *const c_char,
|
||||||
|
help: c_int, highlight: c_int, w: c_uint, columns: c_int);
|
||||||
|
}
|
||||||
|
let name = CString::new(name).unwrap();
|
||||||
|
let description = CString::new(description).unwrap();
|
||||||
|
unsafe { ruby_show_usage_line(name.as_ptr(), null(), description.as_ptr(), help, highlight, w, columns) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user