Skip to content
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

Shrink stacks on force compact #1813

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/third_party/dartino/mark_sweep.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class MarkingVisitor : public RootCallback {
for (Object** p = start; p < end; p++) mark_pointer(*p);
}

bool shrink_stacks() const override { return true; }
bool shrink_stacks() const override { return shrink_stacks_; }
void set_shrink_stacks(bool value) { shrink_stacks_ = value; }

private:
void INLINE mark_pointer(Object* object) {
Expand All @@ -72,6 +73,7 @@ class MarkingVisitor : public RootCallback {
uword new_space_address_;
uword new_space_size_;
MarkingStack* marking_stack_;
bool shrink_stacks_ = false;
};

class FixPointersVisitor : public RootCallback {
Expand Down
3 changes: 3 additions & 0 deletions src/third_party/dartino/two_space_heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ bool TwoSpaceHeap::perform_garbage_collection(bool force_compact) {
SemiSpace* semi_space = new_space();
MarkingStack stack(program_);
MarkingVisitor marking_visitor(semi_space, &stack);
if (force_compact || Flags::shrink_stacks_a_lot) {
marking_visitor.set_shrink_stacks(true);
}

process_heap_->iterate_roots(&marking_visitor);

Expand Down
3 changes: 3 additions & 0 deletions src/third_party/dartino/two_space_heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ class ScavengeVisitor : public RootCallback {

void set_record_new_space_pointers(uint8* p) { record_ = p; }

// We inherit shrink_stacks(), which by default returns false, so
// we don't shrink stacks during scavenge.

private:
template <class SomeSpace>
static inline HeapObject* clone_into_space(Program* program, HeapObject* original, SomeSpace* to);
Expand Down