| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/crankshaft/x87/lithium-codegen-x87.h" | 7 #include "src/crankshaft/x87/lithium-codegen-x87.h" |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| 11 #include "src/code-stubs.h" | 11 #include "src/code-stubs.h" |
| 12 #include "src/codegen.h" | 12 #include "src/codegen.h" |
| 13 #include "src/crankshaft/hydrogen-osr.h" | 13 #include "src/crankshaft/hydrogen-osr.h" |
| 14 #include "src/deoptimizer.h" | 14 #include "src/deoptimizer.h" |
| 15 #include "src/ic/ic.h" | 15 #include "src/ic/ic.h" |
| 16 #include "src/ic/stub-cache.h" | 16 #include "src/ic/stub-cache.h" |
| 17 #include "src/profiler/cpu-profiler.h" | 17 #include "src/profiler/cpu-profiler.h" |
| 18 #include "src/x87/frames-x87.h" | 18 #include "src/x87/frames-x87.h" |
| 19 | 19 |
| 20 namespace v8 { | 20 namespace v8 { |
| 21 namespace internal { | 21 namespace internal { |
| 22 | 22 |
| 23 | |
| 24 // When invoking builtins, we need to record the safepoint in the middle of | 23 // When invoking builtins, we need to record the safepoint in the middle of |
| 25 // the invoke instruction sequence generated by the macro assembler. | 24 // the invoke instruction sequence generated by the macro assembler. |
| 26 class SafepointGenerator final : public CallWrapper { | 25 class SafepointGenerator final : public CallWrapper { |
| 27 public: | 26 public: |
| 28 SafepointGenerator(LCodeGen* codegen, | 27 SafepointGenerator(LCodeGen* codegen, |
| 29 LPointerMap* pointers, | 28 LPointerMap* pointers, |
| 30 Safepoint::DeoptMode mode) | 29 Safepoint::DeoptMode mode) |
| 31 : codegen_(codegen), | 30 : codegen_(codegen), |
| 32 pointers_(pointers), | 31 pointers_(pointers), |
| 33 deopt_mode_(mode) {} | 32 deopt_mode_(mode) {} |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return GeneratePrologue() && | 67 return GeneratePrologue() && |
| 69 GenerateBody() && | 68 GenerateBody() && |
| 70 GenerateDeferredCode() && | 69 GenerateDeferredCode() && |
| 71 GenerateJumpTable() && | 70 GenerateJumpTable() && |
| 72 GenerateSafepointTable(); | 71 GenerateSafepointTable(); |
| 73 } | 72 } |
| 74 | 73 |
| 75 | 74 |
| 76 void LCodeGen::FinishCode(Handle<Code> code) { | 75 void LCodeGen::FinishCode(Handle<Code> code) { |
| 77 DCHECK(is_done()); | 76 DCHECK(is_done()); |
| 78 code->set_stack_slots(GetStackSlotCount()); | 77 code->set_stack_slots(GetTotalFrameSlotCount()); |
| 79 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); | 78 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); |
| 80 PopulateDeoptimizationData(code); | 79 PopulateDeoptimizationData(code); |
| 81 if (info()->ShouldEnsureSpaceForLazyDeopt()) { | 80 if (info()->ShouldEnsureSpaceForLazyDeopt()) { |
| 82 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code); | 81 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code); |
| 83 } | 82 } |
| 84 } | 83 } |
| 85 | 84 |
| 86 | 85 |
| 87 #ifdef _MSC_VER | 86 #ifdef _MSC_VER |
| 88 void LCodeGen::MakeSureStackPagesMapped(int offset) { | 87 void LCodeGen::MakeSureStackPagesMapped(int offset) { |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 DCHECK(is_done()); | 478 DCHECK(is_done()); |
| 480 if (info()->ShouldEnsureSpaceForLazyDeopt()) { | 479 if (info()->ShouldEnsureSpaceForLazyDeopt()) { |
| 481 // For lazy deoptimization we need space to patch a call after every call. | 480 // For lazy deoptimization we need space to patch a call after every call. |
| 482 // Ensure there is always space for such patching, even if the code ends | 481 // Ensure there is always space for such patching, even if the code ends |
| 483 // in a call. | 482 // in a call. |
| 484 int target_offset = masm()->pc_offset() + Deoptimizer::patch_size(); | 483 int target_offset = masm()->pc_offset() + Deoptimizer::patch_size(); |
| 485 while (masm()->pc_offset() < target_offset) { | 484 while (masm()->pc_offset() < target_offset) { |
| 486 masm()->nop(); | 485 masm()->nop(); |
| 487 } | 486 } |
| 488 } | 487 } |
| 489 safepoints_.Emit(masm(), GetStackSlotCount()); | 488 safepoints_.Emit(masm(), GetTotalFrameSlotCount()); |
| 490 return !is_aborted(); | 489 return !is_aborted(); |
| 491 } | 490 } |
| 492 | 491 |
| 493 | 492 |
| 494 Register LCodeGen::ToRegister(int code) const { | 493 Register LCodeGen::ToRegister(int code) const { |
| 495 return Register::from_code(code); | 494 return Register::from_code(code); |
| 496 } | 495 } |
| 497 | 496 |
| 498 | 497 |
| 499 X87Register LCodeGen::ToX87Register(int code) const { | 498 X87Register LCodeGen::ToX87Register(int code) const { |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 DCHECK(index < 0); | 831 DCHECK(index < 0); |
| 833 return -(index + 1) * kPointerSize + kPCOnStackSize; | 832 return -(index + 1) * kPointerSize + kPCOnStackSize; |
| 834 } | 833 } |
| 835 | 834 |
| 836 | 835 |
| 837 Operand LCodeGen::ToOperand(LOperand* op) const { | 836 Operand LCodeGen::ToOperand(LOperand* op) const { |
| 838 if (op->IsRegister()) return Operand(ToRegister(op)); | 837 if (op->IsRegister()) return Operand(ToRegister(op)); |
| 839 DCHECK(!op->IsDoubleRegister()); | 838 DCHECK(!op->IsDoubleRegister()); |
| 840 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 839 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
| 841 if (NeedsEagerFrame()) { | 840 if (NeedsEagerFrame()) { |
| 842 return Operand(ebp, StackSlotOffset(op->index())); | 841 return Operand(ebp, FrameSlotToFPOffset(op->index())); |
| 843 } else { | 842 } else { |
| 844 // Retrieve parameter without eager stack-frame relative to the | 843 // Retrieve parameter without eager stack-frame relative to the |
| 845 // stack-pointer. | 844 // stack-pointer. |
| 846 return Operand(esp, ArgumentsOffsetWithoutFrame(op->index())); | 845 return Operand(esp, ArgumentsOffsetWithoutFrame(op->index())); |
| 847 } | 846 } |
| 848 } | 847 } |
| 849 | 848 |
| 850 | 849 |
| 851 Operand LCodeGen::HighOperand(LOperand* op) { | 850 Operand LCodeGen::HighOperand(LOperand* op) { |
| 852 DCHECK(op->IsDoubleStackSlot()); | 851 DCHECK(op->IsDoubleStackSlot()); |
| 853 if (NeedsEagerFrame()) { | 852 if (NeedsEagerFrame()) { |
| 854 return Operand(ebp, StackSlotOffset(op->index()) + kPointerSize); | 853 return Operand(ebp, FrameSlotToFPOffset(op->index()) + kPointerSize); |
| 855 } else { | 854 } else { |
| 856 // Retrieve parameter without eager stack-frame relative to the | 855 // Retrieve parameter without eager stack-frame relative to the |
| 857 // stack-pointer. | 856 // stack-pointer. |
| 858 return Operand( | 857 return Operand( |
| 859 esp, ArgumentsOffsetWithoutFrame(op->index()) + kPointerSize); | 858 esp, ArgumentsOffsetWithoutFrame(op->index()) + kPointerSize); |
| 860 } | 859 } |
| 861 } | 860 } |
| 862 | 861 |
| 863 | 862 |
| 864 void LCodeGen::WriteTranslation(LEnvironment* environment, | 863 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 environment->HasTaggedValueAt(env_offset + i), | 916 environment->HasTaggedValueAt(env_offset + i), |
| 918 environment->HasUint32ValueAt(env_offset + i), | 917 environment->HasUint32ValueAt(env_offset + i), |
| 919 object_index_pointer, | 918 object_index_pointer, |
| 920 dematerialized_index_pointer); | 919 dematerialized_index_pointer); |
| 921 } | 920 } |
| 922 return; | 921 return; |
| 923 } | 922 } |
| 924 | 923 |
| 925 if (op->IsStackSlot()) { | 924 if (op->IsStackSlot()) { |
| 926 int index = op->index(); | 925 int index = op->index(); |
| 927 if (index >= 0) { | |
| 928 index += StandardFrameConstants::kFixedFrameSize / kPointerSize; | |
| 929 } | |
| 930 if (is_tagged) { | 926 if (is_tagged) { |
| 931 translation->StoreStackSlot(index); | 927 translation->StoreStackSlot(index); |
| 932 } else if (is_uint32) { | 928 } else if (is_uint32) { |
| 933 translation->StoreUint32StackSlot(index); | 929 translation->StoreUint32StackSlot(index); |
| 934 } else { | 930 } else { |
| 935 translation->StoreInt32StackSlot(index); | 931 translation->StoreInt32StackSlot(index); |
| 936 } | 932 } |
| 937 } else if (op->IsDoubleStackSlot()) { | 933 } else if (op->IsDoubleStackSlot()) { |
| 938 int index = op->index(); | 934 int index = op->index(); |
| 939 if (index >= 0) { | |
| 940 index += StandardFrameConstants::kFixedFrameSize / kPointerSize; | |
| 941 } | |
| 942 translation->StoreDoubleStackSlot(index); | 935 translation->StoreDoubleStackSlot(index); |
| 943 } else if (op->IsRegister()) { | 936 } else if (op->IsRegister()) { |
| 944 Register reg = ToRegister(op); | 937 Register reg = ToRegister(op); |
| 945 if (is_tagged) { | 938 if (is_tagged) { |
| 946 translation->StoreRegister(reg); | 939 translation->StoreRegister(reg); |
| 947 } else if (is_uint32) { | 940 } else if (is_uint32) { |
| 948 translation->StoreUint32Register(reg); | 941 translation->StoreUint32Register(reg); |
| 949 } else { | 942 } else { |
| 950 translation->StoreInt32Register(reg); | 943 translation->StoreInt32Register(reg); |
| 951 } | 944 } |
| (...skipping 5007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5959 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), context); | 5952 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), context); |
| 5960 } | 5953 } |
| 5961 | 5954 |
| 5962 | 5955 |
| 5963 #undef __ | 5956 #undef __ |
| 5964 | 5957 |
| 5965 } // namespace internal | 5958 } // namespace internal |
| 5966 } // namespace v8 | 5959 } // namespace v8 |
| 5967 | 5960 |
| 5968 #endif // V8_TARGET_ARCH_X87 | 5961 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |