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

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

Issue 1609893002: Add function tables 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 unified diff | Download patch
« src/wasm/encoder.cc ('K') | « src/wasm/encoder.cc ('k') | no next file » | 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 EmptyTest() { 7 function EmptyTest() {
8 "use asm"; 8 "use asm";
9 function caller() { 9 function caller() {
10 empty(); 10 empty();
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 function caller() { 851 function caller() {
852 return 55; 852 return 55;
853 } 853 }
854 return {alt_caller:caller}; 854 return {alt_caller:caller};
855 } 855 }
856 856
857 var module = _WASMEXP_.instantiateModuleFromAsm( 857 var module = _WASMEXP_.instantiateModuleFromAsm(
858 TestExportNameDifferentFromFunctionName.toString()); 858 TestExportNameDifferentFromFunctionName.toString());
859 module.__init__(); 859 module.__init__();
860 assertEquals(55, module.alt_caller()); 860 assertEquals(55, module.alt_caller());
861
862
863 function TestFunctionTableSimple() {
864 "use asm";
865
866 function dummy() {
867 return 71;
868 }
869
870 function caller() {
871 return function_table[0&0]() | 0;
872 }
873
874 var function_table = [dummy]
875
876 return {caller:caller};
877 }
878
879 assertEquals(71, _WASMEXP_.asmCompileRun(TestFunctionTableSimple.toString()));
880
881
882 function TestFunctionTable() {
883 "use asm";
884
885 function add(a, b) {
886 a = a|0;
887 b = b|0;
888 return (a+b)|0;
889 }
890
891 function sub(a, b) {
892 a = a|0;
893 b = b|0;
894 return (a-b)|0;
895 }
896
897 function inc(a) {
898 a = a|0;
899 return (a+1)|0;
900 }
901
902 function caller(table_id, fun_id, arg1, arg2) {
903 table_id = table_id|0;
904 fun_id = fun_id|0;
905 arg1 = arg1|0;
906 arg2 = arg2|0;
907 if (table_id == 0) {
908 return funBin[fun_id&3](arg1, arg2)|0;
bradnelson 2016/01/20 00:40:52 Given the parser eats constant function indexes an
aseemgarg 2016/01/20 00:56:09 Added that above TestFunctionTableSimple
bradnelson 2016/01/20 00:57:01 Doh, missed the test above, though actually might
909 } else if (table_id == 1) {
910 return fun[fun_id&0](arg1)|0;
911 }
912 return 0;
913 }
914
915 var funBin = [add, sub, sub, add];
916 var fun = [inc];
917
918 return {caller:caller};
919 }
920
921 var module = _WASMEXP_.instantiateModuleFromAsm(TestFunctionTable.toString());
922 module.__init__();
923 assertEquals(55, module.caller(0, 0, 33, 22));
924 assertEquals(11, module.caller(0, 1, 33, 22));
925 assertEquals(9, module.caller(0, 2, 54, 45));
926 assertEquals(99, module.caller(0, 3, 54, 45));
927 assertEquals(23, module.caller(0, 4, 12, 11));
928 assertEquals(31, module.caller(1, 0, 30, 11));
OLDNEW
« src/wasm/encoder.cc ('K') | « src/wasm/encoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698