summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-01-28 17:25:50 -0800
committerAlon Zakai <alonzakai@gmail.com>2016-01-28 17:25:50 -0800
commit8ed5ab1e5610df34d781d346c1e50ec04d1a4036 (patch)
tree01b1c2c6f56481b47dbfddd9ac4f99e267d34efe
parent991891ef329f099ab2927af173dc920bfe2f9234 (diff)
downloadbinaryen-8ed5ab1e5610df34d781d346c1e50ec04d1a4036.tar.gz
binaryen-8ed5ab1e5610df34d781d346c1e50ec04d1a4036.tar.bz2
binaryen-8ed5ab1e5610df34d781d346c1e50ec04d1a4036.zip
current binary format has power of 2 memory, so use ceil to ensure that the conversion only increases memory, and does not make it too small for the segments
-rw-r--r--src/wasm-binary.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index d2959c69d..aea31233d 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -390,8 +390,8 @@ public:
void writeMemory() {
if (wasm->memory.max == 0) return;
if (debug) std::cerr << "== writeMemory" << std::endl;
- o << int8_t(BinaryConsts::Memory) << int8_t(log2(wasm->memory.initial))
- << int8_t(log2(wasm->memory.max))
+ o << int8_t(BinaryConsts::Memory) << int8_t(ceil(log2(wasm->memory.initial)))
+ << int8_t(ceil(log2(wasm->memory.max)))
<< int8_t(1); // export memory
}