diff options
author | Heejin Ahn <aheejin@gmail.com> | 2019-12-20 19:38:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-20 19:38:07 -0800 |
commit | 8f78bb90561fa17791ae6b865c4238b5fca1b8d4 (patch) | |
tree | 9c87763572fcea5c399138da0c42067a531285e7 /src | |
parent | 3f6fd583ca283c12f05c1258962cebdd2202e949 (diff) | |
download | binaryen-8f78bb90561fa17791ae6b865c4238b5fca1b8d4.tar.gz binaryen-8f78bb90561fa17791ae6b865c4238b5fca1b8d4.tar.bz2 binaryen-8f78bb90561fa17791ae6b865c4238b5fca1b8d4.zip |
Fix memory size calculation in MemoryPacking (#2548)
Because `memory.size` returns the size in number of pages, we have to
multiply the size with the page size when converting `memory.init`.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/MemoryPacking.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/passes/MemoryPacking.cpp b/src/passes/MemoryPacking.cpp index 18207026a..98c7cce00 100644 --- a/src/passes/MemoryPacking.cpp +++ b/src/passes/MemoryPacking.cpp @@ -140,7 +140,12 @@ struct MemoryPacking : public Pass { builder.makeBinary( OrInt32, builder.makeBinary( - GtUInt32, curr->dest, builder.makeHost(MemorySize, Name(), {})), + GtUInt32, + curr->dest, + builder.makeBinary( + MulInt32, + builder.makeConst(Literal(Memory::kPageSize)), + builder.makeHost(MemorySize, Name(), {}))), builder.makeBinary(OrInt32, curr->offset, curr->size)), builder.makeUnreachable())); changed = true; |