Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 2199283002: [modules] Introduce new VariableLocation for module imports/exports. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/compiler.h" 9 #include "src/compiler.h"
10 #include "src/interpreter/bytecode-flags.h" 10 #include "src/interpreter/bytecode-flags.h"
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 DCHECK(!hole_init); 826 DCHECK(!hole_init);
827 827
828 Register name = register_allocator()->NewRegister(); 828 Register name = register_allocator()->NewRegister();
829 829
830 builder() 830 builder()
831 ->LoadLiteral(variable->name()) 831 ->LoadLiteral(variable->name())
832 .StoreAccumulatorInRegister(name) 832 .StoreAccumulatorInRegister(name)
833 .CallRuntime(Runtime::kDeclareEvalVar, name, 1); 833 .CallRuntime(Runtime::kDeclareEvalVar, name, 1);
834 break; 834 break;
835 } 835 }
836 case VariableLocation::MODULE:
837 UNREACHABLE();
836 } 838 }
837 } 839 }
838 840
839 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { 841 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) {
840 Variable* variable = decl->proxy()->var(); 842 Variable* variable = decl->proxy()->var();
841 switch (variable->location()) { 843 switch (variable->location()) {
842 case VariableLocation::GLOBAL: 844 case VariableLocation::GLOBAL:
843 case VariableLocation::UNALLOCATED: { 845 case VariableLocation::UNALLOCATED: {
844 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( 846 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo(
845 decl->fun(), info()->script(), info()); 847 decl->fun(), info()->script(), info());
(...skipping 21 matching lines...) Expand all
867 } 869 }
868 case VariableLocation::LOOKUP: { 870 case VariableLocation::LOOKUP: {
869 register_allocator()->PrepareForConsecutiveAllocations(2); 871 register_allocator()->PrepareForConsecutiveAllocations(2);
870 Register name = register_allocator()->NextConsecutiveRegister(); 872 Register name = register_allocator()->NextConsecutiveRegister();
871 Register literal = register_allocator()->NextConsecutiveRegister(); 873 Register literal = register_allocator()->NextConsecutiveRegister();
872 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); 874 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name);
873 875
874 VisitForAccumulatorValue(decl->fun()); 876 VisitForAccumulatorValue(decl->fun());
875 builder()->StoreAccumulatorInRegister(literal).CallRuntime( 877 builder()->StoreAccumulatorInRegister(literal).CallRuntime(
876 Runtime::kDeclareEvalFunction, name, 2); 878 Runtime::kDeclareEvalFunction, name, 2);
879 break;
877 } 880 }
881 case VariableLocation::MODULE:
882 UNREACHABLE();
878 } 883 }
879 } 884 }
880 885
881 void BytecodeGenerator::VisitDeclarations( 886 void BytecodeGenerator::VisitDeclarations(
882 ZoneList<Declaration*>* declarations) { 887 ZoneList<Declaration*>* declarations) {
883 RegisterAllocationScope register_scope(this); 888 RegisterAllocationScope register_scope(this);
884 DCHECK(globals_builder()->empty()); 889 DCHECK(globals_builder()->empty());
885 for (int i = 0; i < declarations->length(); i++) { 890 for (int i = 0; i < declarations->length(); i++) {
886 RegisterAllocationScope register_scope(this); 891 RegisterAllocationScope register_scope(this);
887 Visit(declarations->at(i)); 892 Visit(declarations->at(i));
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 builder()->LoadContextSlot(context_reg, variable->index()); 1874 builder()->LoadContextSlot(context_reg, variable->index());
1870 BuildHoleCheckForVariableLoad(mode, variable->name()); 1875 BuildHoleCheckForVariableLoad(mode, variable->name());
1871 execution_result()->SetResultInAccumulator(); 1876 execution_result()->SetResultInAccumulator();
1872 break; 1877 break;
1873 } 1878 }
1874 case VariableLocation::LOOKUP: { 1879 case VariableLocation::LOOKUP: {
1875 builder()->LoadLookupSlot(variable->name(), typeof_mode); 1880 builder()->LoadLookupSlot(variable->name(), typeof_mode);
1876 execution_result()->SetResultInAccumulator(); 1881 execution_result()->SetResultInAccumulator();
1877 break; 1882 break;
1878 } 1883 }
1884 case VariableLocation::MODULE:
1885 UNREACHABLE();
1879 } 1886 }
1880 } 1887 }
1881 1888
1882 void BytecodeGenerator::VisitVariableLoadForAccumulatorValue( 1889 void BytecodeGenerator::VisitVariableLoadForAccumulatorValue(
1883 Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) { 1890 Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) {
1884 AccumulatorResultScope accumulator_result(this); 1891 AccumulatorResultScope accumulator_result(this);
1885 VisitVariableLoad(variable, slot, typeof_mode); 1892 VisitVariableLoad(variable, slot, typeof_mode);
1886 } 1893 }
1887 1894
1888 Register BytecodeGenerator::VisitVariableLoadForRegisterValue( 1895 Register BytecodeGenerator::VisitVariableLoadForRegisterValue(
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 } 2101 }
2095 2102
2096 builder()->StoreContextSlot(context_reg, variable->index()); 2103 builder()->StoreContextSlot(context_reg, variable->index());
2097 break; 2104 break;
2098 } 2105 }
2099 case VariableLocation::LOOKUP: { 2106 case VariableLocation::LOOKUP: {
2100 DCHECK_NE(CONST_LEGACY, variable->mode()); 2107 DCHECK_NE(CONST_LEGACY, variable->mode());
2101 builder()->StoreLookupSlot(variable->name(), language_mode()); 2108 builder()->StoreLookupSlot(variable->name(), language_mode());
2102 break; 2109 break;
2103 } 2110 }
2111 case VariableLocation::MODULE:
2112 UNREACHABLE();
2104 } 2113 }
2105 } 2114 }
2106 2115
2107 void BytecodeGenerator::VisitAssignment(Assignment* expr) { 2116 void BytecodeGenerator::VisitAssignment(Assignment* expr) {
2108 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); 2117 DCHECK(expr->target()->IsValidReferenceExpressionOrThis());
2109 Register object, key, home_object, value; 2118 Register object, key, home_object, value;
2110 Handle<String> name; 2119 Handle<String> name;
2111 2120
2112 // Left-hand side can only be a property, a global or a variable slot. 2121 // Left-hand side can only be a property, a global or a variable slot.
2113 Property* property = expr->target()->AsProperty(); 2122 Property* property = expr->target()->AsProperty();
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3237 return execution_context()->scope()->language_mode(); 3246 return execution_context()->scope()->language_mode();
3238 } 3247 }
3239 3248
3240 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 3249 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
3241 return TypeFeedbackVector::GetIndex(slot); 3250 return TypeFeedbackVector::GetIndex(slot);
3242 } 3251 }
3243 3252
3244 } // namespace interpreter 3253 } // namespace interpreter
3245 } // namespace internal 3254 } // namespace internal
3246 } // namespace v8 3255 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698