summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-01-13 10:06:56 -0800
committerGitHub <noreply@github.com>2023-01-13 18:06:56 +0000
commit26d3eaada5e8f386b4cfff64461792824c9ff596 (patch)
tree8971ac7c81d11dfa52e6b0a3b58a2b86a5d2cd4b
parent589b3fde7511d53f2be251b5d741e422cde39ec6 (diff)
downloadbinaryen-26d3eaada5e8f386b4cfff64461792824c9ff596.tar.gz
binaryen-26d3eaada5e8f386b4cfff64461792824c9ff596.tar.bz2
binaryen-26d3eaada5e8f386b4cfff64461792824c9ff596.zip
Move closed world flag to tool options (#5428)
This allows tools like wasm-reduce to be told to operate in closed-world mode. That lets them validate in the more strict way of that mode.
-rw-r--r--src/tools/optimization-options.h12
-rw-r--r--src/tools/tool-options.h14
-rw-r--r--test/lit/help/wasm-as.test7
-rw-r--r--test/lit/help/wasm-ctor-eval.test7
-rw-r--r--test/lit/help/wasm-dis.test7
-rw-r--r--test/lit/help/wasm-emscripten-finalize.test7
-rw-r--r--test/lit/help/wasm-metadce.test7
-rw-r--r--test/lit/help/wasm-opt.test18
-rw-r--r--test/lit/help/wasm-reduce.test7
-rw-r--r--test/lit/help/wasm-split.test7
-rw-r--r--test/lit/help/wasm2js.test18
11 files changed, 80 insertions, 31 deletions
diff --git a/src/tools/optimization-options.h b/src/tools/optimization-options.h
index eaa90f55f..698d3305e 100644
--- a/src/tools/optimization-options.h
+++ b/src/tools/optimization-options.h
@@ -270,18 +270,6 @@ struct OptimizationOptions : public ToolOptions {
OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) { passOptions.fastMath = true; })
- .add(
- "--closed-world",
- "-cw",
- "Assume code outside of the module does not inspect or interact with "
- "GC and function references, even if they are passed out. The outside "
- "may hold on to them and pass them back in, but not inspect their "
- "contents or call them.",
- OptimizationOptionsCategory,
- Options::Arguments::Zero,
- [this](Options*, const std::string&) {
- passOptions.closedWorld = true;
- })
.add("--zero-filled-memory",
"-uim",
"Assume that an imported memory will be zero-initialized",
diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h
index 0522b5538..02b825079 100644
--- a/src/tools/tool-options.h
+++ b/src/tools/tool-options.h
@@ -156,7 +156,19 @@ struct ToolOptions : public Options {
Options::Arguments::Zero,
[](Options* o, const std::string& argument) {
setTypeSystem(TypeSystem::Isorecursive);
- });
+ })
+ .add(
+ "--closed-world",
+ "-cw",
+ "Assume code outside of the module does not inspect or interact with "
+ "GC and function references, even if they are passed out. The outside "
+ "may hold on to them and pass them back in, but not inspect their "
+ "contents or call them.",
+ ToolOptionsCategory,
+ Options::Arguments::Zero,
+ [this](Options*, const std::string&) {
+ passOptions.closedWorld = true;
+ });
}
ToolOptions& addFeature(FeatureSet::Feature feature,
diff --git a/test/lit/help/wasm-as.test b/test/lit/help/wasm-as.test
index c94dab310..976c66225 100644
--- a/test/lit/help/wasm-as.test
+++ b/test/lit/help/wasm-as.test
@@ -126,6 +126,13 @@
;; CHECK-NEXT: parsed using the isorecursive hybrid type
;; CHECK-NEXT: system.
;; CHECK-NEXT:
+;; CHECK-NEXT: --closed-world,-cw Assume code outside of the module does
+;; CHECK-NEXT: not inspect or interact with GC and
+;; CHECK-NEXT: function references, even if they are
+;; CHECK-NEXT: passed out. The outside may hold on to
+;; CHECK-NEXT: them and pass them back in, but not
+;; CHECK-NEXT: inspect their contents or call them.
+;; CHECK-NEXT:
;; CHECK-NEXT:
;; CHECK-NEXT: General options:
;; CHECK-NEXT: ----------------
diff --git a/test/lit/help/wasm-ctor-eval.test b/test/lit/help/wasm-ctor-eval.test
index 9295fc9d1..718249295 100644
--- a/test/lit/help/wasm-ctor-eval.test
+++ b/test/lit/help/wasm-ctor-eval.test
@@ -130,6 +130,13 @@
;; CHECK-NEXT: parsed using the isorecursive hybrid type
;; CHECK-NEXT: system.
;; CHECK-NEXT:
+;; CHECK-NEXT: --closed-world,-cw Assume code outside of the module does
+;; CHECK-NEXT: not inspect or interact with GC and
+;; CHECK-NEXT: function references, even if they are
+;; CHECK-NEXT: passed out. The outside may hold on to
+;; CHECK-NEXT: them and pass them back in, but not
+;; CHECK-NEXT: inspect their contents or call them.
+;; CHECK-NEXT:
;; CHECK-NEXT:
;; CHECK-NEXT: General options:
;; CHECK-NEXT: ----------------
diff --git a/test/lit/help/wasm-dis.test b/test/lit/help/wasm-dis.test
index c0f0b6f38..ce2328452 100644
--- a/test/lit/help/wasm-dis.test
+++ b/test/lit/help/wasm-dis.test
@@ -119,6 +119,13 @@
;; CHECK-NEXT: parsed using the isorecursive hybrid type
;; CHECK-NEXT: system.
;; CHECK-NEXT:
+;; CHECK-NEXT: --closed-world,-cw Assume code outside of the module does
+;; CHECK-NEXT: not inspect or interact with GC and
+;; CHECK-NEXT: function references, even if they are
+;; CHECK-NEXT: passed out. The outside may hold on to
+;; CHECK-NEXT: them and pass them back in, but not
+;; CHECK-NEXT: inspect their contents or call them.
+;; CHECK-NEXT:
;; CHECK-NEXT:
;; CHECK-NEXT: General options:
;; CHECK-NEXT: ----------------
diff --git a/test/lit/help/wasm-emscripten-finalize.test b/test/lit/help/wasm-emscripten-finalize.test
index 1600bb823..5bcf2c469 100644
--- a/test/lit/help/wasm-emscripten-finalize.test
+++ b/test/lit/help/wasm-emscripten-finalize.test
@@ -166,6 +166,13 @@
;; CHECK-NEXT: parsed using the isorecursive hybrid type
;; CHECK-NEXT: system.
;; CHECK-NEXT:
+;; CHECK-NEXT: --closed-world,-cw Assume code outside of the module does
+;; CHECK-NEXT: not inspect or interact with GC and
+;; CHECK-NEXT: function references, even if they are
+;; CHECK-NEXT: passed out. The outside may hold on to
+;; CHECK-NEXT: them and pass them back in, but not
+;; CHECK-NEXT: inspect their contents or call them.
+;; CHECK-NEXT:
;; CHECK-NEXT:
;; CHECK-NEXT: General options:
;; CHECK-NEXT: ----------------
diff --git a/test/lit/help/wasm-metadce.test b/test/lit/help/wasm-metadce.test
index a748d8198..59cbcc216 100644
--- a/test/lit/help/wasm-metadce.test
+++ b/test/lit/help/wasm-metadce.test
@@ -167,6 +167,13 @@
;; CHECK-NEXT: parsed using the isorecursive hybrid type
;; CHECK-NEXT: system.
;; CHECK-NEXT:
+;; CHECK-NEXT: --closed-world,-cw Assume code outside of the module does
+;; CHECK-NEXT: not inspect or interact with GC and
+;; CHECK-NEXT: function references, even if they are
+;; CHECK-NEXT: passed out. The outside may hold on to
+;; CHECK-NEXT: them and pass them back in, but not
+;; CHECK-NEXT: inspect their contents or call them.
+;; CHECK-NEXT:
;; CHECK-NEXT:
;; CHECK-NEXT: General options:
;; CHECK-NEXT: ----------------
diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test
index 042807e2f..8e04a756c 100644
--- a/test/lit/help/wasm-opt.test
+++ b/test/lit/help/wasm-opt.test
@@ -564,15 +564,6 @@
;; CHECK-NEXT: corner cases of NaNs and
;; CHECK-NEXT: rounding
;; CHECK-NEXT:
-;; CHECK-NEXT: --closed-world,-cw Assume code outside of the
-;; CHECK-NEXT: module does not inspect or
-;; CHECK-NEXT: interact with GC and function
-;; CHECK-NEXT: references, even if they are
-;; CHECK-NEXT: passed out. The outside may hold
-;; CHECK-NEXT: on to them and pass them back
-;; CHECK-NEXT: in, but not inspect their
-;; CHECK-NEXT: contents or call them.
-;; CHECK-NEXT:
;; CHECK-NEXT: --zero-filled-memory,-uim Assume that an imported memory
;; CHECK-NEXT: will be zero-initialized
;; CHECK-NEXT:
@@ -687,6 +678,15 @@
;; CHECK-NEXT: be parsed using the isorecursive
;; CHECK-NEXT: hybrid type system.
;; CHECK-NEXT:
+;; CHECK-NEXT: --closed-world,-cw Assume code outside of the
+;; CHECK-NEXT: module does not inspect or
+;; CHECK-NEXT: interact with GC and function
+;; CHECK-NEXT: references, even if they are
+;; CHECK-NEXT: passed out. The outside may hold
+;; CHECK-NEXT: on to them and pass them back
+;; CHECK-NEXT: in, but not inspect their
+;; CHECK-NEXT: contents or call them.
+;; CHECK-NEXT:
;; CHECK-NEXT:
;; CHECK-NEXT: General options:
;; CHECK-NEXT: ----------------
diff --git a/test/lit/help/wasm-reduce.test b/test/lit/help/wasm-reduce.test
index c640cf5f7..333cae9ae 100644
--- a/test/lit/help/wasm-reduce.test
+++ b/test/lit/help/wasm-reduce.test
@@ -155,6 +155,13 @@
;; CHECK-NEXT: parsed using the isorecursive hybrid type
;; CHECK-NEXT: system.
;; CHECK-NEXT:
+;; CHECK-NEXT: --closed-world,-cw Assume code outside of the module does
+;; CHECK-NEXT: not inspect or interact with GC and
+;; CHECK-NEXT: function references, even if they are
+;; CHECK-NEXT: passed out. The outside may hold on to
+;; CHECK-NEXT: them and pass them back in, but not
+;; CHECK-NEXT: inspect their contents or call them.
+;; CHECK-NEXT:
;; CHECK-NEXT:
;; CHECK-NEXT: General options:
;; CHECK-NEXT: ----------------
diff --git a/test/lit/help/wasm-split.test b/test/lit/help/wasm-split.test
index 176ba1858..118117d62 100644
--- a/test/lit/help/wasm-split.test
+++ b/test/lit/help/wasm-split.test
@@ -235,6 +235,13 @@
;; CHECK-NEXT: parsed using the isorecursive hybrid type
;; CHECK-NEXT: system.
;; CHECK-NEXT:
+;; CHECK-NEXT: --closed-world,-cw Assume code outside of the module does
+;; CHECK-NEXT: not inspect or interact with GC and
+;; CHECK-NEXT: function references, even if they are
+;; CHECK-NEXT: passed out. The outside may hold on to
+;; CHECK-NEXT: them and pass them back in, but not
+;; CHECK-NEXT: inspect their contents or call them.
+;; CHECK-NEXT:
;; CHECK-NEXT:
;; CHECK-NEXT: General options:
;; CHECK-NEXT: ----------------
diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test
index ab56ff4e8..e023c2af5 100644
--- a/test/lit/help/wasm2js.test
+++ b/test/lit/help/wasm2js.test
@@ -523,15 +523,6 @@
;; CHECK-NEXT: corner cases of NaNs and
;; CHECK-NEXT: rounding
;; CHECK-NEXT:
-;; CHECK-NEXT: --closed-world,-cw Assume code outside of the
-;; CHECK-NEXT: module does not inspect or
-;; CHECK-NEXT: interact with GC and function
-;; CHECK-NEXT: references, even if they are
-;; CHECK-NEXT: passed out. The outside may hold
-;; CHECK-NEXT: on to them and pass them back
-;; CHECK-NEXT: in, but not inspect their
-;; CHECK-NEXT: contents or call them.
-;; CHECK-NEXT:
;; CHECK-NEXT: --zero-filled-memory,-uim Assume that an imported memory
;; CHECK-NEXT: will be zero-initialized
;; CHECK-NEXT:
@@ -646,6 +637,15 @@
;; CHECK-NEXT: be parsed using the isorecursive
;; CHECK-NEXT: hybrid type system.
;; CHECK-NEXT:
+;; CHECK-NEXT: --closed-world,-cw Assume code outside of the
+;; CHECK-NEXT: module does not inspect or
+;; CHECK-NEXT: interact with GC and function
+;; CHECK-NEXT: references, even if they are
+;; CHECK-NEXT: passed out. The outside may hold
+;; CHECK-NEXT: on to them and pass them back
+;; CHECK-NEXT: in, but not inspect their
+;; CHECK-NEXT: contents or call them.
+;; CHECK-NEXT:
;; CHECK-NEXT:
;; CHECK-NEXT: General options:
;; CHECK-NEXT: ----------------