Skip to content

Commit 1e250ae

Browse files
authored
Merge pull request #140 from seal-runtime/enable-jit-139
2 parents f186949 + 88f4fbe commit 1e250ae

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2024"
99
# If this breaks we'll pin to a commit and risk lagging behind Luau
1010
# but mlua's main branch is relatively stable and hasn't broken for us before nor for other projects.
1111
# we need to enable error-send so we can propogate errors across threads in std_thread.rs
12-
mluau = { git = "https://github.com/mluau/mluau.git", features = ["luau", "serialize", "error-send"] }
12+
mluau = { git = "https://github.com/mluau/mluau.git", features = ["luau", "luau-jit", "serialize", "error-send"] }
1313
regex = "1.11.1"
1414
# needed for seal setup (really useful!)
1515
include_dir = { version = "0.7.4" }

src/main.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ fn main() -> LuaResult<()> {
161161
}
162162
}
163163

164+
fn set_jit(luau: &Lua) -> bool {
165+
let should_jit = match std::env::var("SEAL_NO_JIT") {
166+
Ok(var) if var.to_lowercase() == "true" => false,
167+
Ok(var) if var.to_lowercase() == "false" => true,
168+
Ok(_) => true,
169+
Err(_) => true,
170+
};
171+
172+
if should_jit {
173+
luau.enable_jit(should_jit);
174+
}
175+
176+
should_jit
177+
}
178+
164179
fn resolve_file(requested_path: String, function_name: &'static str) -> LuauLoadResult {
165180
if requested_path.ends_with(".lua") {
166181
return wrap_err!("{}: wrong language! seal only runs .luau files", function_name);
@@ -174,6 +189,8 @@ fn resolve_file(requested_path: String, function_name: &'static str) -> LuauLoad
174189
return wrap_err!("{}: unable to enable Luau safeenv (sandbox mode) on chunk '{}' due to err: {}", function_name, chunk_name, err);
175190
};
176191

192+
set_jit(&luau);
193+
177194
globals::set_globals(&luau, chunk_name.clone())?;
178195

179196
let mut src = match fs::read_to_string(&chunk_name) {
@@ -366,7 +383,11 @@ fn seal_standalone(bytecode: Vec<u8>) -> LuauLoadResult {
366383
let luau = Lua::new();
367384
let entry_path = std::env::current_exe().unwrap_or_default();
368385
let entry_path = entry_path.to_string_lossy().into_owned();
386+
387+
set_jit(&luau);
388+
369389
globals::set_globals(&luau, &entry_path)?;
390+
370391
Ok(Some(LuauLoadInfo {
371392
luau,
372393
code: Chunk::Bytecode(bytecode),

0 commit comments

Comments
 (0)