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_BYTECODE_ARRAY_BUILDER_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "src/ast.h" | 10 #include "src/ast.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // applied to the constructor. | 142 // applied to the constructor. |
143 BytecodeArrayBuilder& New(Register constructor, Register first_arg, | 143 BytecodeArrayBuilder& New(Register constructor, Register first_arg, |
144 size_t arg_count); | 144 size_t arg_count); |
145 | 145 |
146 // Call the runtime function with |function_id|. The first argument should be | 146 // Call the runtime function with |function_id|. The first argument should be |
147 // in |first_arg| and all subsequent arguments should be in registers | 147 // in |first_arg| and all subsequent arguments should be in registers |
148 // <first_arg + 1> to <first_arg + 1 + arg_count>. | 148 // <first_arg + 1> to <first_arg + 1 + arg_count>. |
149 BytecodeArrayBuilder& CallRuntime(Runtime::FunctionId function_id, | 149 BytecodeArrayBuilder& CallRuntime(Runtime::FunctionId function_id, |
150 Register first_arg, size_t arg_count); | 150 Register first_arg, size_t arg_count); |
151 | 151 |
| 152 // Call the JS runtime function with |context_index|. The the receiver should |
| 153 // be in |receiver| and all subsequent arguments should be in registers |
| 154 // <receiver + 1> to <receiver + 1 + arg_count>. |
| 155 BytecodeArrayBuilder& CallJSRuntime(int context_index, Register receiver, |
| 156 size_t arg_count); |
| 157 |
152 // Operators (register holds the lhs value, accumulator holds the rhs value). | 158 // Operators (register holds the lhs value, accumulator holds the rhs value). |
153 BytecodeArrayBuilder& BinaryOperation(Token::Value binop, Register reg, | 159 BytecodeArrayBuilder& BinaryOperation(Token::Value binop, Register reg, |
154 Strength strength); | 160 Strength strength); |
155 | 161 |
156 // Count Operators (value stored in accumulator). | 162 // Count Operators (value stored in accumulator). |
157 BytecodeArrayBuilder& CountOperation(Token::Value op, Strength strength); | 163 BytecodeArrayBuilder& CountOperation(Token::Value op, Strength strength); |
158 | 164 |
159 // Unary Operators. | 165 // Unary Operators. |
160 BytecodeArrayBuilder& LogicalNot(); | 166 BytecodeArrayBuilder& LogicalNot(); |
161 BytecodeArrayBuilder& TypeOf(); | 167 BytecodeArrayBuilder& TypeOf(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 224 |
219 static bool FitsInIdx8Operand(int value); | 225 static bool FitsInIdx8Operand(int value); |
220 static bool FitsInIdx8Operand(size_t value); | 226 static bool FitsInIdx8Operand(size_t value); |
221 static bool FitsInImm8Operand(int value); | 227 static bool FitsInImm8Operand(int value); |
222 static bool FitsInIdx16Operand(int value); | 228 static bool FitsInIdx16Operand(int value); |
223 static bool FitsInIdx16Operand(size_t value); | 229 static bool FitsInIdx16Operand(size_t value); |
224 | 230 |
225 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); | 231 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); |
226 static Bytecode GetJumpWithToBoolean(Bytecode jump); | 232 static Bytecode GetJumpWithToBoolean(Bytecode jump); |
227 | 233 |
| 234 enum class RegisterValidityCheck { kCheckRegisters, kDontCheckRegisters }; |
| 235 |
228 template <size_t N> | 236 template <size_t N> |
229 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N])); | 237 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N], |
| 238 RegisterValidityCheck reg_check = |
| 239 RegisterValidityCheck::kCheckRegisters)); |
230 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, | 240 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
231 uint32_t operand2); | 241 uint32_t operand2, RegisterValidityCheck reg_check = |
232 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); | 242 RegisterValidityCheck::kCheckRegisters); |
233 void Output(Bytecode bytecode, uint32_t operand0); | 243 void Output( |
| 244 Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
| 245 RegisterValidityCheck reg_check = RegisterValidityCheck::kCheckRegisters); |
| 246 void Output( |
| 247 Bytecode bytecode, uint32_t operand0, |
| 248 RegisterValidityCheck reg_check = RegisterValidityCheck::kCheckRegisters); |
234 void Output(Bytecode bytecode); | 249 void Output(Bytecode bytecode); |
235 | 250 |
236 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, | 251 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, |
237 BytecodeLabel* label); | 252 BytecodeLabel* label); |
238 void PatchJump(const ZoneVector<uint8_t>::iterator& jump_target, | 253 void PatchJump(const ZoneVector<uint8_t>::iterator& jump_target, |
239 ZoneVector<uint8_t>::iterator jump_location); | 254 ZoneVector<uint8_t>::iterator jump_location); |
240 | 255 |
241 void EnsureReturn(); | 256 void EnsureReturn(); |
242 | 257 |
243 bool OperandIsValid(Bytecode bytecode, int operand_index, | 258 bool OperandIsValid(Bytecode bytecode, int operand_index, |
244 uint32_t operand_value) const; | 259 uint32_t operand_value, |
| 260 RegisterValidityCheck reg_check) const; |
245 bool LastBytecodeInSameBlock() const; | 261 bool LastBytecodeInSameBlock() const; |
246 | 262 |
247 bool NeedToBooleanCast(); | 263 bool NeedToBooleanCast(); |
248 | 264 |
249 int BorrowTemporaryRegister(); | 265 int BorrowTemporaryRegister(); |
250 void ReturnTemporaryRegister(int reg_index); | 266 void ReturnTemporaryRegister(int reg_index); |
251 int PrepareForConsecutiveTemporaryRegisters(size_t count); | 267 int PrepareForConsecutiveTemporaryRegisters(size_t count); |
252 void BorrowConsecutiveTemporaryRegister(int reg_index); | 268 void BorrowConsecutiveTemporaryRegister(int reg_index); |
253 bool TemporaryRegisterIsLive(Register reg) const; | 269 bool TemporaryRegisterIsLive(Register reg) const; |
254 | 270 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 360 |
345 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 361 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
346 }; | 362 }; |
347 | 363 |
348 | 364 |
349 } // namespace interpreter | 365 } // namespace interpreter |
350 } // namespace internal | 366 } // namespace internal |
351 } // namespace v8 | 367 } // namespace v8 |
352 | 368 |
353 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 369 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |