summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passes/Memory64Lowering.cpp3
-rw-r--r--src/wasm/wasm-binary.cpp13
2 files changed, 13 insertions, 3 deletions
diff --git a/src/passes/Memory64Lowering.cpp b/src/passes/Memory64Lowering.cpp
index 5e1004797..c376ed6c6 100644
--- a/src/passes/Memory64Lowering.cpp
+++ b/src/passes/Memory64Lowering.cpp
@@ -98,6 +98,9 @@ struct Memory64Lowering : public WalkerPass<PostWalker<Memory64Lowering>> {
}
// This is visited last.
memory->indexType = Type::i32;
+ if (memory->hasMax() && memory->max > Memory::kMaxSize32) {
+ memory->max = Memory::kMaxSize32;
+ }
}
};
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 0b3ed0b53..43ab509a8 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -107,9 +107,16 @@ void WasmBinaryWriter::writeResizableLimits(
(shared ? (uint32_t)BinaryConsts::IsShared : 0U) |
(is64 ? (uint32_t)BinaryConsts::Is64 : 0U);
o << U32LEB(flags);
- o << U32LEB(initial);
- if (hasMaximum) {
- o << U32LEB(maximum);
+ if (is64) {
+ o << U64LEB(initial);
+ if (hasMaximum) {
+ o << U64LEB(maximum);
+ }
+ } else {
+ o << U32LEB(initial);
+ if (hasMaximum) {
+ o << U32LEB(maximum);
+ }
}
}