diff --git a/Cargo.lock b/Cargo.lock index 3f45501c79..952d4d2bc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,6 +37,17 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" +[[package]] +name = "ahash" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f200cbb1e856866d9eade941cf3aa0c5d7dd36f74311c4273b494f4ef036957" +dependencies = [ + "getrandom 0.2.2", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.15" @@ -1376,7 +1387,7 @@ checksum = "e8a70f1e87a3840ed6a3e99e02c2b861e4dbdf26f0d07e38f42ea5aff46cfce2" dependencies = [ "bitflags", "gpu-descriptor-types", - "hashbrown", + "hashbrown 0.9.1", "tracing", ] @@ -1401,7 +1412,17 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" dependencies = [ - "ahash", + "ahash 0.4.7", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash 0.7.2", + "bumpalo", ] [[package]] @@ -1497,7 +1518,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" dependencies = [ "autocfg 1.0.1", - "hashbrown", + "hashbrown 0.9.1", ] [[package]] @@ -2950,6 +2971,7 @@ name = "roc_collections" version = "0.1.0" dependencies = [ "bumpalo", + "hashbrown 0.11.2", "im 14.3.0", "im-rc 14.3.0", "wyhash", @@ -3181,6 +3203,7 @@ name = "roc_mono" version = "0.1.0" dependencies = [ "bumpalo", + "hashbrown 0.11.2", "indoc 0.3.6", "linked-hash-map", "maplit", diff --git a/compiler/collections/Cargo.toml b/compiler/collections/Cargo.toml index 04dee2c3b5..060747e78a 100644 --- a/compiler/collections/Cargo.toml +++ b/compiler/collections/Cargo.toml @@ -10,3 +10,4 @@ im = "14" # im and im-rc should always have the same version! im-rc = "14" # im and im-rc should always have the same version! wyhash = "0.3" bumpalo = { version = "3.6.1", features = ["collections"] } +hashbrown = { version = "0.11.2", features = [ "bumpalo" ] } diff --git a/compiler/collections/src/all.rs b/compiler/collections/src/all.rs index 18cd19f554..a50a8febcb 100644 --- a/compiler/collections/src/all.rs +++ b/compiler/collections/src/all.rs @@ -28,6 +28,8 @@ pub type SendMap = im::hashmap::HashMap; pub type SendSet = im::hashset::HashSet; +pub type BumpMap<'a, K, V> = hashbrown::HashMap>; + pub fn arena_join<'a, I>(arena: &'a Bump, strings: &mut I, join_str: &str) -> String<'a> where I: Iterator, diff --git a/compiler/mono/Cargo.toml b/compiler/mono/Cargo.toml index 49d240ca8d..2123562c9a 100644 --- a/compiler/mono/Cargo.toml +++ b/compiler/mono/Cargo.toml @@ -16,6 +16,7 @@ roc_solve = { path = "../solve" } roc_problem = { path = "../problem" } ven_pretty = { path = "../../vendor/pretty" } bumpalo = { version = "3.6.1", features = ["collections"] } +hashbrown = { version = "0.11.2", features = [ "bumpalo" ] } ven_ena = { path = "../../vendor/ena" } linked-hash-map = "0.5.4" diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index 1957cfaa2f..00202f42a2 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -6,7 +6,7 @@ use crate::layout::{ }; use bumpalo::collections::Vec; use bumpalo::Bump; -use roc_collections::all::{default_hasher, MutMap, MutSet}; +use roc_collections::all::{default_hasher, BumpMap, MutMap, MutSet}; use roc_module::ident::{ForeignSymbol, Lowercase, TagName}; use roc_module::low_level::LowLevel; use roc_module::symbol::{IdentIds, ModuleId, Symbol}; @@ -126,8 +126,8 @@ pub struct Proc<'a> { pub enum HostExposedLayouts<'a> { NotHostExposed, HostExposed { - rigids: MutMap>, - aliases: MutMap>, + rigids: BumpMap<'a, Lowercase, Layout<'a>>, + aliases: BumpMap<'a, Symbol, Layout<'a>>, }, } @@ -1833,7 +1833,8 @@ fn specialize_external<'a>( let host_exposed_layouts = if host_exposed_variables.is_empty() { HostExposedLayouts::NotHostExposed } else { - let mut aliases = MutMap::default(); + let mut aliases = + hashbrown::HashMap::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(env.arena)); for (symbol, variable) in host_exposed_variables { let layout = layout_cache @@ -1843,7 +1844,10 @@ fn specialize_external<'a>( } HostExposedLayouts::HostExposed { - rigids: MutMap::default(), + rigids: hashbrown::HashMap::with_hasher_in( + default_hasher(), + hashbrown::BumpWrapper(env.arena), + ), aliases, } };