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 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 case Variable::LOOKUP: | 1094 case Variable::LOOKUP: |
1095 UNIMPLEMENTED(); | 1095 UNIMPLEMENTED(); |
1096 } | 1096 } |
1097 } | 1097 } |
1098 | 1098 |
1099 | 1099 |
1100 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 1100 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
1101 Variable* variable = decl->proxy()->var(); | 1101 Variable* variable = decl->proxy()->var(); |
1102 switch (variable->location()) { | 1102 switch (variable->location()) { |
1103 case Variable::UNALLOCATED: { | 1103 case Variable::UNALLOCATED: { |
1104 Handle<SharedFunctionInfo> function = | 1104 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( |
1105 Compiler::BuildFunctionInfo(decl->fun(), info()->script(), info()); | 1105 decl->fun(), info()->script(), info()); |
1106 // Check for stack-overflow exception. | 1106 // Check for stack-overflow exception. |
1107 if (function.is_null()) return SetStackOverflow(); | 1107 if (function.is_null()) return SetStackOverflow(); |
1108 globals()->push_back(variable->name()); | 1108 globals()->push_back(variable->name()); |
1109 globals()->push_back(function); | 1109 globals()->push_back(function); |
1110 break; | 1110 break; |
1111 } | 1111 } |
1112 case Variable::PARAMETER: | 1112 case Variable::PARAMETER: |
1113 case Variable::LOCAL: { | 1113 case Variable::LOCAL: { |
1114 VisitForValue(decl->fun()); | 1114 VisitForValue(decl->fun()); |
1115 Node* value = environment()->Pop(); | 1115 Node* value = environment()->Pop(); |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 void AstGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) { | 1515 void AstGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) { |
1516 Node* node = NewNode(javascript()->CallRuntime(Runtime::kDebugBreak, 0)); | 1516 Node* node = NewNode(javascript()->CallRuntime(Runtime::kDebugBreak, 0)); |
1517 PrepareFrameState(node, stmt->DebugBreakId()); | 1517 PrepareFrameState(node, stmt->DebugBreakId()); |
1518 environment()->MarkAllLocalsLive(); | 1518 environment()->MarkAllLocalsLive(); |
1519 } | 1519 } |
1520 | 1520 |
1521 | 1521 |
1522 void AstGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) { | 1522 void AstGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) { |
1523 Node* context = current_context(); | 1523 Node* context = current_context(); |
1524 | 1524 |
1525 // Build a new shared function info if we cannot find one in the baseline | 1525 // Find or build a shared function info. |
1526 // code. We also have a stack overflow if the recursive compilation did. | 1526 Handle<SharedFunctionInfo> shared_info = |
1527 expr->InitializeSharedInfo(handle(info()->shared_info()->code())); | 1527 Compiler::GetSharedFunctionInfo(expr, info()->script(), info()); |
1528 Handle<SharedFunctionInfo> shared_info = expr->shared_info(); | 1528 CHECK(!shared_info.is_null()); // TODO(mstarzinger): Set stack overflow? |
1529 if (shared_info.is_null()) { | |
1530 shared_info = Compiler::BuildFunctionInfo(expr, info()->script(), info()); | |
1531 CHECK(!shared_info.is_null()); // TODO(mstarzinger): Set stack overflow? | |
1532 } | |
1533 | 1529 |
1534 // Create node to instantiate a new closure. | 1530 // Create node to instantiate a new closure. |
1535 PretenureFlag pretenure = expr->pretenure() ? TENURED : NOT_TENURED; | 1531 PretenureFlag pretenure = expr->pretenure() ? TENURED : NOT_TENURED; |
1536 const Operator* op = javascript()->CreateClosure(shared_info, pretenure); | 1532 const Operator* op = javascript()->CreateClosure(shared_info, pretenure); |
1537 Node* value = NewNode(op, context); | 1533 Node* value = NewNode(op, context); |
1538 ast_context()->ProduceValue(value); | 1534 ast_context()->ProduceValue(value); |
1539 } | 1535 } |
1540 | 1536 |
1541 | 1537 |
1542 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) { | 1538 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) { |
(...skipping 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4078 // Phi does not exist yet, introduce one. | 4074 // Phi does not exist yet, introduce one. |
4079 value = NewPhi(inputs, value, control); | 4075 value = NewPhi(inputs, value, control); |
4080 value->ReplaceInput(inputs - 1, other); | 4076 value->ReplaceInput(inputs - 1, other); |
4081 } | 4077 } |
4082 return value; | 4078 return value; |
4083 } | 4079 } |
4084 | 4080 |
4085 } // namespace compiler | 4081 } // namespace compiler |
4086 } // namespace internal | 4082 } // namespace internal |
4087 } // namespace v8 | 4083 } // namespace v8 |
OLD | NEW |