From 22e48f1f270e0f01765099070c45e75a52d81d70 Mon Sep 17 00:00:00 2001 From: Jean Christophe Beyler Date: Wed, 18 Nov 2015 13:00:30 -0800 Subject: [PATCH 1/2] Creating an obfuscated Loop1 The loop1 method is too simple for LLVM, which then makes it return just 5. Though this proves that the code is correct, we probably want to have the code generation all the same. This patch makes a loop3 method based on loop1 so that the code ais bit different but at least the compiler can no longer optimize it all away. We've left loop1 to show the difference in compiler technologies --- ml-proto/test/labels.wast | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ml-proto/test/labels.wast b/ml-proto/test/labels.wast index 002821e01b..0041323f66 100644 --- a/ml-proto/test/labels.wast +++ b/ml-proto/test/labels.wast @@ -34,6 +34,19 @@ ) ) + (func $loop3 (param $max i32) (result i32) + (local $i i32) + (set_local $i (i32.const 1)) + (loop $exit $cont + (set_local $i (i32.add (get_local $i) (get_local $i))) + (if (i32.gt_u (get_local $i) (get_local $max)) + (br $exit (get_local $i)) + ) + (br $cont) + ) + ) + + (func $switch (param i32) (result i32) (label $ret (i32.mul (i32.const 10) @@ -78,6 +91,7 @@ (export "block" $block) (export "loop1" $loop1) (export "loop2" $loop2) + (export "loop3" $loop3) (export "switch" $switch) (export "return" $return) (export "br_if" $br_if) @@ -86,6 +100,7 @@ (assert_return (invoke "block") (i32.const 1)) (assert_return (invoke "loop1") (i32.const 5)) (assert_return (invoke "loop2") (i32.const 8)) +(assert_return (invoke "loop3" (i32.const 8)) (i32.const 16)) (assert_return (invoke "switch" (i32.const 0)) (i32.const 50)) (assert_return (invoke "switch" (i32.const 1)) (i32.const 20)) (assert_return (invoke "switch" (i32.const 2)) (i32.const 20)) From 97c7c016a4aa99c3e24163fdb9d2ef4b4bd6d3e2 Mon Sep 17 00:00:00 2001 From: Jean Christophe Beyler Date: Wed, 9 Dec 2015 19:23:47 -0800 Subject: [PATCH 2/2] Added a testsuite expected-output for the address.wast test. --- .../test/expected-output/address.wast.log | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 ml-proto/test/expected-output/address.wast.log diff --git a/ml-proto/test/expected-output/address.wast.log b/ml-proto/test/expected-output/address.wast.log new file mode 100644 index 0000000000..6010156759 --- /dev/null +++ b/ml-proto/test/expected-output/address.wast.log @@ -0,0 +1,35 @@ +97 : i32 +98 : i32 +99 : i32 +122 : i32 +25185 : i32 +25442 : i32 +25699 : i32 +122 : i32 +1684234849 : i32 +1701077858 : i32 +1717920867 : i32 +122 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32 +0 : i32