This is an archive of the discontinued LLVM Phabricator instance.

[lld][WebAssembly] Handle 4gb max memories
ClosedPublic

Authored by tlively on Apr 3 2020, 4:24 PM.

Details

Summary

A previous change (53211a) had updated the argument parsing to handle
large max memories, but 4294967296 would still wrap to zero after the
options were parsed. This change updates the configuration to use a
64-bit integer to store the max memory to avoid that overflow.

Diff Detail

Event Timeline

tlively created this revision.Apr 3 2020, 4:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 3 2020, 4:24 PM
sbc100 accepted this revision.Apr 3 2020, 5:10 PM

Do we want have this behind some kind of feature bit eventually?

This revision is now accepted and ready to land.Apr 3 2020, 5:10 PM

Do we want have this behind some kind of feature bit eventually?

Hmm, that seems unnecessary because the user already has to explicitly opt in to their preferred max memory size. I should probably add validation that the max is no more than 4gb for now, though.

tlively updated this revision to Diff 255876.Apr 7 2020, 6:48 PM
  • Add error checking and make zStackSize 64-bit too

@sbc100 if you could take a look at the new error handling too, that would be great

majnemer added inline comments.
lld/wasm/Writer.cpp
291

Should this be 4294967295?

304

Ditto.

tlively marked an inline comment as done.Apr 8 2020, 9:51 AM
tlively added inline comments.
lld/wasm/Writer.cpp
291

No, we want to allow exactly 2^32 but nothing more. The highest possible index into a 4GB memory is 4294967295, but the size is still 4GB exactly.

sbc100 accepted this revision.Apr 9 2020, 1:00 PM

still lgtm

This revision was automatically updated to reflect the committed changes.