summaryrefslogtreecommitdiff
path: root/src/wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-10-15 16:07:24 -0700
committerGitHub <noreply@github.com>2018-10-15 16:07:24 -0700
commit021a2b85fb9264d9cb4a21c039682d1f0fddbd1c (patch)
tree96f39abb25e77769b337aa3d7858c4722c6ba1b4 /src/wasm.h
parent66dbc57d32bb2c8c01deefba7a035ebed5a42e2c (diff)
downloadbinaryen-021a2b85fb9264d9cb4a21c039682d1f0fddbd1c.tar.gz
binaryen-021a2b85fb9264d9cb4a21c039682d1f0fddbd1c.tar.bz2
binaryen-021a2b85fb9264d9cb4a21c039682d1f0fddbd1c.zip
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.
Diffstat (limited to 'src/wasm.h')
-rw-r--r--src/wasm.h10
1 files changed, 7 insertions, 3 deletions
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 {