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