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_INTERPRETER_INTERPRETER_ASSEMBLER_H_ | 5 #ifndef V8_INTERPRETER_INTERPRETER_ASSEMBLER_H_ |
6 #define V8_INTERPRETER_INTERPRETER_ASSEMBLER_H_ | 6 #define V8_INTERPRETER_INTERPRETER_ASSEMBLER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/builtins/builtins.h" | 9 #include "src/builtins/builtins.h" |
10 #include "src/code-stub-assembler.h" | 10 #include "src/code-stub-assembler.h" |
11 #include "src/frames.h" | 11 #include "src/frames.h" |
12 #include "src/globals.h" | 12 #include "src/globals.h" |
13 #include "src/interpreter/bytecode-register.h" | 13 #include "src/interpreter/bytecode-register.h" |
14 #include "src/interpreter/bytecodes.h" | 14 #include "src/interpreter/bytecodes.h" |
15 #include "src/runtime/runtime.h" | 15 #include "src/runtime/runtime.h" |
16 | 16 |
17 namespace v8 { | 17 namespace v8 { |
18 namespace internal { | 18 namespace internal { |
19 namespace interpreter { | 19 namespace interpreter { |
20 | 20 |
21 class V8_EXPORT_PRIVATE InterpreterAssembler : public CodeStubAssembler { | 21 class V8_EXPORT_PRIVATE InterpreterAssembler : public CodeStubAssembler { |
22 public: | 22 public: |
23 InterpreterAssembler(compiler::CodeAssemblerState* state, Bytecode bytecode, | 23 InterpreterAssembler(compiler::CodeAssemblerState* state, Bytecode bytecode, |
24 OperandScale operand_scale); | 24 OperandScale operand_scale); |
25 virtual ~InterpreterAssembler(); | 25 virtual ~InterpreterAssembler(); |
26 | 26 |
27 // Returns the count immediate for bytecode operand |operand_index| in the | 27 // Returns the 32-bit unsigned count immediate for bytecode operand |
| 28 // |operand_index| in the current bytecode. |
| 29 compiler::Node* BytecodeOperandCount(int operand_index); |
| 30 // Returns the 32-bit unsigned flag for bytecode operand |operand_index| |
| 31 // in the current bytecode. |
| 32 compiler::Node* BytecodeOperandFlag(int operand_index); |
| 33 // Returns the 32-bit zero-extended index immediate for bytecode operand |
| 34 // |operand_index| in the current bytecode. |
| 35 compiler::Node* BytecodeOperandIdx(int operand_index); |
| 36 // Returns the smi index immediate for bytecode operand |operand_index| |
| 37 // in the current bytecode. |
| 38 compiler::Node* BytecodeOperandIdxSmi(int operand_index); |
| 39 // Returns the 32-bit unsigned immediate for bytecode operand |operand_index| |
| 40 // in the current bytecode. |
| 41 compiler::Node* BytecodeOperandUImm(int operand_index); |
| 42 // Returns the 32-bit signed immediate for bytecode operand |operand_index| |
| 43 // in the current bytecode. |
| 44 compiler::Node* BytecodeOperandImm(int operand_index); |
| 45 // Returns the word-size signed immediate for bytecode operand |operand_index| |
| 46 // in the current bytecode. |
| 47 compiler::Node* BytecodeOperandImmIntPtr(int operand_index); |
| 48 // Returns the smi immediate for bytecode operand |operand_index| in the |
28 // current bytecode. | 49 // current bytecode. |
29 compiler::Node* BytecodeOperandCount(int operand_index); | 50 compiler::Node* BytecodeOperandImmSmi(int operand_index); |
30 // Returns the 8-bit flag for bytecode operand |operand_index| in the | 51 // Returns the word-size sign-extended register index for bytecode operand |
31 // current bytecode. | 52 // |operand_index| in the current bytecode. |
32 compiler::Node* BytecodeOperandFlag(int operand_index); | |
33 // Returns the index immediate for bytecode operand |operand_index| in the | |
34 // current bytecode. | |
35 compiler::Node* BytecodeOperandIdx(int operand_index); | |
36 // Returns the UImm8 immediate for bytecode operand |operand_index| in the | |
37 // current bytecode. | |
38 compiler::Node* BytecodeOperandUImm(int operand_index); | |
39 // Returns the Imm8 immediate for bytecode operand |operand_index| in the | |
40 // current bytecode. | |
41 compiler::Node* BytecodeOperandImm(int operand_index); | |
42 // Returns the register index for bytecode operand |operand_index| in the | |
43 // current bytecode. | |
44 compiler::Node* BytecodeOperandReg(int operand_index); | 53 compiler::Node* BytecodeOperandReg(int operand_index); |
45 // Returns the runtime id immediate for bytecode operand | 54 // Returns the 32-bit unsigned runtime id immediate for bytecode operand |
46 // |operand_index| in the current bytecode. | 55 // |operand_index| in the current bytecode. |
47 compiler::Node* BytecodeOperandRuntimeId(int operand_index); | 56 compiler::Node* BytecodeOperandRuntimeId(int operand_index); |
48 // Returns the intrinsic id immediate for bytecode operand | 57 // Returns the 32-bit unsigned intrinsic id immediate for bytecode operand |
49 // |operand_index| in the current bytecode. | 58 // |operand_index| in the current bytecode. |
50 compiler::Node* BytecodeOperandIntrinsicId(int operand_index); | 59 compiler::Node* BytecodeOperandIntrinsicId(int operand_index); |
51 | 60 |
52 // Accumulator. | 61 // Accumulator. |
53 compiler::Node* GetAccumulator(); | 62 compiler::Node* GetAccumulator(); |
54 void SetAccumulator(compiler::Node* value); | 63 void SetAccumulator(compiler::Node* value); |
55 | 64 |
56 // Context. | 65 // Context. |
57 compiler::Node* GetContext(); | 66 compiler::Node* GetContext(); |
58 void SetContext(compiler::Node* value); | 67 void SetContext(compiler::Node* value); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // frame when performing a call. | 220 // frame when performing a call. |
212 void CallPrologue() override; | 221 void CallPrologue() override; |
213 void CallEpilogue() override; | 222 void CallEpilogue() override; |
214 | 223 |
215 // Increment the dispatch counter for the (current, next) bytecode pair. | 224 // Increment the dispatch counter for the (current, next) bytecode pair. |
216 void TraceBytecodeDispatch(compiler::Node* target_index); | 225 void TraceBytecodeDispatch(compiler::Node* target_index); |
217 | 226 |
218 // Traces the current bytecode by calling |function_id|. | 227 // Traces the current bytecode by calling |function_id|. |
219 void TraceBytecode(Runtime::FunctionId function_id); | 228 void TraceBytecode(Runtime::FunctionId function_id); |
220 | 229 |
221 // Updates the bytecode array's interrupt budget by |weight| and calls | 230 // Updates the bytecode array's interrupt budget by a 32-bit signed |weight| |
222 // Runtime::kInterrupt if counter reaches zero. | 231 // and calls Runtime::kInterrupt if counter reaches zero. |
223 void UpdateInterruptBudget(compiler::Node* weight); | 232 void UpdateInterruptBudget(compiler::Node* weight); |
224 | 233 |
225 // Returns the offset of register |index| relative to RegisterFilePointer(). | 234 // Returns the offset of register |index| relative to RegisterFilePointer(). |
226 compiler::Node* RegisterFrameOffset(compiler::Node* index); | 235 compiler::Node* RegisterFrameOffset(compiler::Node* index); |
227 | 236 |
228 // Returns the offset of an operand relative to the current bytecode offset. | 237 // Returns the offset of an operand relative to the current bytecode offset. |
229 compiler::Node* OperandOffset(int operand_index); | 238 compiler::Node* OperandOffset(int operand_index); |
230 | 239 |
231 // Returns a value built from an sequence of bytes in the bytecode | 240 // Returns a value built from an sequence of bytes in the bytecode |
232 // array starting at |relative_offset| from the current bytecode. | 241 // array starting at |relative_offset| from the current bytecode. |
233 // The |result_type| determines the size and signedness. of the | 242 // The |result_type| determines the size and signedness. of the |
234 // value read. This method should only be used on architectures that | 243 // value read. This method should only be used on architectures that |
235 // do not support unaligned memory accesses. | 244 // do not support unaligned memory accesses. |
236 compiler::Node* BytecodeOperandReadUnaligned(int relative_offset, | 245 compiler::Node* BytecodeOperandReadUnaligned(int relative_offset, |
237 MachineType result_type); | 246 MachineType result_type); |
238 | 247 |
| 248 // Returns zero- or sign-extended to word32 value of the operand. |
239 compiler::Node* BytecodeOperandUnsignedByte(int operand_index); | 249 compiler::Node* BytecodeOperandUnsignedByte(int operand_index); |
240 compiler::Node* BytecodeOperandSignedByte(int operand_index); | 250 compiler::Node* BytecodeOperandSignedByte(int operand_index); |
241 compiler::Node* BytecodeOperandUnsignedShort(int operand_index); | 251 compiler::Node* BytecodeOperandUnsignedShort(int operand_index); |
242 compiler::Node* BytecodeOperandSignedShort(int operand_index); | 252 compiler::Node* BytecodeOperandSignedShort(int operand_index); |
243 compiler::Node* BytecodeOperandUnsignedQuad(int operand_index); | 253 compiler::Node* BytecodeOperandUnsignedQuad(int operand_index); |
244 compiler::Node* BytecodeOperandSignedQuad(int operand_index); | 254 compiler::Node* BytecodeOperandSignedQuad(int operand_index); |
245 | 255 |
| 256 // Returns zero- or sign-extended to word32 value of the operand of |
| 257 // given size. |
246 compiler::Node* BytecodeSignedOperand(int operand_index, | 258 compiler::Node* BytecodeSignedOperand(int operand_index, |
247 OperandSize operand_size); | 259 OperandSize operand_size); |
248 compiler::Node* BytecodeUnsignedOperand(int operand_index, | 260 compiler::Node* BytecodeUnsignedOperand(int operand_index, |
249 OperandSize operand_size); | 261 OperandSize operand_size); |
250 | 262 |
251 // Jump relative to the current bytecode by |jump_offset| if the | 263 // Jump relative to the current bytecode by |jump_offset| if the |
252 // |condition| is true. Helper function for JumpIfWordEqual and | 264 // |condition| is true. Helper function for JumpIfWordEqual and |
253 // JumpIfWordNotEqual. | 265 // JumpIfWordNotEqual. |
254 void JumpConditional(compiler::Node* condition, compiler::Node* jump_offset); | 266 void JumpConditional(compiler::Node* condition, compiler::Node* jump_offset); |
255 | 267 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 compiler::Node* stack_pointer_before_call_; | 312 compiler::Node* stack_pointer_before_call_; |
301 | 313 |
302 DISALLOW_COPY_AND_ASSIGN(InterpreterAssembler); | 314 DISALLOW_COPY_AND_ASSIGN(InterpreterAssembler); |
303 }; | 315 }; |
304 | 316 |
305 } // namespace interpreter | 317 } // namespace interpreter |
306 } // namespace internal | 318 } // namespace internal |
307 } // namespace v8 | 319 } // namespace v8 |
308 | 320 |
309 #endif // V8_INTERPRETER_INTERPRETER_ASSEMBLER_H_ | 321 #endif // V8_INTERPRETER_INTERPRETER_ASSEMBLER_H_ |
OLD | NEW |