v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
gap-resolver.h
Go to the documentation of this file.
1// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_COMPILER_BACKEND_GAP_RESOLVER_H_
6#define V8_COMPILER_BACKEND_GAP_RESOLVER_H_
7
9
10namespace v8 {
11namespace internal {
12namespace compiler {
13
14class GapResolver final {
15 public:
16 // Interface used by the gap resolver to emit moves and swaps.
17 class Assembler {
18 public:
19 virtual ~Assembler() = default;
20
21 // Assemble move.
22 virtual void AssembleMove(InstructionOperand* source,
24 // Assemble swap.
25 virtual void AssembleSwap(InstructionOperand* source,
27
28 // Helper functions to resolve cyclic dependencies.
29 // - {Push} pushes {src} and returns an operand that encodes the new stack
30 // slot.
31 // - {Pop} pops the topmost stack operand and moves it to {dest}.
32 // - {PopTempStackSlots} pops all remaining unpopped stack slots.
33 // - {SetPendingMove} reserves scratch registers needed to perform the moves
34 // in the cycle.
35 // - {MoveToTempLocation} moves an operand to a temporary location, either
36 // a scratch register or a new stack slot, depending on the platform and the
37 // reserved registers.
38 // - {MoveTempLocationTo} moves the temp location to the destination,
39 // thereby completing the cycle.
41 virtual void Pop(InstructionOperand* dest, MachineRepresentation rep) = 0;
42 virtual void PopTempStackSlots() = 0;
44 MachineRepresentation rep) = 0;
46 MachineRepresentation rep) = 0;
47 virtual void SetPendingMove(MoveOperands* move) = 0;
48 int temp_slots_ = 0;
49 };
50
51 explicit GapResolver(Assembler* assembler) : assembler_(assembler) {}
52
53 // Resolve a set of parallel moves, emitting assembler instructions.
54 V8_EXPORT_PRIVATE void Resolve(ParallelMove* parallel_move);
55
56 private:
57 // Take a vector of moves where each move blocks the next one, and the last
58 // one blocks the first one, and resolve it using a temporary location.
59 void PerformCycle(const std::vector<MoveOperands*>& cycle);
60 // Performs the given move, possibly performing other moves to unblock the
61 // destination operand.
62 void PerformMove(ParallelMove* moves, MoveOperands* move);
63 // Perform the move and its dependencies. Also performs simple cyclic
64 // dependencies. For more complex cases the method may bail out:
65 // in this case, it returns one of the problematic moves. The caller
66 // ({PerformMove}) will use a temporary stack slot to unblock the dependencies
67 // and try again.
69 std::vector<MoveOperands*>* cycle);
70 // Assembler used to emit moves and save registers.
72};
73
74} // namespace compiler
75} // namespace internal
76} // namespace v8
77
78#endif // V8_COMPILER_BACKEND_GAP_RESOLVER_H_
virtual void SetPendingMove(MoveOperands *move)=0
virtual void MoveToTempLocation(InstructionOperand *src, MachineRepresentation rep)=0
virtual void AssembleMove(InstructionOperand *source, InstructionOperand *destination)=0
virtual void AssembleSwap(InstructionOperand *source, InstructionOperand *destination)=0
virtual AllocatedOperand Push(InstructionOperand *src)=0
virtual void Pop(InstructionOperand *dest, MachineRepresentation rep)=0
virtual void MoveTempLocationTo(InstructionOperand *dst, MachineRepresentation rep)=0
GapResolver(Assembler *assembler)
MoveOperands * PerformMoveHelper(ParallelMove *moves, MoveOperands *move, std::vector< MoveOperands * > *cycle)
void PerformCycle(const std::vector< MoveOperands * > &cycle)
V8_EXPORT_PRIVATE void Resolve(ParallelMove *parallel_move)
void PerformMove(ParallelMove *moves, MoveOperands *move)
InstructionOperand destination
#define V8_EXPORT_PRIVATE
Definition macros.h:460