Skip to content

Commit 13d677b

Browse files
committedMar 23, 2016
Merge branch 'stw' into codedb-ffi-io
2 parents 31d4300 + f51631d commit 13d677b

18 files changed

+246
-380
lines changed
 

‎.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ notifications:
3939
on_start: always
4040
env:
4141
global:
42-
- RBXOPT=-Xint
4342
- LANG="en_US.UTF-8"
4443
- secure: olbok/GN6rOYvPnHBYWGz7giCoCdLFpT/7WSBHukYO3E0uNeqAUOOgW2BFOwCVWdSEJ/iTvJXZQ4qVZHX+6jRfvILZeGv+D2P93VdD8UFQRoTOfFC7esAo525s9fuKm9ehUGWZxlzGOBHHckky1jn6pEf8mlXAVM5e76dlH0fck=
4544
- secure: aqG9eB/PrzQ7XJQN6YX/00sNVvwSB77saxXQzguL2WFjAXB74h6168Hzq+awHtNX/vfOb6ta7fpWLHrA0D+gmZnvTR29VlP6nd0vs1tkdX1/jWbiBHjamRffp+NWVdKbJKYn5iLOGXcuUMOzY/opLKOdvxKZfkxGMxR2tTNLZUE=

‎library/rubinius/configuration.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@
9494
"The JIT will emit code to be sure JITd methods can be profiled"
9595

9696
s.section "inline" do |i|
97-
i.vm_variable "generic", true, "Have the JIT inline generic methods"
97+
i.vm_variable "generic", false, "Have the JIT inline generic methods"
9898

99-
i.vm_variable "blocks", true,
99+
i.vm_variable "blocks", false,
100100
"Have the JIT try to inline methods and their literal blocks"
101101

102102
i.vm_variable "debug", false,

‎machine/builtin/block_environment.cpp

+15-19
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ namespace rubinius {
6565
MachineCode* mcode = env->compiled_code_->machine_code();
6666

6767
if(!mcode) {
68-
OnStack<3> os(state, env, args.recv_location(), args.block_location());
69-
OnStack<3> iv(state, invocation.self, invocation.constant_scope, invocation.module);
70-
memory::VariableRootBuffer vrb(state->vm()->current_root_buffers(),
71-
&args.arguments_location(), args.total());
72-
7368
mcode = env->machine_code(state);
7469

7570
if(!mcode) {
@@ -414,8 +409,8 @@ namespace rubinius {
414409
if(!mod) mod = env->module();
415410

416411
Object* block = cNil;
417-
if(VariableScope* scope = env->top_scope_) {
418-
if(!scope->nil_p()) block = scope->block();
412+
if(VariableScope* vs = env->top_scope_) {
413+
if(!vs->nil_p()) block = vs->block();
419414
}
420415

421416
scope->initialize(invocation.self, block, mod, mcode->number_of_locals);
@@ -433,24 +428,25 @@ namespace rubinius {
433428
return NULL;
434429
}
435430

436-
CallFrame* previous_frame = 0;
437-
InterpreterCallFrame* frame = ALLOCA_CALL_FRAME(mcode->stack_size);
431+
CallFrame* previous_frame = NULL;
432+
CallFrame* call_frame = ALLOCA_CALL_FRAME(mcode->stack_size);
438433

439-
frame->prepare(mcode->stack_size);
434+
call_frame->prepare(mcode->stack_size);
440435

441-
frame->constant_scope_ = invocation.constant_scope;
436+
call_frame->constant_scope_ = invocation.constant_scope;
442437

443-
frame->arguments = &args;
444-
frame->dispatch_data = env;
445-
frame->compiled_code = env->compiled_code_;
446-
frame->scope = scope;
447-
frame->top_scope_ = env->top_scope_;
448-
frame->flags = invocation.flags | CallFrame::cMultipleScopes
438+
call_frame->arguments = &args;
439+
call_frame->dispatch_data = env;
440+
call_frame->compiled_code = env->compiled_code_;
441+
call_frame->scope = scope;
442+
call_frame->optional_jit_data = NULL;
443+
call_frame->top_scope_ = env->top_scope_;
444+
call_frame->flags = invocation.flags | CallFrame::cMultipleScopes
449445
| CallFrame::cBlock;
450446

451-
state->vm()->push_call_frame(frame, previous_frame);
447+
state->vm()->push_call_frame(call_frame, previous_frame);
452448

453-
Object* value = 0;
449+
Object* value = NULL;
454450

455451
#ifdef RBX_PROFILER
456452
if(unlikely(state->vm()->tooling())) {

‎machine/call_frame.hpp

+13-18
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,17 @@ namespace rubinius {
208208
return ip_++;
209209
}
210210

211+
/**
212+
* Initialize frame for the given stack size.
213+
*/
214+
void prepare(int stack) {
215+
ip_ = 0;
216+
217+
for(int i = 0; i < stack; i++) {
218+
stk[i] = cNil;
219+
}
220+
}
221+
211222
VariableScope* promote_scope_full(STATE);
212223

213224
VariableScope* promote_scope(STATE) {
@@ -228,28 +239,12 @@ namespace rubinius {
228239
Object* find_breakpoint(STATE);
229240
};
230241

231-
class InterpreterCallFrame : public CallFrame {
232-
public:
233-
// Methods
234-
235-
/**
236-
* Initialize frame for the given stack size.
237-
*/
238-
void prepare(int stack) {
239-
ip_ = 0;
240-
241-
for(int i = 0; i < stack; i++) {
242-
stk[i] = cNil;
243-
}
244-
}
245-
};
246-
247242
#define THREAD_STACK_SIZE 4194304
248243

249244
#define ALLOCA_CALL_FRAME(stack_size) \
250-
reinterpret_cast<InterpreterCallFrame*>(alloca(sizeof(InterpreterCallFrame) + (sizeof(Object*) * stack_size)))
245+
reinterpret_cast<CallFrame*>(alloca(sizeof(CallFrame) + (sizeof(Object*) * stack_size)))
251246
};
252247

253-
#define MAX_CALL_FRAMES (THREAD_STACK_SIZE / sizeof(InterpreterCallFrame))
248+
#define MAX_CALL_FRAMES (THREAD_STACK_SIZE / sizeof(CallFrame))
254249

255250
#endif

‎machine/llvm/inline.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ namespace rubinius {
112112
Value* call_args[] = {
113113
ops_.state(),
114114
call_site_const,
115-
ops_.call_frame(),
116115
ops_.out_args()
117116
};
118117

‎machine/llvm/jit_block.cpp

+34-111
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,47 @@ namespace jit {
4949

5050
info_.set_state(state);
5151
info_.set_args(args);
52-
// TODO: CallFrame
53-
// info_.set_previous(prev);
5452
info_.set_entry(block);
5553

5654
alloc_frame("block_body");
5755

58-
check_arity();
56+
// Push the new CallFrame
57+
Signature sig(ctx_, ctx_->VoidTy);
58+
sig << "State"
59+
<< "CallFrame"
60+
<< "StackVariables"
61+
<< "BlockEnvironment"
62+
<< "Arguments"
63+
<< "BlockInvocation";
5964

60-
initialize_frame(machine_code_->stack_size);
65+
Value* call_args[] = {
66+
state,
67+
call_frame,
68+
info_.variables(),
69+
block_env,
70+
args,
71+
block_inv
72+
};
6173

62-
nil_stack(machine_code_->stack_size, constant(cNil, obj_type));
74+
sig.call("rbx_block_frame_initialize", call_args, 6, "", b());
6375

64-
setup_block_scope();
76+
// TODO: de-dup
77+
{
78+
b().SetInsertPoint(info_.return_pad());
79+
80+
Signature sig(ctx_, ctx_->VoidTy);
81+
sig << "State";
82+
83+
Value* call_args[] = {
84+
state
85+
};
86+
87+
sig.call("rbx_pop_call_frame", call_args, 1, "", b());
88+
89+
b().SetInsertPoint(block);
90+
}
91+
92+
check_arity();
6593

6694
import_args();
6795

@@ -100,111 +128,6 @@ namespace jit {
100128
b().SetInsertPoint(body_);
101129
}
102130

103-
void BlockBuilder::setup_block_scope() {
104-
b().CreateStore(ConstantExpr::getNullValue(llvm::PointerType::getUnqual(vars_type)),
105-
get_field(vars, offset::StackVariables::on_heap));
106-
Value* self = b().CreateLoad(
107-
get_field(block_inv, offset::BlockInvocation::self),
108-
"invocation.self");
109-
110-
b().CreateStore(self, get_field(vars, offset::StackVariables::self));
111-
112-
Value* inv_mod = b().CreateLoad(
113-
get_field(block_inv, offset::BlockInvocation::module),
114-
"invocation.module");
115-
116-
Value* creation_mod = b().CreateLoad(
117-
get_field(block_env, offset::BlockEnvironment::module),
118-
"env.module");
119-
120-
Value* mod = b().CreateSelect(
121-
b().CreateICmpNE(inv_mod, ConstantExpr::getNullValue(inv_mod->getType())),
122-
inv_mod,
123-
creation_mod);
124-
125-
module_ = mod;
126-
127-
b().CreateStore(mod, get_field(vars, offset::StackVariables::module));
128-
129-
Value* blk = b().CreateLoad(get_field(top_scope, offset::VariableScope::block),
130-
"args.block");
131-
b().CreateStore(blk, get_field(vars, offset::StackVariables::block));
132-
133-
134-
// We don't use top_scope here because of nested blocks. Parent MUST be
135-
// the scope the block was created in, not the top scope for depth
136-
// variables to work.
137-
Value* be_scope = b().CreateLoad(
138-
get_field(block_env, offset::BlockEnvironment::scope),
139-
"env.scope");
140-
141-
b().CreateStore(be_scope, get_field(vars, offset::StackVariables::parent));
142-
b().CreateStore(constant(cNil, obj_type), get_field(vars, offset::StackVariables::last_match));
143-
144-
nil_locals();
145-
}
146-
147-
void BlockBuilder::initialize_frame(int stack_size) {
148-
Value* code_gep = get_field(call_frame, offset::CallFrame::compiled_code);
149-
150-
method = b().CreateLoad(get_field(block_env, offset::BlockEnvironment::code),
151-
"env.code");
152-
153-
// previous
154-
b().CreateStore(info_.previous(), get_field(call_frame, offset::CallFrame::previous));
155-
156-
// constant_scope
157-
Value* cs = b().CreateLoad(get_field(block_inv, offset::BlockInvocation::constant_scope),
158-
"invocation.constant_scope");
159-
160-
b().CreateStore(cs, get_field(call_frame, offset::CallFrame::constant_scope));
161-
162-
// arguments
163-
b().CreateStore(info_.args(), get_field(call_frame, offset::CallFrame::arguments));
164-
165-
// msg
166-
b().CreateStore(Constant::getNullValue(ctx_->Int8PtrTy),
167-
get_field(call_frame, offset::CallFrame::dispatch_data));
168-
169-
// compiled_code
170-
b().CreateStore(method, code_gep);
171-
172-
// flags
173-
inv_flags_ = b().CreateLoad(get_field(block_inv, offset::BlockInvocation::flags),
174-
"invocation.flags");
175-
176-
int block_flags = CallFrame::cMultipleScopes |
177-
CallFrame::cBlock |
178-
CallFrame::cJITed;
179-
180-
if(!use_full_scope_) block_flags |= CallFrame::cClosedScope;
181-
182-
Value* flags = b().CreateOr(inv_flags_,
183-
cint(block_flags), "flags");
184-
185-
b().CreateStore(flags, get_field(call_frame, offset::CallFrame::flags));
186-
187-
// ip
188-
b().CreateStore(cint(0),
189-
get_field(call_frame, offset::CallFrame::ip));
190-
191-
// scope
192-
b().CreateStore(vars, get_field(call_frame, offset::CallFrame::scope));
193-
194-
// top_scope
195-
top_scope = b().CreateLoad(
196-
get_field(block_env, offset::BlockEnvironment::top_scope),
197-
"env.top_scope");
198-
199-
b().CreateStore(top_scope, get_field(call_frame, offset::CallFrame::top_scope));
200-
201-
// jit_data
202-
b().CreateStore(
203-
constant(ctx_->runtime_data_holder(), ctx_->Int8PtrTy),
204-
get_field(call_frame, offset::CallFrame::jit_data));
205-
206-
}
207-
208131
void BlockBuilder::check_arity() {
209132
BasicBlock* destruct_check = info_.new_block("destruct_check");
210133
BasicBlock* arg_error = info_.new_block("arg_error");

‎machine/llvm/jit_inline_block.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ namespace jit {
2121
b().SetInsertPoint(entry);
2222

2323
info_.set_args(args);
24-
info_.set_previous(prev);
2524
info_.set_entry(entry);
2625

2726
BasicBlock* body = BasicBlock::Create(ctx_->llvm_context(), "block_body", info_.function());

‎machine/llvm/jit_inline_method.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ namespace jit {
1919
b().SetInsertPoint(entry);
2020

2121
info_.set_args(args);
22-
info_.set_previous(prev);
2322
info_.set_entry(entry);
2423

2524
BasicBlock* body = BasicBlock::Create(ctx_->llvm_context(), "method_body", info_.function());

0 commit comments

Comments
 (0)
Please sign in to comment.