Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: src/compiler/ast-graph-builder.cc

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

Powered by Google App Engine
This is Rietveld 408576698