Skip to content

Truly independent web browser

AK+LibJS/JIT: Move the zone containers of the compiler to AK

Andreas Klingb967e723787e
diff --git a/AK/Rust/src/fast_hash.rs b/AK/Rust/src/fast_hash.rs
new file mode 100644
index 00000000000..3877b6928c3
--- /dev/null
+++ b/AK/Rust/src/fast_hash.rs
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! A fast hasher for keys that no attacker chooses (ids, addresses and small tuples of them), which need no
+//! protection against collisions made on purpose.
+
+use core::hash::Hasher;
+
+/// The hasher of rustc's `FxHasher`: one rotate, xor and multiply per word.
+#[derive(Debug, Clone, Copy, Default)]
+pub struct FastHasher(u64);
+
+const SEED: u64 = 0x51_7c_c1_b7_27_22_0a_95;
+
+impl FastHasher {
+ fn add(&mut self, word: u64) {
+ self.0 = (self.0.rotate_left(5) ^ word).wrapping_mul(SEED);
+ }
+}
+
+impl Hasher for FastHasher {
+ fn write(&mut self, bytes: &[u8]) {
+ let (words, rest) = bytes.as_chunks::<8>();
+ for word in words {
+ self.add(u64::from_le_bytes(*word));
+ }
+ let mut last = [0u8; 8];
+ last[..rest.len()].copy_from_slice(rest);
+ self.add(u64::from_le_bytes(last));
+ }
+
+ fn write_u8(&mut self, value: u8) {
+ self.add(u64::from(value));
+ }
+
+ fn write_u32(&mut self, value: u32) {
+ self.add(u64::from(value));
+ }
+
+ fn write_u64(&mut self, value: u64) {
+ self.add(value);
+ }
+
+ fn write_usize(&mut self, value: usize) {
+ self.add(value as u64);
+ }
+
+ fn finish(&self) -> u64 {
+ self.0
+ }
+}
diff --git a/AK/Rust/src/lib.rs b/AK/Rust/src/lib.rs
index 7a5ddc8b6de..b86ac1ee24a 100644
--- a/AK/Rust/src/lib.rs
+++ b/AK/Rust/src/lib.rs
@@ -7,6 +7,7 @@
//! Rust views of shared AK data structures.
mod column;
+mod fast_hash;
mod generic_lexer;
pub mod math;
pub mod perf_map;
@@ -21,8 +22,11 @@ pub mod waiter_list;
pub mod windows_code_memory;
mod word_chunk;
mod zone;
+mod zone_bit_set;
+mod zone_map;
pub use column::{Column, ColumnFull};
+pub use fast_hash::FastHasher;
pub use generic_lexer::GenericLexer;
pub use row_block::{RowBlock, RowBlockFull, RowList};
pub use scope_guard::ScopeGuard;
@@ -30,6 +34,8 @@ pub use slice::{Span, SpanMut, slice_from_raw_parts, slice_from_raw_parts_mut};
pub use string_conversions::{UnsignedInteger, parse_ascii_digits};
pub use word_chunk::WordChunk;
pub use zone::{Zone, ZoneVec, ZoneVecIntoIter};
+pub use zone_bit_set::ZoneBitSet;
+pub use zone_map::{ZoneMap, ZoneSet};
use core::mem::MaybeUninit;
use std::num::NonZeroUsize;
diff --git a/Libraries/LibJS/JIT/Rust/src/bitset.rs b/AK/Rust/src/zone_bit_set.rs
similarity index 96%
rename from Libraries/LibJS/JIT/Rust/src/bitset.rs
rename to AK/Rust/src/zone_bit_set.rs
index 87e144ceb9a..5b404f17e43 100644
--- a/Libraries/LibJS/JIT/Rust/src/bitset.rs
+++ b/AK/Rust/src/zone_bit_set.rs
@@ -4,15 +4,15 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-//! Fixed-size sets of small integers.
+//! A fixed-size set of small integers that keeps its words in a zone (see `Zone`).
-use ak::Zone;
-use ak::ZoneVec;
+use crate::Zone;
+use crate::ZoneVec;
-/// A fixed-size set of small integers, whose words are in a zone (see `ak::Zone`).
+/// A fixed-size set of small integers, whose words are in a zone (see `Zone`).
#[derive(PartialEq, Eq)]
pub struct ZoneBitSet<'z> {
- // NB: Most bytecode liveness sets fit in one word and take no memory of the zone.
+ // NB: A set of up to 64 integers fits in one word and takes no memory of the zone.
first_word: u64,
extra_words: ZoneVec<'z, u64>,
len: usize,
diff --git a/Libraries/LibJS/JIT/Rust/src/zone_map.rs b/AK/Rust/src/zone_map.rs
similarity index 99%
rename from Libraries/LibJS/JIT/Rust/src/zone_map.rs
rename to AK/Rust/src/zone_map.rs
index 5f455ab72c7..11a23b6192b 100644
--- a/Libraries/LibJS/JIT/Rust/src/zone_map.rs
+++ b/AK/Rust/src/zone_map.rs
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-//! Maps and sets in the zones of a compile.
+//! Maps and sets that keep their entries in a zone (see `Zone`).
//!
//! A `ZoneMap` keeps its entries next to each other in a list of its zone, in the order in which they were added,
//! and finds them through a table of indices into that list. So a compile makes no block of the heap for a map, and
@@ -16,8 +16,8 @@ use core::hash::BuildHasher;
use core::hash::BuildHasherDefault;
use core::hash::Hash;
-use ak::Zone;
-use ak::ZoneVec;
+use crate::Zone;
+use crate::ZoneVec;
use crate::fast_hash::FastHasher;
diff --git a/Libraries/LibJS/JIT/Rust/clippy.toml b/Libraries/LibJS/JIT/Rust/clippy.toml
index 76cc57aa7d3..fab2aed368a 100644
--- a/Libraries/LibJS/JIT/Rust/clippy.toml
+++ b/Libraries/LibJS/JIT/Rust/clippy.toml
@@ -65,16 +65,16 @@ disallowed-types = [
{ path = "std::collections::VecDeque", reason = "the compiler makes no block in the heap: use ak::ZoneVec" },
{ path = "std::collections::BinaryHeap", reason = "the compiler makes no block in the heap: use ak::ZoneVec" },
{ path = "std::collections::LinkedList", reason = "the compiler makes no block in the heap: use ak::ZoneVec" },
- { path = "std::collections::HashMap", reason = "the compiler makes no block in the heap: use crate::zone_map::ZoneMap" },
- { path = "std::collections::HashSet", reason = "the compiler makes no block in the heap: use crate::zone_map::ZoneSet" },
- { path = "std::collections::BTreeMap", reason = "the compiler makes no block in the heap: use crate::zone_map::ZoneMap, or a sorted ak::ZoneVec" },
- { path = "std::collections::BTreeSet", reason = "the compiler makes no block in the heap: use crate::zone_map::ZoneSet, or a sorted ak::ZoneVec" },
+ { path = "std::collections::HashMap", reason = "the compiler makes no block in the heap: use ak::ZoneMap" },
+ { path = "std::collections::HashSet", reason = "the compiler makes no block in the heap: use ak::ZoneSet" },
+ { path = "std::collections::BTreeMap", reason = "the compiler makes no block in the heap: use ak::ZoneMap, or a sorted ak::ZoneVec" },
+ { path = "std::collections::BTreeSet", reason = "the compiler makes no block in the heap: use ak::ZoneSet, or a sorted ak::ZoneVec" },
{ path = "std::boxed::Box", reason = "the compiler makes no block in the heap: use Zone::alloc" },
{ path = "std::rc::Rc", reason = "the compiler makes no block in the heap: share a reference into a zone" },
{ path = "std::sync::Arc", reason = "the compiler makes no block in the heap: share a reference into a zone" },
{ path = "libjs_jit::inline_vec::InlineVec", reason = "the compiler makes no block in the heap: use ak::ZoneVec" },
- { path = "libjs_jit::fast_hash::HashMap", reason = "the compiler makes no block in the heap: use crate::zone_map::ZoneMap" },
- { path = "libjs_jit::fast_hash::HashSet", reason = "the compiler makes no block in the heap: use crate::zone_map::ZoneSet" },
+ { path = "libjs_jit::fast_hash::HashMap", reason = "the compiler makes no block in the heap: use ak::ZoneMap" },
+ { path = "libjs_jit::fast_hash::HashSet", reason = "the compiler makes no block in the heap: use ak::ZoneSet" },
]
disallowed-macros = [
{ path = "std::vec", reason = "the compiler makes no block in the heap: use a slice, or ak::ZoneVec" },
diff --git a/Libraries/LibJS/JIT/Rust/src/builder/inlining.rs b/Libraries/LibJS/JIT/Rust/src/builder/inlining.rs
index 6c3dd4c53f3..9a6f20ca53b 100644
--- a/Libraries/LibJS/JIT/Rust/src/builder/inlining.rs
+++ b/Libraries/LibJS/JIT/Rust/src/builder/inlining.rs
@@ -35,7 +35,6 @@ use super::GraphBuilder;
use super::SlotState;
use super::arguments;
use crate::CompileFailure;
-use crate::bitset::ZoneBitSet;
use crate::builder::Handling;
use crate::builder::handling;
use crate::bytecode::Instruction;
@@ -64,6 +63,7 @@ use crate::snapshot::Intrinsic;
use crate::snapshot::SuperConstructTarget;
use crate::snapshot::call_feedback_flags;
use ak::Zone;
+use ak::ZoneBitSet;
use ak::ZoneVec;
/// How an inlined callee was called.
diff --git a/Libraries/LibJS/JIT/Rust/src/builder/mod.rs b/Libraries/LibJS/JIT/Rust/src/builder/mod.rs
index 9b318c6eb01..9ace6e1b25f 100644
--- a/Libraries/LibJS/JIT/Rust/src/builder/mod.rs
+++ b/Libraries/LibJS/JIT/Rust/src/builder/mod.rs
@@ -54,7 +54,6 @@ pub use speculation::OperationInput;
pub(crate) use osr::is_loop_back_edge;
use crate::CompileFailure;
-use crate::bitset::ZoneBitSet;
use crate::bytecode::DecodedInstruction;
use crate::bytecode::FrameLayout;
use crate::bytecode::Instruction;
@@ -88,8 +87,9 @@ use crate::snapshot::ExecutableSnapshot;
use crate::snapshot::Intrinsic;
use crate::snapshot::RuntimeInfo;
use crate::snapshot::Snapshot;
-use crate::zone_map::ZoneMap;
use ak::Zone;
+use ak::ZoneBitSet;
+use ak::ZoneMap;
use ak::ZoneVec;
pub(crate) use slow_paths::is_ssa_slow_path_output;
pub(crate) use slow_paths::js_call_operands;
diff --git a/Libraries/LibJS/JIT/Rust/src/builder/tests.rs b/Libraries/LibJS/JIT/Rust/src/builder/tests.rs
index 097006daf0b..a1ac778eb52 100644
--- a/Libraries/LibJS/JIT/Rust/src/builder/tests.rs
+++ b/Libraries/LibJS/JIT/Rust/src/builder/tests.rs
@@ -112,7 +112,7 @@ fn cached_liveness_keeps_legacy_arguments_only_for_inlined_walks() {
let first = Function::new(&snapshot, 0, decoded, first_mode, crate::test_zone()).unwrap();
let second = Function::new(&snapshot, 0, decoded, !first_mode, crate::test_zone()).unwrap();
let live_in = |function: &Function<'_>, slot| {
- let mut live = crate::bitset::ZoneBitSet::new_in(0, crate::test_zone());
+ let mut live = ak::ZoneBitSet::new_in(0, crate::test_zone());
function.liveness.live_in(0, &mut live);
live.contains(slot)
};
@@ -350,9 +350,9 @@ fn writes_to_constant_operands_go_to_the_frame() {
#[test]
fn loop_headers_inside_a_loop_body_add_their_phis_to_it() {
- use crate::bitset::ZoneBitSet;
use crate::bytecode::cfg::Cfg;
use crate::bytecode::cfg::Loop;
+ use ak::ZoneBitSet;
let zone = crate::test_zone();
// Loop 1's header lies in loop 0's body, but loop 1 extends outside it,
diff --git a/Libraries/LibJS/JIT/Rust/src/bytecode/cfg.rs b/Libraries/LibJS/JIT/Rust/src/bytecode/cfg.rs
index 774f56a7b7a..2e358cd44b2 100644
--- a/Libraries/LibJS/JIT/Rust/src/bytecode/cfg.rs
+++ b/Libraries/LibJS/JIT/Rust/src/bytecode/cfg.rs
@@ -23,8 +23,8 @@ use super::FrameLayout;
use super::OpCode;
use super::Operand;
use super::THIS_VALUE_REGISTER;
-use crate::bitset::ZoneBitSet;
use ak::Zone;
+use ak::ZoneBitSet;
use ak::ZoneVec;
use std::ops::Range;
diff --git a/Libraries/LibJS/JIT/Rust/src/bytecode/liveness.rs b/Libraries/LibJS/JIT/Rust/src/bytecode/liveness.rs
index 471a8ded711..5a70624e578 100644
--- a/Libraries/LibJS/JIT/Rust/src/bytecode/liveness.rs
+++ b/Libraries/LibJS/JIT/Rust/src/bytecode/liveness.rs
@@ -21,8 +21,8 @@ use super::FrameLayout;
use super::RESERVED_REGISTER_COUNT;
use super::cfg::BasicBlock;
use super::cfg::Cfg;
-use crate::bitset::ZoneBitSet;
use ak::Zone;
+use ak::ZoneBitSet;
use ak::ZoneVec;
/// The live set after every this many instructions of a block, counted from its end, is kept, and the sets of the
diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs b/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs
index 699f8e50f01..c381b501812 100644
--- a/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs
+++ b/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs
@@ -2021,7 +2021,7 @@ mod execution {
.iter()
.position(|instruction| instruction.pc == pc)
.unwrap();
- let mut live = crate::bitset::ZoneBitSet::new_in(0, &work);
+ let mut live = ak::ZoneBitSet::new_in(0, &work);
liveness.live_in(index, &mut live);
for slot in live.iter() {
let operand = layout.operand_for_tracked_index(slot);
@@ -2194,7 +2194,7 @@ mod execution {
.iter()
.position(|instruction| instruction.pc == *pc)
.unwrap();
- let mut live = crate::bitset::ZoneBitSet::new_in(0, &work);
+ let mut live = ak::ZoneBitSet::new_in(0, &work);
liveness.live_in(index, &mut live);
for slot in live.iter() {
let slot = layout.operand_for_tracked_index(slot).raw() as usize;
@@ -2226,7 +2226,7 @@ mod execution {
.iter()
.position(|instruction| instruction.pc == pc)
.unwrap();
- let mut live = crate::bitset::ZoneBitSet::new_in(0, &work);
+ let mut live = ak::ZoneBitSet::new_in(0, &work);
liveness.live_in(index, &mut live);
for slot in live.iter() {
let operand = layout.operand_for_tracked_index(slot);
diff --git a/Libraries/LibJS/JIT/Rust/src/fast_hash.rs b/Libraries/LibJS/JIT/Rust/src/fast_hash.rs
index 10d6cffe827..a01bb7b49ef 100644
--- a/Libraries/LibJS/JIT/Rust/src/fast_hash.rs
+++ b/Libraries/LibJS/JIT/Rust/src/fast_hash.rs
@@ -4,56 +4,11 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-//! Hash maps and sets with a fast hasher, for the compiler's keys: node
-//! ids, cells and small tuples of them, which no attacker chooses, so they
-//! need no protection against collisions made on purpose.
+//! Hash maps and sets with a fast hasher (see `ak::FastHasher`), for the compiler's keys.
use std::hash::BuildHasherDefault;
-use std::hash::Hasher;
-/// The hasher of rustc's `FxHasher`: one rotate, xor and multiply per word.
-#[derive(Debug, Clone, Copy, Default)]
-pub struct FastHasher(u64);
-
-const SEED: u64 = 0x51_7c_c1_b7_27_22_0a_95;
-
-impl FastHasher {
- fn add(&mut self, word: u64) {
- self.0 = (self.0.rotate_left(5) ^ word).wrapping_mul(SEED);
- }
-}
-
-impl Hasher for FastHasher {
- fn write(&mut self, bytes: &[u8]) {
- let (words, rest) = bytes.as_chunks::<8>();
- for word in words {
- self.add(u64::from_le_bytes(*word));
- }
- let mut last = [0u8; 8];
- last[..rest.len()].copy_from_slice(rest);
- self.add(u64::from_le_bytes(last));
- }
-
- fn write_u8(&mut self, value: u8) {
- self.add(u64::from(value));
- }
-
- fn write_u32(&mut self, value: u32) {
- self.add(u64::from(value));
- }
-
- fn write_u64(&mut self, value: u64) {
- self.add(value);
- }
-
- fn write_usize(&mut self, value: usize) {
- self.add(value as u64);
- }
-
- fn finish(&self) -> u64 {
- self.0
- }
-}
+use ak::FastHasher;
pub type HashMap<K, V> = std::collections::HashMap<K, V, BuildHasherDefault<FastHasher>>;
pub type HashSet<K> = std::collections::HashSet<K, BuildHasherDefault<FastHasher>>;
diff --git a/Libraries/LibJS/JIT/Rust/src/ir/mod.rs b/Libraries/LibJS/JIT/Rust/src/ir/mod.rs
index e208d899587..f7c6460eeb9 100644
--- a/Libraries/LibJS/JIT/Rust/src/ir/mod.rs
+++ b/Libraries/LibJS/JIT/Rust/src/ir/mod.rs
@@ -1695,7 +1695,7 @@ pub struct Graph<'z> {
/// wherever its code runs: the arguments and the `this` value register, unless an instruction writes them. Nothing
/// stores to them (the verifier enforces this), so the register allocator reloads what was loaded from them from
/// there (see `regalloc::frame_home()`).
- pub unwritten_slots: crate::bitset::ZoneBitSet<'z>,
+ pub unwritten_slots: ak::ZoneBitSet<'z>,
}
impl<'z> Graph<'z> {
@@ -1721,7 +1721,7 @@ impl<'z> Graph<'z> {
speculatively_hoisted: ZoneVec::new_in(zone),
legacy_arguments: 0..0,
legacy_arguments_guards: ZoneVec::new_in(zone),
- unwritten_slots: crate::bitset::ZoneBitSet::new_in(0, zone),
+ unwritten_slots: ak::ZoneBitSet::new_in(0, zone),
}
}
@@ -1753,7 +1753,7 @@ impl<'z> Graph<'z> {
unwritten_slots,
} = self;
let list = |values: &[NodeId]| ZoneVec::from_slice_in(values, zone);
- let mut unwritten = crate::bitset::ZoneBitSet::new_in(unwritten_slots.capacity(), zone);
+ let mut unwritten = ak::ZoneBitSet::new_in(unwritten_slots.capacity(), zone);
unwritten.union_with(unwritten_slots);
Graph {
zone,
diff --git a/Libraries/LibJS/JIT/Rust/src/lib.rs b/Libraries/LibJS/JIT/Rust/src/lib.rs
index 2a4a1c19b1c..37611294bd0 100644
--- a/Libraries/LibJS/JIT/Rust/src/lib.rs
+++ b/Libraries/LibJS/JIT/Rust/src/lib.rs
@@ -20,7 +20,6 @@
pub mod artifact;
#[allow(clippy::disallowed_types, clippy::disallowed_macros)]
pub mod asm;
-pub mod bitset;
pub mod builder;
pub mod bytecode;
#[allow(clippy::disallowed_types, clippy::disallowed_macros)]
@@ -44,7 +43,6 @@ pub mod scratch;
#[allow(clippy::disallowed_types, clippy::disallowed_macros)]
pub mod snapshot;
pub mod tables;
-pub mod zone_map;
// NB: The tests get their memory on Windows from `ak::windows_code_memory`, which is for x86-64.
#[cfg(all(test, windows, not(target_arch = "x86_64")))]
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/bounds_check_elimination.rs b/Libraries/LibJS/JIT/Rust/src/passes/bounds_check_elimination.rs
index 6acf8c215ec..757b4d34fd0 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/bounds_check_elimination.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/bounds_check_elimination.rs
@@ -49,7 +49,6 @@ use ak::ZoneVec;
use super::dominators::Dominators;
use super::edit::Constants;
use super::edit::Replacements;
-use crate::bitset::ZoneBitSet;
use crate::code::ExitKind;
use crate::code::Repr;
use crate::ir::BinaryOp;
@@ -60,7 +59,8 @@ use crate::ir::Graph;
use crate::ir::Node;
use crate::ir::NodeId;
use crate::ir::Op;
-use crate::zone_map::ZoneMap;
+use ak::ZoneBitSet;
+use ak::ZoneMap;
/// The inclusive range of an int32 value.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/branch_fusion.rs b/Libraries/LibJS/JIT/Rust/src/passes/branch_fusion.rs
index 2aec50ef602..3bc99ea9d27 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/branch_fusion.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/branch_fusion.rs
@@ -15,7 +15,6 @@
//! is a constant, so that its comparison fuses with the branch there.
use super::edit;
-use crate::bitset::ZoneBitSet;
use crate::code::Repr;
use crate::ir::Block;
use crate::ir::BlockId;
@@ -25,6 +24,7 @@ use crate::ir::Graph;
use crate::ir::NodeId;
use crate::ir::Op;
use ak::Zone;
+use ak::ZoneBitSet;
use ak::ZoneVec;
/// The comparison of swapped operands that has the same result.
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/branch_splitting.rs b/Libraries/LibJS/JIT/Rust/src/passes/branch_splitting.rs
index 34451b6b5ab..5e44adb8f8b 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/branch_splitting.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/branch_splitting.rs
@@ -16,13 +16,13 @@ use ak::Zone;
use ak::ZoneVec;
use super::dominators::Dominators;
-use crate::bitset::ZoneBitSet;
use crate::ir::BlockId;
use crate::ir::BranchCondition;
use crate::ir::FrameStateId;
use crate::ir::Graph;
use crate::ir::NodeId;
use crate::ir::Op;
+use ak::ZoneBitSet;
/// A block to split: its phis, the block that branches (itself, or the one
/// it jumps to), and for each side of the branch, the predecessor that takes
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/check_elimination.rs b/Libraries/LibJS/JIT/Rust/src/passes/check_elimination.rs
index 0285f16df61..8f83f549296 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/check_elimination.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/check_elimination.rs
@@ -44,7 +44,6 @@ use super::facts::Location;
use super::facts::Moved;
use super::facts::ValueKind;
use super::facts::elements_kind_implies;
-use crate::bitset::ZoneBitSet;
use crate::bytecode::OpCode;
use crate::code::Dependency;
use crate::ir::BlockId;
@@ -57,6 +56,7 @@ use crate::ir::ShapeCheck;
use crate::ir::value;
use crate::snapshot::CellId;
use ak::Zone;
+use ak::ZoneBitSet;
use ak::ZoneVec;
/// What the analysis decided for the nodes of one visit of the graph.
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/dce.rs b/Libraries/LibJS/JIT/Rust/src/passes/dce.rs
index 974448eb4bf..c9d5b67cf52 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/dce.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/dce.rs
@@ -11,10 +11,10 @@
//! of whose edges lead to the same place, doing nothing, become jumps.
use super::edit;
-use crate::bitset::ZoneBitSet;
use crate::ir::Graph;
use crate::ir::Op;
use ak::Zone;
+use ak::ZoneBitSet;
use ak::ZoneVec;
/// Whether a node can be dropped when its value is unused.
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/dominators.rs b/Libraries/LibJS/JIT/Rust/src/passes/dominators.rs
index 30769088eac..e4c060ea8cc 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/dominators.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/dominators.rs
@@ -13,10 +13,10 @@
use ak::Zone;
use ak::ZoneVec;
-use crate::bitset::ZoneBitSet;
use crate::ir::BlockId;
use crate::ir::Graph;
use crate::tables::Lists;
+use ak::ZoneBitSet;
/// The dominator tree of a graph, in lists of a work zone. `compute()` makes them anew for the graph as it is then,
/// in the memory they have where it is enough.
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/edit.rs b/Libraries/LibJS/JIT/Rust/src/passes/edit.rs
index ff65f03de23..f00c678ff2e 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/edit.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/edit.rs
@@ -7,7 +7,6 @@
//! Graph edits shared by the passes: replacing values, removing nodes, and
//! cleaning up the control flow graph after control nodes lost successors.
-use crate::bitset::ZoneBitSet;
use crate::code::Repr;
use crate::ir::BlockId;
use crate::ir::FrameState;
@@ -15,8 +14,9 @@ use crate::ir::FrameStateId;
use crate::ir::Graph;
use crate::ir::NodeId;
use crate::ir::Op;
-use crate::zone_map::ZoneMap;
use ak::Zone;
+use ak::ZoneBitSet;
+use ak::ZoneMap;
use ak::ZoneVec;
/// Values to replace by other values, as a pass decides them.
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/escape_analysis.rs b/Libraries/LibJS/JIT/Rust/src/passes/escape_analysis.rs
index d964d8934f6..af005dd3f11 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/escape_analysis.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/escape_analysis.rs
@@ -47,7 +47,6 @@
use super::edit;
use super::edit::Constants;
use super::edit::Replacements;
-use crate::bitset::ZoneBitSet;
use crate::code::ExitKind;
use crate::code::Repr;
use crate::codegen::lowering_info::lowering_info;
@@ -61,9 +60,10 @@ use crate::ir::Op;
use crate::ir::VirtualObjectKind;
use crate::ir::value;
use crate::snapshot::CellId;
-use crate::zone_map::ZoneMap;
-use crate::zone_map::ZoneSet;
use ak::Zone;
+use ak::ZoneBitSet;
+use ak::ZoneMap;
+use ak::ZoneSet;
use ak::ZoneVec;
/// The shape and property count each object has at some point, which
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/exit_unboxing.rs b/Libraries/LibJS/JIT/Rust/src/passes/exit_unboxing.rs
index 38598793ed2..412afabdb2c 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/exit_unboxing.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/exit_unboxing.rs
@@ -13,10 +13,10 @@
//! which dominates its boxing and thus the exit, and dead code elimination
//! removes the boxing.
-use crate::bitset::ZoneBitSet;
use crate::ir::Graph;
use crate::ir::Op;
use ak::Zone;
+use ak::ZoneBitSet;
fn is_boxing(op: &Op) -> bool {
matches!(op, Op::BoxInt32 | Op::BoxFloat64 | Op::BoxBool)
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/facts.rs b/Libraries/LibJS/JIT/Rust/src/passes/facts.rs
index c1f6c5119ba..20d3654f6d5 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/facts.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/facts.rs
@@ -33,8 +33,8 @@ use crate::ir::NodeProperties;
use crate::ir::Op;
use crate::ir::ShapeCheck;
use crate::snapshot::CellId;
-use crate::zone_map::ZoneMap;
use ak::Zone;
+use ak::ZoneMap;
use ak::ZoneVec;
/// A list of facts in a zone, which facts at several points may share: FROZEN, a list that nothing changes anymore,
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/gvn.rs b/Libraries/LibJS/JIT/Rust/src/passes/gvn.rs
index 515293b4a1a..9542ee38008 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/gvn.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/gvn.rs
@@ -18,14 +18,14 @@ use ak::ZoneVec;
use super::dominators::Dominators;
use super::edit;
use super::edit::Replacements;
-use crate::bitset::ZoneBitSet;
-use crate::fast_hash::FastHasher;
use crate::ir::BlockId;
use crate::ir::Graph;
use crate::ir::Node;
use crate::ir::NodeId;
use crate::ir::Op;
-use crate::zone_map::ZoneMap;
+use ak::FastHasher;
+use ak::ZoneBitSet;
+use ak::ZoneMap;
use std::hash::Hash;
use std::hash::Hasher;
use std::mem::discriminant;
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/interrupt_check_elimination.rs b/Libraries/LibJS/JIT/Rust/src/passes/interrupt_check_elimination.rs
index 1418582ba56..d056f1f2190 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/interrupt_check_elimination.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/interrupt_check_elimination.rs
@@ -29,7 +29,6 @@ use ak::Zone;
use ak::ZoneVec;
use super::dominators::Dominators;
-use crate::bitset::ZoneBitSet;
use crate::ir::BinaryOp;
use crate::ir::BlockId;
use crate::ir::BranchCondition;
@@ -37,6 +36,7 @@ use crate::ir::Comparison;
use crate::ir::Graph;
use crate::ir::NodeId;
use crate::ir::Op;
+use ak::ZoneBitSet;
/// How many nodes a loop may have to lose its check. In larger ones the check
/// costs next to nothing, and they take longer to count to their end.
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/key_strings.rs b/Libraries/LibJS/JIT/Rust/src/passes/key_strings.rs
index fce49f1e284..f35a167f400 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/key_strings.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/key_strings.rs
@@ -28,11 +28,11 @@
//! concatenation with other uses than keys is marked all the same: its
//! string has the same characters either way.
-use crate::bitset::ZoneBitSet;
use crate::ir::Graph;
use crate::ir::NodeId;
use crate::ir::Op;
use ak::Zone;
+use ak::ZoneBitSet;
use ak::ZoneVec;
pub fn run(graph: &mut Graph, work: &Zone) {
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/licm.rs b/Libraries/LibJS/JIT/Rust/src/passes/licm.rs
index ca1592b1e09..28087a42e1b 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/licm.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/licm.rs
@@ -30,7 +30,6 @@ use ak::ZoneVec;
use super::dominators::Dominators;
use super::edit;
-use crate::bitset::ZoneBitSet;
use crate::code::ExitKind;
use crate::ir::Block;
use crate::ir::BlockId;
@@ -38,6 +37,7 @@ use crate::ir::FrameStateId;
use crate::ir::Graph;
use crate::ir::Locations;
use crate::ir::Op;
+use ak::ZoneBitSet;
struct Loop<'w> {
header: BlockId,
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/loop_rotation.rs b/Libraries/LibJS/JIT/Rust/src/passes/loop_rotation.rs
index 1ba8383f9a7..c30aa58ec6b 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/loop_rotation.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/loop_rotation.rs
@@ -23,13 +23,13 @@ use ak::ZoneVec;
use super::dominators::Dominators;
use super::edit;
-use crate::bitset::ZoneBitSet;
use crate::ir::Block;
use crate::ir::BlockId;
use crate::ir::FrameStateId;
use crate::ir::Graph;
use crate::ir::NodeId;
use crate::ir::Op;
+use ak::ZoneBitSet;
/// How many nodes the blocks of a test that gets copied may have at most.
const MAX_COPIED_NODES: usize = 64;
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/representation.rs b/Libraries/LibJS/JIT/Rust/src/passes/representation.rs
index 9b33da447d8..1c8b1147182 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/representation.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/representation.rs
@@ -22,7 +22,6 @@
use super::edit;
use super::edit::Constants;
use super::edit::Replacements;
-use crate::bitset::ZoneBitSet;
use crate::code::Repr;
use crate::ir::BlockId;
use crate::ir::FrameStateId;
@@ -31,8 +30,9 @@ use crate::ir::Node;
use crate::ir::NodeId;
use crate::ir::Op;
use crate::ir::value;
-use crate::zone_map::ZoneMap;
use ak::Zone;
+use ak::ZoneBitSet;
+use ak::ZoneMap;
use ak::ZoneVec;
/// An unboxed representation phis can take.
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/simplify.rs b/Libraries/LibJS/JIT/Rust/src/passes/simplify.rs
index b50111c8355..2eaaa650d06 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/simplify.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/simplify.rs
@@ -18,7 +18,6 @@
use super::edit;
use super::edit::Constants;
use super::edit::Replacements;
-use crate::bitset::ZoneBitSet;
use crate::code::Repr;
use crate::ir::BinaryOp;
use crate::ir::BlockId;
@@ -29,6 +28,7 @@ use crate::ir::NodeId;
use crate::ir::Op;
use crate::ir::value;
use ak::Zone;
+use ak::ZoneBitSet;
use ak::ZoneVec;
/// The truthiness of a constant, where it does not depend on the heap.
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/tests.rs b/Libraries/LibJS/JIT/Rust/src/passes/tests.rs
index 40a0716de02..63d456350c1 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/tests.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/tests.rs
@@ -361,7 +361,7 @@ fn loads_of_slots_that_nothing_writes_move_out_of_loops_that_call() {
..Block::default()
});
}
- graph.unwritten_slots = crate::bitset::ZoneBitSet::new_in(8, graph.zone);
+ graph.unwritten_slots = ak::ZoneBitSet::new_in(8, graph.zone);
graph.unwritten_slots.insert(7);
let enter = node(&mut graph, Op::Jump { target: BlockId(1) }, vec![], None);
graph.blocks[0].control = Some(enter);
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/truncation.rs b/Libraries/LibJS/JIT/Rust/src/passes/truncation.rs
index a6205338045..2427ad1a654 100644
--- a/Libraries/LibJS/JIT/Rust/src/passes/truncation.rs
+++ b/Libraries/LibJS/JIT/Rust/src/passes/truncation.rs
@@ -30,7 +30,6 @@
//! shifts unused.
use super::edit::Constants;
-use crate::bitset::ZoneBitSet;
use crate::code::Repr;
use crate::ir::BinaryOp;
use crate::ir::ElementsKind;
@@ -40,6 +39,7 @@ use crate::ir::NodeId;
use crate::ir::Op;
use crate::ir::TypedArrayElement;
use ak::Zone;
+use ak::ZoneBitSet;
use ak::ZoneVec;
/// The operations that wrap where their users only read the low 32 bits.
diff --git a/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs b/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs
index f85a51b680b..9d4f5c72c7a 100644
--- a/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs
+++ b/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs
@@ -804,7 +804,7 @@ fn the_verifier_finds_values_reloaded_from_frame_slots_that_do_not_hold_them() {
// A frame slot that the code may write is no home.
let mut written = graph.clone_in(crate::test_zone());
- written.unwritten_slots = crate::bitset::ZoneBitSet::new_in(0, written.zone);
+ written.unwritten_slots = ak::ZoneBitSet::new_in(0, written.zone);
assert!(verify(&written, &registers, &allocation, crate::test_zone()).is_err());
// Another frame slot holds another value.