Skip to content

Commit 592f854

Browse files
committed
Redundantly visit some fields of hidden classes that weren't visited.
1 parent ee5286c commit 592f854

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/gc/collector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class GCVisitorNoRedundancy : public GCVisitor {
6868
virtual void visitRangeRedundant(void* const* start, void* const* end) { visitRange(start, end); }
6969
virtual void visitPotentialRedundant(void* p) { visitPotential(p); }
7070
virtual void visitPotentialRangeRedundant(void* const* start, void* const* end) { visitPotentialRange(start, end); }
71+
virtual bool shouldVisitRedundants() { return true; }
7172
};
7273
}
7374
}

src/gc/gc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
// Files outside of the gc/ folder should only import gc.h or gc_alloc.h
2323
// which are the "public" memory management interface.
2424

25+
// Some code is only useful towards an effort to implement a
26+
// moving gc, gate behind this flag for now.
27+
#define MOVING_GC 0
28+
2529
#define GC_KEEP_ALIVE(t) asm volatile("" : : "X"(t))
2630

2731
#define TRACE_GC_MARKING 0

src/runtime/hiddenclass.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@ void HiddenClass::gc_visit(GCVisitor* visitor) {
3232
visitor->visitRange((void* const*)&children.vector()[0], (void* const*)&children.vector()[children.size()]);
3333
visitor->visit(attrwrapper_child);
3434

35-
// We don't need to visit the keys of the 'children' map, since the children should have those as entries
36-
// in the attr_offssets map.
37-
// Also, if we have any children, we can skip scanning our attr_offsets map, since it will be a subset
38-
// of our child's map.
39-
if (children.empty())
35+
if (children.empty()) {
4036
for (auto p : attr_offsets)
4137
visitor->visit(p.first);
38+
} else {
39+
#if MOVING_GC
40+
// If we have any children, the attr_offsets map will be a subset of the child's map.
41+
for (const auto& p : attr_offsets)
42+
visitor->visitRedundant(p.first);
43+
#endif
44+
}
45+
46+
#if MOVING_GC
47+
// The children should have the entries of the keys of the 'children' map in the attr_offsets map.
48+
for (const auto& p : children) {
49+
visitor->visitRedundant(p.first);
50+
}
51+
#endif
4252
}
4353

4454
void HiddenClass::appendAttribute(BoxedString* attr) {

0 commit comments

Comments
 (0)