Skip to content

Commit

Permalink
Bump dependencies with breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed Nov 21, 2024
1 parent f7f8470 commit 12722eb
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 315 deletions.
543 changes: 299 additions & 244 deletions Cargo.lock

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ bitflags = "2.5.0"
clap = "4.5.21"
colored = "2.1.0"
fast-float = "0.2.0"
hashbrown = { version = "0.14.5", default-features = false }
hashbrown = "0.15.1"
indexmap = { version = "2.6.0", default-features = false }
indoc = "2.0.5"
jemallocator = "0.5.4"
num-bigint = "0.4.6"
num-traits = "0.2.19"
once_cell = { version = "1.20.2", default-features = false }
phf = { version = "0.11.2", default-features = false }
pollster = "0.3.0"
pollster = "0.4.0"
regex = "1.11.1"
regress = { version = "0.10.1", features = ["utf16"] }
rustc-hash = { version = "2.0.0", default-features = false }
Expand All @@ -72,7 +72,7 @@ time = { version = "0.3.36", default-features = false, features = ["local-offset
tinystr = "0.7.5"
log = "0.4.22"
simple_logger = "5.0.0"
cargo_metadata = "0.18.1"
cargo_metadata = "0.19.0"
trybuild = "1.0.101"
rayon = "1.10.0"
toml = "0.8.19"
Expand All @@ -87,21 +87,21 @@ wasm-bindgen-test = "0.3.45"
smol = "2.0.2"
futures-util = "0.3.31"
isahc = "1.7.2"
rustyline = { version = "14.0.0", default-features = false }
rustyline = { version = "15.0.0", default-features = false }
dhat = "0.3.3"
quote = "1.0.37"
syn = { version = "2.0.87", default-features = false }
syn = { version = "2.0.89", default-features = false }
proc-macro2 = "1.0"
synstructure = "0.13"
measureme = "11.0.1"
measureme = "12.0.0"
sptr = "0.3.2"
paste = "1.0"
rand = "0.8.5"
num-integer = "0.1.46"
ryu-js = "1.0.1"
tap = "1.0.1"
thiserror = "1.0.69"
dashmap = "5.5.3"
thiserror = { version = "2.0.3", default-features = false }
dashmap = "6.1.0"
num_enum = "0.7.3"
itertools = { version = "0.13.0", default-features = false }
portable-atomic = "1.9.0"
Expand All @@ -114,10 +114,11 @@ sys-locale = "0.3.2"
temporal_rs = { git = "https://github.com/boa-dev/temporal.git", rev = "1e7901d07a83211e62373ab94284a7d1ada4c913" }
web-time = "1.1.0"
criterion = "0.5.1"
float-cmp = "0.9.0"
float-cmp = "0.10.0"
futures-lite = "2.5.0"
test-case = "3.3.1"
winapi = { version = "0.3.9", default-features = false }
url = "2.5.3"

# ICU4X

Expand Down
4 changes: 2 additions & 2 deletions cli/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use phf::{phf_set, Set};
use regex::{Captures, Regex, Replacer};
use rustyline::{
error::ReadlineError,
highlight::Highlighter,
highlight::{CmdKind, Highlighter},
validate::{MatchingBracketValidator, ValidationContext, ValidationResult, Validator},
Completer, Helper, Hinter,
};
Expand Down Expand Up @@ -97,7 +97,7 @@ impl Highlighter for RLHelper {
self.highlighter.highlight(candidate, 0)
}

fn highlight_char(&self, line: &str, _: usize, _: bool) -> bool {
fn highlight_char(&self, line: &str, _: usize, _: CmdKind) -> bool {
!line.is_empty()
}
}
Expand Down
24 changes: 12 additions & 12 deletions core/engine/src/host_defined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ impl HostDefined {
.and_then(<dyn NativeObject>::downcast_mut::<T>)
}

/// Get type a tuple of types from [`HostDefined`], if they exist.
/// Get a tuple of types from [`HostDefined`], returning `None` for the types that are not on the map.
#[track_caller]
pub fn get_many_mut<T, const SIZE: usize>(&mut self) -> Option<T::NativeTupleMutRef<'_>>
pub fn get_many_mut<T, const SIZE: usize>(&mut self) -> T::NativeTupleMutRef<'_>
where
T: NativeTuple<SIZE>,
{
let ids = T::as_type_ids();
let refs: [&TypeId; SIZE] = std::array::from_fn(|i| &ids[i]);

self.types.get_many_mut(refs).and_then(T::mut_ref_from_anys)
T::mut_ref_from_anys(self.types.get_many_mut(refs))
}

/// Clears all the objects.
Expand All @@ -109,27 +109,27 @@ pub trait NativeTuple<const SIZE: usize> {
fn as_type_ids() -> [TypeId; SIZE];

fn mut_ref_from_anys(
anys: [&'_ mut Box<dyn NativeObject>; SIZE],
) -> Option<Self::NativeTupleMutRef<'_>>;
anys: [Option<&'_ mut Box<dyn NativeObject>>; SIZE],
) -> Self::NativeTupleMutRef<'_>;
}

macro_rules! impl_native_tuple {
($size:literal $(,$name:ident)* ) => {
impl<$($name: NativeObject,)*> NativeTuple<$size> for ($($name,)*) {
type NativeTupleMutRef<'a> = ($(&'a mut $name,)*);
type NativeTupleMutRef<'a> = ($(Option<&'a mut $name>,)*);

fn as_type_ids() -> [TypeId; $size] {
[$(TypeId::of::<$name>(),)*]
}

#[allow(unused_variables, unused_mut, clippy::unused_unit)]
fn mut_ref_from_anys(
anys: [&'_ mut Box<dyn NativeObject>; $size],
) -> Option<Self::NativeTupleMutRef<'_>> {
#[allow(unused_variables, unused_mut)]
anys: [Option<&'_ mut Box<dyn NativeObject>>; $size],
) -> Self::NativeTupleMutRef<'_> {
let mut anys = anys.into_iter();
Some(($(
anys.next().expect("Expect `anys` to be of length `SIZE`").downcast_mut::<$name>()?,
)*))
($(
anys.next().flatten().and_then(|v| v.downcast_mut::<$name>()),
)*)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/gc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ boa_string = ["dep:boa_string"]
[dependencies]
boa_profiler.workspace = true
boa_macros.workspace = true
hashbrown = { workspace = true, features = ["ahash", "raw"] }
hashbrown.workspace = true

boa_string = { workspace = true, optional = true }
thin-vec = { workspace = true, optional = true }
Expand Down
72 changes: 29 additions & 43 deletions core/gc/src/pointers/weak_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// but with some adjustments to use `Ephemeron<K,V>` instead of `(K,V)`

use hashbrown::{
hash_map::DefaultHashBuilder,
raw::{RawIter, RawTable},
TryReserveError,
hash_table::{Entry as RawEntry, Iter as RawIter},
DefaultHashBuilder, HashTable, TryReserveError,
};

use crate::{custom_trace, Allocator, Ephemeron, Finalize, Gc, GcRefCell, Trace};
use std::{fmt, hash::BuildHasher, marker::PhantomData, mem};
use std::{fmt, hash::BuildHasher, marker::PhantomData};

/// A map that holds weak references to its keys and is traced by the garbage collector.
#[derive(Clone, Debug, Default, Finalize)]
Expand Down Expand Up @@ -68,7 +67,7 @@ where
V: Trace + 'static,
{
hash_builder: S,
table: RawTable<Ephemeron<K, V>>,
table: HashTable<Ephemeron<K, V>>,
}

impl<K, V, S> Finalize for RawWeakMap<K, V, S>
Expand Down Expand Up @@ -138,7 +137,7 @@ where
pub(crate) const fn with_hasher(hash_builder: S) -> Self {
Self {
hash_builder,
table: RawTable::new(),
table: HashTable::new(),
}
}

Expand All @@ -150,7 +149,7 @@ where
pub(crate) fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self {
Self {
hash_builder,
table: RawTable::with_capacity(capacity),
table: HashTable::with_capacity(capacity),
}
}

Expand All @@ -172,12 +171,9 @@ where
/// An iterator visiting all entries in arbitrary order.
/// The iterator element type is <code>[Ephemeron]<K, V></code>.
pub(crate) fn iter(&self) -> Iter<'_, K, V> {
// SAFETY: The returned iterator is tied to the lifetime of self.
unsafe {
Iter {
inner: self.table.iter(),
marker: PhantomData,
}
Iter {
inner: self.table.iter(),
marker: PhantomData,
}
}

Expand Down Expand Up @@ -212,14 +208,7 @@ where
// SAFETY:
// - `item` is only used internally, which means it outlives self.
// - `item` pointer is not used after the call to `erase`.
unsafe {
for item in self.table.iter() {
let eph = item.as_ref();
if !f(eph) {
self.table.erase(item);
}
}
}
self.table.retain(|item| f(item));
}

/// Clears the map, removing all key-value pairs. Keeps the allocated memory
Expand Down Expand Up @@ -293,7 +282,7 @@ where
None
} else {
let hash = make_hash_from_gc(&self.hash_builder, k);
self.table.get(hash, equivalent_key(k))?.value()
self.table.find(hash, equivalent_key(k))?.value()
}
}

