| 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/ast/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); | 1085 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); |
| 1086 } | 1086 } |
| 1087 } | 1087 } |
| 1088 | 1088 |
| 1089 | 1089 |
| 1090 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { | 1090 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { |
| 1091 Variable* variable = decl->proxy()->var(); | 1091 Variable* variable = decl->proxy()->var(); |
| 1092 switch (variable->location()) { | 1092 switch (variable->location()) { |
| 1093 case VariableLocation::UNALLOCATED: { | 1093 case VariableLocation::UNALLOCATED: { |
| 1094 DCHECK(!variable->binding_needs_init()); | 1094 DCHECK(!variable->binding_needs_init()); |
| 1095 globals()->push_back(variable->name()); |
| 1095 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); | 1096 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); |
| 1096 DCHECK(!slot.IsInvalid()); | 1097 DCHECK(!slot.IsInvalid()); |
| 1097 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); | 1098 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); |
| 1098 globals()->push_back(isolate()->factory()->undefined_value()); | 1099 globals()->push_back(isolate()->factory()->undefined_value()); |
| 1099 break; | 1100 break; |
| 1100 } | 1101 } |
| 1101 case VariableLocation::PARAMETER: | 1102 case VariableLocation::PARAMETER: |
| 1102 case VariableLocation::LOCAL: | 1103 case VariableLocation::LOCAL: |
| 1103 if (variable->binding_needs_init()) { | 1104 if (variable->binding_needs_init()) { |
| 1104 Node* value = jsgraph()->TheHoleConstant(); | 1105 Node* value = jsgraph()->TheHoleConstant(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1127 | 1128 |
| 1128 | 1129 |
| 1129 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 1130 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
| 1130 Variable* variable = decl->proxy()->var(); | 1131 Variable* variable = decl->proxy()->var(); |
| 1131 switch (variable->location()) { | 1132 switch (variable->location()) { |
| 1132 case VariableLocation::UNALLOCATED: { | 1133 case VariableLocation::UNALLOCATED: { |
| 1133 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( | 1134 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( |
| 1134 decl->fun(), info()->script(), info()); | 1135 decl->fun(), info()->script(), info()); |
| 1135 // Check for stack-overflow exception. | 1136 // Check for stack-overflow exception. |
| 1136 if (function.is_null()) return SetStackOverflow(); | 1137 if (function.is_null()) return SetStackOverflow(); |
| 1138 globals()->push_back(variable->name()); |
| 1137 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); | 1139 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); |
| 1138 DCHECK(!slot.IsInvalid()); | 1140 DCHECK(!slot.IsInvalid()); |
| 1139 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); | 1141 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); |
| 1140 globals()->push_back(function); | 1142 globals()->push_back(function); |
| 1141 break; | 1143 break; |
| 1142 } | 1144 } |
| 1143 case VariableLocation::PARAMETER: | 1145 case VariableLocation::PARAMETER: |
| 1144 case VariableLocation::LOCAL: { | 1146 case VariableLocation::LOCAL: { |
| 1145 VisitForValue(decl->fun()); | 1147 VisitForValue(decl->fun()); |
| 1146 Node* value = environment()->Pop(); | 1148 Node* value = environment()->Pop(); |
| (...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2898 AstVisitor<AstGraphBuilder>::VisitDeclarations(declarations); | 2900 AstVisitor<AstGraphBuilder>::VisitDeclarations(declarations); |
| 2899 if (globals()->empty()) return; | 2901 if (globals()->empty()) return; |
| 2900 int array_index = 0; | 2902 int array_index = 0; |
| 2901 Handle<TypeFeedbackVector> feedback_vector( | 2903 Handle<TypeFeedbackVector> feedback_vector( |
| 2902 info()->closure()->feedback_vector()); | 2904 info()->closure()->feedback_vector()); |
| 2903 Handle<FixedArray> data = isolate()->factory()->NewFixedArray( | 2905 Handle<FixedArray> data = isolate()->factory()->NewFixedArray( |
| 2904 static_cast<int>(globals()->size()), TENURED); | 2906 static_cast<int>(globals()->size()), TENURED); |
| 2905 for (Handle<Object> obj : *globals()) data->set(array_index++, *obj); | 2907 for (Handle<Object> obj : *globals()) data->set(array_index++, *obj); |
| 2906 int encoded_flags = info()->GetDeclareGlobalsFlags(); | 2908 int encoded_flags = info()->GetDeclareGlobalsFlags(); |
| 2907 Node* flags = jsgraph()->Constant(encoded_flags); | 2909 Node* flags = jsgraph()->Constant(encoded_flags); |
| 2908 Node* pairs = jsgraph()->Constant(data); | 2910 Node* decls = jsgraph()->Constant(data); |
| 2909 Node* vector = jsgraph()->Constant(feedback_vector); | 2911 Node* vector = jsgraph()->Constant(feedback_vector); |
| 2910 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals); | 2912 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals); |
| 2911 Node* call = NewNode(op, pairs, flags, vector); | 2913 Node* call = NewNode(op, decls, flags, vector); |
| 2912 PrepareFrameState(call, BailoutId::Declarations()); | 2914 PrepareFrameState(call, BailoutId::Declarations()); |
| 2913 globals()->clear(); | 2915 globals()->clear(); |
| 2914 } | 2916 } |
| 2915 | 2917 |
| 2916 | 2918 |
| 2917 void AstGraphBuilder::VisitIfNotNull(Statement* stmt) { | 2919 void AstGraphBuilder::VisitIfNotNull(Statement* stmt) { |
| 2918 if (stmt == nullptr) return; | 2920 if (stmt == nullptr) return; |
| 2919 Visit(stmt); | 2921 Visit(stmt); |
| 2920 } | 2922 } |
| 2921 | 2923 |
| (...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4367 TypeHintAnalysis* type_hint_analysis, SourcePositionTable* source_positions, | 4369 TypeHintAnalysis* type_hint_analysis, SourcePositionTable* source_positions, |
| 4368 int inlining_id) | 4370 int inlining_id) |
| 4369 : AstGraphBuilder(local_zone, info, jsgraph, invocation_frequency, | 4371 : AstGraphBuilder(local_zone, info, jsgraph, invocation_frequency, |
| 4370 loop_assignment, type_hint_analysis), | 4372 loop_assignment, type_hint_analysis), |
| 4371 source_positions_(source_positions), | 4373 source_positions_(source_positions), |
| 4372 start_position_(info->shared_info()->start_position(), inlining_id) {} | 4374 start_position_(info->shared_info()->start_position(), inlining_id) {} |
| 4373 | 4375 |
| 4374 } // namespace compiler | 4376 } // namespace compiler |
| 4375 } // namespace internal | 4377 } // namespace internal |
| 4376 } // namespace v8 | 4378 } // namespace v8 |
| OLD | NEW |