We could split up module parsing to: First parse the header, then parse the functions. After parsing the header, we check if there is a memory import and an import object. If we can lookup the memory field in the import object without side effects, we could look it up, and then pass its mode it into function parsing. This would prevent the possibility of a recompile.