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