This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Emit type signatures for declared functions
ClosedPublic

Authored by dschuff on Jun 1 2016, 4:54 PM.

Details

Summary

Under emscripten, C code can take the address of a function implemented
in Javascript (which is exposed via an import in wasm). Because imports
do not have linear memory address in wasm, we need to generate a thunk
to be the target of the indirect call; it call the import directly.

To make this possible, LLVM needs to emit the type signatures for these
functions, because they may not be called directly or referred to other
than where the address is taken.

This uses s new .s directive (.functype) which specifies the signature.

Diff Detail

Repository
rL LLVM

Event Timeline

dschuff updated this revision to Diff 59310.Jun 1 2016, 4:54 PM
dschuff retitled this revision from to [WebAssembly] Emit type signatures for declared functions.
dschuff updated this object.
dschuff added a reviewer: sunfish.
dschuff added a subscriber: llvm-commits.
dschuff updated this revision to Diff 59311.Jun 1 2016, 4:56 PM
  • clang-format
dschuff updated this revision to Diff 59312.Jun 1 2016, 4:59 PM
  • Add dox comment, fix typo
sunfish accepted this revision.Jun 2 2016, 2:24 PM
sunfish edited edge metadata.

Ok, as we discussed on IRC, we may do other things in the future, but for now this looks good.

lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
43 ↗(On Diff #59312)

This should probably contain an abort so that we don't have a silent difference between a .s file and a .o file.

This revision is now accepted and ready to land.Jun 2 2016, 2:24 PM
dschuff updated this revision to Diff 59461.Jun 2 2016, 2:39 PM
dschuff marked an inline comment as done.
dschuff edited edge metadata.
  • clang-format
  • Add dox comment, fix typo
  • Add unreachable to catch unimplemented case for non-asm streamer
This revision was automatically updated to reflect the committed changes.