summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm-binary.h3
-rw-r--r--src/wasm/wasm-binary.cpp5
-rw-r--r--test/unit/test_web_limitations.py22
3 files changed, 29 insertions, 1 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index b308abade..e9ad665c4 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -48,7 +48,8 @@ enum {
enum WebLimitations : uint32_t {
MaxDataSegments = 100 * 1000,
MaxFunctionBodySize = 128 * 1024,
- MaxFunctionLocals = 50 * 1000
+ MaxFunctionLocals = 50 * 1000,
+ MaxFunctionParams = 1000
};
template<typename T, typename MiniT> struct LEB {
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 4e5db69b1..55dafadd4 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -453,6 +453,11 @@ void WasmBinaryWriter::writeFunctions() {
tableOfContents.functionBodies.emplace_back(
func->name, sizePos + sizeFieldSize, size);
binaryLocationTrackedExpressionsForFunc.clear();
+
+ if (func->getParams().size() > WebLimitations::MaxFunctionParams) {
+ std::cerr << "Some VMs may not accept this binary because it has a large "
+ << "number of parameters in function " << func->name << ".\n";
+ }
});
finishSection(sectionStart);
}
diff --git a/test/unit/test_web_limitations.py b/test/unit/test_web_limitations.py
new file mode 100644
index 000000000..6359390f9
--- /dev/null
+++ b/test/unit/test_web_limitations.py
@@ -0,0 +1,22 @@
+import os
+
+from scripts.test import shared
+from . import utils
+
+
+class WebLimitations(utils.BinaryenTestCase):
+ def test_many_params(self):
+ """Test that we warn on large numbers of parameters, which Web VMs
+ disallow."""
+
+ params = '(param i32) ' * 1001
+ module = '''
+ (module
+ (func $foo %s
+ )
+ )
+ ''' % params
+ p = shared.run_process(shared.WASM_OPT + ['-o', os.devnull],
+ input=module, capture_output=True)
+ self.assertIn('Some VMs may not accept this binary because it has a large number of parameters in function foo.',
+ p.stderr)