Skip to content

Commit

Permalink
Removed remaining CallFrame passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Mar 14, 2016
1 parent 662b431 commit 33c4672
Show file tree
Hide file tree
Showing 24 changed files with 89 additions and 111 deletions.
2 changes: 1 addition & 1 deletion machine/builtin/array.cpp
Expand Up @@ -140,7 +140,7 @@ namespace rubinius {
}

if(CBOOL(value->respond_to(state, G(sym_to_ary), cTrue))) {
Object* res = value->send(state, state->vm()->call_frame(), G(sym_to_ary));
Object* res = value->send(state, G(sym_to_ary));
if(!res) return 0;

if(Array* ary = try_as<Array>(res)) {
Expand Down
4 changes: 2 additions & 2 deletions machine/builtin/autoload.cpp
Expand Up @@ -18,7 +18,7 @@ namespace rubinius {
Autoload* self = this;
OnStack<2> os(state, self, under);

Object* res = send(state, state->vm()->call_frame(), state->symbol("resolve"));
Object* res = send(state, state->symbol("resolve"));
if(!res) return NULL;

if(CBOOL(res) || !honor_require) {
Expand All @@ -39,7 +39,7 @@ namespace rubinius {
Autoload* self = this;
OnStack<1> os(state, self);

Object* res = send(state, state->vm()->call_frame(), state->symbol("resolve"));
Object* res = send(state, state->symbol("resolve"));
if(!res) return NULL;

if(CBOOL(res) || !honor_require) {
Expand Down
4 changes: 2 additions & 2 deletions machine/builtin/block_environment.cpp
Expand Up @@ -226,7 +226,7 @@ namespace rubinius {
*/
Memory::GCInhibit inhibitor(state);

if(!(obj = obj->send(state, state->vm()->call_frame(), G(sym_to_ary)))) {
if(!(obj = obj->send(state, G(sym_to_ary)))) {
return false;
}
}
Expand Down Expand Up @@ -286,7 +286,7 @@ namespace rubinius {
*/
Memory::GCInhibit inhibitor(state);

kw_result = dispatch.send(state, state->vm()->call_frame(), args);
kw_result = dispatch.send(state, args);
}

if(kw_result) {
Expand Down
3 changes: 1 addition & 2 deletions machine/builtin/call_site.cpp
Expand Up @@ -57,8 +57,7 @@ namespace rubinius {
*/
Memory::GCInhibit inhibitor(state);

ret = G(rubinius)->send(state, state->vm()->call_frame(),
state->symbol("bind_call"), ary);
ret = G(rubinius)->send(state, state->symbol("bind_call"), ary);
}

if(CallUnit* cu = try_as<CallUnit>(ret)) {
Expand Down
2 changes: 1 addition & 1 deletion machine/builtin/executable.cpp
Expand Up @@ -57,7 +57,7 @@ namespace rubinius {

Dispatch dispatch(G(sym_call));

return dispatch.send(state, state->vm()->call_frame(), args);
return dispatch.send(state, args);
}

void Executable::add_inliner(STATE, Memory* om, CompiledCode* code) {
Expand Down
2 changes: 1 addition & 1 deletion machine/builtin/fiber.cpp
Expand Up @@ -63,7 +63,7 @@ namespace rubinius {
vm->set_current_fiber(fib);

Array* result = nil<Array>();
Object* obj = fib->starter()->send(state, NULL, G(sym_call), fib->value(), cNil, false);
Object* obj = fib->starter()->send(state, G(sym_call), fib->value(), cNil, false);

// GC has run! Don't use stack vars!

Expand Down
6 changes: 2 additions & 4 deletions machine/builtin/find_object.cpp
Expand Up @@ -287,8 +287,7 @@ namespace rubinius {
ary->append(state, obj);
} else {
args->set(state, 0, obj);
ret = callable->send(state, state->vm()->call_frame(), G(sym_call),
args, cNil, false);
ret = callable->send(state, G(sym_call), args, cNil, false);
}

delete condition;
Expand Down Expand Up @@ -330,8 +329,7 @@ namespace rubinius {
memory::VariableRootBuffer vrb(state->vm()->current_root_buffers(),
variable_buffer, stack_size);
args->set(state, 0, obj);
ret = callable->send(state, state->vm()->call_frame(), G(sym_call),
args, cNil, false);
ret = callable->send(state, G(sym_call), args, cNil, false);
if(!ret) break;
}
}
Expand Down
17 changes: 6 additions & 11 deletions machine/builtin/native_function.cpp
Expand Up @@ -403,7 +403,7 @@ namespace rubinius {
ary->set(state, 0, Fixnum::from(*(int*)parameters[i]));

Object* result = stub->args_info[i].enum_obj->send(state,
env->current_call_frame(), state->symbol("symbol"), ary);
state->symbol("symbol"), ary);

if(!result) {
utilities::logger::error("Exception raised by callback, ignoring");
Expand Down Expand Up @@ -478,8 +478,7 @@ namespace rubinius {
}
}

Object* obj = stub->callable->send(
state, env->current_call_frame(), G(sym_call), args);
Object* obj = stub->callable->send(state, G(sym_call), args);

// Ug. An exception is being raised...
if(!obj) {
Expand Down Expand Up @@ -556,8 +555,7 @@ namespace rubinius {
Array* ary = Array::create(state, 1);
ary->set(state, 0, obj);

Object* value = stub->ret_info.enum_obj->send(
state, env->current_call_frame(), state->symbol("[]"), ary);
Object* value = stub->ret_info.enum_obj->send(state, state->symbol("[]"), ary);

if(!value) {
// For now, log the error and return nil.
Expand Down Expand Up @@ -922,8 +920,7 @@ namespace rubinius {
heap_allocations[ffi_index] = data;
*tmp = data;
} else if(CBOOL(obj->respond_to(state, state->symbol("to_ptr"), cTrue))) {
Object* o2 = obj->send(state,
state->vm()->call_frame(), state->symbol("to_ptr"));
Object* o2 = obj->send(state, state->symbol("to_ptr"));
if(!o2) {
for(size_t i = 0; i < arg_count; i++) {
if(heap_allocations[i]) {
Expand Down Expand Up @@ -953,8 +950,7 @@ namespace rubinius {
Array* ary = Array::create(state, 1);
ary->set(state, 0, obj);

Object* val = arg_info->enum_obj->send(
state, state->vm()->call_frame(), state->symbol("[]"), ary);
Object* val = arg_info->enum_obj->send(state, state->symbol("[]"), ary);

if(!val) {
for(size_t i = 0; i < arg_count; i++) {
Expand Down Expand Up @@ -1149,8 +1145,7 @@ namespace rubinius {
Array* ary = Array::create(state, 1);
ary->set(state, 0, Integer::from(state, (native_int)result));

ret = ffi_data->ret_info.enum_obj->send(state,
state->vm()->call_frame(), state->symbol("symbol"), ary);
ret = ffi_data->ret_info.enum_obj->send(state, state->symbol("symbol"), ary);
break;
}
case RBX_FFI_TYPE_CALLBACK: {
Expand Down
46 changes: 23 additions & 23 deletions machine/builtin/object.cpp
Expand Up @@ -518,9 +518,7 @@ namespace rubinius {
return class_object(state);
}

Object* Object::send(STATE, CallFrame* caller, Symbol* name, Array* ary,
Object* block, bool allow_private)
{
Object* Object::send(STATE, Symbol* name, Array* ary, Object* block, bool allow_private) {
LookupData lookup(this, this->lookup_begin(state),
allow_private ? G(sym_private) : G(sym_protected));
Dispatch dispatch(name);
Expand All @@ -529,10 +527,10 @@ namespace rubinius {
args.set_block(block);
args.set_recv(this);

return dispatch.send(state, caller, lookup, args);
return dispatch.send(state, lookup, args);
}

Object* Object::send(STATE, CallFrame* caller, Symbol* name, bool allow_private) {
Object* Object::send(STATE, Symbol* name, bool allow_private) {
LookupData lookup(this, this->lookup_begin(state),
allow_private ? G(sym_private) : G(sym_protected));
Dispatch dispatch(name);
Expand All @@ -541,26 +539,28 @@ namespace rubinius {
args.set_block(cNil);
args.set_recv(this);

return dispatch.send(state, caller, lookup, args);
return dispatch.send(state, lookup, args);
}

Object* Object::send_prim(STATE, Executable* exec,
Object* Object::send(STATE, Executable* exec,
Module* mod, Arguments& args, Symbol* min_visibility)
{
if(args.total() < 1) return Primitives::failure();

// Don't shift the argument because we might fail and we need Arguments
// to be pristine in the fallback code.
/* Don't shift the argument because we might fail and we need Arguments to
* be pristine in the fallback code.
*/
Object* meth = args.get_argument(0);
Symbol* sym = try_as<Symbol>(meth);

// All coercion must be done here. Coercing Ruby-side and then
// re-calling #send/#__send__ would produce incorrect results when
// sending messages that are sensitive to the call stack like
// send("__callee__") and the regex globals following send("gsub").
//
// MRI checks for Fixnum explicitly and raises ArgumentError
// instead of TypeError. Seems silly, so we don't bother.
/* All coercion must be done here. Coercing Ruby-side and then re-calling
* #send/#__send__ would produce incorrect results when sending messages
* that are sensitive to the call stack like send("__callee__") and the
* regex globals following send("gsub").
*
* MRI checks for Fixnum explicitly and raises ArgumentError instead of
* TypeError. Seems silly, so we don't bother.
*/
if(!sym) {
if(String* str = try_as<String>(meth)) {
sym = str->to_sym(state);
Expand All @@ -573,9 +573,9 @@ namespace rubinius {
args.shift(state);
args.set_name(sym);

// We have to send it with self from the current frame as the
// source, not this object to have correct visibility checks
// for protected.
/* We have to send it with self from the current frame as the source, not
* this object to have correct visibility checks for protected.
*/
Dispatch dispatch(sym);
Object* scope = this;
CallFrame* call_frame = state->vm()->call_frame();
Expand All @@ -584,19 +584,19 @@ namespace rubinius {
}
LookupData lookup(scope, lookup_begin(state), min_visibility);

return dispatch.send(state, call_frame, lookup, args);
return dispatch.send(state, lookup, args);
}

Object* Object::private_send_prim(STATE,
Executable* exec, Module* mod, Arguments& args)
{
return send_prim(state, exec, mod, args, G(sym_private));
return send(state, exec, mod, args, G(sym_private));
}

Object* Object::public_send_prim(STATE,
Executable* exec, Module* mod, Arguments& args)
{
return send_prim(state, exec, mod, args, G(sym_public));
return send(state, exec, mod, args, G(sym_public));
}

void Object::set_field(STATE, size_t index, Object* val) {
Expand Down Expand Up @@ -921,7 +921,7 @@ namespace rubinius {

Arguments args(missing, this, 2, buf);

if(Object* responds = dispatch.send(state, 0, lookup, args)) {
if(Object* responds = dispatch.send(state, lookup, args)) {
return RBOOL(CBOOL(responds));
}

Expand Down
6 changes: 3 additions & 3 deletions machine/builtin/object.hpp
Expand Up @@ -166,11 +166,11 @@ namespace rubinius {
* Sets up the current task to send the given method name to this
* Object, passing the given number of arguments through varargs.
*/
Object* send(STATE, CallFrame* caller, Symbol* name, Array* args,
Object* send(STATE, Symbol* name, Array* args,
Object* block = cNil, bool allow_private = true);
Object* send(STATE, CallFrame* caller, Symbol* name, bool allow_private = true);
Object* send(STATE, Symbol* name, bool allow_private = true);

Object* send_prim(STATE, Executable* exec, Module* mod, Arguments& args,
Object* send(STATE, Executable* exec, Module* mod, Arguments& args,
Symbol* min_visibility);

/**
Expand Down
9 changes: 3 additions & 6 deletions machine/builtin/pack.cpp
Expand Up @@ -39,8 +39,7 @@ namespace rubinius {
Array* args = Array::create(state, 1);
args->set(state, 0, obj);

return G(rubinius)->send(state, state->vm()->call_frame(),
state->symbol("pack_to_int"), args);
return G(rubinius)->send(state, state->symbol("pack_to_int"), args);
}

#define BITS_LONG (RBX_SIZEOF_LONG * 8)
Expand Down Expand Up @@ -71,8 +70,7 @@ namespace rubinius {
Array* args = Array::create(state, 1);
args->set(state, 0, obj);

return G(rubinius)->send(state, state->vm()->call_frame(),
state->symbol("pack_to_float"), args);
return G(rubinius)->send(state, state->symbol("pack_to_float"), args);
}

inline String* encoding_string(STATE, Object* obj, const char* coerce_name)
Expand All @@ -85,8 +83,7 @@ namespace rubinius {

std::string coerce_method("pack_");
coerce_method += coerce_name;
Object* result = G(rubinius)->send(state, state->vm()->call_frame(),
state->symbol(coerce_method.c_str()), args);
Object* result = G(rubinius)->send(state, state->symbol(coerce_method.c_str()), args);

if(!result) return 0;
return as<String>(result);
Expand Down
4 changes: 2 additions & 2 deletions machine/builtin/proc.cpp
Expand Up @@ -80,7 +80,7 @@ namespace rubinius {
*/
Memory::GCInhibit inhibitor(state);

obj = obj->send(state, state->vm()->call_frame(), G(sym_to_ary));
obj = obj->send(state, G(sym_to_ary));
}

if(!(ary = try_as<Array>(obj))) {
Expand Down Expand Up @@ -121,7 +121,7 @@ namespace rubinius {
if(self->bound_method_->nil_p()) {
if(self->block_->nil_p()) {
Dispatch dispatch(state->symbol("__yield__"));
return dispatch.send(state, state->vm()->call_frame(), args);
return dispatch.send(state, args);
} else {
return self->block_->call(state, args, flags);
}
Expand Down
5 changes: 2 additions & 3 deletions machine/builtin/system.cpp
Expand Up @@ -1425,7 +1425,7 @@ namespace rubinius {
args.set_recv(obj);

OnStack<1> os(state, dest);
Object* ret = dispatch.send(state, state->vm()->call_frame(), lookup, args);
Object* ret = dispatch.send(state, lookup, args);

if(!ret && state->vm()->thread_state()->raise_reason() == cCatchThrow) {
if(state->vm()->thread_state()->throw_dest() == dest) {
Expand Down Expand Up @@ -1542,8 +1542,7 @@ namespace rubinius {
buf[0] = name;
buf[1] = G(sym_public);
Arguments args(name, obj, 2, buf);
responds = RBOOL(CBOOL(dispatch.send(state,
state->vm()->call_frame(), lookup, args)));
responds = RBOOL(CBOOL(dispatch.send(state, lookup, args)));
}
return responds;
}
Expand Down
6 changes: 3 additions & 3 deletions machine/builtin/thread.cpp
Expand Up @@ -111,7 +111,7 @@ namespace rubinius {
}

Object* send_run(STATE) {
return state->vm()->thread.get()->send(state, NULL, state->symbol("__run__"));
return state->vm()->thread.get()->send(state, state->symbol("__run__"));
}

Thread* Thread::allocate(STATE, Object* self) {
Expand Down Expand Up @@ -315,7 +315,7 @@ namespace rubinius {
Object* instance = 0;
OnStack<1> os(state, instance);

instance = klass->send(state, 0, state->symbol("new"));
instance = klass->send(state, state->symbol("new"));
if(instance) {
state->shared().env()->set_loader(instance);
} else {
Expand All @@ -325,7 +325,7 @@ namespace rubinius {
// Enable the JIT after the core library has loaded
G(jit)->enable(state);

Object* exit = instance->send(state, 0, state->symbol("main"));
Object* exit = instance->send(state, state->symbol("main"));

state->shared().signals()->system_exit(state->vm()->thread_state()->raise_value());

Expand Down

0 comments on commit 33c4672

Please sign in to comment.