WebAssembly / reference-types

Proposal for adding basic reference types (anyref)
https://webassembly.github.io/reference-types/
Other
162 stars 40 forks source link

Evaluating initializer expressions in element segments when instantiating #112

Closed q82419 closed 4 years ago

q82419 commented 4 years ago

On step 6.a to 6.c of instantiation, a frame is pushed into to stack with an auxiliary module instance that only consists of the imported globals. https://webassembly.github.io/reference-types/core/exec/modules.html#instantiation And then on the step 6.d, reference values are the results of evaluating the initializer expressions. Let's assume there's only a ref.func x instruction in an initializer expression. When evaluating this expression, the ref.func x will be executed with the current frame, which points to the auxiliary module instance. https://webassembly.github.io/reference-types/core/exec/instructions.html#reference-instructions But when executing the ref.func x instruction, it needs to query the function address F.module.funcaddrs[x]. I think that F.module, which is the auxiliary module instance that only consists of the imported globals, has no function addresses, right?

rossberg commented 4 years ago

Good catch, you are right. Please see #115 for a fix.

q82419 commented 4 years ago

Thanks :)