diff --git a/Cargo.toml b/Cargo.toml index 2324b945..81bbfdb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,9 @@ e2e = [] cli = [] plugins-only = [] builtin-core = [] +## JIT-direct only mode: disable legacy VM-arg fallback and plugin-builtins branches +## (keeps code compiling; VM-integrated JIT paths remain but are inert) +jit-direct-only = [] gui = ["dep:egui", "dep:eframe", "dep:egui_extras", "dep:image"] gui-examples = ["gui"] all-examples = ["gui-examples"] diff --git a/src/jit/policy/invoke.rs b/src/jit/policy/invoke.rs index 6cd3bf3c..f2277c46 100644 --- a/src/jit/policy/invoke.rs +++ b/src/jit/policy/invoke.rs @@ -11,7 +11,10 @@ pub enum InvokeDecision { } fn use_plugin_builtins() -> bool { - std::env::var("NYASH_USE_PLUGIN_BUILTINS").ok().as_deref() == Some("1") + #[cfg(feature = "jit-direct-only")] + { return false; } + #[cfg(not(feature = "jit-direct-only"))] + { return std::env::var("NYASH_USE_PLUGIN_BUILTINS").ok().as_deref() == Some("1"); } } /// Decide invocation policy for a known Box method. diff --git a/src/jit/rt.rs b/src/jit/rt.rs index dbc05b91..e39862a0 100644 --- a/src/jit/rt.rs +++ b/src/jit/rt.rs @@ -4,27 +4,21 @@ use crate::backend::vm::VMValue; use crate::jit::abi::JitValue; // Legacy TLS for hostcalls that still expect VMValue — keep for compatibility -thread_local! { - static LEGACY_VM_ARGS: RefCell> = RefCell::new(Vec::new()); -} +// Legacy VM args TLS — disabled in jit-direct-only (no-op/empty) +#[cfg(not(feature = "jit-direct-only"))] +thread_local! { static LEGACY_VM_ARGS: RefCell> = RefCell::new(Vec::new()); } -pub fn set_legacy_vm_args(args: &[VMValue]) { - LEGACY_VM_ARGS.with(|cell| { - let mut v = cell.borrow_mut(); - v.clear(); - v.extend_from_slice(args); - }); -} +#[cfg(not(feature = "jit-direct-only"))] +pub fn set_legacy_vm_args(args: &[VMValue]) { LEGACY_VM_ARGS.with(|cell| { let mut v = cell.borrow_mut(); v.clear(); v.extend_from_slice(args); }); } -pub fn with_legacy_vm_args(f: F) -> R -where - F: FnOnce(&[VMValue]) -> R, -{ - LEGACY_VM_ARGS.with(|cell| { - let v = cell.borrow(); - f(&v) - }) -} +#[cfg(feature = "jit-direct-only")] +pub fn set_legacy_vm_args(_args: &[VMValue]) { /* no-op in jit-direct-only */ } + +#[cfg(not(feature = "jit-direct-only"))] +pub fn with_legacy_vm_args(f: F) -> R where F: FnOnce(&[VMValue]) -> R { LEGACY_VM_ARGS.with(|cell| { let v = cell.borrow(); f(&v) }) } + +#[cfg(feature = "jit-direct-only")] +pub fn with_legacy_vm_args(f: F) -> R where F: FnOnce(&[VMValue]) -> R { f(&[]) } // New TLS for independent JIT ABI values thread_local! {