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

Side by Side Diff: test/mjsunit/wasm/asm-wasm.js

Issue 1838973002: optimized switch implementation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « test/mjsunit/mjsunit.status ('k') | test/mjsunit/wasm/asm-wasm-switch.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --expose-wasm 5 // Flags: --expose-wasm
6 6
7 function assertWasm(expected, func, ffi) { 7 function assertWasm(expected, func, ffi) {
8 print("Testing " + func.name + "..."); 8 print("Testing " + func.name + "...");
9 assertEquals(expected, Wasm.instantiateModuleFromAsm( 9 assertEquals(expected, Wasm.instantiateModuleFromAsm(
10 func.toString(), ffi).caller()); 10 func.toString(), ffi).caller());
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 var x = 1; 762 var x = 1;
763 return ((x > 0) ? 41 : 71)|0; 763 return ((x > 0) ? 41 : 71)|0;
764 } 764 }
765 765
766 return {caller:caller}; 766 return {caller:caller};
767 } 767 }
768 768
769 assertWasm(41, TestConditional); 769 assertWasm(41, TestConditional);
770 770
771 771
772 function TestSwitch() {
773 "use asm"
774
775 function caller() {
776 var ret = 0;
777 var x = 7;
778 switch (x) {
779 case 1: return 0;
780 case 7: {
781 ret = 12;
782 break;
783 }
784 default: return 0;
785 }
786 switch (x) {
787 case 1: return 0;
788 case 8: return 0;
789 default: ret = (ret + 11)|0;
790 }
791 return ret|0;
792 }
793
794 return {caller:caller};
795 }
796
797 assertWasm(23, TestSwitch);
798
799
800 function TestSwitchFallthrough() {
801 "use asm"
802
803 function caller() {
804 var x = 17;
805 var ret = 0;
806 switch (x) {
807 case 17:
808 case 14: ret = 39;
809 case 1: ret = (ret + 3)|0;
810 case 4: break;
811 default: ret = (ret + 1)|0;
812 }
813 return ret|0;
814 }
815
816 return {caller:caller};
817 }
818
819 assertWasm(42, TestSwitchFallthrough);
820
821
822 function TestNestedSwitch() {
823 "use asm"
824
825 function caller() {
826 var x = 3;
827 var y = -13;
828 switch (x) {
829 case 1: return 0;
830 case 3: {
831 switch (y) {
832 case 2: return 0;
833 case -13: return 43;
834 default: return 0;
835 }
836 }
837 default: return 0;
838 }
839 return 0;
840 }
841
842 return {caller:caller};
843 }
844
845 assertWasm(43, TestNestedSwitch);
846
847
848 (function () { 772 (function () {
849 function TestInitFunctionWithNoGlobals() { 773 function TestInitFunctionWithNoGlobals() {
850 "use asm"; 774 "use asm";
851 function caller() { 775 function caller() {
852 return 51; 776 return 51;
853 } 777 }
854 return {caller}; 778 return {caller};
855 } 779 }
856 780
857 var module = Wasm.instantiateModuleFromAsm( 781 var module = Wasm.instantiateModuleFromAsm(
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 u0xffffffff: u0xffffffff, 1410 u0xffffffff: u0xffffffff,
1487 u0x80000000: u0x80000000, 1411 u0x80000000: u0x80000000,
1488 u0x87654321: u0x87654321, 1412 u0x87654321: u0x87654321,
1489 }; 1413 };
1490 } 1414 }
1491 var wasm = Wasm.instantiateModuleFromAsm(asmModule.toString()); 1415 var wasm = Wasm.instantiateModuleFromAsm(asmModule.toString());
1492 assertEquals(0xffffffff, wasm.u0xffffffff()); 1416 assertEquals(0xffffffff, wasm.u0xffffffff());
1493 assertEquals(0x80000000, wasm.u0x80000000()); 1417 assertEquals(0x80000000, wasm.u0x80000000());
1494 assertEquals(0x87654321, wasm.u0x87654321()); 1418 assertEquals(0x87654321, wasm.u0x87654321());
1495 })(); 1419 })();
OLDNEW
« no previous file with comments | « test/mjsunit/mjsunit.status ('k') | test/mjsunit/wasm/asm-wasm-switch.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698