OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 <cstring> | 5 #include <cstring> |
6 #include <functional> | 6 #include <functional> |
7 #include <iostream> | 7 #include <iostream> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/asmjs/asm-typer.h" | 10 #include "src/asmjs/asm-typer.h" |
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 for (size_t ii = 0; ii < arraysize(kTests); ++ii) { | 1790 for (size_t ii = 0; ii < arraysize(kTests); ++ii) { |
1791 const auto* test = kTests + ii; | 1791 const auto* test = kTests + ii; |
1792 if (!ValidationOf(Module(test->module)) | 1792 if (!ValidationOf(Module(test->module)) |
1793 ->FailsWithMessage(test->error_message)) { | 1793 ->FailsWithMessage(test->error_message)) { |
1794 std::cerr << "Test:\n" << test->module; | 1794 std::cerr << "Test:\n" << test->module; |
1795 CHECK(false); | 1795 CHECK(false); |
1796 } | 1796 } |
1797 } | 1797 } |
1798 } | 1798 } |
1799 | 1799 |
| 1800 TEST(InvalidSourceLayout) { |
| 1801 const char* kTests[] = { |
| 1802 "function asm() {\n" |
| 1803 " 'use asm';\n" |
| 1804 " function f() {}\n" |
| 1805 " var v = 0;\n" |
| 1806 " var v_v = [f];\n" |
| 1807 " return f;\n" |
| 1808 "}", |
| 1809 "function asm() {\n" |
| 1810 " 'use asm';\n" |
| 1811 " function f() {}\n" |
| 1812 " var v_v = [f];\n" |
| 1813 " var v = 0;\n" |
| 1814 " return f;\n" |
| 1815 "}", |
| 1816 "function asm() {\n" |
| 1817 " 'use asm';\n" |
| 1818 " function f() {}\n" |
| 1819 " var v_v = [f];\n" |
| 1820 " return f;\n" |
| 1821 " var v = 0;\n" |
| 1822 "}", |
| 1823 "function asm() {\n" |
| 1824 " 'use asm';\n" |
| 1825 " var v = 0;\n" |
| 1826 " var v_v = [f];\n" |
| 1827 " function f() {}\n" |
| 1828 " return f;\n" |
| 1829 "}", |
| 1830 "function asm() {\n" |
| 1831 " 'use asm';\n" |
| 1832 " var v = 0;\n" |
| 1833 " var v_v = [f];\n" |
| 1834 " return f;\n" |
| 1835 " function f() {}\n" |
| 1836 "}", |
| 1837 "function asm() {\n" |
| 1838 " 'use asm';\n" |
| 1839 " var v = 0;\n" |
| 1840 " function f() {}\n" |
| 1841 " return f;\n" |
| 1842 " var v_v = [f];\n" |
| 1843 "}", |
| 1844 "function asm() {\n" |
| 1845 " 'use asm';\n" |
| 1846 " var v = 0;\n" |
| 1847 " function f() {}\n" |
| 1848 " var v1 = 0;\n" |
| 1849 " var v_v = [f];\n" |
| 1850 " return f;\n" |
| 1851 "}", |
| 1852 "function asm() {\n" |
| 1853 " 'use asm';\n" |
| 1854 " var v = 0;\n" |
| 1855 " function f() {}\n" |
| 1856 " var v_v = [f];\n" |
| 1857 " var v1 = 0;\n" |
| 1858 " return f;\n" |
| 1859 "}", |
| 1860 "function asm() {\n" |
| 1861 " 'use asm';\n" |
| 1862 " var v = 0;\n" |
| 1863 " function f() {}\n" |
| 1864 " var v_v = [f];\n" |
| 1865 " return f;\n" |
| 1866 " var v1 = 0;\n" |
| 1867 "}", |
| 1868 "function asm() {\n" |
| 1869 " function f() {}\n" |
| 1870 " 'use asm';\n" |
| 1871 " var v_v = [f];\n" |
| 1872 " return f;\n" |
| 1873 "}", |
| 1874 "function asm() {\n" |
| 1875 " 'use asm';\n" |
| 1876 " return f;\n" |
| 1877 " var v = 0;\n" |
| 1878 " function f() {}\n" |
| 1879 " var v_v = [f];\n" |
| 1880 "}", |
| 1881 "function asm() {\n" |
| 1882 " 'use asm';\n" |
| 1883 " return f;\n" |
| 1884 " function f() {}\n" |
| 1885 "}", |
| 1886 "function __f_59() {\n" |
| 1887 " 'use asm';\n" |
| 1888 " function __f_110() {\n" |
| 1889 " return 71;\n" |
| 1890 " }\n" |
| 1891 " function __f_21() {\n" |
| 1892 " var __v_38 = 0;\n" |
| 1893 " return __v_23[__v_38&0]() | 0;\n" |
| 1894 " }\n" |
| 1895 " return {__f_21:__f_21};\n" |
| 1896 " var __v_23 = [__f_110];\n" |
| 1897 "}", |
| 1898 }; |
| 1899 |
| 1900 for (size_t ii = 0; ii < arraysize(kTests); ++ii) { |
| 1901 if (!ValidationOf(Module(kTests[ii])) |
| 1902 ->FailsWithMessage("Invalid asm.js source code layout")) { |
| 1903 std::cerr << "Test:\n" << kTests[ii]; |
| 1904 CHECK(false); |
| 1905 } |
| 1906 } |
| 1907 } |
| 1908 |
1800 } // namespace | 1909 } // namespace |
OLD | NEW |