diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 5df21ae1de..9d75bfabc1 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -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(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()); diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index f3fc4f465f..3662e4ff83 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -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 literal = + chunk_->LookupLiteral(LConstantOperand::cast(context)); + LoadHeapObject(esi, Handle::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 handle = instr->value(); + if (handle->IsHeapObject()) { + LoadHeapObject(reg, Handle::cast(handle)); + } else { + __ Set(reg, Immediate(handle)); + } }