diff options
24 files changed, 225 insertions, 25 deletions
diff --git a/src/passes/LLVMMemoryCopyFillLowering.cpp b/src/passes/LLVMMemoryCopyFillLowering.cpp index e5b940a5a..d2a7e5c48 100644 --- a/src/passes/LLVMMemoryCopyFillLowering.cpp +++ b/src/passes/LLVMMemoryCopyFillLowering.cpp @@ -49,7 +49,7 @@ struct LLVMMemoryCopyFillLowering } void run(Module* module) override { - if (!module->features.hasBulkMemory()) { + if (!module->features.hasBulkMemoryOpt()) { return; } if (module->features.hasMemory64() || module->features.hasMultiMemory()) { @@ -108,7 +108,7 @@ struct LLVMMemoryCopyFillLowering } else { module->removeFunction(memFillFuncName); } - module->features.disable(FeatureSet::BulkMemory); + module->features.setBulkMemoryOpt(false); } void createMemoryCopyFunc(Module* module) { diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 881b7ea1f..792cf6235 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -1275,7 +1275,7 @@ struct OptimizeInstructions if (curr->type == Type::unreachable) { return; } - assert(getModule()->features.hasBulkMemory()); + assert(getModule()->features.hasBulkMemoryOpt()); if (auto* ret = optimizeMemoryCopy(curr)) { return replaceCurrent(ret); } @@ -1285,7 +1285,7 @@ struct OptimizeInstructions if (curr->type == Type::unreachable) { return; } - assert(getModule()->features.hasBulkMemory()); + assert(getModule()->features.hasBulkMemoryOpt()); if (auto* ret = optimizeMemoryFill(curr)) { return replaceCurrent(ret); } diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h index f900d76ba..c7acf1d46 100644 --- a/src/tools/tool-options.h +++ b/src/tools/tool-options.h @@ -82,7 +82,16 @@ struct ToolOptions : public Options { .addFeature(FeatureSet::MutableGlobals, "mutable globals") .addFeature(FeatureSet::TruncSat, "nontrapping float-to-int operations") .addFeature(FeatureSet::SIMD, "SIMD operations and types") - .addFeature(FeatureSet::BulkMemory, "bulk memory operations") + .addFeature(FeatureSet::BulkMemory, + "bulk memory operations", + FeatureSet(FeatureSet::BulkMemoryOpt)) + .addFeature(FeatureSet::BulkMemoryOpt, + "memory.copy and memory.fill", + FeatureSet::None, + FeatureSet(FeatureSet::BulkMemory)) + .addFeature(FeatureSet::CallIndirectOverlong, + "LEB encoding of call-indirect (Ignored for compatibility as " + "it has no effect on Binaryen)") .addFeature(FeatureSet::ExceptionHandling, "exception handling operations") .addFeature(FeatureSet::TailCall, "tail call operations") @@ -200,16 +209,18 @@ struct ToolOptions : public Options { } ToolOptions& addFeature(FeatureSet::Feature feature, - const std::string& description) { + const std::string& description, + FeatureSet impliedEnable = FeatureSet::None, + FeatureSet impliedDisable = FeatureSet::None) { (*this) .add(std::string("--enable-") + FeatureSet::toString(feature), "", std::string("Enable ") + description, ToolOptionsCategory, Arguments::Zero, - [this, feature](Options*, const std::string&) { - enabledFeatures.set(feature, true); - disabledFeatures.set(feature, false); + [this, feature, impliedEnable](Options*, const std::string&) { + enabledFeatures.set(feature | impliedEnable, true); + disabledFeatures.set(feature | impliedEnable, false); }) .add(std::string("--disable-") + FeatureSet::toString(feature), @@ -217,9 +228,9 @@ struct ToolOptions : public Options { std::string("Disable ") + description, ToolOptionsCategory, Arguments::Zero, - [this, feature](Options*, const std::string&) { - enabledFeatures.set(feature, false); - disabledFeatures.set(feature, true); + [this, feature, impliedDisable](Options*, const std::string&) { + enabledFeatures.set(feature | impliedDisable, false); + disabledFeatures.set(feature | impliedDisable, true); }); return *this; } diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 7c32e2169..163a62b1e 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -396,6 +396,8 @@ extern const char* MultiMemoryFeature; extern const char* TypedContinuationsFeature; extern const char* SharedEverythingFeature; extern const char* FP16Feature; +extern const char* BulkMemoryOptFeature; +extern const char* CallIndirectOverlongFeature; enum Subsection { NameModule = 0, diff --git a/src/wasm-features.h b/src/wasm-features.h index 92b07b547..20eec56bb 100644 --- a/src/wasm-features.h +++ b/src/wasm-features.h @@ -27,6 +27,8 @@ namespace wasm { struct FeatureSet { enum Feature : uint32_t { + // These features are intended to those documented in tool-conventions: + // https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md#target-features-section None = 0, Atomics = 1 << 0, MutableGlobals = 1 << 1, @@ -47,11 +49,16 @@ struct FeatureSet { TypedContinuations = 1 << 16, SharedEverything = 1 << 17, FP16 = 1 << 18, + BulkMemoryOpt = 1 << 19, // Just the memory.copy and fill operations + // This features is a no-op for compatibility. Having it in this list means + // that we can automatically generate tool flags that set it, but otherwise + // it does nothing. Binaryen always accepts LEB call-indirect encodings. + CallIndirectOverlong = 1 << 20, MVP = None, // Keep in sync with llvm default features: // https://github.com/llvm/llvm-project/blob/c7576cb89d6c95f03968076e902d3adfd1996577/clang/lib/Basic/Targets/WebAssembly.cpp#L150-L153 Default = SignExt | MutableGlobals, - All = (1 << 19) - 1, + All = (1 << 21) - 1, }; static std::string toString(Feature f) { @@ -94,6 +101,10 @@ struct FeatureSet { return "shared-everything"; case FP16: return "fp16"; + case BulkMemoryOpt: + return "bulk-memory-opt"; + case CallIndirectOverlong: + return "call-indirect-overlong"; default: WASM_UNREACHABLE("unexpected feature"); } @@ -145,6 +156,11 @@ struct FeatureSet { return (features & SharedEverything) != 0; } bool hasFP16() const { return (features & FP16) != 0; } + bool hasBulkMemoryOpt() const { + bool has = (features & BulkMemoryOpt) != 0; + assert(has || !hasBulkMemory()); + return has; + } bool hasAll() const { return (features & All) != 0; } void set(FeatureSet f, bool v = true) { @@ -169,6 +185,7 @@ struct FeatureSet { void setTypedContinuations(bool v = true) { set(TypedContinuations, v); } void setSharedEverything(bool v = true) { set(SharedEverything, v); } void setFP16(bool v = true) { set(FP16, v); } + void setBulkMemoryOpt(bool v = true) { set(BulkMemoryOpt, v); } void setMVP() { features = MVP; } void setAll() { features = All; } diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index f710c8bc1..0c931f518 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1354,6 +1354,10 @@ void WasmBinaryWriter::writeFeaturesSection() { return BinaryConsts::CustomSections::SharedEverythingFeature; case FeatureSet::FP16: return BinaryConsts::CustomSections::FP16Feature; + case FeatureSet::BulkMemoryOpt: + return BinaryConsts::CustomSections::BulkMemoryOptFeature; + case FeatureSet::CallIndirectOverlong: + return BinaryConsts::CustomSections::CallIndirectOverlongFeature; case FeatureSet::None: case FeatureSet::Default: case FeatureSet::All: @@ -4790,6 +4794,12 @@ void WasmBinaryReader::readFeatures(size_t payloadLen) { feature = FeatureSet::Atomics; } else if (name == BinaryConsts::CustomSections::BulkMemoryFeature) { feature = FeatureSet::BulkMemory; + if (used) { + // For backward compatibility, enable this dependent feature. + feature |= FeatureSet::BulkMemoryOpt; + } + } else if (name == BinaryConsts::CustomSections::BulkMemoryOptFeature) { + feature = FeatureSet::BulkMemoryOpt; } else if (name == BinaryConsts::CustomSections::ExceptionHandlingFeature) { feature = FeatureSet::ExceptionHandling; } else if (name == BinaryConsts::CustomSections::MutableGlobalsFeature) { diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index e295d3931..242e07c43 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -1526,10 +1526,10 @@ void FunctionValidator::visitDataDrop(DataDrop* curr) { } void FunctionValidator::visitMemoryCopy(MemoryCopy* curr) { - shouldBeTrue( - getModule()->features.hasBulkMemory(), - curr, - "Bulk memory operations require bulk memory [--enable-bulk-memory]"); + shouldBeTrue(getModule()->features.hasBulkMemoryOpt(), + curr, + "memory.copy operations require bulk memory operations " + "[--enable-bulk-memory-opt]"); shouldBeEqualOrFirstIsUnreachable( curr->type, Type(Type::none), curr, "memory.copy must have type none"); auto* destMemory = getModule()->getMemoryOrNull(curr->destMemory); @@ -1561,9 +1561,9 @@ void FunctionValidator::visitMemoryCopy(MemoryCopy* curr) { void FunctionValidator::visitMemoryFill(MemoryFill* curr) { auto* memory = getModule()->getMemoryOrNull(curr->memory); shouldBeTrue( - getModule()->features.hasBulkMemory(), + getModule()->features.hasBulkMemoryOpt(), curr, - "Bulk memory operations require bulk memory [--enable-bulk-memory]"); + "memory.fill operations require bulk memory [--enable-bulk-memory-opt]"); shouldBeEqualOrFirstIsUnreachable( curr->type, Type(Type::none), curr, "memory.fill must have type none"); shouldBeEqualOrFirstIsUnreachable( diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index f5806b184..3e04f29ec 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -57,6 +57,8 @@ const char* MultiMemoryFeature = "multimemory"; const char* TypedContinuationsFeature = "typed-continuations"; const char* SharedEverythingFeature = "shared-everything"; const char* FP16Feature = "fp16"; +const char* BulkMemoryOptFeature = "bulk-memory-opt"; +const char* CallIndirectOverlongFeature = "call-indirect-overlong"; } // namespace CustomSections } // namespace BinaryConsts diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index d38c16857..637b1ab95 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -33,7 +33,7 @@ Features.RelaxedSIMD: 4096 Features.ExtendedConst: 8192 Features.Strings: 16384 Features.MultiMemory: 32768 -Features.All: 524287 +Features.All: 2097151 InvalidId: 0 BlockId: 1 IfId: 2 diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index 8a5b6dc87..d3e6a6767 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -47,7 +47,7 @@ BinaryenFeatureMemory64: 2048 BinaryenFeatureRelaxedSIMD: 4096 BinaryenFeatureExtendedConst: 8192 BinaryenFeatureStrings: 16384 -BinaryenFeatureAll: 524287 +BinaryenFeatureAll: 2097151 (f32.neg (f32.const -33.61199951171875) ) diff --git a/test/lit/help/wasm-as.test b/test/lit/help/wasm-as.test index 5dd4b1515..7f2e1bc94 100644 --- a/test/lit/help/wasm-as.test +++ b/test/lit/help/wasm-as.test @@ -64,6 +64,18 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-bulk-memory Disable bulk memory operations ;; CHECK-NEXT: +;; CHECK-NEXT: --enable-bulk-memory-opt Enable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-bulk-memory-opt Disable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --enable-call-indirect-overlong Enable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-call-indirect-overlong Disable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-exception-handling Enable exception handling operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-exception-handling Disable exception handling operations diff --git a/test/lit/help/wasm-ctor-eval.test b/test/lit/help/wasm-ctor-eval.test index abb80b12e..06e2c4a0d 100644 --- a/test/lit/help/wasm-ctor-eval.test +++ b/test/lit/help/wasm-ctor-eval.test @@ -71,6 +71,18 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-bulk-memory Disable bulk memory operations ;; CHECK-NEXT: +;; CHECK-NEXT: --enable-bulk-memory-opt Enable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-bulk-memory-opt Disable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --enable-call-indirect-overlong Enable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-call-indirect-overlong Disable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-exception-handling Enable exception handling operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-exception-handling Disable exception handling operations diff --git a/test/lit/help/wasm-dis.test b/test/lit/help/wasm-dis.test index 90bc12b99..d698afe86 100644 --- a/test/lit/help/wasm-dis.test +++ b/test/lit/help/wasm-dis.test @@ -57,6 +57,18 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-bulk-memory Disable bulk memory operations ;; CHECK-NEXT: +;; CHECK-NEXT: --enable-bulk-memory-opt Enable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-bulk-memory-opt Disable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --enable-call-indirect-overlong Enable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-call-indirect-overlong Disable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-exception-handling Enable exception handling operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-exception-handling Disable exception handling operations diff --git a/test/lit/help/wasm-emscripten-finalize.test b/test/lit/help/wasm-emscripten-finalize.test index cdd378d40..5f9f17ff2 100644 --- a/test/lit/help/wasm-emscripten-finalize.test +++ b/test/lit/help/wasm-emscripten-finalize.test @@ -99,6 +99,18 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-bulk-memory Disable bulk memory operations ;; CHECK-NEXT: +;; CHECK-NEXT: --enable-bulk-memory-opt Enable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-bulk-memory-opt Disable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --enable-call-indirect-overlong Enable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-call-indirect-overlong Disable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-exception-handling Enable exception handling operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-exception-handling Disable exception handling operations diff --git a/test/lit/help/wasm-merge.test b/test/lit/help/wasm-merge.test index ee1fed13a..f83fc5c0f 100644 --- a/test/lit/help/wasm-merge.test +++ b/test/lit/help/wasm-merge.test @@ -87,6 +87,18 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-bulk-memory Disable bulk memory operations ;; CHECK-NEXT: +;; CHECK-NEXT: --enable-bulk-memory-opt Enable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-bulk-memory-opt Disable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --enable-call-indirect-overlong Enable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-call-indirect-overlong Disable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-exception-handling Enable exception handling operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-exception-handling Disable exception handling operations diff --git a/test/lit/help/wasm-metadce.test b/test/lit/help/wasm-metadce.test index e98834641..0be234ac7 100644 --- a/test/lit/help/wasm-metadce.test +++ b/test/lit/help/wasm-metadce.test @@ -699,6 +699,22 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-bulk-memory Disable bulk memory operations ;; CHECK-NEXT: +;; CHECK-NEXT: --enable-bulk-memory-opt Enable memory.copy and +;; CHECK-NEXT: memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-bulk-memory-opt Disable memory.copy and +;; CHECK-NEXT: memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --enable-call-indirect-overlong Enable LEB encoding of +;; CHECK-NEXT: call-indirect (Ignored for +;; CHECK-NEXT: compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-call-indirect-overlong Disable LEB encoding of +;; CHECK-NEXT: call-indirect (Ignored for +;; CHECK-NEXT: compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-exception-handling Enable exception handling ;; CHECK-NEXT: operations ;; CHECK-NEXT: diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test index 06a9e5e84..630a64588 100644 --- a/test/lit/help/wasm-opt.test +++ b/test/lit/help/wasm-opt.test @@ -708,6 +708,22 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-bulk-memory Disable bulk memory operations ;; CHECK-NEXT: +;; CHECK-NEXT: --enable-bulk-memory-opt Enable memory.copy and +;; CHECK-NEXT: memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-bulk-memory-opt Disable memory.copy and +;; CHECK-NEXT: memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --enable-call-indirect-overlong Enable LEB encoding of +;; CHECK-NEXT: call-indirect (Ignored for +;; CHECK-NEXT: compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-call-indirect-overlong Disable LEB encoding of +;; CHECK-NEXT: call-indirect (Ignored for +;; CHECK-NEXT: compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-exception-handling Enable exception handling ;; CHECK-NEXT: operations ;; CHECK-NEXT: diff --git a/test/lit/help/wasm-reduce.test b/test/lit/help/wasm-reduce.test index cc75aed2b..d02d46fd7 100644 --- a/test/lit/help/wasm-reduce.test +++ b/test/lit/help/wasm-reduce.test @@ -93,6 +93,18 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-bulk-memory Disable bulk memory operations ;; CHECK-NEXT: +;; CHECK-NEXT: --enable-bulk-memory-opt Enable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-bulk-memory-opt Disable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --enable-call-indirect-overlong Enable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-call-indirect-overlong Disable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-exception-handling Enable exception handling operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-exception-handling Disable exception handling operations diff --git a/test/lit/help/wasm-split.test b/test/lit/help/wasm-split.test index e5e736562..04d741421 100644 --- a/test/lit/help/wasm-split.test +++ b/test/lit/help/wasm-split.test @@ -196,6 +196,18 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-bulk-memory Disable bulk memory operations ;; CHECK-NEXT: +;; CHECK-NEXT: --enable-bulk-memory-opt Enable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-bulk-memory-opt Disable memory.copy and memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --enable-call-indirect-overlong Enable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-call-indirect-overlong Disable LEB encoding of call-indirect +;; CHECK-NEXT: (Ignored for compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-exception-handling Enable exception handling operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-exception-handling Disable exception handling operations diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test index 50e229a1d..a326c75db 100644 --- a/test/lit/help/wasm2js.test +++ b/test/lit/help/wasm2js.test @@ -662,6 +662,22 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-bulk-memory Disable bulk memory operations ;; CHECK-NEXT: +;; CHECK-NEXT: --enable-bulk-memory-opt Enable memory.copy and +;; CHECK-NEXT: memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-bulk-memory-opt Disable memory.copy and +;; CHECK-NEXT: memory.fill +;; CHECK-NEXT: +;; CHECK-NEXT: --enable-call-indirect-overlong Enable LEB encoding of +;; CHECK-NEXT: call-indirect (Ignored for +;; CHECK-NEXT: compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: +;; CHECK-NEXT: --disable-call-indirect-overlong Disable LEB encoding of +;; CHECK-NEXT: call-indirect (Ignored for +;; CHECK-NEXT: compatibility as it has no +;; CHECK-NEXT: effect on Binaryen) +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-exception-handling Enable exception handling ;; CHECK-NEXT: operations ;; CHECK-NEXT: diff --git a/test/lld/em_asm_pthread.wasm.out b/test/lld/em_asm_pthread.wasm.out index 8284cc6dc..aae8441f6 100644 --- a/test/lld/em_asm_pthread.wasm.out +++ b/test/lld/em_asm_pthread.wasm.out @@ -12831,5 +12831,5 @@ ) ) ;; custom section "producers", size 172 - ;; features section: threads, mutable-globals, bulk-memory, sign-ext + ;; features section: threads, mutable-globals, bulk-memory, sign-ext, bulk-memory-opt ) diff --git a/test/passes/strip-target-features_roundtrip_print-features_all-features.txt b/test/passes/strip-target-features_roundtrip_print-features_all-features.txt index 901f43bc5..e6b611d4a 100644 --- a/test/passes/strip-target-features_roundtrip_print-features_all-features.txt +++ b/test/passes/strip-target-features_roundtrip_print-features_all-features.txt @@ -17,6 +17,8 @@ --enable-typed-continuations --enable-shared-everything --enable-fp16 +--enable-bulk-memory-opt +--enable-call-indirect-overlong (module (type $0 (func (result v128 externref))) (func $foo (type $0) (result v128 externref) diff --git a/test/unit/input/bulkmem_target_feature.wasm b/test/unit/input/bulkmem_target_feature.wasm Binary files differindex 3c69d2323..7a762820c 100755 --- a/test/unit/input/bulkmem_target_feature.wasm +++ b/test/unit/input/bulkmem_target_feature.wasm diff --git a/test/unit/test_features.py b/test/unit/test_features.py index f5c3fabc5..c115719e7 100644 --- a/test/unit/test_features.py +++ b/test/unit/test_features.py @@ -30,6 +30,9 @@ class FeatureValidationTest(utils.BinaryenTestCase): def check_bulk_mem(self, module, error): self.check_feature(module, error, '--enable-bulk-memory') + def check_bulk_mem_opt(self, module, error): + self.check_feature(module, error, '--enable-bulk-memory-opt') + def check_exception_handling(self, module, error): self.check_feature(module, error, '--enable-exception-handling') @@ -135,8 +138,11 @@ class FeatureValidationTest(utils.BinaryenTestCase): ) ) ''' + self.check_bulk_mem_opt(module, + 'memory.copy operations require bulk memory operations [--enable-bulk-memory-opt]') + # Test that enabling bulk-memory also enables bulk-memory-opt self.check_bulk_mem(module, - 'Bulk memory operations require bulk memory [--enable-bulk-memory]') + 'memory.copy operations require bulk memory operations [--enable-bulk-memory-opt]') def test_bulk_mem_segment(self): module = ''' @@ -306,6 +312,23 @@ class FeatureValidationTest(utils.BinaryenTestCase): ''' self.check_typed_continuations(module, 'all used types should be allowed') + def test_call_indirect_overlong(self): + # Check that the call-indirect-overlong enable and disable are ignored. + module = ''' + (module) + ''' + + def check_nop(flag): + p = shared.run_process( + shared.WASM_OPT + ['--mvp-features', '--print', '-o', os.devnull] + + [flag], + input=module, + check=False, + capture_output=True) + self.assertEqual(p.returncode, 0) + check_nop('--enable-call-indirect-overlong') + check_nop('--disable-call-indirect-overlong') + class TargetFeaturesSectionTest(utils.BinaryenTestCase): def test_atomics(self): @@ -314,10 +337,10 @@ class TargetFeaturesSectionTest(utils.BinaryenTestCase): self.check_features(filename, ['threads']) self.assertIn('i32.atomic.rmw.add', self.disassemble(filename)) - def test_bulk_memory(self): + def test_bulk_memory_opt(self): filename = 'bulkmem_target_feature.wasm' self.roundtrip(filename) - self.check_features(filename, ['bulk-memory']) + self.check_features(filename, ['bulk-memory-opt']) self.assertIn('memory.copy', self.disassemble(filename)) def test_nontrapping_fptoint(self): @@ -427,4 +450,5 @@ class TargetFeaturesSectionTest(utils.BinaryenTestCase): '--enable-typed-continuations', '--enable-shared-everything', '--enable-fp16', + '--enable-bulk-memory-opt', ], p2.stdout.splitlines()) |