summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm-binary.h3
-rw-r--r--test/unit.wast6
-rw-r--r--test/unit.wast.fromBinary23
3 files changed, 20 insertions, 12 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index ad6abf5af..795e89d98 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -848,11 +848,10 @@ public:
}
void visitLoop(Loop *curr) {
if (debug) std::cerr << "zz node: Loop" << std::endl;
- // TODO: optimize, as we usually have a block as our singleton child
o << int8_t(BinaryConsts::Loop);
breakStack.push_back(curr->out);
breakStack.push_back(curr->in);
- recurse(curr->body);
+ recursePossibleBlockContents(curr->body);
breakStack.pop_back();
breakStack.pop_back();
o << int8_t(BinaryConsts::End);
diff --git a/test/unit.wast b/test/unit.wast
index 6c37dd9f3..46c40fa04 100644
--- a/test/unit.wast
+++ b/test/unit.wast
@@ -402,4 +402,10 @@
)
(i32.const 0)
)
+ (func $loop-roundtrip (param $0 f64) (result f64)
+ (loop $loop-out0 $loop-in1
+ (get_local $0)
+ (get_local $0)
+ )
+ )
)
diff --git a/test/unit.wast.fromBinary b/test/unit.wast.fromBinary
index e80ba999e..c9ba4528b 100644
--- a/test/unit.wast.fromBinary
+++ b/test/unit.wast.fromBinary
@@ -9,6 +9,7 @@
(type $4 (func (result f64)))
(type $5 (func (result i32)))
(type $6 (func (param i32) (result i32)))
+ (type $7 (func (param f64) (result f64)))
(import $import$0 "env" "_emscripten_asm_const_vi")
(import $import$1 "asm2wasm" "f64-to-int" (param f64) (result i32))
(import $import$2 "asm2wasm" "f64-rem" (param f64 f64) (result f64))
@@ -260,20 +261,16 @@
)
(block $label$15
(loop $label$16 $label$17
- (block $label$18
- (br $label$16)
- (br $label$17)
- )
+ (br $label$16)
+ (br $label$17)
)
(br $label$9)
)
)
- (block $label$19
- (loop $label$20 $label$21
- (block $label$22
- (br $label$9)
- (br $label$21)
- )
+ (block $label$18
+ (loop $label$19 $label$20
+ (br $label$9)
+ (br $label$20)
)
(br $label$9)
)
@@ -419,5 +416,11 @@
(i32.const 0)
)
)
+ (func $loop-roundtrip (type $7) (param $var$0 f64) (result f64)
+ (loop $label$0 $label$1
+ (get_local $var$0)
+ (get_local $var$0)
+ )
+ )
)