Skip to content

DO NOT REVIEW - WIP coop-rs/rust:02_vec #107274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 80 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
05b7b18
START CoAlloc API
peter-lyons-kehl Jan 21, 2023
406e8a3
CoAlloc: RawVec + compiler 'tests'
peter-lyons-kehl Jan 21, 2023
7de7aff
CoAlloc: GlobalAlloc API
peter-lyons-kehl Dec 10, 2022
4a72a96
CoAlloc: Alloc API
peter-lyons-kehl Jan 21, 2023
e1114cc
CoAlloc: RawVec includes GlobalCoAllocMeta based on allocator; relate…
peter-lyons-kehl Jan 21, 2023
0db8c6f
CoAlloc: VecDeque (PROBABLY NOT COMPILING, standard error)
peter-lyons-kehl Jan 21, 2023
1e4e3ee
CoAlloc: RawVec + Vec with COOP_PREFERRED. PROBABLY NOT COMPILING, bu…
peter-lyons-kehl Jan 22, 2023
8ae4cf0
VecDeque with COOP_PREFERRED. PROBABLY NOT COMPILING, but no ICE.
peter-lyons-kehl Jan 22, 2023
37a0847
CoAlloc: RawVec, Vec, Box uses bounds. ICE
peter-lyons-kehl Jan 22, 2023
b0dd71c
CoAlloc: BinaryHeap now uses bounds. (Probably needs to go together w…
peter-lyons-kehl Jan 22, 2023
b7c43ec
CoAlloc: VecDeque now uses bounds. ICE
peter-lyons-kehl Jan 22, 2023
33c42a4
CoAlloc: VecDeque. Probably ICE.
peter-lyons-kehl Jan 22, 2023
b221045
CoAlloc: Vec + Slice. ICE
peter-lyons-kehl Jan 22, 2023
6ee4ede
CoAlloc: VecDeque. ICE
peter-lyons-kehl Jan 22, 2023
eeb4214
CoAlloc: Minor
peter-lyons-kehl Jan 22, 2023
6c3801d
CoAlloc: Vec + its use cases. ICE
peter-lyons-kehl Jan 22, 2023
682f1e0
CoAlloc: VecDeque minor. ICE
peter-lyons-kehl Jan 22, 2023
3cdb2d9
CoAlloc: Vec, Alloc, GlobalAlloc: x test tidy --bless. ICE
peter-lyons-kehl Jan 22, 2023
4909d57
CoAlloc: VecDeque + BinaryHeap: x test tidy --bless. ICE
peter-lyons-kehl Jan 22, 2023
17b3244
CoAlloc: VecDeque. ICE
peter-lyons-kehl Jan 22, 2023
85c6759
CoAlloc: VecDeque. ICE
peter-lyons-kehl Jan 22, 2023
3306d1d
CoAlloc: Alloc docs. ICE
peter-lyons-kehl Jan 22, 2023
13f09f7
CoAlloc: Vec + BinaryHeap. ICE
peter-lyons-kehl Dec 14, 2022
932d356
CoAlloc: WeVec. ICE
peter-lyons-kehl Jan 22, 2023
4e2268d
CoAlloc: Vec + Alloc. Moved co_alloc_metadata_num_slots_with_preferen…
peter-lyons-kehl Jan 22, 2023
4f54ecb
CoAlloc: BinaryHeap. ICE
peter-lyons-kehl Jan 22, 2023
72db464
CoAlloc: Vec: Renamed ::core::alloc::co_alloc_metadata_num_slots_with…
peter-lyons-kehl Jan 22, 2023
f9d07de
CoAlloc: VecDeque: Renamed ::core::alloc::co_alloc_metadata_num_slots…
peter-lyons-kehl Jan 22, 2023
dab8ad4
CoAlloc: Minor VecDeque. ICE
peter-lyons-kehl Jan 22, 2023
621d05c
CoAlloc: Vec: Tidy. ICE
peter-lyons-kehl Jan 22, 2023
c5fcbb0
CoAlloc: Vec: Working around ICE rust-lang/rust issue #106473 ICE. WIP
peter-lyons-kehl Jan 22, 2023
9db032e
CoAlloc: Vec (NOT String): Working around ICE rust-lang/rust issue #1…
peter-lyons-kehl Jan 22, 2023
ee19ed9
CoAlloc: BinaryHeap: Working around ICE rust-lang/rust issue #106473 …
peter-lyons-kehl Jan 22, 2023
cae1a82
CoAlloc: Vec + related + FFI (NOT String-related): Macros instead of …
peter-lyons-kehl Jan 22, 2023
6d5e865
CoAlloc: VecDeque: Macros instead of const for global COOP defaults (…
peter-lyons-kehl Jan 22, 2023
061fe5d
CoAlloc: BinaryHeap: Macros instead of const for global COOP defaults…
peter-lyons-kehl Jan 22, 2023
20ade76
CoAlloc: TODO replace co_alloc_metadata_num_slots_with_preference_glo…
peter-lyons-kehl Jan 22, 2023
e516e62
CoAlloc: Vec + core: Renamed co_alloc_metadata_num_slots_with_prefere…
peter-lyons-kehl Jan 23, 2023
9d9e75d
CoAlloc: VecDeque: Renamed co_alloc_metadata_num_slots_with_preferenc…
peter-lyons-kehl Jan 23, 2023
9fd925d
CoAlloc: Vec + Box + Rc: Fixing COOP_PREFERRED (and similar).
peter-lyons-kehl Jan 23, 2023
8d02835
CoAlloc: VecDeque: Fixing COOP_PREFERRED (and similar).
peter-lyons-kehl Jan 23, 2023
6a82ca6
CoAlloc: BinaryHeap: Fixing COOP_PREFERRED (and similar).
peter-lyons-kehl Jan 23, 2023
7348162
CoAlloc: Vec + Box: Fixing COOP_PREFERRED.
peter-lyons-kehl Jan 23, 2023
51889f1
CoAlloc: VecDeque: Fixing COOP_PREFERRED.
peter-lyons-kehl Jan 23, 2023
a772e0f
CoAlloc: Vec: Fixing COOP_PREFERRED.
peter-lyons-kehl Jan 23, 2023
1647c55
CoAlloc: VecDeque: Fixing COOP_PREFERRED.
peter-lyons-kehl Jan 23, 2023
6720d1e
CoAlloc: VecDeque: Fixing COOP_PREFERRED
peter-lyons-kehl Jan 23, 2023
59f9ed5
CoAlloc: Slice: Fixing COOP_PREFERRED
peter-lyons-kehl Jan 23, 2023
d849403
CoAlloc: Vec: Fixing COOP_PREFERRED
peter-lyons-kehl Jan 23, 2023
452bf19
CoAlloc: minor cleanup
peter-lyons-kehl Jan 23, 2023
e8d07df
CoAlloc: Vec: COOP_PREFERRED
peter-lyons-kehl Jan 23, 2023
ee2504b
CoAlloc: Vec: COOP_PREFERRED
peter-lyons-kehl Jan 23, 2023
4185a1f
CoAlloc: VecDeque: COOP_PREFERRED
peter-lyons-kehl Jan 23, 2023
0693767
CoAlloc: library/alloc: minor cleanup
peter-lyons-kehl Jan 23, 2023
f47ce34
CoAlloc: library/alloc: Re-added a closing curly bracket in mod test_…
peter-lyons-kehl Jan 23, 2023
86f332d
CoAlloc: Vec + slice: COOP_PREFERRED
peter-lyons-kehl Jan 23, 2023
e097c2f
CoAlloc: library/alloc/src/ffi: minor
peter-lyons-kehl Jan 23, 2023
c146757
CoAlloc: VecDeque: minor
peter-lyons-kehl Jan 23, 2023
6ec79e7
CoAlloc: Vec: COOP_PREFERRED
peter-lyons-kehl Jan 23, 2023
cb22e2f
CoAlloc: Vec + Box: COOP_PREFERRED for various traits
peter-lyons-kehl Jan 23, 2023
d74d5be
CoAlloc: VecDeque: minor cleanup
peter-lyons-kehl Jan 23, 2023
df419ce
CoVec, PlVec, DefVec, WeVec. Cleanup.
peter-lyons-kehl Jan 13, 2023
a3c765e
CoAlloc: Vec: added new_co()
peter-lyons-kehl Jan 23, 2023
86d380a
CoAlloc: std/src/lib.rs: minor
peter-lyons-kehl Jan 23, 2023
94f4fdd
CoAlloc: FFI: minor
peter-lyons-kehl Jan 23, 2023
9d808d1
CoAlloc: VecDeque (io::Read + io::Write for VecDeque): minor
peter-lyons-kehl Jan 23, 2023
3059f60
CoAlloc: sys ... thread dtor: minor
peter-lyons-kehl Jan 23, 2023
da31fd7
CoAlloc: alloc: minor
peter-lyons-kehl Jan 23, 2023
36cb284
CoAlloc: library/core: tidy
peter-lyons-kehl Jan 23, 2023
bc9bdc8
CoAlloc: library/proc_macro: tidy
peter-lyons-kehl Jan 23, 2023
1a84ad6
CoAlloc: Vec, Box + related slice.rs: tidy
peter-lyons-kehl Jan 23, 2023
eb83aba
CoAlloc: std: minor tidy
peter-lyons-kehl Jan 23, 2023
374e144
CoAlloc: VecDeque: tidy
peter-lyons-kehl Jan 23, 2023
f928542
CoAlloc: BinaryHeap: tidy
peter-lyons-kehl Jan 23, 2023
25f6d45
CoAlloc: slice.rs: Cleanup (of old code already commented out)
peter-lyons-kehl Jan 23, 2023
bb72710
CoAlloc: Uncommenting assert of BorrowType::TRAVERSAL_PERMIT. TODO Un…
peter-lyons-kehl Jan 13, 2023
3528115
CoAlloc: Vec + related: cleanup. Now library/alloc compiles, but std/…
peter-lyons-kehl Jan 24, 2023
20f0301
CoAlloc: Vec, related + vec! macro: Separated co-alloc-aware function…
peter-lyons-kehl Jan 24, 2023
43855d4
CoAlloc: library/proc_macro (+related library/alloc): Experimenting w…
peter-lyons-kehl Jan 24, 2023
ebb2264
CoAlloc: Renamed feature global_co_alloc_def to global_co_alloc_defau…
peter-lyons-kehl Jan 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CoAlloc: Vec + its use cases. ICE
  • Loading branch information
peter-lyons-kehl committed Jan 25, 2023
commit 6c3801da7b556877d62bf2d76f1e546cd0e970cd
8 changes: 4 additions & 4 deletions library/alloc/src/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::alloc::{Allocator, Global, Layout};
use crate::boxed::Box;
use crate::collections::TryReserveError;
use crate::collections::TryReserveErrorKind::*;
use crate::vec::DEFAULT_COOP_PREFERRED;

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -49,8 +50,7 @@ enum AllocInit {
/// `usize::MAX`. This means that you need to be careful when round-tripping this type with a
/// `Box<[T]>`, since `capacity()` won't yield the length.
#[allow(missing_debug_implementations)]
// @TODO apply `_coop` with logical && to `A::IsCoAllocator`
pub(crate) struct RawVec<T, A: Allocator = Global, const COOP_PREFERRED: bool = true>
pub(crate) struct RawVec<T, A: Allocator = Global, const COOP_PREFERRED: bool = DEFAULT_COOP_PREFERRED>
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
{
ptr: Unique<T>,
Expand Down Expand Up @@ -506,12 +506,12 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
}
}

// @TODO Custom
// @FIXME Custom
unsafe impl<#[may_dangle] T, const COOP_PREFERRED: bool> Drop for RawVec<T, Global, COOP_PREFERRED>
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]: {
/// Frees the memory owned by the `RawVec` *without* trying to drop its contents.
fn drop(&mut self) {
// @TODO
// @TOFIXMEDO
if let Some((ptr, layout)) = self.current_memory() {
unsafe { self.alloc.deallocate(ptr, layout) }
}
Expand Down
30 changes: 20 additions & 10 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,24 +397,34 @@ mod spec_extend;
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "Vec")]
#[rustc_insignificant_dtor]
// @TODO _coop
pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, const COOP_PREFERRED: bool = true>
pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, const COOP_PREFERRED: bool = DEFAULT_COOP_PREFERRED>
where [(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
{
buf: RawVec<T, A, COOP_PREFERRED>,
len: usize,
}

#[unstable(feature = "global_co_alloc_vec", issue = "none")]
pub type CoVec<T> = Vec<T, Global, true>;
#[unstable(feature = "global_co_alloc_covec", issue = "none")]
pub type CoVec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> = Vec<T, A, true>;

/// "Plain" Vec. Not "cooperative" - not carrying extra data to assist the allocator.
#[unstable(feature = "global_co_alloc_plvec", issue = "none")]
pub type PlVec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> = Vec<T, A, false>;

/// Default `Vec`, `DefVec`, `DecVeque`, `DefDecVeq` "cooperation" (`COOP_PREFERRED`) generic parameter.
#[unstable(feature = "global_co_alloc_def", issue = "none")]
pub const DEFAULT_COOP_PREFERRED: bool = true;

/// "Default" Vec. Either "cooperative" or not - as specified by `DEFAULT_COOP_PREFERRED`. The
/// difference to `Vec` (used without specifying `COOP_PREFERRED`): `DefVec` indicates that the
/// author considered using `CoVec` or `PlVec`, but left it to default instead.
#[unstable(feature = "global_co_alloc_defvec", issue = "none")]
pub type DefVec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> = Vec<T, A, DEFAULT_COOP_PREFERRED>;

/// "Plain" Vec.
#[unstable(feature = "global_co_alloc_vec", issue = "none")]
pub type PlVec<T> = Vec<T, Global, false>;

/// "Weighted" Vec.
/// weight means how much it wants to cooperate. 0 = always pack; u8::MAX = always coop (if `Global` supports it).
/// @TODO Weighing on the side of Allocator - const fn.
/// "Weighted cooperative" Vec. Weight means how much it wants to cooperate (with the allocator). 0
/// = always pack; u8::MAX = always cooperate (if `Global` supports it).
/// @FIXME A `pub const` threshold.
#[unstable(feature = "global_co_alloc_vec", issue = "none")]
pub type WeVec<T, const weight: u8> = Vec<T, Global, {weight>1}>;

Expand Down
25 changes: 16 additions & 9 deletions library/std/src/io/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::io::prelude::*;
use crate::alloc::Allocator;
use crate::cmp;
use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut, SeekFrom};
use core::alloc;

/// A `Cursor` wraps an in-memory buffer and provides it with a
/// [`Seek`] implementation.
Expand Down Expand Up @@ -397,11 +398,12 @@ fn slice_write_vectored(
}

/// Reserves the required space, and pads the vec with 0s if necessary.
fn reserve_and_pad<A: Allocator>(
fn reserve_and_pad<A: Allocator, const COOP_PREFERRED: bool>(
pos_mut: &mut u64,
vec: &mut Vec<u8, A>,
vec: &mut Vec<u8, A, COOP_PREFERRED>,
buf_len: usize,
) -> io::Result<usize> {
) -> io::Result<usize>
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {
let pos: usize = (*pos_mut).try_into().map_err(|_| {
io::const_io_error!(
ErrorKind::InvalidInput,
Expand Down Expand Up @@ -440,9 +442,10 @@ fn reserve_and_pad<A: Allocator>(

/// Writes the slice to the vec without allocating
/// # Safety: vec must have buf.len() spare capacity
unsafe fn vec_write_unchecked<A>(pos: usize, vec: &mut Vec<u8, A>, buf: &[u8]) -> usize
unsafe fn vec_write_unchecked<A, const COOP_PREFERRED: bool>(pos: usize, vec: &mut Vec<u8, A, COOP_PREFERRED>, buf: &[u8]) -> usize
where
A: Allocator,
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
{
debug_assert!(vec.capacity() >= pos + buf.len());
vec.as_mut_ptr().add(pos).copy_from(buf.as_ptr(), buf.len());
Expand All @@ -458,9 +461,10 @@ where
/// This also allows for the vec body to be empty, but with a position of N.
/// This means that [`Write`] will pad the vec with 0 initially,
/// before writing anything from that point
fn vec_write<A>(pos_mut: &mut u64, vec: &mut Vec<u8, A>, buf: &[u8]) -> io::Result<usize>
fn vec_write<A, const COOP_PREFERRED: bool>(pos_mut: &mut u64, vec: &mut Vec<u8, A, COOP_PREFERRED>, buf: &[u8]) -> io::Result<usize>
where
A: Allocator,
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
{
let buf_len = buf.len();
let mut pos = reserve_and_pad(pos_mut, vec, buf_len)?;
Expand Down Expand Up @@ -489,13 +493,14 @@ where
/// This also allows for the vec body to be empty, but with a position of N.
/// This means that [`Write`] will pad the vec with 0 initially,
/// before writing anything from that point
fn vec_write_vectored<A>(
fn vec_write_vectored<A, const COOP_PREFERRED: bool>(
pos_mut: &mut u64,
vec: &mut Vec<u8, A>,
vec: &mut Vec<u8, A, COOP_PREFERRED>,
bufs: &[IoSlice<'_>],
) -> io::Result<usize>
where
A: Allocator,
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
{
// For safety reasons, we don't want this sum to overflow ever.
// If this saturates, the reserve should panic to avoid any unsound writing.
Expand Down Expand Up @@ -543,9 +548,10 @@ impl Write for Cursor<&mut [u8]> {
}

#[stable(feature = "cursor_mut_vec", since = "1.25.0")]
impl<A> Write for Cursor<&mut Vec<u8, A>>
impl<A, const COOP_PREFERRED: bool> Write for Cursor<&mut Vec<u8, A, COOP_PREFERRED>>
where
A: Allocator,
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
{
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
vec_write(&mut self.pos, self.inner, buf)
Expand All @@ -567,9 +573,10 @@ where
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<A> Write for Cursor<Vec<u8, A>>
impl<A, const COOP_PREFERRED: bool> Write for Cursor<Vec<u8, A, COOP_PREFERRED>>
where
A: Allocator,
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
{
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
vec_write(&mut self.pos, &mut self.inner, buf)
Expand Down
3 changes: 2 additions & 1 deletion library/std/src/io/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ impl Write for &mut [u8] {
/// Write is implemented for `Vec<u8>` by appending to the vector.
/// The vector will grow as needed.
#[stable(feature = "rust1", since = "1.0.0")]
impl<A: Allocator> Write for Vec<u8, A> {
impl<A: Allocator, const COOP_PREFERRED: bool> Write for Vec<u8, A, COOP_PREFERRED>
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {
#[inline]
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.extend_from_slice(buf);
Expand Down
4 changes: 3 additions & 1 deletion library/std/src/sys/hermit/thread_local_dtor.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#![cfg(target_thread_local)]
#![unstable(feature = "thread_local_internals", issue = "none")]
#![feature(global_co_alloc_plvec)]

// Simplify dtor registration by using a list of destructors.
// The this solution works like the implementation of macOS and
// doesn't additional OS support

use core::alloc::PlVec;
use crate::mem;

#[thread_local]
static mut DTORS: Vec<(*mut u8, unsafe extern "C" fn(*mut u8))> = Vec::new();
static mut DTORS: PlVec<(*mut u8, unsafe extern "C" fn(*mut u8))> = PlVec::new();

pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
let list = &mut DTORS;
Expand Down
6 changes: 4 additions & 2 deletions library/std/src/sys/solid/thread_local_dtor.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#![cfg(target_thread_local)]
#![unstable(feature = "thread_local_internals", issue = "none")]
#![unstable(feature = "thread_local_internals", issue = "none")]#![feature(global_co_alloc_plvec)]
#![feature(global_co_alloc_plvec)]

// Simplify dtor registration by using a list of destructors.

use super::{abi, itron::task};
use crate::cell::Cell;
use crate::mem;
use core::alloc::PlVec;

#[thread_local]
static REGISTERED: Cell<bool> = Cell::new(false);

#[thread_local]
static mut DTORS: Vec<(*mut u8, unsafe extern "C" fn(*mut u8))> = Vec::new();
static mut DTORS: PlVec<(*mut u8, unsafe extern "C" fn(*mut u8))> = PlVec::new();

pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
if !REGISTERED.get() {
Expand Down
5 changes: 4 additions & 1 deletion library/std/src/sys/unix/thread_local_dtor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![cfg(target_thread_local)]
#![unstable(feature = "thread_local_internals", issue = "none")]
#![feature(global_co_alloc_plvec)]

use core::alloc::PlVec;

//! Provides thread-local destructors without an associated "key", which
//! can be more efficient.
Expand Down Expand Up @@ -64,7 +67,7 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
static REGISTERED: Cell<bool> = Cell::new(false);

#[thread_local]
static mut DTORS: Vec<(*mut u8, unsafe extern "C" fn(*mut u8))> = Vec::new();
static mut DTORS: PlVec<(*mut u8, unsafe extern "C" fn(*mut u8))> = PlVec::new();

if !REGISTERED.get() {
_tlv_atexit(run_dtors, ptr::null_mut());
Expand Down
5 changes: 4 additions & 1 deletion library/std/src/sys/windows/thread_local_dtor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

#![unstable(feature = "thread_local_internals", issue = "none")]
#![cfg(target_thread_local)]
#![feature(global_co_alloc_plvec)]

use core::alloc::PlVec;

// Using a per-thread list avoids the problems in synchronizing global state.
#[thread_local]
static mut DESTRUCTORS: Vec<(*mut u8, unsafe extern "C" fn(*mut u8))> = Vec::new();
static mut DESTRUCTORS: PlVec<(*mut u8, unsafe extern "C" fn(*mut u8))> = Vec::new();

// Ensure this can never be inlined because otherwise this may break in dylibs.
// See #44391.
Expand Down