diff options
Diffstat (limited to 'deps/v8/src/x87/lithium-codegen-x87.cc')
-rw-r--r-- | deps/v8/src/x87/lithium-codegen-x87.cc | 136 |
1 files changed, 90 insertions, 46 deletions
diff --git a/deps/v8/src/x87/lithium-codegen-x87.cc b/deps/v8/src/x87/lithium-codegen-x87.cc index 6021ec74e9..0c852640e8 100644 --- a/deps/v8/src/x87/lithium-codegen-x87.cc +++ b/deps/v8/src/x87/lithium-codegen-x87.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" - #if V8_TARGET_ARCH_X87 #include "src/base/bits.h" @@ -15,6 +13,7 @@ #include "src/hydrogen-osr.h" #include "src/ic/ic.h" #include "src/ic/stub-cache.h" +#include "src/x87/frames-x87.h" #include "src/x87/lithium-codegen-x87.h" namespace v8 { @@ -102,7 +101,7 @@ bool LCodeGen::GeneratePrologue() { #ifdef DEBUG if (strlen(FLAG_stop_at) > 0 && - info_->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { + info_->literal()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { __ int3(); } #endif @@ -807,6 +806,10 @@ int32_t LCodeGen::ToInteger32(LConstantOperand* op) const { int32_t LCodeGen::ToRepresentation(LConstantOperand* op, const Representation& r) const { HConstant* constant = chunk_->LookupConstant(op); + if (r.IsExternal()) { + return reinterpret_cast<int32_t>( + constant->ExternalReferenceValue().address()); + } int32_t value = constant->Integer32Value(); if (r.IsInteger32()) return value; DCHECK(r.IsSmiOrTagged()); @@ -940,15 +943,23 @@ void LCodeGen::AddToTranslation(LEnvironment* environment, } if (op->IsStackSlot()) { + int index = op->index(); + if (index >= 0) { + index += StandardFrameConstants::kFixedFrameSize / kPointerSize; + } if (is_tagged) { - translation->StoreStackSlot(op->index()); + translation->StoreStackSlot(index); } else if (is_uint32) { - translation->StoreUint32StackSlot(op->index()); + translation->StoreUint32StackSlot(index); } else { - translation->StoreInt32StackSlot(op->index()); + translation->StoreInt32StackSlot(index); } } else if (op->IsDoubleStackSlot()) { - translation->StoreDoubleStackSlot(op->index()); + int index = op->index(); + if (index >= 0) { + index += StandardFrameConstants::kFixedFrameSize / kPointerSize; + } + translation->StoreDoubleStackSlot(index); } else if (op->IsRegister()) { Register reg = ToRegister(op); if (is_tagged) { @@ -2434,6 +2445,12 @@ void LCodeGen::DoBranch(LBranch* instr) { __ j(equal, instr->TrueLabel(chunk_)); } + if (expected.Contains(ToBooleanStub::SIMD_VALUE)) { + // SIMD value -> true. + __ CmpInstanceType(map, SIMD128_VALUE_TYPE); + __ j(equal, instr->TrueLabel(chunk_)); + } + if (expected.Contains(ToBooleanStub::HEAP_NUMBER)) { // heap number -> false iff +0, -0, or NaN. Label not_heap_number; @@ -3129,13 +3146,31 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { __ mov(LoadDescriptor::NameRegister(), instr->name()); EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr); - ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; - Handle<Code> ic = CodeFactory::LoadICInOptimizedCode(isolate(), mode, SLOPPY, - PREMONOMORPHIC).code(); + Handle<Code> ic = + CodeFactory::LoadICInOptimizedCode(isolate(), instr->typeof_mode(), + SLOPPY, PREMONOMORPHIC).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } +void LCodeGen::DoLoadGlobalViaContext(LLoadGlobalViaContext* instr) { + DCHECK(ToRegister(instr->context()).is(esi)); + DCHECK(ToRegister(instr->result()).is(eax)); + + int const slot = instr->slot_index(); + int const depth = instr->depth(); + if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { + __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); + Handle<Code> stub = + CodeFactory::LoadGlobalViaContext(isolate(), depth).code(); + CallCode(stub, RelocInfo::CODE_TARGET, instr); + } else { + __ Push(Smi::FromInt(slot)); + __ CallRuntime(Runtime::kLoadGlobalViaContext, 1); + } +} + + void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) { Register context = ToRegister(instr->context()); Register result = ToRegister(instr->result()); @@ -3242,7 +3277,7 @@ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr); Handle<Code> ic = CodeFactory::LoadICInOptimizedCode( - isolate(), NOT_CONTEXTUAL, instr->hydrogen()->language_mode(), + isolate(), NOT_INSIDE_TYPEOF, instr->hydrogen()->language_mode(), instr->hydrogen()->initialization_state()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -3314,38 +3349,29 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { instr->hydrogen()->key()->representation(), elements_kind, instr->base_offset())); - if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || - elements_kind == FLOAT32_ELEMENTS) { + if (elements_kind == FLOAT32_ELEMENTS) { X87Mov(ToX87Register(instr->result()), operand, kX87FloatOperand); - } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS || - elements_kind == FLOAT64_ELEMENTS) { + } else if (elements_kind == FLOAT64_ELEMENTS) { X87Mov(ToX87Register(instr->result()), operand); } else { Register result(ToRegister(instr->result())); switch (elements_kind) { - case EXTERNAL_INT8_ELEMENTS: case INT8_ELEMENTS: __ movsx_b(result, operand); break; - case EXTERNAL_UINT8_CLAMPED_ELEMENTS: - case EXTERNAL_UINT8_ELEMENTS: case UINT8_ELEMENTS: case UINT8_CLAMPED_ELEMENTS: __ movzx_b(result, operand); break; - case EXTERNAL_INT16_ELEMENTS: case INT16_ELEMENTS: __ movsx_w(result, operand); break; - case EXTERNAL_UINT16_ELEMENTS: case UINT16_ELEMENTS: __ movzx_w(result, operand); break; - case EXTERNAL_INT32_ELEMENTS: case INT32_ELEMENTS: __ mov(result, operand); break; - case EXTERNAL_UINT32_ELEMENTS: case UINT32_ELEMENTS: __ mov(result, operand); if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { @@ -3353,8 +3379,6 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { DeoptimizeIf(negative, instr, Deoptimizer::kNegativeValue); } break; - case EXTERNAL_FLOAT32_ELEMENTS: - case EXTERNAL_FLOAT64_ELEMENTS: case FLOAT32_ELEMENTS: case FLOAT64_ELEMENTS: case FAST_SMI_ELEMENTS: @@ -3433,7 +3457,7 @@ void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) { void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { - if (instr->is_typed_elements()) { + if (instr->is_fixed_typed_array()) { DoLoadKeyedExternalArray(instr); } else if (instr->hydrogen()->representation().IsDouble()) { DoLoadKeyedFixedDoubleArray(instr); @@ -3664,10 +3688,9 @@ void LCodeGen::DoContext(LContext* instr) { void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) { DCHECK(ToRegister(instr->context()).is(esi)); - __ push(esi); // The context is the first argument. __ push(Immediate(instr->hydrogen()->pairs())); __ push(Immediate(Smi::FromInt(instr->hydrogen()->flags()))); - CallRuntime(Runtime::kDeclareGlobals, 3, instr); + CallRuntime(Runtime::kDeclareGlobals, 2, instr); } @@ -4472,7 +4495,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { if (operand_value->IsRegister()) { Register value = ToRegister(operand_value); __ Store(value, operand, representation); - } else if (representation.IsInteger32()) { + } else if (representation.IsInteger32() || representation.IsExternal()) { Immediate immediate = ToImmediate(operand_value, representation); DCHECK(!instr->hydrogen()->NeedsWriteBarrier()); __ mov(operand, immediate); @@ -4515,6 +4538,30 @@ void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { } +void LCodeGen::DoStoreGlobalViaContext(LStoreGlobalViaContext* instr) { + DCHECK(ToRegister(instr->context()).is(esi)); + DCHECK(ToRegister(instr->value()) + .is(StoreGlobalViaContextDescriptor::ValueRegister())); + + int const slot = instr->slot_index(); + int const depth = instr->depth(); + if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { + __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); + Handle<Code> stub = CodeFactory::StoreGlobalViaContext( + isolate(), depth, instr->language_mode()) + .code(); + CallCode(stub, RelocInfo::CODE_TARGET, instr); + } else { + __ Push(Smi::FromInt(slot)); + __ Push(StoreGlobalViaContextDescriptor::ValueRegister()); + __ CallRuntime(is_strict(instr->language_mode()) + ? Runtime::kStoreGlobalViaContext_Strict + : Runtime::kStoreGlobalViaContext_Sloppy, + 2); + } +} + + void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { Condition cc = instr->hydrogen()->allow_equality() ? above : above_equal; if (instr->index()->IsConstantOperand()) { @@ -4554,11 +4601,9 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { instr->hydrogen()->key()->representation(), elements_kind, instr->base_offset())); - if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || - elements_kind == FLOAT32_ELEMENTS) { + if (elements_kind == FLOAT32_ELEMENTS) { X87Mov(operand, ToX87Register(instr->value()), kX87FloatOperand); - } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS || - elements_kind == FLOAT64_ELEMENTS) { + } else if (elements_kind == FLOAT64_ELEMENTS) { uint64_t int_val = kHoleNanInt64; int32_t lower = static_cast<int32_t>(int_val); int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); @@ -4588,28 +4633,19 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { } else { Register value = ToRegister(instr->value()); switch (elements_kind) { - case EXTERNAL_UINT8_CLAMPED_ELEMENTS: - case EXTERNAL_UINT8_ELEMENTS: - case EXTERNAL_INT8_ELEMENTS: case UINT8_ELEMENTS: case INT8_ELEMENTS: case UINT8_CLAMPED_ELEMENTS: __ mov_b(operand, value); break; - case EXTERNAL_INT16_ELEMENTS: - case EXTERNAL_UINT16_ELEMENTS: case UINT16_ELEMENTS: case INT16_ELEMENTS: __ mov_w(operand, value); break; - case EXTERNAL_INT32_ELEMENTS: - case EXTERNAL_UINT32_ELEMENTS: case UINT32_ELEMENTS: case INT32_ELEMENTS: __ mov(operand, value); break; - case EXTERNAL_FLOAT32_ELEMENTS: - case EXTERNAL_FLOAT64_ELEMENTS: case FLOAT32_ELEMENTS: case FLOAT64_ELEMENTS: case FAST_SMI_ELEMENTS: @@ -4725,7 +4761,7 @@ void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { // By cases...external, fast-double, fast - if (instr->is_typed_elements()) { + if (instr->is_fixed_typed_array()) { DoStoreKeyedExternalArray(instr); } else if (instr->hydrogen()->value()->representation().IsDouble()) { DoStoreKeyedFixedDoubleArray(instr); @@ -6074,10 +6110,7 @@ Condition LCodeGen::EmitTypeofIs(LTypeofIsAndBranch* instr, Register input) { } else if (String::Equals(type_name, factory()->string_string())) { __ JumpIfSmi(input, false_label, false_distance); __ CmpObjectType(input, FIRST_NONSTRING_TYPE, input); - __ j(above_equal, false_label, false_distance); - __ test_b(FieldOperand(input, Map::kBitFieldOffset), - 1 << Map::kIsUndetectable); - final_branch_condition = zero; + final_branch_condition = below; } else if (String::Equals(type_name, factory()->symbol_string())) { __ JumpIfSmi(input, false_label, false_distance); @@ -6121,6 +6154,17 @@ Condition LCodeGen::EmitTypeofIs(LTypeofIsAndBranch* instr, Register input) { 1 << Map::kIsUndetectable); final_branch_condition = zero; +// clang-format off +#define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ + } else if (String::Equals(type_name, factory()->type##_string())) { \ + __ JumpIfSmi(input, false_label, false_distance); \ + __ cmp(FieldOperand(input, HeapObject::kMapOffset), \ + factory()->type##_map()); \ + final_branch_condition = equal; + SIMD128_TYPES(SIMD128_TYPE) +#undef SIMD128_TYPE + // clang-format on + } else { __ jmp(false_label, false_distance); } |