Skip to content

Commit 5daca40

Browse files
committedSep 12, 2015
Immix sets collect flag.
1 parent 1f4f82d commit 5daca40

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed
 

‎vm/gc/immix.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ namespace rubinius {
6262
ImmixGC::ImmixGC(ObjectMemory* om)
6363
: GarbageCollector(om)
6464
, allocator_(gc_.block_allocator())
65+
, memory_(om)
6566
, marker_(NULL)
6667
, chunks_left_(0)
6768
, chunks_before_collection_(10)
@@ -172,7 +173,7 @@ namespace rubinius {
172173
void ImmixGC::collect(GCData* data) {
173174
gc_.clear_marks();
174175
collect_scan(data);
175-
process_mark_stack();
176+
process_mark_stack(memory_->collect_mature_now);
176177
collect_finish(data);
177178
}
178179

@@ -256,7 +257,10 @@ namespace rubinius {
256257
// We do this in a loop because the scanning might generate new entries
257258
// on the mark stack.
258259
do {
259-
for(Allocator<capi::Handle>::Iterator i(data->handles()->allocator()); i.more(); i.advance()) {
260+
for(Allocator<capi::Handle>::Iterator i(data->handles()->allocator());
261+
i.more();
262+
i.advance())
263+
{
260264
capi::Handle* hdl = i.current();
261265
if(!hdl->in_use_p()) continue;
262266
if(hdl->is_rdata()) {
@@ -266,7 +270,7 @@ namespace rubinius {
266270
}
267271
}
268272
}
269-
} while(process_mark_stack());
273+
} while(process_mark_stack(memory_->collect_mature_now));
270274

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

284288
// Remove unreachable locked objects still in the list
285289
if(data->threads()) {
286290
for(ThreadList::iterator i = data->threads()->begin();
287291
i != data->threads()->end();
288-
++i) {
292+
++i)
293+
{
289294
clean_locked_objects(*i, false);
290295
}
291296
}
@@ -343,8 +348,8 @@ namespace rubinius {
343348
}
344349
}
345350

346-
bool ImmixGC::process_mark_stack(int count) {
347-
return gc_.process_mark_stack(allocator_, count);
351+
bool ImmixGC::process_mark_stack(bool& exit) {
352+
return gc_.process_mark_stack(allocator_, exit);
348353
}
349354

350355
immix::MarkStack& ImmixGC::mark_stack() {

‎vm/gc/immix.hpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ namespace rubinius {
146146

147147
immix::GC<ObjectDescriber> gc_;
148148
immix::ExpandingAllocator allocator_;
149+
ObjectMemory* memory_;
149150
ImmixMarker* marker_;
150151
int chunks_left_;
151152
int chunks_before_collection_;
@@ -171,6 +172,10 @@ namespace rubinius {
171172
ObjectPosition validate_object(Object*);
172173

173174
public: // Inline
175+
ObjectMemory* memory() {
176+
return memory_;
177+
}
178+
174179
size_t& bytes_allocated() {
175180
return gc_.bytes_allocated();
176181
}
@@ -188,7 +193,7 @@ namespace rubinius {
188193
}
189194

190195
void start_marker(STATE);
191-
bool process_mark_stack(int count = 0);
196+
bool process_mark_stack(bool& exit);
192197
immix::MarkStack& mark_stack();
193198

194199
private:

‎vm/gc/immix_marker.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ namespace rubinius {
8787
// number, based mostly on the fact it didn't cause
8888
// big increases in young gc times because of long
8989
// stop the world wait times.
90-
while(immix_->process_mark_stack(100)) {
90+
while(immix_->process_mark_stack(immix_->memory()->collect_mature_now)) {
9191
if(state->shared().thread_nexus()->stop_p()) {
9292
state->shared().thread_nexus()->yielding(state->vm());
9393
}

‎vm/util/immix.hpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -1085,18 +1085,16 @@ namespace immix {
10851085
/**
10861086
* Calls the Describer to scan from each of the Addresses in the mark stack.
10871087
*/
1088-
bool process_mark_stack(Allocator& alloc, int count = 0) {
1088+
bool process_mark_stack(Allocator& alloc, bool& exit) {
10891089
Marker<Describer> mark(this, alloc);
10901090

10911091
if(mark_stack_.empty()) return false;
10921092

10931093
// Use while() since mark_stack_ is modified as we walk it.
1094-
while(!mark_stack_.empty()) {
1094+
while(!mark_stack_.empty() && !exit) {
10951095
Address addr = mark_stack_.back();
10961096
mark_stack_.pop_back();
10971097
desc.walk_pointers(addr, mark);
1098-
count--;
1099-
if(count == 0) return true;
11001098
}
11011099

11021100
return true;

0 commit comments

Comments
 (0)
Please sign in to comment.