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_ASSEMBLER_H_ | 5 #ifndef V8_COMPILER_INTERPRETER_ASSEMBLER_H_ |
6 #define V8_COMPILER_INTERPRETER_ASSEMBLER_H_ | 6 #define V8_COMPILER_INTERPRETER_ASSEMBLER_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" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 // Accumulator. | 54 // Accumulator. |
55 Node* GetAccumulator(); | 55 Node* GetAccumulator(); |
56 void SetAccumulator(Node* value); | 56 void SetAccumulator(Node* value); |
57 | 57 |
58 // Context. | 58 // Context. |
59 Node* GetContext(); | 59 Node* GetContext(); |
60 void SetContext(Node* value); | 60 void SetContext(Node* value); |
61 | 61 |
62 // Loads from and stores to the interpreter register file. | 62 // Loads from and stores to the interpreter register file. |
| 63 Node* LoadRegister(int offset); |
63 Node* LoadRegister(interpreter::Register reg); | 64 Node* LoadRegister(interpreter::Register reg); |
64 Node* LoadRegister(Node* reg_index); | 65 Node* LoadRegister(Node* reg_index); |
| 66 Node* StoreRegister(Node* value, int offset); |
| 67 Node* StoreRegister(Node* value, interpreter::Register reg); |
65 Node* StoreRegister(Node* value, Node* reg_index); | 68 Node* StoreRegister(Node* value, Node* reg_index); |
66 | 69 |
67 // Returns the location in memory of the register |reg_index| in the | 70 // Returns the location in memory of the register |reg_index| in the |
68 // interpreter register file. | 71 // interpreter register file. |
69 Node* RegisterLocation(Node* reg_index); | 72 Node* RegisterLocation(Node* reg_index); |
70 | 73 |
71 // Constants. | 74 // Constants. |
72 Node* Int32Constant(int value); | 75 Node* Int32Constant(int value); |
73 Node* IntPtrConstant(intptr_t value); | 76 Node* IntPtrConstant(intptr_t value); |
74 Node* NumberConstant(double value); | 77 Node* NumberConstant(double value); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // |constructor| for the new keyword, but differs for the super | 111 // |constructor| for the new keyword, but differs for the super |
109 // keyword. | 112 // keyword. |
110 Node* CallConstruct(Node* new_target, Node* constructor, Node* first_arg, | 113 Node* CallConstruct(Node* new_target, Node* constructor, Node* first_arg, |
111 Node* arg_count); | 114 Node* arg_count); |
112 | 115 |
113 // Call JSFunction or Callable |function| with |arg_count| | 116 // Call JSFunction or Callable |function| with |arg_count| |
114 // arguments (not including receiver) and the first argument | 117 // arguments (not including receiver) and the first argument |
115 // located at |first_arg|. | 118 // located at |first_arg|. |
116 Node* CallJS(Node* function, Node* first_arg, Node* arg_count); | 119 Node* CallJS(Node* function, Node* first_arg, Node* arg_count); |
117 | 120 |
| 121 // Specifies whether the current accumulator will be clobbered or saved |
| 122 // across a call. |
| 123 enum class SaveAccumulatorMode { kClobberAccumulator, kSaveAccumulator }; |
| 124 |
118 // Call an IC code stub. | 125 // Call an IC code stub. |
119 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node* arg1, | 126 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node* arg1, |
120 Node* arg2, Node* arg3); | 127 Node* arg2, Node* arg3, |
| 128 SaveAccumulatorMode save_accum = |
| 129 SaveAccumulatorMode::kClobberAccumulator); |
121 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node* arg1, | 130 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node* arg1, |
122 Node* arg2, Node* arg3, Node* arg4); | 131 Node* arg2, Node* arg3, Node* arg4, |
| 132 SaveAccumulatorMode save_accum = |
| 133 SaveAccumulatorMode::kClobberAccumulator); |
123 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node* arg1, | 134 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node* arg1, |
124 Node* arg2, Node* arg3, Node* arg4, Node* arg5); | 135 Node* arg2, Node* arg3, Node* arg4, Node* arg5, |
| 136 SaveAccumulatorMode save_accum = |
| 137 SaveAccumulatorMode::kClobberAccumulator); |
125 | 138 |
126 // Call runtime function. | 139 // Call runtime function. |
127 Node* CallRuntime(Node* function_id, Node* first_arg, Node* arg_count); | 140 Node* CallRuntime(Node* function_id, Node* first_arg, Node* arg_count, |
128 Node* CallRuntime(Runtime::FunctionId function_id, Node* arg1); | 141 SaveAccumulatorMode save_accum = |
129 Node* CallRuntime(Runtime::FunctionId function_id, Node* arg1, Node* arg2); | 142 SaveAccumulatorMode::kClobberAccumulator); |
| 143 Node* CallRuntime(Runtime::FunctionId function_id, Node* arg1, |
| 144 SaveAccumulatorMode save_accum = |
| 145 SaveAccumulatorMode::kClobberAccumulator); |
130 Node* CallRuntime(Runtime::FunctionId function_id, Node* arg1, Node* arg2, | 146 Node* CallRuntime(Runtime::FunctionId function_id, Node* arg1, Node* arg2, |
131 Node* arg3, Node* arg4); | 147 SaveAccumulatorMode save_accum = |
| 148 SaveAccumulatorMode::kClobberAccumulator); |
| 149 Node* CallRuntime(Runtime::FunctionId function_id, Node* arg1, Node* arg2, |
| 150 Node* arg3, Node* arg4, |
| 151 SaveAccumulatorMode save_accum = |
| 152 SaveAccumulatorMode::kClobberAccumulator); |
132 | 153 |
133 // Jump relative to the current bytecode by |jump_offset|. | 154 // Jump relative to the current bytecode by |jump_offset|. |
134 void Jump(Node* jump_offset); | 155 void Jump(Node* jump_offset); |
135 | 156 |
136 // Jump relative to the current bytecode by |jump_offset| if the | 157 // Jump relative to the current bytecode by |jump_offset| if the |
137 // word values |lhs| and |rhs| are equal. | 158 // word values |lhs| and |rhs| are equal. |
138 void JumpIfWordEqual(Node* lhs, Node* rhs, Node* jump_offset); | 159 void JumpIfWordEqual(Node* lhs, Node* rhs, Node* jump_offset); |
139 | 160 |
140 // Returns from the function. | 161 // Returns from the function. |
141 void Return(); | 162 void Return(); |
(...skipping 14 matching lines...) Expand all Loading... |
156 private: | 177 private: |
157 // Returns a raw pointer to start of the register file on the stack. | 178 // Returns a raw pointer to start of the register file on the stack. |
158 Node* RegisterFileRawPointer(); | 179 Node* RegisterFileRawPointer(); |
159 // Returns a tagged pointer to the current function's BytecodeArray object. | 180 // Returns a tagged pointer to the current function's BytecodeArray object. |
160 Node* BytecodeArrayTaggedPointer(); | 181 Node* BytecodeArrayTaggedPointer(); |
161 // Returns the offset from the BytecodeArrayPointer of the current bytecode. | 182 // Returns the offset from the BytecodeArrayPointer of the current bytecode. |
162 Node* BytecodeOffset(); | 183 Node* BytecodeOffset(); |
163 // Returns a raw pointer to first entry in the interpreter dispatch table. | 184 // Returns a raw pointer to first entry in the interpreter dispatch table. |
164 Node* DispatchTableRawPointer(); | 185 Node* DispatchTableRawPointer(); |
165 | 186 |
| 187 // Saves and restores interpreter parameter registers when performing a call |
| 188 // to avoid Turbofan explicitly spilling them to the stack. The accumulator |
| 189 // can be saved and restored if save_accumulator_mode is kSaveAccumulator, |
| 190 // otherwise it will be clobbered by the call. |
| 191 void CallPrologue(SaveAccumulatorMode save_accumulator_mode); |
| 192 void CallEpilogue(SaveAccumulatorMode save_accumulator_mode); |
| 193 |
166 // Returns the offset of register |index| relative to RegisterFilePointer(). | 194 // Returns the offset of register |index| relative to RegisterFilePointer(). |
167 Node* RegisterFrameOffset(Node* index); | 195 Node* RegisterFrameOffset(Node* index); |
168 | 196 |
169 Node* SmiShiftBitsConstant(); | 197 Node* SmiShiftBitsConstant(); |
170 Node* BytecodeOperand(int operand_index); | 198 Node* BytecodeOperand(int operand_index); |
171 Node* BytecodeOperandSignExtended(int operand_index); | 199 Node* BytecodeOperandSignExtended(int operand_index); |
172 Node* BytecodeOperandShort(int operand_index); | 200 Node* BytecodeOperandShort(int operand_index); |
173 | 201 |
174 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 202 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args, |
175 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node** args); | 203 SaveAccumulatorMode save_accum); |
176 Node* CallJSBuiltin(int context_index, Node* receiver, Node** js_args, | 204 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node** args, |
177 int js_arg_count); | 205 SaveAccumulatorMode save_accum); |
178 | 206 |
179 // Returns BytecodeOffset() advanced by delta bytecodes. Note: this does not | 207 // Returns BytecodeOffset() advanced by delta bytecodes. Note: this does not |
180 // update BytecodeOffset() itself. | 208 // update BytecodeOffset() itself. |
181 Node* Advance(int delta); | 209 Node* Advance(int delta); |
182 Node* Advance(Node* delta); | 210 Node* Advance(Node* delta); |
183 | 211 |
184 // Starts next instruction dispatch at |new_bytecode_offset|. | 212 // Starts next instruction dispatch at |new_bytecode_offset|. |
185 void DispatchTo(Node* new_bytecode_offset); | 213 void DispatchTo(Node* new_bytecode_offset); |
186 | 214 |
187 // Abort operations for debug code. | 215 // Abort operations for debug code. |
188 void AbortIfWordNotEqual(Node* lhs, Node* rhs, BailoutReason bailout_reason); | 216 void AbortIfWordNotEqual(Node* lhs, Node* rhs, BailoutReason bailout_reason); |
189 | 217 |
190 // Private helpers which delegate to RawMachineAssembler. | 218 // Private helpers which delegate to RawMachineAssembler. |
191 Isolate* isolate(); | 219 Isolate* isolate(); |
192 Zone* zone(); | 220 Zone* zone(); |
193 | 221 |
194 interpreter::Bytecode bytecode_; | 222 interpreter::Bytecode bytecode_; |
195 base::SmartPointer<RawMachineAssembler> raw_assembler_; | 223 base::SmartPointer<RawMachineAssembler> raw_assembler_; |
| 224 |
196 Node* accumulator_; | 225 Node* accumulator_; |
| 226 Node* bytecode_offset_; |
197 Node* context_; | 227 Node* context_; |
| 228 |
198 bool code_generated_; | 229 bool code_generated_; |
199 | 230 |
200 DISALLOW_COPY_AND_ASSIGN(InterpreterAssembler); | 231 DISALLOW_COPY_AND_ASSIGN(InterpreterAssembler); |
201 }; | 232 }; |
202 | 233 |
203 } // namespace compiler | 234 } // namespace compiler |
204 } // namespace internal | 235 } // namespace internal |
205 } // namespace v8 | 236 } // namespace v8 |
206 | 237 |
207 #endif // V8_COMPILER_INTERPRETER_ASSEMBLER_H_ | 238 #endif // V8_COMPILER_INTERPRETER_ASSEMBLER_H_ |
OLD | NEW |