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

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 2465283004: [modules] Maintain array of cells for imports and local exports. (Closed)
Patch Set: Rename parameter also in header file. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/factory.cc ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 404b9d3b59e92c9140e03d2df7abbcfa3f984f0e..ad1356f31a119a128c587bcc3b87dc34b1ca8bdd 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -1865,26 +1865,11 @@ void BytecodeGenerator::BuildVariableLoad(Variable* variable,
break;
}
case VariableLocation::MODULE: {
- ModuleDescriptor* descriptor = scope()->GetModuleScope()->module();
- if (variable->IsExport()) {
- auto it = descriptor->regular_exports().find(variable->raw_name());
- DCHECK(it != descriptor->regular_exports().end());
- Register export_name = register_allocator()->NewRegister();
- builder()
- ->LoadLiteral(it->second->export_name->string())
- .StoreAccumulatorInRegister(export_name)
- .CallRuntime(Runtime::kLoadModuleExport, export_name);
- } else {
- auto it = descriptor->regular_imports().find(variable->raw_name());
- DCHECK(it != descriptor->regular_imports().end());
- RegisterList args = register_allocator()->NewRegisterList(2);
- builder()
- ->LoadLiteral(it->second->import_name->string())
- .StoreAccumulatorInRegister(args[0])
- .LoadLiteral(Smi::FromInt(it->second->module_request))
- .StoreAccumulatorInRegister(args[1])
- .CallRuntime(Runtime::kLoadModuleImport, args);
- }
+ Register index = register_allocator()->NewRegister();
+ builder()
+ ->LoadLiteral(Smi::FromInt(variable->index()))
+ .StoreAccumulatorInRegister(index)
+ .CallRuntime(Runtime::kLoadModuleVariable, index);
if (hole_check_mode == HoleCheckMode::kRequired) {
BuildThrowIfHole(variable->name());
}
@@ -2052,23 +2037,17 @@ void BytecodeGenerator::BuildVariableAssignment(Variable* variable,
// assignments for them.
DCHECK(variable->IsExport());
- ModuleDescriptor* mod = scope()->GetModuleScope()->module();
- // There may be several export names for this local name, but it doesn't
- // matter which one we pick, as they all map to the same cell.
- auto it = mod->regular_exports().find(variable->raw_name());
- DCHECK(it != mod->regular_exports().end());
-
RegisterList args = register_allocator()->NewRegisterList(2);
builder()
->StoreAccumulatorInRegister(args[1])
- .LoadLiteral(it->second->export_name->string())
+ .LoadLiteral(Smi::FromInt(variable->index()))
.StoreAccumulatorInRegister(args[0]);
if (hole_check_mode == HoleCheckMode::kRequired) {
- builder()->CallRuntime(Runtime::kLoadModuleExport, args[0]);
+ builder()->CallRuntime(Runtime::kLoadModuleVariable, args[0]);
BuildHoleCheckForVariableAssignment(variable, op);
}
builder()
- ->CallRuntime(Runtime::kStoreModuleExport, args)
+ ->CallRuntime(Runtime::kStoreModuleVariable, args)
.LoadAccumulatorWithRegister(args[1]);
break;
}
« no previous file with comments | « src/factory.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698