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

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

Issue 1416583002: Revert of Always give class literals a block scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 // Visit declarations and class literal in a block scope. 1530 if (expr->scope() == NULL) {
1531 if (expr->scope()->ContextLocalCount() > 0) { 1531 // Visit class literal in the same scope, no declarations.
1532 Node* context = BuildLocalBlockContext(expr->scope());
1533 ContextScope scope(this, expr->scope(), context);
1534 VisitDeclarations(expr->scope()->declarations());
1535 VisitClassLiteralContents(expr); 1532 VisitClassLiteralContents(expr);
1536 } else { 1533 } else {
1537 VisitDeclarations(expr->scope()->declarations()); 1534 // Visit declarations and class literal in a block scope.
1538 VisitClassLiteralContents(expr); 1535 if (expr->scope()->ContextLocalCount() > 0) {
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 }
1539 } 1544 }
1540 } 1545 }
1541 1546
1542 1547
1543 void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) { 1548 void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
1544 Node* class_name = expr->raw_name() ? jsgraph()->Constant(expr->name()) 1549 Node* class_name = expr->raw_name() ? jsgraph()->Constant(expr->name())
1545 : jsgraph()->UndefinedConstant(); 1550 : jsgraph()->UndefinedConstant();
1546 1551
1547 // The class name is expected on the operand stack. 1552 // The class name is expected on the operand stack.
1548 environment()->Push(class_name); 1553 environment()->Push(class_name);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 1631
1627 // Set both the prototype and constructor to have fast properties, and also 1632 // Set both the prototype and constructor to have fast properties, and also
1628 // freeze them in strong mode. 1633 // freeze them in strong mode.
1629 environment()->Pop(); // proto 1634 environment()->Pop(); // proto
1630 environment()->Pop(); // literal 1635 environment()->Pop(); // literal
1631 const Operator* op = 1636 const Operator* op =
1632 javascript()->CallRuntime(Runtime::kFinalizeClassDefinition, 2); 1637 javascript()->CallRuntime(Runtime::kFinalizeClassDefinition, 2);
1633 literal = NewNode(op, literal, proto); 1638 literal = NewNode(op, literal, proto);
1634 1639
1635 // Assign to class variable. 1640 // Assign to class variable.
1636 if (expr->class_variable_proxy() != nullptr) { 1641 if (expr->scope() != NULL) {
1642 DCHECK_NOT_NULL(expr->class_variable_proxy());
1637 Variable* var = expr->class_variable_proxy()->var(); 1643 Variable* var = expr->class_variable_proxy()->var();
1638 FrameStateBeforeAndAfter states(this, BailoutId::None()); 1644 FrameStateBeforeAndAfter states(this, BailoutId::None());
1639 VectorSlotPair feedback = CreateVectorSlotPair( 1645 VectorSlotPair feedback = CreateVectorSlotPair(
1640 expr->NeedsProxySlot() ? expr->ProxySlot() 1646 expr->NeedsProxySlot() ? expr->ProxySlot()
1641 : FeedbackVectorSlot::Invalid()); 1647 : FeedbackVectorSlot::Invalid());
1642 BuildVariableAssignment(var, literal, Token::INIT_CONST, feedback, 1648 BuildVariableAssignment(var, literal, Token::INIT_CONST, feedback,
1643 BailoutId::None(), states); 1649 BailoutId::None(), states);
1644 } 1650 }
1645 ast_context()->ProduceValue(literal); 1651 ast_context()->ProduceValue(literal);
1646 } 1652 }
(...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after
4279 // Phi does not exist yet, introduce one. 4285 // Phi does not exist yet, introduce one.
4280 value = NewPhi(inputs, value, control); 4286 value = NewPhi(inputs, value, control);
4281 value->ReplaceInput(inputs - 1, other); 4287 value->ReplaceInput(inputs - 1, other);
4282 } 4288 }
4283 return value; 4289 return value;
4284 } 4290 }
4285 4291
4286 } // namespace compiler 4292 } // namespace compiler
4287 } // namespace internal 4293 } // namespace internal
4288 } // namespace v8 4294 } // 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