Skip to content

Commit

Permalink
Moved memory+gc classes to 'namespace memory'.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Feb 7, 2016
1 parent b2f8bec commit 1350614
Show file tree
Hide file tree
Showing 136 changed files with 676 additions and 589 deletions.
2 changes: 1 addition & 1 deletion rakelib/blueprint.rb
Expand Up @@ -73,7 +73,7 @@
gcc.ldflags << Rubinius::BUILD_CONFIG[:user_ldflags]

# Files
subdirs = %w[ builtin capi util instruments gc llvm missing ].map do |x|
subdirs = %w[ builtin capi util instruments memory llvm missing ].map do |x|
"vm/#{x}/*.{cpp,c}"
end

Expand Down
6 changes: 4 additions & 2 deletions vm/arguments.hpp
Expand Up @@ -6,9 +6,11 @@
#include "builtin/tuple.hpp"

namespace rubinius {
class Array;
namespace memory {
class GarbageCollector;
}

class GarbageCollector;
class Array;

class Arguments {
Symbol* name_;
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/bignum.cpp
Expand Up @@ -1182,7 +1182,7 @@ namespace rubinius {
return storage->raw_bytes();
}

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

mp_int* n = big->mp_val();
Expand Down
4 changes: 2 additions & 2 deletions vm/builtin/bignum.hpp
Expand Up @@ -211,10 +211,10 @@ namespace rubinius {
allow_user_allocate = false;
}

virtual void mark(Object* t, ObjectMark& mark);
virtual void mark(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, ObjectMark& mark) {}
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
};
};

Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/block_environment.cpp
Expand Up @@ -67,7 +67,7 @@ namespace rubinius {
if(!mcode) {
OnStack<3> os(state, env, args.recv_location(), args.block_location());
OnStack<3> iv(state, invocation.self, invocation.constant_scope, invocation.module);
VariableRootBuffer vrb(state->vm()->current_root_buffers(),
memory::VariableRootBuffer vrb(state->vm()->current_root_buffers(),
&args.arguments_location(), args.total());

mcode = env->machine_code(state, previous);
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/byte_array.cpp
Expand Up @@ -219,7 +219,7 @@ namespace rubinius {
return ba->full_size_;
}

void ByteArray::Info::mark(Object* t, ObjectMark& mark) {
void ByteArray::Info::mark(Object* t, memory::ObjectMark& mark) {
// @todo implement
}
}
4 changes: 2 additions & 2 deletions vm/builtin/byte_array.hpp
Expand Up @@ -84,8 +84,8 @@ namespace rubinius {
allow_user_allocate = false;
}

virtual void mark(Object* t, ObjectMark& mark);
virtual void auto_mark(Object* obj, ObjectMark& mark) {}
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);
};

Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/call_custom_cache.cpp
Expand Up @@ -37,7 +37,7 @@ namespace rubinius {
cu->executable(), cu->module(), args);
}

void CallCustomCache::Info::mark(Object* obj, ObjectMark& mark) {
void CallCustomCache::Info::mark(Object* obj, memory::ObjectMark& mark) {
auto_mark(obj, mark);
}
}
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/call_custom_cache.hpp
Expand Up @@ -39,7 +39,7 @@ namespace rubinius {
class Info : public CallSite::Info {
public:
BASIC_TYPEINFO(CallSite::Info)
virtual void mark(Object* t, ObjectMark& mark);
virtual void mark(Object* t, memory::ObjectMark& mark);
};

};
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/call_site.cpp
Expand Up @@ -289,7 +289,7 @@ namespace rubinius {
return true;
}

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

Expand Down
4 changes: 2 additions & 2 deletions vm/builtin/call_site.hpp
Expand Up @@ -134,8 +134,8 @@ namespace rubinius {
allow_user_allocate = false;
}

