diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-03-16 17:51:29 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-03-16 17:51:29 -0700 |
commit | 2467f6f72ecdd1e3f5353abecc67e8e8241f93e6 (patch) | |
tree | 7b4bb91f8e1ecc3df2dcea37541625c02f953c45 /src | |
parent | 3245c24d1fd59c2d4a969570743f764022eb5033 (diff) | |
download | binaryen-2467f6f72ecdd1e3f5353abecc67e8e8241f93e6.tar.gz binaryen-2467f6f72ecdd1e3f5353abecc67e8e8241f93e6.tar.bz2 binaryen-2467f6f72ecdd1e3f5353abecc67e8e8241f93e6.zip |
update memory access in binary format
Diffstat (limited to 'src')
-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) { |