Skip to content

Commit 2416812

Browse files
committed
Pass STATE into the garbage collection functions.
1 parent 5c6a613 commit 2416812

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+581
-656
lines changed

machine/builtin/access_variable.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace rubinius {
7272

7373
if(kind_of<Class>(mod) && self->reference_p()) {
7474
// Promote this to use a direct accessor
75-
if(TypeInfo* ti = state->memory()->find_type_info(self)) {
75+
if(TypeInfo* ti = state->memory()->find_type_info(state, self)) {
7676
TypeInfo::Slots::iterator it = ti->slots.find(access->name()->index());
7777
if(it != ti->slots.end()) {
7878
// Found one!
@@ -98,7 +98,7 @@ namespace rubinius {
9898

9999
if(kind_of<Class>(mod) && self->reference_p()) {
100100
// Promote this to use a direct accessor
101-
if(TypeInfo* ti = state->memory()->find_type_info(self)) {
101+
if(TypeInfo* ti = state->memory()->find_type_info(state, self)) {
102102
TypeInfo::Slots::iterator it = ti->slots.find(access->name()->index());
103103
if(it != ti->slots.end()) {
104104
// Found one!

machine/builtin/bignum.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ namespace rubinius {
11601160
mp_int* n = this->mp_val();
11611161
assert(MANAGED(n));
11621162
Object* m = static_cast<Object*>(n->managed);
1163-
return m->size_in_bytes(state->vm());
1163+
return m->size_in_bytes(state);
11641164
}
11651165

11661166
extern "C" void* MANAGED_REALLOC_MPINT(void* s, mp_int* a, size_t bytes) {
@@ -1182,13 +1182,13 @@ namespace rubinius {
11821182
return storage->raw_bytes();
11831183
}
11841184

1185-
void Bignum::Info::mark(Object* obj, memory::ObjectMark& mark) {
1185+
void Bignum::Info::mark(STATE, Object* obj, memory::ObjectMark& mark) {
11861186
Bignum* big = force_as<Bignum>(obj);
11871187

11881188
mp_int* n = big->mp_val();
11891189
assert(MANAGED(n));
11901190

1191-
if(Object* tmp = mark.call(static_cast<Object*>(n->managed))) {
1191+
if(Object* tmp = mark.call(state, static_cast<Object*>(n->managed))) {
11921192
n->managed = reinterpret_cast<void*>(tmp);
11931193
ByteArray* ba = force_as<ByteArray>(tmp);
11941194
n->dp = OPT_CAST(mp_digit)ba->raw_bytes();

machine/builtin/bignum.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ namespace rubinius {
211211
allow_user_allocate = false;
212212
}
213213

214-
virtual void mark(Object* t, memory::ObjectMark& mark);
214+
virtual void mark(STATE, Object* t, memory::ObjectMark& mark);
215215
virtual void show(STATE, Object* self, int level);
216216
virtual void show_simple(STATE, Object* self, int level);
217-
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
217+
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark) {}
218218
};
219219
};
220220

machine/builtin/byte_array.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,14 @@ namespace rubinius {
212212
return cNil;
213213
}
214214

215-
size_t ByteArray::Info::object_size(const ObjectHeader* obj) {
215+
size_t ByteArray::Info::object_size(STATE, const ObjectHeader* obj) {
216216
const ByteArray *ba = static_cast<const ByteArray*>(obj);
217217
assert(ba);
218218

219219
return ba->full_size();
220220
}
221221

222-
void ByteArray::Info::mark(Object* t, memory::ObjectMark& mark) {
222+
void ByteArray::Info::mark(STATE, Object* t, memory::ObjectMark& mark) {
223223
// @todo implement
224224
}
225225
}

machine/builtin/byte_array.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ namespace rubinius {
8080
allow_user_allocate = false;
8181
}
8282

83-
virtual void mark(Object* t, memory::ObjectMark& mark);
84-
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
85-
virtual size_t object_size(const ObjectHeader* object);
83+
virtual void mark(STATE, Object* t, memory::ObjectMark& mark);
84+
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark) {}
85+
virtual size_t object_size(STATE, const ObjectHeader* object);
8686
};
8787

8888
friend class Info;

machine/builtin/call_site.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ namespace rubinius {
3030
max_evictions = state->shared().config.machine_call_site_evictions.value;
3131
}
3232

33-
void CallSite::Info::mark(Object* obj, memory::ObjectMark& mark) {
34-
auto_mark(obj, mark);
33+
void CallSite::Info::mark(STATE, Object* obj, memory::ObjectMark& mark) {
34+
auto_mark(state, obj, mark);
3535

3636
CallSite* call_site = as<CallSite>(obj);
3737

38-
call_site->evict_and_mark(mark);
38+
call_site->evict_and_mark(state, mark);
3939
}
4040
}

machine/builtin/call_site.hpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ namespace rubinius {
470470
return _cache_miss_(state, this, args);
471471
}
472472

473-
void evict_and_mark(memory::ObjectMark& mark) {
473+
void evict_and_mark(STATE, memory::ObjectMark& mark) {
474474
// 0. Evict inefficient caches.
475475
for(int i = 0; i < max_caches; i++) {
476476
if(InlineCache* cache = _caches_[i]) {
@@ -512,19 +512,19 @@ namespace rubinius {
512512
// 3. Mark remaining caches.
513513
for(int i = 0; i < max_caches; i++) {
514514
if(InlineCache* cache = _caches_[i]) {
515-
if(Object* ref = mark.call(cache->receiver_class())) {
515+
if(Object* ref = mark.call(state, cache->receiver_class())) {
516516
cache->receiver_class(as<Class>(ref));
517-
mark.just_set(this, ref);
517+
mark.just_set(state, this, ref);
518518
}
519519

520-
if(Object* ref = mark.call(cache->stored_module())) {
520+
if(Object* ref = mark.call(state, cache->stored_module())) {
521521
cache->stored_module(as<Module>(ref));
522-
mark.just_set(this, ref);
522+
mark.just_set(state, this, ref);
523523
}
524524

525-
if(Object* ref = mark.call(cache->executable())) {
525+
if(Object* ref = mark.call(state, cache->executable())) {
526526
cache->executable(as<Executable>(ref));
527-
mark.just_set(this, ref);
527+
mark.just_set(state, this, ref);
528528
}
529529
}
530530
}
@@ -582,11 +582,11 @@ namespace rubinius {
582582
allow_user_allocate = false;
583583
}
584584

585-
virtual void mark(Object* obj, memory::ObjectMark& mark);
586-
virtual void auto_mark(Object* obj, memory::ObjectMark& mark);
585+
virtual void mark(STATE, Object* obj, memory::ObjectMark& mark);
586+
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark);
587587
virtual void set_field(STATE, Object* target, size_t index, Object* val);
588588
virtual Object* get_field(STATE, Object* target, size_t index);
589-
virtual void populate_slot_locations();
589+
virtual void populate_slot_locations(STATE);
590590
};
591591
};
592592
}

machine/builtin/compiled_code.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,10 @@ namespace rubinius {
426426
return cNil;
427427
}
428428

429-
void CompiledCode::Info::mark(Object* obj, memory::ObjectMark& mark) {
430-
auto_mark(obj, mark);
429+
void CompiledCode::Info::mark(STATE, Object* obj, memory::ObjectMark& mark) {
430+
auto_mark(state, obj, mark);
431431

432-
mark_inliners(obj, mark);
432+
mark_inliners(state, obj, mark);
433433

434434
CompiledCode* code = as<CompiledCode>(obj);
435435
if(!code->machine_code()) return;
@@ -444,9 +444,9 @@ namespace rubinius {
444444
for(size_t i = 0; i < mcode->references_count(); i++) {
445445
if(size_t ip = mcode->references()[i]) {
446446
Object* ref = reinterpret_cast<Object*>(mcode->opcodes[ip]);
447-
if(Object* updated_ref = mark.call(ref)) {
447+
if(Object* updated_ref = mark.call(state, ref)) {
448448
mcode->opcodes[ip] = reinterpret_cast<intptr_t>(updated_ref);
449-
mark.just_set(code, updated_ref);
449+
mark.just_set(state, code, updated_ref);
450450
}
451451
}
452452
}

machine/builtin/compiled_code.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ namespace rubinius {
144144
class Info : public Executable::Info {
145145
public:
146146
BASIC_TYPEINFO(Executable::Info)
147-
virtual void mark(Object* obj, memory::ObjectMark& mark);
147+
virtual void mark(STATE, Object* obj, memory::ObjectMark& mark);
148148
virtual void show(STATE, Object* self, int level);
149149
};
150150

machine/builtin/data.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ namespace rubinius {
145145
}
146146
}
147147

148-
void Data::Info::mark(Object* t, memory::ObjectMark& mark) {
149-
auto_mark(t, mark);
148+
void Data::Info::mark(STATE, Object* t, memory::ObjectMark& mark) {
149+
auto_mark(state, t, mark);
150150

151151
Data* data = force_as<Data>(t);
152152

machine/builtin/data.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ namespace rubinius {
112112
class Info : public TypeInfo {
113113
public:
114114
Info(object_type type) : TypeInfo(type) { }
115-
virtual void mark(Object* t, memory::ObjectMark& mark);
116-
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
115+
virtual void mark(STATE, Object* t, memory::ObjectMark& mark);
116+
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark) {}
117117
};
118118
};
119119

machine/builtin/encoding.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ namespace rubinius {
594594
return n;
595595
}
596596

597-
void Encoding::Info::mark(Object* obj, memory::ObjectMark& mark) {
598-
auto_mark(obj, mark);
597+
void Encoding::Info::mark(STATE, Object* obj, memory::ObjectMark& mark) {
598+
auto_mark(state, obj, mark);
599599

600600
Encoding* enc_o = force_as<Encoding>(obj);
601601
if(!enc_o->managed()) return;
@@ -604,18 +604,18 @@ namespace rubinius {
604604
if(!enc) return;
605605

606606
ByteArray* enc_ba = ByteArray::from_body(enc);
607-
if(ByteArray* tmp_ba = force_as<ByteArray>(mark.call(enc_ba))) {
607+
if(ByteArray* tmp_ba = force_as<ByteArray>(mark.call(state, enc_ba))) {
608608
enc_o->encoding(reinterpret_cast<OnigEncodingType*>(tmp_ba->raw_bytes()));
609-
mark.just_set(obj, tmp_ba);
609+
mark.just_set(state, obj, tmp_ba);
610610

611611
enc = enc_o->encoding();
612612
}
613613

614614
if(enc->name) {
615615
ByteArray* ba = ByteArray::from_body(const_cast<char*>(enc->name));
616-
if(ByteArray* tmp = force_as<ByteArray>(mark.call(ba))) {
616+
if(ByteArray* tmp = force_as<ByteArray>(mark.call(state, ba))) {
617617
enc->name = reinterpret_cast<const char*>(tmp->raw_bytes());
618-
mark.just_set(obj, tmp);
618+
mark.just_set(state, obj, tmp);
619619
}
620620
}
621621
}

machine/builtin/encoding.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ namespace rubinius {
136136
allow_user_allocate = false;
137137
}
138138

139-
virtual void mark(Object* obj, memory::ObjectMark& mark);
140-
virtual void auto_mark(Object* obj, memory::ObjectMark& mark);
139+
virtual void mark(STATE, Object* obj, memory::ObjectMark& mark);
140+
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark);
141141
virtual void set_field(STATE, Object* target, size_t index, Object* val);
142142
virtual Object* get_field(STATE, Object* target, size_t index);
143-
virtual void populate_slot_locations();
143+
virtual void populate_slot_locations(STATE);
144144
virtual void show(STATE, Object* self, int level);
145145
};
146146
};

machine/builtin/exception.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ namespace rubinius {
293293

294294
msg << "Bounds of object exceeded:" << std::endl;
295295
msg << " type: " << info->type_name << ", bytes: " <<
296-
obj->body_in_bytes(state->vm()) << ", accessed: " << index << std::endl;
296+
obj->body_in_bytes(state) << ", accessed: " << index << std::endl;
297297

298298
RubyException::raise(make_exception(state, get_object_bounds_exceeded_error(state),
299299
msg.str().c_str()));

machine/builtin/executable.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ namespace rubinius {
7777
inliners()->inliners().clear();
7878
}
7979

80-
void Executable::Info::mark(Object* obj, memory::ObjectMark& mark) {
81-
auto_mark(obj, mark);
82-
mark_inliners(obj, mark);
80+
void Executable::Info::mark(STATE, Object* obj, memory::ObjectMark& mark) {
81+
auto_mark(state, obj, mark);
82+
mark_inliners(state, obj, mark);
8383
}
8484

85-
void Executable::Info::mark_inliners(Object* obj, memory::ObjectMark& mark) {
85+
void Executable::Info::mark_inliners(STATE, Object* obj, memory::ObjectMark& mark) {
8686
Executable* exc = static_cast<Executable*>(obj);
8787
if(!exc->inliners() || exc->inliners() == (Inliners*)cNil) return;
8888

@@ -96,9 +96,9 @@ namespace rubinius {
9696
++i) {
9797
CompiledCode* code = *i;
9898

99-
if(Object* tmp = mark.call(code)) {
99+
if(Object* tmp = mark.call(state, code)) {
100100
*i = static_cast<CompiledCode*>(tmp);
101-
mark.just_set(obj, tmp);
101+
mark.just_set(state, obj, tmp);
102102
}
103103
}
104104
}

machine/builtin/executable.hpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,12 @@ namespace rubinius {
9797
public:
9898
BASIC_TYPEINFO(TypeInfo)
9999

100-
virtual void mark(Object* obj, memory::ObjectMark& mark);
101-
102-
void mark_inliners(Object* obj, memory::ObjectMark& mark);
100+
virtual void mark(STATE, Object* obj, memory::ObjectMark& mark);
101+
void mark_inliners(STATE, Object* obj, memory::ObjectMark& mark);
103102
};
104103

105104
friend class Info;
106105
};
107-
108106
}
109107

110108
#endif

machine/builtin/ffi_pointer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,6 @@ namespace rubinius {
538538
}
539539
}
540540

541-
void Pointer::Info::mark(Object* obj, memory::ObjectMark& mark) {
541+
void Pointer::Info::mark(STATE, Object* obj, memory::ObjectMark& mark) {
542542
}
543543
}

machine/builtin/ffi_pointer.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ namespace rubinius {
124124
class Info : public TypeInfo {
125125
public:
126126
Info(object_type type) : TypeInfo(type) { }
127-
virtual void mark(Object* t, memory::ObjectMark& mark);
128-
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
127+
virtual void mark(STATE, Object* t, memory::ObjectMark& mark);
128+
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark) {}
129129
};
130130
};
131131
}

machine/builtin/find_object.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,16 @@ namespace rubinius {
297297

298298
OnStack<2> os(state, ary, args);
299299

300-
memory::ObjectWalker walker(state->memory());
301-
memory::GCData gc_data(state->vm());
300+
memory::ObjectWalker walker(state, state->memory());
301+
memory::GCData gc_data(state);
302302

303303
{
304304
LockPhase locked(state);
305305
// Seed it with the root objects.
306-
walker.seed(gc_data);
306+
walker.seed(state, gc_data);
307307
}
308308

309-
Object* obj = walker.next();
309+
Object* obj = walker.next(state);
310310

311311
while(obj) {
312312
if(condition->perform(state, obj)) {
@@ -334,7 +334,7 @@ namespace rubinius {
334334
}
335335
}
336336

337-
obj = walker.next();
337+
obj = walker.next(state);
338338
}
339339

340340
delete condition;

machine/builtin/fixnum.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -483,5 +483,5 @@ namespace rubinius {
483483
show(state, self, level);
484484
}
485485

486-
void Fixnum::Info::mark(Object* t, memory::ObjectMark& mark) { }
486+
void Fixnum::Info::mark(STATE, Object* t, memory::ObjectMark& mark) { }
487487
}

machine/builtin/fixnum.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,12 @@ namespace rubinius {
261261
allow_user_allocate = false;
262262
}
263263

264-
virtual void mark(Object* t, memory::ObjectMark& mark);
264+
virtual void mark(STATE, Object* t, memory::ObjectMark& mark);
265265
virtual void show(STATE, Object* self, int level);
266266
virtual void show_simple(STATE, Object* self, int level);
267-
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
267+
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark) {}
268268
};
269269
};
270-
271270
}
272271

273272
#endif

machine/builtin/float.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ namespace rubinius {
509509
snprintf(buf, sz, "%+.17e", value());
510510
}
511511

512-
void Float::Info::mark(Object* t, memory::ObjectMark& mark) { }
512+
void Float::Info::mark(STATE, Object* t, memory::ObjectMark& mark) { }
513513

514514
void Float::Info::show(STATE, Object* self, int level) {
515515
Float* f = as<Float>(self);

0 commit comments

Comments
 (0)