Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass STATE into the garbage collection functions.
Browse files Browse the repository at this point in the history
brixen committed Jul 2, 2016
1 parent 5c6a613 commit 2416812
Showing 79 changed files with 581 additions and 656 deletions.
4 changes: 2 additions & 2 deletions machine/builtin/access_variable.cpp
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ namespace rubinius {

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

if(kind_of<Class>(mod) && self->reference_p()) {
// Promote this to use a direct accessor
if(TypeInfo* ti = state->memory()->find_type_info(self)) {
if(TypeInfo* ti = state->memory()->find_type_info(state, self)) {
TypeInfo::Slots::iterator it = ti->slots.find(access->name()->index());
if(it != ti->slots.end()) {
// Found one!
6 changes: 3 additions & 3 deletions machine/builtin/bignum.cpp
Original file line number Diff line number Diff line change
@@ -1160,7 +1160,7 @@ namespace rubinius {
mp_int* n = this->mp_val();
assert(MANAGED(n));
Object* m = static_cast<Object*>(n->managed);
return m->size_in_bytes(state->vm());
return m->size_in_bytes(state);
}

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

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

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

if(Object* tmp = mark.call(static_cast<Object*>(n->managed))) {
if(Object* tmp = mark.call(state, static_cast<Object*>(n->managed))) {
n->managed = reinterpret_cast<void*>(tmp);
ByteArray* ba = force_as<ByteArray>(tmp);
n->dp = OPT_CAST(mp_digit)ba->raw_bytes();
4 changes: 2 additions & 2 deletions machine/builtin/bignum.hpp
Original file line number Diff line number Diff line change
@@ -211,10 +211,10 @@ namespace rubinius {
allow_user_allocate = false;
}

virtual void mark(Object* t, memory::ObjectMark& mark);
virtual void mark(STATE, Object* t, memory::ObjectMark& mark);
virtual void show(STATE, Object* self, int level);
virtual void show_simple(STATE, Object* self, int level);
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark) {}
};
};

4 changes: 2 additions & 2 deletions machine/builtin/byte_array.cpp
Original file line number Diff line number Diff line change
@@ -212,14 +212,14 @@ namespace rubinius {
return cNil;
}

size_t ByteArray::Info::object_size(const ObjectHeader* obj) {
size_t ByteArray::Info::object_size(STATE, const ObjectHeader* obj) {
const ByteArray *ba = static_cast<const ByteArray*>(obj);
assert(ba);

return ba->full_size();
}

void ByteArray::Info::mark(Object* t, memory::ObjectMark& mark) {
void ByteArray::Info::mark(STATE, Object* t, memory::ObjectMark& mark) {
// @todo implement
}
}
6 changes: 3 additions & 3 deletions machine/builtin/byte_array.hpp
Original file line number Diff line number Diff line change
@@ -80,9 +80,9 @@ namespace rubinius {
allow_user_allocate = false;
}

virtual void mark(Object* t, memory::ObjectMark& mark);
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
virtual size_t object_size(const ObjectHeader* object);
virtual void mark(STATE, Object* t, memory::ObjectMark& mark);
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark) {}
virtual size_t object_size(STATE, const ObjectHeader* object);
};

friend class Info;
6 changes: 3 additions & 3 deletions machine/builtin/call_site.cpp
Original file line number Diff line number Diff line change
@@ -30,11 +30,11 @@ namespace rubinius {
max_evictions = state->shared().config.machine_call_site_evictions.value;
}

void CallSite::Info::mark(Object* obj, memory::ObjectMark& mark) {
auto_mark(obj, mark);
void CallSite::Info::mark(STATE, Object* obj, memory::ObjectMark& mark) {
auto_mark(state, obj, mark);

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

call_site->evict_and_mark(mark);
call_site->evict_and_mark(state, mark);
}
}
20 changes: 10 additions & 10 deletions machine/builtin/call_site.hpp
Original file line number Diff line number Diff line change
@@ -470,7 +470,7 @@ namespace rubinius {
return _cache_miss_(state, this, args);
}

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

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

if(Object* ref = mark.call(cache->executable())) {
if(Object* ref = mark.call(state, cache->executable())) {
cache->executable(as<Executable>(ref));
mark.just_set(this, ref);
mark.just_set(state, this, ref);
}
}
}
@@ -582,11 +582,11 @@ namespace rubinius {
allow_user_allocate = false;
}

virtual void mark(Object* obj, memory::ObjectMark& mark);
virtual void auto_mark(Object* obj, memory::ObjectMark& mark);
virtual void mark(STATE, Object* obj, memory::ObjectMark& mark);
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark);
virtual void set_field(STATE, Object* target, size_t index, Object* val);
virtual Object* get_field(STATE, Object* target, size_t index);
virtual void populate_slot_locations();
virtual void populate_slot_locations(STATE);
};
};
}
10 changes: 5 additions & 5 deletions machine/builtin/compiled_code.cpp
Original file line number Diff line number Diff line change
@@ -426,10 +426,10 @@ namespace rubinius {
return cNil;
}

