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/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 Node* name = environment()->Pop(); | 1548 Node* name = environment()->Pop(); |
1549 Node* start = jsgraph()->Constant(expr->start_position()); | 1549 Node* start = jsgraph()->Constant(expr->start_position()); |
1550 Node* end = jsgraph()->Constant(expr->end_position()); | 1550 Node* end = jsgraph()->Constant(expr->end_position()); |
1551 const Operator* opc = javascript()->CallRuntime(Runtime::kDefineClass, 5); | 1551 const Operator* opc = javascript()->CallRuntime(Runtime::kDefineClass, 5); |
1552 Node* literal = NewNode(opc, name, extends, constructor, start, end); | 1552 Node* literal = NewNode(opc, name, extends, constructor, start, end); |
1553 PrepareFrameState(literal, expr->CreateLiteralId(), | 1553 PrepareFrameState(literal, expr->CreateLiteralId(), |
1554 OutputFrameStateCombine::Push()); | 1554 OutputFrameStateCombine::Push()); |
1555 | 1555 |
1556 // The prototype is ensured to exist by Runtime_DefineClass. No access check | 1556 // The prototype is ensured to exist by Runtime_DefineClass. No access check |
1557 // is needed here since the constructor is created by the class literal. | 1557 // is needed here since the constructor is created by the class literal. |
1558 Node* proto = | 1558 Node* prototype = |
1559 BuildLoadObjectField(literal, JSFunction::kPrototypeOrInitialMapOffset); | 1559 BuildLoadObjectField(literal, JSFunction::kPrototypeOrInitialMapOffset); |
1560 | 1560 |
1561 // The class literal and the prototype are both expected on the operand stack | 1561 // The class literal and the prototype are both expected on the operand stack |
1562 // during evaluation of the method values. | 1562 // during evaluation of the method values. |
1563 environment()->Push(literal); | 1563 environment()->Push(literal); |
1564 environment()->Push(proto); | 1564 environment()->Push(prototype); |
1565 | 1565 |
1566 // Create nodes to store method values into the literal. | 1566 // Create nodes to store method values into the literal. |
1567 for (int i = 0; i < expr->properties()->length(); i++) { | 1567 for (int i = 0; i < expr->properties()->length(); i++) { |
1568 ObjectLiteral::Property* property = expr->properties()->at(i); | 1568 ObjectLiteral::Property* property = expr->properties()->at(i); |
1569 environment()->Push(property->is_static() ? literal : proto); | 1569 environment()->Push(environment()->Peek(property->is_static() ? 1 : 0)); |
1570 | 1570 |
1571 VisitForValue(property->key()); | 1571 VisitForValue(property->key()); |
1572 Node* name = BuildToName(environment()->Pop(), expr->GetIdForProperty(i)); | 1572 Node* name = BuildToName(environment()->Pop(), expr->GetIdForProperty(i)); |
1573 environment()->Push(name); | 1573 environment()->Push(name); |
1574 | 1574 |
1575 // The static prototype property is read only. We handle the non computed | 1575 // The static prototype property is read only. We handle the non computed |
1576 // property name case in the parser. Since this is the only case where we | 1576 // property name case in the parser. Since this is the only case where we |
1577 // need to check for an own read only property we special case this so we do | 1577 // need to check for an own read only property we special case this so we do |
1578 // not need to do this for every property. | 1578 // not need to do this for every property. |
1579 if (property->is_static() && property->is_computed_name()) { | 1579 if (property->is_static() && property->is_computed_name()) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1612 const Operator* op = javascript()->CallRuntime( | 1612 const Operator* op = javascript()->CallRuntime( |
1613 Runtime::kDefineSetterPropertyUnchecked, 4); | 1613 Runtime::kDefineSetterPropertyUnchecked, 4); |
1614 NewNode(op, receiver, key, value, attr); | 1614 NewNode(op, receiver, key, value, attr); |
1615 break; | 1615 break; |
1616 } | 1616 } |
1617 } | 1617 } |
1618 } | 1618 } |
1619 | 1619 |
1620 // Set both the prototype and constructor to have fast properties, and also | 1620 // Set both the prototype and constructor to have fast properties, and also |
1621 // freeze them in strong mode. | 1621 // freeze them in strong mode. |
1622 environment()->Pop(); // proto | 1622 prototype = environment()->Pop(); |
1623 environment()->Pop(); // literal | 1623 literal = environment()->Pop(); |
1624 const Operator* op = | 1624 const Operator* op = |
1625 javascript()->CallRuntime(Runtime::kFinalizeClassDefinition, 2); | 1625 javascript()->CallRuntime(Runtime::kFinalizeClassDefinition, 2); |
1626 literal = NewNode(op, literal, proto); | 1626 literal = NewNode(op, literal, prototype); |
1627 | 1627 |
1628 // Assign to class variable. | 1628 // Assign to class variable. |
1629 if (expr->class_variable_proxy() != nullptr) { | 1629 if (expr->class_variable_proxy() != nullptr) { |
1630 Variable* var = expr->class_variable_proxy()->var(); | 1630 Variable* var = expr->class_variable_proxy()->var(); |
1631 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 1631 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
1632 VectorSlotPair feedback = CreateVectorSlotPair( | 1632 VectorSlotPair feedback = CreateVectorSlotPair( |
1633 expr->NeedsProxySlot() ? expr->ProxySlot() | 1633 expr->NeedsProxySlot() ? expr->ProxySlot() |
1634 : FeedbackVectorSlot::Invalid()); | 1634 : FeedbackVectorSlot::Invalid()); |
1635 BuildVariableAssignment(var, literal, Token::INIT, feedback, | 1635 BuildVariableAssignment(var, literal, Token::INIT, feedback, |
1636 BailoutId::None(), states); | 1636 BailoutId::None(), states); |
(...skipping 2661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4298 // Phi does not exist yet, introduce one. | 4298 // Phi does not exist yet, introduce one. |
4299 value = NewPhi(inputs, value, control); | 4299 value = NewPhi(inputs, value, control); |
4300 value->ReplaceInput(inputs - 1, other); | 4300 value->ReplaceInput(inputs - 1, other); |
4301 } | 4301 } |
4302 return value; | 4302 return value; |
4303 } | 4303 } |
4304 | 4304 |
4305 } // namespace compiler | 4305 } // namespace compiler |
4306 } // namespace internal | 4306 } // namespace internal |
4307 } // namespace v8 | 4307 } // namespace v8 |
OLD | NEW |