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