| 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/base/smart-pointers.h" | 9 #include "src/base/smart-pointers.h" |
| 10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
| 11 #include "src/compiler/code-stub-assembler.h" | 11 #include "src/compiler/code-stub-assembler.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/runtime/runtime.h" | 14 #include "src/runtime/runtime.h" |
| 15 | 15 |
| 16 namespace v8 { | 16 namespace v8 { |
| 17 namespace internal { | 17 namespace internal { |
| 18 namespace interpreter { | 18 namespace interpreter { |
| 19 | 19 |
| 20 class InterpreterAssembler : public compiler::CodeStubAssembler { | 20 class InterpreterAssembler : public compiler::CodeStubAssembler { |
| 21 public: | 21 public: |
| 22 InterpreterAssembler(Isolate* isolate, Zone* zone, Bytecode bytecode); | 22 InterpreterAssembler(Isolate* isolate, Zone* zone, Bytecode bytecode, |
| 23 OperandScale operand_scale); |
| 23 virtual ~InterpreterAssembler(); | 24 virtual ~InterpreterAssembler(); |
| 24 | 25 |
| 25 // Returns the count immediate for bytecode operand |operand_index| in the | 26 // Returns the count immediate for bytecode operand |operand_index| in the |
| 26 // current bytecode. | 27 // current bytecode. |
| 27 compiler::Node* BytecodeOperandCount(int operand_index); | 28 compiler::Node* BytecodeOperandCount(int operand_index); |
| 29 // Returns the 8-bit flag for bytecode operand |operand_index| in the |
| 30 // current bytecode. |
| 31 compiler::Node* BytecodeOperandFlag(int operand_index); |
| 28 // Returns the index immediate for bytecode operand |operand_index| in the | 32 // Returns the index immediate for bytecode operand |operand_index| in the |
| 29 // current bytecode. | 33 // current bytecode. |
| 30 compiler::Node* BytecodeOperandIdx(int operand_index); | 34 compiler::Node* BytecodeOperandIdx(int operand_index); |
| 31 // Returns the Imm8 immediate for bytecode operand |operand_index| in the | 35 // Returns the Imm8 immediate for bytecode operand |operand_index| in the |
| 32 // current bytecode. | 36 // current bytecode. |
| 33 compiler::Node* BytecodeOperandImm(int operand_index); | 37 compiler::Node* BytecodeOperandImm(int operand_index); |
| 34 // Returns the register index for bytecode operand |operand_index| in the | 38 // Returns the register index for bytecode operand |operand_index| in the |
| 35 // current bytecode. | 39 // current bytecode. |
| 36 compiler::Node* BytecodeOperandReg(int operand_index); | 40 compiler::Node* BytecodeOperandReg(int operand_index); |
| 41 // Returns the runtime id immediate for bytecode operand |
| 42 // |operand_index| in the current bytecode. |
| 43 compiler::Node* BytecodeOperandRuntimeId(int operand_index); |
| 37 | 44 |
| 38 // Accumulator. | 45 // Accumulator. |
| 39 compiler::Node* GetAccumulator(); | 46 compiler::Node* GetAccumulator(); |
| 40 void SetAccumulator(compiler::Node* value); | 47 void SetAccumulator(compiler::Node* value); |
| 41 | 48 |
| 42 // Context. | 49 // Context. |
| 43 compiler::Node* GetContext(); | 50 compiler::Node* GetContext(); |
| 44 void SetContext(compiler::Node* value); | 51 void SetContext(compiler::Node* value); |
| 45 | 52 |
| 46 // Loads from and stores to the interpreter register file. | 53 // Loads from and stores to the interpreter register file. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // Dispatch to the bytecode. | 136 // Dispatch to the bytecode. |
| 130 void Dispatch(); | 137 void Dispatch(); |
| 131 | 138 |
| 132 // Dispatch to bytecode handler. | 139 // Dispatch to bytecode handler. |
| 133 void DispatchToBytecodeHandler(compiler::Node* handler, | 140 void DispatchToBytecodeHandler(compiler::Node* handler, |
| 134 compiler::Node* bytecode_offset); | 141 compiler::Node* bytecode_offset); |
| 135 void DispatchToBytecodeHandler(compiler::Node* handler) { | 142 void DispatchToBytecodeHandler(compiler::Node* handler) { |
| 136 DispatchToBytecodeHandler(handler, BytecodeOffset()); | 143 DispatchToBytecodeHandler(handler, BytecodeOffset()); |
| 137 } | 144 } |
| 138 | 145 |
| 146 // Dispatch bytecode as wide operand variant. |
| 147 void DispatchWide(OperandScale operand_scale); |
| 148 |
| 139 // Abort with the given bailout reason. | 149 // Abort with the given bailout reason. |
| 140 void Abort(BailoutReason bailout_reason); | 150 void Abort(BailoutReason bailout_reason); |
| 141 | 151 |
| 142 protected: | 152 protected: |
| 143 static bool TargetSupportsUnalignedAccess(); | 153 static bool TargetSupportsUnalignedAccess(); |
| 144 | 154 |
| 145 private: | 155 private: |
| 146 // Returns a raw pointer to start of the register file on the stack. | 156 // Returns a raw pointer to start of the register file on the stack. |
| 147 compiler::Node* RegisterFileRawPointer(); | 157 compiler::Node* RegisterFileRawPointer(); |
| 148 // Returns a tagged pointer to the current function's BytecodeArray object. | 158 // Returns a tagged pointer to the current function's BytecodeArray object. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 160 // Traces the current bytecode by calling |function_id|. | 170 // Traces the current bytecode by calling |function_id|. |
| 161 void TraceBytecode(Runtime::FunctionId function_id); | 171 void TraceBytecode(Runtime::FunctionId function_id); |
| 162 | 172 |
| 163 // Updates the bytecode array's interrupt budget by |weight| and calls | 173 // Updates the bytecode array's interrupt budget by |weight| and calls |
| 164 // Runtime::kInterrupt if counter reaches zero. | 174 // Runtime::kInterrupt if counter reaches zero. |
| 165 void UpdateInterruptBudget(compiler::Node* weight); | 175 void UpdateInterruptBudget(compiler::Node* weight); |
| 166 | 176 |
| 167 // Returns the offset of register |index| relative to RegisterFilePointer(). | 177 // Returns the offset of register |index| relative to RegisterFilePointer(). |
| 168 compiler::Node* RegisterFrameOffset(compiler::Node* index); | 178 compiler::Node* RegisterFrameOffset(compiler::Node* index); |
| 169 | 179 |
| 170 compiler::Node* BytecodeOperand(int operand_index); | 180 // Returns the offset of an operand relative to the current bytecode offset. |
| 171 compiler::Node* BytecodeOperandSignExtended(int operand_index); | 181 compiler::Node* OperandOffset(int operand_index); |
| 172 compiler::Node* BytecodeOperandShort(int operand_index); | 182 |
| 173 compiler::Node* BytecodeOperandShortSignExtended(int operand_index); | 183 // Returns a value built from an sequence of bytes in the bytecode |
| 184 // array starting at |relative_offset| from the current bytecode. |
| 185 // The |result_type| determines the size and signedness. of the |
| 186 // value read. This method should only be used on architectures that |
| 187 // do not support unaligned memory accesses. |
| 188 compiler::Node* BytecodeOperandReadUnaligned(int relative_offset, |
| 189 MachineType result_type); |
| 190 |
| 191 compiler::Node* BytecodeOperandUnsignedByte(int operand_index); |
| 192 compiler::Node* BytecodeOperandSignedByte(int operand_index); |
| 193 compiler::Node* BytecodeOperandUnsignedShort(int operand_index); |
| 194 compiler::Node* BytecodeOperandSignedShort(int operand_index); |
| 195 compiler::Node* BytecodeOperandUnsignedQuad(int operand_index); |
| 196 compiler::Node* BytecodeOperandSignedQuad(int operand_index); |
| 197 |
| 198 compiler::Node* BytecodeSignedOperand(int operand_index, |
| 199 OperandSize operand_size); |
| 200 compiler::Node* BytecodeUnsignedOperand(int operand_index, |
| 201 OperandSize operand_size); |
| 174 | 202 |
| 175 // Returns BytecodeOffset() advanced by delta bytecodes. Note: this does not | 203 // Returns BytecodeOffset() advanced by delta bytecodes. Note: this does not |
| 176 // update BytecodeOffset() itself. | 204 // update BytecodeOffset() itself. |
| 177 compiler::Node* Advance(int delta); | 205 compiler::Node* Advance(int delta); |
| 178 compiler::Node* Advance(compiler::Node* delta); | 206 compiler::Node* Advance(compiler::Node* delta); |
| 179 | 207 |
| 180 // Starts next instruction dispatch at |new_bytecode_offset|. | 208 // Starts next instruction dispatch at |new_bytecode_offset|. |
| 181 void DispatchTo(compiler::Node* new_bytecode_offset); | 209 void DispatchTo(compiler::Node* new_bytecode_offset); |
| 182 | 210 |
| 183 // Abort operations for debug code. | 211 // Abort operations for debug code. |
| 184 void AbortIfWordNotEqual(compiler::Node* lhs, compiler::Node* rhs, | 212 void AbortIfWordNotEqual(compiler::Node* lhs, compiler::Node* rhs, |
| 185 BailoutReason bailout_reason); | 213 BailoutReason bailout_reason); |
| 186 | 214 |
| 215 OperandScale operand_scale() const { return operand_scale_; } |
| 216 |
| 187 Bytecode bytecode_; | 217 Bytecode bytecode_; |
| 218 OperandScale operand_scale_; |
| 188 CodeStubAssembler::Variable accumulator_; | 219 CodeStubAssembler::Variable accumulator_; |
| 189 CodeStubAssembler::Variable context_; | 220 CodeStubAssembler::Variable context_; |
| 190 CodeStubAssembler::Variable bytecode_array_; | 221 CodeStubAssembler::Variable bytecode_array_; |
| 191 | 222 |
| 192 bool disable_stack_check_across_call_; | 223 bool disable_stack_check_across_call_; |
| 193 compiler::Node* stack_pointer_before_call_; | 224 compiler::Node* stack_pointer_before_call_; |
| 194 | 225 |
| 195 DISALLOW_COPY_AND_ASSIGN(InterpreterAssembler); | 226 DISALLOW_COPY_AND_ASSIGN(InterpreterAssembler); |
| 196 }; | 227 }; |
| 197 | 228 |
| 198 } // namespace interpreter | 229 } // namespace interpreter |
| 199 } // namespace internal | 230 } // namespace internal |
| 200 } // namespace v8 | 231 } // namespace v8 |
| 201 | 232 |
| 202 #endif // V8_INTERPRETER_INTERPRETER_ASSEMBLER_H_ | 233 #endif // V8_INTERPRETER_INTERPRETER_ASSEMBLER_H_ |
| OLD | NEW |