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

Side by Side Diff: test/cctest/wasm/test-run-wasm.cc

Issue 2670673002: [wasm] Implement polymorphic checking, matching the reference interpreter. (Closed)
Patch Set: Fix test-run-simd Created 3 years, 10 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 | « src/wasm/wasm-opcodes.h ('k') | test/cctest/wasm/test-run-wasm-simd.cc » ('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 #include <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "src/base/platform/elapsed-timer.h" 9 #include "src/base/platform/elapsed-timer.h"
10 #include "src/utils.h" 10 #include "src/utils.h"
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 WASM_EXEC_TEST(Return12) { 720 WASM_EXEC_TEST(Return12) {
721 WasmRunner<int32_t> r(execution_mode); 721 WasmRunner<int32_t> r(execution_mode);
722 722
723 BUILD(r, RET_I8(12)); 723 BUILD(r, RET_I8(12));
724 CHECK_EQ(12, r.Call()); 724 CHECK_EQ(12, r.Call());
725 } 725 }
726 726
727 WASM_EXEC_TEST(Return17) { 727 WASM_EXEC_TEST(Return17) {
728 WasmRunner<int32_t> r(execution_mode); 728 WasmRunner<int32_t> r(execution_mode);
729 729
730 BUILD(r, WASM_BLOCK(RET_I8(17))); 730 BUILD(r, WASM_BLOCK(RET_I8(17)), WASM_ZERO);
731 CHECK_EQ(17, r.Call()); 731 CHECK_EQ(17, r.Call());
732 } 732 }
733 733
734 WASM_EXEC_TEST(Return_I32) { 734 WASM_EXEC_TEST(Return_I32) {
735 WasmRunner<int32_t, int32_t> r(execution_mode); 735 WasmRunner<int32_t, int32_t> r(execution_mode);
736 736
737 BUILD(r, RET(WASM_GET_LOCAL(0))); 737 BUILD(r, RET(WASM_GET_LOCAL(0)));
738 738
739 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 739 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
740 } 740 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 WASM_EXEC_TEST(BrIf_strict) { 829 WASM_EXEC_TEST(BrIf_strict) {
830 WasmRunner<int32_t, int32_t> r(execution_mode); 830 WasmRunner<int32_t, int32_t> r(execution_mode);
831 BUILD(r, WASM_BLOCK_I(WASM_BRV_IF(0, WASM_GET_LOCAL(0), 831 BUILD(r, WASM_BLOCK_I(WASM_BRV_IF(0, WASM_GET_LOCAL(0),
832 WASM_TEE_LOCAL(0, WASM_I32V_2(99))))); 832 WASM_TEE_LOCAL(0, WASM_I32V_2(99)))));
833 833
834 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 834 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
835 } 835 }
836 836
837 WASM_EXEC_TEST(Br_height) { 837 WASM_EXEC_TEST(Br_height) {
838 WasmRunner<int32_t, int32_t> r(execution_mode); 838 WasmRunner<int32_t, int32_t> r(execution_mode);
839 BUILD(r, WASM_BLOCK_I(WASM_BLOCK_I(WASM_BRV_IFD(0, WASM_GET_LOCAL(0), 839 BUILD(r, WASM_BLOCK_I(
840 WASM_GET_LOCAL(0)), 840 WASM_BLOCK(WASM_BRV_IFD(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)),
841 WASM_RETURN1(WASM_I32V_1(9)), 841 WASM_RETURN1(WASM_I32V_1(9))),
842 WASM_I32V_1(7), WASM_I32V_1(7)), 842 WASM_BRV(0, WASM_I32V_1(8))));
843 WASM_BRV(0, WASM_I32V_1(8))));
844 843
845 for (int32_t i = 0; i < 5; i++) { 844 for (int32_t i = 0; i < 5; i++) {
846 int32_t expected = i != 0 ? 8 : 9; 845 int32_t expected = i != 0 ? 8 : 9;
847 CHECK_EQ(expected, r.Call(i)); 846 CHECK_EQ(expected, r.Call(i));
848 } 847 }
849 } 848 }
850 849
851 WASM_EXEC_TEST(Regression_660262) { 850 WASM_EXEC_TEST(Regression_660262) {
852 WasmRunner<int32_t> r(execution_mode); 851 WasmRunner<int32_t> r(execution_mode);
853 r.module().AddMemoryElems<int32_t>(8); 852 r.module().AddMemoryElems<int32_t>(8);
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 CHECK_EQ(expected, r.Call(*i)); 1269 CHECK_EQ(expected, r.Call(*i));
1271 } 1270 }
1272 } 1271 }
1273 1272
1274 WASM_EXEC_TEST(Block_IfElse_P_return) { 1273 WASM_EXEC_TEST(Block_IfElse_P_return) {
1275 WasmRunner<int32_t, int32_t> r(execution_mode); 1274 WasmRunner<int32_t, int32_t> r(execution_mode);
1276 // if (p0) return 81; else return 82; 1275 // if (p0) return 81; else return 82;
1277 BUILD(r, // -- 1276 BUILD(r, // --
1278 WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- 1277 WASM_IF_ELSE(WASM_GET_LOCAL(0), // --
1279 RET_I8(81), // -- 1278 RET_I8(81), // --
1280 RET_I8(82))); // -- 1279 RET_I8(82)), // --
1280 WASM_ZERO); // --
1281 FOR_INT32_INPUTS(i) { 1281 FOR_INT32_INPUTS(i) {
1282 int32_t expected = *i ? 81 : 82; 1282 int32_t expected = *i ? 81 : 82;
1283 CHECK_EQ(expected, r.Call(*i)); 1283 CHECK_EQ(expected, r.Call(*i));
1284 } 1284 }
1285 } 1285 }
1286 1286
1287 WASM_EXEC_TEST(Block_If_P_assign) { 1287 WASM_EXEC_TEST(Block_If_P_assign) {
1288 WasmRunner<int32_t, int32_t> r(execution_mode); 1288 WasmRunner<int32_t, int32_t> r(execution_mode);
1289 // { if (p0) p0 = 61; p0; } 1289 // { if (p0) p0 = 61; p0; }
1290 BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I32V_1(61))), 1290 BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I32V_1(61))),
1291 WASM_GET_LOCAL(0)); 1291 WASM_GET_LOCAL(0));
1292 FOR_INT32_INPUTS(i) { 1292 FOR_INT32_INPUTS(i) {
1293 int32_t expected = *i ? 61 : *i; 1293 int32_t expected = *i ? 61 : *i;
1294 CHECK_EQ(expected, r.Call(*i)); 1294 CHECK_EQ(expected, r.Call(*i));
1295 } 1295 }
1296 } 1296 }
1297 1297
1298 WASM_EXEC_TEST(DanglingAssign) { 1298 WASM_EXEC_TEST(DanglingAssign) {
1299 WasmRunner<int32_t, int32_t> r(execution_mode); 1299 WasmRunner<int32_t, int32_t> r(execution_mode);
1300 // { return 0; p0 = 0; } 1300 // { return 0; p0 = 0; }
1301 BUILD(r, B2(RET_I8(99), WASM_SET_LOCAL(0, WASM_ZERO))); 1301 BUILD(r, WASM_BLOCK_I(RET_I8(99), WASM_TEE_LOCAL(0, WASM_ZERO)));
1302 CHECK_EQ(99, r.Call(1)); 1302 CHECK_EQ(99, r.Call(1));
1303 } 1303 }
1304 1304
1305 WASM_EXEC_TEST(ExprIf_P) { 1305 WASM_EXEC_TEST(ExprIf_P) {
1306 WasmRunner<int32_t, int32_t> r(execution_mode); 1306 WasmRunner<int32_t, int32_t> r(execution_mode);
1307 // p0 ? 11 : 22; 1307 // p0 ? 11 : 22;
1308 BUILD(r, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), // -- 1308 BUILD(r, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), // --
1309 WASM_I32V_1(11), // -- 1309 WASM_I32V_1(11), // --
1310 WASM_I32V_1(22))); // -- 1310 WASM_I32V_1(22))); // --
1311 FOR_INT32_INPUTS(i) { 1311 FOR_INT32_INPUTS(i) {
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 double buffer[kSize] = {1, 2, 2, 2, 2, 2}; 1757 double buffer[kSize] = {1, 2, 2, 2, 2, 2};
1758 double result = 1758 double result =
1759 GenerateAndRunFold<double>(execution_mode, kExprF64Mul, buffer, kSize, 1759 GenerateAndRunFold<double>(execution_mode, kExprF64Mul, buffer, kSize,
1760 kWasmF64, MachineType::Float64()); 1760 kWasmF64, MachineType::Float64());
1761 CHECK_EQ(32, result); 1761 CHECK_EQ(32, result);
1762 } 1762 }
1763 1763
1764 WASM_EXEC_TEST(Build_Wasm_Infinite_Loop) { 1764 WASM_EXEC_TEST(Build_Wasm_Infinite_Loop) {
1765 WasmRunner<int32_t, int32_t> r(execution_mode); 1765 WasmRunner<int32_t, int32_t> r(execution_mode);
1766 // Only build the graph and compile, don't run. 1766 // Only build the graph and compile, don't run.
1767 BUILD(r, WASM_INFINITE_LOOP); 1767 BUILD(r, WASM_INFINITE_LOOP, WASM_ZERO);
1768 } 1768 }
1769 1769
1770 WASM_EXEC_TEST(Build_Wasm_Infinite_Loop_effect) { 1770 WASM_EXEC_TEST(Build_Wasm_Infinite_Loop_effect) {
1771 WasmRunner<int32_t, int32_t> r(execution_mode); 1771 WasmRunner<int32_t, int32_t> r(execution_mode);
1772 r.module().AddMemoryElems<int8_t>(16); 1772 r.module().AddMemoryElems<int8_t>(16);
1773 1773
1774 // Only build the graph and compile, don't run. 1774 // Only build the graph and compile, don't run.
1775 BUILD(r, WASM_LOOP(WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO), WASM_DROP), 1775 BUILD(r, WASM_LOOP(WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO), WASM_DROP),
1776 WASM_ZERO); 1776 WASM_ZERO);
1777 } 1777 }
(...skipping 22 matching lines...) Expand all
1800 BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE); 1800 BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE);
1801 } 1801 }
1802 1802
1803 TEST(Build_Wasm_Unreachable3) { 1803 TEST(Build_Wasm_Unreachable3) {
1804 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); 1804 WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
1805 BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE, WASM_UNREACHABLE); 1805 BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE, WASM_UNREACHABLE);
1806 } 1806 }
1807 1807
1808 TEST(Build_Wasm_UnreachableIf1) { 1808 TEST(Build_Wasm_UnreachableIf1) {
1809 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); 1809 WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
1810 BUILD(r, WASM_UNREACHABLE, WASM_IF(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); 1810 BUILD(r, WASM_UNREACHABLE,
1811 WASM_IF(WASM_GET_LOCAL(0), WASM_SEQ(WASM_GET_LOCAL(0), WASM_DROP)),
1812 WASM_ZERO);
1811 } 1813 }
1812 1814
1813 TEST(Build_Wasm_UnreachableIf2) { 1815 TEST(Build_Wasm_UnreachableIf2) {
1814 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); 1816 WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
1815 BUILD(r, WASM_UNREACHABLE, 1817 BUILD(r, WASM_UNREACHABLE,
1816 WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_UNREACHABLE)); 1818 WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_UNREACHABLE));
1817 } 1819 }
1818 1820
1819 WASM_EXEC_TEST(Unreachable_Load) { 1821 WASM_EXEC_TEST(Unreachable_Load) {
1820 WasmRunner<int32_t, int32_t> r(execution_mode); 1822 WasmRunner<int32_t, int32_t> r(execution_mode);
1821 r.module().AddMemory(0L); 1823 r.module().AddMemory(8);
1822 BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)), 1824 BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)),
1823 WASM_LOAD_MEM(MachineType::Int8(), WASM_GET_LOCAL(0)))); 1825 WASM_LOAD_MEM(MachineType::Int8(), WASM_GET_LOCAL(0))));
1824 CHECK_EQ(11, r.Call(11)); 1826 CHECK_EQ(11, r.Call(11));
1825 CHECK_EQ(21, r.Call(21)); 1827 CHECK_EQ(21, r.Call(21));
1826 } 1828 }
1827 1829
1830 WASM_EXEC_TEST(BrV_Fallthrough) {
1831 WasmRunner<int32_t> r(execution_mode);
1832 BUILD(r, WASM_BLOCK_I(WASM_BLOCK(WASM_BRV(1, WASM_I32V_1(42))),
1833 WASM_I32V_1(22)));
1834 CHECK_EQ(42, r.Call());
1835 }
1836
1828 WASM_EXEC_TEST(Infinite_Loop_not_taken1) { 1837 WASM_EXEC_TEST(Infinite_Loop_not_taken1) {
1829 WasmRunner<int32_t, int32_t> r(execution_mode); 1838 WasmRunner<int32_t, int32_t> r(execution_mode);
1830 BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_INFINITE_LOOP), WASM_I32V_1(45)); 1839 BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_INFINITE_LOOP), WASM_I32V_1(45));
1831 // Run the code, but don't go into the infinite loop. 1840 // Run the code, but don't go into the infinite loop.
1832 CHECK_EQ(45, r.Call(0)); 1841 CHECK_EQ(45, r.Call(0));
1833 } 1842 }
1834 1843
1835 WASM_EXEC_TEST(Infinite_Loop_not_taken2) { 1844 WASM_EXEC_TEST(Infinite_Loop_not_taken2) {
1836 WasmRunner<int32_t, int32_t> r(execution_mode); 1845 WasmRunner<int32_t, int32_t> r(execution_mode);
1837 BUILD(r, WASM_BLOCK_I(WASM_IF_ELSE(WASM_GET_LOCAL(0), 1846 BUILD(r, WASM_BLOCK_I(
1838 WASM_BRV(1, WASM_I32V_1(45)), 1847 WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I32V_1(45)),
1839 WASM_INFINITE_LOOP))); 1848 WASM_INFINITE_LOOP),
1849 WASM_ZERO));
1840 // Run the code, but don't go into the infinite loop. 1850 // Run the code, but don't go into the infinite loop.
1841 CHECK_EQ(45, r.Call(1)); 1851 CHECK_EQ(45, r.Call(1));
1842 } 1852 }
1843 1853
1844 WASM_EXEC_TEST(Infinite_Loop_not_taken2_brif) { 1854 WASM_EXEC_TEST(Infinite_Loop_not_taken2_brif) {
1845 WasmRunner<int32_t, int32_t> r(execution_mode); 1855 WasmRunner<int32_t, int32_t> r(execution_mode);
1846 BUILD(r, WASM_BLOCK_I(WASM_BRV_IF(0, WASM_I32V_1(45), WASM_GET_LOCAL(0)), 1856 BUILD(r, WASM_BLOCK_I(WASM_BRV_IF(0, WASM_I32V_1(45), WASM_GET_LOCAL(0)),
1847 WASM_INFINITE_LOOP)); 1857 WASM_INFINITE_LOOP));
1848 // Run the code, but don't go into the infinite loop. 1858 // Run the code, but don't go into the infinite loop.
1849 CHECK_EQ(45, r.Call(1)); 1859 CHECK_EQ(45, r.Call(1));
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
2876 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, 2886 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP,
2877 WASM_ZERO); 2887 WASM_ZERO);
2878 const int32_t kMin = std::numeric_limits<int32_t>::min(); 2888 const int32_t kMin = std::numeric_limits<int32_t>::min();
2879 CHECK_EQ(0, r.Call(133, 100)); 2889 CHECK_EQ(0, r.Call(133, 100));
2880 CHECK_EQ(0, r.Call(kMin, -1)); 2890 CHECK_EQ(0, r.Call(kMin, -1));
2881 CHECK_EQ(0, r.Call(0, 1)); 2891 CHECK_EQ(0, r.Call(0, 1));
2882 CHECK_TRAP(r.Call(100, 0)); 2892 CHECK_TRAP(r.Call(100, 0));
2883 CHECK_TRAP(r.Call(-1001, 0)); 2893 CHECK_TRAP(r.Call(-1001, 0));
2884 CHECK_TRAP(r.Call(kMin, 0)); 2894 CHECK_TRAP(r.Call(kMin, 0));
2885 } 2895 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | test/cctest/wasm/test-run-wasm-simd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698