Skip to content

Commit

Permalink
Merge branch 'stw' into codedb-ffi-io
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Mar 20, 2016
2 parents bcb42d3 + 85cd7c9 commit baff08a
Show file tree
Hide file tree
Showing 21 changed files with 637 additions and 773 deletions.
7 changes: 4 additions & 3 deletions machine/builtin/thread.cpp
Expand Up @@ -81,8 +81,9 @@ namespace rubinius {
}

Thread* Thread::create(STATE, Object* self, ThreadFunction function) {
return Thread::create(state, self,
state->shared().thread_nexus()->new_vm_solo(&state->shared()), function);
VM* vm = state->shared().thread_nexus()->new_vm(&state->shared());

return Thread::create(state, self, vm, function);
}

Thread* Thread::create(STATE, Object* self, VM* vm, ThreadFunction function) {
Expand Down Expand Up @@ -347,7 +348,6 @@ namespace rubinius {
State state_obj(vm), *state = &state_obj;

vm->set_current_thread();
state->shared().thread_nexus()->add_vm(vm);

RUBINIUS_THREAD_START(
const_cast<RBX_DTRACE_CHAR_P>(vm->name().c_str()), vm->thread_id(), 0);
Expand Down Expand Up @@ -388,6 +388,7 @@ namespace rubinius {

utilities::logger::write("exit thread: %s", vm->name().c_str());

vm->set_call_frame(0);
vm->become_unmanaged();

if(vm->main_thread_p() || (!value && vm->thread_state()->raise_reason() == cExit)) {
Expand Down
1 change: 1 addition & 0 deletions machine/internal_threads.cpp
Expand Up @@ -49,6 +49,7 @@ namespace rubinius {
RUBINIUS_THREAD_STOP(
const_cast<RBX_DTRACE_CHAR_P>(vm->name().c_str()), vm->thread_id(), 1);

vm->set_call_frame(0);
vm->become_unmanaged();

vm->set_zombie(state);
Expand Down
9 changes: 3 additions & 6 deletions machine/llvm/inline.cpp
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
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
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
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
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

0 comments on commit baff08a

Please sign in to comment.