summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.h
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2016-05-11 15:34:49 -0700
committerDerek Schuff <dschuff@chromium.org>2016-05-11 15:34:49 -0700
commitac827e35fec84074d9d8141ca2c94ad01ca9c5c3 (patch)
tree38f1c4b00de8af9f0545974847e4ab04f13b45fd /src/wasm-interpreter.h
parent9c79f86a3f518c60840b416287a5d26502911ad6 (diff)
downloadbinaryen-ac827e35fec84074d9d8141ca2c94ad01ca9c5c3.tar.gz
binaryen-ac827e35fec84074d9d8141ca2c94ad01ca9c5c3.tar.bz2
binaryen-ac827e35fec84074d9d8141ca2c94ad01ca9c5c3.zip
Introduce a separate type for linear memory addresses (#477)
We've been using size_t (and other things) for addresses, which is generally wrong because it depends on the host, when it should in fact depend on the target. This is a partial fix for #278 (i.e. it's the right fix, I don't think it's applied quite everywhere yet).
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r--src/wasm-interpreter.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 584e4cab4..c40132b18 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -92,9 +92,9 @@ public:
struct ExternalInterface {
virtual void init(Module& wasm) {}
virtual Literal callImport(Import* import, LiteralList& arguments) = 0;
- virtual Literal load(Load* load, size_t addr) = 0;
- virtual void store(Store* store, size_t addr, Literal value) = 0;
- virtual void growMemory(size_t oldSize, size_t newSize) = 0;
+ virtual Literal load(Load* load, Address addr) = 0;
+ virtual void store(Store* store, Address addr, Literal value) = 0;
+ virtual void growMemory(Address oldSize, Address newSize) = 0;
virtual void trap(const char* why) = 0;
};
@@ -722,10 +722,10 @@ private:
return ret;
}
- size_t memorySize; // in pages
+ Address memorySize; // in pages
template <class LS>
- size_t getFinalAddress(LS* curr, Literal ptr) {
+ Address getFinalAddress(LS* curr, Literal ptr) {
auto trapIfGt = [this](uint64_t lhs, uint64_t rhs, const char* msg) {
if (lhs > rhs) {
std::stringstream ss;
@@ -733,7 +733,7 @@ private:
externalInterface->trap(ss.str().c_str());
}
};
- uint32_t memorySizeBytes = memorySize * Memory::kPageSize;
+ Address memorySizeBytes = memorySize * Memory::kPageSize;
uint64_t addr = ptr.type == i32 ? ptr.geti32() : ptr.geti64();
trapIfGt(curr->offset, memorySizeBytes, "offset > memory");
trapIfGt(addr, memorySizeBytes - curr->offset, "final > memory");