diff options
Diffstat (limited to 'deps/v8/src/crankshaft')
55 files changed, 597 insertions, 2120 deletions
diff --git a/deps/v8/src/crankshaft/arm/lithium-arm.cc b/deps/v8/src/crankshaft/arm/lithium-arm.cc index 324dcfefa8..8c4b7356c9 100644 --- a/deps/v8/src/crankshaft/arm/lithium-arm.cc +++ b/deps/v8/src/crankshaft/arm/lithium-arm.cc @@ -304,15 +304,6 @@ void LStoreNamedField::PrintDataTo(StringStream* stream) { } -void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("."); - stream->Add(String::cast(*name())->ToCString().get()); - stream->Add(" <- "); - value()->PrintTo(stream); -} - - void LLoadKeyed::PrintDataTo(StringStream* stream) { elements()->PrintTo(stream); stream->Add("["); @@ -345,15 +336,6 @@ void LStoreKeyed::PrintDataTo(StringStream* stream) { } -void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("["); - key()->PrintTo(stream); - stream->Add("] <- "); - value()->PrintTo(stream); -} - - void LTransitionElementsKind::PrintDataTo(StringStream* stream) { object()->PrintTo(stream); stream->Add(" %p -> %p", *original_map(), *transitioned_map()); @@ -877,7 +859,7 @@ void LChunkBuilder::AddInstruction(LInstruction* instr, LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { LInstruction* result = new (zone()) LPrologue(); - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { result = MarkAsCall(result, instr); } return result; @@ -1019,6 +1001,9 @@ LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { CallInterfaceDescriptor descriptor = instr->descriptor(); + DCHECK_EQ(descriptor.GetParameterCount() + + LCallWithDescriptor::kImplicitRegisterParameterCount, + instr->OperandCount()); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList<LOperand*> ops(instr->OperandCount(), zone()); @@ -1027,15 +1012,20 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor( // Context LOperand* op = UseFixed(instr->OperandAt(1), cp); ops.Add(op, zone()); - // Other register parameters - for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; - i < instr->OperandCount(); i++) { - op = - UseFixed(instr->OperandAt(i), - descriptor.GetRegisterParameter( - i - LCallWithDescriptor::kImplicitRegisterParameterCount)); + // Load register parameters. + int i = 0; + for (; i < descriptor.GetRegisterParameterCount(); i++) { + op = UseFixed(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount), + descriptor.GetRegisterParameter(i)); ops.Add(op, zone()); } + // Push stack parameters. + for (; i < descriptor.GetParameterCount(); i++) { + op = UseAny(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount)); + AddInstruction(new (zone()) LPushArgument(op), instr); + } LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( descriptor, ops, zone()); @@ -2180,26 +2170,6 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { } -LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - LOperand* obj = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister()); - LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - - DCHECK(instr->object()->representation().IsTagged()); - DCHECK(instr->key()->representation().IsTagged()); - DCHECK(instr->value()->representation().IsTagged()); - - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreKeyedGeneric* result = - new (zone()) LStoreKeyedGeneric(context, obj, key, val, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoTransitionElementsKind( HTransitionElementsKind* instr) { if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { @@ -2276,20 +2246,6 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { } -LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - LOperand* obj = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreNamedGeneric* result = - new (zone()) LStoreNamedGeneric(context, obj, val, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { LOperand* context = UseFixed(instr->context(), cp); LOperand* left = UseFixed(instr->left(), r1); diff --git a/deps/v8/src/crankshaft/arm/lithium-arm.h b/deps/v8/src/crankshaft/arm/lithium-arm.h index 80fbe81a0f..abdfbddf4d 100644 --- a/deps/v8/src/crankshaft/arm/lithium-arm.h +++ b/deps/v8/src/crankshaft/arm/lithium-arm.h @@ -132,9 +132,7 @@ class LCodeGen; V(StoreCodeEntry) \ V(StoreContextSlot) \ V(StoreKeyed) \ - V(StoreKeyedGeneric) \ V(StoreNamedField) \ - V(StoreNamedGeneric) \ V(StringAdd) \ V(StringCharCodeAt) \ V(StringCharFromCode) \ @@ -2005,33 +2003,6 @@ class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> { }; -class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> { - public: - LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value, - LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* value() { return inputs_[2]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric) - - void PrintDataTo(StringStream* stream) override; - - Handle<Object> name() const { return hydrogen()->name(); } - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { public: LStoreKeyed(LOperand* object, LOperand* key, LOperand* value, @@ -2068,34 +2039,6 @@ class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { }; -class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> { - public: - LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key, - LOperand* value, LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = key; - inputs_[3] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* key() { return inputs_[2]; } - LOperand* value() { return inputs_[3]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric) - - void PrintDataTo(StringStream* stream) override; - - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> { public: LTransitionElementsKind(LOperand* object, diff --git a/deps/v8/src/crankshaft/arm/lithium-codegen-arm.cc b/deps/v8/src/crankshaft/arm/lithium-codegen-arm.cc index ee3e54b604..f2cc4b447e 100644 --- a/deps/v8/src/crankshaft/arm/lithium-codegen-arm.cc +++ b/deps/v8/src/crankshaft/arm/lithium-codegen-arm.cc @@ -152,7 +152,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Comment(";;; Prologue begin"); // Possibly allocate a local context. - if (info()->scope()->num_heap_slots() > 0) { + if (info()->scope()->NeedsContext()) { Comment(";;; Allocate local context"); bool need_write_barrier = true; // Argument to NewContext is the function, which is in r1. @@ -160,7 +160,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; if (info()->scope()->is_script_scope()) { __ push(r1); - __ Push(info()->scope()->GetScopeInfo(info()->isolate())); + __ Push(info()->scope()->scope_info()); __ CallRuntime(Runtime::kNewScriptContext); deopt_mode = Safepoint::kLazyDeopt; } else { @@ -2602,20 +2602,6 @@ void LCodeGen::EmitVectorLoadICRegisters(T* instr) { } -template <class T> -void LCodeGen::EmitVectorStoreICRegisters(T* instr) { - Register vector_register = ToRegister(instr->temp_vector()); - Register slot_register = ToRegister(instr->temp_slot()); - - AllowDeferredHandleDereference vector_structure_check; - Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); - __ Move(vector_register, vector); - FeedbackVectorSlot slot = instr->hydrogen()->slot(); - int index = vector->GetIndex(slot); - __ mov(slot_register, Operand(Smi::FromInt(index))); -} - - void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { DCHECK(ToRegister(instr->context()).is(cp)); DCHECK(ToRegister(instr->result()).is(r0)); @@ -3860,21 +3846,6 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } -void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreNamedGeneric>(instr); - - __ mov(StoreDescriptor::NameRegister(), Operand(instr->name())); - Handle<Code> ic = - CodeFactory::StoreICInOptimizedCode(isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS); -} - - void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { Condition cc = instr->hydrogen()->allow_equality() ? hi : hs; if (instr->index()->IsConstantOperand()) { @@ -4071,21 +4042,6 @@ void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { } -void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreKeyedGeneric>(instr); - - Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( - isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS); -} - - void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) { class DeferredMaybeGrowElements final : public LDeferredCode { public: @@ -5063,7 +5019,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) { if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ Allocate(size, result, scratch, scratch2, deferred->entry(), flags); } else { Register size = ToRegister(instr->size()); @@ -5165,7 +5121,7 @@ void LCodeGen::DoFastAllocate(LFastAllocate* instr) { } if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ FastAllocate(size, result, scratch1, scratch2, flags); } else { Register size = ToRegister(instr->size()); diff --git a/deps/v8/src/crankshaft/arm/lithium-codegen-arm.h b/deps/v8/src/crankshaft/arm/lithium-codegen-arm.h index 533f4c8cca..26b7fb50a8 100644 --- a/deps/v8/src/crankshaft/arm/lithium-codegen-arm.h +++ b/deps/v8/src/crankshaft/arm/lithium-codegen-arm.h @@ -311,8 +311,6 @@ class LCodeGen: public LCodeGenBase { template <class T> void EmitVectorLoadICRegisters(T* instr); - template <class T> - void EmitVectorStoreICRegisters(T* instr); ZoneList<Deoptimizer::JumpTableEntry> jump_table_; Scope* const scope_; diff --git a/deps/v8/src/crankshaft/arm64/lithium-arm64.cc b/deps/v8/src/crankshaft/arm64/lithium-arm64.cc index 8067a6ae28..8a9ce4266d 100644 --- a/deps/v8/src/crankshaft/arm64/lithium-arm64.cc +++ b/deps/v8/src/crankshaft/arm64/lithium-arm64.cc @@ -252,15 +252,6 @@ void LStoreContextSlot::PrintDataTo(StringStream* stream) { } -void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("["); - key()->PrintTo(stream); - stream->Add("] <- "); - value()->PrintTo(stream); -} - - void LStoreNamedField::PrintDataTo(StringStream* stream) { object()->PrintTo(stream); std::ostringstream os; @@ -271,15 +262,6 @@ void LStoreNamedField::PrintDataTo(StringStream* stream) { } -void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("."); - stream->Add(String::cast(*name())->ToCString().get()); - stream->Add(" <- "); - value()->PrintTo(stream); -} - - void LStringCompareAndBranch::PrintDataTo(StringStream* stream) { stream->Add("if string_compare("); left()->PrintTo(stream); @@ -726,7 +708,7 @@ LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { LInstruction* result = new (zone()) LPrologue(); - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { result = MarkAsCall(result, instr); } return result; @@ -981,6 +963,9 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { CallInterfaceDescriptor descriptor = instr->descriptor(); + DCHECK_EQ(descriptor.GetParameterCount() + + LCallWithDescriptor::kImplicitRegisterParameterCount, + instr->OperandCount()); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList<LOperand*> ops(instr->OperandCount(), zone()); @@ -989,15 +974,30 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor( // Context LOperand* op = UseFixed(instr->OperandAt(1), cp); ops.Add(op, zone()); - // Other register parameters - for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; - i < instr->OperandCount(); i++) { - op = - UseFixed(instr->OperandAt(i), - descriptor.GetRegisterParameter( - i - LCallWithDescriptor::kImplicitRegisterParameterCount)); + // Load register parameters. + int i = 0; + for (; i < descriptor.GetRegisterParameterCount(); i++) { + op = UseFixed(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount), + descriptor.GetRegisterParameter(i)); ops.Add(op, zone()); } + // Push stack parameters. + if (i < descriptor.GetParameterCount()) { + int argc = descriptor.GetParameterCount() - i; + AddInstruction(new (zone()) LPreparePushArguments(argc), instr); + LPushArguments* push_args = new (zone()) LPushArguments(zone()); + for (; i < descriptor.GetParameterCount(); i++) { + if (push_args->ShouldSplitPush()) { + AddInstruction(push_args, instr); + push_args = new (zone()) LPushArguments(zone()); + } + op = UseRegisterAtStart(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount)); + push_args->AddArgument(op); + } + AddInstruction(push_args, instr); + } LCallWithDescriptor* result = new(zone()) LCallWithDescriptor(descriptor, ops, @@ -2209,26 +2209,6 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { } -LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - 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()); - DCHECK(instr->value()->representation().IsTagged()); - - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreKeyedGeneric* result = new (zone()) - LStoreKeyedGeneric(context, object, key, value, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { // TODO(jbramley): It might be beneficial to allow value to be a constant in // some cases. x64 makes use of this with FLAG_track_fields, for example. @@ -2258,21 +2238,6 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { } -LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - LOperand* object = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreNamedGeneric* result = - new (zone()) LStoreNamedGeneric(context, object, value, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { LOperand* context = UseFixed(instr->context(), cp); LOperand* left = UseFixed(instr->left(), x1); diff --git a/deps/v8/src/crankshaft/arm64/lithium-arm64.h b/deps/v8/src/crankshaft/arm64/lithium-arm64.h index 782da09546..9891f9ee49 100644 --- a/deps/v8/src/crankshaft/arm64/lithium-arm64.h +++ b/deps/v8/src/crankshaft/arm64/lithium-arm64.h @@ -143,9 +143,7 @@ class LCodeGen; V(StoreKeyedExternal) \ V(StoreKeyedFixed) \ V(StoreKeyedFixedDouble) \ - V(StoreKeyedGeneric) \ V(StoreNamedField) \ - V(StoreNamedGeneric) \ V(StringAdd) \ V(StringCharCodeAt) \ V(StringCharFromCode) \ @@ -2336,34 +2334,6 @@ class LStoreKeyedFixedDouble final : public LStoreKeyed<1> { }; -class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> { - public: - LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key, - LOperand* value, LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = key; - inputs_[3] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* key() { return inputs_[2]; } - LOperand* value() { return inputs_[3]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric) - - void PrintDataTo(StringStream* stream) override; - - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> { public: LStoreNamedField(LOperand* object, LOperand* value, @@ -2390,33 +2360,6 @@ class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> { }; -class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> { - public: - LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value, - LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* value() { return inputs_[2]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric) - - void PrintDataTo(StringStream* stream) override; - - Handle<Object> name() const { return hydrogen()->name(); } - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> { public: LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements, diff --git a/deps/v8/src/crankshaft/arm64/lithium-codegen-arm64.cc b/deps/v8/src/crankshaft/arm64/lithium-codegen-arm64.cc index ce5813b1e1..a4aa275b15 100644 --- a/deps/v8/src/crankshaft/arm64/lithium-codegen-arm64.cc +++ b/deps/v8/src/crankshaft/arm64/lithium-codegen-arm64.cc @@ -583,14 +583,14 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Comment(";;; Prologue begin"); // Allocate a local context if needed. - if (info()->scope()->num_heap_slots() > 0) { + if (info()->scope()->NeedsContext()) { Comment(";;; Allocate local context"); bool need_write_barrier = true; // Argument to NewContext is the function, which is in x1. int slots = info()->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; if (info()->scope()->is_script_scope()) { - __ Mov(x10, Operand(info()->scope()->GetScopeInfo(info()->isolate()))); + __ Mov(x10, Operand(info()->scope()->scope_info())); __ Push(x1, x10); __ CallRuntime(Runtime::kNewScriptContext); deopt_mode = Safepoint::kLazyDeopt; @@ -1403,7 +1403,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) { if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ Allocate(size, result, temp1, temp2, deferred->entry(), flags); } else { Register size = ToRegister32(instr->size()); @@ -1499,7 +1499,7 @@ void LCodeGen::DoFastAllocate(LFastAllocate* instr) { } if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ FastAllocate(size, result, scratch1, scratch2, flags); } else { Register size = ToRegister(instr->size()); @@ -1973,7 +1973,16 @@ void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) { generator.AfterCall(); } - RecordPushedArgumentsDelta(instr->hydrogen()->argument_delta()); + HCallWithDescriptor* hinstr = instr->hydrogen(); + RecordPushedArgumentsDelta(hinstr->argument_delta()); + + // HCallWithDescriptor instruction is translated to zero or more + // LPushArguments (they handle parameters passed on the stack) followed by + // a LCallWithDescriptor. Each LPushArguments instruction generated records + // the number of arguments pushed thus we need to offset them here. + // The |argument_delta()| used above "knows" only about JS parameters while + // we are dealing here with particular calling convention details. + RecordPushedArgumentsDelta(-hinstr->descriptor().GetStackParameterCount()); } @@ -3021,20 +3030,6 @@ void LCodeGen::EmitVectorLoadICRegisters(T* instr) { } -template <class T> -void LCodeGen::EmitVectorStoreICRegisters(T* instr) { - Register vector_register = ToRegister(instr->temp_vector()); - Register slot_register = ToRegister(instr->temp_slot()); - - AllowDeferredHandleDereference vector_structure_check; - Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); - __ Mov(vector_register, vector); - FeedbackVectorSlot slot = instr->hydrogen()->slot(); - int index = vector->GetIndex(slot); - __ Mov(slot_register, Smi::FromInt(index)); -} - - void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { DCHECK(ToRegister(instr->context()).is(cp)); DCHECK(ToRegister(instr->result()).Is(x0)); @@ -4933,21 +4928,6 @@ void LCodeGen::DoStoreKeyedFixed(LStoreKeyedFixed* instr) { } -void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreKeyedGeneric>(instr); - - Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( - isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) { class DeferredMaybeGrowElements final : public LDeferredCode { public: @@ -5131,21 +5111,6 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } -void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreNamedGeneric>(instr); - - __ Mov(StoreDescriptor::NameRegister(), Operand(instr->name())); - Handle<Code> ic = - CodeFactory::StoreICInOptimizedCode(isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoStringAdd(LStringAdd* instr) { DCHECK(ToRegister(instr->context()).is(cp)); DCHECK(ToRegister(instr->left()).Is(x1)); diff --git a/deps/v8/src/crankshaft/arm64/lithium-codegen-arm64.h b/deps/v8/src/crankshaft/arm64/lithium-codegen-arm64.h index 2fc6f96d7a..ca04fa27c0 100644 --- a/deps/v8/src/crankshaft/arm64/lithium-codegen-arm64.h +++ b/deps/v8/src/crankshaft/arm64/lithium-codegen-arm64.h @@ -186,8 +186,6 @@ class LCodeGen: public LCodeGenBase { template <class T> void EmitVectorLoadICRegisters(T* instr); - template <class T> - void EmitVectorStoreICRegisters(T* instr); // Emits optimized code for %_IsString(x). Preserves input register. // Returns the condition on which a final split to diff --git a/deps/v8/src/crankshaft/compilation-phase.h b/deps/v8/src/crankshaft/compilation-phase.h index 99e24c72c8..8d6468d4dc 100644 --- a/deps/v8/src/crankshaft/compilation-phase.h +++ b/deps/v8/src/crankshaft/compilation-phase.h @@ -6,8 +6,9 @@ #define V8_CRANKSHAFT_COMPILATION_PHASE_H_ #include "src/allocation.h" -#include "src/compiler.h" -#include "src/zone.h" +#include "src/base/platform/elapsed-timer.h" +#include "src/compilation-info.h" +#include "src/zone/zone.h" namespace v8 { namespace internal { diff --git a/deps/v8/src/crankshaft/hydrogen-bce.cc b/deps/v8/src/crankshaft/hydrogen-bce.cc index d00d8ce25c..7910c5bdae 100644 --- a/deps/v8/src/crankshaft/hydrogen-bce.cc +++ b/deps/v8/src/crankshaft/hydrogen-bce.cc @@ -307,24 +307,25 @@ static bool BoundsCheckKeyMatch(void* key1, void* key2) { return k1->IndexBase() == k2->IndexBase() && k1->Length() == k2->Length(); } - BoundsCheckTable::BoundsCheckTable(Zone* zone) - : ZoneHashMap(BoundsCheckKeyMatch, ZoneHashMap::kDefaultHashMapCapacity, - ZoneAllocationPolicy(zone)) { } - + : CustomMatcherZoneHashMap(BoundsCheckKeyMatch, + ZoneHashMap::kDefaultHashMapCapacity, + ZoneAllocationPolicy(zone)) {} BoundsCheckBbData** BoundsCheckTable::LookupOrInsert(BoundsCheckKey* key, Zone* zone) { return reinterpret_cast<BoundsCheckBbData**>( - &(ZoneHashMap::LookupOrInsert(key, key->Hash(), - ZoneAllocationPolicy(zone))->value)); + &(CustomMatcherZoneHashMap::LookupOrInsert(key, key->Hash(), + ZoneAllocationPolicy(zone)) + ->value)); } void BoundsCheckTable::Insert(BoundsCheckKey* key, BoundsCheckBbData* data, Zone* zone) { - ZoneHashMap::LookupOrInsert(key, key->Hash(), ZoneAllocationPolicy(zone)) + CustomMatcherZoneHashMap::LookupOrInsert(key, key->Hash(), + ZoneAllocationPolicy(zone)) ->value = data; } diff --git a/deps/v8/src/crankshaft/hydrogen-bce.h b/deps/v8/src/crankshaft/hydrogen-bce.h index e819ffc403..237fb953f2 100644 --- a/deps/v8/src/crankshaft/hydrogen-bce.h +++ b/deps/v8/src/crankshaft/hydrogen-bce.h @@ -13,7 +13,7 @@ namespace internal { class BoundsCheckBbData; class BoundsCheckKey; -class BoundsCheckTable : private ZoneHashMap { +class BoundsCheckTable : private CustomMatcherZoneHashMap { public: explicit BoundsCheckTable(Zone* zone); diff --git a/deps/v8/src/crankshaft/hydrogen-flow-engine.h b/deps/v8/src/crankshaft/hydrogen-flow-engine.h index 3a488ddc18..149c99bec5 100644 --- a/deps/v8/src/crankshaft/hydrogen-flow-engine.h +++ b/deps/v8/src/crankshaft/hydrogen-flow-engine.h @@ -5,9 +5,9 @@ #ifndef V8_CRANKSHAFT_HYDROGEN_FLOW_ENGINE_H_ #define V8_CRANKSHAFT_HYDROGEN_FLOW_ENGINE_H_ -#include "src/crankshaft/hydrogen.h" #include "src/crankshaft/hydrogen-instructions.h" -#include "src/zone.h" +#include "src/crankshaft/hydrogen.h" +#include "src/zone/zone.h" namespace v8 { namespace internal { diff --git a/deps/v8/src/crankshaft/hydrogen-gvn.h b/deps/v8/src/crankshaft/hydrogen-gvn.h index 9a8d40710f..5f11737dbc 100644 --- a/deps/v8/src/crankshaft/hydrogen-gvn.h +++ b/deps/v8/src/crankshaft/hydrogen-gvn.h @@ -7,9 +7,9 @@ #include <iosfwd> -#include "src/crankshaft/hydrogen.h" #include "src/crankshaft/hydrogen-instructions.h" -#include "src/zone.h" +#include "src/crankshaft/hydrogen.h" +#include "src/zone/zone.h" namespace v8 { namespace internal { diff --git a/deps/v8/src/crankshaft/hydrogen-instructions.cc b/deps/v8/src/crankshaft/hydrogen-instructions.cc index 9fed9612c6..3a0aaa70e7 100644 --- a/deps/v8/src/crankshaft/hydrogen-instructions.cc +++ b/deps/v8/src/crankshaft/hydrogen-instructions.cc @@ -831,7 +831,6 @@ bool HInstruction::CanDeoptimize() { case HValue::kStoreCodeEntry: case HValue::kStoreKeyed: case HValue::kStoreNamedField: - case HValue::kStoreNamedGeneric: case HValue::kStringCharCodeAt: case HValue::kStringCharFromCode: case HValue::kThisFunction: @@ -881,7 +880,6 @@ bool HInstruction::CanDeoptimize() { case HValue::kSimulate: case HValue::kStackCheck: case HValue::kStoreContextSlot: - case HValue::kStoreKeyedGeneric: case HValue::kStringAdd: case HValue::kStringCompareAndBranch: case HValue::kSub: @@ -3039,14 +3037,6 @@ HValue* HLoadKeyedGeneric::Canonicalize() { } -std::ostream& HStoreNamedGeneric::PrintDataTo( - std::ostream& os) const { // NOLINT - Handle<String> n = Handle<String>::cast(name()); - return os << NameOf(object()) << "." << n->ToCString().get() << " = " - << NameOf(value()); -} - - std::ostream& HStoreNamedField::PrintDataTo(std::ostream& os) const { // NOLINT os << NameOf(object()) << access_ << " = " << NameOf(value()); if (NeedsWriteBarrier()) os << " (write-barrier)"; @@ -3070,13 +3060,6 @@ std::ostream& HStoreKeyed::PrintDataTo(std::ostream& os) const { // NOLINT } -std::ostream& HStoreKeyedGeneric::PrintDataTo( - std::ostream& os) const { // NOLINT - return os << NameOf(object()) << "[" << NameOf(key()) - << "] = " << NameOf(value()); -} - - std::ostream& HTransitionElementsKind::PrintDataTo( std::ostream& os) const { // NOLINT os << NameOf(object()); @@ -3236,8 +3219,8 @@ bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect, int32_t new_dominator_size = dominator_size_constant + current_size_max_value; // Since we clear the first word after folded memory, we cannot use the - // whole Page::kMaxRegularHeapObjectSize memory. - if (new_dominator_size > Page::kMaxRegularHeapObjectSize - kPointerSize) { + // whole kMaxRegularHeapObjectSize memory. + if (new_dominator_size > kMaxRegularHeapObjectSize - kPointerSize) { if (FLAG_trace_allocation_folding) { PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n", id(), Mnemonic(), dominator_allocate->id(), diff --git a/deps/v8/src/crankshaft/hydrogen-instructions.h b/deps/v8/src/crankshaft/hydrogen-instructions.h index 41b1e1be8b..cfede98039 100644 --- a/deps/v8/src/crankshaft/hydrogen-instructions.h +++ b/deps/v8/src/crankshaft/hydrogen-instructions.h @@ -9,6 +9,7 @@ #include <iosfwd> #include "src/allocation.h" +#include "src/ast/ast.h" #include "src/base/bits.h" #include "src/bit-vector.h" #include "src/code-stubs.h" @@ -19,7 +20,7 @@ #include "src/globals.h" #include "src/small-pointer-list.h" #include "src/utils.h" -#include "src/zone.h" +#include "src/zone/zone.h" namespace v8 { namespace internal { @@ -36,6 +37,7 @@ class HStoreNamedField; class HValue; class LInstruction; class LChunkBuilder; +class SmallMapList; #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \ V(ArithmeticBinaryOperation) \ @@ -131,9 +133,7 @@ class LChunkBuilder; V(StoreCodeEntry) \ V(StoreContextSlot) \ V(StoreKeyed) \ - V(StoreKeyedGeneric) \ V(StoreNamedField) \ - V(StoreNamedGeneric) \ V(StringAdd) \ V(StringCharCodeAt) \ V(StringCharFromCode) \ @@ -2176,7 +2176,8 @@ class HCallWithDescriptor final : public HInstruction { } else { int par_index = index - 2; DCHECK(par_index < GetParameterCount()); - return RepresentationFromType(descriptor_.GetParameterType(par_index)); + return RepresentationFromMachineType( + descriptor_.GetParameterType(par_index)); } } @@ -2215,7 +2216,7 @@ class HCallWithDescriptor final : public HInstruction { TailCallMode syntactic_tail_call_mode, TailCallMode tail_call_mode, Zone* zone) : descriptor_(descriptor), - values_(GetParameterCount() + 1, zone), + values_(GetParameterCount() + 1, zone), // +1 here is for target. argument_count_(argument_count), bit_field_( TailCallModeField::encode(tail_call_mode) | @@ -2237,7 +2238,7 @@ class HCallWithDescriptor final : public HInstruction { } int GetParameterCount() const { - return descriptor_.GetRegisterParameterCount() + 1; + return descriptor_.GetParameterCount() + 1; // +1 here is for context. } void InternalSetOperandAt(int index, HValue* value) final { @@ -6326,52 +6327,6 @@ class HStoreNamedField final : public HTemplateInstruction<3> { uint32_t bit_field_; }; -class HStoreNamedGeneric final : public HTemplateInstruction<3> { - public: - DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P6(HStoreNamedGeneric, HValue*, - Handle<Name>, HValue*, - LanguageMode, - Handle<TypeFeedbackVector>, - FeedbackVectorSlot); - HValue* object() const { return OperandAt(0); } - HValue* value() const { return OperandAt(1); } - HValue* context() const { return OperandAt(2); } - Handle<Name> name() const { return name_; } - LanguageMode language_mode() const { return language_mode_; } - - std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT - - Representation RequiredInputRepresentation(int index) override { - return Representation::Tagged(); - } - - FeedbackVectorSlot slot() const { return slot_; } - Handle<TypeFeedbackVector> feedback_vector() const { - return feedback_vector_; - } - - DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric) - - private: - HStoreNamedGeneric(HValue* context, HValue* object, Handle<Name> name, - HValue* value, LanguageMode language_mode, - Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) - : name_(name), - feedback_vector_(vector), - slot_(slot), - language_mode_(language_mode) { - SetOperandAt(0, object); - SetOperandAt(1, value); - SetOperandAt(2, context); - SetAllSideEffects(); - } - - Handle<Name> name_; - Handle<TypeFeedbackVector> feedback_vector_; - FeedbackVectorSlot slot_; - LanguageMode language_mode_; -}; - class HStoreKeyed final : public HTemplateInstruction<4>, public ArrayInstructionInterface { public: @@ -6554,50 +6509,6 @@ class HStoreKeyed final : public HTemplateInstruction<4>, HValue* dominator_; }; -class HStoreKeyedGeneric final : public HTemplateInstruction<4> { - public: - DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P6(HStoreKeyedGeneric, HValue*, - HValue*, HValue*, LanguageMode, - Handle<TypeFeedbackVector>, - FeedbackVectorSlot); - - HValue* object() const { return OperandAt(0); } - HValue* key() const { return OperandAt(1); } - HValue* value() const { return OperandAt(2); } - HValue* context() const { return OperandAt(3); } - LanguageMode language_mode() const { return language_mode_; } - - Representation RequiredInputRepresentation(int index) override { - // tagged[tagged] = tagged - return Representation::Tagged(); - } - - FeedbackVectorSlot slot() const { return slot_; } - Handle<TypeFeedbackVector> feedback_vector() const { - return feedback_vector_; - } - - std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT - - DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric) - - private: - HStoreKeyedGeneric(HValue* context, HValue* object, HValue* key, - HValue* value, LanguageMode language_mode, - Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) - : feedback_vector_(vector), slot_(slot), language_mode_(language_mode) { - SetOperandAt(0, object); - SetOperandAt(1, key); - SetOperandAt(2, value); - SetOperandAt(3, context); - SetAllSideEffects(); - } - - Handle<TypeFeedbackVector> feedback_vector_; - FeedbackVectorSlot slot_; - LanguageMode language_mode_; -}; - class HTransitionElementsKind final : public HTemplateInstruction<2> { public: inline static HTransitionElementsKind* New(Isolate* isolate, Zone* zone, diff --git a/deps/v8/src/crankshaft/hydrogen-osr.h b/deps/v8/src/crankshaft/hydrogen-osr.h index 0610b4284f..3bd9b6edad 100644 --- a/deps/v8/src/crankshaft/hydrogen-osr.h +++ b/deps/v8/src/crankshaft/hydrogen-osr.h @@ -6,7 +6,7 @@ #define V8_CRANKSHAFT_HYDROGEN_OSR_H_ #include "src/crankshaft/hydrogen.h" -#include "src/zone.h" +#include "src/zone/zone.h" namespace v8 { namespace internal { diff --git a/deps/v8/src/crankshaft/hydrogen-types.cc b/deps/v8/src/crankshaft/hydrogen-types.cc index 20d50d897c..684e6ad09c 100644 --- a/deps/v8/src/crankshaft/hydrogen-types.cc +++ b/deps/v8/src/crankshaft/hydrogen-types.cc @@ -12,17 +12,17 @@ namespace v8 { namespace internal { // static -HType HType::FromType(Type* type) { - if (Type::Any()->Is(type)) return HType::Any(); +HType HType::FromType(AstType* type) { + if (AstType::Any()->Is(type)) return HType::Any(); if (!type->IsInhabited()) return HType::None(); - if (type->Is(Type::SignedSmall())) return HType::Smi(); - if (type->Is(Type::Number())) return HType::TaggedNumber(); - if (type->Is(Type::Null())) return HType::Null(); - if (type->Is(Type::String())) return HType::String(); - if (type->Is(Type::Boolean())) return HType::Boolean(); - if (type->Is(Type::Undefined())) return HType::Undefined(); - if (type->Is(Type::Object())) return HType::JSObject(); - if (type->Is(Type::DetectableReceiver())) return HType::JSReceiver(); + if (type->Is(AstType::SignedSmall())) return HType::Smi(); + if (type->Is(AstType::Number())) return HType::TaggedNumber(); + if (type->Is(AstType::Null())) return HType::Null(); + if (type->Is(AstType::String())) return HType::String(); + if (type->Is(AstType::Boolean())) return HType::Boolean(); + if (type->Is(AstType::Undefined())) return HType::Undefined(); + if (type->Is(AstType::Object())) return HType::JSObject(); + if (type->Is(AstType::DetectableReceiver())) return HType::JSReceiver(); return HType::Tagged(); } diff --git a/deps/v8/src/crankshaft/hydrogen-types.h b/deps/v8/src/crankshaft/hydrogen-types.h index 0690ece34f..3e68872924 100644 --- a/deps/v8/src/crankshaft/hydrogen-types.h +++ b/deps/v8/src/crankshaft/hydrogen-types.h @@ -8,8 +8,8 @@ #include <climits> #include <iosfwd> +#include "src/ast/ast-types.h" #include "src/base/macros.h" -#include "src/types.h" namespace v8 { namespace internal { @@ -64,7 +64,7 @@ class HType final { HTYPE_LIST(DECLARE_IS_TYPE) #undef DECLARE_IS_TYPE - static HType FromType(Type* type) WARN_UNUSED_RESULT; + static HType FromType(AstType* type) WARN_UNUSED_RESULT; static HType FromFieldType(Handle<FieldType> type, Zone* temp_zone) WARN_UNUSED_RESULT; static HType FromValue(Handle<Object> value) WARN_UNUSED_RESULT; diff --git a/deps/v8/src/crankshaft/hydrogen.cc b/deps/v8/src/crankshaft/hydrogen.cc index f40337e645..8d7b4797c5 100644 --- a/deps/v8/src/crankshaft/hydrogen.cc +++ b/deps/v8/src/crankshaft/hydrogen.cc @@ -9,6 +9,7 @@ #include "src/allocation-site-scopes.h" #include "src/ast/ast-numbering.h" +#include "src/ast/compile-time-value.h" #include "src/ast/scopes.h" #include "src/code-factory.h" #include "src/crankshaft/hydrogen-bce.h" @@ -42,7 +43,6 @@ // GetRootConstructor #include "src/ic/ic-inl.h" #include "src/isolate-inl.h" -#include "src/parsing/parser.h" #include "src/runtime/runtime.h" #if V8_TARGET_ARCH_IA32 @@ -75,7 +75,9 @@ const auto GetRegConfig = RegisterConfiguration::Crankshaft; class HOptimizedGraphBuilderWithPositions : public HOptimizedGraphBuilder { public: explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) - : HOptimizedGraphBuilder(info) {} + : HOptimizedGraphBuilder(info, true) { + SetSourcePosition(info->shared_info()->start_position()); + } #define DEF_VISIT(type) \ void Visit##type(type* node) override { \ @@ -178,9 +180,10 @@ HCompilationJob::Status HCompilationJob::PrepareJobImpl() { } HOptimizedGraphBuilder* graph_builder = - (info()->is_tracking_positions() || FLAG_trace_ic) + (FLAG_hydrogen_track_positions || isolate()->is_profiling() || + FLAG_trace_ic) ? new (info()->zone()) HOptimizedGraphBuilderWithPositions(info()) - : new (info()->zone()) HOptimizedGraphBuilder(info()); + : new (info()->zone()) HOptimizedGraphBuilder(info(), false); // Type-check the function. AstTyper(info()->isolate(), info()->zone(), info()->closure(), @@ -1362,7 +1365,7 @@ HGraph* HGraphBuilder::CreateGraph() { DCHECK(!FLAG_minimal); graph_ = new (zone()) HGraph(info_, descriptor_); if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); - if (!info_->IsStub() && info_->is_tracking_positions()) { + if (!info_->IsStub() && is_tracking_positions()) { TraceInlinedFunction(info_->shared_info(), SourcePosition::Unknown()); } CompilationPhase phase("H_Block building", info_); @@ -1374,7 +1377,7 @@ HGraph* HGraphBuilder::CreateGraph() { int HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, SourcePosition position) { - DCHECK(info_->is_tracking_positions()); + DCHECK(is_tracking_positions()); int inline_id = static_cast<int>(graph()->inlined_function_infos().size()); HInlinedFunctionInfo info(shared->start_position()); @@ -1645,48 +1648,6 @@ HValue* HGraphBuilder::BuildCopyElementsOnWrite(HValue* object, } -void HGraphBuilder::BuildTransitionElementsKind(HValue* object, - HValue* map, - ElementsKind from_kind, - ElementsKind to_kind, - bool is_jsarray) { - DCHECK(!IsFastHoleyElementsKind(from_kind) || - IsFastHoleyElementsKind(to_kind)); - - if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) { - Add<HTrapAllocationMemento>(object); - } - - if (!IsSimpleMapChangeTransition(from_kind, to_kind)) { - HInstruction* elements = AddLoadElements(object); - - HInstruction* empty_fixed_array = Add<HConstant>( - isolate()->factory()->empty_fixed_array()); - - IfBuilder if_builder(this); - - if_builder.IfNot<HCompareObjectEqAndBranch>(elements, empty_fixed_array); - - if_builder.Then(); - - HInstruction* elements_length = AddLoadFixedArrayLength(elements); - - HInstruction* array_length = - is_jsarray - ? Add<HLoadNamedField>(object, nullptr, - HObjectAccess::ForArrayLength(from_kind)) - : elements_length; - - BuildGrowElementsCapacity(object, elements, from_kind, to_kind, - array_length, elements_length); - - if_builder.End(); - } - - Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map); -} - - void HGraphBuilder::BuildJSObjectCheck(HValue* receiver, int bit_field_mask) { // Check that the object isn't a smi. @@ -2129,8 +2090,7 @@ HValue* HGraphBuilder::BuildRegExpConstructResult(HValue* length, return result; } - -HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) { +HValue* HGraphBuilder::BuildNumberToString(HValue* object, AstType* type) { NoObservableSideEffectsScope scope(this); // Convert constant numbers at compile time. @@ -2180,7 +2140,7 @@ HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) { } if_objectissmi.Else(); { - if (type->Is(Type::SignedSmall())) { + if (type->Is(AstType::SignedSmall())) { if_objectissmi.Deopt(DeoptimizeReason::kExpectedSmi); } else { // Check if the object is a heap number. @@ -2236,7 +2196,7 @@ HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) { } if_objectisnumber.Else(); { - if (type->Is(Type::Number())) { + if (type->Is(AstType::Number())) { if_objectisnumber.Deopt(DeoptimizeReason::kExpectedHeapNumber); } } @@ -2411,7 +2371,7 @@ HValue* HGraphBuilder::BuildAddStringLengths(HValue* left_length, HValue* length = AddUncasted<HAdd>(left_length, right_length); // Check that length <= kMaxLength <=> length < MaxLength + 1. HValue* max_length = Add<HConstant>(String::kMaxLength + 1); - if (top_info()->IsStub()) { + if (top_info()->IsStub() || !isolate()->IsStringLengthOverflowIntact()) { // This is a mitigation for crbug.com/627934; the real fix // will be to migrate the StringAddStub to TurboFan one day. IfBuilder if_invalid(this); @@ -2423,6 +2383,7 @@ HValue* HGraphBuilder::BuildAddStringLengths(HValue* left_length, } if_invalid.End(); } else { + graph()->MarkDependsOnStringLengthOverflow(); Add<HBoundsCheck>(length, max_length); } return length; @@ -2652,7 +2613,7 @@ HValue* HGraphBuilder::BuildUncheckedStringAdd( IfBuilder if_size(this); if_size.If<HCompareNumericAndBranch>( - size, Add<HConstant>(Page::kMaxRegularHeapObjectSize), Token::LT); + size, Add<HConstant>(kMaxRegularHeapObjectSize), Token::LT); if_size.Then(); { // Allocate the string object. HAllocate does not care whether we pass @@ -3075,9 +3036,10 @@ HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object, ElementsKind new_kind, HValue* length, HValue* new_capacity) { - Add<HBoundsCheck>(new_capacity, Add<HConstant>( - (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) >> - ElementsKindToShiftSize(new_kind))); + Add<HBoundsCheck>( + new_capacity, + Add<HConstant>((kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) >> + ElementsKindToShiftSize(new_kind))); HValue* new_elements = BuildAllocateAndInitializeArray(new_kind, new_capacity); @@ -3268,93 +3230,6 @@ void HGraphBuilder::BuildCopyElements(HValue* from_elements, AddIncrementCounter(counters->inlined_copied_elements()); } - -HValue* HGraphBuilder::BuildCloneShallowArrayCow(HValue* boilerplate, - HValue* allocation_site, - AllocationSiteMode mode, - ElementsKind kind) { - HAllocate* array = AllocateJSArrayObject(mode); - - HValue* map = AddLoadMap(boilerplate); - HValue* elements = AddLoadElements(boilerplate); - HValue* length = AddLoadArrayLength(boilerplate, kind); - - BuildJSArrayHeader(array, - map, - elements, - mode, - FAST_ELEMENTS, - allocation_site, - length); - return array; -} - - -HValue* HGraphBuilder::BuildCloneShallowArrayEmpty(HValue* boilerplate, - HValue* allocation_site, - AllocationSiteMode mode) { - HAllocate* array = AllocateJSArrayObject(mode); - - HValue* map = AddLoadMap(boilerplate); - - BuildJSArrayHeader(array, - map, - NULL, // set elements to empty fixed array - mode, - FAST_ELEMENTS, - allocation_site, - graph()->GetConstant0()); - return array; -} - - -HValue* HGraphBuilder::BuildCloneShallowArrayNonEmpty(HValue* boilerplate, - HValue* allocation_site, - AllocationSiteMode mode, - ElementsKind kind) { - HValue* boilerplate_elements = AddLoadElements(boilerplate); - HValue* capacity = AddLoadFixedArrayLength(boilerplate_elements); - - // Generate size calculation code here in order to make it dominate - // the JSArray allocation. - HValue* elements_size = BuildCalculateElementsSize(kind, capacity); - - // Create empty JSArray object for now, store elimination should remove - // redundant initialization of elements and length fields and at the same - // time the object will be fully prepared for GC if it happens during - // elements allocation. - HValue* result = BuildCloneShallowArrayEmpty( - boilerplate, allocation_site, mode); - - HAllocate* elements = BuildAllocateElements(kind, elements_size); - - Add<HStoreNamedField>(result, HObjectAccess::ForElementsPointer(), elements); - - // The allocation for the cloned array above causes register pressure on - // machines with low register counts. Force a reload of the boilerplate - // elements here to free up a register for the allocation to avoid unnecessary - // spillage. - boilerplate_elements = AddLoadElements(boilerplate); - boilerplate_elements->SetFlag(HValue::kCantBeReplaced); - - // Copy the elements array header. - for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { - HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); - Add<HStoreNamedField>( - elements, access, - Add<HLoadNamedField>(boilerplate_elements, nullptr, access)); - } - - // And the result of the length - HValue* length = AddLoadArrayLength(boilerplate, kind); - Add<HStoreNamedField>(result, HObjectAccess::ForArrayLength(kind), length); - - BuildCopyElements(boilerplate_elements, kind, elements, - kind, length, NULL); - return result; -} - - void HGraphBuilder::BuildCreateAllocationMemento( HValue* previous_object, HValue* previous_object_size, @@ -3402,16 +3277,6 @@ HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { } -HInstruction* HGraphBuilder::BuildGetScriptContext(int context_index) { - HValue* native_context = BuildGetNativeContext(); - HValue* script_context_table = Add<HLoadNamedField>( - native_context, nullptr, - HObjectAccess::ForContextSlot(Context::SCRIPT_CONTEXT_TABLE_INDEX)); - return Add<HLoadNamedField>(script_context_table, nullptr, - HObjectAccess::ForScriptContext(context_index)); -} - - HValue* HGraphBuilder::BuildGetParentContext(HValue* depth, int depth_value) { HValue* script_context = context(); if (depth != NULL) { @@ -3504,8 +3369,9 @@ HValue* HGraphBuilder::AddLoadJSBuiltin(int context_index) { return Add<HLoadNamedField>(native_context, nullptr, function_access); } -HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) - : HGraphBuilder(info, CallInterfaceDescriptor()), +HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info, + bool track_positions) + : HGraphBuilder(info, CallInterfaceDescriptor(), track_positions), function_state_(NULL), initial_function_state_(this, info, NORMAL_RETURN, 0, TailCallMode::kAllow), @@ -3520,9 +3386,6 @@ HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) // to know it's the initial state. function_state_ = &initial_function_state_; InitializeAstVisitor(info->isolate()); - if (top_info()->is_tracking_positions()) { - SetSourcePosition(info->shared_info()->start_position()); - } } @@ -3622,6 +3485,7 @@ HGraph::HGraph(CompilationInfo* info, CallInterfaceDescriptor descriptor) allow_code_motion_(false), use_optimistic_licm_(false), depends_on_empty_array_proto_elements_(false), + depends_on_string_length_overflow_(false), type_change_checksum_(0), maximum_environment_size_(0), no_side_effects_scope_count_(0), @@ -3629,8 +3493,8 @@ HGraph::HGraph(CompilationInfo* info, CallInterfaceDescriptor descriptor) inlined_function_infos_(info->zone()) { if (info->IsStub()) { // For stubs, explicitly add the context to the environment. - start_environment_ = new (zone_) - HEnvironment(zone_, descriptor.GetRegisterParameterCount() + 1); + start_environment_ = + new (zone_) HEnvironment(zone_, descriptor.GetParameterCount() + 1); } else { start_environment_ = new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); @@ -4088,7 +3952,7 @@ FunctionState::FunctionState(HOptimizedGraphBuilder* owner, // Push on the state stack. owner->set_function_state(this); - if (compilation_info_->is_tracking_positions()) { + if (owner->is_tracking_positions()) { outer_source_position_ = owner->source_position(); owner->EnterInlinedSource( info->shared_info()->start_position(), @@ -4102,7 +3966,7 @@ FunctionState::~FunctionState() { delete test_context_; owner_->set_function_state(outer_); - if (compilation_info_->is_tracking_positions()) { + if (owner_->is_tracking_positions()) { owner_->set_source_position(outer_source_position_); owner_->EnterInlinedSource( outer_->compilation_info()->shared_info()->start_position(), @@ -4651,9 +4515,7 @@ void HOptimizedGraphBuilder::SetUpScope(DeclarationScope* scope) { environment()->Bind(scope->arguments(), arguments_object); } - int rest_index; - Variable* rest = scope->rest_parameter(&rest_index); - if (rest) { + if (scope->rest_parameter() != nullptr) { return Bailout(kRestParameter); } @@ -4704,7 +4566,7 @@ void HOptimizedGraphBuilder::VisitBlock(Block* stmt) { } AddInstruction(function); // Allocate a block context and store it to the stack frame. - HValue* scope_info = Add<HConstant>(scope->GetScopeInfo(isolate())); + HValue* scope_info = Add<HConstant>(scope->scope_info()); Add<HPushArguments>(scope_info, function); HInstruction* inner_context = Add<HCallRuntime>( Runtime::FunctionForId(Runtime::kPushBlockContext), 2); @@ -5001,7 +4863,7 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { CHECK_ALIVE(VisitForValue(stmt->tag())); Add<HSimulate>(stmt->EntryId()); HValue* tag_value = Top(); - Type* tag_type = bounds_.get(stmt->tag()).lower; + AstType* tag_type = bounds_.get(stmt->tag()).lower; // 1. Build all the tests, with dangling true branches BailoutId default_id = BailoutId::None(); @@ -5018,8 +4880,8 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { if (current_block() == NULL) return Bailout(kUnsupportedSwitchStatement); HValue* label_value = Pop(); - Type* label_type = bounds_.get(clause->label()).lower; - Type* combined_type = clause->compare_type(); + AstType* label_type = bounds_.get(clause->label()).lower; + AstType* combined_type = clause->compare_type(); HControlInstruction* compare = BuildCompareInstruction( Token::EQ_STRICT, tag_value, label_value, tag_type, label_type, combined_type, @@ -5634,7 +5496,6 @@ void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { DCHECK(current_block()->HasPredecessor()); Variable* variable = expr->var(); switch (variable->location()) { - case VariableLocation::GLOBAL: case VariableLocation::UNALLOCATED: { if (IsLexicalVariableMode(variable->mode())) { // TODO(rossberg): should this be an DCHECK? @@ -6218,7 +6079,7 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::IsCompatible( PropertyAccessInfo* info) { if (!CanInlinePropertyAccess(map_)) return false; - // Currently only handle Type::Number as a polymorphic case. + // Currently only handle AstType::Number as a polymorphic case. // TODO(verwaest): Support monomorphic handling of numbers with a HCheckNumber // instruction. if (IsNumberType()) return false; @@ -6929,9 +6790,16 @@ void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX)); Handle<TypeFeedbackVector> vector = handle(current_feedback_vector(), isolate()); - HStoreNamedGeneric* instr = - Add<HStoreNamedGeneric>(global_object, var->name(), value, - function_language_mode(), vector, slot); + HValue* name = Add<HConstant>(var->name()); + HValue* vector_value = Add<HConstant>(vector); + HValue* slot_value = Add<HConstant>(vector->GetIndex(slot)); + Callable callable = CodeFactory::StoreICInOptimizedCode( + isolate(), function_language_mode()); + HValue* stub = Add<HConstant>(callable.code()); + HValue* values[] = {context(), global_object, name, + value, slot_value, vector_value}; + HCallWithDescriptor* instr = Add<HCallWithDescriptor>( + stub, 0, callable.descriptor(), ArrayVector(values)); USE(instr); DCHECK(instr->HasObservableSideEffects()); Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); @@ -6958,7 +6826,6 @@ void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { CHECK_ALIVE(VisitForValue(operation)); switch (var->location()) { - case VariableLocation::GLOBAL: case VariableLocation::UNALLOCATED: HandleGlobalVariableAssignment(var, Top(), expr->AssignmentSlot(), expr->AssignmentId()); @@ -6966,9 +6833,6 @@ void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { case VariableLocation::PARAMETER: case VariableLocation::LOCAL: - if (var->mode() == CONST_LEGACY) { - return Bailout(kUnsupportedConstCompoundAssignment); - } if (var->mode() == CONST) { return Bailout(kNonInitializerAssignmentToConst); } @@ -6998,9 +6862,7 @@ void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { mode = HStoreContextSlot::kCheckDeoptimize; break; case CONST: - return Bailout(kNonInitializerAssignmentToConst); - case CONST_LEGACY: - if (is_strict(function_language_mode())) { + if (var->throw_on_const_assignment(function_language_mode())) { return Bailout(kNonInitializerAssignmentToConst); } else { return ast_context()->ReturnValue(Pop()); @@ -7072,33 +6934,17 @@ void HOptimizedGraphBuilder::VisitAssignment(Assignment* expr) { if (var->mode() == CONST) { if (expr->op() != Token::INIT) { - return Bailout(kNonInitializerAssignmentToConst); - } - } else if (var->mode() == CONST_LEGACY) { - if (expr->op() != Token::INIT) { - if (is_strict(function_language_mode())) { + if (var->throw_on_const_assignment(function_language_mode())) { return Bailout(kNonInitializerAssignmentToConst); } else { CHECK_ALIVE(VisitForValue(expr->value())); return ast_context()->ReturnValue(Pop()); } } - - // TODO(adamk): Is this required? Legacy const variables are always - // initialized before use. - if (var->IsStackAllocated()) { - // We insert a use of the old value to detect unsupported uses of const - // variables (e.g. initialization inside a loop). - HValue* old_value = environment()->Lookup(var); - Add<HUseConst>(old_value); - } } - if (var->is_arguments()) return Bailout(kAssignmentToArguments); - // Handle the assignment. switch (var->location()) { - case VariableLocation::GLOBAL: case VariableLocation::UNALLOCATED: CHECK_ALIVE(VisitForValue(expr->value())); HandleGlobalVariableAssignment(var, Top(), expr->AssignmentSlot(), @@ -7147,10 +6993,10 @@ void HOptimizedGraphBuilder::VisitAssignment(Assignment* expr) { mode = HStoreContextSlot::kCheckDeoptimize; break; case CONST: - // This case is checked statically so no need to - // perform checks here - UNREACHABLE(); - case CONST_LEGACY: + // If we reached this point, the only possibility + // is a sloppy assignment to a function name. + DCHECK(function_language_mode() == SLOPPY && + !var->throw_on_const_assignment(SLOPPY)); return ast_context()->ReturnValue(Pop()); default: mode = HStoreContextSlot::kNoCheck; @@ -7200,7 +7046,7 @@ void HOptimizedGraphBuilder::VisitThrow(Throw* expr) { CHECK_ALIVE(VisitForValue(expr->exception())); HValue* value = environment()->Pop(); - if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position()); + if (!is_tracking_positions()) SetSourcePosition(expr->position()); Add<HPushArguments>(value); Add<HCallRuntime>(Runtime::FunctionForId(Runtime::kThrow), 1); Add<HSimulate>(expr->id()); @@ -7274,20 +7120,30 @@ HInstruction* HOptimizedGraphBuilder::BuildNamedGeneric( Handle<TypeFeedbackVector> vector = handle(current_feedback_vector(), isolate()); + HValue* key = Add<HConstant>(name); + HValue* vector_value = Add<HConstant>(vector); + HValue* slot_value = Add<HConstant>(vector->GetIndex(slot)); + HValue* values[] = {context(), object, key, + value, slot_value, vector_value}; + if (current_feedback_vector()->GetKind(slot) == FeedbackVectorSlotKind::KEYED_STORE_IC) { // It's possible that a keyed store of a constant string was converted // to a named store. Here, at the last minute, we need to make sure to // use a generic Keyed Store if we are using the type vector, because // it has to share information with full code. - HConstant* key = Add<HConstant>(name); - HStoreKeyedGeneric* result = New<HStoreKeyedGeneric>( - object, key, value, function_language_mode(), vector, slot); + Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( + isolate(), function_language_mode()); + HValue* stub = Add<HConstant>(callable.code()); + HCallWithDescriptor* result = New<HCallWithDescriptor>( + stub, 0, callable.descriptor(), ArrayVector(values)); return result; } - - HStoreNamedGeneric* result = New<HStoreNamedGeneric>( - object, name, value, function_language_mode(), vector, slot); + Callable callable = CodeFactory::StoreICInOptimizedCode( + isolate(), function_language_mode()); + HValue* stub = Add<HConstant>(callable.code()); + HCallWithDescriptor* result = New<HCallWithDescriptor>( + stub, 0, callable.descriptor(), ArrayVector(values)); return result; } } @@ -7303,8 +7159,16 @@ HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( New<HLoadKeyedGeneric>(object, key, vector, slot); return result; } else { - HStoreKeyedGeneric* result = New<HStoreKeyedGeneric>( - object, key, value, function_language_mode(), vector, slot); + HValue* vector_value = Add<HConstant>(vector); + HValue* slot_value = Add<HConstant>(vector->GetIndex(slot)); + HValue* values[] = {context(), object, key, + value, slot_value, vector_value}; + + Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( + isolate(), function_language_mode()); + HValue* stub = Add<HConstant>(callable.code()); + HCallWithDescriptor* result = New<HCallWithDescriptor>( + stub, 0, callable.descriptor(), ArrayVector(values)); return result; } } @@ -7843,7 +7707,7 @@ HValue* HOptimizedGraphBuilder::BuildNamedAccess( } HValue* checked_object; - // Type::Number() is only supported by polymorphic load/call handling. + // AstType::Number() is only supported by polymorphic load/call handling. DCHECK(!info.IsNumberType()); BuildCheckHeapObject(object); if (AreStringTypes(maps)) { @@ -8409,14 +8273,12 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, return false; } - if (target_info.scope()->num_heap_slots() > 0) { + if (target_info.scope()->NeedsContext()) { TraceInline(target, caller, "target has context-allocated variables"); return false; } - int rest_index; - Variable* rest = target_info.scope()->rest_parameter(&rest_index); - if (rest) { + if (target_info.scope()->rest_parameter() != nullptr) { TraceInline(target, caller, "target uses rest parameters"); return false; } @@ -8490,7 +8352,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, .Run(); int inlining_id = 0; - if (top_info()->is_tracking_positions()) { + if (is_tracking_positions()) { inlining_id = TraceInlinedFunction(target_shared, source_position()); } @@ -8539,7 +8401,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, return_id, target, context, arguments_count, function, function_state()->inlining_kind(), function->scope()->arguments(), arguments_object, syntactic_tail_call_mode); - if (top_info()->is_tracking_positions()) { + if (is_tracking_positions()) { enter_inlined->set_inlining_id(inlining_id); } function_state()->set_entry(enter_inlined); @@ -9375,7 +9237,7 @@ bool HOptimizedGraphBuilder::TryInlineApiCall( HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder, - api_function_address, nullptr}; + api_function_address}; HInstruction* call = nullptr; CHECK(argc <= CallApiCallbackStub::kArgMax); @@ -9386,16 +9248,14 @@ bool HOptimizedGraphBuilder::TryInlineApiCall( HConstant* code_value = Add<HConstant>(code); call = New<HCallWithDescriptor>( code_value, argc + 1, stub.GetCallInterfaceDescriptor(), - Vector<HValue*>(op_vals, arraysize(op_vals) - 1), - syntactic_tail_call_mode); + Vector<HValue*>(op_vals, arraysize(op_vals)), syntactic_tail_call_mode); } else { CallApiCallbackStub stub(isolate(), argc, call_data_undefined, false); Handle<Code> code = stub.GetCode(); HConstant* code_value = Add<HConstant>(code); call = New<HCallWithDescriptor>( code_value, argc + 1, stub.GetCallInterfaceDescriptor(), - Vector<HValue*>(op_vals, arraysize(op_vals) - 1), - syntactic_tail_call_mode); + Vector<HValue*>(op_vals, arraysize(op_vals)), syntactic_tail_call_mode); Drop(1); // Drop function. } @@ -9461,8 +9321,6 @@ bool HOptimizedGraphBuilder::TryIndirectCall(Call* expr) { case kFunctionApply: { // For .apply, only the pattern f.apply(receiver, arguments) // is supported. - if (current_info()->scope()->arguments() == NULL) return false; - if (!CanBeFunctionApplyArguments(expr)) return false; BuildFunctionApply(expr); @@ -9482,6 +9340,10 @@ void HOptimizedGraphBuilder::BuildFunctionApply(Call* expr) { HValue* function = Pop(); // f Drop(1); // apply + // Make sure the arguments object is live. + VariableProxy* arg_two = args->at(1)->AsVariableProxy(); + LookupAndMakeLive(arg_two->var()); + Handle<Map> function_map = expr->GetReceiverTypes()->first(); HValue* checked_function = AddCheckMap(function, function_map); @@ -9727,8 +9589,9 @@ bool HOptimizedGraphBuilder::CanBeFunctionApplyArguments(Call* expr) { if (args->length() != 2) return false; VariableProxy* arg_two = args->at(1)->AsVariableProxy(); if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; - HValue* arg_two_value = LookupAndMakeLive(arg_two->var()); + HValue* arg_two_value = environment()->Lookup(arg_two->var()); if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; + DCHECK_NOT_NULL(current_info()->scope()->arguments()); return true; } @@ -9737,7 +9600,7 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) { DCHECK(!HasStackOverflow()); DCHECK(current_block() != NULL); DCHECK(current_block()->HasPredecessor()); - if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position()); + if (!is_tracking_positions()) SetSourcePosition(expr->position()); Expression* callee = expr->expression(); int argument_count = expr->arguments()->length() + 1; // Plus receiver. HInstruction* call = NULL; @@ -9975,7 +9838,7 @@ bool HOptimizedGraphBuilder::TryInlineArrayCall(Expression* expression, HValue* elements_size = BuildCalculateElementsSize(kind, capacity); // Bail out for large objects. - HValue* max_size = Add<HConstant>(Page::kMaxRegularHeapObjectSize); + HValue* max_size = Add<HConstant>(kMaxRegularHeapObjectSize); Add<HBoundsCheck>(elements_size, max_size); // Allocate (dealing with failure appropriately). @@ -10019,7 +9882,7 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) { DCHECK(!HasStackOverflow()); DCHECK(current_block() != NULL); DCHECK(current_block()->HasPredecessor()); - if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position()); + if (!is_tracking_positions()) SetSourcePosition(expr->position()); int argument_count = expr->arguments()->length() + 1; // Plus constructor. Factory* factory = isolate()->factory(); @@ -10419,6 +10282,8 @@ void HOptimizedGraphBuilder::GenerateTypedArrayInitialize( HInstruction* length = AddUncasted<HDiv>(byte_length, Add<HConstant>(static_cast<int32_t>(element_size))); + // Callers (in typedarray.js) ensure that length <= %_MaxSmi(). + length = AddUncasted<HForceRepresentation>(length, Representation::Smi()); Add<HStoreNamedField>(obj, HObjectAccess::ForJSTypedArrayLength(), @@ -10602,7 +10467,7 @@ void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { return ast_context()->ReturnInstruction(instr, expr->id()); } else if (proxy != NULL) { Variable* var = proxy->var(); - if (var->IsUnallocatedOrGlobalSlot()) { + if (var->IsUnallocated()) { Bailout(kDeleteWithGlobalVariable); } else if (var->IsStackAllocated() || var->IsContextSlot()) { // Result of deleting non-global variables is false. 'this' is not really @@ -10680,13 +10545,12 @@ void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) { if (join != NULL) return ast_context()->ReturnValue(Pop()); } - -static Representation RepresentationFor(Type* type) { +static Representation RepresentationFor(AstType* type) { DisallowHeapAllocation no_allocation; - if (type->Is(Type::None())) return Representation::None(); - if (type->Is(Type::SignedSmall())) return Representation::Smi(); - if (type->Is(Type::Signed32())) return Representation::Integer32(); - if (type->Is(Type::Number())) return Representation::Double(); + if (type->Is(AstType::None())) return Representation::None(); + if (type->Is(AstType::SignedSmall())) return Representation::Smi(); + if (type->Is(AstType::Signed32())) return Representation::Integer32(); + if (type->Is(AstType::Number())) return Representation::Double(); return Representation::Tagged(); } @@ -10745,7 +10609,7 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) { DCHECK(!HasStackOverflow()); DCHECK(current_block() != NULL); DCHECK(current_block()->HasPredecessor()); - if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position()); + if (!is_tracking_positions()) SetSourcePosition(expr->position()); Expression* target = expr->expression(); VariableProxy* proxy = target->AsVariableProxy(); Property* prop = target->AsProperty(); @@ -10763,9 +10627,6 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) { if (proxy != NULL) { Variable* var = proxy->var(); - if (var->mode() == CONST_LEGACY) { - return Bailout(kUnsupportedCountOperationWithConst); - } if (var->mode() == CONST) { return Bailout(kNonInitializerAssignmentToConst); } @@ -10778,7 +10639,6 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) { Push(after); switch (var->location()) { - case VariableLocation::GLOBAL: case VariableLocation::UNALLOCATED: HandleGlobalVariableAssignment(var, after, expr->CountSlot(), expr->AssignmentId()); @@ -10939,27 +10799,24 @@ bool CanBeZero(HValue* right) { return true; } - -HValue* HGraphBuilder::EnforceNumberType(HValue* number, - Type* expected) { - if (expected->Is(Type::SignedSmall())) { +HValue* HGraphBuilder::EnforceNumberType(HValue* number, AstType* expected) { + if (expected->Is(AstType::SignedSmall())) { return AddUncasted<HForceRepresentation>(number, Representation::Smi()); } - if (expected->Is(Type::Signed32())) { + if (expected->Is(AstType::Signed32())) { return AddUncasted<HForceRepresentation>(number, Representation::Integer32()); } return number; } - -HValue* HGraphBuilder::TruncateToNumber(HValue* value, Type** expected) { +HValue* HGraphBuilder::TruncateToNumber(HValue* value, AstType** expected) { if (value->IsConstant()) { HConstant* constant = HConstant::cast(value); Maybe<HConstant*> number = constant->CopyToTruncatedNumber(isolate(), zone()); if (number.IsJust()) { - *expected = Type::Number(); + *expected = AstType::Number(); return AddInstruction(number.FromJust()); } } @@ -10969,24 +10826,24 @@ HValue* HGraphBuilder::TruncateToNumber(HValue* value, Type** expected) { // pushes with a NoObservableSideEffectsScope. NoObservableSideEffectsScope no_effects(this); - Type* expected_type = *expected; + AstType* expected_type = *expected; // Separate the number type from the rest. - Type* expected_obj = - Type::Intersect(expected_type, Type::NonNumber(), zone()); - Type* expected_number = - Type::Intersect(expected_type, Type::Number(), zone()); + AstType* expected_obj = + AstType::Intersect(expected_type, AstType::NonNumber(), zone()); + AstType* expected_number = + AstType::Intersect(expected_type, AstType::Number(), zone()); // We expect to get a number. - // (We need to check first, since Type::None->Is(Type::Any()) == true. - if (expected_obj->Is(Type::None())) { - DCHECK(!expected_number->Is(Type::None())); + // (We need to check first, since AstType::None->Is(AstType::Any()) == true. + if (expected_obj->Is(AstType::None())) { + DCHECK(!expected_number->Is(AstType::None())); return value; } - if (expected_obj->Is(Type::Undefined())) { + if (expected_obj->Is(AstType::Undefined())) { // This is already done by HChange. - *expected = Type::Union(expected_number, Type::Number(), zone()); + *expected = AstType::Union(expected_number, AstType::Number(), zone()); return value; } @@ -10999,9 +10856,9 @@ HValue* HOptimizedGraphBuilder::BuildBinaryOperation( HValue* left, HValue* right, PushBeforeSimulateBehavior push_sim_result) { - Type* left_type = bounds_.get(expr->left()).lower; - Type* right_type = bounds_.get(expr->right()).lower; - Type* result_type = bounds_.get(expr).lower; + AstType* left_type = bounds_.get(expr->left()).lower; + AstType* right_type = bounds_.get(expr->right()).lower; + AstType* result_type = bounds_.get(expr).lower; Maybe<int> fixed_right_arg = expr->fixed_right_arg(); Handle<AllocationSite> allocation_site = expr->allocation_site(); @@ -11027,12 +10884,10 @@ HValue* HOptimizedGraphBuilder::BuildBinaryOperation( return result; } -HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left, - HValue* right, Type* left_type, - Type* right_type, Type* result_type, - Maybe<int> fixed_right_arg, - HAllocationMode allocation_mode, - BailoutId opt_id) { +HValue* HGraphBuilder::BuildBinaryOperation( + Token::Value op, HValue* left, HValue* right, AstType* left_type, + AstType* right_type, AstType* result_type, Maybe<int> fixed_right_arg, + HAllocationMode allocation_mode, BailoutId opt_id) { bool maybe_string_add = false; if (op == Token::ADD) { // If we are adding constant string with something for which we don't have @@ -11040,18 +10895,18 @@ HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left, // generate deopt instructions. if (!left_type->IsInhabited() && right->IsConstant() && HConstant::cast(right)->HasStringValue()) { - left_type = Type::String(); + left_type = AstType::String(); } if (!right_type->IsInhabited() && left->IsConstant() && HConstant::cast(left)->HasStringValue()) { - right_type = Type::String(); + right_type = AstType::String(); } - maybe_string_add = (left_type->Maybe(Type::String()) || - left_type->Maybe(Type::Receiver()) || - right_type->Maybe(Type::String()) || - right_type->Maybe(Type::Receiver())); + maybe_string_add = (left_type->Maybe(AstType::String()) || + left_type->Maybe(AstType::Receiver()) || + right_type->Maybe(AstType::String()) || + right_type->Maybe(AstType::Receiver())); } Representation left_rep = RepresentationFor(left_type); @@ -11061,7 +10916,7 @@ HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left, Add<HDeoptimize>( DeoptimizeReason::kInsufficientTypeFeedbackForLHSOfBinaryOperation, Deoptimizer::SOFT); - left_type = Type::Any(); + left_type = AstType::Any(); left_rep = RepresentationFor(left_type); maybe_string_add = op == Token::ADD; } @@ -11070,7 +10925,7 @@ HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left, Add<HDeoptimize>( DeoptimizeReason::kInsufficientTypeFeedbackForRHSOfBinaryOperation, Deoptimizer::SOFT); - right_type = Type::Any(); + right_type = AstType::Any(); right_rep = RepresentationFor(right_type); maybe_string_add = op == Token::ADD; } @@ -11082,34 +10937,34 @@ HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left, // Special case for string addition here. if (op == Token::ADD && - (left_type->Is(Type::String()) || right_type->Is(Type::String()))) { + (left_type->Is(AstType::String()) || right_type->Is(AstType::String()))) { // Validate type feedback for left argument. - if (left_type->Is(Type::String())) { + if (left_type->Is(AstType::String())) { left = BuildCheckString(left); } // Validate type feedback for right argument. - if (right_type->Is(Type::String())) { + if (right_type->Is(AstType::String())) { right = BuildCheckString(right); } // Convert left argument as necessary. - if (left_type->Is(Type::Number())) { - DCHECK(right_type->Is(Type::String())); + if (left_type->Is(AstType::Number())) { + DCHECK(right_type->Is(AstType::String())); left = BuildNumberToString(left, left_type); - } else if (!left_type->Is(Type::String())) { - DCHECK(right_type->Is(Type::String())); + } else if (!left_type->Is(AstType::String())) { + DCHECK(right_type->Is(AstType::String())); return AddUncasted<HStringAdd>( left, right, allocation_mode.GetPretenureMode(), STRING_ADD_CONVERT_LEFT, allocation_mode.feedback_site()); } // Convert right argument as necessary. - if (right_type->Is(Type::Number())) { - DCHECK(left_type->Is(Type::String())); + if (right_type->Is(AstType::Number())) { + DCHECK(left_type->Is(AstType::String())); right = BuildNumberToString(right, right_type); - } else if (!right_type->Is(Type::String())) { - DCHECK(left_type->Is(Type::String())); + } else if (!right_type->Is(AstType::String())) { + DCHECK(left_type->Is(AstType::String())); return AddUncasted<HStringAdd>( left, right, allocation_mode.GetPretenureMode(), STRING_ADD_CONVERT_RIGHT, allocation_mode.feedback_site()); @@ -11267,8 +11122,8 @@ HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left, break; case Token::BIT_OR: { HValue *operand, *shift_amount; - if (left_type->Is(Type::Signed32()) && - right_type->Is(Type::Signed32()) && + if (left_type->Is(AstType::Signed32()) && + right_type->Is(AstType::Signed32()) && MatchRotateRight(left, right, &operand, &shift_amount)) { instr = AddUncasted<HRor>(operand, shift_amount); } else { @@ -11470,7 +11325,7 @@ void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) { BuildBinaryOperation(expr, left, right, ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE : PUSH_BEFORE_SIMULATE); - if (top_info()->is_tracking_positions() && result->IsBinaryOperation()) { + if (is_tracking_positions() && result->IsBinaryOperation()) { HBinaryOperation::cast(result)->SetOperandPositions( zone(), ScriptPositionToSourcePosition(expr->left()->position()), @@ -11512,7 +11367,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { DCHECK(current_block() != NULL); DCHECK(current_block()->HasPredecessor()); - if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position()); + if (!is_tracking_positions()) SetSourcePosition(expr->position()); // Check for a few fast cases. The AST visiting behavior must be in sync // with the full codegen: We don't push both left and right values onto @@ -11540,9 +11395,9 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { return ast_context()->ReturnControl(instr, expr->id()); } - Type* left_type = bounds_.get(expr->left()).lower; - Type* right_type = bounds_.get(expr->right()).lower; - Type* combined_type = expr->combined_type(); + AstType* left_type = bounds_.get(expr->left()).lower; + AstType* right_type = bounds_.get(expr->right()).lower; + AstType* combined_type = expr->combined_type(); CHECK_ALIVE(VisitForValue(expr->left())); CHECK_ALIVE(VisitForValue(expr->right())); @@ -11627,10 +11482,9 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { return ast_context()->ReturnControl(compare, expr->id()); } - HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( - Token::Value op, HValue* left, HValue* right, Type* left_type, - Type* right_type, Type* combined_type, SourcePosition left_position, + Token::Value op, HValue* left, HValue* right, AstType* left_type, + AstType* right_type, AstType* combined_type, SourcePosition left_position, SourcePosition right_position, PushBeforeSimulateBehavior push_sim_result, BailoutId bailout_id) { // Cases handled below depend on collected type feedback. They should @@ -11640,14 +11494,14 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( DeoptimizeReason:: kInsufficientTypeFeedbackForCombinedTypeOfBinaryOperation, Deoptimizer::SOFT); - combined_type = left_type = right_type = Type::Any(); + combined_type = left_type = right_type = AstType::Any(); } Representation left_rep = RepresentationFor(left_type); Representation right_rep = RepresentationFor(right_type); Representation combined_rep = RepresentationFor(combined_type); - if (combined_type->Is(Type::Receiver())) { + if (combined_type->Is(AstType::Receiver())) { if (Token::IsEqualityOp(op)) { // HCompareObjectEqAndBranch can only deal with object, so // exclude numbers. @@ -11669,7 +11523,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( AddCheckMap(operand_to_check, map); HCompareObjectEqAndBranch* result = New<HCompareObjectEqAndBranch>(left, right); - if (top_info()->is_tracking_positions()) { + if (is_tracking_positions()) { result->set_operand_position(zone(), 0, left_position); result->set_operand_position(zone(), 1, right_position); } @@ -11731,7 +11585,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( Bailout(kUnsupportedNonPrimitiveCompare); return NULL; } - } else if (combined_type->Is(Type::InternalizedString()) && + } else if (combined_type->Is(AstType::InternalizedString()) && Token::IsEqualityOp(op)) { // If we have a constant argument, it should be consistent with the type // feedback (otherwise we fail assertions in HCompareObjectEqAndBranch). @@ -11752,7 +11606,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( HCompareObjectEqAndBranch* result = New<HCompareObjectEqAndBranch>(left, right); return result; - } else if (combined_type->Is(Type::String())) { + } else if (combined_type->Is(AstType::String())) { BuildCheckHeapObject(left); Add<HCheckInstanceType>(left, HCheckInstanceType::IS_STRING); BuildCheckHeapObject(right); @@ -11760,7 +11614,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( HStringCompareAndBranch* result = New<HStringCompareAndBranch>(left, right, op); return result; - } else if (combined_type->Is(Type::Boolean())) { + } else if (combined_type->Is(AstType::Boolean())) { AddCheckMap(left, isolate()->factory()->boolean_map()); AddCheckMap(right, isolate()->factory()->boolean_map()); if (Token::IsEqualityOp(op)) { @@ -11812,7 +11666,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( HCompareNumericAndBranch* result = New<HCompareNumericAndBranch>(left, right, op); result->set_observed_input_representation(left_rep, right_rep); - if (top_info()->is_tracking_positions()) { + if (is_tracking_positions()) { result->SetOperandPositions(zone(), left_position, right_position); } return result; @@ -11828,7 +11682,7 @@ void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr, DCHECK(current_block() != NULL); DCHECK(current_block()->HasPredecessor()); DCHECK(expr->op() == Token::EQ || expr->op() == Token::EQ_STRICT); - if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position()); + if (!is_tracking_positions()) SetSourcePosition(expr->position()); CHECK_ALIVE(VisitForValue(sub_expr)); HValue* value = Pop(); HControlInstruction* instr; @@ -11899,7 +11753,7 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( Add<HAllocate>(object_size_constant, type, pretenure_flag, instance_type, graph()->GetConstant0(), top_site); - // If allocation folding reaches Page::kMaxRegularHeapObjectSize the + // If allocation folding reaches kMaxRegularHeapObjectSize the // elements array may not get folded into the object. Hence, we set the // elements pointer to empty fixed array and let store elimination remove // this store in the folding case. @@ -12196,7 +12050,6 @@ void HOptimizedGraphBuilder::VisitVariableDeclaration( VariableProxy* proxy = declaration->proxy(); Variable* variable = proxy->var(); switch (variable->location()) { - case VariableLocation::GLOBAL: case VariableLocation::UNALLOCATED: { DCHECK(!variable->binding_needs_init()); FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); @@ -12236,7 +12089,6 @@ void HOptimizedGraphBuilder::VisitFunctionDeclaration( VariableProxy* proxy = declaration->proxy(); Variable* variable = proxy->var(); switch (variable->location()) { - case VariableLocation::GLOBAL: case VariableLocation::UNALLOCATED: { FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); DCHECK(!slot.IsInvalid()); @@ -12475,27 +12327,18 @@ void HOptimizedGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) { } -// Fast support for string.charAt(n) and string[n]. -void HOptimizedGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) { - DCHECK(call->arguments()->length() == 1); - CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); - HValue* char_code = Pop(); - HInstruction* result = NewUncasted<HStringCharFromCode>(char_code); - return ast_context()->ReturnInstruction(result, call->id()); -} - - // Fast support for SubString. void HOptimizedGraphBuilder::GenerateSubString(CallRuntime* call) { DCHECK_EQ(3, call->arguments()->length()); CHECK_ALIVE(VisitExpressions(call->arguments())); - PushArgumentsFromEnvironment(call->arguments()->length()); Callable callable = CodeFactory::SubString(isolate()); HValue* stub = Add<HConstant>(callable.code()); - HValue* values[] = {context()}; - HInstruction* result = - New<HCallWithDescriptor>(stub, call->arguments()->length(), - callable.descriptor(), ArrayVector(values)); + HValue* to = Pop(); + HValue* from = Pop(); + HValue* string = Pop(); + HValue* values[] = {context(), string, from, to}; + HInstruction* result = New<HCallWithDescriptor>( + stub, 0, callable.descriptor(), ArrayVector(values)); result->set_type(HType::String()); return ast_context()->ReturnInstruction(result, call->id()); } @@ -12517,13 +12360,16 @@ void HOptimizedGraphBuilder::GenerateNewObject(CallRuntime* call) { void HOptimizedGraphBuilder::GenerateRegExpExec(CallRuntime* call) { DCHECK_EQ(4, call->arguments()->length()); CHECK_ALIVE(VisitExpressions(call->arguments())); - PushArgumentsFromEnvironment(call->arguments()->length()); Callable callable = CodeFactory::RegExpExec(isolate()); + HValue* last_match_info = Pop(); + HValue* index = Pop(); + HValue* subject = Pop(); + HValue* regexp_object = Pop(); HValue* stub = Add<HConstant>(callable.code()); - HValue* values[] = {context()}; - HInstruction* result = - New<HCallWithDescriptor>(stub, call->arguments()->length(), - callable.descriptor(), ArrayVector(values)); + HValue* values[] = {context(), regexp_object, subject, index, + last_match_info}; + HInstruction* result = New<HCallWithDescriptor>( + stub, 0, callable.descriptor(), ArrayVector(values)); return ast_context()->ReturnInstruction(result, call->id()); } @@ -12567,7 +12413,7 @@ void HOptimizedGraphBuilder::GenerateNumberToString(CallRuntime* call) { DCHECK_EQ(1, call->arguments()->length()); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* number = Pop(); - HValue* result = BuildNumberToString(number, Type::Any()); + HValue* result = BuildNumberToString(number, AstType::Any()); return ast_context()->ReturnValue(result); } @@ -13249,8 +13095,7 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { PrintIndent(); std::ostringstream os; os << "0 " << uses << " " << NameOf(instruction) << " " << *instruction; - if (graph->info()->is_tracking_positions() && - instruction->has_position() && instruction->position().raw() != 0) { + if (instruction->has_position() && instruction->position().raw() != 0) { const SourcePosition pos = instruction->position(); os << " pos:"; if (pos.inlining_id() != 0) os << pos.inlining_id() << "_"; diff --git a/deps/v8/src/crankshaft/hydrogen.h b/deps/v8/src/crankshaft/hydrogen.h index 931dd01dcb..d2f1637d11 100644 --- a/deps/v8/src/crankshaft/hydrogen.h +++ b/deps/v8/src/crankshaft/hydrogen.h @@ -8,13 +8,15 @@ #include "src/accessors.h" #include "src/allocation.h" #include "src/ast/ast-type-bounds.h" +#include "src/ast/scopes.h" #include "src/bailout-reason.h" +#include "src/compilation-info.h" #include "src/compiler.h" #include "src/crankshaft/compilation-phase.h" #include "src/crankshaft/hydrogen-instructions.h" #include "src/globals.h" #include "src/parsing/parse-info.h" -#include "src/zone.h" +#include "src/zone/zone.h" namespace v8 { namespace internal { @@ -30,12 +32,11 @@ class HTracer; class LAllocator; class LChunk; class LiveRange; -class Scope; class HCompilationJob final : public CompilationJob { public: explicit HCompilationJob(Handle<JSFunction> function) - : CompilationJob(&info_, "Crankshaft"), + : CompilationJob(function->GetIsolate(), &info_, "Crankshaft"), zone_(function->GetIsolate()->allocator()), parse_info_(&zone_, function), info_(&parse_info_, function), @@ -439,6 +440,13 @@ class HGraph final : public ZoneObject { return depends_on_empty_array_proto_elements_; } + void MarkDependsOnStringLengthOverflow() { + if (depends_on_string_length_overflow_) return; + info()->dependencies()->AssumePropertyCell( + isolate()->factory()->string_length_protector()); + depends_on_string_length_overflow_ = true; + } + bool has_uint32_instructions() { DCHECK(uint32_instructions_ == NULL || !uint32_instructions_->is_empty()); return uint32_instructions_ != NULL; @@ -514,6 +522,7 @@ class HGraph final : public ZoneObject { bool allow_code_motion_; bool use_optimistic_licm_; bool depends_on_empty_array_proto_elements_; + bool depends_on_string_length_overflow_; int type_change_checksum_; int maximum_environment_size_; int no_side_effects_scope_count_; @@ -1056,14 +1065,16 @@ class HAllocationMode final BASE_EMBEDDED { class HGraphBuilder { public: explicit HGraphBuilder(CompilationInfo* info, - CallInterfaceDescriptor descriptor) + CallInterfaceDescriptor descriptor, + bool track_positions) : info_(info), descriptor_(descriptor), graph_(NULL), current_block_(NULL), scope_(info->scope()), position_(SourcePosition::Unknown()), - start_position_(0) {} + start_position_(0), + track_positions_(track_positions) {} virtual ~HGraphBuilder() {} Scope* scope() const { return scope_; } @@ -1395,7 +1406,7 @@ class HGraphBuilder { ElementsKind to_kind, bool is_jsarray); - HValue* BuildNumberToString(HValue* object, Type* type); + HValue* BuildNumberToString(HValue* object, AstType* type); HValue* BuildToNumber(HValue* input); HValue* BuildToObject(HValue* receiver); @@ -1499,8 +1510,8 @@ class HGraphBuilder { HValue** shift_amount); HValue* BuildBinaryOperation(Token::Value op, HValue* left, HValue* right, - Type* left_type, Type* right_type, - Type* result_type, Maybe<int> fixed_right_arg, + AstType* left_type, AstType* right_type, + AstType* result_type, Maybe<int> fixed_right_arg, HAllocationMode allocation_mode, BailoutId opt_id = BailoutId::None()); @@ -1513,8 +1524,8 @@ class HGraphBuilder { HValue* AddLoadJSBuiltin(int context_index); - HValue* EnforceNumberType(HValue* number, Type* expected); - HValue* TruncateToNumber(HValue* value, Type** expected); + HValue* EnforceNumberType(HValue* number, AstType* expected); + HValue* TruncateToNumber(HValue* value, AstType** expected); void FinishExitWithHardDeoptimization(DeoptimizeReason reason); @@ -1833,20 +1844,6 @@ class HGraphBuilder { HValue* length, HValue* capacity); - HValue* BuildCloneShallowArrayCow(HValue* boilerplate, - HValue* allocation_site, - AllocationSiteMode mode, - ElementsKind kind); - - HValue* BuildCloneShallowArrayEmpty(HValue* boilerplate, - HValue* allocation_site, - AllocationSiteMode mode); - - HValue* BuildCloneShallowArrayNonEmpty(HValue* boilerplate, - HValue* allocation_site, - AllocationSiteMode mode, - ElementsKind kind); - HValue* BuildElementIndexHash(HValue* index); void BuildCreateAllocationMemento(HValue* previous_object, @@ -1859,7 +1856,7 @@ class HGraphBuilder { HInstruction* BuildGetNativeContext(HValue* closure); HInstruction* BuildGetNativeContext(); - HInstruction* BuildGetScriptContext(int context_index); + // Builds a loop version if |depth| is specified or unrolls the loop to // |depth_value| iterations otherwise. HValue* BuildGetParentContext(HValue* depth, int depth_value); @@ -1879,7 +1876,7 @@ class HGraphBuilder { } void EnterInlinedSource(int start_position, int id) { - if (top_info()->is_tracking_positions()) { + if (is_tracking_positions()) { start_position_ = start_position; position_.set_inlining_id(id); } @@ -1900,6 +1897,8 @@ class HGraphBuilder { SourcePosition source_position() { return position_; } void set_source_position(SourcePosition position) { position_ = position; } + bool is_tracking_positions() { return track_positions_; } + int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, SourcePosition position); @@ -1925,6 +1924,7 @@ class HGraphBuilder { Scope* scope_; SourcePosition position_; int start_position_; + bool track_positions_; }; template <> @@ -2122,7 +2122,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, BreakAndContinueScope* next_; }; - explicit HOptimizedGraphBuilder(CompilationInfo* info); + explicit HOptimizedGraphBuilder(CompilationInfo* info, bool track_positions); bool BuildGraph() override; @@ -2214,7 +2214,6 @@ class HOptimizedGraphBuilder : public HGraphBuilder, F(IsJSProxy) \ F(Call) \ F(NewObject) \ - F(StringCharFromCode) \ F(ToInteger) \ F(ToObject) \ F(ToString) \ @@ -2305,11 +2304,9 @@ class HOptimizedGraphBuilder : public HGraphBuilder, int index, HEnvironment* env) { if (!FLAG_analyze_environment_liveness) return false; - // |this| and |arguments| are always live; zapping parameters isn't - // safe because function.arguments can inspect them at any time. - return !var->is_this() && - !var->is_arguments() && - env->is_local_index(index); + // Zapping parameters isn't safe because function.arguments can inspect them + // at any time. + return env->is_local_index(index); } void BindIfLive(Variable* var, HValue* value) { HEnvironment* env = environment(); @@ -2706,8 +2703,8 @@ class HOptimizedGraphBuilder : public HGraphBuilder, }; HControlInstruction* BuildCompareInstruction( - Token::Value op, HValue* left, HValue* right, Type* left_type, - Type* right_type, Type* combined_type, SourcePosition left_position, + Token::Value op, HValue* left, HValue* right, AstType* left_type, + AstType* right_type, AstType* combined_type, SourcePosition left_position, SourcePosition right_position, PushBeforeSimulateBehavior push_sim_result, BailoutId bailout_id); diff --git a/deps/v8/src/crankshaft/ia32/lithium-codegen-ia32.cc b/deps/v8/src/crankshaft/ia32/lithium-codegen-ia32.cc index 2512e2be01..6c121dd271 100644 --- a/deps/v8/src/crankshaft/ia32/lithium-codegen-ia32.cc +++ b/deps/v8/src/crankshaft/ia32/lithium-codegen-ia32.cc @@ -164,7 +164,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Comment(";;; Prologue begin"); // Possibly allocate a local context. - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { Comment(";;; Allocate local context"); bool need_write_barrier = true; // Argument to NewContext is the function, which is still in edi. @@ -172,7 +172,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; if (info()->scope()->is_script_scope()) { __ push(edi); - __ Push(info()->scope()->GetScopeInfo(info()->isolate())); + __ Push(info()->scope()->scope_info()); __ CallRuntime(Runtime::kNewScriptContext); deopt_mode = Safepoint::kLazyDeopt; } else { @@ -2397,20 +2397,6 @@ void LCodeGen::EmitVectorLoadICRegisters(T* instr) { } -template <class T> -void LCodeGen::EmitVectorStoreICRegisters(T* instr) { - Register vector_register = ToRegister(instr->temp_vector()); - Register slot_register = ToRegister(instr->temp_slot()); - - AllowDeferredHandleDereference vector_structure_check; - Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); - __ mov(vector_register, vector); - FeedbackVectorSlot slot = instr->hydrogen()->slot(); - int index = vector->GetIndex(slot); - __ mov(slot_register, Immediate(Smi::FromInt(index))); -} - - void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { DCHECK(ToRegister(instr->context()).is(esi)); DCHECK(ToRegister(instr->result()).is(eax)); @@ -3703,21 +3689,6 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } -void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(esi)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreNamedGeneric>(instr); - - __ mov(StoreDescriptor::NameRegister(), instr->name()); - Handle<Code> ic = - CodeFactory::StoreICInOptimizedCode(isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { Condition cc = instr->hydrogen()->allow_equality() ? above : above_equal; if (instr->index()->IsConstantOperand()) { @@ -3877,21 +3848,6 @@ void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { } -void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(esi)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreKeyedGeneric>(instr); - - Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( - isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { Register object = ToRegister(instr->object()); Register temp = ToRegister(instr->temp()); @@ -4831,7 +4787,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) { if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ Allocate(size, result, temp, no_reg, deferred->entry(), flags); } else { Register size = ToRegister(instr->size()); @@ -4874,7 +4830,7 @@ void LCodeGen::DoFastAllocate(LFastAllocate* instr) { } if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ FastAllocate(size, result, temp, flags); } else { Register size = ToRegister(instr->size()); diff --git a/deps/v8/src/crankshaft/ia32/lithium-codegen-ia32.h b/deps/v8/src/crankshaft/ia32/lithium-codegen-ia32.h index 38a493dbb4..8e16d9c5fc 100644 --- a/deps/v8/src/crankshaft/ia32/lithium-codegen-ia32.h +++ b/deps/v8/src/crankshaft/ia32/lithium-codegen-ia32.h @@ -294,8 +294,6 @@ class LCodeGen: public LCodeGenBase { template <class T> void EmitVectorLoadICRegisters(T* instr); - template <class T> - void EmitVectorStoreICRegisters(T* instr); void EmitReturn(LReturn* instr); diff --git a/deps/v8/src/crankshaft/ia32/lithium-ia32.cc b/deps/v8/src/crankshaft/ia32/lithium-ia32.cc index 67942241e6..e6077cc4ad 100644 --- a/deps/v8/src/crankshaft/ia32/lithium-ia32.cc +++ b/deps/v8/src/crankshaft/ia32/lithium-ia32.cc @@ -351,15 +351,6 @@ void LStoreNamedField::PrintDataTo(StringStream* stream) { } -void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("."); - stream->Add(String::cast(*name())->ToCString().get()); - stream->Add(" <- "); - value()->PrintTo(stream); -} - - void LLoadKeyed::PrintDataTo(StringStream* stream) { elements()->PrintTo(stream); stream->Add("["); @@ -392,15 +383,6 @@ void LStoreKeyed::PrintDataTo(StringStream* stream) { } -void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("["); - key()->PrintTo(stream); - stream->Add("] <- "); - value()->PrintTo(stream); -} - - void LTransitionElementsKind::PrintDataTo(StringStream* stream) { object()->PrintTo(stream); stream->Add(" %p -> %p", *original_map(), *transitioned_map()); @@ -910,7 +892,7 @@ void LChunkBuilder::AddInstruction(LInstruction* instr, LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { LInstruction* result = new (zone()) LPrologue(); - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { result = MarkAsCall(result, instr); } return result; @@ -1054,6 +1036,10 @@ LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { CallInterfaceDescriptor descriptor = instr->descriptor(); + DCHECK_EQ(descriptor.GetParameterCount() + + LCallWithDescriptor::kImplicitRegisterParameterCount, + instr->OperandCount()); + LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList<LOperand*> ops(instr->OperandCount(), zone()); // Target @@ -1061,15 +1047,20 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor( // Context LOperand* op = UseFixed(instr->OperandAt(1), esi); ops.Add(op, zone()); - // Other register parameters - for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; - i < instr->OperandCount(); i++) { - op = - UseFixed(instr->OperandAt(i), - descriptor.GetRegisterParameter( - i - LCallWithDescriptor::kImplicitRegisterParameterCount)); + // Load register parameters. + int i = 0; + for (; i < descriptor.GetRegisterParameterCount(); i++) { + op = UseFixed(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount), + descriptor.GetRegisterParameter(i)); ops.Add(op, zone()); } + // Push stack parameters. + for (; i < descriptor.GetParameterCount(); i++) { + op = UseAny(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount)); + AddInstruction(new (zone()) LPushArgument(op), instr); + } LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( descriptor, ops, zone()); @@ -2211,26 +2202,6 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { } -LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), esi); - 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()); - DCHECK(instr->value()->representation().IsTagged()); - - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreKeyedGeneric* result = new (zone()) - LStoreKeyedGeneric(context, object, key, value, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoTransitionElementsKind( HTransitionElementsKind* instr) { if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { @@ -2332,20 +2303,6 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { } -LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), esi); - LOperand* object = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreNamedGeneric* result = - new (zone()) LStoreNamedGeneric(context, object, value, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { LOperand* context = UseFixed(instr->context(), esi); LOperand* left = UseFixed(instr->left(), edx); diff --git a/deps/v8/src/crankshaft/ia32/lithium-ia32.h b/deps/v8/src/crankshaft/ia32/lithium-ia32.h index e525341ca0..816d8fd2c1 100644 --- a/deps/v8/src/crankshaft/ia32/lithium-ia32.h +++ b/deps/v8/src/crankshaft/ia32/lithium-ia32.h @@ -136,9 +136,7 @@ class LCodeGen; V(StoreCodeEntry) \ V(StoreContextSlot) \ V(StoreKeyed) \ - V(StoreKeyedGeneric) \ V(StoreNamedField) \ - V(StoreNamedGeneric) \ V(StringAdd) \ V(StringCharCodeAt) \ V(StringCharFromCode) \ @@ -2022,32 +2020,6 @@ class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> { }; -class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> { - public: - LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value, - LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* value() { return inputs_[2]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric) - - void PrintDataTo(StringStream* stream) override; - Handle<Object> name() const { return hydrogen()->name(); } - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { public: LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val, @@ -2078,34 +2050,6 @@ class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { }; -class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> { - public: - LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key, - LOperand* value, LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = key; - inputs_[3] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* key() { return inputs_[2]; } - LOperand* value() { return inputs_[3]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric) - - void PrintDataTo(StringStream* stream) override; - - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> { public: LTransitionElementsKind(LOperand* object, diff --git a/deps/v8/src/crankshaft/lithium-allocator.h b/deps/v8/src/crankshaft/lithium-allocator.h index ce0e56560b..d28ad7f9e7 100644 --- a/deps/v8/src/crankshaft/lithium-allocator.h +++ b/deps/v8/src/crankshaft/lithium-allocator.h @@ -9,7 +9,7 @@ #include "src/base/compiler-specific.h" #include "src/crankshaft/compilation-phase.h" #include "src/crankshaft/lithium.h" -#include "src/zone.h" +#include "src/zone/zone.h" namespace v8 { namespace internal { diff --git a/deps/v8/src/crankshaft/lithium-codegen.cc b/deps/v8/src/crankshaft/lithium-codegen.cc index 5041de6451..decc2a596f 100644 --- a/deps/v8/src/crankshaft/lithium-codegen.cc +++ b/deps/v8/src/crankshaft/lithium-codegen.cc @@ -66,6 +66,8 @@ LCodeGenBase::LCodeGenBase(LChunk* chunk, MacroAssembler* assembler, source_position_table_builder_(info->zone(), info->SourcePositionRecordingMode()) {} +Isolate* LCodeGenBase::isolate() const { return info_->isolate(); } + bool LCodeGenBase::GenerateBody() { DCHECK(is_generating()); bool emit_instructions = true; diff --git a/deps/v8/src/crankshaft/lithium-codegen.h b/deps/v8/src/crankshaft/lithium-codegen.h index fbf96924ee..c6bf447543 100644 --- a/deps/v8/src/crankshaft/lithium-codegen.h +++ b/deps/v8/src/crankshaft/lithium-codegen.h @@ -6,13 +6,13 @@ #define V8_CRANKSHAFT_LITHIUM_CODEGEN_H_ #include "src/bailout-reason.h" -#include "src/compiler.h" #include "src/deoptimizer.h" #include "src/source-position-table.h" namespace v8 { namespace internal { +class CompilationInfo; class HGraph; class LChunk; class LEnvironment; @@ -29,7 +29,7 @@ class LCodeGenBase BASE_EMBEDDED { // Simple accessors. MacroAssembler* masm() const { return masm_; } CompilationInfo* info() const { return info_; } - Isolate* isolate() const { return info_->isolate(); } + Isolate* isolate() const; Factory* factory() const { return isolate()->factory(); } Heap* heap() const { return isolate()->heap(); } Zone* zone() const { return zone_; } diff --git a/deps/v8/src/crankshaft/lithium.h b/deps/v8/src/crankshaft/lithium.h index a2c028330b..d04bd5674a 100644 --- a/deps/v8/src/crankshaft/lithium.h +++ b/deps/v8/src/crankshaft/lithium.h @@ -12,7 +12,7 @@ #include "src/crankshaft/compilation-phase.h" #include "src/crankshaft/hydrogen.h" #include "src/safepoint-table.h" -#include "src/zone-allocator.h" +#include "src/zone/zone-allocator.h" namespace v8 { namespace internal { diff --git a/deps/v8/src/crankshaft/mips/lithium-codegen-mips.cc b/deps/v8/src/crankshaft/mips/lithium-codegen-mips.cc index 6be0d13f13..b24b1c5f08 100644 --- a/deps/v8/src/crankshaft/mips/lithium-codegen-mips.cc +++ b/deps/v8/src/crankshaft/mips/lithium-codegen-mips.cc @@ -171,7 +171,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Comment(";;; Prologue begin"); // Possibly allocate a local context. - if (info()->scope()->num_heap_slots() > 0) { + if (info()->scope()->NeedsContext()) { Comment(";;; Allocate local context"); bool need_write_barrier = true; // Argument to NewContext is the function, which is in a1. @@ -179,7 +179,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; if (info()->scope()->is_script_scope()) { __ push(a1); - __ Push(info()->scope()->GetScopeInfo(info()->isolate())); + __ Push(info()->scope()->scope_info()); __ CallRuntime(Runtime::kNewScriptContext); deopt_mode = Safepoint::kLazyDeopt; } else { @@ -2499,20 +2499,6 @@ void LCodeGen::EmitVectorLoadICRegisters(T* instr) { } -template <class T> -void LCodeGen::EmitVectorStoreICRegisters(T* instr) { - Register vector_register = ToRegister(instr->temp_vector()); - Register slot_register = ToRegister(instr->temp_slot()); - - AllowDeferredHandleDereference vector_structure_check; - Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); - __ li(vector_register, vector); - FeedbackVectorSlot slot = instr->hydrogen()->slot(); - int index = vector->GetIndex(slot); - __ li(slot_register, Operand(Smi::FromInt(index))); -} - - void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { DCHECK(ToRegister(instr->context()).is(cp)); DCHECK(ToRegister(instr->result()).is(v0)); @@ -3448,7 +3434,9 @@ void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) { // Math.sqrt(-Infinity) == NaN Label done; __ Move(temp, static_cast<double>(-V8_INFINITY)); + // Set up Infinity. __ Neg_d(result, temp); + // result is overwritten if the branch is not taken. __ BranchF(&done, NULL, eq, temp, input); // Add +0 to convert -0 to +0. @@ -3800,21 +3788,6 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } -void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreNamedGeneric>(instr); - - __ li(StoreDescriptor::NameRegister(), Operand(instr->name())); - Handle<Code> ic = - CodeFactory::StoreICInOptimizedCode(isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { Condition cc = instr->hydrogen()->allow_equality() ? hi : hs; Operand operand(0); @@ -4025,21 +3998,6 @@ void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { } -void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreKeyedGeneric>(instr); - - Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( - isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) { class DeferredMaybeGrowElements final : public LDeferredCode { public: @@ -5042,7 +5000,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) { if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ Allocate(size, result, scratch, scratch2, deferred->entry(), flags); } else { Register size = ToRegister(instr->size()); @@ -5145,7 +5103,7 @@ void LCodeGen::DoFastAllocate(LFastAllocate* instr) { } if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ FastAllocate(size, result, scratch1, scratch2, flags); } else { Register size = ToRegister(instr->size()); diff --git a/deps/v8/src/crankshaft/mips/lithium-codegen-mips.h b/deps/v8/src/crankshaft/mips/lithium-codegen-mips.h index d51f62c90f..bb09abc1df 100644 --- a/deps/v8/src/crankshaft/mips/lithium-codegen-mips.h +++ b/deps/v8/src/crankshaft/mips/lithium-codegen-mips.h @@ -340,8 +340,6 @@ class LCodeGen: public LCodeGenBase { template <class T> void EmitVectorLoadICRegisters(T* instr); - template <class T> - void EmitVectorStoreICRegisters(T* instr); ZoneList<Deoptimizer::JumpTableEntry> jump_table_; Scope* const scope_; diff --git a/deps/v8/src/crankshaft/mips/lithium-mips.cc b/deps/v8/src/crankshaft/mips/lithium-mips.cc index a7880eee87..5533b8f59d 100644 --- a/deps/v8/src/crankshaft/mips/lithium-mips.cc +++ b/deps/v8/src/crankshaft/mips/lithium-mips.cc @@ -311,15 +311,6 @@ void LStoreNamedField::PrintDataTo(StringStream* stream) { } -void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("."); - stream->Add(String::cast(*name())->ToCString().get()); - stream->Add(" <- "); - value()->PrintTo(stream); -} - - void LLoadKeyed::PrintDataTo(StringStream* stream) { elements()->PrintTo(stream); stream->Add("["); @@ -352,15 +343,6 @@ void LStoreKeyed::PrintDataTo(StringStream* stream) { } -void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("["); - key()->PrintTo(stream); - stream->Add("] <- "); - value()->PrintTo(stream); -} - - void LTransitionElementsKind::PrintDataTo(StringStream* stream) { object()->PrintTo(stream); stream->Add(" %p -> %p", *original_map(), *transitioned_map()); @@ -887,7 +869,7 @@ void LChunkBuilder::AddInstruction(LInstruction* instr, LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { LInstruction* result = new (zone()) LPrologue(); - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { result = MarkAsCall(result, instr); } return result; @@ -1024,6 +1006,9 @@ LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { CallInterfaceDescriptor descriptor = instr->descriptor(); + DCHECK_EQ(descriptor.GetParameterCount() + + LCallWithDescriptor::kImplicitRegisterParameterCount, + instr->OperandCount()); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList<LOperand*> ops(instr->OperandCount(), zone()); @@ -1032,15 +1017,20 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor( // Context LOperand* op = UseFixed(instr->OperandAt(1), cp); ops.Add(op, zone()); - // Other register parameters - for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; - i < instr->OperandCount(); i++) { - op = - UseFixed(instr->OperandAt(i), - descriptor.GetRegisterParameter( - i - LCallWithDescriptor::kImplicitRegisterParameterCount)); + // Load register parameters. + int i = 0; + for (; i < descriptor.GetRegisterParameterCount(); i++) { + op = UseFixed(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount), + descriptor.GetRegisterParameter(i)); ops.Add(op, zone()); } + // Push stack parameters. + for (; i < descriptor.GetParameterCount(); i++) { + op = UseAny(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount)); + AddInstruction(new (zone()) LPushArgument(op), instr); + } LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( descriptor, ops, zone()); @@ -2127,26 +2117,6 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { } -LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - LOperand* obj = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister()); - LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - - DCHECK(instr->object()->representation().IsTagged()); - DCHECK(instr->key()->representation().IsTagged()); - DCHECK(instr->value()->representation().IsTagged()); - - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreKeyedGeneric* result = - new (zone()) LStoreKeyedGeneric(context, obj, key, val, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoTransitionElementsKind( HTransitionElementsKind* instr) { if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { @@ -2223,20 +2193,6 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { } -LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - LOperand* obj = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreNamedGeneric* result = - new (zone()) LStoreNamedGeneric(context, obj, val, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { LOperand* context = UseFixed(instr->context(), cp); LOperand* left = UseFixed(instr->left(), a1); diff --git a/deps/v8/src/crankshaft/mips/lithium-mips.h b/deps/v8/src/crankshaft/mips/lithium-mips.h index 9711c9a6db..f49fb93c59 100644 --- a/deps/v8/src/crankshaft/mips/lithium-mips.h +++ b/deps/v8/src/crankshaft/mips/lithium-mips.h @@ -131,9 +131,7 @@ class LCodeGen; V(StoreCodeEntry) \ V(StoreContextSlot) \ V(StoreKeyed) \ - V(StoreKeyedGeneric) \ V(StoreNamedField) \ - V(StoreNamedGeneric) \ V(StringAdd) \ V(StringCharCodeAt) \ V(StringCharFromCode) \ @@ -1969,33 +1967,6 @@ class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> { }; -class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> { - public: - LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value, - LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* value() { return inputs_[2]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric) - - void PrintDataTo(StringStream* stream) override; - - Handle<Object> name() const { return hydrogen()->name(); } - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { public: LStoreKeyed(LOperand* object, LOperand* key, LOperand* value, @@ -2026,34 +1997,6 @@ class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { }; -class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> { - public: - LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key, - LOperand* value, LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = key; - inputs_[3] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* key() { return inputs_[2]; } - LOperand* value() { return inputs_[3]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric) - - void PrintDataTo(StringStream* stream) override; - - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> { public: LTransitionElementsKind(LOperand* object, diff --git a/deps/v8/src/crankshaft/mips64/lithium-codegen-mips64.cc b/deps/v8/src/crankshaft/mips64/lithium-codegen-mips64.cc index 924f552ab0..5f93e55fde 100644 --- a/deps/v8/src/crankshaft/mips64/lithium-codegen-mips64.cc +++ b/deps/v8/src/crankshaft/mips64/lithium-codegen-mips64.cc @@ -147,7 +147,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Comment(";;; Prologue begin"); // Possibly allocate a local context. - if (info()->scope()->num_heap_slots() > 0) { + if (info()->scope()->NeedsContext()) { Comment(";;; Allocate local context"); bool need_write_barrier = true; // Argument to NewContext is the function, which is in a1. @@ -155,7 +155,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; if (info()->scope()->is_script_scope()) { __ push(a1); - __ Push(info()->scope()->GetScopeInfo(info()->isolate())); + __ Push(info()->scope()->scope_info()); __ CallRuntime(Runtime::kNewScriptContext); deopt_mode = Safepoint::kLazyDeopt; } else { @@ -2623,20 +2623,6 @@ void LCodeGen::EmitVectorLoadICRegisters(T* instr) { } -template <class T> -void LCodeGen::EmitVectorStoreICRegisters(T* instr) { - Register vector_register = ToRegister(instr->temp_vector()); - Register slot_register = ToRegister(instr->temp_slot()); - - AllowDeferredHandleDereference vector_structure_check; - Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); - __ li(vector_register, vector); - FeedbackVectorSlot slot = instr->hydrogen()->slot(); - int index = vector->GetIndex(slot); - __ li(slot_register, Operand(Smi::FromInt(index))); -} - - void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { DCHECK(ToRegister(instr->context()).is(cp)); DCHECK(ToRegister(instr->result()).is(v0)); @@ -3655,7 +3641,9 @@ void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) { // Math.sqrt(-Infinity) == NaN Label done; __ Move(temp, static_cast<double>(-V8_INFINITY)); + // Set up Infinity. __ Neg_d(result, temp); + // result is overwritten if the branch is not taken. __ BranchF(&done, NULL, eq, temp, input); // Add +0 to convert -0 to +0. @@ -4013,21 +4001,6 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } -void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreNamedGeneric>(instr); - - __ li(StoreDescriptor::NameRegister(), Operand(instr->name())); - Handle<Code> ic = - CodeFactory::StoreICInOptimizedCode(isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { Condition cc = instr->hydrogen()->allow_equality() ? hi : hs; Operand operand((int64_t)0); @@ -4260,21 +4233,6 @@ void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { } -void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreKeyedGeneric>(instr); - - Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( - isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) { class DeferredMaybeGrowElements final : public LDeferredCode { public: @@ -5248,7 +5206,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) { if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ Allocate(size, result, scratch, scratch2, deferred->entry(), flags); } else { Register size = ToRegister(instr->size()); @@ -5353,7 +5311,7 @@ void LCodeGen::DoFastAllocate(LFastAllocate* instr) { } if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ FastAllocate(size, result, scratch1, scratch2, flags); } else { Register size = ToRegister(instr->size()); diff --git a/deps/v8/src/crankshaft/mips64/lithium-codegen-mips64.h b/deps/v8/src/crankshaft/mips64/lithium-codegen-mips64.h index 41d8b2c031..aaa2e6be17 100644 --- a/deps/v8/src/crankshaft/mips64/lithium-codegen-mips64.h +++ b/deps/v8/src/crankshaft/mips64/lithium-codegen-mips64.h @@ -343,8 +343,6 @@ class LCodeGen: public LCodeGenBase { template <class T> void EmitVectorLoadICRegisters(T* instr); - template <class T> - void EmitVectorStoreICRegisters(T* instr); ZoneList<Deoptimizer::JumpTableEntry*> jump_table_; Scope* const scope_; diff --git a/deps/v8/src/crankshaft/mips64/lithium-mips64.cc b/deps/v8/src/crankshaft/mips64/lithium-mips64.cc index 922f12ada8..0855754d31 100644 --- a/deps/v8/src/crankshaft/mips64/lithium-mips64.cc +++ b/deps/v8/src/crankshaft/mips64/lithium-mips64.cc @@ -311,15 +311,6 @@ void LStoreNamedField::PrintDataTo(StringStream* stream) { } -void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("."); - stream->Add(String::cast(*name())->ToCString().get()); - stream->Add(" <- "); - value()->PrintTo(stream); -} - - void LLoadKeyed::PrintDataTo(StringStream* stream) { elements()->PrintTo(stream); stream->Add("["); @@ -352,15 +343,6 @@ void LStoreKeyed::PrintDataTo(StringStream* stream) { } -void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("["); - key()->PrintTo(stream); - stream->Add("] <- "); - value()->PrintTo(stream); -} - - void LTransitionElementsKind::PrintDataTo(StringStream* stream) { object()->PrintTo(stream); stream->Add(" %p -> %p", *original_map(), *transitioned_map()); @@ -887,7 +869,7 @@ void LChunkBuilder::AddInstruction(LInstruction* instr, LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { LInstruction* result = new (zone()) LPrologue(); - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { result = MarkAsCall(result, instr); } return result; @@ -1024,6 +1006,9 @@ LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { CallInterfaceDescriptor descriptor = instr->descriptor(); + DCHECK_EQ(descriptor.GetParameterCount() + + LCallWithDescriptor::kImplicitRegisterParameterCount, + instr->OperandCount()); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList<LOperand*> ops(instr->OperandCount(), zone()); @@ -1032,15 +1017,20 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor( // Context LOperand* op = UseFixed(instr->OperandAt(1), cp); ops.Add(op, zone()); - // Other register parameters - for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; - i < instr->OperandCount(); i++) { - op = - UseFixed(instr->OperandAt(i), - descriptor.GetRegisterParameter( - i - LCallWithDescriptor::kImplicitRegisterParameterCount)); + // Load register parameters. + int i = 0; + for (; i < descriptor.GetRegisterParameterCount(); i++) { + op = UseFixed(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount), + descriptor.GetRegisterParameter(i)); ops.Add(op, zone()); } + // Push stack parameters. + for (; i < descriptor.GetParameterCount(); i++) { + op = UseAny(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount)); + AddInstruction(new (zone()) LPushArgument(op), instr); + } LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( descriptor, ops, zone()); @@ -2132,26 +2122,6 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { } -LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - LOperand* obj = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister()); - LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - - DCHECK(instr->object()->representation().IsTagged()); - DCHECK(instr->key()->representation().IsTagged()); - DCHECK(instr->value()->representation().IsTagged()); - - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreKeyedGeneric* result = - new (zone()) LStoreKeyedGeneric(context, obj, key, val, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoTransitionElementsKind( HTransitionElementsKind* instr) { if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { @@ -2228,20 +2198,6 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { } -LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - LOperand* obj = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreNamedGeneric* result = - new (zone()) LStoreNamedGeneric(context, obj, val, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { LOperand* context = UseFixed(instr->context(), cp); LOperand* left = UseFixed(instr->left(), a1); diff --git a/deps/v8/src/crankshaft/mips64/lithium-mips64.h b/deps/v8/src/crankshaft/mips64/lithium-mips64.h index f8b5c48885..7bc89afd46 100644 --- a/deps/v8/src/crankshaft/mips64/lithium-mips64.h +++ b/deps/v8/src/crankshaft/mips64/lithium-mips64.h @@ -133,9 +133,7 @@ class LCodeGen; V(StoreCodeEntry) \ V(StoreContextSlot) \ V(StoreKeyed) \ - V(StoreKeyedGeneric) \ V(StoreNamedField) \ - V(StoreNamedGeneric) \ V(StringAdd) \ V(StringCharCodeAt) \ V(StringCharFromCode) \ @@ -2015,33 +2013,6 @@ class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> { }; -class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> { - public: - LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value, - LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* value() { return inputs_[2]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric) - - void PrintDataTo(StringStream* stream) override; - - Handle<Object> name() const { return hydrogen()->name(); } - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { public: LStoreKeyed(LOperand* object, LOperand* key, LOperand* value, @@ -2072,34 +2043,6 @@ class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { }; -class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> { - public: - LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key, - LOperand* value, LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = key; - inputs_[3] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* key() { return inputs_[2]; } - LOperand* value() { return inputs_[3]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric) - - void PrintDataTo(StringStream* stream) override; - - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> { public: LTransitionElementsKind(LOperand* object, diff --git a/deps/v8/src/crankshaft/ppc/lithium-codegen-ppc.cc b/deps/v8/src/crankshaft/ppc/lithium-codegen-ppc.cc index e1203b86a4..321c39355f 100644 --- a/deps/v8/src/crankshaft/ppc/lithium-codegen-ppc.cc +++ b/deps/v8/src/crankshaft/ppc/lithium-codegen-ppc.cc @@ -158,7 +158,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Comment(";;; Prologue begin"); // Possibly allocate a local context. - if (info()->scope()->num_heap_slots() > 0) { + if (info()->scope()->NeedsContext()) { Comment(";;; Allocate local context"); bool need_write_barrier = true; // Argument to NewContext is the function, which is in r4. @@ -166,7 +166,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; if (info()->scope()->is_script_scope()) { __ push(r4); - __ Push(info()->scope()->GetScopeInfo(info()->isolate())); + __ Push(info()->scope()->scope_info()); __ CallRuntime(Runtime::kNewScriptContext); deopt_mode = Safepoint::kLazyDeopt; } else { @@ -2677,20 +2677,6 @@ void LCodeGen::EmitVectorLoadICRegisters(T* instr) { } -template <class T> -void LCodeGen::EmitVectorStoreICRegisters(T* instr) { - Register vector_register = ToRegister(instr->temp_vector()); - Register slot_register = ToRegister(instr->temp_slot()); - - AllowDeferredHandleDereference vector_structure_check; - Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); - __ Move(vector_register, vector); - FeedbackVectorSlot slot = instr->hydrogen()->slot(); - int index = vector->GetIndex(slot); - __ LoadSmiLiteral(slot_register, Smi::FromInt(index)); -} - - void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { DCHECK(ToRegister(instr->context()).is(cp)); DCHECK(ToRegister(instr->result()).is(r3)); @@ -4085,21 +4071,6 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } -void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreNamedGeneric>(instr); - - __ mov(StoreDescriptor::NameRegister(), Operand(instr->name())); - Handle<Code> ic = - CodeFactory::StoreICInOptimizedCode(isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { Representation representation = instr->hydrogen()->length()->representation(); DCHECK(representation.Equals(instr->hydrogen()->index()->representation())); @@ -4110,7 +4081,7 @@ void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { int32_t length = ToInteger32(LConstantOperand::cast(instr->length())); Register index = ToRegister(instr->index()); if (representation.IsSmi()) { - __ Cmpli(index, Operand(Smi::FromInt(length)), r0); + __ CmplSmiLiteral(index, Smi::FromInt(length), r0); } else { __ Cmplwi(index, Operand(length), r0); } @@ -4119,7 +4090,7 @@ void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { int32_t index = ToInteger32(LConstantOperand::cast(instr->index())); Register length = ToRegister(instr->length()); if (representation.IsSmi()) { - __ Cmpli(length, Operand(Smi::FromInt(index)), r0); + __ CmplSmiLiteral(length, Smi::FromInt(index), r0); } else { __ Cmplwi(length, Operand(index), r0); } @@ -4344,21 +4315,6 @@ void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { } -void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreKeyedGeneric>(instr); - - Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( - isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) { class DeferredMaybeGrowElements final : public LDeferredCode { public: @@ -5324,7 +5280,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) { if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ Allocate(size, result, scratch, scratch2, deferred->entry(), flags); } else { Register size = ToRegister(instr->size()); @@ -5430,7 +5386,7 @@ void LCodeGen::DoFastAllocate(LFastAllocate* instr) { } if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ FastAllocate(size, result, scratch1, scratch2, flags); } else { Register size = ToRegister(instr->size()); diff --git a/deps/v8/src/crankshaft/ppc/lithium-codegen-ppc.h b/deps/v8/src/crankshaft/ppc/lithium-codegen-ppc.h index fe212d4034..a4a90a7184 100644 --- a/deps/v8/src/crankshaft/ppc/lithium-codegen-ppc.h +++ b/deps/v8/src/crankshaft/ppc/lithium-codegen-ppc.h @@ -277,8 +277,6 @@ class LCodeGen : public LCodeGenBase { template <class T> void EmitVectorLoadICRegisters(T* instr); - template <class T> - void EmitVectorStoreICRegisters(T* instr); ZoneList<Deoptimizer::JumpTableEntry> jump_table_; Scope* const scope_; diff --git a/deps/v8/src/crankshaft/ppc/lithium-ppc.cc b/deps/v8/src/crankshaft/ppc/lithium-ppc.cc index 958620c38a..738cf231ce 100644 --- a/deps/v8/src/crankshaft/ppc/lithium-ppc.cc +++ b/deps/v8/src/crankshaft/ppc/lithium-ppc.cc @@ -317,15 +317,6 @@ void LStoreNamedField::PrintDataTo(StringStream* stream) { } -void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("."); - stream->Add(String::cast(*name())->ToCString().get()); - stream->Add(" <- "); - value()->PrintTo(stream); -} - - void LLoadKeyed::PrintDataTo(StringStream* stream) { elements()->PrintTo(stream); stream->Add("["); @@ -358,15 +349,6 @@ void LStoreKeyed::PrintDataTo(StringStream* stream) { } -void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("["); - key()->PrintTo(stream); - stream->Add("] <- "); - value()->PrintTo(stream); -} - - void LTransitionElementsKind::PrintDataTo(StringStream* stream) { object()->PrintTo(stream); stream->Add(" %p -> %p", *original_map(), *transitioned_map()); @@ -892,7 +874,7 @@ void LChunkBuilder::AddInstruction(LInstruction* instr, LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { LInstruction* result = new (zone()) LPrologue(); - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { result = MarkAsCall(result, instr); } return result; @@ -1030,6 +1012,9 @@ LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { LInstruction* LChunkBuilder::DoCallWithDescriptor(HCallWithDescriptor* instr) { CallInterfaceDescriptor descriptor = instr->descriptor(); + DCHECK_EQ(descriptor.GetParameterCount() + + LCallWithDescriptor::kImplicitRegisterParameterCount, + instr->OperandCount()); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList<LOperand*> ops(instr->OperandCount(), zone()); @@ -1038,15 +1023,20 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor(HCallWithDescriptor* instr) { // Context LOperand* op = UseFixed(instr->OperandAt(1), cp); ops.Add(op, zone()); - // Other register parameters - for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; - i < instr->OperandCount(); i++) { - op = - UseFixed(instr->OperandAt(i), - descriptor.GetRegisterParameter( - i - LCallWithDescriptor::kImplicitRegisterParameterCount)); + // Load register parameters. + int i = 0; + for (; i < descriptor.GetRegisterParameterCount(); i++) { + op = UseFixed(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount), + descriptor.GetRegisterParameter(i)); ops.Add(op, zone()); } + // Push stack parameters. + for (; i < descriptor.GetParameterCount(); i++) { + op = UseAny(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount)); + AddInstruction(new (zone()) LPushArgument(op), instr); + } LCallWithDescriptor* result = new (zone()) LCallWithDescriptor(descriptor, ops, zone()); @@ -2150,26 +2140,6 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { } -LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - LOperand* obj = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister()); - LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - - DCHECK(instr->object()->representation().IsTagged()); - DCHECK(instr->key()->representation().IsTagged()); - DCHECK(instr->value()->representation().IsTagged()); - - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreKeyedGeneric* result = - new (zone()) LStoreKeyedGeneric(context, obj, key, val, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoTransitionElementsKind( HTransitionElementsKind* instr) { if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { @@ -2245,19 +2215,6 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { } -LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - LOperand* obj = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - LStoreNamedGeneric* result = - new (zone()) LStoreNamedGeneric(context, obj, val, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { LOperand* context = UseFixed(instr->context(), cp); LOperand* left = UseFixed(instr->left(), r4); diff --git a/deps/v8/src/crankshaft/ppc/lithium-ppc.h b/deps/v8/src/crankshaft/ppc/lithium-ppc.h index f26bfc5e87..626f00ab8e 100644 --- a/deps/v8/src/crankshaft/ppc/lithium-ppc.h +++ b/deps/v8/src/crankshaft/ppc/lithium-ppc.h @@ -134,9 +134,7 @@ class LCodeGen; V(StoreCodeEntry) \ V(StoreContextSlot) \ V(StoreKeyed) \ - V(StoreKeyedGeneric) \ V(StoreNamedField) \ - V(StoreNamedGeneric) \ V(StringAdd) \ V(StringCharCodeAt) \ V(StringCharFromCode) \ @@ -1954,33 +1952,6 @@ class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> { }; -class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> { - public: - LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value, - LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* value() { return inputs_[2]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric) - - void PrintDataTo(StringStream* stream) override; - - Handle<Object> name() const { return hydrogen()->name(); } - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { public: LStoreKeyed(LOperand* object, LOperand* key, LOperand* value, @@ -2015,34 +1986,6 @@ class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { }; -class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> { - public: - LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key, - LOperand* value, LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = key; - inputs_[3] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* key() { return inputs_[2]; } - LOperand* value() { return inputs_[3]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric) - - void PrintDataTo(StringStream* stream) override; - - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> { public: LTransitionElementsKind(LOperand* object, LOperand* context, diff --git a/deps/v8/src/crankshaft/s390/lithium-codegen-s390.cc b/deps/v8/src/crankshaft/s390/lithium-codegen-s390.cc index ec2a85a07b..71881ada39 100644 --- a/deps/v8/src/crankshaft/s390/lithium-codegen-s390.cc +++ b/deps/v8/src/crankshaft/s390/lithium-codegen-s390.cc @@ -66,8 +66,8 @@ void LCodeGen::SaveCallerDoubles() { BitVector* doubles = chunk()->allocated_double_registers(); BitVector::Iterator save_iterator(doubles); while (!save_iterator.Done()) { - __ std(DoubleRegister::from_code(save_iterator.Current()), - MemOperand(sp, count * kDoubleSize)); + __ StoreDouble(DoubleRegister::from_code(save_iterator.Current()), + MemOperand(sp, count * kDoubleSize)); save_iterator.Advance(); count++; } @@ -81,8 +81,8 @@ void LCodeGen::RestoreCallerDoubles() { BitVector::Iterator save_iterator(doubles); int count = 0; while (!save_iterator.Done()) { - __ ld(DoubleRegister::from_code(save_iterator.Current()), - MemOperand(sp, count * kDoubleSize)); + __ LoadDouble(DoubleRegister::from_code(save_iterator.Current()), + MemOperand(sp, count * kDoubleSize)); save_iterator.Advance(); count++; } @@ -148,7 +148,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Comment(";;; Prologue begin"); // Possibly allocate a local context. - if (info()->scope()->num_heap_slots() > 0) { + if (info()->scope()->NeedsContext()) { Comment(";;; Allocate local context"); bool need_write_barrier = true; // Argument to NewContext is the function, which is in r3. @@ -156,7 +156,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; if (info()->scope()->is_script_scope()) { __ push(r3); - __ Push(info()->scope()->GetScopeInfo(info()->isolate())); + __ Push(info()->scope()->scope_info()); __ CallRuntime(Runtime::kNewScriptContext); deopt_mode = Safepoint::kLazyDeopt; } else { @@ -2089,7 +2089,8 @@ void LCodeGen::DoBranch(LBranch* instr) { EmitBranch(instr, al); } else if (type.IsHeapNumber()) { DCHECK(!info()->IsStub()); - __ ld(dbl_scratch, FieldMemOperand(reg, HeapNumber::kValueOffset)); + __ LoadDouble(dbl_scratch, + FieldMemOperand(reg, HeapNumber::kValueOffset)); // Test the double value. Zero and NaN are false. __ lzdr(kDoubleRegZero); __ cdbr(dbl_scratch, kDoubleRegZero); @@ -2652,19 +2653,6 @@ void LCodeGen::EmitVectorLoadICRegisters(T* instr) { __ LoadSmiLiteral(slot_register, Smi::FromInt(index)); } -template <class T> -void LCodeGen::EmitVectorStoreICRegisters(T* instr) { - Register vector_register = ToRegister(instr->temp_vector()); - Register slot_register = ToRegister(instr->temp_slot()); - - AllowDeferredHandleDereference vector_structure_check; - Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); - __ Move(vector_register, vector); - FeedbackVectorSlot slot = instr->hydrogen()->slot(); - int index = vector->GetIndex(slot); - __ LoadSmiLiteral(slot_register, Smi::FromInt(index)); -} - void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { DCHECK(ToRegister(instr->context()).is(cp)); DCHECK(ToRegister(instr->result()).is(r2)); @@ -2739,7 +2727,7 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { if (instr->hydrogen()->representation().IsDouble()) { DCHECK(access.IsInobject()); DoubleRegister result = ToDoubleRegister(instr->result()); - __ ld(result, FieldMemOperand(object, offset)); + __ LoadDouble(result, FieldMemOperand(object, offset)); return; } @@ -2889,9 +2877,10 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { } } else { // i.e. elements_kind == EXTERNAL_DOUBLE_ELEMENTS if (!use_scratch) { - __ ld(result, MemOperand(external_pointer, base_offset)); + __ LoadDouble(result, MemOperand(external_pointer, base_offset)); } else { - __ ld(result, MemOperand(scratch0(), external_pointer, base_offset)); + __ LoadDouble(result, + MemOperand(scratch0(), external_pointer, base_offset)); } } } else { @@ -2986,9 +2975,9 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { } if (!use_scratch) { - __ ld(result, MemOperand(elements, base_offset)); + __ LoadDouble(result, MemOperand(elements, base_offset)); } else { - __ ld(result, MemOperand(scratch, elements, base_offset)); + __ LoadDouble(result, MemOperand(scratch, elements, base_offset)); } if (instr->hydrogen()->RequiresHoleCheck()) { @@ -3919,7 +3908,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { DCHECK(!hinstr->NeedsWriteBarrier()); DoubleRegister value = ToDoubleRegister(instr->value()); DCHECK(offset >= 0); - __ std(value, FieldMemOperand(object, offset)); + __ StoreDouble(value, FieldMemOperand(object, offset)); return; } @@ -3944,7 +3933,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { if (FLAG_unbox_double_fields && representation.IsDouble()) { DCHECK(access.IsInobject()); DoubleRegister value = ToDoubleRegister(instr->value()); - __ std(value, FieldMemOperand(object, offset)); + __ StoreDouble(value, FieldMemOperand(object, offset)); if (hinstr->NeedsWriteBarrier()) { record_value = ToRegister(instr->value()); } @@ -3984,31 +3973,18 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } } -void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreNamedGeneric>(instr); - - __ mov(StoreDescriptor::NameRegister(), Operand(instr->name())); - Handle<Code> ic = - CodeFactory::StoreICInOptimizedCode(isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { Representation representation = instr->hydrogen()->length()->representation(); DCHECK(representation.Equals(instr->hydrogen()->index()->representation())); DCHECK(representation.IsSmiOrInteger32()); + Register temp = scratch0(); Condition cc = instr->hydrogen()->allow_equality() ? lt : le; if (instr->length()->IsConstantOperand()) { int32_t length = ToInteger32(LConstantOperand::cast(instr->length())); Register index = ToRegister(instr->index()); if (representation.IsSmi()) { - __ CmpLogicalP(index, Operand(Smi::FromInt(length))); + __ CmpLogicalSmiLiteral(index, Smi::FromInt(length), temp); } else { __ CmpLogical32(index, Operand(length)); } @@ -4017,7 +3993,7 @@ void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { int32_t index = ToInteger32(LConstantOperand::cast(instr->index())); Register length = ToRegister(instr->length()); if (representation.IsSmi()) { - __ CmpLogicalP(length, Operand(Smi::FromInt(index))); + __ CmpLogicalSmiLiteral(length, Smi::FromInt(index), temp); } else { __ CmpLogical32(length, Operand(index)); } @@ -4187,14 +4163,15 @@ void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) { __ CanonicalizeNaN(double_scratch, value); DCHECK(address_offset >= 0); if (use_scratch) - __ std(double_scratch, MemOperand(scratch, elements, address_offset)); + __ StoreDouble(double_scratch, + MemOperand(scratch, elements, address_offset)); else - __ std(double_scratch, MemOperand(elements, address_offset)); + __ StoreDouble(double_scratch, MemOperand(elements, address_offset)); } else { if (use_scratch) - __ std(value, MemOperand(scratch, elements, address_offset)); + __ StoreDouble(value, MemOperand(scratch, elements, address_offset)); else - __ std(value, MemOperand(elements, address_offset)); + __ StoreDouble(value, MemOperand(elements, address_offset)); } } @@ -4286,20 +4263,6 @@ void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { } } -void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(cp)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreKeyedGeneric>(instr); - - Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( - isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) { class DeferredMaybeGrowElements final : public LDeferredCode { public: @@ -4789,7 +4752,8 @@ void LCodeGen::EmitNumberUntagD(LNumberUntagD* instr, Register input_reg, DeoptimizeIf(ne, instr, DeoptimizeReason::kNotAHeapNumber); } // load heap number - __ ld(result_reg, FieldMemOperand(input_reg, HeapNumber::kValueOffset)); + __ LoadDouble(result_reg, + FieldMemOperand(input_reg, HeapNumber::kValueOffset)); if (deoptimize_on_minus_zero) { __ TestDoubleIsMinusZero(result_reg, scratch, ip); DeoptimizeIf(eq, instr, DeoptimizeReason::kMinusZero); @@ -4801,7 +4765,8 @@ void LCodeGen::EmitNumberUntagD(LNumberUntagD* instr, Register input_reg, __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); DeoptimizeIf(ne, instr, DeoptimizeReason::kNotAHeapNumberUndefined); __ LoadRoot(scratch, Heap::kNanValueRootIndex); - __ ld(result_reg, FieldMemOperand(scratch, HeapNumber::kValueOffset)); + __ LoadDouble(result_reg, + FieldMemOperand(scratch, HeapNumber::kValueOffset)); __ b(&done, Label::kNear); } } else { @@ -4862,8 +4827,8 @@ void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { // Deoptimize if we don't have a heap number. DeoptimizeIf(ne, instr, DeoptimizeReason::kNotAHeapNumber); - __ ld(double_scratch2, - FieldMemOperand(input_reg, HeapNumber::kValueOffset)); + __ LoadDouble(double_scratch2, + FieldMemOperand(input_reg, HeapNumber::kValueOffset)); if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { // preserve heap number pointer in scratch2 for minus zero check below __ LoadRR(scratch2, input_reg); @@ -5177,7 +5142,7 @@ void LCodeGen::DoClampTToUint8(LClampTToUint8* instr) { // Heap number __ bind(&heap_number); - __ ld(temp_reg, FieldMemOperand(input_reg, HeapNumber::kValueOffset)); + __ LoadDouble(temp_reg, FieldMemOperand(input_reg, HeapNumber::kValueOffset)); __ ClampDoubleToUint8(result_reg, temp_reg, double_scratch0()); __ b(&done, Label::kNear); @@ -5224,7 +5189,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) { if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ Allocate(size, result, scratch, scratch2, deferred->entry(), flags); } else { Register size = ToRegister(instr->size()); @@ -5337,7 +5302,7 @@ void LCodeGen::DoFastAllocate(LFastAllocate* instr) { } if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ FastAllocate(size, result, scratch1, scratch2, flags); } else { Register size = ToRegister(instr->size()); diff --git a/deps/v8/src/crankshaft/s390/lithium-codegen-s390.h b/deps/v8/src/crankshaft/s390/lithium-codegen-s390.h index e5df255f4d..30e9d2b997 100644 --- a/deps/v8/src/crankshaft/s390/lithium-codegen-s390.h +++ b/deps/v8/src/crankshaft/s390/lithium-codegen-s390.h @@ -276,8 +276,6 @@ class LCodeGen : public LCodeGenBase { template <class T> void EmitVectorLoadICRegisters(T* instr); - template <class T> - void EmitVectorStoreICRegisters(T* instr); ZoneList<Deoptimizer::JumpTableEntry> jump_table_; Scope* const scope_; diff --git a/deps/v8/src/crankshaft/s390/lithium-s390.cc b/deps/v8/src/crankshaft/s390/lithium-s390.cc index 3048e4c8b5..bf9dfd56ba 100644 --- a/deps/v8/src/crankshaft/s390/lithium-s390.cc +++ b/deps/v8/src/crankshaft/s390/lithium-s390.cc @@ -287,14 +287,6 @@ void LStoreNamedField::PrintDataTo(StringStream* stream) { value()->PrintTo(stream); } -void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("."); - stream->Add(String::cast(*name())->ToCString().get()); - stream->Add(" <- "); - value()->PrintTo(stream); -} - void LLoadKeyed::PrintDataTo(StringStream* stream) { elements()->PrintTo(stream); stream->Add("["); @@ -325,14 +317,6 @@ void LStoreKeyed::PrintDataTo(StringStream* stream) { } } -void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("["); - key()->PrintTo(stream); - stream->Add("] <- "); - value()->PrintTo(stream); -} - void LTransitionElementsKind::PrintDataTo(StringStream* stream) { object()->PrintTo(stream); stream->Add(" %p -> %p", *original_map(), *transitioned_map()); @@ -815,7 +799,7 @@ void LChunkBuilder::AddInstruction(LInstruction* instr, LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { LInstruction* result = new (zone()) LPrologue(); - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { result = MarkAsCall(result, instr); } return result; @@ -937,6 +921,9 @@ LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { LInstruction* LChunkBuilder::DoCallWithDescriptor(HCallWithDescriptor* instr) { CallInterfaceDescriptor descriptor = instr->descriptor(); + DCHECK_EQ(descriptor.GetParameterCount() + + LCallWithDescriptor::kImplicitRegisterParameterCount, + instr->OperandCount()); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList<LOperand*> ops(instr->OperandCount(), zone()); @@ -945,15 +932,20 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor(HCallWithDescriptor* instr) { // Context LOperand* op = UseFixed(instr->OperandAt(1), cp); ops.Add(op, zone()); - // Other register parameters - for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; - i < instr->OperandCount(); i++) { - op = - UseFixed(instr->OperandAt(i), - descriptor.GetRegisterParameter( - i - LCallWithDescriptor::kImplicitRegisterParameterCount)); + // Load register parameters. + int i = 0; + for (; i < descriptor.GetRegisterParameterCount(); i++) { + op = UseFixed(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount), + descriptor.GetRegisterParameter(i)); ops.Add(op, zone()); } + // Push stack parameters. + for (; i < descriptor.GetParameterCount(); i++) { + op = UseAny(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount)); + AddInstruction(new (zone()) LPushArgument(op), instr); + } LCallWithDescriptor* result = new (zone()) LCallWithDescriptor(descriptor, ops, zone()); @@ -1968,25 +1960,6 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { return new (zone()) LStoreKeyed(backing_store, key, val, backing_store_owner); } -LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - LOperand* obj = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister()); - LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - - DCHECK(instr->object()->representation().IsTagged()); - DCHECK(instr->key()->representation().IsTagged()); - DCHECK(instr->value()->representation().IsTagged()); - - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreKeyedGeneric* result = - new (zone()) LStoreKeyedGeneric(context, obj, key, val, slot, vector); - return MarkAsCall(result, instr); -} - LInstruction* LChunkBuilder::DoTransitionElementsKind( HTransitionElementsKind* instr) { if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { @@ -2058,18 +2031,6 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { return new (zone()) LStoreNamedField(obj, val, temp); } -LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), cp); - LOperand* obj = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - LStoreNamedGeneric* result = - new (zone()) LStoreNamedGeneric(context, obj, val, slot, vector); - return MarkAsCall(result, instr); -} - LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { LOperand* context = UseFixed(instr->context(), cp); LOperand* left = UseFixed(instr->left(), r3); diff --git a/deps/v8/src/crankshaft/s390/lithium-s390.h b/deps/v8/src/crankshaft/s390/lithium-s390.h index 1f1e520067..70670ac3e8 100644 --- a/deps/v8/src/crankshaft/s390/lithium-s390.h +++ b/deps/v8/src/crankshaft/s390/lithium-s390.h @@ -132,9 +132,7 @@ class LCodeGen; V(StoreCodeEntry) \ V(StoreContextSlot) \ V(StoreKeyed) \ - V(StoreKeyedGeneric) \ V(StoreNamedField) \ - V(StoreNamedGeneric) \ V(StringAdd) \ V(StringCharCodeAt) \ V(StringCharFromCode) \ @@ -1822,32 +1820,6 @@ class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> { } }; -class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> { - public: - LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value, - LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* value() { return inputs_[2]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric) - - void PrintDataTo(StringStream* stream) override; - - Handle<Object> name() const { return hydrogen()->name(); } - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { public: LStoreKeyed(LOperand* object, LOperand* key, LOperand* value, @@ -1881,33 +1853,6 @@ class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { uint32_t base_offset() const { return hydrogen()->base_offset(); } }; -class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> { - public: - LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key, - LOperand* value, LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = key; - inputs_[3] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* key() { return inputs_[2]; } - LOperand* value() { return inputs_[3]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric) - - void PrintDataTo(StringStream* stream) override; - - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> { public: LTransitionElementsKind(LOperand* object, LOperand* context, diff --git a/deps/v8/src/crankshaft/typing.cc b/deps/v8/src/crankshaft/typing.cc index 5961838711..d2b56e255b 100644 --- a/deps/v8/src/crankshaft/typing.cc +++ b/deps/v8/src/crankshaft/typing.cc @@ -4,11 +4,12 @@ #include "src/crankshaft/typing.h" +#include "src/ast/compile-time-value.h" #include "src/ast/scopes.h" -#include "src/frames.h" +#include "src/ast/variables.h" #include "src/frames-inl.h" +#include "src/frames.h" #include "src/ostreams.h" -#include "src/parsing/parser.h" // for CompileTimeValue; TODO(rossberg): move #include "src/splay-tree-inl.h" namespace v8 { @@ -33,20 +34,20 @@ AstTyper::AstTyper(Isolate* isolate, Zone* zone, Handle<JSFunction> closure, #ifdef OBJECT_PRINT - static void PrintObserved(Variable* var, Object* value, Type* type) { - OFStream os(stdout); - os << " observed " << (var->IsParameter() ? "param" : "local") << " "; - var->name()->Print(os); - os << " : " << Brief(value) << " -> "; - type->PrintTo(os); - os << std::endl; +static void PrintObserved(Variable* var, Object* value, AstType* type) { + OFStream os(stdout); + os << " observed " << (var->IsParameter() ? "param" : "local") << " "; + var->name()->Print(os); + os << " : " << Brief(value) << " -> "; + type->PrintTo(os); + os << std::endl; } #endif // OBJECT_PRINT Effect AstTyper::ObservedOnStack(Object* value) { - Type* lower = Type::NowOf(value, zone()); - return Effect(Bounds(lower, Type::Any())); + AstType* lower = AstType::NowOf(value, zone()); + return Effect(AstBounds(lower, AstType::Any())); } @@ -84,15 +85,16 @@ void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) { store_.LookupBounds(parameter_index(i)).lower); } - ZoneList<Variable*> local_vars(locals, zone()); - ZoneList<Variable*> context_vars(scope_->ContextLocalCount(), zone()); - ZoneList<Variable*> global_vars(scope_->ContextGlobalCount(), zone()); - scope_->CollectStackAndContextLocals(&local_vars, &context_vars, - &global_vars); - for (int i = 0; i < locals; i++) { - PrintObserved(local_vars.at(i), - frame->GetExpression(i), - store_.LookupBounds(stack_local_index(i)).lower); + ZoneList<Variable*>* local_vars = scope_->locals(); + int local_index = 0; + for (int i = 0; i < local_vars->length(); i++) { + Variable* var = local_vars->at(i); + if (var->IsStackLocal()) { + PrintObserved( + var, frame->GetExpression(local_index), + store_.LookupBounds(stack_local_index(local_index)).lower); + local_index++; + } } } #endif // OBJECT_PRINT @@ -205,11 +207,12 @@ void AstTyper::VisitSwitchStatement(SwitchStatement* stmt) { if (!clause->is_default()) { Expression* label = clause->label(); // Collect type feedback. - Type* tag_type; - Type* label_type; - Type* combined_type; + AstType* tag_type; + AstType* label_type; + AstType* combined_type; oracle()->CompareType(clause->CompareId(), - &tag_type, &label_type, &combined_type); + clause->CompareOperationFeedbackSlot(), &tag_type, + &label_type, &combined_type); NarrowLowerType(stmt->tag(), tag_type); NarrowLowerType(label, label_type); clause->set_compare_type(combined_type); @@ -366,8 +369,8 @@ void AstTyper::VisitConditional(Conditional* expr) { store_.Seq(then_effects); NarrowType(expr, - Bounds::Either(bounds_->get(expr->then_expression()), - bounds_->get(expr->else_expression()), zone())); + AstBounds::Either(bounds_->get(expr->then_expression()), + bounds_->get(expr->else_expression()), zone())); } @@ -380,14 +383,14 @@ void AstTyper::VisitVariableProxy(VariableProxy* expr) { void AstTyper::VisitLiteral(Literal* expr) { - Type* type = Type::Constant(expr->value(), zone()); - NarrowType(expr, Bounds(type)); + AstType* type = AstType::Constant(expr->value(), zone()); + NarrowType(expr, AstBounds(type)); } void AstTyper::VisitRegExpLiteral(RegExpLiteral* expr) { // TODO(rossberg): Reintroduce RegExp type. - NarrowType(expr, Bounds(Type::Object())); + NarrowType(expr, AstBounds(AstType::Object())); } @@ -415,7 +418,7 @@ void AstTyper::VisitObjectLiteral(ObjectLiteral* expr) { RECURSE(Visit(prop->value())); } - NarrowType(expr, Bounds(Type::Object())); + NarrowType(expr, AstBounds(AstType::Object())); } @@ -426,7 +429,7 @@ void AstTyper::VisitArrayLiteral(ArrayLiteral* expr) { RECURSE(Visit(value)); } - NarrowType(expr, Bounds(Type::Object())); + NarrowType(expr, AstBounds(AstType::Object())); } @@ -479,7 +482,7 @@ void AstTyper::VisitThrow(Throw* expr) { RECURSE(Visit(expr->exception())); // TODO(rossberg): is it worth having a non-termination effect? - NarrowType(expr, Bounds(Type::None())); + NarrowType(expr, AstBounds(AstType::None())); } @@ -562,7 +565,7 @@ void AstTyper::VisitCallNew(CallNew* expr) { RECURSE(Visit(arg)); } - NarrowType(expr, Bounds(Type::None(), Type::Receiver())); + NarrowType(expr, AstBounds(AstType::None(), AstType::Receiver())); } @@ -589,13 +592,13 @@ void AstTyper::VisitUnaryOperation(UnaryOperation* expr) { switch (expr->op()) { case Token::NOT: case Token::DELETE: - NarrowType(expr, Bounds(Type::Boolean())); + NarrowType(expr, AstBounds(AstType::Boolean())); break; case Token::VOID: - NarrowType(expr, Bounds(Type::Undefined())); + NarrowType(expr, AstBounds(AstType::Undefined())); break; case Token::TYPEOF: - NarrowType(expr, Bounds(Type::InternalizedString())); + NarrowType(expr, AstBounds(AstType::InternalizedString())); break; default: UNREACHABLE(); @@ -612,12 +615,13 @@ void AstTyper::VisitCountOperation(CountOperation* expr) { oracle()->CountReceiverTypes(slot, expr->GetReceiverTypes()); expr->set_store_mode(store_mode); expr->set_key_type(key_type); - expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId())); + expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId(), + expr->CountBinaryOpFeedbackSlot())); // TODO(rossberg): merge the count type with the generic expression type. RECURSE(Visit(expr->expression())); - NarrowType(expr, Bounds(Type::SignedSmall(), Type::Number())); + NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Number())); VariableProxy* proxy = expr->expression()->AsVariableProxy(); if (proxy != NULL && proxy->var()->IsStackAllocated()) { @@ -625,17 +629,18 @@ void AstTyper::VisitCountOperation(CountOperation* expr) { } } - void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { // Collect type feedback. - Type* type; - Type* left_type; - Type* right_type; + AstType* type; + AstType* left_type; + AstType* right_type; Maybe<int> fixed_right_arg = Nothing<int>(); Handle<AllocationSite> allocation_site; oracle()->BinaryType(expr->BinaryOperationFeedbackId(), - &left_type, &right_type, &type, &fixed_right_arg, - &allocation_site, expr->op()); + expr->BinaryOperationFeedbackSlot(), &left_type, + &right_type, &type, &fixed_right_arg, &allocation_site, + expr->op()); + NarrowLowerType(expr, type); NarrowLowerType(expr->left(), left_type); NarrowLowerType(expr->right(), right_type); @@ -662,19 +667,21 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { left_effects.Alt(right_effects); store_.Seq(left_effects); - NarrowType(expr, Bounds::Either(bounds_->get(expr->left()), - bounds_->get(expr->right()), zone())); + NarrowType(expr, AstBounds::Either(bounds_->get(expr->left()), + bounds_->get(expr->right()), zone())); break; } case Token::BIT_OR: case Token::BIT_AND: { RECURSE(Visit(expr->left())); RECURSE(Visit(expr->right())); - Type* upper = Type::Union(bounds_->get(expr->left()).upper, - bounds_->get(expr->right()).upper, zone()); - if (!upper->Is(Type::Signed32())) upper = Type::Signed32(); - Type* lower = Type::Intersect(Type::SignedSmall(), upper, zone()); - NarrowType(expr, Bounds(lower, upper)); + AstType* upper = + AstType::Union(bounds_->get(expr->left()).upper, + bounds_->get(expr->right()).upper, zone()); + if (!upper->Is(AstType::Signed32())) upper = AstType::Signed32(); + AstType* lower = + AstType::Intersect(AstType::SignedSmall(), upper, zone()); + NarrowType(expr, AstBounds(lower, upper)); break; } case Token::BIT_XOR: @@ -682,7 +689,7 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { case Token::SAR: RECURSE(Visit(expr->left())); RECURSE(Visit(expr->right())); - NarrowType(expr, Bounds(Type::SignedSmall(), Type::Signed32())); + NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Signed32())); break; case Token::SHR: RECURSE(Visit(expr->left())); @@ -690,28 +697,29 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { // TODO(rossberg): The upper bound would be Unsigned32, but since there // is no 'positive Smi' type for the lower bound, we use the smallest // union of Smi and Unsigned32 as upper bound instead. - NarrowType(expr, Bounds(Type::SignedSmall(), Type::Number())); + NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Number())); break; case Token::ADD: { RECURSE(Visit(expr->left())); RECURSE(Visit(expr->right())); - Bounds l = bounds_->get(expr->left()); - Bounds r = bounds_->get(expr->right()); - Type* lower = + AstBounds l = bounds_->get(expr->left()); + AstBounds r = bounds_->get(expr->right()); + AstType* lower = !l.lower->IsInhabited() || !r.lower->IsInhabited() - ? Type::None() - : l.lower->Is(Type::String()) || r.lower->Is(Type::String()) - ? Type::String() - : l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) - ? Type::SignedSmall() - : Type::None(); - Type* upper = - l.upper->Is(Type::String()) || r.upper->Is(Type::String()) - ? Type::String() - : l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) - ? Type::Number() - : Type::NumberOrString(); - NarrowType(expr, Bounds(lower, upper)); + ? AstType::None() + : l.lower->Is(AstType::String()) || r.lower->Is(AstType::String()) + ? AstType::String() + : l.lower->Is(AstType::Number()) && + r.lower->Is(AstType::Number()) + ? AstType::SignedSmall() + : AstType::None(); + AstType* upper = + l.upper->Is(AstType::String()) || r.upper->Is(AstType::String()) + ? AstType::String() + : l.upper->Is(AstType::Number()) && r.upper->Is(AstType::Number()) + ? AstType::Number() + : AstType::NumberOrString(); + NarrowType(expr, AstBounds(lower, upper)); break; } case Token::SUB: @@ -720,7 +728,7 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { case Token::MOD: RECURSE(Visit(expr->left())); RECURSE(Visit(expr->right())); - NarrowType(expr, Bounds(Type::SignedSmall(), Type::Number())); + NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Number())); break; default: UNREACHABLE(); @@ -730,11 +738,12 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { void AstTyper::VisitCompareOperation(CompareOperation* expr) { // Collect type feedback. - Type* left_type; - Type* right_type; - Type* combined_type; + AstType* left_type; + AstType* right_type; + AstType* combined_type; oracle()->CompareType(expr->CompareOperationFeedbackId(), - &left_type, &right_type, &combined_type); + expr->CompareOperationFeedbackSlot(), &left_type, + &right_type, &combined_type); NarrowLowerType(expr->left(), left_type); NarrowLowerType(expr->right(), right_type); expr->set_combined_type(combined_type); @@ -742,7 +751,7 @@ void AstTyper::VisitCompareOperation(CompareOperation* expr) { RECURSE(Visit(expr->left())); RECURSE(Visit(expr->right())); - NarrowType(expr, Bounds(Type::Boolean())); + NarrowType(expr, AstBounds(AstType::Boolean())); } @@ -767,6 +776,14 @@ void AstTyper::VisitRewritableExpression(RewritableExpression* expr) { Visit(expr->expression()); } +int AstTyper::variable_index(Variable* var) { + // Stack locals have the range [0 .. l] + // Parameters have the range [-1 .. p] + // We map this to [-p-2 .. -1, 0 .. l] + return var->IsStackLocal() + ? stack_local_index(var->index()) + : var->IsParameter() ? parameter_index(var->index()) : kNoVar; +} void AstTyper::VisitDeclarations(ZoneList<Declaration*>* decls) { for (int i = 0; i < decls->length(); ++i) { diff --git a/deps/v8/src/crankshaft/typing.h b/deps/v8/src/crankshaft/typing.h index 94340c5a74..eb88634777 100644 --- a/deps/v8/src/crankshaft/typing.h +++ b/deps/v8/src/crankshaft/typing.h @@ -7,16 +7,18 @@ #include "src/allocation.h" #include "src/ast/ast-type-bounds.h" -#include "src/ast/scopes.h" +#include "src/ast/ast-types.h" +#include "src/ast/ast.h" #include "src/ast/variables.h" #include "src/effects.h" #include "src/type-info.h" -#include "src/types.h" -#include "src/zone.h" +#include "src/zone/zone.h" namespace v8 { namespace internal { +class DeclarationScope; +class Isolate; class FunctionLiteral; class AstTyper final : public AstVisitor<AstTyper> { @@ -49,11 +51,11 @@ class AstTyper final : public AstVisitor<AstTyper> { Zone* zone() const { return zone_; } TypeFeedbackOracle* oracle() { return &oracle_; } - void NarrowType(Expression* e, Bounds b) { - bounds_->set(e, Bounds::Both(bounds_->get(e), b, zone())); + void NarrowType(Expression* e, AstBounds b) { + bounds_->set(e, AstBounds::Both(bounds_->get(e), b, zone())); } - void NarrowLowerType(Expression* e, Type* t) { - bounds_->set(e, Bounds::NarrowLower(bounds_->get(e), t, zone())); + void NarrowLowerType(Expression* e, AstType* t) { + bounds_->set(e, AstBounds::NarrowLower(bounds_->get(e), t, zone())); } Effects EnterEffects() { @@ -65,13 +67,7 @@ class AstTyper final : public AstVisitor<AstTyper> { int parameter_index(int index) { return -index - 2; } int stack_local_index(int index) { return index; } - int variable_index(Variable* var) { - // Stack locals have the range [0 .. l] - // Parameters have the range [-1 .. p] - // We map this to [-p-2 .. -1, 0 .. l] - return var->IsStackLocal() ? stack_local_index(var->index()) : - var->IsParameter() ? parameter_index(var->index()) : kNoVar; - } + int variable_index(Variable* var); void VisitDeclarations(ZoneList<Declaration*>* declarations); void VisitStatements(ZoneList<Statement*>* statements); diff --git a/deps/v8/src/crankshaft/unique.h b/deps/v8/src/crankshaft/unique.h index 54abfa7710..4c6a0976f8 100644 --- a/deps/v8/src/crankshaft/unique.h +++ b/deps/v8/src/crankshaft/unique.h @@ -11,7 +11,7 @@ #include "src/base/functional.h" #include "src/handles.h" #include "src/utils.h" -#include "src/zone.h" +#include "src/zone/zone.h" namespace v8 { namespace internal { diff --git a/deps/v8/src/crankshaft/x64/lithium-codegen-x64.cc b/deps/v8/src/crankshaft/x64/lithium-codegen-x64.cc index 66046a4e68..50e2aa0915 100644 --- a/deps/v8/src/crankshaft/x64/lithium-codegen-x64.cc +++ b/deps/v8/src/crankshaft/x64/lithium-codegen-x64.cc @@ -167,7 +167,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Comment(";;; Prologue begin"); // Possibly allocate a local context. - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { Comment(";;; Allocate local context"); bool need_write_barrier = true; // Argument to NewContext is the function, which is still in rdi. @@ -175,7 +175,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; if (info()->scope()->is_script_scope()) { __ Push(rdi); - __ Push(info()->scope()->GetScopeInfo(info()->isolate())); + __ Push(info()->scope()->scope_info()); __ CallRuntime(Runtime::kNewScriptContext); deopt_mode = Safepoint::kLazyDeopt; } else { @@ -2539,20 +2539,6 @@ void LCodeGen::EmitVectorLoadICRegisters(T* instr) { } -template <class T> -void LCodeGen::EmitVectorStoreICRegisters(T* instr) { - Register vector_register = ToRegister(instr->temp_vector()); - Register slot_register = ToRegister(instr->temp_slot()); - - AllowDeferredHandleDereference vector_structure_check; - Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); - __ Move(vector_register, vector); - FeedbackVectorSlot slot = instr->hydrogen()->slot(); - int index = vector->GetIndex(slot); - __ Move(slot_register, Smi::FromInt(index)); -} - - void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { DCHECK(ToRegister(instr->context()).is(rsi)); DCHECK(ToRegister(instr->result()).is(rax)); @@ -3902,21 +3888,6 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } -void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(rsi)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreNamedGeneric>(instr); - - __ Move(StoreDescriptor::NameRegister(), instr->hydrogen()->name()); - Handle<Code> ic = - CodeFactory::StoreICInOptimizedCode(isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { Representation representation = instr->hydrogen()->length()->representation(); DCHECK(representation.Equals(instr->hydrogen()->index()->representation())); @@ -4158,21 +4129,6 @@ void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { } -void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(rsi)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreKeyedGeneric>(instr); - - Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( - isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) { class DeferredMaybeGrowElements final : public LDeferredCode { public: @@ -5110,7 +5066,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) { if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ Allocate(size, result, temp, no_reg, deferred->entry(), flags); } else { Register size = ToRegister(instr->size()); @@ -5153,7 +5109,7 @@ void LCodeGen::DoFastAllocate(LFastAllocate* instr) { } if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ FastAllocate(size, result, temp, flags); } else { Register size = ToRegister(instr->size()); diff --git a/deps/v8/src/crankshaft/x64/lithium-codegen-x64.h b/deps/v8/src/crankshaft/x64/lithium-codegen-x64.h index 22c39ad088..22a32a147d 100644 --- a/deps/v8/src/crankshaft/x64/lithium-codegen-x64.h +++ b/deps/v8/src/crankshaft/x64/lithium-codegen-x64.h @@ -297,8 +297,6 @@ class LCodeGen: public LCodeGenBase { template <class T> void EmitVectorLoadICRegisters(T* instr); - template <class T> - void EmitVectorStoreICRegisters(T* instr); #ifdef _MSC_VER // On windows, you may not access the stack more than one page below diff --git a/deps/v8/src/crankshaft/x64/lithium-x64.cc b/deps/v8/src/crankshaft/x64/lithium-x64.cc index 42451690af..18fb5d4d09 100644 --- a/deps/v8/src/crankshaft/x64/lithium-x64.cc +++ b/deps/v8/src/crankshaft/x64/lithium-x64.cc @@ -348,15 +348,6 @@ void LStoreNamedField::PrintDataTo(StringStream* stream) { } -void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("."); - stream->Add(String::cast(*name())->ToCString().get()); - stream->Add(" <- "); - value()->PrintTo(stream); -} - - void LLoadKeyed::PrintDataTo(StringStream* stream) { elements()->PrintTo(stream); stream->Add("["); @@ -389,15 +380,6 @@ void LStoreKeyed::PrintDataTo(StringStream* stream) { } -void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("["); - key()->PrintTo(stream); - stream->Add("] <- "); - value()->PrintTo(stream); -} - - void LTransitionElementsKind::PrintDataTo(StringStream* stream) { object()->PrintTo(stream); stream->Add(" %p -> %p", *original_map(), *transitioned_map()); @@ -907,7 +889,7 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { LInstruction* result = new (zone()) LPrologue(); - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { result = MarkAsCall(result, instr); } return result; @@ -1042,6 +1024,9 @@ LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { CallInterfaceDescriptor descriptor = instr->descriptor(); + DCHECK_EQ(descriptor.GetParameterCount() + + LCallWithDescriptor::kImplicitRegisterParameterCount, + instr->OperandCount()); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList<LOperand*> ops(instr->OperandCount(), zone()); @@ -1050,15 +1035,20 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor( // Context LOperand* op = UseFixed(instr->OperandAt(1), rsi); ops.Add(op, zone()); - // Other register parameters - for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; - i < instr->OperandCount(); i++) { - op = - UseFixed(instr->OperandAt(i), - descriptor.GetRegisterParameter( - i - LCallWithDescriptor::kImplicitRegisterParameterCount)); + // Load register parameters. + int i = 0; + for (; i < descriptor.GetRegisterParameterCount(); i++) { + op = UseFixed(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount), + descriptor.GetRegisterParameter(i)); ops.Add(op, zone()); } + // Push stack parameters. + for (; i < descriptor.GetParameterCount(); i++) { + op = UseAny(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount)); + AddInstruction(new (zone()) LPushArgument(op), instr); + } LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( descriptor, ops, zone()); @@ -2223,26 +2213,6 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { } -LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), rsi); - 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()); - DCHECK(instr->value()->representation().IsTagged()); - - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreKeyedGeneric* result = new (zone()) - LStoreKeyedGeneric(context, object, key, value, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoTransitionElementsKind( HTransitionElementsKind* instr) { if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { @@ -2337,20 +2307,6 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { } -LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), rsi); - LOperand* object = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreNamedGeneric* result = - new (zone()) LStoreNamedGeneric(context, object, value, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { LOperand* context = UseFixed(instr->context(), rsi); LOperand* left = UseFixed(instr->left(), rdx); diff --git a/deps/v8/src/crankshaft/x64/lithium-x64.h b/deps/v8/src/crankshaft/x64/lithium-x64.h index 5c0ce04a8a..e7eaa01529 100644 --- a/deps/v8/src/crankshaft/x64/lithium-x64.h +++ b/deps/v8/src/crankshaft/x64/lithium-x64.h @@ -132,9 +132,7 @@ class LCodeGen; V(StoreCodeEntry) \ V(StoreContextSlot) \ V(StoreKeyed) \ - V(StoreKeyedGeneric) \ V(StoreNamedField) \ - V(StoreNamedGeneric) \ V(StringAdd) \ V(StringCharCodeAt) \ V(StringCharFromCode) \ @@ -2013,33 +2011,6 @@ class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> { }; -class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> { - public: - LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value, - LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* value() { return inputs_[2]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric) - - void PrintDataTo(StringStream* stream) override; - - Handle<Object> name() const { return hydrogen()->name(); } - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { public: LStoreKeyed(LOperand* object, LOperand* key, LOperand* value, @@ -2068,34 +2039,6 @@ class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { }; -class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> { - public: - LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key, - LOperand* value, LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = key; - inputs_[3] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* key() { return inputs_[2]; } - LOperand* value() { return inputs_[3]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric) - - void PrintDataTo(StringStream* stream) override; - - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> { public: LTransitionElementsKind(LOperand* object, diff --git a/deps/v8/src/crankshaft/x87/lithium-codegen-x87.cc b/deps/v8/src/crankshaft/x87/lithium-codegen-x87.cc index 1a42d5b41b..2d597d4c3b 100644 --- a/deps/v8/src/crankshaft/x87/lithium-codegen-x87.cc +++ b/deps/v8/src/crankshaft/x87/lithium-codegen-x87.cc @@ -134,7 +134,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Comment(";;; Prologue begin"); // Possibly allocate a local context. - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { Comment(";;; Allocate local context"); bool need_write_barrier = true; // Argument to NewContext is the function, which is still in edi. @@ -142,7 +142,7 @@ void LCodeGen::DoPrologue(LPrologue* instr) { Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; if (info()->scope()->is_script_scope()) { __ push(edi); - __ Push(info()->scope()->GetScopeInfo(info()->isolate())); + __ Push(info()->scope()->scope_info()); __ CallRuntime(Runtime::kNewScriptContext); deopt_mode = Safepoint::kLazyDeopt; } else { @@ -2681,20 +2681,6 @@ void LCodeGen::EmitVectorLoadICRegisters(T* instr) { } -template <class T> -void LCodeGen::EmitVectorStoreICRegisters(T* instr) { - Register vector_register = ToRegister(instr->temp_vector()); - Register slot_register = ToRegister(instr->temp_slot()); - - AllowDeferredHandleDereference vector_structure_check; - Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); - __ mov(vector_register, vector); - FeedbackVectorSlot slot = instr->hydrogen()->slot(); - int index = vector->GetIndex(slot); - __ mov(slot_register, Immediate(Smi::FromInt(index))); -} - - void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { DCHECK(ToRegister(instr->context()).is(esi)); DCHECK(ToRegister(instr->result()).is(eax)); @@ -3703,7 +3689,9 @@ void LCodeGen::DoMathCos(LMathCos* instr) { __ PrepareCallCFunction(2, eax); __ fstp_d(MemOperand(esp, 0)); X87PrepareToWrite(result); + __ X87SetFPUCW(0x027F); __ CallCFunction(ExternalReference::ieee754_cos_function(isolate()), 2); + __ X87SetFPUCW(0x037F); // Return value is in st(0) on ia32. X87CommitWrite(result); } @@ -3717,7 +3705,9 @@ void LCodeGen::DoMathSin(LMathSin* instr) { __ PrepareCallCFunction(2, eax); __ fstp_d(MemOperand(esp, 0)); X87PrepareToWrite(result); + __ X87SetFPUCW(0x027F); __ CallCFunction(ExternalReference::ieee754_sin_function(isolate()), 2); + __ X87SetFPUCW(0x037F); // Return value is in st(0) on ia32. X87CommitWrite(result); } @@ -3976,21 +3966,6 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } -void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(esi)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreNamedGeneric>(instr); - - __ mov(StoreDescriptor::NameRegister(), instr->name()); - Handle<Code> ic = - CodeFactory::StoreICInOptimizedCode(isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { Condition cc = instr->hydrogen()->allow_equality() ? above : above_equal; if (instr->index()->IsConstantOperand()) { @@ -4199,21 +4174,6 @@ void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { } -void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { - DCHECK(ToRegister(instr->context()).is(esi)); - DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); - DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); - DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - - EmitVectorStoreICRegisters<LStoreKeyedGeneric>(instr); - - Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( - isolate(), instr->language_mode()) - .code(); - CallCode(ic, RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { Register object = ToRegister(instr->object()); Register temp = ToRegister(instr->temp()); @@ -5315,7 +5275,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) { if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ Allocate(size, result, temp, no_reg, deferred->entry(), flags); } else { Register size = ToRegister(instr->size()); @@ -5358,7 +5318,7 @@ void LCodeGen::DoFastAllocate(LFastAllocate* instr) { } if (instr->size()->IsConstantOperand()) { int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); - CHECK(size <= Page::kMaxRegularHeapObjectSize); + CHECK(size <= kMaxRegularHeapObjectSize); __ FastAllocate(size, result, temp, flags); } else { Register size = ToRegister(instr->size()); diff --git a/deps/v8/src/crankshaft/x87/lithium-codegen-x87.h b/deps/v8/src/crankshaft/x87/lithium-codegen-x87.h index cdf02f3f8c..850f330900 100644 --- a/deps/v8/src/crankshaft/x87/lithium-codegen-x87.h +++ b/deps/v8/src/crankshaft/x87/lithium-codegen-x87.h @@ -323,8 +323,6 @@ class LCodeGen: public LCodeGenBase { template <class T> void EmitVectorLoadICRegisters(T* instr); - template <class T> - void EmitVectorStoreICRegisters(T* instr); void EmitReturn(LReturn* instr); diff --git a/deps/v8/src/crankshaft/x87/lithium-x87.cc b/deps/v8/src/crankshaft/x87/lithium-x87.cc index f614b93c9c..a319c0c718 100644 --- a/deps/v8/src/crankshaft/x87/lithium-x87.cc +++ b/deps/v8/src/crankshaft/x87/lithium-x87.cc @@ -362,15 +362,6 @@ void LStoreNamedField::PrintDataTo(StringStream* stream) { } -void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("."); - stream->Add(String::cast(*name())->ToCString().get()); - stream->Add(" <- "); - value()->PrintTo(stream); -} - - void LLoadKeyed::PrintDataTo(StringStream* stream) { elements()->PrintTo(stream); stream->Add("["); @@ -403,15 +394,6 @@ void LStoreKeyed::PrintDataTo(StringStream* stream) { } -void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { - object()->PrintTo(stream); - stream->Add("["); - key()->PrintTo(stream); - stream->Add("] <- "); - value()->PrintTo(stream); -} - - void LTransitionElementsKind::PrintDataTo(StringStream* stream) { object()->PrintTo(stream); stream->Add(" %p -> %p", *original_map(), *transitioned_map()); @@ -925,7 +907,7 @@ void LChunkBuilder::AddInstruction(LInstruction* instr, LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { LInstruction* result = new (zone()) LPrologue(); - if (info_->scope()->num_heap_slots() > 0) { + if (info_->scope()->NeedsContext()) { result = MarkAsCall(result, instr); } return result; @@ -1071,6 +1053,10 @@ LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { CallInterfaceDescriptor descriptor = instr->descriptor(); + DCHECK_EQ(descriptor.GetParameterCount() + + LCallWithDescriptor::kImplicitRegisterParameterCount, + instr->OperandCount()); + LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList<LOperand*> ops(instr->OperandCount(), zone()); // Target @@ -1078,15 +1064,20 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor( // Context LOperand* op = UseFixed(instr->OperandAt(1), esi); ops.Add(op, zone()); - // Other register parameters - for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; - i < instr->OperandCount(); i++) { - op = - UseFixed(instr->OperandAt(i), - descriptor.GetRegisterParameter( - i - LCallWithDescriptor::kImplicitRegisterParameterCount)); + // Load register parameters. + int i = 0; + for (; i < descriptor.GetRegisterParameterCount(); i++) { + op = UseFixed(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount), + descriptor.GetRegisterParameter(i)); ops.Add(op, zone()); } + // Push stack parameters. + for (; i < descriptor.GetParameterCount(); i++) { + op = UseAny(instr->OperandAt( + i + LCallWithDescriptor::kImplicitRegisterParameterCount)); + AddInstruction(new (zone()) LPushArgument(op), instr); + } LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( descriptor, ops, zone()); @@ -2213,26 +2204,6 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { } -LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), esi); - 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()); - DCHECK(instr->value()->representation().IsTagged()); - - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreKeyedGeneric* result = new (zone()) - LStoreKeyedGeneric(context, object, key, value, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoTransitionElementsKind( HTransitionElementsKind* instr) { if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { @@ -2334,20 +2305,6 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { } -LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { - LOperand* context = UseFixed(instr->context(), esi); - LOperand* object = - UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); - LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); - LOperand* slot = FixedTemp(StoreWithVectorDescriptor::SlotRegister()); - LOperand* vector = FixedTemp(StoreWithVectorDescriptor::VectorRegister()); - - LStoreNamedGeneric* result = - new (zone()) LStoreNamedGeneric(context, object, value, slot, vector); - return MarkAsCall(result, instr); -} - - LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { LOperand* context = UseFixed(instr->context(), esi); LOperand* left = UseFixed(instr->left(), edx); diff --git a/deps/v8/src/crankshaft/x87/lithium-x87.h b/deps/v8/src/crankshaft/x87/lithium-x87.h index 3ef8f75523..e2b804322a 100644 --- a/deps/v8/src/crankshaft/x87/lithium-x87.h +++ b/deps/v8/src/crankshaft/x87/lithium-x87.h @@ -135,9 +135,7 @@ class LCodeGen; V(StoreCodeEntry) \ V(StoreContextSlot) \ V(StoreKeyed) \ - V(StoreKeyedGeneric) \ V(StoreNamedField) \ - V(StoreNamedGeneric) \ V(StringAdd) \ V(StringCharCodeAt) \ V(StringCharFromCode) \ @@ -2008,32 +2006,6 @@ class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> { }; -class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> { - public: - LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value, - LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* value() { return inputs_[2]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric) - - void PrintDataTo(StringStream* stream) override; - Handle<Object> name() const { return hydrogen()->name(); } - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { public: LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val, @@ -2064,34 +2036,6 @@ class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> { }; -class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> { - public: - LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key, - LOperand* value, LOperand* slot, LOperand* vector) { - inputs_[0] = context; - inputs_[1] = object; - inputs_[2] = key; - inputs_[3] = value; - temps_[0] = slot; - temps_[1] = vector; - } - - LOperand* context() { return inputs_[0]; } - LOperand* object() { return inputs_[1]; } - LOperand* key() { return inputs_[2]; } - LOperand* value() { return inputs_[3]; } - LOperand* temp_slot() { return temps_[0]; } - LOperand* temp_vector() { return temps_[1]; } - - DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic") - DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric) - - void PrintDataTo(StringStream* stream) override; - - LanguageMode language_mode() { return hydrogen()->language_mode(); } -}; - - class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> { public: LTransitionElementsKind(LOperand* object, |