| Index: src/ast/scopes.cc
 | 
| diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
 | 
| index a11689f67a6a261717f4d8011a6a4173a46e6deb..fb170f2740b93ec387e946836d0c0f48d1bf3990 100644
 | 
| --- a/src/ast/scopes.cc
 | 
| +++ b/src/ast/scopes.cc
 | 
| @@ -1084,6 +1084,9 @@ static void PrintLocation(Variable* var) {
 | 
|      case VariableLocation::LOOKUP:
 | 
|        PrintF("lookup");
 | 
|        break;
 | 
| +    case VariableLocation::MODULE:
 | 
| +      PrintF("module");
 | 
| +      break;
 | 
|    }
 | 
|  }
 | 
|  
 | 
| @@ -1492,6 +1495,7 @@ void Scope::PropagateScopeInfo(bool outer_scope_calls_sloppy_eval) {
 | 
|  
 | 
|  
 | 
|  bool Scope::MustAllocate(Variable* var) {
 | 
| +  DCHECK(var->location() != VariableLocation::MODULE);
 | 
|    // Give var a read/write use if there is a chance it might be accessed
 | 
|    // via an eval() call.  This is only possible if the variable has a
 | 
|    // visible name.
 | 
| @@ -1711,6 +1715,21 @@ void DeclarationScope::AllocateLocals(AstValueFactory* ast_value_factory) {
 | 
|    }
 | 
|  }
 | 
|  
 | 
| +void DeclarationScope::AllocateModuleVariables() {
 | 
| +  for (auto entry : module()->imports()) {
 | 
| +    if (entry->local_name == nullptr) continue;
 | 
| +    if (entry->import_name == nullptr) continue;  // Namespace import.
 | 
| +    Variable* var = LookupLocal(entry->local_name);
 | 
| +    // TODO(neis): Use a meaningful index.
 | 
| +    var->AllocateTo(VariableLocation::MODULE, 42);
 | 
| +  }
 | 
| +  for (auto entry : module()->exports()) {
 | 
| +    if (entry->local_name == nullptr) continue;
 | 
| +    Variable* var = LookupLocal(entry->local_name);
 | 
| +    var->AllocateTo(VariableLocation::MODULE, 42);
 | 
| +  }
 | 
| +}
 | 
| +
 | 
|  void Scope::AllocateVariablesRecursively(AstValueFactory* ast_value_factory) {
 | 
|    if (!already_resolved()) {
 | 
|      num_stack_slots_ = 0;
 | 
| @@ -1729,7 +1748,11 @@ void Scope::AllocateVariablesRecursively(AstValueFactory* ast_value_factory) {
 | 
|    // Allocate variables for this scope.
 | 
|    // Parameters must be allocated first, if any.
 | 
|    if (is_declaration_scope()) {
 | 
| -    if (is_function_scope()) AsDeclarationScope()->AllocateParameterLocals();
 | 
| +    if (is_module_scope()) {
 | 
| +      AsDeclarationScope()->AllocateModuleVariables();
 | 
| +    } else if (is_function_scope()) {
 | 
| +      AsDeclarationScope()->AllocateParameterLocals();
 | 
| +    }
 | 
|      AsDeclarationScope()->AllocateReceiver();
 | 
|    }
 | 
|    AllocateNonParameterLocalsAndDeclaredGlobals(ast_value_factory);
 | 
| 
 |