Skip to content

Commit

Permalink
Immix sets collect flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Sep 12, 2015
1 parent 1f4f82d commit 5daca40
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
19 changes: 12 additions & 7 deletions vm/gc/immix.cpp
Expand Up @@ -62,6 +62,7 @@ namespace rubinius {
ImmixGC::ImmixGC(ObjectMemory* om)
: GarbageCollector(om)
, allocator_(gc_.block_allocator())
, memory_(om)
, marker_(NULL)
, chunks_left_(0)
, chunks_before_collection_(10)
Expand Down Expand Up @@ -172,7 +173,7 @@ namespace rubinius {
void ImmixGC::collect(GCData* data) {
gc_.clear_marks();
collect_scan(data);
process_mark_stack();
process_mark_stack(memory_->collect_mature_now);
collect_finish(data);
}

Expand Down Expand Up @@ -256,7 +257,10 @@ namespace rubinius {
// We do this in a loop because the scanning might generate new entries
// on the mark stack.
do {
for(Allocator<capi::Handle>::Iterator i(data->handles()->allocator()); i.more(); i.advance()) {
for(Allocator<capi::Handle>::Iterator i(data->handles()->allocator());
i.more();
i.advance())
{
capi::Handle* hdl = i.current();
if(!hdl->in_use_p()) continue;
if(hdl->is_rdata()) {
Expand All @@ -266,7 +270,7 @@ namespace rubinius {
}
}
}
} while(process_mark_stack());
} while(process_mark_stack(memory_->collect_mature_now));

// We've now finished marking the entire object graph.
// Clean weakrefs before keeping additional objects alive
Expand All @@ -279,13 +283,14 @@ namespace rubinius {
do {
walk_finalizers();
scan_fibers(data, true);
} while(process_mark_stack());
} while(process_mark_stack(memory_->collect_mature_now));

// Remove unreachable locked objects still in the list
if(data->threads()) {
for(ThreadList::iterator i = data->threads()->begin();
i != data->threads()->end();
++i) {
++i)
{
clean_locked_objects(*i, false);
}
}
Expand Down Expand Up @@ -343,8 +348,8 @@ namespace rubinius {
}
}

bool ImmixGC::process_mark_stack(int count) {
return gc_.process_mark_stack(allocator_, count);
bool ImmixGC::process_mark_stack(bool& exit) {
return gc_.process_mark_stack(allocator_, exit);
}

immix::MarkStack& ImmixGC::mark_stack() {
Expand Down
7 changes: 6 additions & 1 deletion vm/gc/immix.hpp
Expand Up @@ -146,6 +146,7 @@ namespace rubinius {

immix::GC<ObjectDescriber> gc_;
immix::ExpandingAllocator allocator_;
ObjectMemory* memory_;
ImmixMarker* marker_;
int chunks_left_;
int chunks_before_collection_;
Expand All @@ -171,6 +172,10 @@ namespace rubinius {
ObjectPosition validate_object(Object*);

public: // Inline
ObjectMemory* memory() {
return memory_;
}

size_t& bytes_allocated() {
return gc_.bytes_allocated();
}
Expand All @@ -188,7 +193,7 @@ namespace rubinius {
}

void start_marker(STATE);
bool process_mark_stack(int count = 0);
bool process_mark_stack(bool& exit);
immix::MarkStack& mark_stack();

private:
Expand Down
2 changes: 1 addition & 1 deletion vm/gc/immix_marker.cpp
Expand Up @@ -87,7 +87,7 @@ namespace rubinius {
// number, based mostly on the fact it didn't cause
// big increases in young gc times because of long
// stop the world wait times.
while(immix_->process_mark_stack(100)) {
while(immix_->process_mark_stack(immix_->memory()->collect_mature_now)) {
if(state->shared().thread_nexus()->stop_p()) {
state->shared().thread_nexus()->yielding(state->vm());
}
Expand Down
6 changes: 2 additions & 4 deletions vm/util/immix.hpp
Expand Up @@ -1085,18 +1085,16 @@ namespace immix {
/**
* Calls the Describer to scan from each of the Addresses in the mark stack.
*/
bool process_mark_stack(Allocator& alloc, int count = 0) {
bool process_mark_stack(Allocator& alloc, bool& exit) {
Marker<Describer> mark(this, alloc);

if(mark_stack_.empty()) return false;

// Use while() since mark_stack_ is modified as we walk it.
while(!mark_stack_.empty()) {
while(!mark_stack_.empty() && !exit) {
Address addr = mark_stack_.back();
mark_stack_.pop_back();
desc.walk_pointers(addr, mark);
count--;
if(count == 0) return true;
}

return true;
Expand Down

0 comments on commit 5daca40

Please sign in to comment.