diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/string_cache | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/string_cache')
-rw-r--r-- | vendor/string_cache/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/string_cache/Cargo.lock | 134 | ||||
-rw-r--r-- | vendor/string_cache/Cargo.toml | 13 | ||||
-rw-r--r-- | vendor/string_cache/src/atom.rs | 9 | ||||
-rw-r--r-- | vendor/string_cache/src/dynamic_set.rs | 48 |
5 files changed, 122 insertions, 84 deletions
diff --git a/vendor/string_cache/.cargo-checksum.json b/vendor/string_cache/.cargo-checksum.json index 39023d295..36ae27f58 100644 --- a/vendor/string_cache/.cargo-checksum.json +++ b/vendor/string_cache/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.lock":"ca63167cb0772820bf3ea4ab32bc915e4f9732dab7521bd9c6da068ff83ed4dc","Cargo.toml":"913fff4dae8e06b0384fd26b7d3b1305a74ebed08364ad3548a03a9298f67cb0","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"d13530e5e0d72b9106c735c276f88fd11aeaaccb404dda75a74d2cfafbf59268","examples/simple.rs":"227cbe14cdb0cb710a259707144b259684e9576615247628b8d57c895dd8c538","src/atom.rs":"f8c1a75cac54254633497fed370396efa62c2b82a3c9c629ec6ae598c44ea321","src/dynamic_set.rs":"c10c776a76b97facb9de03de9ad6c923bb6e64757f37941d7bd3458b32f53470","src/lib.rs":"844ad2b53bde6f0d65650b9b034b91bdcece1ac285c0f2a97fea04382b6917e2","src/static_sets.rs":"0d91d476b5277cf3cbbcd0c9f18cc5286086fecf59654115efab5090862ec8e8","src/trivial_impls.rs":"ba12375f21c5f033a52bdf10dd6ab366702e1d68954aa012fc90cc7efc2a5ed3","tests/small-stack.rs":"f3c8dd5f38eba6e41aa44fe7a4af3a2a2e5bfc0a1fb938e76319d9780956177c"},"package":"33994d0838dc2d152d17a62adf608a869b5e846b65b389af7f3dbc1de45c5b26"}
\ No newline at end of file +{"files":{"Cargo.lock":"b48cc34d0fa6616630f3e62c88929f230cee804755ee54f19e8d4dfab2f82aa7","Cargo.toml":"c7a9d4ccbdab45b0e18d85a7218000329e04d2bddb502dcedcf8ff0f8c382907","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"d13530e5e0d72b9106c735c276f88fd11aeaaccb404dda75a74d2cfafbf59268","examples/simple.rs":"227cbe14cdb0cb710a259707144b259684e9576615247628b8d57c895dd8c538","src/atom.rs":"d91ea4f98f171a6b7ab13e9dbb91bf280ada81dda746d16ade349ba9aa81b909","src/dynamic_set.rs":"e1308168a077578be1eb0e2a5d804c368b91a5f06d47deacd03ea0867bbb0334","src/lib.rs":"844ad2b53bde6f0d65650b9b034b91bdcece1ac285c0f2a97fea04382b6917e2","src/static_sets.rs":"0d91d476b5277cf3cbbcd0c9f18cc5286086fecf59654115efab5090862ec8e8","src/trivial_impls.rs":"ba12375f21c5f033a52bdf10dd6ab366702e1d68954aa012fc90cc7efc2a5ed3","tests/small-stack.rs":"f3c8dd5f38eba6e41aa44fe7a4af3a2a2e5bfc0a1fb938e76319d9780956177c"},"package":"f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b"}
\ No newline at end of file diff --git a/vendor/string_cache/Cargo.lock b/vendor/string_cache/Cargo.lock index b7e316bc8..59518bef5 100644 --- a/vendor/string_cache/Cargo.lock +++ b/vendor/string_cache/Cargo.lock @@ -3,10 +3,16 @@ version = 3 [[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] name = "bitflags" -version = "1.3.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" [[package]] name = "cfg-if" @@ -15,32 +21,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "lazy_static" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" - -[[package]] name = "libc" -version = "0.2.117" +version = "0.2.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" +checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" [[package]] name = "lock_api" -version = "0.4.6" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ + "autocfg", "scopeguard", ] @@ -51,28 +43,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40f005c60db6e03bae699e414c58bf9aa7ea02a2d0b9bfbcf19286cc4c82b30" [[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", - "instant", "libc", "redox_syscall", "smallvec", - "winapi", + "windows-sys", ] [[package]] @@ -107,28 +103,28 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe5626ac617da2f2d9c48af5515a21d5a480dbd151e01bb1c355e26a3e68113" +checksum = "fec2851eb56d010dc9a21b89ca53ee75e6528bab60c11e89d38390904982da9f" [[package]] name = "siphasher" -version = "0.3.1" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83da420ee8d1a89e640d0948c646c1c088758d3a3c538f943bfa97bdac17929d" +checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b" [[package]] name = "smallvec" -version = "1.8.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "string_cache" -version = "0.8.3" +version = "0.8.7" dependencies = [ - "lazy_static", "new_debug_unreachable", + "once_cell", "parking_lot", "phf_shared", "precomputed-hash", @@ -136,23 +132,67 @@ dependencies = [ ] [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-sys" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows-targets", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows_x86_64_msvc" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" diff --git a/vendor/string_cache/Cargo.toml b/vendor/string_cache/Cargo.toml index f5f17fa9f..e74053006 100644 --- a/vendor/string_cache/Cargo.toml +++ b/vendor/string_cache/Cargo.toml @@ -12,11 +12,12 @@ [package] edition = "2018" name = "string_cache" -version = "0.8.3" +version = "0.8.7" authors = ["The Servo Project Developers"] description = "A string interning library for Rust, developed as part of the Servo project." documentation = "https://docs.rs/string_cache/" -license = "MIT / Apache-2.0" +readme = "README.md" +license = "MIT OR Apache-2.0" repository = "https://github.com/servo/string-cache" [lib] @@ -26,14 +27,14 @@ name = "string_cache" name = "small-stack" harness = false -[dependencies.lazy_static] -version = "1.1.0" - [dependencies.new_debug_unreachable] version = "1.0.2" +[dependencies.once_cell] +version = "1.10.0" + [dependencies.parking_lot] -version = "0.11" +version = "0.12" [dependencies.phf_shared] version = "0.10" diff --git a/vendor/string_cache/src/atom.rs b/vendor/string_cache/src/atom.rs index c02651b31..321b0a40e 100644 --- a/vendor/string_cache/src/atom.rs +++ b/vendor/string_cache/src/atom.rs @@ -105,7 +105,7 @@ impl<Static> Atom<Static> { } impl<Static: StaticAtomSet> Atom<Static> { - /// Return the internal repersentation. For testing. + /// Return the internal representation. For testing. #[doc(hidden)] pub fn unsafe_data(&self) -> u64 { self.unsafe_data.get() @@ -200,8 +200,7 @@ impl<'a, Static: StaticAtomSet> From<Cow<'a, str>> for Atom<Static> { phantom: PhantomData, } } else { - let ptr: std::ptr::NonNull<Entry> = - DYNAMIC_SET.lock().insert(string_to_add, hash.g); + let ptr: std::ptr::NonNull<Entry> = DYNAMIC_SET.insert(string_to_add, hash.g); let data = ptr.as_ptr() as u64; debug_assert!(0 == data & TAG_MASK); Atom { @@ -237,9 +236,7 @@ impl<Static> Drop for Atom<Static> { // Out of line to guide inlining. fn drop_slow<Static>(this: &mut Atom<Static>) { - DYNAMIC_SET - .lock() - .remove(this.unsafe_data.get() as *mut Entry); + DYNAMIC_SET.remove(this.unsafe_data.get() as *mut Entry); } } } diff --git a/vendor/string_cache/src/dynamic_set.rs b/vendor/string_cache/src/dynamic_set.rs index 602b700c8..46e7a5452 100644 --- a/vendor/string_cache/src/dynamic_set.rs +++ b/vendor/string_cache/src/dynamic_set.rs @@ -7,7 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use parking_lot::Mutex; use std::borrow::Cow; use std::mem; @@ -19,7 +19,7 @@ const NB_BUCKETS: usize = 1 << 12; // 4096 const BUCKET_MASK: u32 = (1 << 12) - 1; pub(crate) struct Set { - buckets: Box<[Option<Box<Entry>>; NB_BUCKETS]>, + buckets: Box<[Mutex<Option<Box<Entry>>>]>, } pub(crate) struct Entry { @@ -38,22 +38,24 @@ fn entry_alignment_is_sufficient() { assert!(mem::align_of::<Entry>() >= ENTRY_ALIGNMENT); } -lazy_static! { - pub(crate) static ref DYNAMIC_SET: Mutex<Set> = Mutex::new({ - type T = Option<Box<Entry>>; - let _static_assert_size_eq = std::mem::transmute::<T, usize>; - let vec = std::mem::ManuallyDrop::new(vec![0_usize; NB_BUCKETS]); - Set { - buckets: unsafe { Box::from_raw(vec.as_ptr() as *mut [T; NB_BUCKETS]) }, - } - }); -} +pub(crate) static DYNAMIC_SET: Lazy<Set> = Lazy::new(|| { + // NOTE: Using const initialization for buckets breaks the small-stack test. + // ``` + // // buckets: [Mutex<Option<Box<Entry>>>; NB_BUCKETS], + // const MUTEX: Mutex<Option<Box<Entry>>> = Mutex::new(None); + // let buckets = Box::new([MUTEX; NB_BUCKETS]); + // ``` + let buckets = (0..NB_BUCKETS).map(|_| Mutex::new(None)).collect(); + Set { buckets } +}); impl Set { - pub(crate) fn insert(&mut self, string: Cow<str>, hash: u32) -> NonNull<Entry> { + pub(crate) fn insert(&self, string: Cow<str>, hash: u32) -> NonNull<Entry> { let bucket_index = (hash & BUCKET_MASK) as usize; + let mut linked_list = self.buckets[bucket_index].lock(); + { - let mut ptr: Option<&mut Box<Entry>> = self.buckets[bucket_index].as_mut(); + let mut ptr: Option<&mut Box<Entry>> = linked_list.as_mut(); while let Some(entry) = ptr.take() { if entry.hash == hash && *entry.string == *string { @@ -74,25 +76,23 @@ impl Set { debug_assert!(mem::align_of::<Entry>() >= ENTRY_ALIGNMENT); let string = string.into_owned(); let mut entry = Box::new(Entry { - next_in_bucket: self.buckets[bucket_index].take(), + next_in_bucket: linked_list.take(), hash, ref_count: AtomicIsize::new(1), string: string.into_boxed_str(), }); let ptr = NonNull::from(&mut *entry); - self.buckets[bucket_index] = Some(entry); - + *linked_list = Some(entry); ptr } - pub(crate) fn remove(&mut self, ptr: *mut Entry) { - let bucket_index = { - let value: &Entry = unsafe { &*ptr }; - debug_assert!(value.ref_count.load(SeqCst) == 0); - (value.hash & BUCKET_MASK) as usize - }; + pub(crate) fn remove(&self, ptr: *mut Entry) { + let value: &Entry = unsafe { &*ptr }; + let bucket_index = (value.hash & BUCKET_MASK) as usize; - let mut current: &mut Option<Box<Entry>> = &mut self.buckets[bucket_index]; + let mut linked_list = self.buckets[bucket_index].lock(); + debug_assert!(value.ref_count.load(SeqCst) == 0); + let mut current: &mut Option<Box<Entry>> = &mut linked_list; while let Some(entry_ptr) = current.as_mut() { let entry_ptr: *mut Entry = &mut **entry_ptr; |