Skip to content

Commit

Permalink
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
@@ -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());
}
}
@@ -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);

44 changes: 12 additions & 32 deletions machine/llvm/inline_primitive.cpp
Original file line number Diff line number Diff line change
@@ -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
@@ -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);
@@ -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)
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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());

17 changes: 5 additions & 12 deletions machine/llvm/jit_block.cpp
Original file line number Diff line number Diff line change
@@ -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"));
@@ -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");
@@ -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");
@@ -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));

@@ -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_);

@@ -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());

6 changes: 1 addition & 5 deletions machine/llvm/jit_inline_block.cpp
Original file line number Diff line number Diff line change
@@ -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());
@@ -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
};

4 changes: 1 addition & 3 deletions machine/llvm/jit_inline_method.cpp
Original file line number Diff line number Diff line change
@@ -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 {
13 changes: 4 additions & 9 deletions machine/llvm/jit_method.cpp
Original file line number Diff line number Diff line change
@@ -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"));
@@ -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");
@@ -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");
@@ -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_);
}
@@ -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
5 changes: 2 additions & 3 deletions machine/llvm/jit_operations.hpp
Original file line number Diff line number Diff line change
@@ -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();

25 changes: 11 additions & 14 deletions machine/llvm/jit_util.cpp
Original file line number Diff line number Diff line change
@@ -263,10 +263,9 @@ extern "C" {
return ret;
}

