diff options
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r-- | src/wasm-binary.h | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 3985bae04..3ce76e247 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -840,9 +840,8 @@ public: } void emitMemoryAccess(size_t alignment, size_t bytes, uint32_t offset) { - o << int8_t( ((alignment == bytes || alignment == 0) ? BinaryConsts::NaturalAlignment : BinaryConsts::Alignment) | - (offset ? BinaryConsts::Offset : 0) ); - if (offset) o << LEB128(offset); + o << LEB128(Log2(alignment ? alignment : bytes)); + o << LEB128(offset); } void visitLoad(Load *curr) { @@ -1682,13 +1681,8 @@ public: } void readMemoryAccess(uint32_t& alignment, size_t bytes, uint32_t& offset) { - auto value = getInt8(); - alignment = value & BinaryConsts::Alignment ? 1 : bytes; - if (value & BinaryConsts::Offset) { - offset = getLEB128(); - } else { - offset = 0; - } + alignment = Pow2(getLEB128()); + offset = getLEB128(); } bool maybeVisitImpl(Load *curr, uint8_t code) { |