Skip to content

Commit

Permalink
fix(vm): Check if a collection is needed when creating a child thread
Browse files Browse the repository at this point in the history
bors r+
  • Loading branch information
Marwes committed Jun 9, 2019
1 parent 45427d5 commit 86e4b9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ let guess_loop _ =
else io.println ("Incorrect, " <> int.show.show result <> " != 24") *> guess_loop ()
else
io.println
"Expression is not valid. You must use each of the four numbers exactly once!"
"Expression is not valid, you must use each of the four numbers exactly once!"
*> guess_loop ()
guess_loop ()
Expand Down
10 changes: 6 additions & 4 deletions vm/src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl<'b> Traverseable for Roots<'b> {
}

impl<'b> crate::gc::CollectScope for Roots<'b> {
fn scope<F>(&self, gc: &mut Gc, f: F)
fn scope<F>(&self, gc: &mut Gc, sweep: F)
where
F: FnOnce(&mut Gc),
{
Expand All @@ -295,8 +295,10 @@ impl<'b> crate::gc::CollectScope for Roots<'b> {
// never leak any lifetimes outside of this function
unsafe {
let locks = self.mark_child_roots(gc);
// Scan `self` sweep `gc`
f(gc);

// Remove any threads that aren't marked as they are about to be collected

sweep(gc);

// `sweep` all child gcs
for (_, mut context, _) in locks {
Expand Down Expand Up @@ -553,7 +555,7 @@ impl Thread {
let mut context = vm.owned_context();
StackFrame::<State>::frame(&mut context.stack, 0, State::Unknown);
}
let ptr = self.context().gc.alloc(Move(vm))?;
let ptr = self.context().alloc(Move(vm))?;

Ok(ptr.root_thread())
}
Expand Down

0 comments on commit 86e4b9f

Please sign in to comment.