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 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 | 1015 |
1016 void AstGraphBuilder::VisitBlock(Block* stmt) { | 1016 void AstGraphBuilder::VisitBlock(Block* stmt) { |
1017 BlockBuilder block(this); | 1017 BlockBuilder block(this); |
1018 ControlScopeForBreakable scope(this, stmt, &block); | 1018 ControlScopeForBreakable scope(this, stmt, &block); |
1019 if (stmt->labels() != NULL) block.BeginBlock(); | 1019 if (stmt->labels() != NULL) block.BeginBlock(); |
1020 if (stmt->scope() == NULL) { | 1020 if (stmt->scope() == NULL) { |
1021 // Visit statements in the same scope, no declarations. | 1021 // Visit statements in the same scope, no declarations. |
1022 VisitStatements(stmt->statements()); | 1022 VisitStatements(stmt->statements()); |
1023 } else { | 1023 } else { |
1024 // Visit declarations and statements in a block scope. | 1024 // Visit declarations and statements in a block scope. |
1025 Node* context = BuildLocalBlockContext(stmt->scope()); | 1025 if (stmt->scope()->ContextLocalCount() > 0) { |
1026 ContextScope scope(this, stmt->scope(), context); | 1026 Node* context = BuildLocalBlockContext(stmt->scope()); |
1027 VisitDeclarations(stmt->scope()->declarations()); | 1027 ContextScope scope(this, stmt->scope(), context); |
1028 VisitStatements(stmt->statements()); | 1028 VisitDeclarations(stmt->scope()->declarations()); |
| 1029 VisitStatements(stmt->statements()); |
| 1030 } else { |
| 1031 VisitDeclarations(stmt->scope()->declarations()); |
| 1032 VisitStatements(stmt->statements()); |
| 1033 } |
1029 } | 1034 } |
1030 if (stmt->labels() != NULL) block.EndBlock(); | 1035 if (stmt->labels() != NULL) block.EndBlock(); |
1031 } | 1036 } |
1032 | 1037 |
1033 | 1038 |
1034 void AstGraphBuilder::VisitModuleStatement(ModuleStatement* stmt) { | 1039 void AstGraphBuilder::VisitModuleStatement(ModuleStatement* stmt) { |
1035 UNREACHABLE(); | 1040 UNREACHABLE(); |
1036 } | 1041 } |
1037 | 1042 |
1038 | 1043 |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 ast_context()->ProduceValue(value); | 1478 ast_context()->ProduceValue(value); |
1474 } | 1479 } |
1475 | 1480 |
1476 | 1481 |
1477 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) { | 1482 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) { |
1478 if (expr->scope() == NULL) { | 1483 if (expr->scope() == NULL) { |
1479 // Visit class literal in the same scope, no declarations. | 1484 // Visit class literal in the same scope, no declarations. |
1480 VisitClassLiteralContents(expr); | 1485 VisitClassLiteralContents(expr); |
1481 } else { | 1486 } else { |
1482 // Visit declarations and class literal in a block scope. | 1487 // Visit declarations and class literal in a block scope. |
1483 Node* context = BuildLocalBlockContext(expr->scope()); | 1488 if (expr->scope()->ContextLocalCount() > 0) { |
1484 ContextScope scope(this, expr->scope(), context); | 1489 Node* context = BuildLocalBlockContext(expr->scope()); |
1485 VisitDeclarations(expr->scope()->declarations()); | 1490 ContextScope scope(this, expr->scope(), context); |
1486 VisitClassLiteralContents(expr); | 1491 VisitDeclarations(expr->scope()->declarations()); |
| 1492 VisitClassLiteralContents(expr); |
| 1493 } else { |
| 1494 VisitDeclarations(expr->scope()->declarations()); |
| 1495 VisitClassLiteralContents(expr); |
| 1496 } |
1487 } | 1497 } |
1488 } | 1498 } |
1489 | 1499 |
1490 | 1500 |
1491 void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) { | 1501 void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) { |
1492 Node* class_name = expr->raw_name() ? jsgraph()->Constant(expr->name()) | 1502 Node* class_name = expr->raw_name() ? jsgraph()->Constant(expr->name()) |
1493 : jsgraph()->UndefinedConstant(); | 1503 : jsgraph()->UndefinedConstant(); |
1494 | 1504 |
1495 // The class name is expected on the operand stack. | 1505 // The class name is expected on the operand stack. |
1496 environment()->Push(class_name); | 1506 environment()->Push(class_name); |
(...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3567 // Phi does not exist yet, introduce one. | 3577 // Phi does not exist yet, introduce one. |
3568 value = NewPhi(inputs, value, control); | 3578 value = NewPhi(inputs, value, control); |
3569 value->ReplaceInput(inputs - 1, other); | 3579 value->ReplaceInput(inputs - 1, other); |
3570 } | 3580 } |
3571 return value; | 3581 return value; |
3572 } | 3582 } |
3573 | 3583 |
3574 } // namespace compiler | 3584 } // namespace compiler |
3575 } // namespace internal | 3585 } // namespace internal |
3576 } // namespace v8 | 3586 } // namespace v8 |
OLD | NEW |