| 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 #include "src/interpreter/bytecode-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace interpreter { | 9 namespace interpreter { |
| 10 | 10 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 if (FitsInIdxOperand(arg_count)) { | 467 if (FitsInIdxOperand(arg_count)) { |
| 468 Output(Bytecode::kCall, callable.ToOperand(), receiver.ToOperand(), | 468 Output(Bytecode::kCall, callable.ToOperand(), receiver.ToOperand(), |
| 469 static_cast<uint8_t>(arg_count)); | 469 static_cast<uint8_t>(arg_count)); |
| 470 } else { | 470 } else { |
| 471 UNIMPLEMENTED(); | 471 UNIMPLEMENTED(); |
| 472 } | 472 } |
| 473 return *this; | 473 return *this; |
| 474 } | 474 } |
| 475 | 475 |
| 476 | 476 |
| 477 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( |
| 478 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { |
| 479 DCHECK(FitsInWideIdxOperand(function_id)); |
| 480 DCHECK(FitsInIdxOperand(arg_count)); |
| 481 Output(Bytecode::kCallRuntime, static_cast<uint16_t>(function_id), |
| 482 first_arg.ToOperand(), static_cast<uint8_t>(arg_count)); |
| 483 return *this; |
| 484 } |
| 485 |
| 486 |
| 477 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { | 487 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { |
| 478 // These constants shouldn't be added to the constant pool, the should use | 488 // These constants shouldn't be added to the constant pool, the should use |
| 479 // specialzed bytecodes instead. | 489 // specialzed bytecodes instead. |
| 480 DCHECK(!object.is_identical_to(isolate_->factory()->undefined_value())); | 490 DCHECK(!object.is_identical_to(isolate_->factory()->undefined_value())); |
| 481 DCHECK(!object.is_identical_to(isolate_->factory()->null_value())); | 491 DCHECK(!object.is_identical_to(isolate_->factory()->null_value())); |
| 482 DCHECK(!object.is_identical_to(isolate_->factory()->the_hole_value())); | 492 DCHECK(!object.is_identical_to(isolate_->factory()->the_hole_value())); |
| 483 DCHECK(!object.is_identical_to(isolate_->factory()->true_value())); | 493 DCHECK(!object.is_identical_to(isolate_->factory()->true_value())); |
| 484 DCHECK(!object.is_identical_to(isolate_->factory()->false_value())); | 494 DCHECK(!object.is_identical_to(isolate_->factory()->false_value())); |
| 485 | 495 |
| 486 size_t* entry = constants_map_.Find(object); | 496 size_t* entry = constants_map_.Find(object); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 return value <= static_cast<size_t>(kMaxUInt8); | 614 return value <= static_cast<size_t>(kMaxUInt8); |
| 605 } | 615 } |
| 606 | 616 |
| 607 | 617 |
| 608 // static | 618 // static |
| 609 bool BytecodeArrayBuilder::FitsInImm8Operand(int value) { | 619 bool BytecodeArrayBuilder::FitsInImm8Operand(int value) { |
| 610 return kMinInt8 <= value && value < kMaxInt8; | 620 return kMinInt8 <= value && value < kMaxInt8; |
| 611 } | 621 } |
| 612 | 622 |
| 613 | 623 |
| 624 // static |
| 625 bool BytecodeArrayBuilder::FitsInWideIdxOperand(int value) { |
| 626 return kMinUInt16 <= value && value <= kMaxUInt16; |
| 627 } |
| 628 |
| 629 |
| 614 TemporaryRegisterScope::TemporaryRegisterScope(BytecodeArrayBuilder* builder) | 630 TemporaryRegisterScope::TemporaryRegisterScope(BytecodeArrayBuilder* builder) |
| 615 : builder_(builder), count_(0), last_register_index_(-1) {} | 631 : builder_(builder), count_(0), last_register_index_(-1) {} |
| 616 | 632 |
| 617 | 633 |
| 618 TemporaryRegisterScope::~TemporaryRegisterScope() { | 634 TemporaryRegisterScope::~TemporaryRegisterScope() { |
| 619 while (count_-- != 0) { | 635 while (count_-- != 0) { |
| 620 builder_->ReturnTemporaryRegister(last_register_index_--); | 636 builder_->ReturnTemporaryRegister(last_register_index_--); |
| 621 } | 637 } |
| 622 } | 638 } |
| 623 | 639 |
| 624 | 640 |
| 625 Register TemporaryRegisterScope::NewRegister() { | 641 Register TemporaryRegisterScope::NewRegister() { |
| 626 count_++; | 642 count_++; |
| 627 last_register_index_ = builder_->BorrowTemporaryRegister(); | 643 last_register_index_ = builder_->BorrowTemporaryRegister(); |
| 628 return Register(last_register_index_); | 644 return Register(last_register_index_); |
| 629 } | 645 } |
| 630 | 646 |
| 631 } // namespace interpreter | 647 } // namespace interpreter |
| 632 } // namespace internal | 648 } // namespace internal |
| 633 } // namespace v8 | 649 } // namespace v8 |
| OLD | NEW |