void CompiledCode::Info::mark(Object* obj, memory::ObjectMark& mark) {
auto_mark(obj, mark);
void CompiledCode::Info::mark(STATE, Object* obj, memory::ObjectMark& mark) {
auto_mark(state, obj, mark);

mark_inliners(obj, mark);
mark_inliners(state, obj, mark);

CompiledCode* code = as<CompiledCode>(obj);
if(!code->machine_code()) return;
@@ -444,9 +444,9 @@ namespace rubinius {
for(size_t i = 0; i < mcode->references_count(); i++) {
if(size_t ip = mcode->references()[i]) {
Object* ref = reinterpret_cast<Object*>(mcode->opcodes[ip]);
if(Object* updated_ref = mark.call(ref)) {
if(Object* updated_ref = mark.call(state, ref)) {
mcode->opcodes[ip] = reinterpret_cast<intptr_t>(updated_ref);
mark.just_set(code, updated_ref);
mark.just_set(state, code, updated_ref);
}
}
}
2 changes: 1 addition & 1 deletion machine/builtin/compiled_code.hpp
Original file line number Diff line number Diff line change
@@ -144,7 +144,7 @@ namespace rubinius {
class Info : public Executable::Info {
public:
BASIC_TYPEINFO(Executable::Info)
virtual void mark(Object* obj, memory::ObjectMark& mark);
virtual void mark(STATE, Object* obj, memory::ObjectMark& mark);
virtual void show(STATE, Object* self, int level);
};

4 changes: 2 additions & 2 deletions machine/builtin/data.cpp
Original file line number Diff line number Diff line change
@@ -145,8 +145,8 @@ namespace rubinius {
}
}

void Data::Info::mark(Object* t, memory::ObjectMark& mark) {
auto_mark(t, mark);
void Data::Info::mark(STATE, Object* t, memory::ObjectMark& mark) {
auto_mark(state, t, mark);

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

4 changes: 2 additions & 2 deletions machine/builtin/data.hpp
Original file line number Diff line number Diff line change
@@ -112,8 +112,8 @@ namespace rubinius {
class Info : public TypeInfo {
public:
Info(object_type type) : TypeInfo(type) { }
virtual void mark(Object* t, memory::ObjectMark& mark);
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
virtual void mark(STATE, Object* t, memory::ObjectMark& mark);
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark) {}
};
};

12 changes: 6 additions & 6 deletions machine/builtin/encoding.cpp
Original file line number Diff line number Diff line change
@@ -594,8 +594,8 @@ namespace rubinius {
return n;
}

void Encoding::Info::mark(Object* obj, memory::ObjectMark& mark) {
auto_mark(obj, mark);
void Encoding::Info::mark(STATE, Object* obj, memory::ObjectMark& mark) {
auto_mark(state, obj, mark);

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

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

enc = enc_o->encoding();
}

if(enc->name) {
ByteArray* ba = ByteArray::from_body(const_cast<char*>(enc->name));
if(ByteArray* tmp = force_as<ByteArray>(mark.call(ba))) {
if(ByteArray* tmp = force_as<ByteArray>(mark.call(state, ba))) {
enc->name = reinterpret_cast<const char*>(tmp->raw_bytes());
mark.just_set(obj, tmp);
mark.just_set(state, obj, tmp);
}
}
}
6 changes: 3 additions & 3 deletions machine/builtin/encoding.hpp
Original file line number Diff line number Diff line change
@@ -136,11 +136,11 @@ namespace rubinius {
allow_user_allocate = false;
}

virtual void mark(Object* obj, memory::ObjectMark& mark);
virtual void auto_mark(Object* obj, memory::ObjectMark& mark);
virtual void mark(STATE, Object* obj, memory::ObjectMark& mark);
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark);
virtual void set_field(STATE, Object* target, size_t index, Object* val);
virtual Object* get_field(STATE, Object* target, size_t index);
virtual void populate_slot_locations();
virtual void populate_slot_locations(STATE);
virtual void show(STATE, Object* self, int level);
};
};
2 changes: 1 addition & 1 deletion machine/builtin/exception.cpp
Original file line number Diff line number Diff line change
@@ -293,7 +293,7 @@ namespace rubinius {

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

RubyException::raise(make_exception(state, get_object_bounds_exceeded_error(state),
msg.str().c_str()));
12 changes: 6 additions & 6 deletions machine/builtin/executable.cpp
Original file line number Diff line number Diff line change
@@ -77,12 +77,12 @@ namespace rubinius {
inliners()->inliners().clear();
}

void Executable::Info::mark(Object* obj, memory::ObjectMark& mark) {
auto_mark(obj, mark);
mark_inliners(obj, mark);
void Executable::Info::mark(STATE, Object* obj, memory::ObjectMark& mark) {
auto_mark(state, obj, mark);
mark_inliners(state, obj, mark);
}

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

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

if(Object* tmp = mark.call(code)) {
if(Object* tmp = mark.call(state, code)) {
*i = static_cast<CompiledCode*>(tmp);
mark.just_set(obj, tmp);
mark.just_set(state, obj, tmp);
}
}
}
6 changes: 2 additions & 4 deletions machine/builtin/executable.hpp
Original file line number Diff line number Diff line change
@@ -97,14 +97,12 @@ namespace rubinius {
public:
BASIC_TYPEINFO(TypeInfo)

virtual void mark(Object* obj, memory::ObjectMark& mark);

void mark_inliners(Object* obj, memory::ObjectMark& mark);
virtual void mark(STATE, Object* obj, memory::ObjectMark& mark);
void mark_inliners(STATE, Object* obj, memory::ObjectMark& mark);
};

friend class Info;
};

}

#endif
2 changes: 1 addition & 1 deletion machine/builtin/ffi_pointer.cpp
Original file line number Diff line number Diff line change
@@ -538,6 +538,6 @@ namespace rubinius {
}
}

void Pointer::Info::mark(Object* obj, memory::ObjectMark& mark) {
void Pointer::Info::mark(STATE, Object* obj, memory::ObjectMark& mark) {
}
}
4 changes: 2 additions & 2 deletions machine/builtin/ffi_pointer.hpp
Original file line number Diff line number Diff line change
@@ -124,8 +124,8 @@ namespace rubinius {
class Info : public TypeInfo {
public:
Info(object_type type) : TypeInfo(type) { }
virtual void mark(Object* t, memory::ObjectMark& mark);
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
virtual void mark(STATE, Object* t, memory::ObjectMark& mark);
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark) {}
};
};
}
10 changes: 5 additions & 5 deletions machine/builtin/find_object.cpp
Original file line number Diff line number Diff line change
@@ -297,16 +297,16 @@ namespace rubinius {

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

memory::ObjectWalker walker(state->memory());
memory::GCData gc_data(state->vm());
memory::ObjectWalker walker(state, state->memory());
memory::GCData gc_data(state);

{
LockPhase locked(state);
// Seed it with the root objects.
walker.seed(gc_data);
walker.seed(state, gc_data);
}

Object* obj = walker.next();
Object* obj = walker.next(state);

while(obj) {
if(condition->perform(state, obj)) {
@@ -334,7 +334,7 @@ namespace rubinius {
}
}

obj = walker.next();
obj = walker.next(state);
}

delete condition;
2 changes: 1 addition & 1 deletion machine/builtin/fixnum.cpp
Original file line number Diff line number Diff line change
@@ -483,5 +483,5 @@ namespace rubinius {
show(state, self, level);
}

void Fixnum::Info::mark(Object* t, memory::ObjectMark& mark) { }
void Fixnum::Info::mark(STATE, Object* t, memory::ObjectMark& mark) { }
}
5 changes: 2 additions & 3 deletions machine/builtin/fixnum.hpp
Original file line number Diff line number Diff line change
@@ -261,13 +261,12 @@ namespace rubinius {
allow_user_allocate = false;
}

virtual void mark(Object* t, memory::ObjectMark& mark);
virtual void mark(STATE, Object* t, memory::ObjectMark& mark);
virtual void show(STATE, Object* self, int level);
virtual void show_simple(STATE, Object* self, int level);
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
virtual void auto_mark(STATE, Object* obj, memory::ObjectMark& mark) {}
};
};

}

#endif
2 changes: 1 addition & 1 deletion machine/builtin/float.cpp
Original file line number Diff line number Diff line change
@@ -509,7 +509,7 @@ namespace rubinius {
snprintf(buf, sz, "%+.17e", value());
}

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

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

0 comments on commit 2416812

Please sign in to comment.