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

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

Issue 1413903002: Always give class literals a block scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: TurboFan cleanup Created 5 years, 2 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
« no previous file with comments | « no previous file | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 1520
1521 // Create node to instantiate a new closure. 1521 // Create node to instantiate a new closure.
1522 PretenureFlag pretenure = expr->pretenure() ? TENURED : NOT_TENURED; 1522 PretenureFlag pretenure = expr->pretenure() ? TENURED : NOT_TENURED;
1523 const Operator* op = javascript()->CreateClosure(shared_info, pretenure); 1523 const Operator* op = javascript()->CreateClosure(shared_info, pretenure);
1524 Node* value = NewNode(op); 1524 Node* value = NewNode(op);
1525 ast_context()->ProduceValue(value); 1525 ast_context()->ProduceValue(value);
1526 } 1526 }
1527 1527
1528 1528
1529 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) { 1529 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) {
1530 if (expr->scope() == NULL) { 1530 // Visit declarations and class literal in a block scope.
1531 // Visit class literal in the same scope, no declarations. 1531 if (expr->scope()->ContextLocalCount() > 0) {
1532 Node* context = BuildLocalBlockContext(expr->scope());
1533 ContextScope scope(this, expr->scope(), context);
1534 VisitDeclarations(expr->scope()->declarations());
1532 VisitClassLiteralContents(expr); 1535 VisitClassLiteralContents(expr);
1533 } else { 1536 } else {
1534 // Visit declarations and class literal in a block scope. 1537 VisitDeclarations(expr->scope()->declarations());
1535 if (expr->scope()->ContextLocalCount() > 0) { 1538 VisitClassLiteralContents(expr);
1536 Node* context = BuildLocalBlockContext(expr->scope());
1537 ContextScope scope(this, expr->scope(), context);
1538 VisitDeclarations(expr->scope()->declarations());
1539 VisitClassLiteralContents(expr);
1540 } else {
1541 VisitDeclarations(expr->scope()->declarations());
1542 VisitClassLiteralContents(expr);
1543 }
1544 } 1539 }
1545 } 1540 }
1546 1541
1547 1542
1548 void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) { 1543 void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
1549 Node* class_name = expr->raw_name() ? jsgraph()->Constant(expr->name()) 1544 Node* class_name = expr->raw_name() ? jsgraph()->Constant(expr->name())
1550 : jsgraph()->UndefinedConstant(); 1545 : jsgraph()->UndefinedConstant();
1551 1546
1552 // The class name is expected on the operand stack. 1547 // The class name is expected on the operand stack.
1553 environment()->Push(class_name); 1548 environment()->Push(class_name);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 1626
1632 // Set both the prototype and constructor to have fast properties, and also 1627 // Set both the prototype and constructor to have fast properties, and also
1633 // freeze them in strong mode. 1628 // freeze them in strong mode.
1634 environment()->Pop(); // proto 1629 environment()->Pop(); // proto
1635 environment()->Pop(); // literal 1630 environment()->Pop(); // literal
1636 const Operator* op = 1631 const Operator* op =
1637 javascript()->CallRuntime(Runtime::kFinalizeClassDefinition, 2); 1632 javascript()->CallRuntime(Runtime::kFinalizeClassDefinition, 2);
1638 literal = NewNode(op, literal, proto); 1633 literal = NewNode(op, literal, proto);
1639 1634
1640 // Assign to class variable. 1635 // Assign to class variable.
1641 if (expr->scope() != NULL) { 1636 if (expr->class_variable_proxy() != nullptr) {
1642 DCHECK_NOT_NULL(expr->class_variable_proxy());
1643 Variable* var = expr->class_variable_proxy()->var(); 1637 Variable* var = expr->class_variable_proxy()->var();
1644 FrameStateBeforeAndAfter states(this, BailoutId::None()); 1638 FrameStateBeforeAndAfter states(this, BailoutId::None());
1645 VectorSlotPair feedback = CreateVectorSlotPair( 1639 VectorSlotPair feedback = CreateVectorSlotPair(
1646 expr->NeedsProxySlot() ? expr->ProxySlot() 1640 expr->NeedsProxySlot() ? expr->ProxySlot()
1647 : FeedbackVectorSlot::Invalid()); 1641 : FeedbackVectorSlot::Invalid());
1648 BuildVariableAssignment(var, literal, Token::INIT_CONST, feedback, 1642 BuildVariableAssignment(var, literal, Token::INIT_CONST, feedback,
1649 BailoutId::None(), states); 1643 BailoutId::None(), states);
1650 } 1644 }
1651 ast_context()->ProduceValue(literal); 1645 ast_context()->ProduceValue(literal);
1652 } 1646 }
(...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after
4285 // Phi does not exist yet, introduce one. 4279 // Phi does not exist yet, introduce one.
4286 value = NewPhi(inputs, value, control); 4280 value = NewPhi(inputs, value, control);
4287 value->ReplaceInput(inputs - 1, other); 4281 value->ReplaceInput(inputs - 1, other);
4288 } 4282 }
4289 return value; 4283 return value;
4290 } 4284 }
4291 4285
4292 } // namespace compiler 4286 } // namespace compiler
4293 } // namespace internal 4287 } // namespace internal
4294 } // namespace v8 4288 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698