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 "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/interpreter/bytecode-array-writer.h" | 9 #include "src/interpreter/bytecode-array-writer.h" |
10 #include "src/interpreter/bytecode-register-allocator.h" | 10 #include "src/interpreter/bytecode-register-allocator.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 TemporaryRegisterAllocator* temporary_register_allocator() { | 268 TemporaryRegisterAllocator* temporary_register_allocator() { |
269 return &temporary_allocator_; | 269 return &temporary_allocator_; |
270 } | 270 } |
271 const TemporaryRegisterAllocator* temporary_register_allocator() const { | 271 const TemporaryRegisterAllocator* temporary_register_allocator() const { |
272 return &temporary_allocator_; | 272 return &temporary_allocator_; |
273 } | 273 } |
274 Zone* zone() const { return zone_; } | 274 Zone* zone() const { return zone_; } |
275 | 275 |
276 void EnsureReturn(); | 276 void EnsureReturn(); |
277 | 277 |
278 static uint32_t RegisterOperand(Register reg); | 278 static uint32_t RegisterOperand(Register reg) { |
279 static Register RegisterFromOperand(uint32_t operand); | 279 return static_cast<uint32_t>(reg.ToOperand()); |
280 static uint32_t SignedOperand(int value, OperandSize size); | 280 } |
281 static uint32_t UnsignedOperand(int value); | 281 |
282 static uint32_t UnsignedOperand(size_t value); | 282 static uint32_t SignedOperand(int value) { |
| 283 return static_cast<uint32_t>(value); |
| 284 } |
| 285 |
| 286 static uint32_t UnsignedOperand(int value) { |
| 287 DCHECK_GE(value, 0); |
| 288 return static_cast<uint32_t>(value); |
| 289 } |
| 290 |
| 291 static uint32_t UnsignedOperand(size_t value) { |
| 292 DCHECK_LE(value, kMaxUInt32); |
| 293 return static_cast<uint32_t>(value); |
| 294 } |
283 | 295 |
284 private: | 296 private: |
285 friend class BytecodeRegisterAllocator; | 297 friend class BytecodeRegisterAllocator; |
286 | 298 |
287 static Bytecode BytecodeForBinaryOperation(Token::Value op); | 299 static Bytecode BytecodeForBinaryOperation(Token::Value op); |
288 static Bytecode BytecodeForCountOperation(Token::Value op); | 300 static Bytecode BytecodeForCountOperation(Token::Value op); |
289 static Bytecode BytecodeForCompareOperation(Token::Value op); | 301 static Bytecode BytecodeForCompareOperation(Token::Value op); |
290 static Bytecode BytecodeForStoreNamedProperty(LanguageMode language_mode); | 302 static Bytecode BytecodeForStoreNamedProperty(LanguageMode language_mode); |
291 static Bytecode BytecodeForStoreKeyedProperty(LanguageMode language_mode); | 303 static Bytecode BytecodeForStoreKeyedProperty(LanguageMode language_mode); |
292 static Bytecode BytecodeForLoadGlobal(TypeofMode typeof_mode); | 304 static Bytecode BytecodeForLoadGlobal(TypeofMode typeof_mode); |
293 static Bytecode BytecodeForStoreGlobal(LanguageMode language_mode); | 305 static Bytecode BytecodeForStoreGlobal(LanguageMode language_mode); |
294 static Bytecode BytecodeForStoreLookupSlot(LanguageMode language_mode); | 306 static Bytecode BytecodeForStoreLookupSlot(LanguageMode language_mode); |
295 static Bytecode BytecodeForCreateArguments(CreateArgumentsType type); | 307 static Bytecode BytecodeForCreateArguments(CreateArgumentsType type); |
296 static Bytecode BytecodeForDelete(LanguageMode language_mode); | 308 static Bytecode BytecodeForDelete(LanguageMode language_mode); |
297 static Bytecode BytecodeForCall(TailCallMode tail_call_mode); | 309 static Bytecode BytecodeForCall(TailCallMode tail_call_mode); |
298 | 310 |
| 311 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
| 312 uint32_t operand2, uint32_t operand3); |
| 313 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
| 314 uint32_t operand2); |
| 315 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); |
| 316 void Output(Bytecode bytecode, uint32_t operand0); |
299 void Output(Bytecode bytecode); | 317 void Output(Bytecode bytecode); |
300 void OutputScaled(Bytecode bytecode, OperandScale operand_scale, | |
301 uint32_t operand0, uint32_t operand1, uint32_t operand2, | |
302 uint32_t operand3); | |
303 void OutputScaled(Bytecode bytecode, OperandScale operand_scale, | |
304 uint32_t operand0, uint32_t operand1, uint32_t operand2); | |
305 void OutputScaled(Bytecode bytecode, OperandScale operand_scale, | |
306 uint32_t operand0, uint32_t operand1); | |
307 void OutputScaled(Bytecode bytecode, OperandScale operand_scale, | |
308 uint32_t operand0); | |
309 | 318 |
310 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, | 319 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, |
311 BytecodeLabel* label); | 320 BytecodeLabel* label); |
312 | 321 |
313 | 322 bool RegisterIsValid(Register reg) const; |
314 bool OperandIsValid(Bytecode bytecode, OperandScale operand_scale, | 323 bool OperandsAreValid(Bytecode bytecode, int operand_count, |
315 int operand_index, uint32_t operand_value) const; | 324 uint32_t operand0 = 0, uint32_t operand1 = 0, |
316 bool RegisterIsValid(Register reg, OperandSize reg_size) const; | 325 uint32_t operand2 = 0, uint32_t operand3 = 0) const; |
317 | 326 |
318 // Attach latest source position to |node|. | 327 // Attach latest source position to |node|. |
319 void AttachSourceInfo(BytecodeNode* node); | 328 void AttachSourceInfo(BytecodeNode* node); |
320 | 329 |
321 // Gets a constant pool entry for the |object|. | 330 // Gets a constant pool entry for the |object|. |
322 size_t GetConstantPoolEntry(Handle<Object> object); | 331 size_t GetConstantPoolEntry(Handle<Object> object); |
323 | 332 |
324 // Not implemented as the illegal bytecode is used inside internally | 333 // Not implemented as the illegal bytecode is used inside internally |
325 // to indicate a bytecode field is not valid or an error has occured | 334 // to indicate a bytecode field is not valid or an error has occured |
326 // during bytecode generation. | 335 // during bytecode generation. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 BytecodeSourceInfo latest_source_info_; | 368 BytecodeSourceInfo latest_source_info_; |
360 | 369 |
361 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); | 370 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); |
362 }; | 371 }; |
363 | 372 |
364 } // namespace interpreter | 373 } // namespace interpreter |
365 } // namespace internal | 374 } // namespace internal |
366 } // namespace v8 | 375 } // namespace v8 |
367 | 376 |
368 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 377 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |