Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Unified Diff: test/mjsunit/wasm/asm-wasm.js

Issue 1573413002: Add switch to asm to wasm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/wasm/asm-wasm-builder.cc ('K') | « src/wasm/asm-wasm-builder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/asm-wasm.js
diff --git a/test/mjsunit/wasm/asm-wasm.js b/test/mjsunit/wasm/asm-wasm.js
index 960977eab5399d02ff1d2c449ebc915147ea4dce..7f187ada27d0e2f1f4eb2e64830c218fc5ddbb46 100644
--- a/test/mjsunit/wasm/asm-wasm.js
+++ b/test/mjsunit/wasm/asm-wasm.js
@@ -669,3 +669,76 @@ function TestConditional() {
}
assertEquals(41, WASM.asmCompileRun(TestConditional.toString()));
+
+function TestSwitch() {
+ "use asm"
+
+ function caller() {
+ var ret = 0;
+ var x = 7;
+ switch (x) {
+ case 1: return 0;
+ case 7: {
+ ret = 12;
+ break;
+ }
+ default: return 0;
+ }
+ switch (x) {
+ case 1: return 0;
+ case 8: return 0;
+ default: ret = (ret + 11)|0;
+ }
+ return ret|0;
+ }
+
+ return {caller:caller};
+}
+
+assertEquals(23, WASM.asmCompileRun(TestSwitch.toString()));
+
+function TestSwitchFallthrough() {
+ "use asm"
+
+ function caller() {
+ var x = 17;
+ var ret = 0;
+ switch (x) {
+ case 17:
+ case 14: ret = 39;
+ case 1: ret = (ret + 3)|0;
+ case 4: break;
+ default: ret = (ret + 1)|0;
+ }
+ return ret|0;
+ }
+
+ return {caller:caller};
+}
+
+assertEquals(42, WASM.asmCompileRun(TestSwitchFallthrough.toString()));
+
+function TestNestedSwitch() {
+ "use asm"
+
+ function caller() {
+ var x = 3;
+ var y = -13;
+ switch (x) {
+ case 1: return 0;
+ case 3: {
+ switch (y) {
+ case 2: return 0;
+ case -13: return 43;
+ default: return 0;
+ }
+ }
+ default: return 0;
+ }
+ return 0;
+ }
+
+ return {caller:caller};
+}
+
+assertEquals(43, WASM.asmCompileRun(TestNestedSwitch.toString()));
« src/wasm/asm-wasm-builder.cc ('K') | « src/wasm/asm-wasm-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698