Skip to content

Commit ed19963

Browse files
committed
[simple] Fix singleton collector along with single-threaded context
1 parent 1bad3c5 commit ed19963

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

libs/simple/src/context/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl SimpleCollectorContext {
9696
pub(crate) unsafe fn from_collector(collector: &SimpleCollector) -> Self {
9797
SimpleCollectorContext {
9898
raw: Box::into_raw(ManuallyDrop::into_inner(
99-
RawContext::from_collector(collector.internal_clone())
99+
RawContext::from_collector(collector.clone_internal())
100100
)),
101101
root: true // We are the exclusive owner
102102
}

libs/simple/src/context/simple.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ impl Debug for RawContext {
9393
impl RawContext {
9494
pub(crate) unsafe fn from_collector(collector: SimpleCollector) -> ManuallyDrop<Box<Self>> {
9595
assert!(
96-
!collector.manager.has_existing_context
96+
!collector.as_raw().manager.has_existing_context
9797
.replace(true),
9898
"Already created a context for the collector!"
9999
);
100-
let logger = collector.logger.new(o!());
100+
let logger = collector.as_raw().logger.new(o!());
101101
let context = ManuallyDrop::new(Box::new(RawContext {
102102
logger: logger.clone(), collector,
103103
shadow_stack: UnsafeCell::new(ShadowStack {
@@ -128,9 +128,9 @@ impl RawContext {
128128
* at a safepoint.
129129
* This simplifies the implementation considerably.
130130
*/
131-
assert!(!self.collector.collecting.get());
132-
self.collector.collecting.set(true);
133-
let collection_id = self.collector.state.borrow_mut()
131+
assert!(!self.collector.as_raw().collecting.get());
132+
self.collector.as_raw().collecting.set(true);
133+
let collection_id = self.collector.as_raw().state.borrow_mut()
134134
.next_pending_id();
135135
trace!(
136136
self.logger,
@@ -150,14 +150,14 @@ impl RawContext {
150150
"shadow_stack" => FnValue(|_| format!("{:?}", shadow_stack.as_vec())),
151151
"state" => ?self.state,
152152
"collection_id" => collection_id,
153-
"original_size" => self.collector.heap.allocator.allocated_size(),
153+
"original_size" => self.collector.as_raw().heap.allocator.allocated_size(),
154154
);
155-
self.collector.perform_raw_collection(&[ptr]);
155+
self.collector.as_raw().perform_raw_collection(&[ptr]);
156156
assert_eq!(
157157
self.state.replace(ContextState::Active),
158158
ContextState::SafePoint { collection_id }
159159
);
160-
assert!(self.collector.collecting.replace(false));
160+
assert!(self.collector.as_raw().collecting.replace(false));
161161
}
162162
/// Borrow a reference to the shadow stack,
163163
/// assuming this context is valid (not active).

0 commit comments

Comments
 (0)