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

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

Issue 2471033004: [ignition,modules] Introduce bytecodes for loading/storing module variables. (Closed)
Patch Set: Rebase. Created 4 years, 1 month 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
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 builder()->LoadLookupGlobalSlot(variable->name(), typeof_mode, 1858 builder()->LoadLookupGlobalSlot(variable->name(), typeof_mode,
1859 feedback_index(slot), depth); 1859 feedback_index(slot), depth);
1860 break; 1860 break;
1861 } 1861 }
1862 default: 1862 default:
1863 builder()->LoadLookupSlot(variable->name(), typeof_mode); 1863 builder()->LoadLookupSlot(variable->name(), typeof_mode);
1864 } 1864 }
1865 break; 1865 break;
1866 } 1866 }
1867 case VariableLocation::MODULE: { 1867 case VariableLocation::MODULE: {
1868 Register index = register_allocator()->NewRegister(); 1868 int depth = execution_context()->ContextChainDepth(variable->scope());
1869 builder() 1869 builder()->LoadModuleVariable(variable->index(), depth);
1870 ->LoadLiteral(Smi::FromInt(variable->index()))
1871 .StoreAccumulatorInRegister(index)
1872 .CallRuntime(Runtime::kLoadModuleVariable, index);
1873 if (hole_check_mode == HoleCheckMode::kRequired) { 1870 if (hole_check_mode == HoleCheckMode::kRequired) {
1874 BuildThrowIfHole(variable->name()); 1871 BuildThrowIfHole(variable->name());
1875 } 1872 }
1876 break; 1873 break;
1877 } 1874 }
1878 } 1875 }
1879 } 1876 }
1880 1877
1881 void BytecodeGenerator::BuildVariableLoadForAccumulatorValue( 1878 void BytecodeGenerator::BuildVariableLoadForAccumulatorValue(
1882 Variable* variable, FeedbackVectorSlot slot, HoleCheckMode hole_check_mode, 1879 Variable* variable, FeedbackVectorSlot slot, HoleCheckMode hole_check_mode,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 if (mode == CONST && op != Token::INIT) { 2027 if (mode == CONST && op != Token::INIT) {
2031 builder()->CallRuntime(Runtime::kThrowConstAssignError); 2028 builder()->CallRuntime(Runtime::kThrowConstAssignError);
2032 break; 2029 break;
2033 } 2030 }
2034 2031
2035 // If we don't throw above, we know that we're dealing with an 2032 // If we don't throw above, we know that we're dealing with an
2036 // export because imports are const and we do not generate initializing 2033 // export because imports are const and we do not generate initializing
2037 // assignments for them. 2034 // assignments for them.
2038 DCHECK(variable->IsExport()); 2035 DCHECK(variable->IsExport());
2039 2036
2040 RegisterList args = register_allocator()->NewRegisterList(2); 2037 int depth = execution_context()->ContextChainDepth(variable->scope());
2041 builder()
2042 ->StoreAccumulatorInRegister(args[1])
2043 .LoadLiteral(Smi::FromInt(variable->index()))
2044 .StoreAccumulatorInRegister(args[0]);
2045 if (hole_check_mode == HoleCheckMode::kRequired) { 2038 if (hole_check_mode == HoleCheckMode::kRequired) {
2046 builder()->CallRuntime(Runtime::kLoadModuleVariable, args[0]); 2039 Register value_temp = register_allocator()->NewRegister();
2040 builder()
2041 ->StoreAccumulatorInRegister(value_temp)
2042 .LoadModuleVariable(variable->index(), depth);
2047 BuildHoleCheckForVariableAssignment(variable, op); 2043 BuildHoleCheckForVariableAssignment(variable, op);
2044 builder()->LoadAccumulatorWithRegister(value_temp);
2048 } 2045 }
2049 builder() 2046 builder()->StoreModuleVariable(variable->index(), depth);
2050 ->CallRuntime(Runtime::kStoreModuleVariable, args)
2051 .LoadAccumulatorWithRegister(args[1]);
2052 break; 2047 break;
2053 } 2048 }
2054 } 2049 }
2055 } 2050 }
2056 2051
2057 void BytecodeGenerator::VisitAssignment(Assignment* expr) { 2052 void BytecodeGenerator::VisitAssignment(Assignment* expr) {
2058 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); 2053 DCHECK(expr->target()->IsValidReferenceExpressionOrThis());
2059 Register object, key; 2054 Register object, key;
2060 RegisterList super_property_args; 2055 RegisterList super_property_args;
2061 Handle<String> name; 2056 Handle<String> name;
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3195 } 3190 }
3196 3191
3197 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3192 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3198 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3193 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3199 : Runtime::kStoreKeyedToSuper_Sloppy; 3194 : Runtime::kStoreKeyedToSuper_Sloppy;
3200 } 3195 }
3201 3196
3202 } // namespace interpreter 3197 } // namespace interpreter
3203 } // namespace internal 3198 } // namespace internal
3204 } // namespace v8 3199 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698