Skip to content

Truly independent web browser

LibJS: Use fixed-size storage for compiled JIT site records

Shannon Booth245a9bfbe9a0
diff --git a/Libraries/LibJS/JIT/Rust/src/code.rs b/Libraries/LibJS/JIT/Rust/src/code.rs
index b32a4481fad..c34a88c5a8f 100644
--- a/Libraries/LibJS/JIT/Rust/src/code.rs
+++ b/Libraries/LibJS/JIT/Rust/src/code.rs
@@ -187,10 +187,10 @@ pub struct Site {
pub kind: SiteKind,
/// The frames there, innermost first: the frames of the inlined calls
/// the site is in, and the compiled function's frame.
- pub frames: Vec<FrameState>,
+ pub frames: Box<[FrameState]>,
/// The objects the compiled code never allocated, which the frames'
/// values refer to (as `ValueLocation::VirtualObject`).
- pub objects: Vec<VirtualObjectDescriptor>,
+ pub objects: Box<[VirtualObjectDescriptor]>,
/// For a `SiteKind::Call`: the room for the frames of the inlined calls
/// that the call leaves below its callee's frame (see `Op::CallDirect`).
pub inlined_frame_bytes: u32,
@@ -234,7 +234,7 @@ pub struct VirtualObjectDescriptor {
/// same at every site of the code: the runtime may have created the
/// object at another site of the same frame already, and then uses that.
pub allocation: u32,
- pub properties: Vec<ValueLocation>,
+ pub properties: Box<[ValueLocation]>,
}
/// Set in the return pc (`ExecutionContext::caller_return_pc`) of the frame of
@@ -271,12 +271,12 @@ pub struct FrameState {
pub mode: ResumeMode,
/// The value of each frame slot that differs from what the frame already
/// holds, in slot order.
- pub values: Vec<(u32, ValueLocation)>,
+ pub values: Box<[(u32, ValueLocation)]>,
/// The live slots whose value the frame already holds (see
/// `ir::FrameState::in_frame`), in slot order. Exits clear the registers
/// and locals listed in neither, except a `ResumeAfter` destination,
/// which exits never write either.
- pub in_frame: Vec<u32>,
+ pub in_frame: Box<[u32]>,
/// See `ir::FrameState::passed_argument_count`.
pub passed_argument_count: Option<u32>,
/// The argument slots that the legacy `arguments` of the frame's
diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/sites.rs b/Libraries/LibJS/JIT/Rust/src/codegen/sites.rs
index 66667bd35a3..9aca6c11dae 100644
--- a/Libraries/LibJS/JIT/Rust/src/codegen/sites.rs
+++ b/Libraries/LibJS/JIT/Rust/src/codegen/sites.rs
@@ -82,8 +82,8 @@ pub(crate) fn site(
executable: frame_state.executable,
pc: frame_state.pc,
mode: frame_state.mode,
- values,
- in_frame,
+ values: values.into_boxed_slice(),
+ in_frame: in_frame.into_boxed_slice(),
passed_argument_count: frame_state.passed_argument_count,
legacy_arguments: frame_state.legacy_arguments.clone(),
}
diff --git a/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs b/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs
index 8e9905f46b6..553378798af 100644
--- a/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs
+++ b/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs
@@ -554,19 +554,19 @@ fn exits_find_constants_registers_and_spilled_values() {
descriptor,
Site {
kind: SiteKind::Exit(ExitKind::NoFeedback),
- frames: vec![CodeFrameState {
+ frames: Box::new([CodeFrameState {
executable: 0,
pc: program.offsets[2],
mode: crate::code::ResumeMode::ResumeAt,
- values: vec![
+ values: Box::new([
(r(5).raw(), ValueLocation::Constant(value::int32(10))),
(r(6).raw(), ValueLocation::Register(argument_register, Repr::Tagged)),
- ],
- in_frame: Vec::new(),
+ ]),
+ in_frame: Box::new([]),
passed_argument_count: None,
legacy_arguments: 0..0,
- }],
- objects: Vec::new(),
+ }]),
+ objects: Box::new([]),
inlined_frame_bytes: 0,
}
);