Skip to content

Truly independent web browser

LibJS/JIT: Don't clone the regalloc verifier state at each output

Andreas Kling3c5eb03d9e78
diff --git a/Libraries/LibJS/JIT/Rust/src/regalloc/verify.rs b/Libraries/LibJS/JIT/Rust/src/regalloc/verify.rs
index fe808340250..c76064f89e1 100644
--- a/Libraries/LibJS/JIT/Rust/src/regalloc/verify.rs
+++ b/Libraries/LibJS/JIT/Rust/src/regalloc/verify.rs
@@ -342,9 +342,13 @@ impl Verifier<'_> {
}
}
if let Some(output @ Location::Register(_)) = allocation.output {
- let mut clobbered = state.clone();
- clobbered.remove(&output);
- self.check_exit_values(&clobbered, node_id, &context);
+ // NB: Cloning the state instead would take time quadratic in the size of code that keeps many values in
+ // their stack slots past many nodes.
+ let previous = state.remove(&output);
+ self.check_exit_values(state, node_id, &context);
+ if let Some(previous) = previous {
+ state.insert(output, previous);
+ }
} else {
self.check_exit_values(state, node_id, &context);
}