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/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/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-info.h" | 10 #include "src/compilation-info.h" |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 | 925 |
926 Register name = register_allocator()->NewRegister(); | 926 Register name = register_allocator()->NewRegister(); |
927 | 927 |
928 builder() | 928 builder() |
929 ->LoadLiteral(variable->name()) | 929 ->LoadLiteral(variable->name()) |
930 .StoreAccumulatorInRegister(name) | 930 .StoreAccumulatorInRegister(name) |
931 .CallRuntime(Runtime::kDeclareEvalVar, name, 1); | 931 .CallRuntime(Runtime::kDeclareEvalVar, name, 1); |
932 break; | 932 break; |
933 } | 933 } |
934 case VariableLocation::MODULE: | 934 case VariableLocation::MODULE: |
935 if (variable->IsExport() && variable->binding_needs_init()) { | 935 // Nothing to do here. |
936 builder()->LoadTheHole(); | |
937 VisitVariableAssignment(variable, Token::INIT, | |
938 FeedbackVectorSlot::Invalid()); | |
939 } | |
940 // Nothing to do for imports. | |
941 break; | 936 break; |
942 } | 937 } |
943 } | 938 } |
944 | 939 |
945 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 940 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
946 Variable* variable = decl->proxy()->var(); | 941 Variable* variable = decl->proxy()->var(); |
947 DCHECK(variable->mode() == LET || variable->mode() == VAR); | 942 DCHECK(variable->mode() == LET || variable->mode() == VAR); |
948 switch (variable->location()) { | 943 switch (variable->location()) { |
949 case VariableLocation::UNALLOCATED: { | 944 case VariableLocation::UNALLOCATED: { |
950 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); | 945 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); |
(...skipping 19 matching lines...) Expand all Loading... |
970 Register name = register_allocator()->NextConsecutiveRegister(); | 965 Register name = register_allocator()->NextConsecutiveRegister(); |
971 Register literal = register_allocator()->NextConsecutiveRegister(); | 966 Register literal = register_allocator()->NextConsecutiveRegister(); |
972 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); | 967 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); |
973 | 968 |
974 VisitForAccumulatorValue(decl->fun()); | 969 VisitForAccumulatorValue(decl->fun()); |
975 builder()->StoreAccumulatorInRegister(literal).CallRuntime( | 970 builder()->StoreAccumulatorInRegister(literal).CallRuntime( |
976 Runtime::kDeclareEvalFunction, name, 2); | 971 Runtime::kDeclareEvalFunction, name, 2); |
977 break; | 972 break; |
978 } | 973 } |
979 case VariableLocation::MODULE: | 974 case VariableLocation::MODULE: |
980 DCHECK_EQ(variable->mode(), LET); | 975 DCHECK(variable->mode() == LET); |
981 DCHECK(variable->IsExport()); | |
982 VisitForAccumulatorValue(decl->fun()); | 976 VisitForAccumulatorValue(decl->fun()); |
983 VisitVariableAssignment(variable, Token::INIT, | 977 VisitVariableAssignment(variable, Token::INIT, |
984 FeedbackVectorSlot::Invalid()); | 978 FeedbackVectorSlot::Invalid()); |
985 break; | 979 break; |
986 } | 980 } |
987 } | 981 } |
988 | 982 |
989 void BytecodeGenerator::VisitDeclarations( | 983 void BytecodeGenerator::VisitDeclarations( |
990 ZoneList<Declaration*>* declarations) { | 984 ZoneList<Declaration*>* declarations) { |
991 RegisterAllocationScope register_scope(this); | 985 RegisterAllocationScope register_scope(this); |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2017 Register import_name = register_allocator()->NextConsecutiveRegister(); | 2011 Register import_name = register_allocator()->NextConsecutiveRegister(); |
2018 Register module_request = | 2012 Register module_request = |
2019 register_allocator()->NextConsecutiveRegister(); | 2013 register_allocator()->NextConsecutiveRegister(); |
2020 builder() | 2014 builder() |
2021 ->LoadLiteral(it->second->import_name->string()) | 2015 ->LoadLiteral(it->second->import_name->string()) |
2022 .StoreAccumulatorInRegister(import_name) | 2016 .StoreAccumulatorInRegister(import_name) |
2023 .LoadLiteral(Smi::FromInt(it->second->module_request)) | 2017 .LoadLiteral(Smi::FromInt(it->second->module_request)) |
2024 .StoreAccumulatorInRegister(module_request) | 2018 .StoreAccumulatorInRegister(module_request) |
2025 .CallRuntime(Runtime::kLoadModuleImport, import_name, 2); | 2019 .CallRuntime(Runtime::kLoadModuleImport, import_name, 2); |
2026 } | 2020 } |
2027 BuildHoleCheckForVariableLoad(variable); | |
2028 break; | 2021 break; |
2029 } | 2022 } |
2030 } | 2023 } |
2031 execution_result()->SetResultInAccumulator(); | 2024 execution_result()->SetResultInAccumulator(); |
2032 } | 2025 } |
2033 | 2026 |
2034 void BytecodeGenerator::VisitVariableLoadForAccumulatorValue( | 2027 void BytecodeGenerator::VisitVariableLoadForAccumulatorValue( |
2035 Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) { | 2028 Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) { |
2036 AccumulatorResultScope accumulator_result(this); | 2029 AccumulatorResultScope accumulator_result(this); |
2037 VisitVariableLoad(variable, slot, typeof_mode); | 2030 VisitVariableLoad(variable, slot, typeof_mode); |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3470 return execution_context()->scope()->language_mode(); | 3463 return execution_context()->scope()->language_mode(); |
3471 } | 3464 } |
3472 | 3465 |
3473 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3466 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3474 return TypeFeedbackVector::GetIndex(slot); | 3467 return TypeFeedbackVector::GetIndex(slot); |
3475 } | 3468 } |
3476 | 3469 |
3477 } // namespace interpreter | 3470 } // namespace interpreter |
3478 } // namespace internal | 3471 } // namespace internal |
3479 } // namespace v8 | 3472 } // namespace v8 |
OLD | NEW |