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

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

Issue 2388153003: [modules] Implement namespace imports. (Closed)
Patch Set: Add comment on VisitModuleNamespaceImports. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.h ('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 c7d333f0a534fc194c367304cbd8dafe99706248..76b97b9015b6eb4e8a55dcc2236d7e8a902368f7 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -674,6 +674,9 @@ void BytecodeGenerator::GenerateBytecodeBody() {
// Visit declarations within the function scope.
VisitDeclarations(scope()->declarations());
+ // Emit initializing assignments for module namespace imports (if any).
+ VisitModuleNamespaceImports();
+
// Perform a stack-check before the body.
builder()->StackCheck(info()->literal()->start_position());
@@ -873,6 +876,24 @@ void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) {
}
}
+void BytecodeGenerator::VisitModuleNamespaceImports() {
+ if (!scope()->is_module_scope()) return;
+
+ RegisterAllocationScope register_scope(this);
+ Register module_request = register_allocator()->NewRegister();
+
+ ModuleDescriptor* descriptor = scope()->AsModuleScope()->module();
+ for (auto entry : descriptor->namespace_imports()) {
+ builder()
+ ->LoadLiteral(Smi::FromInt(entry->module_request))
+ .StoreAccumulatorInRegister(module_request)
+ .CallRuntime(Runtime::kGetModuleNamespace, module_request);
+ Variable* var = scope()->LookupLocal(entry->local_name);
+ DCHECK_NOT_NULL(var);
+ VisitVariableAssignment(var, Token::INIT, FeedbackVectorSlot::Invalid());
+ }
+}
+
void BytecodeGenerator::VisitDeclarations(
ZoneList<Declaration*>* declarations) {
RegisterAllocationScope register_scope(this);
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698