| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.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/compilation-info.h" | 9 #include "src/compilation-info.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 PrepareEagerCheckpoint(expr->CreateLiteralId()); | 1595 PrepareEagerCheckpoint(expr->CreateLiteralId()); |
| 1596 Handle<Name> name = isolate()->factory()->prototype_string(); | 1596 Handle<Name> name = isolate()->factory()->prototype_string(); |
| 1597 VectorSlotPair pair = CreateVectorSlotPair(expr->PrototypeSlot()); | 1597 VectorSlotPair pair = CreateVectorSlotPair(expr->PrototypeSlot()); |
| 1598 Node* prototype = BuildNamedLoad(literal, name, pair); | 1598 Node* prototype = BuildNamedLoad(literal, name, pair); |
| 1599 PrepareFrameState(prototype, expr->PrototypeId(), | 1599 PrepareFrameState(prototype, expr->PrototypeId(), |
| 1600 OutputFrameStateCombine::Push()); | 1600 OutputFrameStateCombine::Push()); |
| 1601 environment()->Push(prototype); | 1601 environment()->Push(prototype); |
| 1602 | 1602 |
| 1603 // Create nodes to store method values into the literal. | 1603 // Create nodes to store method values into the literal. |
| 1604 for (int i = 0; i < expr->properties()->length(); i++) { | 1604 for (int i = 0; i < expr->properties()->length(); i++) { |
| 1605 ObjectLiteral::Property* property = expr->properties()->at(i); | 1605 ClassLiteral::Property* property = expr->properties()->at(i); |
| 1606 environment()->Push(environment()->Peek(property->is_static() ? 1 : 0)); | 1606 environment()->Push(environment()->Peek(property->is_static() ? 1 : 0)); |
| 1607 | 1607 |
| 1608 VisitForValue(property->key()); | 1608 VisitForValue(property->key()); |
| 1609 Node* name = BuildToName(environment()->Pop(), expr->GetIdForProperty(i)); | 1609 Node* name = BuildToName(environment()->Pop(), expr->GetIdForProperty(i)); |
| 1610 environment()->Push(name); | 1610 environment()->Push(name); |
| 1611 | 1611 |
| 1612 // The static prototype property is read only. We handle the non computed | 1612 // The static prototype property is read only. We handle the non computed |
| 1613 // property name case in the parser. Since this is the only case where we | 1613 // property name case in the parser. Since this is the only case where we |
| 1614 // need to check for an own read only property we special case this so we do | 1614 // need to check for an own read only property we special case this so we do |
| 1615 // not need to do this for every property. | 1615 // not need to do this for every property. |
| 1616 if (property->is_static() && property->is_computed_name()) { | 1616 if (property->is_static() && property->is_computed_name()) { |
| 1617 Node* check = BuildThrowIfStaticPrototype(environment()->Pop(), | 1617 Node* check = BuildThrowIfStaticPrototype(environment()->Pop(), |
| 1618 expr->GetIdForProperty(i)); | 1618 expr->GetIdForProperty(i)); |
| 1619 environment()->Push(check); | 1619 environment()->Push(check); |
| 1620 } | 1620 } |
| 1621 | 1621 |
| 1622 VisitForValue(property->value()); | 1622 VisitForValue(property->value()); |
| 1623 Node* value = environment()->Pop(); | 1623 Node* value = environment()->Pop(); |
| 1624 Node* key = environment()->Pop(); | 1624 Node* key = environment()->Pop(); |
| 1625 Node* receiver = environment()->Pop(); | 1625 Node* receiver = environment()->Pop(); |
| 1626 | 1626 |
| 1627 BuildSetHomeObject(value, receiver, property); | 1627 BuildSetHomeObject(value, receiver, property); |
| 1628 | 1628 |
| 1629 switch (property->kind()) { | 1629 switch (property->kind()) { |
| 1630 case ObjectLiteral::Property::CONSTANT: | 1630 case ClassLiteral::Property::METHOD: { |
| 1631 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | |
| 1632 case ObjectLiteral::Property::PROTOTYPE: | |
| 1633 UNREACHABLE(); | |
| 1634 case ObjectLiteral::Property::COMPUTED: { | |
| 1635 Node* attr = jsgraph()->Constant(DONT_ENUM); | 1631 Node* attr = jsgraph()->Constant(DONT_ENUM); |
| 1636 Node* set_function_name = | 1632 Node* set_function_name = |
| 1637 jsgraph()->Constant(property->NeedsSetFunctionName()); | 1633 jsgraph()->Constant(property->NeedsSetFunctionName()); |
| 1638 const Operator* op = | 1634 const Operator* op = |
| 1639 javascript()->CallRuntime(Runtime::kDefineDataPropertyInLiteral); | 1635 javascript()->CallRuntime(Runtime::kDefineDataPropertyInLiteral); |
| 1640 Node* call = NewNode(op, receiver, key, value, attr, set_function_name); | 1636 Node* call = NewNode(op, receiver, key, value, attr, set_function_name); |
| 1641 PrepareFrameState(call, BailoutId::None()); | 1637 PrepareFrameState(call, BailoutId::None()); |
| 1642 break; | 1638 break; |
| 1643 } | 1639 } |
| 1644 case ObjectLiteral::Property::GETTER: { | 1640 case ClassLiteral::Property::GETTER: { |
| 1645 Node* attr = jsgraph()->Constant(DONT_ENUM); | 1641 Node* attr = jsgraph()->Constant(DONT_ENUM); |
| 1646 const Operator* op = javascript()->CallRuntime( | 1642 const Operator* op = javascript()->CallRuntime( |
| 1647 Runtime::kDefineGetterPropertyUnchecked, 4); | 1643 Runtime::kDefineGetterPropertyUnchecked, 4); |
| 1648 NewNode(op, receiver, key, value, attr); | 1644 NewNode(op, receiver, key, value, attr); |
| 1649 break; | 1645 break; |
| 1650 } | 1646 } |
| 1651 case ObjectLiteral::Property::SETTER: { | 1647 case ClassLiteral::Property::SETTER: { |
| 1652 Node* attr = jsgraph()->Constant(DONT_ENUM); | 1648 Node* attr = jsgraph()->Constant(DONT_ENUM); |
| 1653 const Operator* op = javascript()->CallRuntime( | 1649 const Operator* op = javascript()->CallRuntime( |
| 1654 Runtime::kDefineSetterPropertyUnchecked, 4); | 1650 Runtime::kDefineSetterPropertyUnchecked, 4); |
| 1655 NewNode(op, receiver, key, value, attr); | 1651 NewNode(op, receiver, key, value, attr); |
| 1656 break; | 1652 break; |
| 1657 } | 1653 } |
| 1658 } | 1654 } |
| 1659 } | 1655 } |
| 1660 | 1656 |
| 1661 // Set the constructor to have fast properties. | 1657 // Set the constructor to have fast properties. |
| (...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3690 return name; | 3686 return name; |
| 3691 } | 3687 } |
| 3692 | 3688 |
| 3693 | 3689 |
| 3694 Node* AstGraphBuilder::BuildToObject(Node* input, BailoutId bailout_id) { | 3690 Node* AstGraphBuilder::BuildToObject(Node* input, BailoutId bailout_id) { |
| 3695 Node* object = NewNode(javascript()->ToObject(), input); | 3691 Node* object = NewNode(javascript()->ToObject(), input); |
| 3696 PrepareFrameState(object, bailout_id, OutputFrameStateCombine::Push()); | 3692 PrepareFrameState(object, bailout_id, OutputFrameStateCombine::Push()); |
| 3697 return object; | 3693 return object; |
| 3698 } | 3694 } |
| 3699 | 3695 |
| 3700 | |
| 3701 Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object, | 3696 Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object, |
| 3702 ObjectLiteralProperty* property, | 3697 LiteralProperty* property, |
| 3703 int slot_number) { | 3698 int slot_number) { |
| 3704 Expression* expr = property->value(); | 3699 Expression* expr = property->value(); |
| 3705 if (!FunctionLiteral::NeedsHomeObject(expr)) return value; | 3700 if (!FunctionLiteral::NeedsHomeObject(expr)) return value; |
| 3706 Handle<Name> name = isolate()->factory()->home_object_symbol(); | 3701 Handle<Name> name = isolate()->factory()->home_object_symbol(); |
| 3707 VectorSlotPair feedback = | 3702 VectorSlotPair feedback = |
| 3708 CreateVectorSlotPair(property->GetSlot(slot_number)); | 3703 CreateVectorSlotPair(property->GetSlot(slot_number)); |
| 3709 Node* store = BuildNamedStore(value, name, home_object, feedback); | 3704 Node* store = BuildNamedStore(value, name, home_object, feedback); |
| 3710 PrepareFrameState(store, BailoutId::None(), | 3705 PrepareFrameState(store, BailoutId::None(), |
| 3711 OutputFrameStateCombine::Ignore()); | 3706 OutputFrameStateCombine::Ignore()); |
| 3712 return store; | 3707 return store; |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4334 // Phi does not exist yet, introduce one. | 4329 // Phi does not exist yet, introduce one. |
| 4335 value = NewPhi(inputs, value, control); | 4330 value = NewPhi(inputs, value, control); |
| 4336 value->ReplaceInput(inputs - 1, other); | 4331 value->ReplaceInput(inputs - 1, other); |
| 4337 } | 4332 } |
| 4338 return value; | 4333 return value; |
| 4339 } | 4334 } |
| 4340 | 4335 |
| 4341 } // namespace compiler | 4336 } // namespace compiler |
| 4342 } // namespace internal | 4337 } // namespace internal |
| 4343 } // namespace v8 | 4338 } // namespace v8 |
| OLD | NEW |