Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d653ec8

Browse files
committedJul 4, 2016
Clean up young generation debris.
1 parent f412225 commit d653ec8

21 files changed

+41
-599
lines changed
 

‎machine/builtin/string.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ namespace rubinius {
187187
* allocate a new object in the young space, we can copy it directly
188188
* without needing a write barrier.
189189
*/
190+
/* TODO: young gen removal
190191
String* so = state->memory()->new_object<String>(state, G(string));
191192
if(likely(so->young_object_p())) {
192193
so->copy_body(state, this);
@@ -195,6 +196,7 @@ namespace rubinius {
195196
infect(state, so);
196197
return so;
197198
}
199+
*/
198200
}
199201
return string_dup_slow(state);
200202
}

‎machine/capi/handles.cpp

+2-32
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ namespace rubinius {
7070
if(diagnostics()) delete diagnostics();
7171
}
7272

73-
void Handles::deallocate_handles(std::list<Handle*>* cached,
74-
unsigned int mark, /* BakerGC */ void* young)
75-
{
73+
void Handles::deallocate_handles(std::list<Handle*>* cached, unsigned int mark) {
7674
std::vector<bool> chunk_marks(allocator_->chunks_.size(), false);
7775

7876
diagnostics()->objects_ = 0;
@@ -96,35 +94,7 @@ namespace rubinius {
9694
continue;
9795
}
9896

99-
if(young) {
100-
/*
101-
if(obj->young_object_p()) {
102-
// A weakref pointing to a valid young object
103-
//
104-
// TODO this only works because we run prune_handles right after
105-
// a collection. In this state, valid objects are only in current.
106-
if(young->in_current_p(obj)) {
107-
chunk_marks[i] = true;
108-
diagnostics()->objects_++;
109-
// A weakref pointing to a forwarded young object
110-
} else if(obj->forwarded_p()) {
111-
handle->set_object(obj->forward());
112-
chunk_marks[i] = true;
113-
diagnostics()->objects_++;
114-
// A weakref pointing to a dead young object
115-
} else {
116-
handle->clear();
117-
}
118-
} else {
119-
// Not a young object, so won't be GC'd so mark
120-
// chunk as still active
121-
chunk_marks[i] = true;
122-
diagnostics()->objects_++;
123-
}
124-
*/
125-
126-
// A weakref pointing to a dead mature object
127-
} else if(!obj->marked_p(mark)) {
97+
if(!obj->marked_p(mark)) {
12898
handle->clear();
12999
} else {
130100
chunk_marks[i] = true;

‎machine/capi/handles.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace rubinius {
5151

5252
bool validate(Handle* handle);
5353

54-
void deallocate_handles(std::list<Handle*>* cached, unsigned int mark, /* BakerGC */ void* young);
54+
void deallocate_handles(std::list<Handle*>* cached, unsigned int mark);
5555

5656
void flush_all(NativeMethodEnvironment* env);
5757

‎machine/global_cache.cpp

-27
Original file line numberDiff line numberDiff line change
@@ -193,33 +193,6 @@ namespace rubinius {
193193
Object* klass = entry->klass;
194194
if(!klass) continue;
195195

196-
if(klass->young_object_p()) {
197-
if(klass->forwarded_p()) {
198-
Module* fwd = force_as<Module>(klass->forward());
199-
entry->klass = fwd;
200-
} else {
201-
clear = true;
202-
}
203-
}
204-
205-
Object* mod = entry->module;
206-
if(mod->young_object_p()) {
207-
if(mod->forwarded_p()) {
208-
entry->module = force_as<Module>(mod->forward());
209-
} else {
210-
clear = true;
211-
}
212-
}
213-
214-
Object* exec = entry->method;
215-
if(exec->young_object_p()) {
216-
if(exec->forwarded_p()) {
217-
entry->method = force_as<Executable>(exec->forward());
218-
} else {
219-
clear = true;
220-
}
221-
}
222-
223196
if(clear) {
224197
entry_names[i] = NULL;
225198
entry->clear();

‎machine/memory.cpp

+6-87
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ namespace rubinius {
6868
, mature_gc_in_progress_(false)
6969
, slab_size_(4096)
7070
, interrupt_flag_(false)
71-
, collect_young_flag_(false)
7271
, collect_full_flag_(false)
7372
, last_object_id(1)
7473
, last_snapshot_id(0)
@@ -82,6 +81,8 @@ namespace rubinius {
8281
}
8382
#endif
8483

84+
state->shared().set_memory(this);
85+
8586
for(size_t i = 0; i < LastObjectType; i++) {
8687
type_info[i] = NULL;
8788
}
@@ -100,7 +101,6 @@ namespace rubinius {
100101

101102
delete immix_;
102103
delete mark_sweep_;
103-
/* delete young_; */
104104

105105
for(std::list<capi::GlobalHandle*>::iterator i = global_capi_handle_locations_.begin();
106106
i != global_capi_handle_locations_.end(); ++i) {
@@ -421,26 +421,6 @@ namespace rubinius {
421421
}
422422
}
423423

424-
bool Memory::refill_slab(STATE, memory::Slab& slab) {
425-
utilities::thread::SpinLock::LockGuard guard(allocation_lock_);
426-
427-
memory::Address addr = memory::Address::null(); /* young_->allocate_for_slab(slab_size_); */
428-
429-
metrics::MetricsData& metrics = state->vm()->metrics();
430-
metrics.memory.young_objects += slab.allocations();
431-
metrics.memory.young_bytes += slab.bytes_used();
432-
433-
if(addr) {
434-
slab.refill(addr, slab_size_);
435-
metrics.memory.slab_refills++;
436-
return true;
437-
} else {
438-
slab.refill(0, 0);
439-
metrics.memory.slab_refills_fails++;
440-
return false;
441-
}
442-
}
443-
444424
bool Memory::valid_object_p(STATE, Object* obj) {
445425
if(obj->true_p()) {
446426
return true;
@@ -454,8 +434,6 @@ namespace rubinius {
454434
return true;
455435
} else if(obj->symbol_p()) {
456436
return true;
457-
} else if(obj->young_object_p()) {
458-
return false; /* young_->validate_object(obj) == cValid; */
459437
} else if(obj->mature_object_p()) {
460438
if(obj->in_immix_p()) {
461439
if(immix_->validate_object(state, obj) == cInImmix) {
@@ -511,76 +489,24 @@ namespace rubinius {
511489
* prohibition lifts, a GC will eventually be triggered again.
512490
*/
513491
if(!can_gc()) {
514-
collect_young_flag_ = false;
515492
collect_full_flag_ = false;
516493
interrupt_flag_ = false;
517494
return;
518495
}
519496

520-
if(!collect_young_flag_ && !collect_full_flag_) return;
497+
if(!collect_full_flag_) return;
521498

522499
if(cDebugThreading) {
523500
std::cerr << std::endl << "[" << state
524501
<< " WORLD beginning GC.]" << std::endl;
525502
}
526503

527-
if(collect_young_flag_) {
528-
memory::GCData gc_data(state);
529-
530-
RUBINIUS_GC_BEGIN(0);
531-
collect_young(state, &gc_data);
532-
533-
if(!collect_full_flag_) interrupt_flag_ = false;
534-
535-
RUBINIUS_GC_END(0);
536-
}
537-
538504
if(collect_full_flag_) {
539505
RUBINIUS_GC_BEGIN(1);
540506
collect_full(state);
541507
}
542508
}
543509

544-
void Memory::collect_young(STATE, memory::GCData* data) {
545-
timer::StopWatch<timer::milliseconds> timerx(
546-
state->vm()->metrics().gc.young_ms);
547-
548-
/*
549-
young_->collect(data);
550-
551-
prune_handles(state, data->handles(), data->cached_handles(), young_);
552-
553-
metrics::MetricsData& metrics = state->vm()->metrics();
554-
metrics.gc.young_count++;
555-
556-
data->global_cache()->prune_young();
557-
558-
{
559-
std::lock_guard<std::mutex> guard(data->thread_nexus()->threads_mutex());
560-
561-
for(ThreadList::iterator i = data->thread_nexus()->threads()->begin();
562-
i != data->thread_nexus()->threads()->end();
563-
++i)
564-
{
565-
memory::Slab& slab = (*i)->local_slab();
566-
567-
// Reset the slab to a size of 0 so that the thread has to do
568-
// an allocation to get a proper refill. This keeps the number
569-
// of threads in the system from starving the available
570-
// number of slabs.
571-
slab.refill(0, 0);
572-
}
573-
}
574-
575-
young_->reset();
576-
#ifdef RBX_GC_DEBUG
577-
young_->verify(data);
578-
#endif
579-
*/
580-
581-
collect_young_flag_ = false;
582-
}
583-
584510
void Memory::collect_full(STATE) {
585511
// If we're already collecting, ignore this request
586512
if(mature_gc_in_progress_) return;
@@ -634,7 +560,7 @@ namespace rubinius {
634560

635561
data->global_cache()->prune_unmarked(mark());
636562

637-
prune_handles(state, data->handles(), data->cached_handles(), NULL);
563+
prune_handles(state, data->handles(), data->cached_handles());
638564

639565
// Have to do this after all things that check for mark bits is
640566
// done, as it free()s objects, invalidating mark bits.
@@ -723,10 +649,8 @@ namespace rubinius {
723649

724650
}
725651

726-
void Memory::prune_handles(STATE, capi::Handles* handles,
727-
std::list<capi::Handle*>* cached, /* BakerGC */ void* young)
728-
{
729-
handles->deallocate_handles(cached, mark(), young);
652+
void Memory::prune_handles(STATE, capi::Handles* handles, std::list<capi::Handle*>* cached) {
653+
handles->deallocate_handles(cached, mark());
730654
}
731655

732656
void Memory::add_type_info(STATE, TypeInfo* ti) {
@@ -793,11 +717,6 @@ namespace rubinius {
793717
ObjectPosition Memory::validate_object(STATE, Object* obj) {
794718
ObjectPosition pos;
795719

796-
/*
797-
pos = young_->validate_object(obj);
798-
if(pos != cUnknown) return pos;
799-
*/
800-
801720
pos = immix_->validate_object(state, obj);
802721
if(pos != cUnknown) return pos;
803722

‎machine/memory.hpp

+2-41
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ namespace rubinius {
115115
/// Flag indicating that a Memory condition exists
116116
bool interrupt_flag_;
117117

118-
/// Flag indicating whether a young collection should be performed soon
119-
bool collect_young_flag_;
120-
121118
/// Flag indicating whether a full collection should be performed soon
122119
bool collect_full_flag_;
123120

@@ -172,16 +169,6 @@ namespace rubinius {
172169
allow_gc_ = false;
173170
}
174171

175-
void schedule_young_collection(STATE, metrics::metric& counter) {
176-
counter++;
177-
178-
// Don't trigger GC if currently prohibited so we don't thrash checking.
179-
if(can_gc()) {
180-
interrupt_flag_ = collect_young_flag_ = true;
181-
state->vm()->thread_nexus()->set_stop();
182-
}
183-
}
184-
185172
void schedule_full_collection(STATE, const char* trigger, metrics::metric& counter) {
186173
counter++;
187174
schedule_full_collection(state, trigger);
@@ -277,25 +264,7 @@ namespace rubinius {
277264
Object* new_object(STATE, Class* klass, native_int bytes, object_type type) {
278265
// TODO: GC
279266
// allocate:
280-
Object* obj = 0; /* state->vm()->local_slab().allocate(bytes).as<Object>();
281-
282-
if(likely(obj)) {
283-
state->vm()->metrics().memory.young_objects++;
284-
state->vm()->metrics().memory.young_bytes += bytes;
285-
286-
obj->init_header(YoungObjectZone, type);
287-
288-
goto set_klass;
289-
}
290-
291-
if(state->vm()->local_slab().empty_p()) {
292-
if(refill_slab(state, state->vm()->local_slab())) {
293-
goto allocate;
294-
} else {
295-
schedule_young_collection(state->vm(), state->vm()->metrics().gc.young_set);
296-
}
297-
}
298-
*/
267+
Object* obj = 0;
299268

300269
if(likely(obj = new_object(state, bytes))) goto set_type;
301270

@@ -510,8 +479,6 @@ namespace rubinius {
510479
TypeInfo* find_type_info(STATE, Object* obj);
511480
Object* promote_object(STATE, Object* obj);
512481

513-
bool refill_slab(STATE, memory::Slab& slab);
514-
515482
void assign_object_id(STATE, Object* obj);
516483
bool inflate_lock_count_overflow(STATE, ObjectHeader* obj, int count);
517484
LockStatus contend_for_lock(STATE, ObjectHeader* obj, size_t us, bool interrupt);
@@ -525,14 +492,12 @@ namespace rubinius {
525492
void add_code_resource(STATE, memory::CodeResource* cr);
526493

527494
void validate_handles(STATE, capi::Handles* handles);
528-
void prune_handles(STATE, capi::Handles* handles,
529-
std::list<capi::Handle*>* cached, /* BakerGC */ void* young);
495+
void prune_handles(STATE, capi::Handles* handles, std::list<capi::Handle*>* cached);
530496

531497
ObjectPosition validate_object(STATE, Object* obj);
532498

533499
void collect(STATE) {
534500
if(can_gc()) {
535-
collect_young_flag_ = true;
536501
collect_full_flag_ = true;
537502
interrupt_flag_ = true;
538503
state->vm()->thread_nexus()->set_stop();
@@ -590,10 +555,6 @@ namespace rubinius {
590555
return interrupt_flag_;
591556
}
592557

593-
bool& collect_young_p() {
594-
return collect_young_flag_;
595-
}
596-
597558
bool& collect_full_p() {
598559
return collect_full_flag_;
599560
}

‎machine/memory/debug.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ namespace memory {
3434

3535
seen[obj] = 1;
3636

37-
/*
38-
if(obj->young_object_p()) {
39-
if(!memory_->young.current->contains_p(obj)) {
40-
throw std::runtime_error("Invalid young object detected.");
41-
}
42-
}
43-
*/
44-
4537
scan_object(state, obj);
4638

4739
return NULL;

0 commit comments

Comments
 (0)
Please sign in to comment.