virtual void mark(Object* obj, ObjectMark& mark);
virtual void auto_mark(Object* obj, ObjectMark& mark);
virtual void mark(Object* obj, memory::ObjectMark& mark);
virtual void auto_mark(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();
Expand Down
6 changes: 4 additions & 2 deletions vm/builtin/compiled_code.cpp
Expand Up @@ -19,6 +19,8 @@
#include "builtin/symbol.hpp"
#include "builtin/tuple.hpp"

#include "memory/object_mark.hpp"

#include "util/logger.hpp"

#include <ostream>
Expand Down Expand Up @@ -200,7 +202,7 @@ namespace rubinius {

OnStack<5> os(state, code, exec, mod, args.recv_location(), args.block_location());

VariableRootBuffer vrb(state->vm()->current_root_buffers(),
memory::VariableRootBuffer vrb(state->vm()->current_root_buffers(),
&args.arguments_location(), args.total());

if(!code->internalize(state, call_frame, &reason, &ip)) {
Expand Down Expand Up @@ -457,7 +459,7 @@ namespace rubinius {
return cNil;
}

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

mark_inliners(obj, mark);
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/compiled_code.hpp
Expand Up @@ -179,7 +179,7 @@ namespace rubinius {
class Info : public Executable::Info {
public:
BASIC_TYPEINFO(Executable::Info)
virtual void mark(Object* obj, ObjectMark& mark);
virtual void mark(Object* obj, memory::ObjectMark& mark);
virtual void show(STATE, Object* self, int level);
};

Expand Down
8 changes: 4 additions & 4 deletions vm/builtin/data.cpp
Expand Up @@ -39,7 +39,7 @@ namespace rubinius {
data->internal_ = rdata;

if(mark || free) {
state->memory()->needs_finalization(data, (FinalizerFunction)&Data::finalize);
state->memory()->needs_finalization(data, (memory::FinalizerFunction)&Data::finalize);
}

state->vm()->metrics().memory.data_objects++;
Expand Down Expand Up @@ -72,7 +72,7 @@ namespace rubinius {
data->internal_ = rdata;

if(type->function.dmark || type->function.dfree) {
state->memory()->needs_finalization(data, (FinalizerFunction)&Data::finalize);
state->memory()->needs_finalization(data, (memory::FinalizerFunction)&Data::finalize);
}

state->vm()->metrics().memory.data_objects++;
Expand Down Expand Up @@ -138,7 +138,7 @@ namespace rubinius {
}
}

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

Data* data = force_as<Data>(t);
Expand All @@ -161,7 +161,7 @@ namespace rubinius {
Data::MarkFunctor marker = data->mark();

if(marker) {
ObjectMark* cur = capi::current_mark();
memory::ObjectMark* cur = capi::current_mark();
capi::set_current_mark(&mark);

(*marker)(data->data());
Expand Down
4 changes: 2 additions & 2 deletions vm/builtin/data.hpp
Expand Up @@ -112,8 +112,8 @@ namespace rubinius {
class Info : public TypeInfo {
public:
Info(object_type type) : TypeInfo(type) { }
virtual void mark(Object* t, ObjectMark& mark);
virtual void auto_mark(Object* obj, ObjectMark& mark) {}
virtual void mark(Object* t, memory::ObjectMark& mark);
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
};
};

Expand Down
5 changes: 3 additions & 2 deletions vm/builtin/dir.cpp
Expand Up @@ -18,8 +18,9 @@ namespace rubinius {
Dir* d = Dir::allocate(state, G(dir));
d->os_ = 0;

state->memory()->needs_finalization(d, (FinalizerFunction)&Dir::finalize,
FinalizeObject::eUnmanaged);
state->memory()->needs_finalization(d,
(memory::FinalizerFunction)&Dir::finalize,
memory::FinalizeObject::eUnmanaged);

return d;
}
Expand Down
7 changes: 4 additions & 3 deletions vm/builtin/encoding.cpp
Expand Up @@ -598,7 +598,7 @@ namespace rubinius {
return n;
}

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

Encoding* enc_o = force_as<Encoding>(obj);
Expand Down Expand Up @@ -733,8 +733,9 @@ namespace rubinius {

c->set_converter(NULL);

state->memory()->needs_finalization(c, (FinalizerFunction)&Converter::finalize,
FinalizeObject::eUnmanaged);
state->memory()->needs_finalization(c,
(memory::FinalizerFunction)&Converter::finalize,
memory::FinalizeObject::eUnmanaged);

return c;
}
Expand Down
4 changes: 2 additions & 2 deletions vm/builtin/encoding.hpp
Expand Up @@ -154,8 +154,8 @@ namespace rubinius {
allow_user_allocate = false;
}

virtual void mark(Object* obj, ObjectMark& mark);
virtual void auto_mark(Object* obj, ObjectMark& mark);
virtual void mark(Object* obj, memory::ObjectMark& mark);
virtual void auto_mark(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();
Expand Down
6 changes: 3 additions & 3 deletions vm/builtin/executable.cpp
Expand Up @@ -80,12 +80,12 @@ namespace rubinius {
inliners_->inliners().clear();
}

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

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

Expand All @@ -110,7 +110,7 @@ namespace rubinius {
om->add_code_resource(state, this);
}

void Inliners::cleanup(STATE, CodeManager* cm) {
void Inliners::cleanup(STATE, memory::CodeManager* cm) {
inliners_.clear();
}
}
8 changes: 4 additions & 4 deletions vm/builtin/executable.hpp
Expand Up @@ -19,7 +19,7 @@ namespace rubinius {
class CompiledCode;
class ObjectMemory;

class Inliners : public CodeResource {
class Inliners : public memory::CodeResource {
std::vector<CompiledCode*> inliners_;

public:
Expand All @@ -29,7 +29,7 @@ namespace rubinius {
return inliners_;
}

void cleanup(State* state, CodeManager* cm);
void cleanup(State* state, memory::CodeManager* cm);
};

class Executable : public Object {
Expand Down Expand Up @@ -108,9 +108,9 @@ namespace rubinius {
public:
BASIC_TYPEINFO(TypeInfo)

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

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

friend class Info;
Expand Down
5 changes: 3 additions & 2 deletions vm/builtin/ffi_pointer.cpp
Expand Up @@ -116,7 +116,8 @@ namespace rubinius {
if(autorelease) {
if(!set_finalizer) {
state->memory()->needs_finalization(this,
(FinalizerFunction)&Pointer::finalize, FinalizeObject::eUnmanaged);
(memory::FinalizerFunction)&Pointer::finalize,
memory::FinalizeObject::eUnmanaged);
set_finalizer = true;
}
} else {
Expand Down Expand Up @@ -538,6 +539,6 @@ namespace rubinius {
}
}

void Pointer::Info::mark(Object* obj, ObjectMark& mark) {
void Pointer::Info::mark(Object* obj, memory::ObjectMark& mark) {
}
}
4 changes: 2 additions & 2 deletions vm/builtin/ffi_pointer.hpp
Expand Up @@ -124,8 +124,8 @@ namespace rubinius {
class Info : public TypeInfo {
public:
Info(object_type type) : TypeInfo(type) { }
virtual void mark(Object* t, ObjectMark& mark);
virtual void auto_mark(Object* obj, ObjectMark& mark) {}
virtual void mark(Object* t, memory::ObjectMark& mark);
virtual void auto_mark(Object* obj, memory::ObjectMark& mark) {}
};
};
}
Expand Down
12 changes: 7 additions & 5 deletions vm/builtin/fiber.cpp
Expand Up @@ -36,8 +36,9 @@ namespace rubinius {

fib->data_ = state->vm()->new_fiber_data(true);

state->memory()->needs_finalization(fib, (FinalizerFunction)&Fiber::finalize,
FinalizeObject::eUnmanaged);
state->memory()->needs_finalization(fib,
(memory::FinalizerFunction)&Fiber::finalize,
memory::FinalizeObject::eUnmanaged);

state->vm()->current_fiber.set(fib);
state->vm()->root_fiber.set(fib);
Expand Down Expand Up @@ -105,8 +106,9 @@ namespace rubinius {
fib->starter(state, callable);
fib->status_ = Fiber::eSleeping;

state->memory()->needs_finalization(fib, (FinalizerFunction)&Fiber::finalize,
FinalizeObject::eUnmanaged);
state->memory()->needs_finalization(fib,
(memory::FinalizerFunction)&Fiber::finalize,
memory::FinalizeObject::eUnmanaged);

return fib;
#else
Expand Down Expand Up @@ -284,7 +286,7 @@ namespace rubinius {
#endif
}

void Fiber::Info::mark(Object* obj, ObjectMark& mark) {
void Fiber::Info::mark(Object* obj, memory::ObjectMark& mark) {
auto_mark(obj, mark);
Fiber* fib = force_as<Fiber>(obj);
FiberData* data = fib->data_;
Expand Down
4 changes: 2 additions & 2 deletions vm/builtin/fiber.hpp
Expand Up @@ -85,7 +85,7 @@ namespace rubinius {
return data_->stack_size();
}

VariableRootBuffers& variable_root_buffers() {
memory::VariableRootBuffers& variable_root_buffers() {
return data_->variable_root_buffers();
}

Expand Down Expand Up @@ -126,7 +126,7 @@ namespace rubinius {
class Info : public TypeInfo {
public:
BASIC_TYPEINFO(TypeInfo)
virtual void mark(Object* t, ObjectMark& mark);
virtual void mark(Object* t, memory::ObjectMark& mark);
};
};
}
Expand Down
6 changes: 3 additions & 3 deletions vm/builtin/find_object.cpp
Expand Up @@ -302,8 +302,8 @@ namespace rubinius {
OnStack<2> os(state, ary, args);

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

{
LockPhase locked(state);
Expand Down Expand Up @@ -331,7 +331,7 @@ namespace rubinius {
for(size_t i = 0; i < stack_size; ++i) {
variable_buffer[i] = &stack_buf[i];
}
VariableRootBuffer vrb(state->vm()->current_root_buffers(),
memory::VariableRootBuffer vrb(state->vm()->current_root_buffers(),
variable_buffer, stack_size);
args->set(state, 0, obj);
ret = callable->send(state, calling_environment, G(sym_call),
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/fixnum.cpp
Expand Up @@ -483,5 +483,5 @@ namespace rubinius {
show(state, self, level);
}

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

0 comments on commit 1350614

Please sign in to comment.