| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 // entry, so that it can be referenced by above exception handling support. | 288 // entry, so that it can be referenced by above exception handling support. |
| 289 int NewHandlerEntry() { return handler_table_builder()->NewHandlerEntry(); } | 289 int NewHandlerEntry() { return handler_table_builder()->NewHandlerEntry(); } |
| 290 | 290 |
| 291 // Allocates a slot in the constant pool which can later be inserted. | 291 // Allocates a slot in the constant pool which can later be inserted. |
| 292 size_t AllocateConstantPoolEntry(); | 292 size_t AllocateConstantPoolEntry(); |
| 293 // Inserts a entry into an allocated constant pool entry. | 293 // Inserts a entry into an allocated constant pool entry. |
| 294 void InsertConstantPoolEntryAt(size_t entry, Handle<Object> object); | 294 void InsertConstantPoolEntryAt(size_t entry, Handle<Object> object); |
| 295 | 295 |
| 296 void InitializeReturnPosition(FunctionLiteral* literal); | 296 void InitializeReturnPosition(FunctionLiteral* literal); |
| 297 | 297 |
| 298 void SetStatementPosition(Statement* stmt); | 298 void SetStatementPosition(Statement* stmt) { |
| 299 void SetExpressionPosition(Expression* expr); | 299 if (stmt->position() == kNoSourcePosition) return; |
| 300 void SetExpressionAsStatementPosition(Expression* expr); | 300 latest_source_info_.MakeStatementPosition(stmt->position()); |
| 301 } |
| 302 |
| 303 void SetExpressionPosition(Expression* expr) { |
| 304 if (expr->position() == kNoSourcePosition) return; |
| 305 if (!latest_source_info_.is_statement()) { |
| 306 // Ensure the current expression position is overwritten with the |
| 307 // latest value. |
| 308 latest_source_info_.MakeExpressionPosition(expr->position()); |
| 309 } |
| 310 } |
| 311 |
| 312 void SetExpressionAsStatementPosition(Expression* expr) { |
| 313 if (expr->position() == kNoSourcePosition) return; |
| 314 latest_source_info_.MakeStatementPosition(expr->position()); |
| 315 } |
| 301 | 316 |
| 302 // Accessors | 317 // Accessors |
| 303 TemporaryRegisterAllocator* temporary_register_allocator() { | 318 TemporaryRegisterAllocator* temporary_register_allocator() { |
| 304 return &temporary_allocator_; | 319 return &temporary_allocator_; |
| 305 } | 320 } |
| 306 const TemporaryRegisterAllocator* temporary_register_allocator() const { | 321 const TemporaryRegisterAllocator* temporary_register_allocator() const { |
| 307 return &temporary_allocator_; | 322 return &temporary_allocator_; |
| 308 } | 323 } |
| 309 Zone* zone() const { return zone_; } | 324 Zone* zone() const { return zone_; } |
| 310 | 325 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 324 } | 339 } |
| 325 | 340 |
| 326 static uint32_t UnsignedOperand(size_t value) { | 341 static uint32_t UnsignedOperand(size_t value) { |
| 327 DCHECK_LE(value, kMaxUInt32); | 342 DCHECK_LE(value, kMaxUInt32); |
| 328 return static_cast<uint32_t>(value); | 343 return static_cast<uint32_t>(value); |
| 329 } | 344 } |
| 330 | 345 |
| 331 private: | 346 private: |
| 332 friend class BytecodeRegisterAllocator; | 347 friend class BytecodeRegisterAllocator; |
| 333 | 348 |
| 334 static Bytecode BytecodeForBinaryOperation(Token::Value op); | 349 INLINE(void Output(Bytecode bytecode, uint32_t operand0, |
| 335 static Bytecode BytecodeForCountOperation(Token::Value op); | 350 uint32_t operand1, uint32_t operand2, uint32_t operand3)); |
| 336 static Bytecode BytecodeForCompareOperation(Token::Value op); | 351 INLINE(void Output(Bytecode bytecode, uint32_t operand0, |
| 337 static Bytecode BytecodeForStoreNamedProperty(LanguageMode language_mode); | 352 uint32_t operand1, uint32_t operand2)); |
| 338 static Bytecode BytecodeForStoreKeyedProperty(LanguageMode language_mode); | 353 INLINE(void Output(Bytecode bytecode, uint32_t operand0, |
| 339 static Bytecode BytecodeForLoadGlobal(TypeofMode typeof_mode); | 354 uint32_t operand1)); |
| 340 static Bytecode BytecodeForStoreGlobal(LanguageMode language_mode); | 355 INLINE(void Output(Bytecode bytecode, uint32_t operand0)); |
| 341 static Bytecode BytecodeForStoreLookupSlot(LanguageMode language_mode); | 356 INLINE(void Output(Bytecode bytecode)); |
| 342 static Bytecode BytecodeForCreateArguments(CreateArgumentsType type); | |
| 343 static Bytecode BytecodeForDelete(LanguageMode language_mode); | |
| 344 static Bytecode BytecodeForCall(TailCallMode tail_call_mode); | |
| 345 | 357 |
| 346 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, | 358 INLINE(void OutputJump(Bytecode bytecode, BytecodeLabel* label)); |
| 347 uint32_t operand2, uint32_t operand3); | 359 INLINE(void OutputJump(Bytecode bytecode, uint32_t operand0, |
| 348 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, | 360 BytecodeLabel* label)); |
| 349 uint32_t operand2); | |
| 350 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); | |
| 351 void Output(Bytecode bytecode, uint32_t operand0); | |
| 352 void Output(Bytecode bytecode); | |
| 353 | |
| 354 BytecodeArrayBuilder& OutputJump(BytecodeNode* node, BytecodeLabel* label); | |
| 355 | 361 |
| 356 bool RegisterIsValid(Register reg) const; | 362 bool RegisterIsValid(Register reg) const; |
| 357 bool OperandsAreValid(Bytecode bytecode, int operand_count, | 363 bool OperandsAreValid(Bytecode bytecode, int operand_count, |
| 358 uint32_t operand0 = 0, uint32_t operand1 = 0, | 364 uint32_t operand0 = 0, uint32_t operand1 = 0, |
| 359 uint32_t operand2 = 0, uint32_t operand3 = 0) const; | 365 uint32_t operand2 = 0, uint32_t operand3 = 0) const; |
| 360 | 366 |
| 361 // Attach latest source position to |node|. | |
| 362 void AttachSourceInfo(BytecodeNode* node); | |
| 363 | |
| 364 // Set position for return. | 367 // Set position for return. |
| 365 void SetReturnPosition(); | 368 void SetReturnPosition(); |
| 366 | 369 |
| 367 // Gets a constant pool entry for the |object|. | 370 // Gets a constant pool entry for the |object|. |
| 368 size_t GetConstantPoolEntry(Handle<Object> object); | 371 size_t GetConstantPoolEntry(Handle<Object> object); |
| 369 | 372 |
| 370 // Not implemented as the illegal bytecode is used inside internally | 373 // Not implemented as the illegal bytecode is used inside internally |
| 371 // to indicate a bytecode field is not valid or an error has occured | 374 // to indicate a bytecode field is not valid or an error has occured |
| 372 // during bytecode generation. | 375 // during bytecode generation. |
| 373 BytecodeArrayBuilder& Illegal(); | 376 BytecodeArrayBuilder& Illegal(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 static int const kNoFeedbackSlot = 0; | 408 static int const kNoFeedbackSlot = 0; |
| 406 | 409 |
| 407 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); | 410 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); |
| 408 }; | 411 }; |
| 409 | 412 |
| 410 } // namespace interpreter | 413 } // namespace interpreter |
| 411 } // namespace internal | 414 } // namespace internal |
| 412 } // namespace v8 | 415 } // namespace v8 |
| 413 | 416 |
| 414 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 417 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| OLD | NEW |