diff options
Diffstat (limited to 'src/binaryen-shell.cpp')
-rw-r--r-- | src/binaryen-shell.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/binaryen-shell.cpp b/src/binaryen-shell.cpp index 61cab723c..93d4c65ce 100644 --- a/src/binaryen-shell.cpp +++ b/src/binaryen-shell.cpp @@ -66,8 +66,8 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { std::vector<char> memory; template <typename T> static bool aligned(const char* address) { - static_assert(!(alignof(T) & (alignof(T) - 1)), "must be a power of 2"); - return 0 == (reinterpret_cast<uintptr_t>(address) & (alignof(T) - 1)); + static_assert(!(sizeof(T) & (sizeof(T) - 1)), "must be a power of 2"); + return 0 == (reinterpret_cast<uintptr_t>(address) & (sizeof(T) - 1)); } Memory(Memory&) = delete; Memory& operator=(const Memory&) = delete; @@ -111,10 +111,10 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { ShellExternalInterface() : memory() {} void init(Module& wasm) override { - memory.resize(wasm.memory.initial); + memory.resize(wasm.memory.initial * wasm::Memory::kPageSize); // apply memory segments for (auto segment : wasm.memory.segments) { - assert(segment.offset + segment.size <= wasm.memory.initial); + assert(segment.offset + segment.size <= wasm.memory.initial * wasm::Memory::kPageSize); for (size_t i = 0; i != segment.size; ++i) { memory.set(segment.offset + i, segment.data[i]); } @@ -178,9 +178,9 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { } case i64: { switch (store->bytes) { - case 1: memory.set<int8_t>(addr, value.geti64()); break; - case 2: memory.set<int16_t>(addr, value.geti64()); break; - case 4: memory.set<int32_t>(addr, value.geti64()); break; + case 1: memory.set<int8_t>(addr, (int8_t)value.geti64()); break; + case 2: memory.set<int16_t>(addr, (int16_t)value.geti64()); break; + case 4: memory.set<int32_t>(addr, (int32_t)value.geti64()); break; case 8: memory.set<int64_t>(addr, value.geti64()); break; default: abort(); } @@ -248,7 +248,7 @@ static void run_asserts(size_t* i, bool* checked, AllocatingModule* wasm, if (wasm) { interface = new ShellExternalInterface(); instance = new ModuleInstance(*wasm, interface); - if (entry.is() > 0) { + if (entry.is()) { Function* function = wasm->functionsMap[entry]; if (!function) { std::cerr << "Unknown entry " << entry << std::endl; @@ -259,7 +259,7 @@ static void run_asserts(size_t* i, bool* checked, AllocatingModule* wasm, } try { instance->callExport(entry, arguments); - } catch (ExitException& x) { + } catch (ExitException&) { } } } @@ -287,7 +287,7 @@ static void run_asserts(size_t* i, bool* checked, AllocatingModule* wasm, throw ParseException(); }) ); - } catch (const ParseException& e) { + } catch (const ParseException&) { invalid = true; } if (!invalid) { @@ -307,7 +307,7 @@ static void run_asserts(size_t* i, bool* checked, AllocatingModule* wasm, try { Invocation invocation(*curr[1], instance, *builder->get()); result = invocation.invoke(); - } catch (const TrapException& e) { + } catch (const TrapException&) { trapped = true; } if (id == ASSERT_RETURN) { |