summaryrefslogtreecommitdiff
path: root/yjit
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2024-11-04 08:14:28 -0800
committerGitHub <[email protected]>2024-11-04 11:14:28 -0500
commit478e0fc710b8fefaa3bdb7cb41dda8716e29927a (patch)
tree7e4dfe65ad53e2ae5483adb0276d00ebe58bb802 /yjit
parent51ac93011a8b279c1e2b93bbe6c8709392e82f57 (diff)
YJIT: Replace Array#each only when YJIT is enabled (#11955)
* YJIT: Replace Array#each only when YJIT is enabled * Add comments about BUILTIN_ATTR_C_TRACE * Make Ruby Array#each available with --yjit as well * Fix all paths that expect a C location * Use method_basic_definition_p to detect patches * Copy a comment about C_TRACE flag to compilers * Rephrase a comment about add_yjit_hook * Give METHOD_ENTRY_BASIC flag to Array#each * Add --yjit-c-builtin option * Allow inconsistent source_location in test-spec * Refactor a check of BUILTIN_ATTR_C_TRACE * Set METHOD_ENTRY_BASIC without touching vm->running
Notes
Notes: Merged-By: maximecb <[email protected]>
Diffstat (limited to 'yjit')
-rw-r--r--yjit/src/cruby_bindings.inc.rs1
-rw-r--r--yjit/src/options.rs20
2 files changed, 20 insertions, 1 deletions
diff --git a/yjit/src/cruby_bindings.inc.rs b/yjit/src/cruby_bindings.inc.rs
index 4eb44634a1..bb6ae68651 100644
--- a/yjit/src/cruby_bindings.inc.rs
+++ b/yjit/src/cruby_bindings.inc.rs
@@ -492,6 +492,7 @@ pub type rb_iseq_type = u32;
pub const BUILTIN_ATTR_LEAF: rb_builtin_attr = 1;
pub const BUILTIN_ATTR_SINGLE_NOARG_LEAF: rb_builtin_attr = 2;
pub const BUILTIN_ATTR_INLINE_BLOCK: rb_builtin_attr = 4;
+pub const BUILTIN_ATTR_C_TRACE: rb_builtin_attr = 8;
pub type rb_builtin_attr = u32;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
diff --git a/yjit/src/options.rs b/yjit/src/options.rs
index b993b5685b..51483bead1 100644
--- a/yjit/src/options.rs
+++ b/yjit/src/options.rs
@@ -1,5 +1,5 @@
use std::{ffi::{CStr, CString}, ptr::null, fs::File};
-use crate::{backend::current::TEMP_REGS, stats::Counter};
+use crate::{backend::current::TEMP_REGS, cruby::*, stats::Counter};
use std::os::raw::{c_char, c_int, c_uint};
// Call threshold for small deployments and command-line apps
@@ -46,6 +46,9 @@ pub struct Options {
// The number of registers allocated for stack temps
pub num_temp_regs: usize,
+ // Disable Ruby builtin methods defined by `with_yjit` hooks, e.g. Array#each in Ruby
+ pub c_builtin: bool,
+
// Capture stats
pub gen_stats: bool,
@@ -94,6 +97,7 @@ pub static mut OPTIONS: Options = Options {
no_type_prop: false,
max_versions: 4,
num_temp_regs: 5,
+ c_builtin: false,
gen_stats: false,
trace_exits: None,
print_stats: true,
@@ -270,6 +274,10 @@ pub fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> {
}
},
+ ("c-builtin", _) => unsafe {
+ OPTIONS.c_builtin = true;
+ },
+
("code-gc", _) => unsafe {
OPTIONS.code_gc = true;
},
@@ -413,3 +421,13 @@ pub extern "C" fn rb_yjit_show_usage(help: c_int, highlight: c_int, width: c_uin
unsafe { ruby_show_usage_line(name.as_ptr(), null(), description.as_ptr(), help, highlight, width, columns) }
}
}
+
+/// Return true if --yjit-c-builtin is given
+#[no_mangle]
+pub extern "C" fn rb_yjit_c_builtin_p(_ec: EcPtr, _self: VALUE) -> VALUE {
+ if get_option!(c_builtin) {
+ Qtrue
+ } else {
+ Qfalse
+ }
+}