| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef V8_ARM64_LITHIUM_GAP_RESOLVER_ARM64_H_ | 5 #ifndef V8_ARM64_LITHIUM_GAP_RESOLVER_ARM64_H_ |
| 6 #define V8_ARM64_LITHIUM_GAP_RESOLVER_ARM64_H_ | 6 #define V8_ARM64_LITHIUM_GAP_RESOLVER_ARM64_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/lithium.h" | 10 #include "src/lithium.h" |
| 11 #include "src/arm64/delayed-masm-arm64.h" |
| 11 | 12 |
| 12 namespace v8 { | 13 namespace v8 { |
| 13 namespace internal { | 14 namespace internal { |
| 14 | 15 |
| 15 class LCodeGen; | 16 class LCodeGen; |
| 16 class LGapResolver; | 17 class LGapResolver; |
| 17 | 18 |
| 19 class DelayedGapMasm : public DelayedMasm { |
| 20 public: |
| 21 DelayedGapMasm(LCodeGen* owner, MacroAssembler* masm) |
| 22 : DelayedMasm(owner, masm, root) { |
| 23 // We use the root register as an extra scratch register. |
| 24 // The root register has two advantages: |
| 25 // - It is not in crankshaft allocatable registers list, so it can't |
| 26 // interfere with the allocatable registers. |
| 27 // - We don't need to push it on the stack, as we can reload it with its |
| 28 // value once we have finish. |
| 29 } |
| 30 void EndDelayedUse(); |
| 31 }; |
| 32 |
| 33 |
| 18 class LGapResolver BASE_EMBEDDED { | 34 class LGapResolver BASE_EMBEDDED { |
| 19 public: | 35 public: |
| 20 explicit LGapResolver(LCodeGen* owner); | 36 explicit LGapResolver(LCodeGen* owner); |
| 21 | 37 |
| 22 // Resolve a set of parallel moves, emitting assembler instructions. | 38 // Resolve a set of parallel moves, emitting assembler instructions. |
| 23 void Resolve(LParallelMove* parallel_move); | 39 void Resolve(LParallelMove* parallel_move); |
| 24 | 40 |
| 25 private: | 41 private: |
| 26 // Build the initial list of moves. | 42 // Build the initial list of moves. |
| 27 void BuildInitialMoveList(LParallelMove* parallel_move); | 43 void BuildInitialMoveList(LParallelMove* parallel_move); |
| 28 | 44 |
| 29 // Perform the move at the moves_ index in question (possibly requiring | 45 // Perform the move at the moves_ index in question (possibly requiring |
| 30 // other moves to satisfy dependencies). | 46 // other moves to satisfy dependencies). |
| 31 void PerformMove(int index); | 47 void PerformMove(int index); |
| 32 | 48 |
| 33 // If a cycle is found in the series of moves, save the blocking value to | 49 // If a cycle is found in the series of moves, save the blocking value to |
| 34 // a scratch register. The cycle must be found by hitting the root of the | 50 // a scratch register. The cycle must be found by hitting the root of the |
| 35 // depth-first search. | 51 // depth-first search. |
| 36 void BreakCycle(int index); | 52 void BreakCycle(int index); |
| 37 | 53 |
| 38 // After a cycle has been resolved, restore the value from the scratch | 54 // After a cycle has been resolved, restore the value from the scratch |
| 39 // register to its proper destination. | 55 // register to its proper destination. |
| 40 void RestoreValue(); | 56 void RestoreValue(); |
| 41 | 57 |
| 42 // Emit a move and remove it from the move graph. | 58 // Emit a move and remove it from the move graph. |
| 43 void EmitMove(int index); | 59 void EmitMove(int index); |
| 44 | 60 |
| 45 // Emit a move from one stack slot to another. | 61 // Emit a move from one stack slot to another. |
| 46 void EmitStackSlotMove(int index); | 62 void EmitStackSlotMove(int index) { |
| 63 masm_.StackSlotMove(moves_[index].source(), moves_[index].destination()); |
| 64 } |
| 47 | 65 |
| 48 // Verify the move list before performing moves. | 66 // Verify the move list before performing moves. |
| 49 void Verify(); | 67 void Verify(); |
| 50 | 68 |
| 69 // Registers used to solve cycles. |
| 70 const Register& SavedValueRegister() { |
| 71 ASSERT(!masm_.ScratchRegister().IsAllocatable()); |
| 72 return masm_.ScratchRegister(); |
| 73 } |
| 74 // The scratch register is used to break cycles and to store constant. |
| 75 // These two methods switch from one mode to the other. |
| 76 void AcquireSavedValueRegister() { masm_.AcquireScratchRegister(); } |
| 77 void ReleaseSavedValueRegister() { masm_.ReleaseScratchRegister(); } |
| 78 const FPRegister& SavedFPValueRegister() { |
| 79 // We use the Crankshaft floating-point scratch register to break a cycle |
| 80 // involving double values as the MacroAssembler will not need it for the |
| 81 // operations performed by the gap resolver. |
| 82 ASSERT(!crankshaft_fp_scratch.IsAllocatable()); |
| 83 return crankshaft_fp_scratch; |
| 84 } |
| 85 |
| 51 LCodeGen* cgen_; | 86 LCodeGen* cgen_; |
| 87 DelayedGapMasm masm_; |
| 52 | 88 |
| 53 // List of moves not yet resolved. | 89 // List of moves not yet resolved. |
| 54 ZoneList<LMoveOperands> moves_; | 90 ZoneList<LMoveOperands> moves_; |
| 55 | 91 |
| 56 int root_index_; | 92 int root_index_; |
| 57 bool in_cycle_; | 93 bool in_cycle_; |
| 58 LOperand* saved_destination_; | 94 LOperand* saved_destination_; |
| 59 | |
| 60 // We use the root register as a scratch in a few places. When that happens, | |
| 61 // this flag is set to indicate that it needs to be restored. | |
| 62 bool need_to_restore_root_; | |
| 63 }; | 95 }; |
| 64 | 96 |
| 65 } } // namespace v8::internal | 97 } } // namespace v8::internal |
| 66 | 98 |
| 67 #endif // V8_ARM64_LITHIUM_GAP_RESOLVER_ARM64_H_ | 99 #endif // V8_ARM64_LITHIUM_GAP_RESOLVER_ARM64_H_ |
| OLD | NEW |