From 021a2b85fb9264d9cb4a21c039682d1f0fddbd1c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 15 Oct 2018 16:07:24 -0700 Subject: Support 4GB Memories (#1702) This fixes asm2wasm parsing of the max to allow 4GB, and also changes the internal Memory::kMaxValue values to reflect that. We used to use kMaxValue to also represent "no limit", so I split that out into kUnlimitedValue. --- src/wasm.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/wasm.h') diff --git a/src/wasm.h b/src/wasm.h index 57591d811..a0f634d17 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -662,6 +662,8 @@ public: class Table : public Importable { public: static const Address::address_t kPageSize = 1; + static const Index kUnlimitedSize = Index(-1); + // In wasm32, the maximum table size is limited by a 32-bit pointer: 4GB static const Index kMaxSize = Index(-1); struct Segment { @@ -684,13 +686,15 @@ public: Table() : exists(false), initial(0), max(kMaxSize) { name = Name::fromInt(0); } - bool hasMax() { return max != kMaxSize; } + bool hasMax() { return max != kUnlimitedSize; } }; class Memory : public Importable { public: static const Address::address_t kPageSize = 64 * 1024; - static const Address::address_t kMaxSize = ~Address::address_t(0) / kPageSize; + static const Address::address_t kUnlimitedSize = Address::address_t(-1); + // In wasm32, the maximum memory size is limited by a 32-bit pointer: 4GB + static const Address::address_t kMaxSize = (uint64_t(4) * 1024 * 1024 * 1024) / kPageSize; static const Address::address_t kPageMask = ~(kPageSize - 1); struct Segment { @@ -718,7 +722,7 @@ public: Memory() : initial(0), max(kMaxSize), exists(false), shared(false) { name = Name::fromInt(0); } - bool hasMax() { return max != kMaxSize; } + bool hasMax() { return max != kUnlimitedSize; } }; class Global : public Importable { -- cgit v1.2.3