Chromium Code Reviews| Index: src/interpreter/bytecode-generator.cc |
| diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
| index c7d333f0a534fc194c367304cbd8dafe99706248..2bdc6c47575816b8d6c6a437ebbe71029068a6be 100644 |
| --- a/src/interpreter/bytecode-generator.cc |
| +++ b/src/interpreter/bytecode-generator.cc |
| @@ -674,6 +674,8 @@ void BytecodeGenerator::GenerateBytecodeBody() { |
| // Visit declarations within the function scope. |
| VisitDeclarations(scope()->declarations()); |
| + VisitModuleNamespaceImports(); |
|
Michael Starzinger
2016/10/05 13:07:30
nit: Please add "// Visit module imports if needed
neis
2016/10/06 08:56:44
Done.
|
| + |
| // Perform a stack-check before the body. |
| builder()->StackCheck(info()->literal()->start_position()); |
| @@ -873,6 +875,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); |