Object* rbx_create_block(STATE, int index) {
Object* rbx_create_block(STATE, CallFrame* call_frame, int index) {
CPP_TRY

CallFrame* call_frame = state->vm()->call_frame();
Object* _lit = call_frame->compiled_code->literals()->at(state, index);
CompiledCode* code = 0;

@@ -402,9 +401,7 @@ extern "C" {
return args.total();
}

int rbx_destructure_inline_args(STATE,
Object* obj, Object** vars, int size)
{
int rbx_destructure_inline_args(STATE, Object* obj, Object** vars, int size) {
Array* ary = try_as<Array>(obj);

if(!ary && CBOOL(obj->respond_to(state, G(sym_to_ary), cFalse))) {
@@ -623,7 +620,7 @@ extern "C" {
}

Object* rbx_check_serial(STATE, CallSite* call_site,
int serial, Object* recv, Symbol* vis) {
int serial, Object* recv) {
return RBOOL(call_site->update_and_validate(state, recv, G(sym_public), serial));
}

@@ -832,14 +829,14 @@ extern "C" {
return res;
}

Object* rbx_set_local_depth(STATE, Object* top,
Object* rbx_set_local_depth(STATE, CallFrame* call_frame, Object* top,
int depth, int index) {
if(depth == 0) {
Exception::internal_error(state,
"illegal set_local_depth usage");
return 0;
} else {
VariableScope* scope = state->vm()->call_frame()->scope->parent();
VariableScope* scope = call_frame->scope->parent();

if(!scope || scope->nil_p()) {
Exception::internal_error(state,
@@ -868,9 +865,9 @@ extern "C" {
return top;
}

Object* rbx_set_local_from(STATE, Object* top,
Object* rbx_set_local_from(STATE, CallFrame* call_frame, Object* top,
int depth, int index) {
VariableScope* scope = state->vm()->call_frame()->scope->parent();
VariableScope* scope = call_frame->scope->parent();

if(!scope || scope->nil_p()) {
Exception::internal_error(state,
@@ -893,14 +890,14 @@ extern "C" {
return top;
}

Object* rbx_push_local_depth(STATE,
Object* rbx_push_local_depth(STATE, CallFrame* call_frame,
int depth, int index) {
if(depth == 0) {
Exception::internal_error(state,
"illegal push_local_depth usage");
return 0;
} else {
VariableScope* scope = state->vm()->call_frame()->scope->parent();
VariableScope* scope = call_frame->scope->parent();

if(!scope || scope->nil_p()) {
Exception::internal_error(state,
@@ -927,9 +924,9 @@ extern "C" {
}
}

Object* rbx_push_local_from(STATE,
Object* rbx_push_local_from(STATE, CallFrame* call_frame,
int depth, int index) {
VariableScope* scope = state->vm()->call_frame()->scope->parent();
VariableScope* scope = call_frame->scope->parent();

if(!scope || scope->nil_p()) {
Exception::internal_error(state,
156 changes: 34 additions & 122 deletions machine/llvm/jit_visit.hpp

Large diffs are not rendered by default.

513 changes: 255 additions & 258 deletions machine/llvm/types32.cpp.gen

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions machine/llvm/types32.ll
Original file line number Diff line number Diff line change
@@ -67,8 +67,8 @@ declare void @outputDispatch(%"struct.rubinius::Dispatch"*)
%"struct.rubinius::CallSite" = type {
%"struct.rubinius::Object", ; header
%"struct.rubinius::Symbol"*, ; name
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::CallSite"*, %"struct.rubinius::CallFrame"*, %"struct.rubinius::Arguments"*)*, ; executor
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::CallSite"*, %"struct.rubinius::CallFrame"*, %"struct.rubinius::Arguments"*)*, ; fallback
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::CallSite"*, %"struct.rubinius::Arguments"*)*, ; executor
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::CallSite"*, %"struct.rubinius::Arguments"*)*, ; fallback
void (%"struct.rubinius::State"*, %"struct.rubinius::CallSite"*, %"struct.rubinius::Class"*, %"struct.rubinius::Dispatch"*)*, ; updater
%"struct.rubinius::Executable"*, ; executable
i32 ; ip
@@ -257,7 +257,7 @@ declare void @outputCompiledCode(%"struct.rubinius::CompiledCode"*)
%"struct.rubinius::Object", ; header
%"struct.rubinius::Symbol"*, ; primitive
%"struct.rubinius::Fixnum"*, ; serial
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::CallFrame"*, %"struct.rubinius::Executable"*, %"struct.rubinius::Module"*, %"struct.rubinius::Arguments"*)*, ; execute
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::Executable"*, %"struct.rubinius::Module"*, %"struct.rubinius::Arguments"*)*, ; execute
%"struct.rubinius::Inliners"*, ; inliners
i32, ; prim_index
i8 ; custom_call_site
513 changes: 255 additions & 258 deletions machine/llvm/types64.cpp.gen

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions machine/llvm/types64.ll
Original file line number Diff line number Diff line change
@@ -67,8 +67,8 @@ declare void @outputDispatch(%"struct.rubinius::Dispatch"*)
%"struct.rubinius::CallSite" = type {
%"struct.rubinius::Object", ; header
%"struct.rubinius::Symbol"*, ; name
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::CallSite"*, %"struct.rubinius::CallFrame"*, %"struct.rubinius::Arguments"*)*, ; executor
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::CallSite"*, %"struct.rubinius::CallFrame"*, %"struct.rubinius::Arguments"*)*, ; fallback
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::CallSite"*, %"struct.rubinius::Arguments"*)*, ; executor
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::CallSite"*, %"struct.rubinius::Arguments"*)*, ; fallback
void (%"struct.rubinius::State"*, %"struct.rubinius::CallSite"*, %"struct.rubinius::Class"*, %"struct.rubinius::Dispatch"*)*, ; updater
%"struct.rubinius::Executable"*, ; executable
i32 ; ip
@@ -257,7 +257,7 @@ declare void @outputCompiledCode(%"struct.rubinius::CompiledCode"*)
%"struct.rubinius::Object", ; header
%"struct.rubinius::Symbol"*, ; primitive
%"struct.rubinius::Fixnum"*, ; serial
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::CallFrame"*, %"struct.rubinius::Executable"*, %"struct.rubinius::Module"*, %"struct.rubinius::Arguments"*)*, ; execute
%"struct.rubinius::Object"* (%"struct.rubinius::State"*, %"struct.rubinius::Executable"*, %"struct.rubinius::Module"*, %"struct.rubinius::Arguments"*)*, ; execute
%"struct.rubinius::Inliners"*, ; inliners
i32, ; prim_index
i8 ; custom_call_site

0 comments on commit 9e28da4

Please sign in to comment.