Commit f8fbd269 authored by Benjamin Woodruff's avatar Benjamin Woodruff

Turbopack: Try out valuable::Valuable for RcStr and ReadRef types

parent 9bd5a76d
...@@ -7,8 +7,8 @@ xtask = "run --package xtask --" ...@@ -7,8 +7,8 @@ xtask = "run --package xtask --"
[build] [build]
rustflags = [ rustflags = [
"--cfg", "--cfg=tokio_unstable",
"tokio_unstable", "--cfg=tracing_unstable",
"-Zshare-generics=y", # make the current crate share its generic instantiations "-Zshare-generics=y", # make the current crate share its generic instantiations
"-Zthreads=8", # parallel frontend https://blog.rust-lang.org/2023/11/09/parallel-rustc.html "-Zthreads=8", # parallel frontend https://blog.rust-lang.org/2023/11/09/parallel-rustc.html
"-Csymbol-mangling-version=v0", "-Csymbol-mangling-version=v0",
...@@ -18,8 +18,8 @@ rustdocflags = [] ...@@ -18,8 +18,8 @@ rustdocflags = []
[target.x86_64-pc-windows-msvc] [target.x86_64-pc-windows-msvc]
linker = "rust-lld" linker = "rust-lld"
rustflags = [ rustflags = [
"--cfg", "--cfg=tokio_unstable",
"tokio_unstable", "--cfg=tracing_unstable",
"-Zshare-generics=y", "-Zshare-generics=y",
"-C", "-C",
"target-feature=+crt-static" "target-feature=+crt-static"
...@@ -27,8 +27,8 @@ rustflags = [ ...@@ -27,8 +27,8 @@ rustflags = [
[target.i686-pc-windows-msvc] [target.i686-pc-windows-msvc]
rustflags = [ rustflags = [
"--cfg", "--cfg=tokio_unstable",
"tokio_unstable", "--cfg=tracing_unstable",
"-Zshare-generics=y", "-Zshare-generics=y",
"-C", "-C",
"target-feature=+crt-static" "target-feature=+crt-static"
...@@ -36,8 +36,8 @@ rustflags = [ ...@@ -36,8 +36,8 @@ rustflags = [
[target.'cfg(all(target_os = "linux", target_env = "gnu"))'] [target.'cfg(all(target_os = "linux", target_env = "gnu"))']
rustflags = [ rustflags = [
"--cfg", "--cfg=tokio_unstable",
"tokio_unstable", "--cfg=tracing_unstable",
"-Zshare-generics=y", "-Zshare-generics=y",
"-Zthreads=8", "-Zthreads=8",
"-Zunstable-options", "-Zunstable-options",
...@@ -50,8 +50,8 @@ rustflags = [ ...@@ -50,8 +50,8 @@ rustflags = [
linker = "aarch64-linux-musl-gcc" linker = "aarch64-linux-musl-gcc"
# Config need to be mirrowed to .github/workflows/build_and_deploy.yml # Config need to be mirrowed to .github/workflows/build_and_deploy.yml
rustflags = [ rustflags = [
"--cfg", "--cfg=tokio_unstable",
"tokio_unstable", "--cfg=tracing_unstable",
"-Zshare-generics=y", "-Zshare-generics=y",
"-Csymbol-mangling-version=v0", "-Csymbol-mangling-version=v0",
"-Ctarget-feature=-crt-static", "-Ctarget-feature=-crt-static",
...@@ -61,8 +61,8 @@ rustflags = [ ...@@ -61,8 +61,8 @@ rustflags = [
[target.x86_64-unknown-linux-musl] [target.x86_64-unknown-linux-musl]
# Config need to be mirrowed to .github/workflows/build_and_deploy.yml # Config need to be mirrowed to .github/workflows/build_and_deploy.yml
rustflags = [ rustflags = [
"--cfg", "--cfg=tokio_unstable",
"tokio_unstable", "--cfg=tracing_unstable",
"-Zshare-generics=y", "-Zshare-generics=y",
"-Zthreads=8", "-Zthreads=8",
"-Csymbol-mangling-version=v0", "-Csymbol-mangling-version=v0",
...@@ -73,4 +73,4 @@ rustflags = [ ...@@ -73,4 +73,4 @@ rustflags = [
linker = "arm-linux-gnueabihf-gcc" linker = "arm-linux-gnueabihf-gcc"
[target.wasm32-unknown-unknown] [target.wasm32-unknown-unknown]
rustflags = ["-Zshare-generics=y", "--cfg", 'getrandom_backend="wasm_js"'] rustflags = ["-Zshare-generics=y", '--cfg=getrandom_backend="wasm_js"']
\ No newline at end of file
...@@ -4313,6 +4313,7 @@ dependencies = [ ...@@ -4313,6 +4313,7 @@ dependencies = [
"turbopack-nodejs", "turbopack-nodejs",
"turbopack-static", "turbopack-static",
"turbopack-trace-utils", "turbopack-trace-utils",
"valuable",
] ]
[[package]] [[package]]
...@@ -9104,6 +9105,7 @@ dependencies = [ ...@@ -9104,6 +9105,7 @@ dependencies = [
"shrink-to-fit", "shrink-to-fit",
"triomphe 0.1.12", "triomphe 0.1.12",
"turbo-tasks-hash", "turbo-tasks-hash",
"valuable",
] ]
[[package]] [[package]]
...@@ -9165,6 +9167,7 @@ dependencies = [ ...@@ -9165,6 +9167,7 @@ dependencies = [
"turbo-tasks-macros", "turbo-tasks-macros",
"turbo-tasks-malloc", "turbo-tasks-malloc",
"unsize", "unsize",
"valuable",
] ]
[[package]] [[package]]
...@@ -10243,9 +10246,9 @@ dependencies = [ ...@@ -10243,9 +10246,9 @@ dependencies = [
[[package]] [[package]]
name = "valuable" name = "valuable"
version = "0.1.0" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
[[package]] [[package]]
name = "vcpkg" name = "vcpkg"
......
...@@ -437,12 +437,13 @@ thread_local = "1.1.8" ...@@ -437,12 +437,13 @@ thread_local = "1.1.8"
thiserror = "1.0.48" thiserror = "1.0.48"
tokio = "1.43.0" tokio = "1.43.0"
tokio-util = { version = "0.7.13", features = ["io", "rt"] } tokio-util = { version = "0.7.13", features = ["io", "rt"] }
tracing = "0.1.37" tracing = { version = "0.1.37", features = ["valuable"] }
tracing-subscriber = "0.3.16" tracing-subscriber = "0.3.16"
triomphe = { git = "https://github.com/sokra/triomphe", branch = "sokra/unstable" } triomphe = { git = "https://github.com/sokra/triomphe", branch = "sokra/unstable" }
unsize = "1.1.0" unsize = "1.1.0"
url = "2.2.2" url = "2.2.2"
urlencoding = "2.1.2" urlencoding = "2.1.2"
valuable = "0.1.1"
vergen = { version = "9.0.6", features = ["cargo"] } vergen = { version = "9.0.6", features = ["cargo"] }
vergen-gitcl = { version = "1.0.8", features = ["cargo"] } vergen-gitcl = { version = "1.0.8", features = ["cargo"] }
webbrowser = "0.8.7" webbrowser = "0.8.7"
......
...@@ -55,6 +55,7 @@ swc_core = { workspace = true, features = [ ...@@ -55,6 +55,7 @@ swc_core = { workspace = true, features = [
"ecma_visit", "ecma_visit",
] } ] }
modularize_imports = { workspace = true } modularize_imports = { workspace = true }
valuable = { workspace = true }
next-custom-transforms = { workspace = true } next-custom-transforms = { workspace = true }
next-taskless = { workspace = true } next-taskless = { workspace = true }
......
...@@ -33,6 +33,7 @@ use turbopack_ecmascript::{ ...@@ -33,6 +33,7 @@ use turbopack_ecmascript::{
source_map::parse_source_map_comment, source_map::parse_source_map_comment,
utils::StringifyJs, utils::StringifyJs,
}; };
use valuable::Valuable;
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
pub struct RawEcmascriptModuleType {} pub struct RawEcmascriptModuleType {}
...@@ -169,7 +170,7 @@ impl EcmascriptChunkItem for RawEcmascriptChunkItem { ...@@ -169,7 +170,7 @@ impl EcmascriptChunkItem for RawEcmascriptChunkItem {
async fn content(&self) -> Result<Vc<EcmascriptChunkItemContent>> { async fn content(&self) -> Result<Vc<EcmascriptChunkItemContent>> {
let span = tracing::info_span!( let span = tracing::info_span!(
"code generation raw module", "code generation raw module",
name = display(self.module.ident().to_string().await?) name = &self.module.ident().to_string().await?.as_value(),
); );
async { async {
......
...@@ -17,6 +17,7 @@ new_debug_unreachable = "1.0.6" ...@@ -17,6 +17,7 @@ new_debug_unreachable = "1.0.6"
shrink-to-fit = { workspace = true } shrink-to-fit = { workspace = true }
rustc-hash = { workspace = true } rustc-hash = { workspace = true }
bytes-str = { workspace = true } bytes-str = { workspace = true }
valuable = { workspace = true }
[target.'cfg(not(target_family = "wasm"))'.dependencies] [target.'cfg(not(target_family = "wasm"))'.dependencies]
napi = { workspace = true, optional = true } napi = { workspace = true, optional = true }
......
...@@ -15,6 +15,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; ...@@ -15,6 +15,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use shrink_to_fit::ShrinkToFit; use shrink_to_fit::ShrinkToFit;
use triomphe::Arc; use triomphe::Arc;
use turbo_tasks_hash::{DeterministicHash, DeterministicHasher}; use turbo_tasks_hash::{DeterministicHash, DeterministicHasher};
use valuable::Valuable;
use crate::{ use crate::{
dynamic::{deref_from, hash_bytes, new_atom}, dynamic::{deref_from, hash_bytes, new_atom},
...@@ -269,6 +270,16 @@ impl Display for RcStr { ...@@ -269,6 +270,16 @@ impl Display for RcStr {
} }
} }
impl Valuable for RcStr {
fn as_value(&self) -> valuable::Value<'_> {
valuable::Value::String(self.as_str())
}
fn visit(&self, visit: &mut dyn valuable::Visit) {
visit.visit_value(valuable::Value::String(self.as_str()));
}
}
impl From<RcStr> for String { impl From<RcStr> for String {
fn from(s: RcStr) -> Self { fn from(s: RcStr) -> Self {
s.into_owned() s.into_owned()
......
...@@ -31,6 +31,7 @@ erased-serde = { workspace = true } ...@@ -31,6 +31,7 @@ erased-serde = { workspace = true }
event-listener = "5.4.0" event-listener = "5.4.0"
futures = { workspace = true } futures = { workspace = true }
indexmap = { workspace = true, features = ["serde"] } indexmap = { workspace = true, features = ["serde"] }
inventory = { workspace = true }
mopa = "0.2.0" mopa = "0.2.0"
once_cell = { workspace = true } once_cell = { workspace = true }
parking_lot = { workspace = true, features = ["serde"]} parking_lot = { workspace = true, features = ["serde"]}
...@@ -54,5 +55,5 @@ turbo-tasks-hash = { workspace = true } ...@@ -54,5 +55,5 @@ turbo-tasks-hash = { workspace = true }
turbo-tasks-macros = { workspace = true } turbo-tasks-macros = { workspace = true }
turbo-tasks-malloc = { workspace = true } turbo-tasks-malloc = { workspace = true }
unsize = { workspace = true } unsize = { workspace = true }
inventory = { workspace = true } valuable = { workspace = true }
...@@ -9,6 +9,7 @@ use std::{ ...@@ -9,6 +9,7 @@ use std::{
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_tasks_hash::DeterministicHash; use turbo_tasks_hash::DeterministicHash;
use valuable::Valuable;
use crate::{ use crate::{
SharedReference, Vc, VcRead, VcValueType, SharedReference, Vc, VcRead, VcValueType,
...@@ -54,6 +55,20 @@ where ...@@ -54,6 +55,20 @@ where
} }
} }
impl<T> Valuable for ReadRef<T>
where
T: VcValueType,
VcReadTarget<T>: Valuable,
{
fn as_value(&self) -> valuable::Value<'_> {
VcReadTarget::<T>::as_value(&**self)
}
fn visit(&self, visit: &mut dyn valuable::Visit) {
VcReadTarget::<T>::visit(&**self, visit)
}
}
impl<T> Debug for ReadRef<T> impl<T> Debug for ReadRef<T>
where where
T: Debug, T: Debug,
......
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