diff --git a/scripts/test/shared.py b/scripts/test/shared.py index ad02b617d44..b145b1f99cb 100644 --- a/scripts/test/shared.py +++ b/scripts/test/shared.py @@ -424,7 +424,6 @@ def get_tests(test_dir, extensions=[], recursive=False): 'annotations.wast', # String annotations IDs should be allowed 'id.wast', # Empty IDs should be disallowed 'instance.wast', # Requires support for table default elements - 'table64.wast', # Requires validations for table size 'tag.wast', # Non-empty tag results allowed by stack switching 'local_init.wast', # Requires local validation to respect unnamed blocks 'ref_func.wast', # Requires rejecting undeclared functions references diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 0e7bab677f4..59ce47e4b74 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -912,13 +912,13 @@ void TranslateToFuzzReader::finalizeTable() { // reasonable limit for the maximum table size. // // This also avoids an issue that arises from table->initial being an - // Address (64 bits) but Table::kMaxSize being an Index (32 bits), as a - // result of which we need to clamp to Table::kMaxSize as well in order for + // Address (64 bits) but Table::kMaxSize32 being an Index (32 bits), as a + // result of which we need to clamp to Table::kMaxSize32 as well in order for // the module to validate (but since we are clamping to a smaller value, // there is no need). const Address ReasonableMaxTableSize = 10000; table->initial = std::min(table->initial, ReasonableMaxTableSize); - assert(ReasonableMaxTableSize <= Table::kMaxSize); + assert(ReasonableMaxTableSize <= Table::kMaxSize32); table->max = oneIn(2) ? Address(Table::kUnlimitedSize) : table->initial; diff --git a/src/wasm-builder.h b/src/wasm-builder.h index cd73babb6ca..22bd50086af 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -106,7 +106,7 @@ class Builder { Type type = Type(HeapType::func, Nullable), Address initial = 0, - Address max = Table::kMaxSize, + Address max = Table::kUnlimitedSize, Type addressType = Type::i32) { auto table = std::make_unique(); table->name = name; diff --git a/src/wasm.h b/src/wasm.h index c35b1ea2531..bd8aec34cc8 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2447,12 +2447,14 @@ class ElementSegment : public Named { class Table : public Importable { public: static const Address::address32_t kPageSize = 1; - static const Index kUnlimitedSize = Index(-1); - // In wasm32/64, the maximum table size is limited by a 32-bit pointer: 4GB - static const Index kMaxSize = Index(-1); + static const Address::address64_t kUnlimitedSize = Address::address64_t(-1); + + // The maximum table size is limited by a 32/64 bit index + static const Address::address32_t kMaxSize32 = Address::address32_t(-1); + static const Address::address64_t kMaxSize64 = Address::address64_t(-1); Address initial = 0; - Address max = kMaxSize; + Address max = kUnlimitedSize; Type addressType = Type::i32; Type type = Type(HeapType::func, Nullable); @@ -2461,7 +2463,7 @@ class Table : public Importable { void clear() { name = ""; initial = 0; - max = kMaxSize; + max = kUnlimitedSize; } }; diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 6783b1eafbb..b419b803e4c 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -5009,7 +5009,7 @@ void WasmBinaryReader::readTableDeclarations() { void WasmBinaryReader::readElementSegments() { auto num = getU32LEB(); - if (num >= Table::kMaxSize) { + if (num >= Table::kMaxSize32) { throwError("Too many segments"); } std::unordered_set usedNames;