| 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/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 Register key = register_allocator()->NextConsecutiveRegister(); | 1538 Register key = register_allocator()->NextConsecutiveRegister(); |
| 1539 Register value = register_allocator()->NextConsecutiveRegister(); | 1539 Register value = register_allocator()->NextConsecutiveRegister(); |
| 1540 Register attr = register_allocator()->NextConsecutiveRegister(); | 1540 Register attr = register_allocator()->NextConsecutiveRegister(); |
| 1541 Register set_function_name = register_allocator()->NextConsecutiveRegister(); | 1541 Register set_function_name = register_allocator()->NextConsecutiveRegister(); |
| 1542 | 1542 |
| 1543 bool attr_assigned = false; | 1543 bool attr_assigned = false; |
| 1544 Register old_receiver = Register::invalid_value(); | 1544 Register old_receiver = Register::invalid_value(); |
| 1545 | 1545 |
| 1546 // Create nodes to store method values into the literal. | 1546 // Create nodes to store method values into the literal. |
| 1547 for (int i = 0; i < expr->properties()->length(); i++) { | 1547 for (int i = 0; i < expr->properties()->length(); i++) { |
| 1548 ObjectLiteral::Property* property = expr->properties()->at(i); | 1548 ClassLiteral::Property* property = expr->properties()->at(i); |
| 1549 | 1549 |
| 1550 // Set-up receiver. | 1550 // Set-up receiver. |
| 1551 Register new_receiver = property->is_static() ? literal : prototype; | 1551 Register new_receiver = property->is_static() ? literal : prototype; |
| 1552 if (new_receiver != old_receiver) { | 1552 if (new_receiver != old_receiver) { |
| 1553 builder()->MoveRegister(new_receiver, receiver); | 1553 builder()->MoveRegister(new_receiver, receiver); |
| 1554 old_receiver = new_receiver; | 1554 old_receiver = new_receiver; |
| 1555 } | 1555 } |
| 1556 | 1556 |
| 1557 VisitForAccumulatorValue(property->key()); | 1557 VisitForAccumulatorValue(property->key()); |
| 1558 builder()->CastAccumulatorToName(key); | 1558 builder()->CastAccumulatorToName(key); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1569 VisitSetHomeObject(value, receiver, property); | 1569 VisitSetHomeObject(value, receiver, property); |
| 1570 | 1570 |
| 1571 if (!attr_assigned) { | 1571 if (!attr_assigned) { |
| 1572 builder() | 1572 builder() |
| 1573 ->LoadLiteral(Smi::FromInt(DONT_ENUM)) | 1573 ->LoadLiteral(Smi::FromInt(DONT_ENUM)) |
| 1574 .StoreAccumulatorInRegister(attr); | 1574 .StoreAccumulatorInRegister(attr); |
| 1575 attr_assigned = true; | 1575 attr_assigned = true; |
| 1576 } | 1576 } |
| 1577 | 1577 |
| 1578 switch (property->kind()) { | 1578 switch (property->kind()) { |
| 1579 case ObjectLiteral::Property::CONSTANT: | 1579 case ClassLiteral::Property::METHOD: { |
| 1580 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | |
| 1581 case ObjectLiteral::Property::PROTOTYPE: | |
| 1582 // Invalid properties for ES6 classes. | |
| 1583 UNREACHABLE(); | |
| 1584 break; | |
| 1585 case ObjectLiteral::Property::COMPUTED: { | |
| 1586 builder() | 1580 builder() |
| 1587 ->LoadLiteral(Smi::FromInt(property->NeedsSetFunctionName())) | 1581 ->LoadLiteral(Smi::FromInt(property->NeedsSetFunctionName())) |
| 1588 .StoreAccumulatorInRegister(set_function_name); | 1582 .StoreAccumulatorInRegister(set_function_name); |
| 1589 builder()->CallRuntime(Runtime::kDefineDataPropertyInLiteral, receiver, | 1583 builder()->CallRuntime(Runtime::kDefineDataPropertyInLiteral, receiver, |
| 1590 5); | 1584 5); |
| 1591 break; | 1585 break; |
| 1592 } | 1586 } |
| 1593 case ObjectLiteral::Property::GETTER: { | 1587 case ClassLiteral::Property::GETTER: { |
| 1594 builder()->CallRuntime(Runtime::kDefineGetterPropertyUnchecked, | 1588 builder()->CallRuntime(Runtime::kDefineGetterPropertyUnchecked, |
| 1595 receiver, 4); | 1589 receiver, 4); |
| 1596 break; | 1590 break; |
| 1597 } | 1591 } |
| 1598 case ObjectLiteral::Property::SETTER: { | 1592 case ClassLiteral::Property::SETTER: { |
| 1599 builder()->CallRuntime(Runtime::kDefineSetterPropertyUnchecked, | 1593 builder()->CallRuntime(Runtime::kDefineSetterPropertyUnchecked, |
| 1600 receiver, 4); | 1594 receiver, 4); |
| 1601 break; | 1595 break; |
| 1602 } | 1596 } |
| 1603 } | 1597 } |
| 1604 } | 1598 } |
| 1605 } | 1599 } |
| 1606 | 1600 |
| 1607 void BytecodeGenerator::VisitClassLiteralStaticPrototypeWithComputedName( | 1601 void BytecodeGenerator::VisitClassLiteralStaticPrototypeWithComputedName( |
| 1608 Register key) { | 1602 Register key) { |
| (...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3220 if (property == nullptr) { | 3214 if (property == nullptr) { |
| 3221 builder()->LoadNull().StoreAccumulatorInRegister(value_out); | 3215 builder()->LoadNull().StoreAccumulatorInRegister(value_out); |
| 3222 } else { | 3216 } else { |
| 3223 VisitForAccumulatorValue(property->value()); | 3217 VisitForAccumulatorValue(property->value()); |
| 3224 builder()->StoreAccumulatorInRegister(value_out); | 3218 builder()->StoreAccumulatorInRegister(value_out); |
| 3225 VisitSetHomeObject(value_out, home_object, property); | 3219 VisitSetHomeObject(value_out, home_object, property); |
| 3226 } | 3220 } |
| 3227 } | 3221 } |
| 3228 | 3222 |
| 3229 void BytecodeGenerator::VisitSetHomeObject(Register value, Register home_object, | 3223 void BytecodeGenerator::VisitSetHomeObject(Register value, Register home_object, |
| 3230 ObjectLiteralProperty* property, | 3224 LiteralProperty* property, |
| 3231 int slot_number) { | 3225 int slot_number) { |
| 3232 Expression* expr = property->value(); | 3226 Expression* expr = property->value(); |
| 3233 if (FunctionLiteral::NeedsHomeObject(expr)) { | 3227 if (FunctionLiteral::NeedsHomeObject(expr)) { |
| 3234 FeedbackVectorSlot slot = property->GetSlot(slot_number); | 3228 FeedbackVectorSlot slot = property->GetSlot(slot_number); |
| 3235 builder() | 3229 builder() |
| 3236 ->LoadAccumulatorWithRegister(home_object) | 3230 ->LoadAccumulatorWithRegister(home_object) |
| 3237 .StoreNamedProperty(value, home_object_symbol(), feedback_index(slot), | 3231 .StoreNamedProperty(value, home_object_symbol(), feedback_index(slot), |
| 3238 language_mode()); | 3232 language_mode()); |
| 3239 } | 3233 } |
| 3240 } | 3234 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3385 return execution_context()->scope()->language_mode(); | 3379 return execution_context()->scope()->language_mode(); |
| 3386 } | 3380 } |
| 3387 | 3381 |
| 3388 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3382 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3389 return TypeFeedbackVector::GetIndex(slot); | 3383 return TypeFeedbackVector::GetIndex(slot); |
| 3390 } | 3384 } |
| 3391 | 3385 |
| 3392 } // namespace interpreter | 3386 } // namespace interpreter |
| 3393 } // namespace internal | 3387 } // namespace internal |
| 3394 } // namespace v8 | 3388 } // namespace v8 |
| OLD | NEW |