-
Notifications
You must be signed in to change notification settings - Fork 7
Unstable indices #21
Description
The only way to statically identify functions, tables, memories, and globals within a wasm module in is by index, and conditional sections can mean that indices can be dependent on instantiation-time resolution. This complicates some analysis and transformation use cases.
Consider a wasm transformation that takes a module, inserts a function, and then inserts some calls to that function. With wasm today, this is relatively straightforward, and there are multiple tools that can do it. But with conditional sections, doing this correctly in general can get complex, because you can't easily insert calls which reliably name the function you inserted.
Or, consider an analysis tool that wants to do program slice analysis, for example, looking backwards from every WASI call which uses a filesystem path. With conditional sections, it's not possible, in general, to identify which calls in a module are calls to filesystem functions without knowing the conditions that will be selected at instantiation time.
It's worth pointing out that this second problem also occurs with call_indirect -- if you place a function in a table, potentially any call_indirect function in the program can call it. A key difference though is that tables only contain functions that have their address taken. Conditional sections affect every function that occurs after them in the index space.