[WASM] Implement thin-to-thick semantic for WebAssembly #186
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolve #30
This IRGen change enables us to call
thin-to-thicked functions safely on WebAssembly runtime.For example, the following SIL uses
thin_to_thick_functioninstruction to transform thin function (which means there is no context argument in the last of arguments list) to thick function.On x86_64 architecture, that SIL is transformed into the following LLVM IR
On x86_64, the trailing
swiftselfis put inr13register, so it's OK that there is a difference of trailingswiftselfparameter between callee and calling signature.But this IR is invalid on WebAssembly because WebAssembly runtime validation spec requires they should be same signature when calling function indirectly.
So I changed to emit a thunk function to match these function signatures like the following LLVM IR.
$s16closureToConvertTujust proxy forwards the invocation to actual function which is come from trailing context pointer.This change makes some failing test cases with optimization passed without indirect function call error.