Index: src/wasm/wasm-module.cc |
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc |
index f57226cf2750fcbd9eedeed7ffe810fb19189dee..a81b344dcc83cb088d752f15b326677125316549 100644 |
--- a/src/wasm/wasm-module.cc |
+++ b/src/wasm/wasm-module.cc |
@@ -1219,11 +1219,6 @@ class WasmInstanceBuilder { |
LoadDataSegments(nullptr, 0); |
} |
- DCHECK(wasm::IsWasmInstance(*instance)); |
- if (instance->has_memory_object()) { |
- instance->get_memory_object()->AddInstance(isolate_, instance); |
- } |
- |
//-------------------------------------------------------------------------- |
// Set up the runtime support for the new instance. |
//-------------------------------------------------------------------------- |
@@ -1247,6 +1242,14 @@ class WasmInstanceBuilder { |
ProcessExports(code_table, instance); |
//-------------------------------------------------------------------------- |
+ // Add instance to Memory object |
+ //-------------------------------------------------------------------------- |
+ DCHECK(wasm::IsWasmInstance(*instance)); |
+ if (instance->has_memory_object()) { |
+ instance->get_memory_object()->AddInstance(isolate_, instance); |
+ } |
+ |
+ //-------------------------------------------------------------------------- |
// Set up the indirect function tables for the new instance. |
//-------------------------------------------------------------------------- |
if (function_table_count > 0) InitializeTables(code_table, instance); |
@@ -1291,6 +1294,7 @@ class WasmInstanceBuilder { |
} |
} |
+ //-------------------------------------------------------------------------- |
// Set up and link the new instance. |
//-------------------------------------------------------------------------- |
{ |