diff options
Diffstat (limited to 'deps/v8/src/x87/lithium-x87.cc')
-rw-r--r-- | deps/v8/src/x87/lithium-x87.cc | 155 |
1 files changed, 96 insertions, 59 deletions
diff --git a/deps/v8/src/x87/lithium-x87.cc b/deps/v8/src/x87/lithium-x87.cc index f2eb9f0a00..9304b8975c 100644 --- a/deps/v8/src/x87/lithium-x87.cc +++ b/deps/v8/src/x87/lithium-x87.cc @@ -472,18 +472,18 @@ LPlatformChunk* LChunkBuilder::Build() { } -void LChunkBuilder::Abort(BailoutReason reason) { - info()->set_bailout_reason(reason); - status_ = ABORTED; -} - - LUnallocated* LChunkBuilder::ToUnallocated(Register reg) { return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER, Register::ToAllocationIndex(reg)); } +LUnallocated* LChunkBuilder::ToUnallocated(X87Register reg) { + return new (zone()) LUnallocated(LUnallocated::FIXED_DOUBLE_REGISTER, + X87Register::ToAllocationIndex(reg)); +} + + LOperand* LChunkBuilder::UseFixed(HValue* value, Register fixed_register) { return Use(value, ToUnallocated(fixed_register)); } @@ -616,6 +616,12 @@ LInstruction* LChunkBuilder::DefineFixed(LTemplateResultInstruction<1>* instr, } +LInstruction* LChunkBuilder::DefineFixed(LTemplateResultInstruction<1>* instr, + X87Register reg) { + return Define(instr, ToUnallocated(reg)); +} + + LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { HEnvironment* hydrogen_env = current_block_->last_environment(); int argument_index_accumulator = 0; @@ -872,6 +878,14 @@ void LChunkBuilder::VisitInstruction(HInstruction* current) { if (current->IsControlInstruction() && HControlInstruction::cast(current)->KnownSuccessorBlock(&successor) && successor != NULL) { + // Always insert a fpu register barrier here when branch is optimized to + // be a direct goto. + // TODO(weiliang): require a better solution. + if (!current->IsGoto()) { + LClobberDoubles* clobber = new (zone()) LClobberDoubles(isolate()); + clobber->set_hydrogen_value(current); + chunk_->AddInstruction(clobber, current_block_); + } instr = new(zone()) LGoto(successor); } else { instr = current->CompileToLithium(this); @@ -931,7 +945,8 @@ void LChunkBuilder::AddInstruction(LInstruction* instr, if (FLAG_stress_environments && !instr->HasEnvironment()) { instr = AssignEnvironment(instr); } - if (instr->IsGoto() && LGoto::cast(instr)->jumps_to_join()) { + if (instr->IsGoto() && + (LGoto::cast(instr)->jumps_to_join() || next_block_->is_osr_entry())) { // TODO(olivf) Since phis of spilled values are joined as registers // (not in the stack slot), we need to allow the goto gaps to keep one // x87 register alive. To ensure all other values are still spilled, we @@ -979,7 +994,9 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { bool easy_case = !r.IsTagged() || type.IsBoolean() || type.IsSmi() || type.IsJSArray() || type.IsHeapNumber() || type.IsString(); LOperand* temp = !easy_case && expected.NeedsMap() ? TempRegister() : NULL; - LInstruction* branch = new(zone()) LBranch(UseRegister(value), temp); + LInstruction* branch = + temp != NULL ? new (zone()) LBranch(UseRegister(value), temp) + : new (zone()) LBranch(UseRegisterAtStart(value), temp); if (!easy_case && ((!expected.Contains(ToBooleanStub::SMI) && expected.NeedsMap()) || !expected.IsGeneric())) { @@ -1119,13 +1136,13 @@ LInstruction* LChunkBuilder::DoCallJSFunction( LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { - const InterfaceDescriptor* descriptor = instr->descriptor(); + CallInterfaceDescriptor descriptor = instr->descriptor(); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList<LOperand*> ops(instr->OperandCount(), zone()); ops.Add(target, zone()); for (int i = 1; i < instr->OperandCount(); i++) { - LOperand* op = UseFixed(instr->OperandAt(i), - descriptor->GetParameterRegister(i - 1)); + LOperand* op = + UseFixed(instr->OperandAt(i), descriptor.GetParameterRegister(i - 1)); ops.Add(op, zone()); } @@ -1135,6 +1152,19 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor( } +LInstruction* LChunkBuilder::DoTailCallThroughMegamorphicCache( + HTailCallThroughMegamorphicCache* instr) { + LOperand* context = UseFixed(instr->context(), esi); + LOperand* receiver_register = + UseFixed(instr->receiver(), LoadDescriptor::ReceiverRegister()); + LOperand* name_register = + UseFixed(instr->name(), LoadDescriptor::NameRegister()); + // Not marked as call. It can't deoptimize, and it never returns. + return new (zone()) LTailCallThroughMegamorphicCache( + context, receiver_register, name_register); +} + + LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { LOperand* context = UseFixed(instr->context(), esi); LOperand* function = UseFixed(instr->function(), edi); @@ -1169,16 +1199,16 @@ LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) { LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) { - // Crankshaft is turned off for nosse2. - UNREACHABLE(); - return NULL; + LOperand* input = UseRegisterAtStart(instr->value()); + LInstruction* result = DefineAsRegister(new (zone()) LMathRound(input)); + return AssignEnvironment(result); } LInstruction* LChunkBuilder::DoMathFround(HUnaryMathOperation* instr) { - LOperand* input = UseRegisterAtStart(instr->value()); + LOperand* input = UseRegister(instr->value()); LMathFround* result = new (zone()) LMathFround(input); - return AssignEnvironment(DefineAsRegister(result)); + return DefineSameAsFirst(result); } @@ -1212,25 +1242,26 @@ LInstruction* LChunkBuilder::DoMathClz32(HUnaryMathOperation* instr) { LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { DCHECK(instr->representation().IsDouble()); DCHECK(instr->value()->representation().IsDouble()); - LOperand* value = UseTempRegister(instr->value()); - LOperand* temp1 = TempRegister(); - LOperand* temp2 = TempRegister(); + LOperand* value = UseRegisterAtStart(instr->value()); + LOperand* temp1 = FixedTemp(ecx); + LOperand* temp2 = FixedTemp(edx); LMathExp* result = new(zone()) LMathExp(value, temp1, temp2); - return DefineAsRegister(result); + return MarkAsCall(DefineSameAsFirst(result), instr); } LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) { LOperand* input = UseRegisterAtStart(instr->value()); - LMathSqrt* result = new(zone()) LMathSqrt(input); - return DefineSameAsFirst(result); + LOperand* temp1 = FixedTemp(ecx); + LOperand* temp2 = FixedTemp(edx); + LMathSqrt* result = new(zone()) LMathSqrt(input, temp1, temp2); + return MarkAsCall(DefineSameAsFirst(result), instr); } LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) { LOperand* input = UseRegisterAtStart(instr->value()); - LOperand* temp = TempRegister(); - LMathPowHalf* result = new(zone()) LMathPowHalf(input, temp); + LMathPowHalf* result = new (zone()) LMathPowHalf(input); return DefineSameAsFirst(result); } @@ -1602,6 +1633,8 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { LOperand* left = NULL; LOperand* right = NULL; + LOperand* scratch = TempRegister(); + if (instr->representation().IsSmiOrInteger32()) { DCHECK(instr->left()->representation().Equals(instr->representation())); DCHECK(instr->right()->representation().Equals(instr->representation())); @@ -1614,15 +1647,19 @@ LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { left = UseRegisterAtStart(instr->left()); right = UseRegisterAtStart(instr->right()); } - LMathMinMax* minmax = new(zone()) LMathMinMax(left, right); + LMathMinMax* minmax = new (zone()) LMathMinMax(left, right, scratch); return DefineSameAsFirst(minmax); } LInstruction* LChunkBuilder::DoPower(HPower* instr) { - // Crankshaft is turned off for nosse2. - UNREACHABLE(); - return NULL; + // Unlike ia32, we don't have a MathPowStub and directly call c function. + DCHECK(instr->representation().IsDouble()); + DCHECK(instr->left()->representation().IsDouble()); + LOperand* left = UseRegisterAtStart(instr->left()); + LOperand* right = UseRegisterAtStart(instr->right()); + LPower* result = new (zone()) LPower(left, right); + return MarkAsCall(DefineSameAsFirst(result), instr); } @@ -1684,9 +1721,8 @@ LInstruction* LChunkBuilder::DoCompareHoleAndBranch( LInstruction* LChunkBuilder::DoCompareMinusZeroAndBranch( HCompareMinusZeroAndBranch* instr) { - LOperand* value = UseRegister(instr->value()); - LOperand* scratch = TempRegister(); - return new(zone()) LCompareMinusZeroAndBranch(value, scratch); + LOperand* value = UseRegisterAtStart(instr->value()); + return new (zone()) LCompareMinusZeroAndBranch(value); } @@ -2009,8 +2045,8 @@ LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { HValue* value = instr->value(); Representation input_rep = value->representation(); if (input_rep.IsDouble()) { - UNREACHABLE(); - return NULL; + LOperand* reg = UseRegister(value); + return DefineFixed(new (zone()) LClampDToUint8(reg), eax); } else if (input_rep.IsInteger32()) { LOperand* reg = UseFixed(value, eax); return DefineFixed(new(zone()) LClampIToUint8(reg), eax); @@ -2054,10 +2090,7 @@ LInstruction* LChunkBuilder::DoConstant(HConstant* instr) { } else if (r.IsInteger32()) { return DefineAsRegister(new(zone()) LConstantI); } else if (r.IsDouble()) { - double value = instr->DoubleValue(); - bool value_is_zero = BitCast<uint64_t, double>(value) == 0; - LOperand* temp = value_is_zero ? NULL : TempRegister(); - return DefineAsRegister(new(zone()) LConstantD(temp)); + return DefineAsRegister(new (zone()) LConstantD); } else if (r.IsExternal()) { return DefineAsRegister(new(zone()) LConstantE); } else if (r.IsTagged()) { @@ -2079,11 +2112,11 @@ LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) { LOperand* context = UseFixed(instr->context(), esi); - LOperand* global_object = UseFixed(instr->global_object(), - LoadIC::ReceiverRegister()); + LOperand* global_object = + UseFixed(instr->global_object(), LoadDescriptor::ReceiverRegister()); LOperand* vector = NULL; if (FLAG_vector_ics) { - vector = FixedTemp(LoadIC::VectorRegister()); + vector = FixedTemp(VectorLoadICDescriptor::VectorRegister()); } LLoadGlobalGeneric* result = @@ -2140,10 +2173,11 @@ LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) { LInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) { LOperand* context = UseFixed(instr->context(), esi); - LOperand* object = UseFixed(instr->object(), LoadIC::ReceiverRegister()); + LOperand* object = + UseFixed(instr->object(), LoadDescriptor::ReceiverRegister()); LOperand* vector = NULL; if (FLAG_vector_ics) { - vector = FixedTemp(LoadIC::VectorRegister()); + vector = FixedTemp(VectorLoadICDescriptor::VectorRegister()); } LLoadNamedGeneric* result = new(zone()) LLoadNamedGeneric( context, object, vector); @@ -2203,11 +2237,12 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { LOperand* context = UseFixed(instr->context(), esi); - LOperand* object = UseFixed(instr->object(), LoadIC::ReceiverRegister()); - LOperand* key = UseFixed(instr->key(), LoadIC::NameRegister()); + LOperand* object = + UseFixed(instr->object(), LoadDescriptor::ReceiverRegister()); + LOperand* key = UseFixed(instr->key(), LoadDescriptor::NameRegister()); LOperand* vector = NULL; if (FLAG_vector_ics) { - vector = FixedTemp(LoadIC::VectorRegister()); + vector = FixedTemp(VectorLoadICDescriptor::VectorRegister()); } LLoadKeyedGeneric* result = new(zone()) LLoadKeyedGeneric(context, object, key, vector); @@ -2246,8 +2281,10 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { if (instr->value()->representation().IsDouble()) { LOperand* object = UseRegisterAtStart(instr->elements()); - LOperand* val = NULL; - val = UseRegisterAtStart(instr->value()); + // For storing double hole, no fp register required. + LOperand* val = instr->IsConstantHoleStore() + ? NULL + : UseRegisterAtStart(instr->value()); LOperand* key = UseRegisterOrConstantAtStart(instr->key()); return new(zone()) LStoreKeyed(object, key, val); } else { @@ -2292,10 +2329,10 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { LOperand* context = UseFixed(instr->context(), esi); - LOperand* object = UseFixed(instr->object(), - KeyedStoreIC::ReceiverRegister()); - LOperand* key = UseFixed(instr->key(), KeyedStoreIC::NameRegister()); - LOperand* value = UseFixed(instr->value(), KeyedStoreIC::ValueRegister()); + LOperand* object = + UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); + LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister()); + LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); DCHECK(instr->object()->representation().IsTagged()); DCHECK(instr->key()->representation().IsTagged()); @@ -2375,8 +2412,6 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { val = UseTempRegister(instr->value()); } else if (can_be_constant) { val = UseRegisterOrConstant(instr->value()); - } else if (instr->field_representation().IsSmi()) { - val = UseTempRegister(instr->value()); } else if (instr->field_representation().IsDouble()) { val = UseRegisterAtStart(instr->value()); } else { @@ -2397,8 +2432,9 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { LOperand* context = UseFixed(instr->context(), esi); - LOperand* object = UseFixed(instr->object(), StoreIC::ReceiverRegister()); - LOperand* value = UseFixed(instr->value(), StoreIC::ValueRegister()); + LOperand* object = + UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); + LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); LStoreNamedGeneric* result = new(zone()) LStoreNamedGeneric(context, object, value); @@ -2475,10 +2511,10 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { return DefineAsSpilled(result, spill_index); } else { DCHECK(info()->IsStub()); - CodeStubInterfaceDescriptor* descriptor = - info()->code_stub()->GetInterfaceDescriptor(); + CallInterfaceDescriptor descriptor = + info()->code_stub()->GetCallInterfaceDescriptor(); int index = static_cast<int>(instr->index()); - Register reg = descriptor->GetEnvironmentParameterRegister(index); + Register reg = descriptor.GetEnvironmentParameterRegister(index); return DefineFixed(result, reg); } } @@ -2494,7 +2530,7 @@ LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { } else { spill_index = env_index - instr->environment()->first_local_index(); if (spill_index > LUnallocated::kMaxFixedSlotIndex) { - Abort(kNotEnoughSpillSlotsForOsr); + Retry(kNotEnoughSpillSlotsForOsr); spill_index = 0; } if (spill_index == 0) { @@ -2606,6 +2642,7 @@ LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) { inner->Bind(instr->arguments_var(), instr->arguments_object()); } + inner->BindContext(instr->closure_context()); inner->set_entry(instr); current_block_->UpdateEnvironment(inner); chunk_->AddInlinedClosure(instr->closure()); |