diff options
author | Wouter van Oortmerssen <aardappel@gmail.com> | 2021-02-25 13:18:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-25 13:18:34 -0800 |
commit | 7977ad58a367f49555c70ea5f0f0f6ab06b28903 (patch) | |
tree | 92afec6d6555f653c863a372fbfddcc66fd1d9ba /src/wasm/wasm-validator.cpp | |
parent | 04c1515acb354714af3d07fe2a3b65b2bb0398ab (diff) | |
download | binaryen-7977ad58a367f49555c70ea5f0f0f6ab06b28903.tar.gz binaryen-7977ad58a367f49555c70ea5f0f0f6ab06b28903.tar.bz2 binaryen-7977ad58a367f49555c70ea5f0f0f6ab06b28903.zip |
Support 64-bit data segment init-exps in Memory64 (#3593)
This as a consequence of https://reviews.llvm.org/D95651
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 6bcdb0e7c..7e9c30c77 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2818,7 +2818,7 @@ static void validateMemory(Module& module, ValidationInfo& info) { "memory is shared, but atomics are disabled"); } for (auto& segment : curr.segments) { - Index size = segment.data.size(); + auto size = segment.data.size(); if (segment.isPassive) { info.shouldBeTrue(module.features.hasBulkMemory(), segment.offset, @@ -2828,11 +2828,20 @@ static void validateMemory(Module& module, ValidationInfo& info) { segment.offset, "passive segment should not have an offset"); } else { - if (!info.shouldBeEqual(segment.offset->type, - Type(Type::i32), - segment.offset, - "segment offset should be i32")) { - continue; + if (curr.is64()) { + if (!info.shouldBeEqual(segment.offset->type, + Type(Type::i64), + segment.offset, + "segment offset should be i64")) { + continue; + } + } else { + if (!info.shouldBeEqual(segment.offset->type, + Type(Type::i32), + segment.offset, + "segment offset should be i32")) { + continue; + } } info.shouldBeTrue(checkSegmentOffset(segment.offset, segment.data.size(), @@ -2840,8 +2849,8 @@ static void validateMemory(Module& module, ValidationInfo& info) { segment.offset, "memory segment offset should be reasonable"); if (segment.offset->is<Const>()) { - Index start = segment.offset->cast<Const>()->value.geti32(); - Index end = start + size; + auto start = segment.offset->cast<Const>()->value.getUnsigned(); + auto end = start + size; info.shouldBeTrue(end <= curr.initial * Memory::kPageSize, segment.data.size(), "segment size should fit in memory (end)"); |