Commit 53757f3e authored by Benjamin Woodruff's avatar Benjamin Woodruff

WIP: Turbopack: Replace SliceMap with FrozenMap

parent c15f8ecd
...@@ -9673,6 +9673,7 @@ dependencies = [ ...@@ -9673,6 +9673,7 @@ dependencies = [
"tokio", "tokio",
"tracing", "tracing",
"turbo-bincode", "turbo-bincode",
"turbo-frozenmap",
"turbo-prehash", "turbo-prehash",
"turbo-rcstr", "turbo-rcstr",
"turbo-tasks", "turbo-tasks",
...@@ -9796,6 +9797,7 @@ dependencies = [ ...@@ -9796,6 +9797,7 @@ dependencies = [
"tracing", "tracing",
"turbo-bincode", "turbo-bincode",
"turbo-esregex", "turbo-esregex",
"turbo-frozenmap",
"turbo-rcstr", "turbo-rcstr",
"turbo-tasks", "turbo-tasks",
"turbo-tasks-backend", "turbo-tasks-backend",
...@@ -10014,6 +10016,7 @@ dependencies = [ ...@@ -10014,6 +10016,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"tracing", "tracing",
"turbo-frozenmap",
"turbo-rcstr", "turbo-rcstr",
"turbo-tasks", "turbo-tasks",
"turbo-tasks-fs", "turbo-tasks-fs",
......
...@@ -138,8 +138,6 @@ pub use crate::{ ...@@ -138,8 +138,6 @@ pub use crate::{
}, },
}; };
pub type SliceMap<K, V> = Box<[(K, V)]>;
pub type FxIndexSet<T> = indexmap::IndexSet<T, BuildHasherDefault<FxHasher>>; pub type FxIndexSet<T> = indexmap::IndexSet<T, BuildHasherDefault<FxHasher>>;
pub type FxIndexMap<K, V> = indexmap::IndexMap<K, V, BuildHasherDefault<FxHasher>>; pub type FxIndexMap<K, V> = indexmap::IndexMap<K, V, BuildHasherDefault<FxHasher>>;
pub type FxDashMap<K, V> = dashmap::DashMap<K, V, BuildHasherDefault<FxHasher>>; pub type FxDashMap<K, V> = dashmap::DashMap<K, V, BuildHasherDefault<FxHasher>>;
......
...@@ -39,6 +39,7 @@ swc_sourcemap = { workspace = true } ...@@ -39,6 +39,7 @@ swc_sourcemap = { workspace = true }
swc_core = { workspace = true, features = ["ecma_preset_env", "common"] } swc_core = { workspace = true, features = ["ecma_preset_env", "common"] }
tracing = { workspace = true } tracing = { workspace = true }
turbo-bincode = { workspace = true } turbo-bincode = { workspace = true }
turbo-frozenmap = { workspace = true }
turbo-prehash = { workspace = true } turbo-prehash = { workspace = true }
turbo-rcstr = { workspace = true } turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true } turbo-tasks = { workspace = true }
......
...@@ -48,6 +48,7 @@ tokio = { workspace = true } ...@@ -48,6 +48,7 @@ tokio = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
turbo-bincode = { workspace = true } turbo-bincode = { workspace = true }
turbo-esregex = { workspace = true } turbo-esregex = { workspace = true }
turbo-frozenmap = { workspace = true }
turbo-rcstr = { workspace = true } turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true } turbo-tasks = { workspace = true }
turbo-tasks-fs = { workspace = true } turbo-tasks-fs = { workspace = true }
......
...@@ -9,6 +9,7 @@ use swc_core::{ ...@@ -9,6 +9,7 @@ use swc_core::{
}, },
quote, quote,
}; };
use turbo_frozenmap::FrozenMap;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, ValueToString, Vc}; use turbo_tasks::{ResolvedVc, ValueToString, Vc};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
...@@ -434,10 +435,10 @@ impl ModuleReference for EsmAssetReference { ...@@ -434,10 +435,10 @@ impl ModuleReference for EsmAssetReference {
.await? .await?
{ {
return Ok(ModuleResolveResult { return Ok(ModuleResolveResult {
primary: Box::new([( primary: FrozenMap::from_unique_sorted_box(Box::new([(
RequestKey::default(), RequestKey::default(),
ModuleResolveResultItem::Ignore, ModuleResolveResultItem::Ignore,
)]), )])),
affecting_sources: Default::default(), affecting_sources: Default::default(),
} }
.cell()); .cell());
......
...@@ -419,7 +419,7 @@ impl PatternMapping { ...@@ -419,7 +419,7 @@ impl PatternMapping {
)) ))
.cell()), .cell()),
1 if !request.request_pattern().await?.has_dynamic_parts() => { 1 if !request.request_pattern().await?.has_dynamic_parts() => {
let resolve_item = &result.primary.first().unwrap().1; let resolve_item = &result.primary.first_key_value().unwrap().1;
let single_pattern_mapping = let single_pattern_mapping =
to_single_pattern_mapping(origin, chunking_context, resolve_item, resolve_type) to_single_pattern_mapping(origin, chunking_context, resolve_item, resolve_type)
.await?; .await?;
......
...@@ -14,13 +14,14 @@ workspace = true ...@@ -14,13 +14,14 @@ workspace = true
[dependencies] [dependencies]
anyhow = { workspace = true } anyhow = { workspace = true }
next-taskless = { workspace = true }
regex = { workspace = true } regex = { workspace = true }
serde = { workspace = true } serde = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
turbo-frozenmap = { workspace = true }
turbo-rcstr = { workspace = true } turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true } turbo-tasks = { workspace = true }
turbo-tasks-fs = { workspace = true } turbo-tasks-fs = { workspace = true }
turbopack-core = { workspace = true } turbopack-core = { workspace = true }
next-taskless = { workspace = true }
...@@ -317,7 +317,7 @@ async fn resolve_node_gyp_build_files( ...@@ -317,7 +317,7 @@ async fn resolve_node_gyp_build_files(
) )
.await?; .await?;
if let Some((_, ResolveResultItem::Source(source))) = if let Some((_, ResolveResultItem::Source(source))) =
resolved_prebuilt_file.primary.first() resolved_prebuilt_file.primary.first_key_value()
{ {
resolved.insert(format!("build/Release/{name}.node").into(), *source); resolved.insert(format!("build/Release/{name}.node").into(), *source);
if collect_affecting_sources { if collect_affecting_sources {
......
...@@ -2,6 +2,7 @@ use std::mem::take; ...@@ -2,6 +2,7 @@ use std::mem::take;
use anyhow::Result; use anyhow::Result;
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
use turbo_frozenmap::FrozenMap;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{FxIndexMap, ResolvedVc, ValueDefault, Vc, fxindexset}; use turbo_tasks::{FxIndexMap, ResolvedVc, ValueDefault, Vc, fxindexset};
use turbo_tasks_fs::{FileContent, FileJsonContent, FileSystemPath, FileSystemPathOption}; use turbo_tasks_fs::{FileContent, FileJsonContent, FileSystemPath, FileSystemPathOption};
...@@ -478,12 +479,11 @@ pub async fn type_resolve( ...@@ -478,12 +479,11 @@ pub async fn type_resolve(
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn as_typings_result(result: Vc<ModuleResolveResult>) -> Result<Vc<ModuleResolveResult>> { pub async fn as_typings_result(result: Vc<ModuleResolveResult>) -> Result<Vc<ModuleResolveResult>> {
let mut result = result.owned().await?; let mut result = result.owned().await?;
result.primary = IntoIterator::into_iter(take(&mut result.primary)) let mut primary = Box::<[_]>::from(take(&mut result.primary));
.map(|(mut k, v)| { for (request_key, _v) in &mut primary {
k.conditions.insert("types".to_string(), true); request_key.conditions.insert("types".to_string(), true);
(k, v) }
}) result.primary = FrozenMap::from_overlapping_vec(primary.into_vec());
.collect();
Ok(result.cell()) Ok(result.cell())
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment