| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 .CallRuntime(Runtime::kDeclareEvalVar, name, 1); | 940 .CallRuntime(Runtime::kDeclareEvalVar, name, 1); |
| 941 break; | 941 break; |
| 942 } | 942 } |
| 943 case VariableLocation::MODULE: | 943 case VariableLocation::MODULE: |
| 944 UNREACHABLE(); | 944 UNREACHABLE(); |
| 945 } | 945 } |
| 946 } | 946 } |
| 947 | 947 |
| 948 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 948 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
| 949 Variable* variable = decl->proxy()->var(); | 949 Variable* variable = decl->proxy()->var(); |
| 950 DCHECK(variable->mode() == LET || variable->mode() == VAR); |
| 950 switch (variable->location()) { | 951 switch (variable->location()) { |
| 951 case VariableLocation::GLOBAL: | 952 case VariableLocation::GLOBAL: |
| 952 case VariableLocation::UNALLOCATED: { | 953 case VariableLocation::UNALLOCATED: { |
| 953 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); | 954 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); |
| 954 globals_builder()->AddFunctionDeclaration(slot, decl->fun()); | 955 globals_builder()->AddFunctionDeclaration(slot, decl->fun()); |
| 955 break; | 956 break; |
| 956 } | 957 } |
| 957 case VariableLocation::PARAMETER: | 958 case VariableLocation::PARAMETER: |
| 958 case VariableLocation::LOCAL: { | 959 case VariableLocation::LOCAL: { |
| 959 VisitForAccumulatorValue(decl->fun()); | 960 VisitForAccumulatorValue(decl->fun()); |
| 960 DCHECK(variable->mode() == LET || variable->mode() == VAR || | |
| 961 variable->mode() == CONST); | |
| 962 VisitVariableAssignment(variable, Token::INIT, | 961 VisitVariableAssignment(variable, Token::INIT, |
| 963 FeedbackVectorSlot::Invalid()); | 962 FeedbackVectorSlot::Invalid()); |
| 964 break; | 963 break; |
| 965 } | 964 } |
| 966 case VariableLocation::CONTEXT: { | 965 case VariableLocation::CONTEXT: { |
| 967 DCHECK_EQ(0, execution_context()->ContextChainDepth(variable->scope())); | 966 DCHECK_EQ(0, execution_context()->ContextChainDepth(variable->scope())); |
| 968 VisitForAccumulatorValue(decl->fun()); | 967 VisitForAccumulatorValue(decl->fun()); |
| 969 builder()->StoreContextSlot(execution_context()->reg(), | 968 builder()->StoreContextSlot(execution_context()->reg(), |
| 970 variable->index()); | 969 variable->index()); |
| 971 break; | 970 break; |
| (...skipping 2418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3390 return execution_context()->scope()->language_mode(); | 3389 return execution_context()->scope()->language_mode(); |
| 3391 } | 3390 } |
| 3392 | 3391 |
| 3393 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3392 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3394 return TypeFeedbackVector::GetIndex(slot); | 3393 return TypeFeedbackVector::GetIndex(slot); |
| 3395 } | 3394 } |
| 3396 | 3395 |
| 3397 } // namespace interpreter | 3396 } // namespace interpreter |
| 3398 } // namespace internal | 3397 } // namespace internal |
| 3399 } // namespace v8 | 3398 } // namespace v8 |
| OLD | NEW |