Truly independent web browser
LibJS: Never JIT compile executables with over 64 KiB of bytecode
Andreas Klingfcd146acf01f
diff --git a/Libraries/LibJS/Rust/src/jit/tier_up.rs b/Libraries/LibJS/Rust/src/jit/tier_up.rsindex f6e3c6725ac..a47309d21fe 100644--- a/Libraries/LibJS/Rust/src/jit/tier_up.rs+++ b/Libraries/LibJS/Rust/src/jit/tier_up.rs@@ -128,11 +128,19 @@ impl CompileTarget {}}+/// Executables with more bytecode than this are never compiled. The compile of one takes time and memory in proportion+/// to its size or worse (YouTube's top-level script code, 8.8 MiB of bytecode, took minutes and over 1 GiB), and code+/// that large rarely runs hot as a whole.+const MAX_COMPILED_BYTECODE_SIZE: usize = 64 * 1024;+/// What to compile the running frame's executable for, if it should be compiled at all.fn code_to_compile(vm: &Vm) -> Option<CompileTarget> {if vm.debugging_enabled() {return None;}+ if vm.current_executable().bytecode().len() > MAX_COMPILED_BYTECODE_SIZE {+ return None;+ }let frame = vm.running_execution_context_ref();let Some(function) = frame.function.get() else {// NB: The top-level code of a script or of a module runs once, but its loops can run long. Other code without