Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Parser] Enable the new text parser by default #6371

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ full changeset diff at the end of each section.
Current Trunk
-------------

- (If new wat parser is enabled) Source map comments on `else` branches must
now be placed above the instruction inside the `else` branch rather than on
the `else` branch itself.
- The new, standards-compliant text parser is now the default. `wasm-opt` has a
`--deprecated-wat-parser` flag that will switch back to using the old text
parser, but that option will go away soon.
- Source map comments on `else` branches must now be placed above the
instruction inside the `else` branch rather than on the `else` branch itself.
- Source map locations from instructions are no longer automatically propagated
to function epilogues.
- Add a new `BinaryenModuleReadWithFeatures` function to the C API that allows
to configure which features to enable in the parser.
- The build-time option to use legacy WasmGC opcodes is removed.
Expand Down
2 changes: 2 additions & 0 deletions src/parser/wat-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ void propagateDebugLocations(Module& wasm) {
// do not already have their own debug locations.
PassRunner runner(&wasm);
runner.add("propagate-debug-locs");
// The parser should not be responsible for validation.
runner.setIsNested(true);
runner.run();
}

Expand Down
2 changes: 1 addition & 1 deletion src/wasm/wasm-io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

namespace wasm {

bool useNewWATParser = false;
bool useNewWATParser = true;

#define DEBUG_TYPE "writer"

Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/bad-indirect-call3.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(memory $0 256 256)
(data $0 (i32.const 10) "waka waka waka waka waka")
(table $0 1 1 funcref)
(elem $0 (i32.const 0) $callee)
(elem $implicit-elem (i32.const 0) $callee)
(export "sig_mismatch" (func $sig_mismatch))
(func $callee (type $0) (param $0 externref)
(i32.store8
Expand Down
72 changes: 36 additions & 36 deletions test/lit/basic/exception-handling-old.wast
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
;; Old Phase 3 exception handling

;; CHECK-TEXT: (func $simple-try-catch (type $0)
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (throw $e-i32
;; CHECK-TEXT-NEXT: (i32.const 0)
Expand Down Expand Up @@ -106,7 +106,7 @@

;; CHECK-TEXT: (func $try-catch-multivalue-tag (type $0)
;; CHECK-TEXT-NEXT: (local $x (tuple i32 i64))
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (throw $e-i32-i64
;; CHECK-TEXT-NEXT: (i32.const 0)
Expand Down Expand Up @@ -179,16 +179,16 @@
)

;; CHECK-TEXT: (func $try-with-block-label (type $0)
;; CHECK-TEXT-NEXT: (block $l10
;; CHECK-TEXT-NEXT: (block $label
;; CHECK-TEXT-NEXT: (try $l1
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (br $l10)
;; CHECK-TEXT-NEXT: (br $label)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (catch $e-i32
;; CHECK-TEXT-NEXT: (drop
;; CHECK-TEXT-NEXT: (pop i32)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (br $l10)
;; CHECK-TEXT-NEXT: (br $label)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: )
Expand Down Expand Up @@ -221,7 +221,7 @@
)

;; CHECK-TEXT: (func $empty-try-body (type $0)
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (nop)
;; CHECK-TEXT-NEXT: )
Expand Down Expand Up @@ -254,7 +254,7 @@
)

;; CHECK-TEXT: (func $multiple-insts-within-try-and-catch-bodies (type $0)
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (call $foo)
;; CHECK-TEXT-NEXT: (call $bar)
Expand Down Expand Up @@ -298,7 +298,7 @@
)

;; CHECK-TEXT: (func $multiple-catches (type $0)
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (throw $e-i32
;; CHECK-TEXT-NEXT: (i32.const 0)
Expand Down Expand Up @@ -350,7 +350,7 @@
)

;; CHECK-TEXT: (func $catch-all (type $0)
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (throw $e-i32
;; CHECK-TEXT-NEXT: (i32.const 0)
Expand Down Expand Up @@ -383,7 +383,7 @@
)

;; CHECK-TEXT: (func $catch-and-catch-all-together (type $0)
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (throw $e-i32
;; CHECK-TEXT-NEXT: (i32.const 0)
Expand Down Expand Up @@ -447,9 +447,9 @@
)

;; CHECK-TEXT: (func $nested-try-catch (type $0)
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (try $try1
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (throw $e-i32
;; CHECK-TEXT-NEXT: (i32.const 0)
Expand All @@ -471,7 +471,7 @@
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (catch_all
;; CHECK-TEXT-NEXT: (try $try2
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (throw $e-i32
;; CHECK-TEXT-NEXT: (i32.const 0)
Expand Down Expand Up @@ -563,7 +563,7 @@
)

;; CHECK-TEXT: (func $catchless-delegateless-try (type $0)
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (throw $e-i32
;; CHECK-TEXT-NEXT: (i32.const 0)
Expand Down Expand Up @@ -591,13 +591,13 @@
;; CHECK-TEXT: (func $inner-delegate-target-outer-catch (type $0)
;; CHECK-TEXT-NEXT: (try $l0
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (call $foo)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (delegate $l0)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (try $try3
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (call $foo)
;; CHECK-TEXT-NEXT: )
Expand Down Expand Up @@ -653,20 +653,20 @@
)

;; CHECK-TEXT: (func $branch-and-delegate-target-same-try-label (type $0)
;; CHECK-TEXT-NEXT: (block $l05
;; CHECK-TEXT-NEXT: (block $label
;; CHECK-TEXT-NEXT: (try $l0
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (br_if $l05
;; CHECK-TEXT-NEXT: (br_if $label
;; CHECK-TEXT-NEXT: (i32.const 1)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (delegate $l0)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (try $try4
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (br_if $l05
;; CHECK-TEXT-NEXT: (br_if $label
;; CHECK-TEXT-NEXT: (i32.const 1)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: )
Expand Down Expand Up @@ -736,7 +736,7 @@
;; CHECK-TEXT: (func $inner-delegate-target-outer-delegate (type $0)
;; CHECK-TEXT-NEXT: (try $l0
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (call $foo)
;; CHECK-TEXT-NEXT: )
Expand Down Expand Up @@ -778,7 +778,7 @@
)

;; CHECK-TEXT: (func $empty-catch-body (type $0)
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (nop)
;; CHECK-TEXT-NEXT: )
Expand Down Expand Up @@ -854,7 +854,7 @@
)

;; CHECK-TEXT: (func $branch-and-rethrow-target-same-try-label (type $0)
;; CHECK-TEXT-NEXT: (block $l06
;; CHECK-TEXT-NEXT: (block $label
;; CHECK-TEXT-NEXT: (try $l0
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (call $foo)
Expand All @@ -866,7 +866,7 @@
;; CHECK-TEXT-NEXT: (rethrow $l0)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (catch_all
;; CHECK-TEXT-NEXT: (br $l06)
;; CHECK-TEXT-NEXT: (br $label)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: )
Expand Down Expand Up @@ -915,7 +915,7 @@
;; CHECK-TEXT-NEXT: (call $foo)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (catch_all
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (call $foo)
;; CHECK-TEXT-NEXT: )
Expand Down Expand Up @@ -984,7 +984,7 @@
;; CHECK-TEXT-NEXT: (call $foo)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (catch_all
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (call $foo)
;; CHECK-TEXT-NEXT: )
Expand Down Expand Up @@ -1063,7 +1063,7 @@
;; CHECK-TEXT-NEXT: (call $foo)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (catch_all
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (rethrow $l0)
;; CHECK-TEXT-NEXT: )
Expand All @@ -1073,14 +1073,14 @@
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (try $l07
;; CHECK-TEXT-NEXT: (try $l00
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (call $foo)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (catch_all
;; CHECK-TEXT-NEXT: (try $try8
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (rethrow $l07)
;; CHECK-TEXT-NEXT: (rethrow $l00)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (catch_all
;; CHECK-TEXT-NEXT: (nop)
Expand Down Expand Up @@ -1152,7 +1152,7 @@
)

;; CHECK-TEXT: (func $pop-within-if-condition (type $0)
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (nop)
;; CHECK-TEXT-NEXT: )
Expand Down Expand Up @@ -1212,13 +1212,13 @@
)

;; CHECK-TEXT: (func $pop-can-be-supertype (type $0)
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (nop)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (catch $e-eqref
;; CHECK-TEXT-NEXT: (drop
;; CHECK-TEXT-NEXT: (pop anyref)
;; CHECK-TEXT-NEXT: (pop eqref)
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: )
Expand Down Expand Up @@ -1249,7 +1249,7 @@
;; CHECK-TEXT: (func $catchless-try-with-inner-delegate (type $0)
;; CHECK-TEXT-NEXT: (try $label$0
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (throw $e-i32
;; CHECK-TEXT-NEXT: (i32.const 0)
Expand Down Expand Up @@ -1295,7 +1295,7 @@
;; CHECK-TEXT-NEXT: (block $l0
;; CHECK-TEXT-NEXT: (block $l1
;; CHECK-TEXT-NEXT: )
;; CHECK-TEXT-NEXT: (try $try
;; CHECK-TEXT-NEXT: (try
;; CHECK-TEXT-NEXT: (do
;; CHECK-TEXT-NEXT: (nop)
;; CHECK-TEXT-NEXT: )
Expand Down
2 changes: 1 addition & 1 deletion test/lit/basic/extended-names-passive-data-segments.wast
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(data $passive_data "b")
(data "c")
)
;; CHECK-TEXT: (data $1 "c")
;; CHECK-TEXT: (data $0 "c")

;; CHECK-BIN: (data $1 "c")

Expand Down
2 changes: 1 addition & 1 deletion test/lit/basic/extended-names.wast
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

;; CHECK-TEXT: (data $passive_data "b")

;; CHECK-TEXT: (data $2 "c")
;; CHECK-TEXT: (data $0 "c")

;; CHECK-TEXT: (table $t1 1 funcref)
;; CHECK-BIN: (memory $m1 1 1)
Expand Down
Loading
Loading