| 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 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 case Variable::LOOKUP: | 1088 case Variable::LOOKUP: |
| 1089 UNIMPLEMENTED(); | 1089 UNIMPLEMENTED(); |
| 1090 } | 1090 } |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 | 1093 |
| 1094 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 1094 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
| 1095 Variable* variable = decl->proxy()->var(); | 1095 Variable* variable = decl->proxy()->var(); |
| 1096 switch (variable->location()) { | 1096 switch (variable->location()) { |
| 1097 case Variable::UNALLOCATED: { | 1097 case Variable::UNALLOCATED: { |
| 1098 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( | 1098 Handle<SharedFunctionInfo> function = |
| 1099 decl->fun(), info()->script(), info()); | 1099 Compiler::BuildFunctionInfo(decl->fun(), info()->script(), info()); |
| 1100 // Check for stack-overflow exception. | 1100 // Check for stack-overflow exception. |
| 1101 if (function.is_null()) return SetStackOverflow(); | 1101 if (function.is_null()) return SetStackOverflow(); |
| 1102 globals()->push_back(variable->name()); | 1102 globals()->push_back(variable->name()); |
| 1103 globals()->push_back(function); | 1103 globals()->push_back(function); |
| 1104 break; | 1104 break; |
| 1105 } | 1105 } |
| 1106 case Variable::PARAMETER: | 1106 case Variable::PARAMETER: |
| 1107 case Variable::LOCAL: { | 1107 case Variable::LOCAL: { |
| 1108 VisitForValue(decl->fun()); | 1108 VisitForValue(decl->fun()); |
| 1109 Node* value = environment()->Pop(); | 1109 Node* value = environment()->Pop(); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1512 void AstGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) { | 1512 void AstGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) { |
| 1513 Node* node = NewNode(javascript()->CallRuntime(Runtime::kDebugBreak, 0)); | 1513 Node* node = NewNode(javascript()->CallRuntime(Runtime::kDebugBreak, 0)); |
| 1514 PrepareFrameState(node, stmt->DebugBreakId()); | 1514 PrepareFrameState(node, stmt->DebugBreakId()); |
| 1515 environment()->MarkAllLocalsLive(); | 1515 environment()->MarkAllLocalsLive(); |
| 1516 } | 1516 } |
| 1517 | 1517 |
| 1518 | 1518 |
| 1519 void AstGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) { | 1519 void AstGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) { |
| 1520 Node* context = current_context(); | 1520 Node* context = current_context(); |
| 1521 | 1521 |
| 1522 // Find or build a shared function info. | 1522 // Build a new shared function info if we cannot find one in the baseline |
| 1523 Handle<SharedFunctionInfo> shared_info = | 1523 // code. We also have a stack overflow if the recursive compilation did. |
| 1524 Compiler::GetSharedFunctionInfo(expr, info()->script(), info()); | 1524 expr->InitializeSharedInfo(handle(info()->shared_info()->code())); |
| 1525 CHECK(!shared_info.is_null()); // TODO(mstarzinger): Set stack overflow? | 1525 Handle<SharedFunctionInfo> shared_info = expr->shared_info(); |
| 1526 if (shared_info.is_null()) { |
| 1527 shared_info = Compiler::BuildFunctionInfo(expr, info()->script(), info()); |
| 1528 CHECK(!shared_info.is_null()); // TODO(mstarzinger): Set stack overflow? |
| 1529 } |
| 1526 | 1530 |
| 1527 // Create node to instantiate a new closure. | 1531 // Create node to instantiate a new closure. |
| 1528 PretenureFlag pretenure = expr->pretenure() ? TENURED : NOT_TENURED; | 1532 PretenureFlag pretenure = expr->pretenure() ? TENURED : NOT_TENURED; |
| 1529 const Operator* op = javascript()->CreateClosure(shared_info, pretenure); | 1533 const Operator* op = javascript()->CreateClosure(shared_info, pretenure); |
| 1530 Node* value = NewNode(op, context); | 1534 Node* value = NewNode(op, context); |
| 1531 ast_context()->ProduceValue(value); | 1535 ast_context()->ProduceValue(value); |
| 1532 } | 1536 } |
| 1533 | 1537 |
| 1534 | 1538 |
| 1535 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) { | 1539 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) { |
| (...skipping 2622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4158 // Phi does not exist yet, introduce one. | 4162 // Phi does not exist yet, introduce one. |
| 4159 value = NewPhi(inputs, value, control); | 4163 value = NewPhi(inputs, value, control); |
| 4160 value->ReplaceInput(inputs - 1, other); | 4164 value->ReplaceInput(inputs - 1, other); |
| 4161 } | 4165 } |
| 4162 return value; | 4166 return value; |
| 4163 } | 4167 } |
| 4164 | 4168 |
| 4165 } // namespace compiler | 4169 } // namespace compiler |
| 4166 } // namespace internal | 4170 } // namespace internal |
| 4167 } // namespace v8 | 4171 } // namespace v8 |
| OLD | NEW |