Skip to content

Commit

Permalink
Updated JIT for removed CallFrame* passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Mar 20, 2016
1 parent 154bde3 commit 9e28da4
Show file tree
Hide file tree
Showing 13 changed files with 589 additions and 728 deletions.
9 changes: 3 additions & 6 deletions machine/llvm/inline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,20 +474,18 @@ namespace rubinius {
if(!found) {
Signature sig2(ops_.context(), "Object");
sig2 << "State";
sig2 << "CallFrame";
sig2 << "Object";
sig2 << "Object";
sig2 << "Object";

Value* call_args2[] = {
ops_.state(),
ops_.call_frame(),
self,
ops_.constant(acc->name()),
val
};

sig2.call("rbx_set_ivar", call_args2, 5, "ivar",
sig2.call("rbx_set_ivar", call_args2, 4, "ivar",
ops_.b());
}
}
Expand Down Expand Up @@ -935,10 +933,9 @@ namespace rubinius {

Signature check(ops_.context(), ops_.NativeIntTy);
check << "State";
check << "CallFrame";

Value* check_args[] = { ops_.state(), ops_.call_frame() };
check.call("rbx_enter_unmanaged", check_args, 2, "unused", ops_.b());
Value* check_args[] = { ops_.state() };
check.call("rbx_enter_unmanaged", check_args, 1, "unused", ops_.b());

Type* return_type = find_type(ops_, nf->ffi_data->ret_info.type);

Expand Down
44 changes: 12 additions & 32 deletions machine/llvm/inline_primitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,18 +1287,16 @@ namespace rubinius {

Signature sig(ops.context(), "Object");
sig << "State";
sig << "CallFrame";
sig << "Object";

Function* func = sig.function("rbx_create_instance");
func->setDoesNotCapture(1);
func->setDoesNotCapture(2);
func->setDoesNotCapture(3);
func->setDoesNotAlias(0);

Value* call_args[] = { ops.state(), ops.call_frame(), cls };
Value* call_args[] = { ops.state(), cls };

CallInst* out = sig.call("rbx_create_instance", call_args, 3,
CallInst* out = sig.call("rbx_create_instance", call_args, 2,
"instance", ops.b());
// Even though an allocation actually modifies memory etc, it does
// not have the semantics that it does. Allocation of this object
Expand Down Expand Up @@ -1455,20 +1453,16 @@ namespace rubinius {

ops.set_block(set);

Value* call_frame = ops.call_frame();

Signature sig(ops.context(), ops.ObjType);
sig << ops.StateTy;
sig << ops.ObjType;
sig << "CallFrame";

Value* call_args[] = {
ops.state(),
matchdata,
call_frame
};

CallInst* res = sig.call("rbx_regexp_set_last_match", call_args, 3, "set_last_match", ops.b());
CallInst* res = sig.call("rbx_regexp_set_last_match", call_args, 2, "set_last_match", ops.b());
res->setDoesNotThrow();

i.set_result(res);
Expand Down Expand Up @@ -1506,14 +1500,12 @@ namespace rubinius {

Signature sig(ops.context(), ops.ObjType);
sig << "State";
sig << "CallFrame";
sig << "Object";
sig << ops.context()->Int32Ty;
sig << ops.ObjArrayTy;

Value* call_args[] = {
ops.state(),
ops.call_frame(),
i.recv(),
ops.cint(count),
ops.stack_objects(count)
Expand All @@ -1532,14 +1524,12 @@ namespace rubinius {

Signature sig(ops.context(), ops.ObjType);
sig << "State";
sig << "CallFrame";

Value* call_args[] = {
ops.state(),
ops.call_frame()
ops.state()
};

CallInst* res = sig.call("rbx_variable_scope_of_sender", call_args, 2, "result", ops.b());
CallInst* res = sig.call("rbx_variable_scope_of_sender", call_args, 1, "result", ops.b());
res->setDoesNotThrow();

i.set_result(res);
Expand All @@ -1553,14 +1543,12 @@ namespace rubinius {

Signature sig(ops.context(), ops.ObjType);
sig << "State";
sig << "CallFrame";

Value* call_args[] = {
ops.state(),
ops.call_frame()
ops.state()
};

CallInst* res = sig.call("rbx_compiledcode_of_sender", call_args, 2, "result", ops.b());
CallInst* res = sig.call("rbx_compiledcode_of_sender", call_args, 1, "result", ops.b());
res->setDoesNotThrow();

i.set_result(res);
Expand All @@ -1574,14 +1562,12 @@ namespace rubinius {

Signature sig(ops.context(), ops.ObjType);
sig << "State";
sig << "CallFrame";

Value* call_args[] = {
ops.state(),
ops.call_frame()
ops.state()
};

CallInst* res = sig.call("rbx_constant_scope_of_sender", call_args, 2, "result", ops.b());
CallInst* res = sig.call("rbx_constant_scope_of_sender", call_args, 1, "result", ops.b());
res->setDoesNotThrow();

i.set_result(res);
Expand All @@ -1595,14 +1581,13 @@ namespace rubinius {

Signature sig(ops.context(), ops.ObjType);
sig << "State";
sig << "CallFrame";

Value* call_args[] = {
ops.state(),
ops.call_frame()
ops.state()
};

CallInst* res = sig.call("rbx_location_of_closest_ruby_method", call_args, 2, "result", ops.b());
CallInst* res = sig.call("rbx_location_of_closest_ruby_method",
call_args, 1, "result", ops.b());
res->setDoesNotThrow();

i.set_result(res);
Expand Down Expand Up @@ -1764,11 +1749,6 @@ namespace rubinius {
sig << "State";
call_args.push_back(ops_.state());

if(stub_res.pass_callframe()) {
sig << "CallFrame";
call_args.push_back(ops_.call_frame());
}

sig << "Object";
call_args.push_back(recv());

Expand Down
17 changes: 5 additions & 12 deletions machine/llvm/jit_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace jit {
void BlockBuilder::setup() {
std::vector<Type*> ftypes;
ftypes.push_back(ctx_->ptr_type("State"));
ftypes.push_back(ctx_->ptr_type("CallFrame"));
ftypes.push_back(ctx_->ptr_type("BlockEnvironment"));
ftypes.push_back(ctx_->ptr_type("Arguments"));
ftypes.push_back(ctx_->ptr_type("BlockInvocation"));
Expand All @@ -39,7 +38,6 @@ namespace jit {

Function::arg_iterator ai = func->arg_begin();
llvm::Value* state = ai++; state->setName("state");
llvm::Value* prev = ai++; prev->setName("previous");
block_env = ai++; block_env->setName("env");
llvm::Value* args = ai++; args->setName("args");
block_inv = ai++; block_inv->setName("invocation");
Expand All @@ -51,7 +49,8 @@ namespace jit {

info_.set_state(state);
info_.set_args(args);
info_.set_previous(prev);
// TODO: CallFrame
// info_.set_previous(prev);
info_.set_entry(block);

alloc_frame("block_body");
Expand Down Expand Up @@ -266,16 +265,14 @@ namespace jit {

Signature sig(ctx_, ctx_->Int32Ty);
sig << "State";
sig << "CallFrame";
sig << "Arguments";

Value* call_args[] = {
info_.state(),
info_.call_frame(),
info_.args()
};

Value* val = sig.call("rbx_destructure_args", call_args, 3, "", b());
Value* val = sig.call("rbx_destructure_args", call_args, 2, "", b());

Value* is_error = b().CreateICmpEQ(val, cint(-1));

Expand Down Expand Up @@ -364,17 +361,15 @@ namespace jit {

Signature sig(ctx_, "Object");
sig << "State";
sig << "CallFrame";
sig << "Object";

Value* call_args[] = {
info_.state(),
info_.previous(),
kw_arg
};

Value* keyword_val = sig.call("rbx_check_keyword",
call_args, 3, "rbx_check_keyword", b());
call_args, 2, "rbx_check_keyword", b());

b().CreateStore(keyword_val, keyword_object_);

Expand All @@ -401,18 +396,16 @@ namespace jit {
Signature sig(ctx_, "Object");

sig << "State";
sig << "CallFrame";
sig << "Arguments";
sig << ctx_->Int32Ty;

Value* call_args[] = {
info_.state(),
info_.previous(),
info_.args(),
cint(machine_code_->total_args)
};

Value* val = sig.call("rbx_arg_error", call_args, 4, "rbx_arg_error", b());
Value* val = sig.call("rbx_arg_error", call_args, 3, "rbx_arg_error", b());
info_.add_return_value(val, b().GetInsertBlock());
b().CreateBr(info_.return_pad());

Expand Down
6 changes: 1 addition & 5 deletions machine/llvm/jit_inline_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,18 @@ namespace jit {

Signature sig(ctx_, ctx_->Int32Ty);
sig << "State";
sig << "CallFrame";
sig << "Object";
sig << args_array->getType();
sig << ctx_->Int32Ty;

Value* call_args[] = {
info_.state(),
info_.call_frame(),
stack_args.at(0),
args_array,
cint(T)
};

Value* size = sig.call("rbx_destructure_inline_args", call_args, 5, "", b());
Value* size = sig.call("rbx_destructure_inline_args", call_args, 4, "", b());

info_.add_return_value(Constant::getNullValue(obj_type),
b().GetInsertBlock());
Expand Down Expand Up @@ -231,12 +229,10 @@ namespace jit {

Signature sig(ctx_, "Object");
sig << "State";
sig << "CallFrame";
sig << "Object";

Value* call_args[] = {
info_.state(),
info_.previous(),
kw_arg
};

Expand Down
4 changes: 1 addition & 3 deletions machine/llvm/jit_inline_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,16 @@ namespace jit {
if(SN > M) {
Signature sig(ctx_, "Object");
sig << "State";
sig << "CallFrame";
sig << "Object";

Value* call_args[] = {
info_.state(),
info_.previous(),
b().CreateLoad(
b().CreateGEP(args_array, cint(SN - H - 1)))
};

Value* keyword_val = sig.call("rbx_check_keyword",
call_args, 3, "keyword_val", b());
call_args, 2, "keyword_val", b());

b().CreateStore(keyword_val, keyword_object);
} else {
Expand Down
13 changes: 4 additions & 9 deletions machine/llvm/jit_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace jit {
void MethodBuilder::setup() {
std::vector<Type*> ftypes;
ftypes.push_back(ctx_->ptr_type("State"));
ftypes.push_back(ctx_->ptr_type("CallFrame"));
ftypes.push_back(ctx_->ptr_type("Executable"));
ftypes.push_back(ctx_->ptr_type("Module"));
ftypes.push_back(ctx_->ptr_type("Arguments"));
Expand All @@ -41,7 +40,6 @@ namespace jit {

Function::arg_iterator ai = func->arg_begin();
llvm::Value* state = ai++; state->setName("state");
llvm::Value* prev = ai++; prev->setName("previous");
exec = ai++; exec->setName("exec");
module = ai++; module->setName("mod");
llvm::Value* args = ai++; args->setName("args");
Expand All @@ -53,7 +51,8 @@ namespace jit {

info_.set_state(state);
info_.set_args(args);
info_.set_previous(prev);
// TODO: CallFrame
// info_.set_previous(prev);
info_.set_entry(block);

alloc_frame("method_body");
Expand Down Expand Up @@ -144,17 +143,15 @@ namespace jit {

Signature sig(ctx_, "Object");
sig << "State";
sig << "CallFrame";
sig << "Object";

Value* call_args[] = {
info_.state(),
info_.previous(),
kw_arg
};

Value* keyword_val = sig.call("rbx_check_keyword",
call_args, 3, "keyword_val", b());
call_args, 2, "keyword_val", b());

b().CreateStore(keyword_val, keyword_object_);
}
Expand All @@ -167,18 +164,16 @@ namespace jit {
Signature sig(ctx_, "Object");

sig << "State";
sig << "CallFrame";
sig << "Arguments";
sig << ctx_->Int32Ty;

Value* call_args[] = {
info_.state(),
info_.previous(),
info_.args(),
cint(machine_code_->total_args)
};

Value* val = sig.call("rbx_arg_error", call_args, 4, "ret", b());
Value* val = sig.call("rbx_arg_error", call_args, 3, "ret", b());
return_value(val);

// Switch to using continuation
Expand Down
5 changes: 2 additions & 3 deletions machine/llvm/jit_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,11 @@ namespace rubinius {
Signature sig(ctx_, "Object");

sig << "State";
sig << "CallFrame";
sig << "Object";

Value* call_args[] = { state_, call_frame_, stack_top() };
Value* call_args[] = { state_, stack_top() };

CallInst* res = sig.call("rbx_check_frozen", call_args, 3, "", b());
CallInst* res = sig.call("rbx_check_frozen", call_args, 2, "check_frozen", b());
res->setOnlyReadsMemory();
res->setDoesNotThrow();

Expand Down
Loading

0 comments on commit 9e28da4

Please sign in to comment.