diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/MemoryPacking.cpp | 10 | ||||
-rw-r--r-- | src/wasm-binary.h | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/passes/MemoryPacking.cpp b/src/passes/MemoryPacking.cpp index d8e59cae6..640207fc7 100644 --- a/src/passes/MemoryPacking.cpp +++ b/src/passes/MemoryPacking.cpp @@ -87,6 +87,11 @@ Expression* makeShiftedMemorySize(Builder& builder) { struct MemoryPacking : public Pass { size_t dropStateGlobalCount = 0; + // FIXME: Chrome has a bug decoding section indices that prevents it from + // using more than 63. Just use WebLimitations::MaxDataSegments once this is + // fixed. See https://bugs.chromium.org/p/v8/issues/detail?id=10151. + uint32_t maxSegments; + void run(PassRunner* runner, Module* module) override; void optimizeBulkMemoryOps(PassRunner* runner, Module* module); void getSegmentReferrers(Module* module, std::vector<Referrers>& referrers); @@ -116,6 +121,9 @@ void MemoryPacking::run(PassRunner* runner, Module* module) { return; } + maxSegments = module->features.hasBulkMemory() + ? 63 + : uint32_t(WebLimitations::MaxDataSegments); auto& segments = module->memory.segments; // For each segment, a list of bulk memory instructions that refer to it @@ -436,7 +444,7 @@ void MemoryPacking::createSplitSegments(Builder& builder, offset = segment.offset; } } - if (WebLimitations::MaxDataSegments <= packed.size() + segmentsRemaining) { + if (maxSegments <= packed.size() + segmentsRemaining) { // Give up splitting and merge all remaining ranges except end zeroes auto lastNonzero = ranges.end() - 1; if (lastNonzero->isZero) { diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 5cfafb509..0dd8be61a 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -47,7 +47,7 @@ enum { // wasm VMs on the web have decided to impose some limits on what they // accept -enum WebLimitations { +enum WebLimitations : uint32_t { MaxDataSegments = 100 * 1000, MaxFunctionBodySize = 128 * 1024, MaxFunctionLocals = 50 * 1000 |