Expand All @@ -311,30 +300,29 @@ where
pub(crate) fn insert(&mut self, k: &Gc<K>, v: V) -> Option<Ephemeron<K, V>> {
let hash = make_hash_from_gc(&self.hash_builder, k);
let hasher = make_hasher(&self.hash_builder);
let eph = Ephemeron::new(k, v);
match self
.table
.find_or_find_insert_slot(hash, equivalent_key(k), hasher)
{
// SAFETY: `bucket` is only used inside the replace call, meaning it doesn't
// outlive self.
Ok(bucket) => Some(mem::replace(unsafe { bucket.as_mut() }, eph)),
Err(slot) => {
// SAFETY: `slot` comes from a call to `find_or_find_insert_slot`, and `self`
// is not mutated until the call to `insert_in_slot`.
unsafe {
self.table.insert_in_slot(hash, slot, eph);
}
None
let entry = self.table.entry(hash, equivalent_key(k), hasher);
let (old, slot) = match entry {
RawEntry::Occupied(occupied_entry) => {
let (v, slot) = occupied_entry.remove();
(Some(v), slot)
}
}
RawEntry::Vacant(vacant_entry) => (None, vacant_entry),
};

slot.insert(Ephemeron::new(k, v));
old
}

/// Removes a key from the map, returning the value at the key if the key
/// was previously in the map. Keeps the allocated memory for reuse.
pub(crate) fn remove(&mut self, k: &Gc<K>) -> Option<V> {
let hash = make_hash_from_gc(&self.hash_builder, k);
self.table.remove_entry(hash, equivalent_key(k))?.value()
self.table
.find_entry(hash, equivalent_key(k))
.ok()?
.remove()
.0
.value()
}

/// Clears all the expired keys in the map.
Expand All @@ -348,7 +336,7 @@ where
K: Trace + ?Sized + 'static,
V: Trace + 'static,
{
inner: RawIter<Ephemeron<K, V>>,
inner: RawIter<'a, Ephemeron<K, V>>,
marker: PhantomData<&'a Ephemeron<K, V>>,
}

Expand Down Expand Up @@ -386,9 +374,7 @@ where

#[inline]
fn next(&mut self) -> Option<Self::Item> {
// SAFETY: The original map outlives the iterator thanks to the lifetime parameter,
// and since the returned ephemeron carries that information, the call to `as_ref` is safe.
unsafe { self.inner.next().map(|b| b.as_ref()) }
self.inner.next()
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion core/interner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ once_cell = { workspace = true, features = ["std"]}
indexmap.workspace = true
serde = { workspace = true, features = ["derive"], optional = true }
arbitrary = { workspace = true, features = ["derive"], optional = true }
hashbrown = { workspace = true, default-features = false, features = ["inline-more"] }
hashbrown.workspace = true

[lints]
workspace = true
Expand Down
3 changes: 2 additions & 1 deletion core/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ boa_engine.workspace = true
boa_gc.workspace = true
boa_interop.workspace = true
rustc-hash = { workspace = true, features = ["std"] }
url = { version = "2.5.3", optional = true }
url = { workspace = true, optional = true }

[dev-dependencies]
indoc.workspace = true
Expand All @@ -30,3 +30,4 @@ all-features = true
[features]
default = ["all"]
all = ["url"]
url = ["dep:url"]
4 changes: 2 additions & 2 deletions examples/src/bin/host_defined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ fn main() -> Result<(), JsError> {
let value: usize = args.get_or_undefined(0).try_js_into(context)?;

let mut host_defined = context.realm().host_defined_mut();
let Some((host_defined, metrics)) =
let (Some(host_defined), Some(metrics)) =
host_defined.get_many_mut::<(CustomHostDefinedStruct, HostDefinedMetrics), 2>()
else {
return Err(JsNativeError::typ()
.with_message("Realm does not have HostDefined field")
.with_message("Realm does not have HostDefined fields")
.into());
};

Expand Down

0 comments on commit 12722eb

Please sign in to comment.