Skip to content

Commit

Permalink
API cleanup, state->vm()->om => state->memory()
Browse files Browse the repository at this point in the history
  • Loading branch information
evanphx committed Nov 3, 2011
1 parent b6a3d1b commit 8bf4930
Show file tree
Hide file tree
Showing 23 changed files with 108 additions and 97 deletions.
30 changes: 15 additions & 15 deletions vm/agent_components.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -488,47 +488,47 @@ namespace agent {
young->add(new StaticInteger<int>("bytes", ss.config.gc_bytes * 2)); young->add(new StaticInteger<int>("bytes", ss.config.gc_bytes * 2));


Tree* mature = mem->get_tree("mature"); Tree* mature = mem->get_tree("mature");
mature->add(new ReadInteger<size_t>("bytes", &state->vm()->om->immix_usage())); mature->add(new ReadInteger<size_t>("bytes", &state->memory()->immix_usage()));


Tree* large = mem->get_tree("large"); Tree* large = mem->get_tree("large");
large->add(new ReadInteger<size_t>("bytes", &state->vm()->om->loe_usage())); large->add(new ReadInteger<size_t>("bytes", &state->memory()->loe_usage()));


Tree* code = mem->get_tree("code"); Tree* code = mem->get_tree("code");
code->add(new ReadInteger<size_t>("bytes", &state->vm()->om->code_usage())); code->add(new ReadInteger<size_t>("bytes", &state->memory()->code_usage()));


Tree* symbols = mem->get_tree("symbols"); Tree* symbols = mem->get_tree("symbols");
symbols->add(new ReadInteger<size_t>("bytes", &ss.symbols.bytes_used())); symbols->add(new ReadInteger<size_t>("bytes", &ss.symbols.bytes_used()));


Tree* counter = mem->get_tree("counter"); Tree* counter = mem->get_tree("counter");
counter->add(new ReadAtomicInteger("young_objects", counter->add(new ReadAtomicInteger("young_objects",
state->vm()->om->gc_stats.young_objects_allocated)); state->memory()->gc_stats.young_objects_allocated));
counter->add(new ReadAtomicInteger("young_bytes", counter->add(new ReadAtomicInteger("young_bytes",
state->vm()->om->gc_stats.young_bytes_allocated)); state->memory()->gc_stats.young_bytes_allocated));
counter->add(new ReadAtomicInteger("promoted_objects", counter->add(new ReadAtomicInteger("promoted_objects",
state->vm()->om->gc_stats.promoted_objects_allocated)); state->memory()->gc_stats.promoted_objects_allocated));
counter->add(new ReadAtomicInteger("promoted_bytes", counter->add(new ReadAtomicInteger("promoted_bytes",
state->vm()->om->gc_stats.promoted_bytes_allocated)); state->memory()->gc_stats.promoted_bytes_allocated));
counter->add(new ReadAtomicInteger("mature_objects", counter->add(new ReadAtomicInteger("mature_objects",
state->vm()->om->gc_stats.mature_objects_allocated)); state->memory()->gc_stats.mature_objects_allocated));
counter->add(new ReadAtomicInteger("mature_bytes", counter->add(new ReadAtomicInteger("mature_bytes",
state->vm()->om->gc_stats.mature_bytes_allocated)); state->memory()->gc_stats.mature_bytes_allocated));


Tree* gc_young = system_->get_tree("gc")->get_tree("young"); Tree* gc_young = system_->get_tree("gc")->get_tree("young");


gc_young->add(new ReadAtomicInteger("count", gc_young->add(new ReadAtomicInteger("count",
state->vm()->om->gc_stats.young_collection_count)); state->memory()->gc_stats.young_collection_count));
gc_young->add(new ReadAtomicInteger("total_wallclock", gc_young->add(new ReadAtomicInteger("total_wallclock",
state->vm()->om->gc_stats.total_young_collection_time)); state->memory()->gc_stats.total_young_collection_time));
gc_young->add(new ReadAtomicInteger("last_wallclock", gc_young->add(new ReadAtomicInteger("last_wallclock",
state->vm()->om->gc_stats.last_young_collection_time)); state->memory()->gc_stats.last_young_collection_time));


Tree* gc_full = system_->get_tree("gc")->get_tree("full"); Tree* gc_full = system_->get_tree("gc")->get_tree("full");
gc_full->add(new ReadAtomicInteger("count", gc_full->add(new ReadAtomicInteger("count",
state->vm()->om->gc_stats.full_collection_count)); state->memory()->gc_stats.full_collection_count));
gc_full->add(new ReadAtomicInteger("total_wallclock", gc_full->add(new ReadAtomicInteger("total_wallclock",
state->vm()->om->gc_stats.total_full_collection_time)); state->memory()->gc_stats.total_full_collection_time));
gc_full->add(new ReadAtomicInteger("last_wallclock", gc_full->add(new ReadAtomicInteger("last_wallclock",
state->vm()->om->gc_stats.last_full_collection_time)); state->memory()->gc_stats.last_full_collection_time));


Tree* jit = system_->get_tree("jit"); Tree* jit = system_->get_tree("jit");
jit->add(new ReadAtomicInteger("methods", ss.stats.jitted_methods)); jit->add(new ReadAtomicInteger("methods", ss.stats.jitted_methods));
Expand Down
4 changes: 2 additions & 2 deletions vm/builtin/access_variable.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace rubinius {


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


if(self->reference_p()) { if(self->reference_p()) {
// Promote this to use a direct accessor // Promote this to use a direct accessor
if(TypeInfo* ti = state->vm()->om->find_type_info(self)) { if(TypeInfo* ti = state->memory()->find_type_info(self)) {
TypeInfo::Slots::iterator it = ti->slots.find(access->name()->index()); TypeInfo::Slots::iterator it = ti->slots.find(access->name()->index());
if(it != ti->slots.end()) { if(it != ti->slots.end()) {
// Found one! // Found one!
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/bytearray.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace rubinius {
assert(bytes >= 0 && bytes < INT32_MAX); assert(bytes >= 0 && bytes < INT32_MAX);


size_t body = bytes; size_t body = bytes;
ByteArray* ba = state->vm()->om->new_object_bytes_mature<ByteArray>(state, G(bytearray), body); ByteArray* ba = state->memory()->new_object_bytes_mature<ByteArray>(state, G(bytearray), body);
if(unlikely(!ba)) { if(unlikely(!ba)) {
Exception::memory_error(state); Exception::memory_error(state);
} }
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/chararray.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace rubinius {
assert(bytes >= 0 && bytes < INT32_MAX); assert(bytes >= 0 && bytes < INT32_MAX);


size_t body = bytes; size_t body = bytes;
CharArray* ba = state->vm()->om->new_object_bytes_mature<CharArray>(state, G(chararray), body); CharArray* ba = state->memory()->new_object_bytes_mature<CharArray>(state, G(chararray), body);
if(unlikely(!ba)) { if(unlikely(!ba)) {
Exception::memory_error(state); Exception::memory_error(state);
} }
Expand Down
20 changes: 10 additions & 10 deletions vm/builtin/class.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
namespace rubinius { namespace rubinius {


Class* Class::create(STATE, Class* super) { Class* Class::create(STATE, Class* super) {
Class* cls = state->vm()->om->new_object_enduring<Class>(state, G(klass)); Class* cls = state->memory()->new_object_enduring<Class>(state, G(klass));


cls->init(state->vm()->shared.inc_class_count(state)); cls->init(state->vm()->shared.inc_class_count(state));


cls->name(state, nil<Symbol>()); cls->name(state, nil<Symbol>());
cls->instance_type(state, super->instance_type()); cls->instance_type(state, super->instance_type());


if(super->type_info()->type == PackedObject::type) { if(super->type_info()->type == PackedObject::type) {
cls->set_type_info(state->vm()->om->type_info[ObjectType]); cls->set_type_info(state->memory()->type_info[ObjectType]);
} else { } else {
cls->set_type_info(super->type_info()); cls->set_type_info(super->type_info());
} }
Expand All @@ -48,12 +48,12 @@ namespace rubinius {
} }


Class* Class::s_allocate(STATE) { Class* Class::s_allocate(STATE) {
Class* cls = as<Class>(state->vm()->om->new_object_enduring<Class>(state, G(klass))); Class* cls = as<Class>(state->memory()->new_object_enduring<Class>(state, G(klass)));


cls->init(state->vm()->shared.inc_class_count(state)); cls->init(state->vm()->shared.inc_class_count(state));
cls->setup(state); cls->setup(state);


cls->set_type_info(state->vm()->om->type_info[ObjectType]); cls->set_type_info(state->memory()->type_info[ObjectType]);
return cls; return cls;
} }


Expand Down Expand Up @@ -81,7 +81,7 @@ namespace rubinius {
obj->init_header(self, YoungObjectZone, PackedObject::type); obj->init_header(self, YoungObjectZone, PackedObject::type);
} else { } else {
obj = reinterpret_cast<PackedObject*>( obj = reinterpret_cast<PackedObject*>(
state->vm()->om->new_object_fast(state, self, size, PackedObject::type)); state->memory()->new_object_fast(state, self, size, PackedObject::type));
} }


// Don't use 'this' !!! The above code might have GC'd // Don't use 'this' !!! The above code might have GC'd
Expand Down Expand Up @@ -115,7 +115,7 @@ namespace rubinius {
obj->init_header(self, YoungObjectZone, PackedObject::type); obj->init_header(self, YoungObjectZone, PackedObject::type);
} else { } else {
obj = reinterpret_cast<PackedObject*>( obj = reinterpret_cast<PackedObject*>(
state->vm()->om->new_object_fast(state, self, size, PackedObject::type)); state->memory()->new_object_fast(state, self, size, PackedObject::type));
} }
} else { } else {
return collect_and_allocate(state, gct, self, calling_environment); return collect_and_allocate(state, gct, self, calling_environment);
Expand Down Expand Up @@ -183,7 +183,7 @@ namespace rubinius {


instance_type(state, sup->instance_type()); instance_type(state, sup->instance_type());
if(sup->type_info()->type == PackedObject::type) { if(sup->type_info()->type == PackedObject::type) {
set_type_info(state->vm()->om->type_info[ObjectType]); set_type_info(state->memory()->type_info[ObjectType]);
} else { } else {
set_type_info(sup->type_info()); set_type_info(sup->type_info());
} }
Expand All @@ -195,7 +195,7 @@ namespace rubinius {


void Class::set_object_type(STATE, size_t type) { void Class::set_object_type(STATE, size_t type) {
instance_type(state, Fixnum::from(type)); instance_type(state, Fixnum::from(type));
type_info_ = state->vm()->om->type_info[type]; type_info_ = state->memory()->type_info[type];
} }


/* Look at this class and it's superclass contents (which includes /* Look at this class and it's superclass contents (which includes
Expand Down Expand Up @@ -271,14 +271,14 @@ namespace rubinius {


SingletonClass* SingletonClass::attach(STATE, Object* obj, Class* sup) { SingletonClass* SingletonClass::attach(STATE, Object* obj, Class* sup) {
SingletonClass *sc; SingletonClass *sc;
sc = state->vm()->om->new_object_enduring<SingletonClass>(state, G(klass)); sc = state->memory()->new_object_enduring<SingletonClass>(state, G(klass));
sc->init(state->vm()->shared.inc_class_count(state)); sc->init(state->vm()->shared.inc_class_count(state));


sc->attached_instance(state, obj); sc->attached_instance(state, obj);
sc->setup(state); sc->setup(state);


if(kind_of<PackedObject>(obj)) { if(kind_of<PackedObject>(obj)) {
sc->set_type_info(state->vm()->om->type_info[Object::type]); sc->set_type_info(state->memory()->type_info[Object::type]);
} else { } else {
sc->set_type_info(obj->klass()->type_info()); sc->set_type_info(obj->klass()->type_info());
} }
Expand Down
6 changes: 3 additions & 3 deletions vm/builtin/data.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace rubinius {


// Data is just a heap alias for the handle, so go ahead and create // Data is just a heap alias for the handle, so go ahead and create
// the handle and populate it as an RData now. // the handle and populate it as an RData now.
InflatedHeader* ih = state->vm()->om->inflate_header(state, data); InflatedHeader* ih = state->memory()->inflate_header(state, data);
capi::Handle* handle = ih->handle(); capi::Handle* handle = ih->handle();


assert(!handle && "can't already have a handle, it's brand new!"); assert(!handle && "can't already have a handle, it's brand new!");
Expand All @@ -45,14 +45,14 @@ namespace rubinius {
// If this Data requires a free function, register this object // If this Data requires a free function, register this object
// as needing finalization. // as needing finalization.
if(free) { if(free) {
state->vm()->om->needs_finalization(data, (FinalizerFunction)&Data::finalize); state->memory()->needs_finalization(data, (FinalizerFunction)&Data::finalize);
} }


return data; return data;
} }


RDataShadow* Data::slow_rdata(STATE) { RDataShadow* Data::slow_rdata(STATE) {
InflatedHeader* ih = state->vm()->om->inflate_header(state, this); InflatedHeader* ih = state->memory()->inflate_header(state, this);
capi::Handle* handle = ih->handle(); capi::Handle* handle = ih->handle();


assert(handle && handle->is_rdata() && "invalid initialized Data object"); assert(handle && handle->is_rdata() && "invalid initialized Data object");
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/dir.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace rubinius {
Dir* d = state->new_object<Dir>(G(dir)); Dir* d = state->new_object<Dir>(G(dir));
d->os_ = 0; d->os_ = 0;


state->vm()->om->needs_finalization(d, (FinalizerFunction)&Dir::finalize); state->memory()->needs_finalization(d, (FinalizerFunction)&Dir::finalize);


return d; return d;
} }
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/ffi_pointer.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace rubinius {
autorelease = val->true_p() ? true : false; autorelease = val->true_p() ? true : false;


if(autorelease && !set_finalizer) { if(autorelease && !set_finalizer) {
state->vm()->om->needs_finalization(this, state->memory()->needs_finalization(this,
(FinalizerFunction)&Pointer::finalize); (FinalizerFunction)&Pointer::finalize);
set_finalizer = true; set_finalizer = true;
} }
Expand Down
8 changes: 4 additions & 4 deletions vm/builtin/fiber.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace rubinius {
if(fib->nil_p()) { if(fib->nil_p()) {
fib = state->new_object<Fiber>(G(fiber)); fib = state->new_object<Fiber>(G(fiber));
if(fib->zone() != YoungObjectZone) { if(fib->zone() != YoungObjectZone) {
state->vm()->om->remember_object(fib); state->memory()->remember_object(fib);
} }
fib->prev_ = nil<Fiber>(); fib->prev_ = nil<Fiber>();
fib->top_ = 0; fib->top_ = 0;
Expand All @@ -156,7 +156,7 @@ namespace rubinius {
fib->context_ = new ucontext_t; fib->context_ = new ucontext_t;
#endif #endif


state->vm()->om->needs_finalization(fib, (FinalizerFunction)&Fiber::finalize); state->memory()->needs_finalization(fib, (FinalizerFunction)&Fiber::finalize);


state->vm()->current_fiber.set(fib); state->vm()->current_fiber.set(fib);
state->vm()->root_fiber.set(fib); state->vm()->root_fiber.set(fib);
Expand Down Expand Up @@ -232,7 +232,7 @@ namespace rubinius {


Fiber* fib = state->new_object<Fiber>(G(fiber)); Fiber* fib = state->new_object<Fiber>(G(fiber));
if(fib->zone() != YoungObjectZone) { if(fib->zone() != YoungObjectZone) {
state->vm()->om->remember_object(fib); state->memory()->remember_object(fib);
} }
fib->starter(state, callable); fib->starter(state, callable);
fib->prev(state, nil<Fiber>()); fib->prev(state, nil<Fiber>());
Expand All @@ -243,7 +243,7 @@ namespace rubinius {
fib->stack_size_ = stack_size; fib->stack_size_ = stack_size;
fib->stack_ = malloc(stack_size); fib->stack_ = malloc(stack_size);


state->vm()->om->needs_finalization(fib, (FinalizerFunction)&Fiber::finalize); state->memory()->needs_finalization(fib, (FinalizerFunction)&Fiber::finalize);


#ifdef FIBER_NATIVE #ifdef FIBER_NATIVE
fib->context_ = new fiber_context_t; fib->context_ = new fiber_context_t;
Expand Down
6 changes: 3 additions & 3 deletions vm/builtin/find_object.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ namespace rubinius {
if(obj->ivars() == target_) return true; if(obj->ivars() == target_) return true;


// Check slots. // Check slots.
TypeInfo* ti = state->vm()->om->type_info[obj->type_id()]; TypeInfo* ti = state->memory()->type_info[obj->type_id()];
for(TypeInfo::Slots::iterator i = ti->slots.begin(); for(TypeInfo::Slots::iterator i = ti->slots.begin();
i != ti->slots.end(); i != ti->slots.end();
++i) { ++i) {
Expand Down Expand Up @@ -257,7 +257,7 @@ namespace rubinius {
Object* System::vm_find_object(STATE, Array* arg, Object* callable, Object* System::vm_find_object(STATE, Array* arg, Object* callable,
CallFrame* calling_environment) CallFrame* calling_environment)
{ {
ObjectMemory::GCInhibit inhibitor(state->vm()->om); ObjectMemory::GCInhibit inhibitor(state->memory());


// Support an aux mode, where callable is an array and we just append // Support an aux mode, where callable is an array and we just append
// objects to it rather than #call it. // objects to it rather than #call it.
Expand Down Expand Up @@ -290,7 +290,7 @@ namespace rubinius {
} }


state->set_call_frame(calling_environment); state->set_call_frame(calling_environment);
ObjectWalker walker(state->vm()->om); ObjectWalker walker(state->memory());
GCData gc_data(state->vm()); GCData gc_data(state->vm());


// Seed it with the root objects. // Seed it with the root objects.
Expand Down
4 changes: 2 additions & 2 deletions vm/builtin/heap_dump.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ namespace rubinius {


static Layout* find_layout(STATE, Object* obj, Layout* root, Array* ary, SymbolList& syms) { static Layout* find_layout(STATE, Object* obj, Layout* root, Array* ary, SymbolList& syms) {
// Collect all the ivar names that we want to pull out // Collect all the ivar names that we want to pull out
TypeInfo* ti = state->vm()->om->type_info[obj->type_id()]; TypeInfo* ti = state->memory()->type_info[obj->type_id()];
for(TypeInfo::Slots::iterator i = ti->slots.begin(); for(TypeInfo::Slots::iterator i = ti->slots.begin();
i != ti->slots.end(); i != ti->slots.end();
++i) { ++i) {
Expand Down Expand Up @@ -388,7 +388,7 @@ namespace rubinius {
}; };


Object* System::vm_dump_heap(STATE, String* path) { Object* System::vm_dump_heap(STATE, String* path) {
ObjectWalker walker(state->vm()->om); ObjectWalker walker(state->memory());
GCData gc_data(state->vm()); GCData gc_data(state->vm());


// Seed it with the root objects. // Seed it with the root objects.
Expand Down
4 changes: 2 additions & 2 deletions vm/builtin/io.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace rubinius {


// Don't bother to add finalization for stdio // Don't bother to add finalization for stdio
if(fd >= 3) { if(fd >= 3) {
state->vm()->om->needs_finalization(io, (FinalizerFunction)&IO::finalize); state->memory()->needs_finalization(io, (FinalizerFunction)&IO::finalize);
} }


return io; return io;
Expand All @@ -92,7 +92,7 @@ namespace rubinius {
// Ensure the instance's class is set (i.e. for subclasses of IO) // Ensure the instance's class is set (i.e. for subclasses of IO)
io->klass(state, as<Class>(self)); io->klass(state, as<Class>(self));


state->vm()->om->needs_finalization(io, (FinalizerFunction)&IO::finalize); state->memory()->needs_finalization(io, (FinalizerFunction)&IO::finalize);


return io; return io;
} }
Expand Down
4 changes: 2 additions & 2 deletions vm/builtin/module.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace rubinius {
} }


Module* Module::create(STATE) { Module* Module::create(STATE) {
Module* mod = state->vm()->om->new_object_enduring<Module>(state, G(module)); Module* mod = state->memory()->new_object_enduring<Module>(state, G(module));


mod->name(state, nil<Symbol>()); mod->name(state, nil<Symbol>());
mod->superclass(state, nil<Module>()); mod->superclass(state, nil<Module>());
Expand Down Expand Up @@ -375,7 +375,7 @@ namespace rubinius {


IncludedModule* IncludedModule::create(STATE) { IncludedModule* IncludedModule::create(STATE) {
IncludedModule* imod; IncludedModule* imod;
imod = state->vm()->om->new_object_enduring<IncludedModule>(state, G(included_module)); imod = state->memory()->new_object_enduring<IncludedModule>(state, G(included_module));


imod->name(state, state->symbol("<included module>")); imod->name(state, state->symbol("<included module>"));
imod->superclass(state, nil<Module>()); imod->superclass(state, nil<Module>());
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/nativemethod.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace rubinius {
} }


VALUE NativeMethodFrame::get_handle(STATE, Object* obj) { VALUE NativeMethodFrame::get_handle(STATE, Object* obj) {
InflatedHeader* ih = state->vm()->om->inflate_header(state, obj); InflatedHeader* ih = state->memory()->inflate_header(state, obj);


capi::Handle* handle = ih->handle(); capi::Handle* handle = ih->handle();


Expand Down
Loading

0 comments on commit 8bf4930

Please sign in to comment.