Index: src/code-stub-assembler.cc |
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc |
index 970dc4f54230a7f30747f82b016bf90b0f6e7a3c..4847366c3ef1f05be572b94de07c3c87d58a8a59 100644 |
--- a/src/code-stub-assembler.cc |
+++ b/src/code-stub-assembler.cc |
@@ -1276,6 +1276,27 @@ Node* CodeStubAssembler::LoadNativeContext(Node* context) { |
return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); |
} |
+Node* CodeStubAssembler::LoadModuleContext(Node* context) { |
+ Variable var_context(this, MachineRepresentation::kTaggedPointer); |
+ var_context.Bind(context); |
+ |
+ Label loop_start(this, &var_context), loop_end(this); |
+ Goto(&loop_start); |
+ Bind(&loop_start); |
+ { |
+ Node* context_map = LoadMap(var_context.value()); |
+ Node* is_module_context = |
+ WordEqual(context_map, LoadRoot(Heap::kModuleContextMapRootIndex)); |
+ GotoIf(is_module_context, &loop_end); |
+ |
+ var_context.Bind( |
+ LoadContextElement(var_context.value(), Context::PREVIOUS_INDEX)); |
+ Goto(&loop_start); |
+ } |
+ Bind(&loop_end); |
+ return var_context.value(); |
+} |
+ |
Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, |
Node* native_context) { |
CSA_ASSERT(IsNativeContext(native_context)); |