diff --git a/Cargo.lock b/Cargo.lock index 6a83cb9f6..ab513baaa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -451,17 +451,19 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "comemo" version = "0.4.0" -source = "git+https://github.com/typst/comemo?rev=60b30c6#60b30c6ae54f3c940dc4f778ca5090bd2a42a72e" +source = "git+https://github.com/typst/comemo?rev=4b949e2#4b949e2c4f1ac5a6d31c73f06daf290d880ff509" dependencies = [ + "bumpalo", "comemo-macros", "parking_lot", "siphasher", + "slab", ] [[package]] name = "comemo-macros" version = "0.4.0" -source = "git+https://github.com/typst/comemo?rev=60b30c6#60b30c6ae54f3c940dc4f778ca5090bd2a42a72e" +source = "git+https://github.com/typst/comemo?rev=4b949e2#4b949e2c4f1ac5a6d31c73f06daf290d880ff509" dependencies = [ "proc-macro2", "quote", @@ -2496,6 +2498,12 @@ dependencies = [ "read-fonts", ] +[[package]] +name = "slab" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" + [[package]] name = "slotmap" version = "1.0.7" diff --git a/Cargo.toml b/Cargo.toml index 5e169f295..4c7b9363d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -165,4 +165,4 @@ uninlined_format_args = "warn" wildcard_in_or_patterns = "allow" [patch.crates-io] -comemo = { git = "https://github.com/typst/comemo", rev = "60b30c6" } +comemo = { git = "https://github.com/typst/comemo", rev = "4b949e2" } diff --git a/crates/typst-library/src/engine.rs b/crates/typst-library/src/engine.rs index cb98f4599..27f03a31f 100644 --- a/crates/typst-library/src/engine.rs +++ b/crates/typst-library/src/engine.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; use std::sync::atomic::{AtomicUsize, Ordering}; -use comemo::{Track, Tracked, TrackedMut, Validate}; +use comemo::{Track, Tracked, TrackedMut}; use ecow::EcoVec; use rayon::iter::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator}; use typst_syntax::{FileId, Span}; @@ -219,7 +219,7 @@ pub struct Route<'a> { // We need to override the constraint's lifetime here so that `Tracked` is // covariant over the constraint. If it becomes invariant, we're in for a // world of lifetime pain. - outer: Option as Validate>::Constraint>>, + outer: Option as Track>::Call>>, /// This is set if this route segment was inserted through the start of a /// module evaluation. id: Option, diff --git a/crates/typst-library/src/introspection/locator.rs b/crates/typst-library/src/introspection/locator.rs index 3ba3d6486..2d07619b9 100644 --- a/crates/typst-library/src/introspection/locator.rs +++ b/crates/typst-library/src/introspection/locator.rs @@ -3,7 +3,7 @@ use std::fmt::{self, Debug, Formatter}; use std::hash::Hash; use std::sync::OnceLock; -use comemo::{Tracked, Validate}; +use comemo::{Track, Tracked}; use crate::introspection::{Introspector, Location}; @@ -312,7 +312,7 @@ enum LinkKind<'a> { /// We need to override the constraint's lifetime here so that `Tracked` is /// covariant over the constraint. If it becomes invariant, we're in for a /// world of lifetime pain. - Outer(Tracked<'a, Locator<'a>, as Validate>::Constraint>), + Outer(Tracked<'a, Locator<'a>, as Track>::Call>), /// A link which indicates that we are in measurement mode. Measure(Location), } diff --git a/crates/typst/src/lib.rs b/crates/typst/src/lib.rs index 47e5531fd..7ee8c19a4 100644 --- a/crates/typst/src/lib.rs +++ b/crates/typst/src/lib.rs @@ -39,9 +39,9 @@ pub use typst_syntax as syntax; pub use typst_utils as utils; use std::collections::HashSet; -use std::sync::LazyLock; +use std::sync::{LazyLock, Mutex}; -use comemo::{Track, Tracked, Validate}; +use comemo::{Track, Tracked}; use ecow::{EcoString, EcoVec, eco_format, eco_vec}; use typst_html::HtmlDocument; use typst_library::diag::{ @@ -135,10 +135,11 @@ fn compile_impl( subsink = Sink::new(); - let constraint = ::Constraint::new(); + let constraint = Mutex::new(comemo::Constraint::new()); + let push = |call, ret| constraint.lock().unwrap().push(call, ret); let mut engine = Engine { world, - introspector: introspector.track_with(&constraint), + introspector: introspector.track_with(&push), traced, sink: subsink.track_mut(), route: Route::default(), @@ -150,7 +151,10 @@ fn compile_impl( introspector = document.introspector(); iter += 1; - if timed!("check stabilized", introspector.validate(&constraint)) { + if timed!( + "check stabilized", + constraint.into_inner().unwrap().validate(introspector) + ) { break; }