Index: src/x64/full-codegen-x64.cc |
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc |
index 1949c316cb1d9de1dfedeff644ad81417106aa2b..6ee32c1daeb6604b8945bb3191a0ffb0a714538f 100644 |
--- a/src/x64/full-codegen-x64.cc |
+++ b/src/x64/full-codegen-x64.cc |
@@ -759,8 +759,7 @@ void FullCodeGenerator::PrepareForBailoutBeforeSplit(Expression* expr, |
void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { |
- // The variable in the declaration always resides in the current function |
- // context. |
+ // The variable in the declaration always resides in the current context. |
ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); |
if (generate_debug_code_) { |
// Check that we're not inside a with or catch context. |
@@ -891,33 +890,32 @@ void FullCodeGenerator::VisitFunctionDeclaration( |
void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { |
- VariableProxy* proxy = declaration->proxy(); |
- Variable* variable = proxy->var(); |
- Handle<JSModule> instance = declaration->module()->interface()->Instance(); |
- ASSERT(!instance.is_null()); |
+ Variable* variable = declaration->proxy()->var(); |
+ ASSERT(variable->location() == Variable::CONTEXT); |
+ ASSERT(variable->interface()->IsFrozen()); |
- switch (variable->location()) { |
- case Variable::UNALLOCATED: { |
- Comment cmnt(masm_, "[ ModuleDeclaration"); |
- globals_->Add(variable->name(), zone()); |
- globals_->Add(instance, zone()); |
- Visit(declaration->module()); |
- break; |
- } |
+ Comment cmnt(masm_, "[ ModuleDeclaration"); |
+ EmitDebugCheckDeclarationContext(variable); |
- case Variable::CONTEXT: { |
- Comment cmnt(masm_, "[ ModuleDeclaration"); |
- EmitDebugCheckDeclarationContext(variable); |
- __ Move(ContextOperand(rsi, variable->index()), instance); |
- Visit(declaration->module()); |
- break; |
- } |
+ // Load instance object. |
+ __ LoadContext(rax, scope_->ContextChainLength(scope_->GlobalScope())); |
+ __ movq(rax, ContextOperand(rax, variable->interface()->Index())); |
+ __ movq(rax, ContextOperand(rax, Context::EXTENSION_INDEX)); |
- case Variable::PARAMETER: |
- case Variable::LOCAL: |
- case Variable::LOOKUP: |
- UNREACHABLE(); |
- } |
+ // Assign it. |
+ __ movq(ContextOperand(rsi, variable->index()), rax); |
+ // We know that we have written a module, which is not a smi. |
+ __ RecordWriteContextSlot(rsi, |
+ Context::SlotOffset(variable->index()), |
+ rax, |
+ rcx, |
+ kDontSaveFPRegs, |
+ EMIT_REMEMBERED_SET, |
+ OMIT_SMI_CHECK); |
+ PrepareForBailoutForId(declaration->proxy()->id(), NO_REGISTERS); |
+ |
+ // Traverse into body. |
+ Visit(declaration->module()); |
} |
@@ -959,6 +957,14 @@ void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
} |
+void FullCodeGenerator::DeclareModules(Handle<FixedArray> descriptions) { |
+ // Call the runtime to declare the modules. |
+ __ Push(descriptions); |
+ __ CallRuntime(Runtime::kDeclareModules, 1); |
+ // Return value is ignored. |
+} |
+ |
+ |
void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
Comment cmnt(masm_, "[ SwitchStatement"); |
Breakable nested_statement(this, stmt); |
@@ -1368,9 +1374,9 @@ void FullCodeGenerator::EmitDynamicLookupFastCase(Variable* var, |
} else if (var->mode() == DYNAMIC_LOCAL) { |
Variable* local = var->local_if_not_shadowed(); |
__ movq(rax, ContextSlotOperandCheckExtensions(local, slow)); |
- if (local->mode() == CONST || |
- local->mode() == CONST_HARMONY || |
- local->mode() == LET) { |
+ if (local->mode() == LET || |
+ local->mode() == CONST || |
+ local->mode() == CONST_HARMONY) { |
__ CompareRoot(rax, Heap::kTheHoleValueRootIndex); |
__ j(not_equal, done); |
if (local->mode() == CONST) { |