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 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { | 926 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { |
927 Variable* variable = decl->proxy()->var(); | 927 Variable* variable = decl->proxy()->var(); |
928 DCHECK(!variable->binding_needs_init()); | 928 DCHECK(!variable->binding_needs_init()); |
929 switch (variable->location()) { | 929 switch (variable->location()) { |
930 case VariableLocation::UNALLOCATED: { | 930 case VariableLocation::UNALLOCATED: { |
931 globals()->push_back(variable->name()); | 931 globals()->push_back(variable->name()); |
932 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); | 932 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); |
933 DCHECK(!slot.IsInvalid()); | 933 DCHECK(!slot.IsInvalid()); |
934 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); | 934 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); |
935 globals()->push_back(isolate()->factory()->undefined_value()); | 935 globals()->push_back(isolate()->factory()->undefined_value()); |
936 globals()->push_back(isolate()->factory()->undefined_value()); | |
937 break; | 936 break; |
938 } | 937 } |
939 case VariableLocation::PARAMETER: | 938 case VariableLocation::PARAMETER: |
940 case VariableLocation::LOCAL: | 939 case VariableLocation::LOCAL: |
941 case VariableLocation::CONTEXT: | 940 case VariableLocation::CONTEXT: |
942 break; | 941 break; |
943 case VariableLocation::LOOKUP: | 942 case VariableLocation::LOOKUP: |
944 case VariableLocation::MODULE: | 943 case VariableLocation::MODULE: |
945 UNREACHABLE(); | 944 UNREACHABLE(); |
946 } | 945 } |
947 } | 946 } |
948 | 947 |
949 | 948 |
950 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 949 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
951 Variable* variable = decl->proxy()->var(); | 950 Variable* variable = decl->proxy()->var(); |
952 switch (variable->location()) { | 951 switch (variable->location()) { |
953 case VariableLocation::UNALLOCATED: { | 952 case VariableLocation::UNALLOCATED: { |
954 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( | 953 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( |
955 decl->fun(), info()->script(), info()); | 954 decl->fun(), info()->script(), info()); |
956 // Check for stack-overflow exception. | 955 // Check for stack-overflow exception. |
957 if (function.is_null()) return SetStackOverflow(); | 956 if (function.is_null()) return SetStackOverflow(); |
958 globals()->push_back(variable->name()); | 957 globals()->push_back(variable->name()); |
959 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); | 958 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); |
960 DCHECK(!slot.IsInvalid()); | 959 DCHECK(!slot.IsInvalid()); |
961 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); | 960 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); |
962 | |
963 // We need the slot where the literals array lives, too. | |
964 slot = decl->fun()->LiteralFeedbackSlot(); | |
965 DCHECK(!slot.IsInvalid()); | |
966 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); | |
967 | |
968 globals()->push_back(function); | 961 globals()->push_back(function); |
969 break; | 962 break; |
970 } | 963 } |
971 case VariableLocation::PARAMETER: | 964 case VariableLocation::PARAMETER: |
972 case VariableLocation::LOCAL: { | 965 case VariableLocation::LOCAL: { |
973 VisitForValue(decl->fun()); | 966 VisitForValue(decl->fun()); |
974 Node* value = environment()->Pop(); | 967 Node* value = environment()->Pop(); |
975 environment()->Bind(variable, value); | 968 environment()->Bind(variable, value); |
976 break; | 969 break; |
977 } | 970 } |
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3173 float invocation_frequency, LoopAssignmentAnalysis* loop_assignment, | 3166 float invocation_frequency, LoopAssignmentAnalysis* loop_assignment, |
3174 SourcePositionTable* source_positions, int inlining_id) | 3167 SourcePositionTable* source_positions, int inlining_id) |
3175 : AstGraphBuilder(local_zone, info, jsgraph, invocation_frequency, | 3168 : AstGraphBuilder(local_zone, info, jsgraph, invocation_frequency, |
3176 loop_assignment), | 3169 loop_assignment), |
3177 source_positions_(source_positions), | 3170 source_positions_(source_positions), |
3178 start_position_(info->shared_info()->start_position(), inlining_id) {} | 3171 start_position_(info->shared_info()->start_position(), inlining_id) {} |
3179 | 3172 |
3180 } // namespace compiler | 3173 } // namespace compiler |
3181 } // namespace internal | 3174 } // namespace internal |
3182 } // namespace v8 | 3175 } // namespace v8 |
OLD | NEW |