Commit 8a510e30 authored by Rudi Chen's avatar Rudi Chen

ifdef out some moving GC code for now.

parent 9fade195
......@@ -235,6 +235,7 @@ public:
}
};
#if MOVING_GC
class ReferenceMapWorklist : public Worklist {
ReferenceMap* refmap;
......@@ -287,6 +288,7 @@ public:
void pin(GCAllocation* al) { refmap->pinned.emplace(al); }
};
#endif
void registerPermanentRoot(void* obj, bool allow_duplicates) {
assert(global_heap.getAllocationFromInteriorPointer(obj));
......@@ -485,6 +487,7 @@ void GCVisitor::visitPotentialRange(void** start, void** end) {
}
}
#if MOVING_GC
void GCVisitorPinning::_visit(void** ptr_address) {
void* p = *ptr_address;
if ((uintptr_t)p < SMALL_ARENA_START || (uintptr_t)p >= HUGE_ARENA_START + ARENA_SIZE) {
......@@ -510,6 +513,7 @@ void GCVisitorReplacing::_visit(void** ptr_address) {
*ptr_address = new_value;
}
}
#endif
static void visitRoots(GCVisitor& visitor) {
GC_TRACE_LOG("Looking at the stack\n");
......@@ -784,6 +788,7 @@ static void sweepPhase(std::vector<Box*>& weakly_referenced) {
}
static void mapReferencesPhase(ReferenceMap& refmap) {
#if MOVING_GC
ReferenceMapWorklist worklist(&refmap, roots);
GCVisitorPinning visitor(&worklist);
......@@ -794,8 +799,10 @@ static void mapReferencesPhase(ReferenceMap& refmap) {
}
graphTraversalMarking(worklist, visitor);
#endif
}
#if MOVING_GC
#define MOVE_LOG 1
static FILE* move_log;
......@@ -844,6 +851,7 @@ static void move(ReferenceMap& refmap, GCAllocation* old_al, size_t size) {
// TODO: This probably should not happen.
}
}
#endif
// Move objects around memory randomly. The purpose is to test whether the rest
// of the program is able to support a moving collector (e.g. if all pointers are
......@@ -856,6 +864,7 @@ static void move(ReferenceMap& refmap, GCAllocation* old_al, size_t size) {
// 2) Reallocate all non-pinned object. Update the value for every pointer locations
// from the map built in (1)
static void testMoving() {
#if MOVING_GC
global_heap.prepareForCollection();
ReferenceMap refmap;
......@@ -867,6 +876,7 @@ static void testMoving() {
global_heap.forEachSmallArenaReference([&refmap](GCAllocation* al, size_t size) { move(refmap, al, size); });
global_heap.cleanupAfterCollection();
#endif
}
bool gcIsEnabled() {
......
......@@ -91,6 +91,7 @@ class ReferenceMapWorklist;
#define MOVING_OVERRIDE
#endif
#if MOVING_GC
// Bulds the reference map, and also determine which objects cannot be moved.
class GCVisitorPinning : public GCVisitorNoRedundancy {
private:
......@@ -134,6 +135,7 @@ public:
// Track movement (reallocation) of objects.
std::unordered_map<GCAllocation*, GCAllocation*> moves;
};
#endif
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment