Enable inlining functions with contexts different than their caller.

BUG=
TEST=

Review URL: http://codereview.chromium.org/7925007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9421 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1046b1a4
......@@ -4527,14 +4527,17 @@ bool HGraphBuilder::TryInline(Call* expr) {
return false;
}
// No context change required.
CompilationInfo* outer_info = info();
#if !defined(V8_TARGET_ARCH_IA32)
// Target must be able to use caller's context.
if (target->context() != outer_info->closure()->context() ||
outer_info->scope()->contains_with() ||
outer_info->scope()->num_heap_slots() > 0) {
TraceInline(target, caller, "target requires context change");
return false;
}
#endif
// Don't inline deeper than kMaxInliningLevels calls.
HEnvironment* env = environment();
......@@ -4655,6 +4658,10 @@ bool HGraphBuilder::TryInline(Call* expr) {
function,
undefined,
call_kind);
HConstant* context = new HConstant(Handle<Context>(target->context()),
Representation::Tagged());
AddInstruction(context);
inner_env->BindContext(context);
HBasicBlock* body_entry = CreateBasicBlock(inner_env);
current_block()->Goto(body_entry);
body_entry->SetJoinId(expr->ReturnId());
......
......@@ -516,14 +516,18 @@ void LCodeGen::CallRuntimeFromDeferred(Runtime::FunctionId id,
int argc,
LInstruction* instr,
LOperand* context) {
ASSERT(context->IsRegister() || context->IsStackSlot());
if (context->IsRegister()) {
if (!ToRegister(context).is(esi)) {
__ mov(esi, ToRegister(context));
}
} else {
// Context is stack slot.
} else if (context->IsStackSlot()) {
__ mov(esi, ToOperand(context));
} else if (context->IsConstantOperand()) {
Handle<Object> literal =
chunk_->LookupLiteral(LConstantOperand::cast(context));
LoadHeapObject(esi, Handle<Context>::cast(literal));
} else {
UNREACHABLE();
}
__ CallRuntimeSaveDoubles(id);
......@@ -1235,8 +1239,13 @@ void LCodeGen::DoConstantD(LConstantD* instr) {
void LCodeGen::DoConstantT(LConstantT* instr) {
ASSERT(instr->result()->IsRegister());
__ Set(ToRegister(instr->result()), Immediate(instr->value()));
Register reg = ToRegister(instr->result());
Handle<Object> handle = instr->value();
if (handle->IsHeapObject()) {
LoadHeapObject(reg, Handle<HeapObject>::cast(handle));
} else {
__ Set(reg, Immediate(handle));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment