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-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
6 | 6 |
7 #include "src/ast/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/builtins/builtins-constructor.h" | 9 #include "src/builtins/builtins-constructor.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 ->LoadLiteral(Smi::FromInt(SLOPPY)) | 1749 ->LoadLiteral(Smi::FromInt(SLOPPY)) |
1750 .StoreAccumulatorInRegister(args[3]) | 1750 .StoreAccumulatorInRegister(args[3]) |
1751 .CallRuntime(Runtime::kSetProperty, args); | 1751 .CallRuntime(Runtime::kSetProperty, args); |
1752 Register value = args[2]; | 1752 Register value = args[2]; |
1753 VisitSetHomeObject(value, literal, property); | 1753 VisitSetHomeObject(value, literal, property); |
1754 } | 1754 } |
1755 } | 1755 } |
1756 break; | 1756 break; |
1757 } | 1757 } |
1758 case ObjectLiteral::Property::PROTOTYPE: { | 1758 case ObjectLiteral::Property::PROTOTYPE: { |
| 1759 // __proto__:null is handled by CreateObjectLiteral. |
| 1760 if (property->IsNullPrototype()) break; |
1759 DCHECK(property->emit_store()); | 1761 DCHECK(property->emit_store()); |
1760 RegisterList args = register_allocator()->NewRegisterList(2); | 1762 RegisterList args = register_allocator()->NewRegisterList(2); |
1761 builder()->MoveRegister(literal, args[0]); | 1763 builder()->MoveRegister(literal, args[0]); |
1762 VisitForRegisterValue(property->value(), args[1]); | 1764 VisitForRegisterValue(property->value(), args[1]); |
1763 builder()->CallRuntime(Runtime::kInternalSetPrototype, args); | 1765 builder()->CallRuntime(Runtime::kInternalSetPrototype, args); |
1764 break; | 1766 break; |
1765 } | 1767 } |
1766 case ObjectLiteral::Property::GETTER: | 1768 case ObjectLiteral::Property::GETTER: |
1767 if (property->emit_store()) { | 1769 if (property->emit_store()) { |
1768 accessor_table.lookup(key)->second->getter = property; | 1770 accessor_table.lookup(key)->second->getter = property; |
(...skipping 29 matching lines...) Expand all Loading... |
1798 // with the first computed property name and continues with all properties to | 1800 // with the first computed property name and continues with all properties to |
1799 // its right. All the code from above initializes the static component of the | 1801 // its right. All the code from above initializes the static component of the |
1800 // object literal, and arranges for the map of the result to reflect the | 1802 // object literal, and arranges for the map of the result to reflect the |
1801 // static order in which the keys appear. For the dynamic properties, we | 1803 // static order in which the keys appear. For the dynamic properties, we |
1802 // compile them into a series of "SetOwnProperty" runtime calls. This will | 1804 // compile them into a series of "SetOwnProperty" runtime calls. This will |
1803 // preserve insertion order. | 1805 // preserve insertion order. |
1804 for (; property_index < expr->properties()->length(); property_index++) { | 1806 for (; property_index < expr->properties()->length(); property_index++) { |
1805 ObjectLiteral::Property* property = expr->properties()->at(property_index); | 1807 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
1806 RegisterAllocationScope inner_register_scope(this); | 1808 RegisterAllocationScope inner_register_scope(this); |
1807 | 1809 |
1808 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { | 1810 if (property->IsPrototype()) { |
| 1811 // __proto__:null is handled by CreateObjectLiteral. |
| 1812 if (property->IsNullPrototype()) continue; |
1809 DCHECK(property->emit_store()); | 1813 DCHECK(property->emit_store()); |
1810 RegisterList args = register_allocator()->NewRegisterList(2); | 1814 RegisterList args = register_allocator()->NewRegisterList(2); |
1811 builder()->MoveRegister(literal, args[0]); | 1815 builder()->MoveRegister(literal, args[0]); |
1812 VisitForRegisterValue(property->value(), args[1]); | 1816 VisitForRegisterValue(property->value(), args[1]); |
1813 builder()->CallRuntime(Runtime::kInternalSetPrototype, args); | 1817 builder()->CallRuntime(Runtime::kInternalSetPrototype, args); |
1814 continue; | 1818 continue; |
1815 } | 1819 } |
1816 | 1820 |
1817 switch (property->kind()) { | 1821 switch (property->kind()) { |
1818 case ObjectLiteral::Property::CONSTANT: | 1822 case ObjectLiteral::Property::CONSTANT: |
(...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3668 } | 3672 } |
3669 | 3673 |
3670 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3674 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3671 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3675 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3672 : Runtime::kStoreKeyedToSuper_Sloppy; | 3676 : Runtime::kStoreKeyedToSuper_Sloppy; |
3673 } | 3677 } |
3674 | 3678 |
3675 } // namespace interpreter | 3679 } // namespace interpreter |
3676 } // namespace internal | 3680 } // namespace internal |
3677 } // namespace v8 | 3681 } // namespace v8 |
OLD | NEW |