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

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

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Move computed property names check to parser and runtime function Created 4 years 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 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 for (int i = 0; i < expr->properties()->length(); i++) { 1618 for (int i = 0; i < expr->properties()->length(); i++) {
1619 ClassLiteral::Property* property = expr->properties()->at(i); 1619 ClassLiteral::Property* property = expr->properties()->at(i);
1620 environment()->Push(environment()->Peek(property->is_static() ? 1 : 0)); 1620 environment()->Push(environment()->Peek(property->is_static() ? 1 : 0));
1621 1621
1622 VisitForValue(property->key()); 1622 VisitForValue(property->key());
1623 Node* name = BuildToName(environment()->Pop(), expr->GetIdForProperty(i)); 1623 Node* name = BuildToName(environment()->Pop(), expr->GetIdForProperty(i));
1624 environment()->Push(name); 1624 environment()->Push(name);
1625 1625
1626 // The static prototype property is read only. We handle the non computed 1626 // The static prototype property is read only. We handle the non computed
1627 // property name case in the parser. Since this is the only case where we 1627 // property name case in the parser. Since this is the only case where we
1628 // need to check for an own read only property we special case this so we do 1628 // need to check for an own read only property we special case this so we
1629 // not need to do this for every property. 1629 // do not need to do this for every property.
1630 if (property->is_static() && property->is_computed_name()) { 1630 if (property->is_static() && property->is_computed_name()) {
1631 Node* check = BuildThrowIfStaticPrototype(environment()->Pop(), 1631 Node* check = BuildThrowIfStaticPrototype(environment()->Pop(),
1632 expr->GetIdForProperty(i)); 1632 expr->GetIdForProperty(i));
1633 environment()->Push(check); 1633 environment()->Push(check);
1634 } 1634 }
1635 1635
1636 VisitForValue(property->value()); 1636 VisitForValue(property->value());
1637 Node* value = environment()->Pop(); 1637 Node* value = environment()->Pop();
1638 Node* key = environment()->Pop(); 1638 Node* key = environment()->Pop();
1639 Node* receiver = environment()->Pop(); 1639 Node* receiver = environment()->Pop();
(...skipping 25 matching lines...) Expand all
1665 NewNode(op, receiver, key, value, attr); 1665 NewNode(op, receiver, key, value, attr);
1666 break; 1666 break;
1667 } 1667 }
1668 case ClassLiteral::Property::FIELD: { 1668 case ClassLiteral::Property::FIELD: {
1669 UNREACHABLE(); 1669 UNREACHABLE();
1670 break; 1670 break;
1671 } 1671 }
1672 } 1672 }
1673 } 1673 }
1674 1674
1675 prototype = environment()->Pop();
1676
1677 // Install a "name" property if missing.
1678 if (!expr->has_name_static_property() &&
1679 !expr->constructor()->raw_name()->IsEmpty()) {
1680 literal = environment()->Pop();
1681 const Operator* op =
1682 javascript()->CallRuntime(Runtime::kInstallClassNameAccessor);
1683 literal =
1684 NewNode(op, literal,
1685 jsgraph()->BooleanConstant(expr->has_static_computed_names()));
Toon Verwaest 2016/11/29 12:27:47 The standard way is to call a different runtime fu
1686 PrepareFrameState(literal, BailoutId::None());
1687 environment()->Push(literal);
1688 }
1689
1675 // Set the constructor to have fast properties. 1690 // Set the constructor to have fast properties.
1676 prototype = environment()->Pop();
1677 literal = environment()->Pop(); 1691 literal = environment()->Pop();
1678 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties); 1692 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties);
1679 literal = NewNode(op, literal); 1693 literal = NewNode(op, literal);
1680 1694
1681 // Assign to class variable. 1695 // Assign to class variable.
1682 if (expr->class_variable_proxy() != nullptr) { 1696 if (expr->class_variable_proxy() != nullptr) {
1683 Variable* var = expr->class_variable_proxy()->var(); 1697 Variable* var = expr->class_variable_proxy()->var();
1684 VectorSlotPair feedback = CreateVectorSlotPair( 1698 VectorSlotPair feedback = CreateVectorSlotPair(
1685 expr->NeedsProxySlot() ? expr->ProxySlot() 1699 expr->NeedsProxySlot() ? expr->ProxySlot()
1686 : FeedbackVectorSlot::Invalid()); 1700 : FeedbackVectorSlot::Invalid());
(...skipping 2668 matching lines...) Expand 10 before | Expand all | Expand 10 after
4355 // Phi does not exist yet, introduce one. 4369 // Phi does not exist yet, introduce one.
4356 value = NewPhi(inputs, value, control); 4370 value = NewPhi(inputs, value, control);
4357 value->ReplaceInput(inputs - 1, other); 4371 value->ReplaceInput(inputs - 1, other);
4358 } 4372 }
4359 return value; 4373 return value;
4360 } 4374 }
4361 4375
4362 } // namespace compiler 4376 } // namespace compiler
4363 } // namespace internal 4377 } // namespace internal
4364 } // namespace v8 4378 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698