diff options
author | Sam Clegg <sbc@chromium.org> | 2017-04-28 21:12:09 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2017-04-28 21:12:09 +0000 |
commit | ff0730b3fcd488caf121e2e4d1aa8506ff13f3c6 (patch) | |
tree | 1ef967cec5a0f6d43a28015a9bd81ede35262ad4 /llvm/lib/MC/WasmObjectWriter.cpp | |
parent | 267ba94ce6593ba09b1d45ac04d8cc5851685f9c (diff) | |
download | bcm5719-llvm-ff0730b3fcd488caf121e2e4d1aa8506ff13f3c6.tar.gz bcm5719-llvm-ff0730b3fcd488caf121e2e4d1aa8506ff13f3c6.zip |
[WebAssembly] Write initial memory in pages not bytes
Subscribers: jfb, dschuff
Differential Revision: https://reviews.llvm.org/D32660
llvm-svn: 301687
Diffstat (limited to 'llvm/lib/MC/WasmObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/WasmObjectWriter.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index 6444046a30d..ae66829741b 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -913,12 +913,14 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm, // For now, always emit the memory section, since loads and stores are not // valid without it. In the future, we could perhaps be more clever and omit // it if there are no loads or stores. - startSection(Section, wasm::WASM_SEC_MEMORY); + uint32_t NumPages = + (DataBytes.size() + wasm::WasmPageSize - 1) / wasm::WasmPageSize; + startSection(Section, wasm::WASM_SEC_MEMORY); encodeULEB128(1, getStream()); // number of memory spaces encodeULEB128(0, getStream()); // flags - encodeULEB128(DataBytes.size(), getStream()); // initial + encodeULEB128(NumPages, getStream()); // initial endSection(Section); |