| 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/js-type-feedback.h" | 10 #include "src/compiler/js-type-feedback.h" |
| (...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 | 1526 |
| 1527 // Create node to instantiate a new closure. | 1527 // Create node to instantiate a new closure. |
| 1528 PretenureFlag pretenure = expr->pretenure() ? TENURED : NOT_TENURED; | 1528 PretenureFlag pretenure = expr->pretenure() ? TENURED : NOT_TENURED; |
| 1529 const Operator* op = javascript()->CreateClosure(shared_info, pretenure); | 1529 const Operator* op = javascript()->CreateClosure(shared_info, pretenure); |
| 1530 Node* value = NewNode(op); | 1530 Node* value = NewNode(op); |
| 1531 ast_context()->ProduceValue(value); | 1531 ast_context()->ProduceValue(value); |
| 1532 } | 1532 } |
| 1533 | 1533 |
| 1534 | 1534 |
| 1535 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) { | 1535 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) { |
| 1536 if (expr->scope() == NULL) { | 1536 // Visit declarations and class literal in a block scope. |
| 1537 // Visit class literal in the same scope, no declarations. | 1537 if (expr->scope()->ContextLocalCount() > 0) { |
| 1538 Node* context = BuildLocalBlockContext(expr->scope()); |
| 1539 ContextScope scope(this, expr->scope(), context); |
| 1540 VisitDeclarations(expr->scope()->declarations()); |
| 1538 VisitClassLiteralContents(expr); | 1541 VisitClassLiteralContents(expr); |
| 1539 } else { | 1542 } else { |
| 1540 // Visit declarations and class literal in a block scope. | 1543 VisitDeclarations(expr->scope()->declarations()); |
| 1541 if (expr->scope()->ContextLocalCount() > 0) { | 1544 VisitClassLiteralContents(expr); |
| 1542 Node* context = BuildLocalBlockContext(expr->scope()); | |
| 1543 ContextScope scope(this, expr->scope(), context); | |
| 1544 VisitDeclarations(expr->scope()->declarations()); | |
| 1545 VisitClassLiteralContents(expr); | |
| 1546 } else { | |
| 1547 VisitDeclarations(expr->scope()->declarations()); | |
| 1548 VisitClassLiteralContents(expr); | |
| 1549 } | |
| 1550 } | 1545 } |
| 1551 } | 1546 } |
| 1552 | 1547 |
| 1553 | 1548 |
| 1554 void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) { | 1549 void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) { |
| 1555 Node* class_name = expr->raw_name() ? jsgraph()->Constant(expr->name()) | 1550 Node* class_name = expr->raw_name() ? jsgraph()->Constant(expr->name()) |
| 1556 : jsgraph()->UndefinedConstant(); | 1551 : jsgraph()->UndefinedConstant(); |
| 1557 | 1552 |
| 1558 // The class name is expected on the operand stack. | 1553 // The class name is expected on the operand stack. |
| 1559 environment()->Push(class_name); | 1554 environment()->Push(class_name); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 | 1632 |
| 1638 // Set both the prototype and constructor to have fast properties, and also | 1633 // Set both the prototype and constructor to have fast properties, and also |
| 1639 // freeze them in strong mode. | 1634 // freeze them in strong mode. |
| 1640 environment()->Pop(); // proto | 1635 environment()->Pop(); // proto |
| 1641 environment()->Pop(); // literal | 1636 environment()->Pop(); // literal |
| 1642 const Operator* op = | 1637 const Operator* op = |
| 1643 javascript()->CallRuntime(Runtime::kFinalizeClassDefinition, 2); | 1638 javascript()->CallRuntime(Runtime::kFinalizeClassDefinition, 2); |
| 1644 literal = NewNode(op, literal, proto); | 1639 literal = NewNode(op, literal, proto); |
| 1645 | 1640 |
| 1646 // Assign to class variable. | 1641 // Assign to class variable. |
| 1647 if (expr->scope() != NULL) { | 1642 if (expr->class_variable_proxy() != nullptr) { |
| 1648 DCHECK_NOT_NULL(expr->class_variable_proxy()); | |
| 1649 Variable* var = expr->class_variable_proxy()->var(); | 1643 Variable* var = expr->class_variable_proxy()->var(); |
| 1650 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 1644 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
| 1651 VectorSlotPair feedback = CreateVectorSlotPair( | 1645 VectorSlotPair feedback = CreateVectorSlotPair( |
| 1652 expr->NeedsProxySlot() ? expr->ProxySlot() | 1646 expr->NeedsProxySlot() ? expr->ProxySlot() |
| 1653 : FeedbackVectorSlot::Invalid()); | 1647 : FeedbackVectorSlot::Invalid()); |
| 1654 BuildVariableAssignment(var, literal, Token::INIT_CONST, feedback, | 1648 BuildVariableAssignment(var, literal, Token::INIT_CONST, feedback, |
| 1655 BailoutId::None(), states); | 1649 BailoutId::None(), states); |
| 1656 } | 1650 } |
| 1657 ast_context()->ProduceValue(literal); | 1651 ast_context()->ProduceValue(literal); |
| 1658 } | 1652 } |
| (...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4291 // Phi does not exist yet, introduce one. | 4285 // Phi does not exist yet, introduce one. |
| 4292 value = NewPhi(inputs, value, control); | 4286 value = NewPhi(inputs, value, control); |
| 4293 value->ReplaceInput(inputs - 1, other); | 4287 value->ReplaceInput(inputs - 1, other); |
| 4294 } | 4288 } |
| 4295 return value; | 4289 return value; |
| 4296 } | 4290 } |
| 4297 | 4291 |
| 4298 } // namespace compiler | 4292 } // namespace compiler |
| 4299 } // namespace internal | 4293 } // namespace internal |
| 4300 } // namespace v8 | 4294 } // namespace v8 |
| OLD | NEW |