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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateArguments( | 582 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateArguments( |
583 CreateArgumentsType type) { | 583 CreateArgumentsType type) { |
584 // TODO(rmcilroy): Consider passing the type as a bytecode operand rather | 584 // TODO(rmcilroy): Consider passing the type as a bytecode operand rather |
585 // than having two different bytecodes once we have better support for | 585 // than having two different bytecodes once we have better support for |
586 // branches in the InterpreterAssembler. | 586 // branches in the InterpreterAssembler. |
587 Bytecode bytecode = BytecodeForCreateArguments(type); | 587 Bytecode bytecode = BytecodeForCreateArguments(type); |
588 Output(bytecode); | 588 Output(bytecode); |
589 return *this; | 589 return *this; |
590 } | 590 } |
591 | 591 |
592 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateRestArguments(int index) { | |
593 size_t index_entry = | |
594 GetConstantPoolEntry(Handle<Object>(Smi::FromInt(index), isolate_)); | |
595 // This will always be the first entry in the constant pool, since the rest | |
596 // arguments object is created at the start of the function just after | |
597 // creating the arguments object. | |
598 CHECK(FitsInIdx8Operand(index_entry)); | |
599 Output(Bytecode::kCreateRestArguments, static_cast<uint8_t>(index_entry)); | |
600 return *this; | |
601 } | |
602 | 592 |
603 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateRegExpLiteral( | 593 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateRegExpLiteral( |
604 Handle<String> pattern, int literal_index, int flags) { | 594 Handle<String> pattern, int literal_index, int flags) { |
605 DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bits. | 595 DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bits. |
606 size_t pattern_entry = GetConstantPoolEntry(pattern); | 596 size_t pattern_entry = GetConstantPoolEntry(pattern); |
607 if (FitsInIdx8Operand(literal_index) && FitsInIdx8Operand(pattern_entry)) { | 597 if (FitsInIdx8Operand(literal_index) && FitsInIdx8Operand(pattern_entry)) { |
608 Output(Bytecode::kCreateRegExpLiteral, static_cast<uint8_t>(pattern_entry), | 598 Output(Bytecode::kCreateRegExpLiteral, static_cast<uint8_t>(pattern_entry), |
609 static_cast<uint8_t>(literal_index), static_cast<uint8_t>(flags)); | 599 static_cast<uint8_t>(literal_index), static_cast<uint8_t>(flags)); |
610 } else if (FitsInIdx16Operand(literal_index) && | 600 } else if (FitsInIdx16Operand(literal_index) && |
611 FitsInIdx16Operand(pattern_entry)) { | 601 FitsInIdx16Operand(pattern_entry)) { |
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 case STRICT: | 1600 case STRICT: |
1611 return Bytecode::kStaLookupSlotStrict; | 1601 return Bytecode::kStaLookupSlotStrict; |
1612 case STRONG: | 1602 case STRONG: |
1613 UNIMPLEMENTED(); | 1603 UNIMPLEMENTED(); |
1614 default: | 1604 default: |
1615 UNREACHABLE(); | 1605 UNREACHABLE(); |
1616 } | 1606 } |
1617 return static_cast<Bytecode>(-1); | 1607 return static_cast<Bytecode>(-1); |
1618 } | 1608 } |
1619 | 1609 |
1620 | |
1621 // static | 1610 // static |
1622 Bytecode BytecodeArrayBuilder::BytecodeForCreateArguments( | 1611 Bytecode BytecodeArrayBuilder::BytecodeForCreateArguments( |
1623 CreateArgumentsType type) { | 1612 CreateArgumentsType type) { |
1624 switch (type) { | 1613 switch (type) { |
1625 case CreateArgumentsType::kMappedArguments: | 1614 case CreateArgumentsType::kMappedArguments: |
1626 return Bytecode::kCreateMappedArguments; | 1615 return Bytecode::kCreateMappedArguments; |
1627 case CreateArgumentsType::kUnmappedArguments: | 1616 case CreateArgumentsType::kUnmappedArguments: |
1628 return Bytecode::kCreateUnmappedArguments; | 1617 return Bytecode::kCreateUnmappedArguments; |
1629 default: | 1618 case CreateArgumentsType::kRestParameter: |
1630 UNREACHABLE(); | 1619 return Bytecode::kCreateRestParameter; |
1631 } | 1620 } |
| 1621 UNREACHABLE(); |
1632 return static_cast<Bytecode>(-1); | 1622 return static_cast<Bytecode>(-1); |
1633 } | 1623 } |
1634 | 1624 |
1635 | 1625 |
1636 // static | 1626 // static |
1637 Bytecode BytecodeArrayBuilder::BytecodeForDelete(LanguageMode language_mode) { | 1627 Bytecode BytecodeArrayBuilder::BytecodeForDelete(LanguageMode language_mode) { |
1638 switch (language_mode) { | 1628 switch (language_mode) { |
1639 case SLOPPY: | 1629 case SLOPPY: |
1640 return Bytecode::kDeletePropertySloppy; | 1630 return Bytecode::kDeletePropertySloppy; |
1641 case STRICT: | 1631 case STRICT: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 } | 1686 } |
1697 | 1687 |
1698 // static | 1688 // static |
1699 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { | 1689 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { |
1700 return value.is_short_operand(); | 1690 return value.is_short_operand(); |
1701 } | 1691 } |
1702 | 1692 |
1703 } // namespace interpreter | 1693 } // namespace interpreter |
1704 } // namespace internal | 1694 } // namespace internal |
1705 } // namespace v8 | 1695 } // namespace v8 |
OLD | NEW |