wagon icon indicating copy to clipboard operation
wagon copied to clipboard

wasm: ExecInitExpr is done too early

Open losfair opened this issue 7 years ago • 1 comments

The execution of case getGlobal in ExecInitExpr depends on runtime imports to work correctly. We don't have that information before imports get resolved and therefore cannot execute init expressions ahead of time.

losfair avatar Aug 25 '18 14:08 losfair

In the docs it says:

In the MVP, to keep things simple while still supporting the basic needs of dynamic linking, initializer expressions are restricted to the following nullary operators:

 - the four constant operators; and
 - get_global, where the global index must refer to an immutable import.

The current implementation appears to work for globals that are defined before the global referencing it is defined (index-wise) - does that not suit?

I guess we could re-order module initialization or do two passes to resolve this if necessary.

twitchyliquid64 avatar Mar 23 '19 18:03 twitchyliquid64