OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_COMPILER_INTERPRETER_CODEGEN_H_ | 5 #ifndef V8_COMPILER_INTERPRETER_CODEGEN_H_ |
6 #define V8_COMPILER_INTERPRETER_CODEGEN_H_ | 6 #define V8_COMPILER_INTERPRETER_CODEGEN_H_ |
7 | 7 |
8 // Clients of this interface shouldn't depend on lots of compiler internals. | 8 // Clients of this interface shouldn't depend on lots of compiler internals. |
9 // Do not include anything from src/compiler here! | 9 // Do not include anything from src/compiler here! |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
11 #include "src/base/smart-pointers.h" | 11 #include "src/base/smart-pointers.h" |
12 #include "src/frames.h" | 12 #include "src/frames.h" |
13 #include "src/interpreter/bytecodes.h" | 13 #include "src/interpreter/bytecodes.h" |
14 #include "src/unique.h" | 14 #include "src/unique.h" |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 class Isolate; | 19 class Isolate; |
20 class Zone; | 20 class Zone; |
21 | 21 |
22 namespace compiler { | 22 namespace compiler { |
23 | 23 |
24 class CallDescriptor; | 24 class CallDescriptor; |
25 class CommonOperatorBuilder; | |
26 class Graph; | 25 class Graph; |
27 class MachineOperatorBuilder; | |
28 class Node; | 26 class Node; |
29 class Operator; | 27 class Operator; |
30 class RawMachineAssembler; | 28 class RawMachineAssembler; |
31 class Schedule; | 29 class Schedule; |
32 | 30 |
33 class InterpreterAssembler { | 31 class InterpreterAssembler { |
34 public: | 32 public: |
35 InterpreterAssembler(Isolate* isolate, Zone* zone, | 33 InterpreterAssembler(Isolate* isolate, Zone* zone, |
36 interpreter::Bytecode bytecode); | 34 interpreter::Bytecode bytecode); |
37 virtual ~InterpreterAssembler(); | 35 virtual ~InterpreterAssembler(); |
38 | 36 |
39 Handle<Code> GenerateCode(); | 37 Handle<Code> GenerateCode(); |
40 | 38 |
39 // Accumulator. | |
40 Node* IncomingAccumulator(); | |
titzer
2015/08/14 12:42:20
The distinction between "incoming" accumulator and
rmcilroy
2015/08/14 14:03:41
Good idea. Done.
| |
41 void StoreAccumulator(Node* value); | |
42 | |
41 // Constants. | 43 // Constants. |
42 Node* Int32Constant(int value); | 44 Node* Int32Constant(int value); |
43 Node* NumberConstant(double value); | 45 Node* NumberConstant(double value); |
44 Node* HeapConstant(Unique<HeapObject> object); | 46 Node* HeapConstant(Unique<HeapObject> object); |
45 | 47 |
46 // Returns the bytecode operand |index| for the current bytecode. | |
47 Node* BytecodeOperand(int index); | |
48 | |
49 // Loads from and stores to the interpreter register file. | 48 // Loads from and stores to the interpreter register file. |
50 Node* LoadRegister(int index); | 49 Node* LoadRegister(Node* reg_index); |
51 Node* LoadRegister(Node* index); | 50 Node* StoreRegister(Node* value, Node* reg_index); |
52 Node* StoreRegister(Node* value, int index); | |
53 Node* StoreRegister(Node* value, Node* index); | |
54 | 51 |
55 // Returns from the function. | 52 // Returns from the function. |
56 void Return(); | 53 void Return(); |
57 | 54 |
58 // Dispatch to the bytecode. | 55 // Dispatch to the bytecode. |
59 void Dispatch(); | 56 void Dispatch(); |
60 | 57 |
58 Node* BytecodeOperand(int index); | |
59 Node* BytecodeOperandSignExtended(int index); | |
60 | |
61 protected: | 61 protected: |
62 static const int kFirstRegisterOffsetFromFp = | |
63 -kPointerSize - StandardFrameConstants::kFixedFrameSizeFromFp; | |
64 | |
65 // TODO(rmcilroy): Increase this when required. | |
66 static const int kMaxRegisterIndex = 255; | |
67 | |
68 // Close the graph. | 62 // Close the graph. |
69 void End(); | 63 void End(); |
70 | 64 |
71 // Protected helpers (for testing) which delegate to RawMachineAssembler. | 65 // Protected helpers (for testing) which delegate to RawMachineAssembler. |
72 CallDescriptor* call_descriptor() const; | 66 CallDescriptor* call_descriptor() const; |
73 Graph* graph(); | 67 Graph* graph(); |
74 | 68 |
75 private: | 69 private: |
70 // Returns a raw pointer to start of the register file on the stack. | |
71 Node* RegisterFilePointer(); | |
titzer
2015/08/14 12:42:20
Can we name this RegisterFileRawPointer() and the
rmcilroy
2015/08/14 14:03:41
Done (also done for DispatchTablePointer below)
| |
76 // Returns a tagged pointer to the current function's BytecodeArray object. | 72 // Returns a tagged pointer to the current function's BytecodeArray object. |
77 Node* BytecodeArrayPointer(); | 73 Node* BytecodeArrayPointer(); |
78 // Returns the offset from the BytecodeArrayPointer of the current bytecode. | 74 // Returns the offset from the BytecodeArrayPointer of the current bytecode. |
79 Node* BytecodeOffset(); | 75 Node* BytecodeOffset(); |
80 // Returns a pointer to first entry in the interpreter dispatch table. | 76 // Returns a pointer to first entry in the interpreter dispatch table. |
81 Node* DispatchTablePointer(); | 77 Node* DispatchTablePointer(); |
82 // Returns the frame pointer for the current function. | |
83 Node* FramePointer(); | |
84 | 78 |
85 // Returns the offset of register |index|. | 79 // Returns the offset of register |index| relative to RegisterFilePointer(). |
86 Node* RegisterFrameOffset(int index); | |
87 Node* RegisterFrameOffset(Node* index); | 80 Node* RegisterFrameOffset(Node* index); |
88 | 81 |
89 // Returns BytecodeOffset() advanced by delta bytecodes. Note: this does not | 82 // Returns BytecodeOffset() advanced by delta bytecodes. Note: this does not |
90 // update BytecodeOffset() itself. | 83 // update BytecodeOffset() itself. |
91 Node* Advance(int delta); | 84 Node* Advance(int delta); |
92 | 85 |
86 // Returns the outgoing accumulator value, which is either by | |
87 // SetOutgoingAccumulator or is the IncomingAccumulator. | |
88 Node* OutgoingAccumulator(); | |
89 | |
93 // Sets the end node of the graph. | 90 // Sets the end node of the graph. |
94 void SetEndInput(Node* input); | 91 void SetEndInput(Node* input); |
95 | 92 |
96 // Private helpers which delegate to RawMachineAssembler. | 93 // Private helpers which delegate to RawMachineAssembler. |
97 Isolate* isolate(); | 94 Isolate* isolate(); |
98 Schedule* schedule(); | 95 Schedule* schedule(); |
99 MachineOperatorBuilder* machine(); | |
100 CommonOperatorBuilder* common(); | |
101 | 96 |
102 interpreter::Bytecode bytecode_; | 97 interpreter::Bytecode bytecode_; |
103 base::SmartPointer<RawMachineAssembler> raw_assembler_; | 98 base::SmartPointer<RawMachineAssembler> raw_assembler_; |
104 Node* end_node_; | 99 Node* end_node_; |
100 Node* outgoing_accumulator_; | |
105 bool code_generated_; | 101 bool code_generated_; |
106 | 102 |
107 DISALLOW_COPY_AND_ASSIGN(InterpreterAssembler); | 103 DISALLOW_COPY_AND_ASSIGN(InterpreterAssembler); |
108 }; | 104 }; |
109 | 105 |
110 } // namespace interpreter | 106 } // namespace interpreter |
111 } // namespace internal | 107 } // namespace internal |
112 } // namespace v8 | 108 } // namespace v8 |
113 | 109 |
114 #endif // V8_COMPILER_INTERPRETER_CODEGEN_H_ | 110 #endif // V8_COMPILER_INTERPRETER_CODEGEN_H_ |
OLD | NEW |