This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Use a separate wasm data segment for each global symbol
ClosedPublic

Authored by sbc100 on Sep 13 2017, 4:30 PM.

Details

Summary

This is stepping stone towards honoring -fdata-sections
and letting the assembler decide how many wasm data
segments to create.

This behaviour is also closer to what s2wasm currently does.

Event Timeline

sbc100 created this revision.Sep 13 2017, 4:30 PM
sbc100 updated this revision to Diff 115137.Sep 13 2017, 4:31 PM

remove debugging

sbc100 edited the summary of this revision. (Show Details)Sep 13 2017, 4:32 PM
sbc100 added a reviewer: dschuff.
sbc100 added a subscriber: llvm-commits.
sbc100 updated this revision to Diff 115138.Sep 13 2017, 4:34 PM
  • restore debugging
dschuff added inline comments.Sep 14 2017, 11:05 AM
lib/MC/WasmObjectWriter.cpp
99

Might be worth putting a comment here (or somewhere) mentioning that because wasm binaries have only one real data section (which is allocated/mapped over the whole memory), each segment has to track its "virtual" section/subsection/whatever we want to call it.

102

IIRC A SmallVector with size 0 is no better (worse actually) than a std::vector. We could just use std::vector, or I guess if we really do want one segment per LLVM global, then 4 will be the most common size, so we could just use a Smallvector<4>.

271

APIs should just take SmallVectorImpl parameters, and then any size SmallVector can be used as an argument.

sbc100 updated this revision to Diff 115298.Sep 14 2017, 2:52 PM
sbc100 marked 2 inline comments as done.
  • review feedback
  • Merge remote-tracking branch 'origin/master' into data_sections
sbc100 added inline comments.Sep 14 2017, 3:27 PM
lib/MC/WasmObjectWriter.cpp
102

Hmm... look like this was inherited from the existing code. I'll change it to 4 for now and revisit in a followup.

271

Actually it looks like these can take ArrayRef? Would that make sense? If its OK with you I'll make a separate change for that... maybe I can land that one first?

dschuff accepted this revision.Sep 14 2017, 3:34 PM
dschuff added inline comments.
lib/MC/WasmObjectWriter.cpp
102

sounds good.

271

Yeah, separate change is fine, this is preexisting for the other functions too.

This revision is now accepted and ready to land.Sep 14 2017, 3:34 PM

Oh also a nit: It's spelled 'separate' :D

sbc100 retitled this revision from [WebAssembly] Use a seperate wasm data segment for each global symbol to [WebAssembly] Use a separate wasm data segment for each global symbol.Sep 14 2017, 4:03 PM
This revision was automatically updated to reflect the committed changes.
This comment was removed by sbc100.