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

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

Issue 2330473002: Class fields, part 3 (backends)
Patch Set: clean up test properly 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/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 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 Node* constructor = environment()->Pop(); 1584 Node* constructor = environment()->Pop();
1585 Node* extends = environment()->Pop(); 1585 Node* extends = environment()->Pop();
1586 Node* start = jsgraph()->Constant(expr->start_position()); 1586 Node* start = jsgraph()->Constant(expr->start_position());
1587 Node* end = jsgraph()->Constant(expr->end_position()); 1587 Node* end = jsgraph()->Constant(expr->end_position());
1588 const Operator* opc = javascript()->CallRuntime(Runtime::kDefineClass); 1588 const Operator* opc = javascript()->CallRuntime(Runtime::kDefineClass);
1589 Node* literal = NewNode(opc, extends, constructor, start, end); 1589 Node* literal = NewNode(opc, extends, constructor, start, end);
1590 PrepareFrameState(literal, expr->CreateLiteralId(), 1590 PrepareFrameState(literal, expr->CreateLiteralId(),
1591 OutputFrameStateCombine::Push()); 1591 OutputFrameStateCombine::Push());
1592 environment()->Push(literal); 1592 environment()->Push(literal);
1593 1593
1594 // TODO(bakkot) This shouldn't be necessary; I just couldn't figure out how to
1595 // invoke the function literal with appropriate home object and receiver
1596 // (mainly because of FeedbackVector check failures which are totally opaque
1597 // to me)
1598 VariableProxy* static_initializer_proxy = expr->static_initializer_proxy();
1599 if (static_initializer_proxy != nullptr) {
1600 Variable* variable = static_initializer_proxy->var();
1601 BuildVariableAssignment(variable, literal, Token::INIT,
1602 CreateVectorSlotPair(FeedbackVectorSlot::Invalid()),
1603 BailoutId::None()); // TODO(bakkot) tokens
1604 }
1605
1594 // Load the "prototype" from the constructor. 1606 // Load the "prototype" from the constructor.
1595 PrepareEagerCheckpoint(expr->CreateLiteralId()); 1607 PrepareEagerCheckpoint(expr->CreateLiteralId());
1596 Handle<Name> name = isolate()->factory()->prototype_string(); 1608 Handle<Name> name = isolate()->factory()->prototype_string();
1597 VectorSlotPair pair = CreateVectorSlotPair(expr->PrototypeSlot()); 1609 VectorSlotPair pair = CreateVectorSlotPair(expr->PrototypeSlot());
1598 Node* prototype = BuildNamedLoad(literal, name, pair); 1610 Node* prototype = BuildNamedLoad(literal, name, pair);
1599 PrepareFrameState(prototype, expr->PrototypeId(), 1611 PrepareFrameState(prototype, expr->PrototypeId(),
1600 OutputFrameStateCombine::Push()); 1612 OutputFrameStateCombine::Push());
1601 environment()->Push(prototype); 1613 environment()->Push(prototype);
1602 1614
1603 // Create nodes to store method values into the literal. 1615 // Create nodes to store method values into the literal.
1604 for (int i = 0; i < expr->properties()->length(); i++) { 1616 for (int i = 0; i < expr->properties()->length(); i++) {
1605 ClassLiteral::Property* property = expr->properties()->at(i); 1617 ClassLiteral::Property* property = expr->properties()->at(i);
1618
1619 if (property->kind() == ClassLiteral::Property::FIELD &&
1620 !property->is_static()) {
1621 // This just does the ToName call on the field name and stores it in a
1622 // variable (a proxy for which is the value() of this property)
1623 Variable* variable =
1624 property->value()->AsVariableProxy()->var(); // TODO(bakkot) DCHECKs
1625 VisitForValue(property->key());
1626 Node* key = environment()->Pop();
1627 BuildVariableAssignment(
1628 variable, key, Token::INIT,
1629 CreateVectorSlotPair(FeedbackVectorSlot::Invalid()),
1630 BailoutId::None());
1631 continue;
1632 }
1633
1606 environment()->Push(environment()->Peek(property->is_static() ? 1 : 0)); 1634 environment()->Push(environment()->Peek(property->is_static() ? 1 : 0));
1607 1635
1608 VisitForValue(property->key()); 1636 VisitForValue(property->key());
1609 Node* name = BuildToName(environment()->Pop(), expr->GetIdForProperty(i)); 1637 Node* name = BuildToName(environment()->Pop(), expr->GetIdForProperty(i));
1610 environment()->Push(name); 1638 environment()->Push(name);
1611 1639
1612 // The static prototype property is read only. We handle the non computed 1640 // 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 1641 // 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 1642 // 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. 1643 // not need to do this for every property.
(...skipping 29 matching lines...) Expand all
1645 break; 1673 break;
1646 } 1674 }
1647 case ClassLiteral::Property::SETTER: { 1675 case ClassLiteral::Property::SETTER: {
1648 Node* attr = jsgraph()->Constant(DONT_ENUM); 1676 Node* attr = jsgraph()->Constant(DONT_ENUM);
1649 const Operator* op = javascript()->CallRuntime( 1677 const Operator* op = javascript()->CallRuntime(
1650 Runtime::kDefineSetterPropertyUnchecked, 4); 1678 Runtime::kDefineSetterPropertyUnchecked, 4);
1651 NewNode(op, receiver, key, value, attr); 1679 NewNode(op, receiver, key, value, attr);
1652 break; 1680 break;
1653 } 1681 }
1654 case ClassLiteral::Property::FIELD: { 1682 case ClassLiteral::Property::FIELD: {
1655 UNREACHABLE(); 1683 DCHECK(property->is_static());
1684 Node* attr = jsgraph()->Constant(DONT_ENUM);
1685 Node* set_function_name =
1686 jsgraph()->Constant(property->NeedsSetFunctionName());
1687 const Operator* op =
1688 javascript()->CallRuntime(Runtime::kDefineDataPropertyInLiteral);
1689 Node* call = NewNode(op, receiver, key, value, attr, set_function_name);
1690 PrepareFrameState(call, BailoutId::None());
1656 break; 1691 break;
1657 } 1692 }
1658 } 1693 }
1659 } 1694 }
1660 1695
1661 // Set the constructor to have fast properties. 1696 // Set the constructor to have fast properties.
1662 prototype = environment()->Pop(); 1697 prototype = environment()->Pop();
1663 literal = environment()->Pop(); 1698 literal = environment()->Pop();
1664 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties); 1699 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties);
1665 literal = NewNode(op, literal); 1700 literal = NewNode(op, literal);
(...skipping 2667 matching lines...) Expand 10 before | Expand all | Expand 10 after
4333 // Phi does not exist yet, introduce one. 4368 // Phi does not exist yet, introduce one.
4334 value = NewPhi(inputs, value, control); 4369 value = NewPhi(inputs, value, control);
4335 value->ReplaceInput(inputs - 1, other); 4370 value->ReplaceInput(inputs - 1, other);
4336 } 4371 }
4337 return value; 4372 return value;
4338 } 4373 }
4339 4374
4340 } // namespace compiler 4375 } // namespace compiler
4341 } // namespace internal 4376 } // namespace internal
4342 } // namespace v8 4377 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/full-codegen/arm/full-codegen-arm.cc » ('j') | src/interpreter/bytecode-generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698