Browse files

Renamed some internal setup() to prepare() for clarity.

  • Loading branch information...
1 parent fe4a3fa commit dd28d0e4e66c179f8e8ffd5b96293d8b37cb991d @rue rue committed Feb 18, 2009
Showing with 54 additions and 34 deletions.
  1. +24 −22 vm/builtin/block_environment.cpp
  2. +4 −1 vm/builtin/variable_scope.hpp
  3. +4 −1 vm/call_frame.hpp
  4. +1 −0 vm/environment.cpp
  5. +11 −10 vm/vmmethod.cpp
  6. +10 −0 vm/vmmethod.hpp
View
46 vm/builtin/block_environment.cpp
@@ -33,6 +33,7 @@ namespace rubinius {
return env;
}
+ /** @todo Duplicates VMMethod functionality. Refactor. --rue */
Object* BlockEnvironment::call(STATE, CallFrame* call_frame, size_t args) {
Object* val;
if(args > 0) {
@@ -57,23 +58,24 @@ namespace rubinius {
scope->setup_as_block(top_scope_, scope_, vmm->number_of_locals);
- CallFrame* cf = (CallFrame*)alloca(sizeof(CallFrame) + (vmm->stack_size * sizeof(Object*)));
- cf->setup(vmm->stack_size);
+ CallFrame* frame = (CallFrame*)alloca(sizeof(CallFrame) + (vmm->stack_size * sizeof(Object*)));
+ frame->prepare(vmm->stack_size);
- cf->is_block = true;
- cf->previous = call_frame;
- cf->name = name_;
- cf->cm = method_;
- cf->args = args;
- cf->scope = scope;
- cf->top_scope = top_scope_;
+ frame->is_block = true;
+ frame->previous = call_frame;
+ frame->name = name_;
+ frame->cm = method_;
+ frame->args = args;
+ frame->scope = scope;
+ frame->top_scope = top_scope_;
// if(unlikely(task->profiler)) task->profiler->enter_block(state, home_, method_);
- cf->push(val);
- return VMMethod::run_interpreter(state, vmm, cf);
+ frame->push(val);
+ return VMMethod::run_interpreter(state, vmm, frame);
}
+ /** @todo See above. --rue */
Object* BlockEnvironment::call(STATE, CallFrame* call_frame, Message& msg) {
Object* val;
if(msg.args() > 0) {
@@ -92,21 +94,21 @@ namespace rubinius {
scope->setup_as_block(top_scope_, scope_, vmm->number_of_locals);
- CallFrame* cf = (CallFrame*)alloca(sizeof(CallFrame) + (vmm->stack_size * sizeof(Object*)));
- cf->setup(vmm->stack_size);
+ CallFrame* frame = (CallFrame*)alloca(sizeof(CallFrame) + (vmm->stack_size * sizeof(Object*)));
+ frame->prepare(vmm->stack_size);
- cf->is_block = true;
- cf->previous = call_frame;
- cf->name = name_;
- cf->cm = method_;
- cf->args = msg.args();
- cf->scope = scope;
- cf->top_scope = top_scope_;
+ frame->is_block = true;
+ frame->previous = call_frame;
+ frame->name = name_;
+ frame->cm = method_;
+ frame->args = msg.args();
+ frame->scope = scope;
+ frame->top_scope = top_scope_;
// if(unlikely(task->profiler)) task->profiler->enter_block(state, home_, method_);
- cf->push(val);
- return VMMethod::run_interpreter(state, vmm, cf);
+ frame->push(val);
+ return VMMethod::run_interpreter(state, vmm, frame);
}
Object* BlockEnvironment::call_prim(STATE, Executable* exec, CallFrame* call_frame, Message& msg) {
View
5 vm/builtin/variable_scope.hpp
@@ -27,7 +27,10 @@ namespace rubinius {
static void init(STATE);
- void setup(Object* self, Module* mod, Object* block, int num) {
+ /**
+ * Initialize and default scope.
+ */
+ void prepare(Object* self, Module* mod, Object* block, int num) {
obj_type = InvalidType;
parent_ = (VariableScope*)Qnil;
self_ = self;
View
5 vm/call_frame.hpp
@@ -37,7 +37,10 @@ namespace rubinius {
// MUST BE AT THE END!
Object* stk[];
- void setup(int stack) {
+ /**
+ * Initialize frame for the given stack size.
+ */
+ void prepare(int stack) {
is_block = false;
ip = 0;
current_unwind = 0;
View
1 vm/environment.cpp
@@ -136,6 +136,7 @@ namespace rubinius {
CompiledFile* cf = CompiledFile::load(stream);
if(cf->magic != "!RBIX") throw std::runtime_error("Invalid file");
+ /** @todo Redundant? CompiledFile::execute() does this. --rue */
state->thread_state()->clear_exception();
// TODO check version number
View
21 vm/vmmethod.cpp
@@ -469,33 +469,34 @@ namespace rubinius {
VariableScope* scope = (VariableScope*)alloca(sizeof(VariableScope) +
(vmm->number_of_locals * sizeof(Object*)));
- scope->setup(msg.recv, msg.module, msg.block, vmm->number_of_locals);
+ scope->prepare(msg.recv, msg.module, msg.block, vmm->number_of_locals);
- CallFrame* cf = (CallFrame*)alloca(sizeof(CallFrame) + (vmm->stack_size * sizeof(Object*)));
- cf->setup(vmm->stack_size);
+ CallFrame* frame = (CallFrame*)alloca(sizeof(CallFrame) + (vmm->stack_size * sizeof(Object*)));
+ frame->prepare(vmm->stack_size);
- cf->previous = previous;
- cf->name = msg.name;
- cf->cm = cm;
- cf->args = msg.args();
- cf->scope = cf->top_scope = scope;
+ frame->previous = previous;
+ frame->name = msg.name;
+ frame->cm = cm;
+ frame->args = msg.args();
+ frame->scope = frame->top_scope = scope;
// If argument handling fails..
ArgumentHandler args;
if(args.call(state, vmm, scope, msg) == false) {
Exception* exc =
Exception::make_argument_error(state, vmm->required_args, msg.args(), msg.name);
- exc->fill_locations(state, cf);
+ exc->fill_locations(state, frame);
state->thread_state()->raise_exception(exc);
return NULL;
}
// if(unlikely(task->profiler)) task->profiler->enter_method(state, msg, cm);
- return run_interpreter(state, vmm, cf);
+ return run_interpreter(state, vmm, frame);
}
+ /** @todo Is this redundant after having gone through set_argument_handler? --rue */
Object* VMMethod::execute(STATE, CallFrame* previous, Message& msg) {
return execute_specialized<GenericArguments>(state, previous, msg);
}
View
10 vm/vmmethod.hpp
@@ -79,8 +79,18 @@ namespace rubinius {
{}
};
+ /**
+ * Dispatch method on the defined interpreter.
+ */
static Object* run_interpreter(STATE, VMMethod* const vmm, CallFrame* const call_frame);
+
+ /**
+ * Interpreting implementation.
+ *
+ * @see vm/llvm/instructions.cpp for the code.
+ */
static Object* interpreter(STATE, VMMethod* const vmm, CallFrame* const call_frame);
+
static Object* debugger_interpreter(STATE, VMMethod* const vmm, CallFrame* const call_frame);
void setup_argument_handler(CompiledMethod* meth);

0 comments on commit dd28d0e

Please sign in to comment.