diff options
author | Derek Schuff <dschuff@chromium.org> | 2016-03-09 17:38:56 -0800 |
---|---|---|
committer | Derek Schuff <dschuff@chromium.org> | 2016-03-09 17:38:56 -0800 |
commit | 864fa9c37ba1b33605805d89ab920e6fa4e67a38 (patch) | |
tree | c2cb837f4285b06b47bbb017a909df718673b7c1 /src/wasm-binary.h | |
parent | e9d98deed872a72a826f78c8525464c446c6f21b (diff) | |
parent | ac9d61d45fec988640b57dc6b9de97e7d46c41f5 (diff) | |
download | binaryen-864fa9c37ba1b33605805d89ab920e6fa4e67a38.tar.gz binaryen-864fa9c37ba1b33605805d89ab920e6fa4e67a38.tar.bz2 binaryen-864fa9c37ba1b33605805d89ab920e6fa4e67a38.zip |
Merge pull request #225 from WebAssembly/memory_pages
Make initial and max memory sizes be in pages instead of bytes
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r-- | src/wasm-binary.h | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 8a03ca843..715c06287 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -287,6 +287,10 @@ enum ASTNodes { F64ConvertF32 = 0xb2, F64ReinterpretI64 = 0xb3, I64ReinterpretF64 = 0xb5, + I32RotR = 0xb6, + I32RotL = 0xb7, + I64RotR = 0xb8, + I64RotL = 0xb9, I32ReinterpretF32 = 0xfe, // XXX not in v8 spec doc I32LoadMem8S = 0x20, @@ -402,18 +406,10 @@ public: void writeMemory() { if (wasm->memory.max == 0) return; if (debug) std::cerr << "== writeMemory" << std::endl; - o << int8_t(BinaryConsts::Memory); - if (wasm->memory.initial == 0) { // XXX diverge from v8, 0 means 0, 1 and above are powers of 2 starting at 0 - o << int8_t(0); - } else { - o << int8_t(std::min(ceil(log2(wasm->memory.initial)), 31.0) + 1); // up to 31 bits, don't let ceil get us to UINT_MAX which can overflow - } - if (wasm->memory.max == 0) { - o << int8_t(0); - } else { - o << int8_t(std::min(ceil(log2(wasm->memory.max)), 31.0) + 1); - } - o << int8_t(1); // export memory + o << int8_t(BinaryConsts::Memory) + << LEB128(wasm->memory.initial) + << LEB128(wasm->memory.max) + << int8_t(1); // export memory } void writeSignatures() { @@ -891,6 +887,8 @@ public: case Shl: INT_TYPED_CODE(Shl);; case ShrU: INT_TYPED_CODE(ShrU); case ShrS: INT_TYPED_CODE(ShrS); + case RotL: INT_TYPED_CODE(RotL); + case RotR: INT_TYPED_CODE(RotR); case Div: FLOAT_TYPED_CODE(Div); case CopySign: FLOAT_TYPED_CODE(CopySign); case Min: FLOAT_TYPED_CODE(Min); @@ -1088,10 +1086,8 @@ public: void readMemory() { if (debug) std::cerr << "== readMemory" << std::endl; - size_t initial = getInt8(); - wasm.memory.initial = initial == 0 ? 0 : std::pow<size_t>(2, initial - 1); - size_t max = getInt8(); - wasm.memory.max = max == 0 ? 0 : std::pow<size_t>(2, max - 1); + wasm.memory.initial = getLEB128(); + wasm.memory.max = getLEB128(); verifyInt8(1); // export memory } @@ -1603,6 +1599,8 @@ public: INT_TYPED_CODE(Shl); INT_TYPED_CODE(ShrU); INT_TYPED_CODE(ShrS); + INT_TYPED_CODE(RotL); + INT_TYPED_CODE(RotR); FLOAT_TYPED_CODE(Div); FLOAT_TYPED_CODE(CopySign); FLOAT_TYPED_CODE(Min); @@ -1671,4 +1669,3 @@ public: } // namespace wasm #endif // wasm_wasm_binary_h - |