1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416
|
# Copyright (C) 2011, 2012, 2013, 2014 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
# Crash course on the language that this is written in (which I just call
# "assembly" even though it's more than that):
#
# - Mostly gas-style operand ordering. The last operand tends to be the
# destination. So "a := b" is written as "mov b, a". But unlike gas,
# comparisons are in-order, so "if (a < b)" is written as
# "bilt a, b, ...".
#
# - "b" = byte, "h" = 16-bit word, "i" = 32-bit word, "p" = pointer.
# Currently this is just 32-bit so "i" and "p" are interchangeable
# except when an op supports one but not the other.
#
# - In general, valid operands for macro invocations and instructions are
# registers (eg "t0"), addresses (eg "4[t0]"), base-index addresses
# (eg "7[t0, t1, 2]"), absolute addresses (eg "0xa0000000[]"), or labels
# (eg "_foo" or ".foo"). Macro invocations can also take anonymous
# macros as operands. Instructions cannot take anonymous macros.
#
# - Labels must have names that begin with either "_" or ".". A "." label
# is local and gets renamed before code gen to minimize namespace
# pollution. A "_" label is an extern symbol (i.e. ".globl"). The "_"
# may or may not be removed during code gen depending on whether the asm
# conventions for C name mangling on the target platform mandate a "_"
# prefix.
#
# - A "macro" is a lambda expression, which may be either anonymous or
# named. But this has caveats. "macro" can take zero or more arguments,
# which may be macros or any valid operands, but it can only return
# code. But you can do Turing-complete things via continuation passing
# style: "macro foo (a, b) b(a) end foo(foo, foo)". Actually, don't do
# that, since you'll just crash the assembler.
#
# - An "if" is a conditional on settings. Any identifier supplied in the
# predicate of an "if" is assumed to be a #define that is available
# during code gen. So you can't use "if" for computation in a macro, but
# you can use it to select different pieces of code for different
# platforms.
#
# - Arguments to macros follow lexical scoping rather than dynamic scoping.
# Const's also follow lexical scoping and may override (hide) arguments
# or other consts. All variables (arguments and constants) can be bound
# to operands. Additionally, arguments (but not constants) can be bound
# to macros.
# Below we have a bunch of constant declarations. Each constant must have
# a corresponding ASSERT() in LLIntData.cpp.
# Utilities
macro dispatch(advance)
addp advance * 4, PC
jmp [PC]
end
macro dispatchBranchWithOffset(pcOffset)
lshifti 2, pcOffset
addp pcOffset, PC
jmp [PC]
end
macro dispatchBranch(pcOffset)
loadi pcOffset, t0
dispatchBranchWithOffset(t0)
end
macro dispatchAfterCall()
loadi ArgumentCount + TagOffset[cfr], PC
loadi 4[PC], t2
storei t1, TagOffset[cfr, t2, 8]
storei t0, PayloadOffset[cfr, t2, 8]
valueProfile(t1, t0, 4 * (CallOpCodeSize - 1), t3)
dispatch(CallOpCodeSize)
end
macro cCall2(function, arg1, arg2)
if ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS
move arg1, a0
move arg2, a1
call function
elsif X86 or X86_WIN
subp 8, sp
push arg2
push arg1
call function
addp 16, sp
elsif SH4
setargs arg1, arg2
call function
elsif C_LOOP
cloopCallSlowPath function, arg1, arg2
else
error
end
end
macro cCall2Void(function, arg1, arg2)
if C_LOOP
cloopCallSlowPathVoid function, arg1, arg2
else
cCall2(function, arg1, arg2)
end
end
# This barely works. arg3 and arg4 should probably be immediates.
macro cCall4(function, arg1, arg2, arg3, arg4)
if ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS
move arg1, a0
move arg2, a1
move arg3, a2
move arg4, a3
call function
elsif X86 or X86_WIN
push arg4
push arg3
push arg2
push arg1
call function
addp 16, sp
elsif SH4
setargs arg1, arg2, arg3, arg4
call function
elsif C_LOOP
error
else
error
end
end
macro callSlowPath(slowPath)
cCall2(slowPath, cfr, PC)
move t0, PC
end
macro doVMEntry(makeCall)
if X86 or X86_WIN
const entry = t4
const vm = t3
const protoCallFrame = t5
const temp1 = t0
const temp2 = t1
const temp3 = t2
const temp4 = t3 # same as vm
elsif ARM or ARMv7 or ARMv7_TRADITIONAL or C_LOOP
const entry = a0
const vm = a1
const protoCallFrame = a2
const temp1 = t3
const temp2 = t4
const temp3 = t5
const temp4 = t4 # Same as temp2
elsif MIPS
const entry = a0
const vm = a1
const protoCallFrame = a2
const temp1 = t3
const temp2 = t5
const temp3 = t4
const temp4 = t6
elsif SH4
const entry = a0
const vm = a1
const protoCallFrame = a2
const temp1 = t3
const temp2 = a3
const temp3 = t8
const temp4 = t9
end
functionPrologue()
pushCalleeSaves()
if X86 or X86_WIN
loadp 12[cfr], vm
loadp 8[cfr], entry
end
if ARMv7
vmEntryRecord(cfr, temp1)
move temp1, sp
else
vmEntryRecord(cfr, sp)
end
storep vm, VMEntryRecord::m_vm[sp]
loadp VM::topCallFrame[vm], temp2
storep temp2, VMEntryRecord::m_prevTopCallFrame[sp]
loadp VM::topVMEntryFrame[vm], temp2
storep temp2, VMEntryRecord::m_prevTopVMEntryFrame[sp]
# Align stack pointer
if X86_WIN
addp CallFrameAlignSlots * SlotSize, sp, temp1
andp ~StackAlignmentMask, temp1
subp temp1, CallFrameAlignSlots * SlotSize, sp
elsif ARM or ARMv7 or ARMv7_TRADITIONAL
addp CallFrameAlignSlots * SlotSize, sp, temp1
clrbp temp1, StackAlignmentMask, temp1
if ARMv7
subp temp1, CallFrameAlignSlots * SlotSize, temp1
move temp1, sp
else
subp temp1, CallFrameAlignSlots * SlotSize, sp
end
end
if X86 or X86_WIN
loadp 16[cfr], protoCallFrame
end
loadi ProtoCallFrame::paddedArgCount[protoCallFrame], temp2
addp CallFrameHeaderSlots, temp2, temp2
lshiftp 3, temp2
subp sp, temp2, temp1
# Ensure that we have enough additional stack capacity for the incoming args,
# and the frame for the JS code we're executing. We need to do this check
# before we start copying the args from the protoCallFrame below.
bpaeq temp1, VM::m_jsStackLimit[vm], .stackHeightOK
if C_LOOP
move entry, temp2
move vm, temp3
cloopCallSlowPath _llint_stack_check_at_vm_entry, vm, temp1
bpeq t0, 0, .stackCheckFailed
move temp2, entry
move temp3, vm
jmp .stackHeightOK
.stackCheckFailed:
move temp2, entry
move temp3, vm
end
cCall2(_llint_throw_stack_overflow_error, vm, protoCallFrame)
if ARMv7
vmEntryRecord(cfr, temp1)
move temp1, sp
else
vmEntryRecord(cfr, sp)
end
loadp VMEntryRecord::m_vm[sp], temp3
loadp VMEntryRecord::m_prevTopCallFrame[sp], temp4
storep temp4, VM::topCallFrame[temp3]
loadp VMEntryRecord::m_prevTopVMEntryFrame[sp], temp4
storep temp4, VM::topVMEntryFrame[temp3]
if ARMv7
subp cfr, CalleeRegisterSaveSize, temp3
move temp3, sp
else
subp cfr, CalleeRegisterSaveSize, sp
end
popCalleeSaves()
functionEpilogue()
ret
.stackHeightOK:
move temp1, sp
move 5, temp1
.copyHeaderLoop:
subi 1, temp1
loadi TagOffset[protoCallFrame, temp1, 8], temp3
storei temp3, TagOffset + CodeBlock[sp, temp1, 8]
loadi PayloadOffset[protoCallFrame, temp1, 8], temp3
storei temp3, PayloadOffset + CodeBlock[sp, temp1, 8]
btinz temp1, .copyHeaderLoop
loadi PayloadOffset + ProtoCallFrame::argCountAndCodeOriginValue[protoCallFrame], temp2
subi 1, temp2
loadi ProtoCallFrame::paddedArgCount[protoCallFrame], temp3
subi 1, temp3
bieq temp2, temp3, .copyArgs
.fillExtraArgsLoop:
subi 1, temp3
storei UndefinedTag, ThisArgumentOffset + 8 + TagOffset[sp, temp3, 8]
storei 0, ThisArgumentOffset + 8 + PayloadOffset[sp, temp3, 8]
bineq temp2, temp3, .fillExtraArgsLoop
.copyArgs:
loadp ProtoCallFrame::args[protoCallFrame], temp1
.copyArgsLoop:
btiz temp2, .copyArgsDone
subi 1, temp2
loadi TagOffset[temp1, temp2, 8], temp3
storei temp3, ThisArgumentOffset + 8 + TagOffset[sp, temp2, 8]
loadi PayloadOffset[temp1, temp2, 8], temp3
storei temp3, ThisArgumentOffset + 8 + PayloadOffset[sp, temp2, 8]
jmp .copyArgsLoop
.copyArgsDone:
storep sp, VM::topCallFrame[vm]
storep cfr, VM::topVMEntryFrame[vm]
makeCall(entry, temp1, temp2)
if ARMv7
vmEntryRecord(cfr, temp1)
move temp1, sp
else
vmEntryRecord(cfr, sp)
end
loadp VMEntryRecord::m_vm[sp], temp3
loadp VMEntryRecord::m_prevTopCallFrame[sp], temp4
storep temp4, VM::topCallFrame[temp3]
loadp VMEntryRecord::m_prevTopVMEntryFrame[sp], temp4
storep temp4, VM::topVMEntryFrame[temp3]
if ARMv7
subp cfr, CalleeRegisterSaveSize, temp3
move temp3, sp
else
subp cfr, CalleeRegisterSaveSize, sp
end
popCalleeSaves()
functionEpilogue()
ret
end
macro makeJavaScriptCall(entry, temp, unused)
addp CallerFrameAndPCSize, sp
checkStackPointerAlignment(t2, 0xbad0dc02)
if C_LOOP
cloopCallJSFunction entry
else
call entry
end
checkStackPointerAlignment(t2, 0xbad0dc03)
subp CallerFrameAndPCSize, sp
end
macro makeHostFunctionCall(entry, temp1, temp2)
move entry, temp1
storep cfr, [sp]
if C_LOOP
move sp, a0
storep lr, PtrSize[sp]
cloopCallNative temp1
elsif X86 or X86_WIN
# Put callee frame pointer on stack as arg0, also put it in ecx for "fastcall" targets
move 0, temp2
move temp2, 4[sp] # put 0 in ReturnPC
move sp, t2 # t2 is ecx
push temp2 # Push dummy arg1
push t2
call temp1
addp 8, sp
else
move sp, a0
call temp1
end
end
_handleUncaughtException:
loadp Callee + PayloadOffset[cfr], t3
andp MarkedBlockMask, t3
loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
loadp VM::callFrameForThrow[t3], cfr
loadp CallerFrame[cfr], cfr
if ARMv7
vmEntryRecord(cfr, t3)
move t3, sp
else
vmEntryRecord(cfr, sp)
end
loadp VMEntryRecord::m_vm[sp], t3
loadp VMEntryRecord::m_prevTopCallFrame[sp], t5
storep t5, VM::topCallFrame[t3]
loadp VMEntryRecord::m_prevTopVMEntryFrame[sp], t5
storep t5, VM::topVMEntryFrame[t3]
if ARMv7
subp cfr, CalleeRegisterSaveSize, t3
move t3, sp
else
subp cfr, CalleeRegisterSaveSize, sp
end
popCalleeSaves()
functionEpilogue()
ret
macro doReturnFromHostFunction(extraStackSpace)
functionEpilogue(extraStackSpace)
ret
end
# Debugging operation if you'd like to print an operand in the instruction stream. fromWhere
# should be an immediate integer - any integer you like; use it to identify the place you're
# debugging from. operand should likewise be an immediate, and should identify the operand
# in the instruction stream you'd like to print out.
macro traceOperand(fromWhere, operand)
cCall4(_llint_trace_operand, cfr, PC, fromWhere, operand)
move t0, PC
move t1, cfr
end
# Debugging operation if you'd like to print the value of an operand in the instruction
# stream. Same as traceOperand(), but assumes that the operand is a register, and prints its
# value.
macro traceValue(fromWhere, operand)
cCall4(_llint_trace_value, cfr, PC, fromWhere, operand)
move t0, PC
move t1, cfr
end
# Call a slowPath for call opcodes.
macro callCallSlowPath(slowPath, action)
storep PC, ArgumentCount + TagOffset[cfr]
cCall2(slowPath, cfr, PC)
action(t0)
end
macro callWatchdogTimerHandler(throwHandler)
storei PC, ArgumentCount + TagOffset[cfr]
cCall2(_llint_slow_path_handle_watchdog_timer, cfr, PC)
btpnz t0, throwHandler
loadi ArgumentCount + TagOffset[cfr], PC
end
macro checkSwitchToJITForLoop()
checkSwitchToJIT(
1,
macro ()
storei PC, ArgumentCount + TagOffset[cfr]
cCall2(_llint_loop_osr, cfr, PC)
btpz t0, .recover
move t1, sp
jmp t0
.recover:
loadi ArgumentCount + TagOffset[cfr], PC
end)
end
macro loadVariable(operand, index, tag, payload)
loadisFromInstruction(operand, index)
loadi TagOffset[cfr, index, 8], tag
loadi PayloadOffset[cfr, index, 8], payload
end
# Index, tag, and payload must be different registers. Index is not
# changed.
macro loadConstantOrVariable(index, tag, payload)
bigteq index, FirstConstantRegisterIndex, .constant
loadi TagOffset[cfr, index, 8], tag
loadi PayloadOffset[cfr, index, 8], payload
jmp .done
.constant:
loadp CodeBlock[cfr], payload
loadp CodeBlock::m_constantRegisters + VectorBufferOffset[payload], payload
# There is a bit of evil here: if the index contains a value >= FirstConstantRegisterIndex,
# then value << 3 will be equal to (value - FirstConstantRegisterIndex) << 3.
loadp TagOffset[payload, index, 8], tag
loadp PayloadOffset[payload, index, 8], payload
.done:
end
macro loadConstantOrVariableTag(index, tag)
bigteq index, FirstConstantRegisterIndex, .constant
loadi TagOffset[cfr, index, 8], tag
jmp .done
.constant:
loadp CodeBlock[cfr], tag
loadp CodeBlock::m_constantRegisters + VectorBufferOffset[tag], tag
# There is a bit of evil here: if the index contains a value >= FirstConstantRegisterIndex,
# then value << 3 will be equal to (value - FirstConstantRegisterIndex) << 3.
loadp TagOffset[tag, index, 8], tag
.done:
end
# Index and payload may be the same register. Index may be clobbered.
macro loadConstantOrVariable2Reg(index, tag, payload)
bigteq index, FirstConstantRegisterIndex, .constant
loadi TagOffset[cfr, index, 8], tag
loadi PayloadOffset[cfr, index, 8], payload
jmp .done
.constant:
loadp CodeBlock[cfr], tag
loadp CodeBlock::m_constantRegisters + VectorBufferOffset[tag], tag
# There is a bit of evil here: if the index contains a value >= FirstConstantRegisterIndex,
# then value << 3 will be equal to (value - FirstConstantRegisterIndex) << 3.
lshifti 3, index
addp index, tag
loadp PayloadOffset[tag], payload
loadp TagOffset[tag], tag
.done:
end
macro loadConstantOrVariablePayloadTagCustom(index, tagCheck, payload)
bigteq index, FirstConstantRegisterIndex, .constant
tagCheck(TagOffset[cfr, index, 8])
loadi PayloadOffset[cfr, index, 8], payload
jmp .done
.constant:
loadp CodeBlock[cfr], payload
loadp CodeBlock::m_constantRegisters + VectorBufferOffset[payload], payload
# There is a bit of evil here: if the index contains a value >= FirstConstantRegisterIndex,
# then value << 3 will be equal to (value - FirstConstantRegisterIndex) << 3.
tagCheck(TagOffset[payload, index, 8])
loadp PayloadOffset[payload, index, 8], payload
.done:
end
# Index and payload must be different registers. Index is not mutated. Use
# this if you know what the tag of the variable should be. Doing the tag
# test as part of loading the variable reduces register use, but may not
# be faster than doing loadConstantOrVariable followed by a branch on the
# tag.
macro loadConstantOrVariablePayload(index, expectedTag, payload, slow)
loadConstantOrVariablePayloadTagCustom(
index,
macro (actualTag) bineq actualTag, expectedTag, slow end,
payload)
end
macro loadConstantOrVariablePayloadUnchecked(index, payload)
loadConstantOrVariablePayloadTagCustom(
index,
macro (actualTag) end,
payload)
end
macro storeStructureWithTypeInfo(cell, structure, scratch)
storep structure, JSCell::m_structureID[cell]
loadi Structure::m_blob + StructureIDBlob::u.words.word2[structure], scratch
storei scratch, JSCell::m_indexingType[cell]
end
macro writeBarrierOnOperand(cellOperand)
if GGC
loadisFromInstruction(cellOperand, t1)
loadConstantOrVariablePayload(t1, CellTag, t2, .writeBarrierDone)
checkMarkByte(t2, t1, t3,
macro(gcData)
btbnz gcData, .writeBarrierDone
push cfr, PC
# We make two extra slots because cCall2 will poke.
subp 8, sp
cCall2Void(_llint_write_barrier_slow, cfr, t2)
addp 8, sp
pop PC, cfr
end
)
.writeBarrierDone:
end
end
macro writeBarrierOnOperands(cellOperand, valueOperand)
if GGC
loadisFromInstruction(valueOperand, t1)
loadConstantOrVariableTag(t1, t0)
bineq t0, CellTag, .writeBarrierDone
writeBarrierOnOperand(cellOperand)
.writeBarrierDone:
end
end
macro writeBarrierOnGlobalObject(valueOperand)
if GGC
loadisFromInstruction(valueOperand, t1)
loadConstantOrVariableTag(t1, t0)
bineq t0, CellTag, .writeBarrierDone
loadp CodeBlock[cfr], t3
loadp CodeBlock::m_globalObject[t3], t3
checkMarkByte(t3, t1, t2,
macro(gcData)
btbnz gcData, .writeBarrierDone
push cfr, PC
# We make two extra slots because cCall2 will poke.
subp 8, sp
cCall2Void(_llint_write_barrier_slow, cfr, t3)
addp 8, sp
pop PC, cfr
end
)
.writeBarrierDone:
end
end
macro valueProfile(tag, payload, operand, scratch)
loadp operand[PC], scratch
storei tag, ValueProfile::m_buckets + TagOffset[scratch]
storei payload, ValueProfile::m_buckets + PayloadOffset[scratch]
end
# Entrypoints into the interpreter
# Expects that CodeBlock is in t1, which is what prologue() leaves behind.
macro functionArityCheck(doneLabel, slowPath)
loadi PayloadOffset + ArgumentCount[cfr], t0
biaeq t0, CodeBlock::m_numParameters[t1], doneLabel
cCall2(slowPath, cfr, PC) # This slowPath has a simple protocol: t0 = 0 => no error, t0 != 0 => error
btiz t0, .noError
move t1, cfr # t1 contains caller frame
jmp _llint_throw_from_slow_path_trampoline
.noError:
# t1 points to ArityCheckData.
loadp CommonSlowPaths::ArityCheckData::thunkToCall[t1], t2
btpz t2, .proceedInline
loadp CommonSlowPaths::ArityCheckData::returnPC[t1], t5
loadp CommonSlowPaths::ArityCheckData::paddedStackSpace[t1], t0
call t2
if ASSERT_ENABLED
loadp ReturnPC[cfr], t0
loadp [t0], t0
end
jmp .continue
.proceedInline:
loadi CommonSlowPaths::ArityCheckData::paddedStackSpace[t1], t1
btiz t1, .continue
// Move frame up "t1 * 2" slots
lshiftp 1, t1
negi t1
move cfr, t3
loadi PayloadOffset + ArgumentCount[cfr], t2
addi CallFrameHeaderSlots, t2
.copyLoop:
loadi PayloadOffset[t3], t0
storei t0, PayloadOffset[t3, t1, 8]
loadi TagOffset[t3], t0
storei t0, TagOffset[t3, t1, 8]
addp 8, t3
bsubinz 1, t2, .copyLoop
// Fill new slots with JSUndefined
move t1, t2
.fillLoop:
move 0, t0
storei t0, PayloadOffset[t3, t1, 8]
move UndefinedTag, t0
storei t0, TagOffset[t3, t1, 8]
addp 8, t3
baddinz 1, t2, .fillLoop
lshiftp 3, t1
addp t1, cfr
addp t1, sp
.continue:
# Reload CodeBlock and PC, since the slow_path clobbered it.
loadp CodeBlock[cfr], t1
loadp CodeBlock::m_instructions[t1], PC
jmp doneLabel
end
macro branchIfException(label)
loadp Callee + PayloadOffset[cfr], t3
andp MarkedBlockMask, t3
loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
bieq VM::m_exception + TagOffset[t3], EmptyValueTag, .noException
jmp label
.noException:
end
# Instruction implementations
_llint_op_enter:
traceExecution()
checkStackPointerAlignment(t2, 0xdead00e1)
loadp CodeBlock[cfr], t2 // t2<CodeBlock> = cfr.CodeBlock
loadi CodeBlock::m_numVars[t2], t2 // t2<size_t> = t2<CodeBlock>.m_numVars
btiz t2, .opEnterDone
move UndefinedTag, t0
move 0, t1
negi t2
.opEnterLoop:
storei t0, TagOffset[cfr, t2, 8]
storei t1, PayloadOffset[cfr, t2, 8]
addi 1, t2
btinz t2, .opEnterLoop
.opEnterDone:
callSlowPath(_slow_path_enter)
dispatch(1)
_llint_op_create_lexical_environment:
traceExecution()
loadi 4[PC], t0
callSlowPath(_llint_slow_path_create_lexical_environment)
dispatch(2)
_llint_op_init_lazy_reg:
traceExecution()
loadi 4[PC], t0
storei EmptyValueTag, TagOffset[cfr, t0, 8]
storei 0, PayloadOffset[cfr, t0, 8]
dispatch(2)
_llint_op_create_arguments:
traceExecution()
loadi 4[PC], t0
bineq TagOffset[cfr, t0, 8], EmptyValueTag, .opCreateArgumentsDone
callSlowPath(_slow_path_create_arguments)
.opCreateArgumentsDone:
dispatch(2)
_llint_op_create_this:
traceExecution()
loadi 8[PC], t0
loadp PayloadOffset[cfr, t0, 8], t0
loadp JSFunction::m_allocationProfile + ObjectAllocationProfile::m_allocator[t0], t1
loadp JSFunction::m_allocationProfile + ObjectAllocationProfile::m_structure[t0], t2
btpz t1, .opCreateThisSlow
allocateJSObject(t1, t2, t0, t3, .opCreateThisSlow)
loadi 4[PC], t1
storei CellTag, TagOffset[cfr, t1, 8]
storei t0, PayloadOffset[cfr, t1, 8]
dispatch(4)
.opCreateThisSlow:
callSlowPath(_slow_path_create_this)
dispatch(4)
_llint_op_get_callee:
traceExecution()
loadi 4[PC], t0
loadp PayloadOffset + Callee[cfr], t1
loadpFromInstruction(2, t2)
bpneq t1, t2, .opGetCalleeSlow
storei CellTag, TagOffset[cfr, t0, 8]
storei t1, PayloadOffset[cfr, t0, 8]
dispatch(3)
.opGetCalleeSlow:
callSlowPath(_slow_path_get_callee)
dispatch(3)
_llint_op_to_this:
traceExecution()
loadi 4[PC], t0
bineq TagOffset[cfr, t0, 8], CellTag, .opToThisSlow
loadi PayloadOffset[cfr, t0, 8], t0
bbneq JSCell::m_type[t0], FinalObjectType, .opToThisSlow
loadpFromInstruction(2, t2)
bpneq JSCell::m_structureID[t0], t2, .opToThisSlow
dispatch(4)
.opToThisSlow:
callSlowPath(_slow_path_to_this)
dispatch(4)
_llint_op_new_object:
traceExecution()
loadpFromInstruction(3, t0)
loadp ObjectAllocationProfile::m_allocator[t0], t1
loadp ObjectAllocationProfile::m_structure[t0], t2
allocateJSObject(t1, t2, t0, t3, .opNewObjectSlow)
loadi 4[PC], t1
storei CellTag, TagOffset[cfr, t1, 8]
storei t0, PayloadOffset[cfr, t1, 8]
dispatch(4)
.opNewObjectSlow:
callSlowPath(_llint_slow_path_new_object)
dispatch(4)
_llint_op_mov:
traceExecution()
loadi 8[PC], t1
loadi 4[PC], t0
loadConstantOrVariable(t1, t2, t3)
storei t2, TagOffset[cfr, t0, 8]
storei t3, PayloadOffset[cfr, t0, 8]
dispatch(3)
macro notifyWrite(set, valueTag, valuePayload, scratch, slow)
loadb VariableWatchpointSet::m_state[set], scratch
bieq scratch, IsInvalidated, .done
bineq valuePayload, VariableWatchpointSet::m_inferredValue + PayloadOffset[set], slow
bineq valueTag, VariableWatchpointSet::m_inferredValue + TagOffset[set], slow
.done:
end
_llint_op_captured_mov:
traceExecution()
loadi 8[PC], t1
loadConstantOrVariable(t1, t2, t3)
loadpFromInstruction(3, t0)
btpz t0, .opCapturedMovReady
notifyWrite(t0, t2, t3, t1, .opCapturedMovSlow)
.opCapturedMovReady:
loadi 4[PC], t0
storei t2, TagOffset[cfr, t0, 8]
storei t3, PayloadOffset[cfr, t0, 8]
dispatch(4)
.opCapturedMovSlow:
callSlowPath(_slow_path_captured_mov)
dispatch(4)
_llint_op_not:
traceExecution()
loadi 8[PC], t0
loadi 4[PC], t1
loadConstantOrVariable(t0, t2, t3)
bineq t2, BooleanTag, .opNotSlow
xori 1, t3
storei t2, TagOffset[cfr, t1, 8]
storei t3, PayloadOffset[cfr, t1, 8]
dispatch(3)
.opNotSlow:
callSlowPath(_slow_path_not)
dispatch(3)
_llint_op_eq:
traceExecution()
loadi 12[PC], t2
loadi 8[PC], t0
loadConstantOrVariable(t2, t3, t1)
loadConstantOrVariable2Reg(t0, t2, t0)
bineq t2, t3, .opEqSlow
bieq t2, CellTag, .opEqSlow
bib t2, LowestTag, .opEqSlow
loadi 4[PC], t2
cieq t0, t1, t0
storei BooleanTag, TagOffset[cfr, t2, 8]
storei t0, PayloadOffset[cfr, t2, 8]
dispatch(4)
.opEqSlow:
callSlowPath(_slow_path_eq)
dispatch(4)
_llint_op_eq_null:
traceExecution()
loadi 8[PC], t0
loadi 4[PC], t3
assertNotConstant(t0)
loadi TagOffset[cfr, t0, 8], t1
loadi PayloadOffset[cfr, t0, 8], t0
bineq t1, CellTag, .opEqNullImmediate
btbnz JSCell::m_flags[t0], MasqueradesAsUndefined, .opEqNullMasqueradesAsUndefined
move 0, t1
jmp .opEqNullNotImmediate
.opEqNullMasqueradesAsUndefined:
loadp JSCell::m_structureID[t0], t1
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
cpeq Structure::m_globalObject[t1], t0, t1
jmp .opEqNullNotImmediate
.opEqNullImmediate:
cieq t1, NullTag, t2
cieq t1, UndefinedTag, t1
ori t2, t1
.opEqNullNotImmediate:
storei BooleanTag, TagOffset[cfr, t3, 8]
storei t1, PayloadOffset[cfr, t3, 8]
dispatch(3)
_llint_op_neq:
traceExecution()
loadi 12[PC], t2
loadi 8[PC], t0
loadConstantOrVariable(t2, t3, t1)
loadConstantOrVariable2Reg(t0, t2, t0)
bineq t2, t3, .opNeqSlow
bieq t2, CellTag, .opNeqSlow
bib t2, LowestTag, .opNeqSlow
loadi 4[PC], t2
cineq t0, t1, t0
storei BooleanTag, TagOffset[cfr, t2, 8]
storei t0, PayloadOffset[cfr, t2, 8]
dispatch(4)
.opNeqSlow:
callSlowPath(_slow_path_neq)
dispatch(4)
_llint_op_neq_null:
traceExecution()
loadi 8[PC], t0
loadi 4[PC], t3
assertNotConstant(t0)
loadi TagOffset[cfr, t0, 8], t1
loadi PayloadOffset[cfr, t0, 8], t0
bineq t1, CellTag, .opNeqNullImmediate
btbnz JSCell::m_flags[t0], MasqueradesAsUndefined, .opNeqNullMasqueradesAsUndefined
move 1, t1
jmp .opNeqNullNotImmediate
.opNeqNullMasqueradesAsUndefined:
loadp JSCell::m_structureID[t0], t1
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
cpneq Structure::m_globalObject[t1], t0, t1
jmp .opNeqNullNotImmediate
.opNeqNullImmediate:
cineq t1, NullTag, t2
cineq t1, UndefinedTag, t1
andi t2, t1
.opNeqNullNotImmediate:
storei BooleanTag, TagOffset[cfr, t3, 8]
storei t1, PayloadOffset[cfr, t3, 8]
dispatch(3)
macro strictEq(equalityOperation, slowPath)
loadi 12[PC], t2
loadi 8[PC], t0
loadConstantOrVariable(t2, t3, t1)
loadConstantOrVariable2Reg(t0, t2, t0)
bineq t2, t3, .slow
bib t2, LowestTag, .slow
bineq t2, CellTag, .notString
bbneq JSCell::m_type[t0], StringType, .notString
bbeq JSCell::m_type[t1], StringType, .slow
.notString:
loadi 4[PC], t2
equalityOperation(t0, t1, t0)
storei BooleanTag, TagOffset[cfr, t2, 8]
storei t0, PayloadOffset[cfr, t2, 8]
dispatch(4)
.slow:
callSlowPath(slowPath)
dispatch(4)
end
_llint_op_stricteq:
traceExecution()
strictEq(macro (left, right, result) cieq left, right, result end, _slow_path_stricteq)
_llint_op_nstricteq:
traceExecution()
strictEq(macro (left, right, result) cineq left, right, result end, _slow_path_nstricteq)
_llint_op_inc:
traceExecution()
loadi 4[PC], t0
bineq TagOffset[cfr, t0, 8], Int32Tag, .opIncSlow
loadi PayloadOffset[cfr, t0, 8], t1
baddio 1, t1, .opIncSlow
storei t1, PayloadOffset[cfr, t0, 8]
dispatch(2)
.opIncSlow:
callSlowPath(_slow_path_inc)
dispatch(2)
_llint_op_dec:
traceExecution()
loadi 4[PC], t0
bineq TagOffset[cfr, t0, 8], Int32Tag, .opDecSlow
loadi PayloadOffset[cfr, t0, 8], t1
bsubio 1, t1, .opDecSlow
storei t1, PayloadOffset[cfr, t0, 8]
dispatch(2)
.opDecSlow:
callSlowPath(_slow_path_dec)
dispatch(2)
_llint_op_to_number:
traceExecution()
loadi 8[PC], t0
loadi 4[PC], t1
loadConstantOrVariable(t0, t2, t3)
bieq t2, Int32Tag, .opToNumberIsInt
biaeq t2, LowestTag, .opToNumberSlow
.opToNumberIsInt:
storei t2, TagOffset[cfr, t1, 8]
storei t3, PayloadOffset[cfr, t1, 8]
dispatch(3)
.opToNumberSlow:
callSlowPath(_slow_path_to_number)
dispatch(3)
_llint_op_negate:
traceExecution()
loadi 8[PC], t0
loadi 4[PC], t3
loadConstantOrVariable(t0, t1, t2)
bineq t1, Int32Tag, .opNegateSrcNotInt
btiz t2, 0x7fffffff, .opNegateSlow
negi t2
storei Int32Tag, TagOffset[cfr, t3, 8]
storei t2, PayloadOffset[cfr, t3, 8]
dispatch(3)
.opNegateSrcNotInt:
bia t1, LowestTag, .opNegateSlow
xori 0x80000000, t1
storei t1, TagOffset[cfr, t3, 8]
storei t2, PayloadOffset[cfr, t3, 8]
dispatch(3)
.opNegateSlow:
callSlowPath(_slow_path_negate)
dispatch(3)
macro binaryOpCustomStore(integerOperationAndStore, doubleOperation, slowPath)
loadi 12[PC], t2
loadi 8[PC], t0
loadConstantOrVariable(t2, t3, t1)
loadConstantOrVariable2Reg(t0, t2, t0)
bineq t2, Int32Tag, .op1NotInt
bineq t3, Int32Tag, .op2NotInt
loadi 4[PC], t2
integerOperationAndStore(t3, t1, t0, .slow, t2)
dispatch(5)
.op1NotInt:
# First operand is definitely not an int, the second operand could be anything.
bia t2, LowestTag, .slow
bib t3, LowestTag, .op1NotIntOp2Double
bineq t3, Int32Tag, .slow
ci2d t1, ft1
jmp .op1NotIntReady
.op1NotIntOp2Double:
fii2d t1, t3, ft1
.op1NotIntReady:
loadi 4[PC], t1
fii2d t0, t2, ft0
doubleOperation(ft1, ft0)
stored ft0, [cfr, t1, 8]
dispatch(5)
.op2NotInt:
# First operand is definitely an int, the second operand is definitely not.
loadi 4[PC], t2
bia t3, LowestTag, .slow
ci2d t0, ft0
fii2d t1, t3, ft1
doubleOperation(ft1, ft0)
stored ft0, [cfr, t2, 8]
dispatch(5)
.slow:
callSlowPath(slowPath)
dispatch(5)
end
macro binaryOp(integerOperation, doubleOperation, slowPath)
binaryOpCustomStore(
macro (int32Tag, left, right, slow, index)
integerOperation(left, right, slow)
storei int32Tag, TagOffset[cfr, index, 8]
storei right, PayloadOffset[cfr, index, 8]
end,
doubleOperation, slowPath)
end
_llint_op_add:
traceExecution()
binaryOp(
macro (left, right, slow) baddio left, right, slow end,
macro (left, right) addd left, right end,
_slow_path_add)
_llint_op_mul:
traceExecution()
binaryOpCustomStore(
macro (int32Tag, left, right, slow, index)
const scratch = int32Tag # We know that we can reuse the int32Tag register since it has a constant.
move right, scratch
bmulio left, scratch, slow
btinz scratch, .done
bilt left, 0, slow
bilt right, 0, slow
.done:
storei Int32Tag, TagOffset[cfr, index, 8]
storei scratch, PayloadOffset[cfr, index, 8]
end,
macro (left, right) muld left, right end,
_slow_path_mul)
_llint_op_sub:
traceExecution()
binaryOp(
macro (left, right, slow) bsubio left, right, slow end,
macro (left, right) subd left, right end,
_slow_path_sub)
_llint_op_div:
traceExecution()
binaryOpCustomStore(
macro (int32Tag, left, right, slow, index)
ci2d left, ft0
ci2d right, ft1
divd ft0, ft1
bcd2i ft1, right, .notInt
storei int32Tag, TagOffset[cfr, index, 8]
storei right, PayloadOffset[cfr, index, 8]
jmp .done
.notInt:
stored ft1, [cfr, index, 8]
.done:
end,
macro (left, right) divd left, right end,
_slow_path_div)
macro bitOp(operation, slowPath, advance)
loadi 12[PC], t2
loadi 8[PC], t0
loadConstantOrVariable(t2, t3, t1)
loadConstantOrVariable2Reg(t0, t2, t0)
bineq t3, Int32Tag, .slow
bineq t2, Int32Tag, .slow
loadi 4[PC], t2
operation(t1, t0)
storei t3, TagOffset[cfr, t2, 8]
storei t0, PayloadOffset[cfr, t2, 8]
dispatch(advance)
.slow:
callSlowPath(slowPath)
dispatch(advance)
end
_llint_op_lshift:
traceExecution()
bitOp(
macro (left, right) lshifti left, right end,
_slow_path_lshift,
4)
_llint_op_rshift:
traceExecution()
bitOp(
macro (left, right) rshifti left, right end,
_slow_path_rshift,
4)
_llint_op_urshift:
traceExecution()
bitOp(
macro (left, right) urshifti left, right end,
_slow_path_urshift,
4)
_llint_op_unsigned:
traceExecution()
loadi 4[PC], t0
loadi 8[PC], t1
loadConstantOrVariablePayload(t1, Int32Tag, t2, .opUnsignedSlow)
bilt t2, 0, .opUnsignedSlow
storei t2, PayloadOffset[cfr, t0, 8]
storei Int32Tag, TagOffset[cfr, t0, 8]
dispatch(3)
.opUnsignedSlow:
callSlowPath(_slow_path_unsigned)
dispatch(3)
_llint_op_bitand:
traceExecution()
bitOp(
macro (left, right) andi left, right end,
_slow_path_bitand,
5)
_llint_op_bitxor:
traceExecution()
bitOp(
macro (left, right) xori left, right end,
_slow_path_bitxor,
5)
_llint_op_bitor:
traceExecution()
bitOp(
macro (left, right) ori left, right end,
_slow_path_bitor,
5)
_llint_op_check_has_instance:
traceExecution()
loadi 12[PC], t1
loadConstantOrVariablePayload(t1, CellTag, t0, .opCheckHasInstanceSlow)
btbz JSCell::m_flags[t0], ImplementsDefaultHasInstance, .opCheckHasInstanceSlow
dispatch(5)
.opCheckHasInstanceSlow:
callSlowPath(_llint_slow_path_check_has_instance)
dispatch(0)
_llint_op_instanceof:
traceExecution()
# Actually do the work.
loadi 12[PC], t0
loadi 4[PC], t3
loadConstantOrVariablePayload(t0, CellTag, t1, .opInstanceofSlow)
bbb JSCell::m_type[t1], ObjectType, .opInstanceofSlow
loadi 8[PC], t0
loadConstantOrVariablePayload(t0, CellTag, t2, .opInstanceofSlow)
# Register state: t1 = prototype, t2 = value
move 1, t0
.opInstanceofLoop:
loadp JSCell::m_structureID[t2], t2
loadi Structure::m_prototype + PayloadOffset[t2], t2
bpeq t2, t1, .opInstanceofDone
btinz t2, .opInstanceofLoop
move 0, t0
.opInstanceofDone:
storei BooleanTag, TagOffset[cfr, t3, 8]
storei t0, PayloadOffset[cfr, t3, 8]
dispatch(4)
.opInstanceofSlow:
callSlowPath(_llint_slow_path_instanceof)
dispatch(4)
_llint_op_is_undefined:
traceExecution()
loadi 8[PC], t1
loadi 4[PC], t0
loadConstantOrVariable(t1, t2, t3)
storei BooleanTag, TagOffset[cfr, t0, 8]
bieq t2, CellTag, .opIsUndefinedCell
cieq t2, UndefinedTag, t3
storei t3, PayloadOffset[cfr, t0, 8]
dispatch(3)
.opIsUndefinedCell:
btbnz JSCell::m_flags[t3], MasqueradesAsUndefined, .opIsUndefinedMasqueradesAsUndefined
move 0, t1
storei t1, PayloadOffset[cfr, t0, 8]
dispatch(3)
.opIsUndefinedMasqueradesAsUndefined:
loadp JSCell::m_structureID[t3], t1
loadp CodeBlock[cfr], t3
loadp CodeBlock::m_globalObject[t3], t3
cpeq Structure::m_globalObject[t1], t3, t1
storei t1, PayloadOffset[cfr, t0, 8]
dispatch(3)
_llint_op_is_boolean:
traceExecution()
loadi 8[PC], t1
loadi 4[PC], t2
loadConstantOrVariableTag(t1, t0)
cieq t0, BooleanTag, t0
storei BooleanTag, TagOffset[cfr, t2, 8]
storei t0, PayloadOffset[cfr, t2, 8]
dispatch(3)
_llint_op_is_number:
traceExecution()
loadi 8[PC], t1
loadi 4[PC], t2
loadConstantOrVariableTag(t1, t0)
storei BooleanTag, TagOffset[cfr, t2, 8]
addi 1, t0
cib t0, LowestTag + 1, t1
storei t1, PayloadOffset[cfr, t2, 8]
dispatch(3)
_llint_op_is_string:
traceExecution()
loadi 8[PC], t1
loadi 4[PC], t2
loadConstantOrVariable(t1, t0, t3)
storei BooleanTag, TagOffset[cfr, t2, 8]
bineq t0, CellTag, .opIsStringNotCell
cbeq JSCell::m_type[t3], StringType, t1
storei t1, PayloadOffset[cfr, t2, 8]
dispatch(3)
.opIsStringNotCell:
storep 0, PayloadOffset[cfr, t2, 8]
dispatch(3)
macro loadPropertyAtVariableOffsetKnownNotInline(propertyOffset, objectAndStorage, tag, payload)
assert(macro (ok) bigteq propertyOffset, firstOutOfLineOffset, ok end)
negi propertyOffset
loadp JSObject::m_butterfly[objectAndStorage], objectAndStorage
loadi TagOffset + (firstOutOfLineOffset - 2) * 8[objectAndStorage, propertyOffset, 8], tag
loadi PayloadOffset + (firstOutOfLineOffset - 2) * 8[objectAndStorage, propertyOffset, 8], payload
end
macro loadPropertyAtVariableOffset(propertyOffset, objectAndStorage, tag, payload)
bilt propertyOffset, firstOutOfLineOffset, .isInline
loadp JSObject::m_butterfly[objectAndStorage], objectAndStorage
negi propertyOffset
jmp .ready
.isInline:
addp sizeof JSObject - (firstOutOfLineOffset - 2) * 8, objectAndStorage
.ready:
loadi TagOffset + (firstOutOfLineOffset - 2) * 8[objectAndStorage, propertyOffset, 8], tag
loadi PayloadOffset + (firstOutOfLineOffset - 2) * 8[objectAndStorage, propertyOffset, 8], payload
end
macro storePropertyAtVariableOffset(propertyOffsetAsInt, objectAndStorage, tag, payload)
bilt propertyOffsetAsInt, firstOutOfLineOffset, .isInline
loadp JSObject::m_butterfly[objectAndStorage], objectAndStorage
negi propertyOffsetAsInt
jmp .ready
.isInline:
addp sizeof JSObject - (firstOutOfLineOffset - 2) * 8, objectAndStorage
.ready:
storei tag, TagOffset + (firstOutOfLineOffset - 2) * 8[objectAndStorage, propertyOffsetAsInt, 8]
storei payload, PayloadOffset + (firstOutOfLineOffset - 2) * 8[objectAndStorage, propertyOffsetAsInt, 8]
end
_llint_op_init_global_const:
traceExecution()
writeBarrierOnGlobalObject(2)
loadi 8[PC], t1
loadi 4[PC], t0
loadConstantOrVariable(t1, t2, t3)
storei t2, TagOffset[t0]
storei t3, PayloadOffset[t0]
dispatch(5)
# We only do monomorphic get_by_id caching for now, and we do not modify the
# opcode. We do, however, allow for the cache to change anytime if fails, since
# ping-ponging is free. At best we get lucky and the get_by_id will continue
# to take fast path on the new cache. At worst we take slow path, which is what
# we would have been doing anyway.
macro getById(getPropertyStorage)
traceExecution()
loadi 8[PC], t0
loadi 16[PC], t1
loadConstantOrVariablePayload(t0, CellTag, t3, .opGetByIdSlow)
loadi 20[PC], t2
getPropertyStorage(
t3,
t0,
macro (propertyStorage, scratch)
bpneq JSCell::m_structureID[t3], t1, .opGetByIdSlow
loadi 4[PC], t1
loadi TagOffset[propertyStorage, t2], scratch
loadi PayloadOffset[propertyStorage, t2], t2
storei scratch, TagOffset[cfr, t1, 8]
storei t2, PayloadOffset[cfr, t1, 8]
valueProfile(scratch, t2, 32, t1)
dispatch(9)
end)
.opGetByIdSlow:
callSlowPath(_llint_slow_path_get_by_id)
dispatch(9)
end
_llint_op_get_by_id:
getById(withInlineStorage)
_llint_op_get_by_id_out_of_line:
getById(withOutOfLineStorage)
_llint_op_get_array_length:
traceExecution()
loadi 8[PC], t0
loadp 16[PC], t1
loadConstantOrVariablePayload(t0, CellTag, t3, .opGetArrayLengthSlow)
move t3, t2
arrayProfile(t2, t1, t0)
btiz t2, IsArray, .opGetArrayLengthSlow
btiz t2, IndexingShapeMask, .opGetArrayLengthSlow
loadi 4[PC], t1
loadp JSObject::m_butterfly[t3], t0
loadi -sizeof IndexingHeader + IndexingHeader::u.lengths.publicLength[t0], t0
bilt t0, 0, .opGetArrayLengthSlow
valueProfile(Int32Tag, t0, 32, t2)
storep t0, PayloadOffset[cfr, t1, 8]
storep Int32Tag, TagOffset[cfr, t1, 8]
dispatch(9)
.opGetArrayLengthSlow:
callSlowPath(_llint_slow_path_get_by_id)
dispatch(9)
_llint_op_get_arguments_length:
traceExecution()
loadi 8[PC], t0
loadi 4[PC], t1
bineq TagOffset[cfr, t0, 8], EmptyValueTag, .opGetArgumentsLengthSlow
loadi ArgumentCount + PayloadOffset[cfr], t2
subi 1, t2
storei Int32Tag, TagOffset[cfr, t1, 8]
storei t2, PayloadOffset[cfr, t1, 8]
dispatch(4)
.opGetArgumentsLengthSlow:
callSlowPath(_llint_slow_path_get_arguments_length)
dispatch(4)
macro putById(getPropertyStorage)
traceExecution()
writeBarrierOnOperands(1, 3)
loadi 4[PC], t3
loadi 16[PC], t1
loadConstantOrVariablePayload(t3, CellTag, t0, .opPutByIdSlow)
loadi 12[PC], t2
getPropertyStorage(
t0,
t3,
macro (propertyStorage, scratch)
bpneq JSCell::m_structureID[t0], t1, .opPutByIdSlow
loadi 20[PC], t1
loadConstantOrVariable2Reg(t2, scratch, t2)
storei scratch, TagOffset[propertyStorage, t1]
storei t2, PayloadOffset[propertyStorage, t1]
dispatch(9)
end)
.opPutByIdSlow:
callSlowPath(_llint_slow_path_put_by_id)
dispatch(9)
end
_llint_op_put_by_id:
putById(withInlineStorage)
_llint_op_put_by_id_out_of_line:
putById(withOutOfLineStorage)
macro putByIdTransition(additionalChecks, getPropertyStorage)
traceExecution()
writeBarrierOnOperand(1)
loadi 4[PC], t3
loadi 16[PC], t1
loadConstantOrVariablePayload(t3, CellTag, t0, .opPutByIdSlow)
loadi 12[PC], t2
bpneq JSCell::m_structureID[t0], t1, .opPutByIdSlow
additionalChecks(t1, t3, .opPutByIdSlow)
loadi 20[PC], t1
getPropertyStorage(
t0,
t3,
macro (propertyStorage, scratch)
addp t1, propertyStorage, t3
loadConstantOrVariable2Reg(t2, t1, t2)
storei t1, TagOffset[t3]
loadi 24[PC], t1
storei t2, PayloadOffset[t3]
storep t1, JSCell::m_structureID[t0]
dispatch(9)
end)
.opPutByIdSlow:
callSlowPath(_llint_slow_path_put_by_id)
dispatch(9)
end
macro noAdditionalChecks(oldStructure, scratch, slowPath)
end
macro structureChainChecks(oldStructure, scratch, slowPath)
const protoCell = oldStructure # Reusing the oldStructure register for the proto
loadp 28[PC], scratch
assert(macro (ok) btpnz scratch, ok end)
loadp StructureChain::m_vector[scratch], scratch
assert(macro (ok) btpnz scratch, ok end)
bieq Structure::m_prototype + TagOffset[oldStructure], NullTag, .done
.loop:
loadi Structure::m_prototype + PayloadOffset[oldStructure], protoCell
loadp JSCell::m_structureID[protoCell], oldStructure
bpneq oldStructure, [scratch], slowPath
addp 4, scratch
bineq Structure::m_prototype + TagOffset[oldStructure], NullTag, .loop
.done:
end
_llint_op_put_by_id_transition_direct:
putByIdTransition(noAdditionalChecks, withInlineStorage)
_llint_op_put_by_id_transition_direct_out_of_line:
putByIdTransition(noAdditionalChecks, withOutOfLineStorage)
_llint_op_put_by_id_transition_normal:
putByIdTransition(structureChainChecks, withInlineStorage)
_llint_op_put_by_id_transition_normal_out_of_line:
putByIdTransition(structureChainChecks, withOutOfLineStorage)
_llint_op_get_by_val:
traceExecution()
loadi 8[PC], t2
loadConstantOrVariablePayload(t2, CellTag, t0, .opGetByValSlow)
move t0, t2
loadp 16[PC], t3
arrayProfile(t2, t3, t1)
loadi 12[PC], t3
loadConstantOrVariablePayload(t3, Int32Tag, t1, .opGetByValSlow)
loadp JSObject::m_butterfly[t0], t3
andi IndexingShapeMask, t2
bieq t2, Int32Shape, .opGetByValIsContiguous
bineq t2, ContiguousShape, .opGetByValNotContiguous
.opGetByValIsContiguous:
biaeq t1, -sizeof IndexingHeader + IndexingHeader::u.lengths.publicLength[t3], .opGetByValOutOfBounds
loadi TagOffset[t3, t1, 8], t2
loadi PayloadOffset[t3, t1, 8], t1
jmp .opGetByValDone
.opGetByValNotContiguous:
bineq t2, DoubleShape, .opGetByValNotDouble
biaeq t1, -sizeof IndexingHeader + IndexingHeader::u.lengths.publicLength[t3], .opGetByValOutOfBounds
loadd [t3, t1, 8], ft0
bdnequn ft0, ft0, .opGetByValSlow
# FIXME: This could be massively optimized.
fd2ii ft0, t1, t2
loadi 4[PC], t0
jmp .opGetByValNotEmpty
.opGetByValNotDouble:
subi ArrayStorageShape, t2
bia t2, SlowPutArrayStorageShape - ArrayStorageShape, .opGetByValSlow
biaeq t1, -sizeof IndexingHeader + IndexingHeader::u.lengths.vectorLength[t3], .opGetByValOutOfBounds
loadi ArrayStorage::m_vector + TagOffset[t3, t1, 8], t2
loadi ArrayStorage::m_vector + PayloadOffset[t3, t1, 8], t1
.opGetByValDone:
loadi 4[PC], t0
bieq t2, EmptyValueTag, .opGetByValOutOfBounds
.opGetByValNotEmpty:
storei t2, TagOffset[cfr, t0, 8]
storei t1, PayloadOffset[cfr, t0, 8]
valueProfile(t2, t1, 20, t0)
dispatch(6)
.opGetByValOutOfBounds:
loadpFromInstruction(4, t0)
storeb 1, ArrayProfile::m_outOfBounds[t0]
.opGetByValSlow:
callSlowPath(_llint_slow_path_get_by_val)
dispatch(6)
_llint_op_get_argument_by_val:
# FIXME: At some point we should array profile this. Right now it isn't necessary
# since the DFG will never turn a get_argument_by_val into a GetByVal.
traceExecution()
loadi 8[PC], t0
loadi 12[PC], t1
bineq TagOffset[cfr, t0, 8], EmptyValueTag, .opGetArgumentByValSlow
loadConstantOrVariablePayload(t1, Int32Tag, t2, .opGetArgumentByValSlow)
addi 1, t2
loadi ArgumentCount + PayloadOffset[cfr], t1
biaeq t2, t1, .opGetArgumentByValSlow
loadi 4[PC], t3
loadi ThisArgumentOffset + TagOffset[cfr, t2, 8], t0
loadi ThisArgumentOffset + PayloadOffset[cfr, t2, 8], t1
storei t0, TagOffset[cfr, t3, 8]
storei t1, PayloadOffset[cfr, t3, 8]
valueProfile(t0, t1, 20, t2)
dispatch(6)
.opGetArgumentByValSlow:
callSlowPath(_llint_slow_path_get_argument_by_val)
dispatch(6)
macro contiguousPutByVal(storeCallback)
biaeq t3, -sizeof IndexingHeader + IndexingHeader::u.lengths.publicLength[t0], .outOfBounds
.storeResult:
loadi 12[PC], t2
storeCallback(t2, t1, t0, t3)
dispatch(5)
.outOfBounds:
biaeq t3, -sizeof IndexingHeader + IndexingHeader::u.lengths.vectorLength[t0], .opPutByValOutOfBounds
loadp 16[PC], t2
storeb 1, ArrayProfile::m_mayStoreToHole[t2]
addi 1, t3, t2
storei t2, -sizeof IndexingHeader + IndexingHeader::u.lengths.publicLength[t0]
jmp .storeResult
end
macro putByVal(slowPath)
traceExecution()
writeBarrierOnOperands(1, 3)
loadi 4[PC], t0
loadConstantOrVariablePayload(t0, CellTag, t1, .opPutByValSlow)
move t1, t2
loadp 16[PC], t3
arrayProfile(t2, t3, t0)
loadi 8[PC], t0
loadConstantOrVariablePayload(t0, Int32Tag, t3, .opPutByValSlow)
loadp JSObject::m_butterfly[t1], t0
andi IndexingShapeMask, t2
bineq t2, Int32Shape, .opPutByValNotInt32
contiguousPutByVal(
macro (operand, scratch, base, index)
loadConstantOrVariablePayload(operand, Int32Tag, scratch, .opPutByValSlow)
storei Int32Tag, TagOffset[base, index, 8]
storei scratch, PayloadOffset[base, index, 8]
end)
.opPutByValNotInt32:
bineq t2, DoubleShape, .opPutByValNotDouble
contiguousPutByVal(
macro (operand, scratch, base, index)
const tag = scratch
const payload = operand
loadConstantOrVariable2Reg(operand, tag, payload)
bineq tag, Int32Tag, .notInt
ci2d payload, ft0
jmp .ready
.notInt:
fii2d payload, tag, ft0
bdnequn ft0, ft0, .opPutByValSlow
.ready:
stored ft0, [base, index, 8]
end)
.opPutByValNotDouble:
bineq t2, ContiguousShape, .opPutByValNotContiguous
contiguousPutByVal(
macro (operand, scratch, base, index)
const tag = scratch
const payload = operand
loadConstantOrVariable2Reg(operand, tag, payload)
storei tag, TagOffset[base, index, 8]
storei payload, PayloadOffset[base, index, 8]
end)
.opPutByValNotContiguous:
bineq t2, ArrayStorageShape, .opPutByValSlow
biaeq t3, -sizeof IndexingHeader + IndexingHeader::u.lengths.vectorLength[t0], .opPutByValOutOfBounds
bieq ArrayStorage::m_vector + TagOffset[t0, t3, 8], EmptyValueTag, .opPutByValArrayStorageEmpty
.opPutByValArrayStorageStoreResult:
loadi 12[PC], t2
loadConstantOrVariable2Reg(t2, t1, t2)
storei t1, ArrayStorage::m_vector + TagOffset[t0, t3, 8]
storei t2, ArrayStorage::m_vector + PayloadOffset[t0, t3, 8]
dispatch(5)
.opPutByValArrayStorageEmpty:
loadp 16[PC], t1
storeb 1, ArrayProfile::m_mayStoreToHole[t1]
addi 1, ArrayStorage::m_numValuesInVector[t0]
bib t3, -sizeof IndexingHeader + IndexingHeader::u.lengths.publicLength[t0], .opPutByValArrayStorageStoreResult
addi 1, t3, t1
storei t1, -sizeof IndexingHeader + IndexingHeader::u.lengths.publicLength[t0]
jmp .opPutByValArrayStorageStoreResult
.opPutByValOutOfBounds:
loadpFromInstruction(4, t0)
storeb 1, ArrayProfile::m_outOfBounds[t0]
.opPutByValSlow:
callSlowPath(slowPath)
dispatch(5)
end
_llint_op_put_by_val:
putByVal(_llint_slow_path_put_by_val)
_llint_op_put_by_val_direct:
putByVal(_llint_slow_path_put_by_val_direct)
_llint_op_jmp:
traceExecution()
dispatchBranch(4[PC])
macro jumpTrueOrFalse(conditionOp, slow)
loadi 4[PC], t1
loadConstantOrVariablePayload(t1, BooleanTag, t0, .slow)
conditionOp(t0, .target)
dispatch(3)
.target:
dispatchBranch(8[PC])
.slow:
callSlowPath(slow)
dispatch(0)
end
macro equalNull(cellHandler, immediateHandler)
loadi 4[PC], t0
assertNotConstant(t0)
loadi TagOffset[cfr, t0, 8], t1
loadi PayloadOffset[cfr, t0, 8], t0
bineq t1, CellTag, .immediate
loadp JSCell::m_structureID[t0], t2
cellHandler(t2, JSCell::m_flags[t0], .target)
dispatch(3)
.target:
dispatchBranch(8[PC])
.immediate:
ori 1, t1
immediateHandler(t1, .target)
dispatch(3)
end
_llint_op_jeq_null:
traceExecution()
equalNull(
macro (structure, value, target)
btbz value, MasqueradesAsUndefined, .opJeqNullNotMasqueradesAsUndefined
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
bpeq Structure::m_globalObject[structure], t0, target
.opJeqNullNotMasqueradesAsUndefined:
end,
macro (value, target) bieq value, NullTag, target end)
_llint_op_jneq_null:
traceExecution()
equalNull(
macro (structure, value, target)
btbz value, MasqueradesAsUndefined, target
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
bpneq Structure::m_globalObject[structure], t0, target
end,
macro (value, target) bineq value, NullTag, target end)
_llint_op_jneq_ptr:
traceExecution()
loadi 4[PC], t0
loadi 8[PC], t1
loadp CodeBlock[cfr], t2
loadp CodeBlock::m_globalObject[t2], t2
bineq TagOffset[cfr, t0, 8], CellTag, .opJneqPtrBranch
loadp JSGlobalObject::m_specialPointers[t2, t1, 4], t1
bpeq PayloadOffset[cfr, t0, 8], t1, .opJneqPtrFallThrough
.opJneqPtrBranch:
dispatchBranch(12[PC])
.opJneqPtrFallThrough:
dispatch(4)
macro compare(integerCompare, doubleCompare, slowPath)
loadi 4[PC], t2
loadi 8[PC], t3
loadConstantOrVariable(t2, t0, t1)
loadConstantOrVariable2Reg(t3, t2, t3)
bineq t0, Int32Tag, .op1NotInt
bineq t2, Int32Tag, .op2NotInt
integerCompare(t1, t3, .jumpTarget)
dispatch(4)
.op1NotInt:
bia t0, LowestTag, .slow
bib t2, LowestTag, .op1NotIntOp2Double
bineq t2, Int32Tag, .slow
ci2d t3, ft1
jmp .op1NotIntReady
.op1NotIntOp2Double:
fii2d t3, t2, ft1
.op1NotIntReady:
fii2d t1, t0, ft0
doubleCompare(ft0, ft1, .jumpTarget)
dispatch(4)
.op2NotInt:
ci2d t1, ft0
bia t2, LowestTag, .slow
fii2d t3, t2, ft1
doubleCompare(ft0, ft1, .jumpTarget)
dispatch(4)
.jumpTarget:
dispatchBranch(12[PC])
.slow:
callSlowPath(slowPath)
dispatch(0)
end
_llint_op_switch_imm:
traceExecution()
loadi 12[PC], t2
loadi 4[PC], t3
loadConstantOrVariable(t2, t1, t0)
loadp CodeBlock[cfr], t2
loadp CodeBlock::m_rareData[t2], t2
muli sizeof SimpleJumpTable, t3 # FIXME: would be nice to peephole this!
loadp CodeBlock::RareData::m_switchJumpTables + VectorBufferOffset[t2], t2
addp t3, t2
bineq t1, Int32Tag, .opSwitchImmNotInt
subi SimpleJumpTable::min[t2], t0
biaeq t0, SimpleJumpTable::branchOffsets + VectorSizeOffset[t2], .opSwitchImmFallThrough
loadp SimpleJumpTable::branchOffsets + VectorBufferOffset[t2], t3
loadi [t3, t0, 4], t1
btiz t1, .opSwitchImmFallThrough
dispatchBranchWithOffset(t1)
.opSwitchImmNotInt:
bib t1, LowestTag, .opSwitchImmSlow # Go to slow path if it's a double.
.opSwitchImmFallThrough:
dispatchBranch(8[PC])
.opSwitchImmSlow:
callSlowPath(_llint_slow_path_switch_imm)
dispatch(0)
_llint_op_switch_char:
traceExecution()
loadi 12[PC], t2
loadi 4[PC], t3
loadConstantOrVariable(t2, t1, t0)
loadp CodeBlock[cfr], t2
loadp CodeBlock::m_rareData[t2], t2
muli sizeof SimpleJumpTable, t3
loadp CodeBlock::RareData::m_switchJumpTables + VectorBufferOffset[t2], t2
addp t3, t2
bineq t1, CellTag, .opSwitchCharFallThrough
bbneq JSCell::m_type[t0], StringType, .opSwitchCharFallThrough
bineq JSString::m_length[t0], 1, .opSwitchCharFallThrough
loadp JSString::m_value[t0], t0
btpz t0, .opSwitchOnRope
loadp StringImpl::m_data8[t0], t1
btinz StringImpl::m_hashAndFlags[t0], HashFlags8BitBuffer, .opSwitchChar8Bit
loadh [t1], t0
jmp .opSwitchCharReady
.opSwitchChar8Bit:
loadb [t1], t0
.opSwitchCharReady:
subi SimpleJumpTable::min[t2], t0
biaeq t0, SimpleJumpTable::branchOffsets + VectorSizeOffset[t2], .opSwitchCharFallThrough
loadp SimpleJumpTable::branchOffsets + VectorBufferOffset[t2], t2
loadi [t2, t0, 4], t1
btiz t1, .opSwitchCharFallThrough
dispatchBranchWithOffset(t1)
.opSwitchCharFallThrough:
dispatchBranch(8[PC])
.opSwitchOnRope:
callSlowPath(_llint_slow_path_switch_char)
dispatch(0)
_llint_op_new_func:
traceExecution()
btiz 12[PC], .opNewFuncUnchecked
loadi 4[PC], t1
bineq TagOffset[cfr, t1, 8], EmptyValueTag, .opNewFuncDone
.opNewFuncUnchecked:
callSlowPath(_llint_slow_path_new_func)
.opNewFuncDone:
dispatch(4)
_llint_op_new_captured_func:
traceExecution()
callSlowPath(_slow_path_new_captured_func)
dispatch(4)
macro arrayProfileForCall()
loadi 16[PC], t3
negi t3
bineq ThisArgumentOffset + TagOffset[cfr, t3, 8], CellTag, .done
loadi ThisArgumentOffset + PayloadOffset[cfr, t3, 8], t0
loadp JSCell::m_structureID[t0], t0
loadpFromInstruction(CallOpCodeSize - 2, t1)
storep t0, ArrayProfile::m_lastSeenStructureID[t1]
.done:
end
macro doCall(slowPath)
loadi 8[PC], t0
loadi 20[PC], t1
loadp LLIntCallLinkInfo::callee[t1], t2
loadConstantOrVariablePayload(t0, CellTag, t3, .opCallSlow)
bineq t3, t2, .opCallSlow
loadi 16[PC], t3
lshifti 3, t3
negi t3
addp cfr, t3 # t3 contains the new value of cfr
loadp JSFunction::m_scope[t2], t0
storei t2, Callee + PayloadOffset[t3]
storei t0, ScopeChain + PayloadOffset[t3]
loadi 12[PC], t2
storei PC, ArgumentCount + TagOffset[cfr]
storei t2, ArgumentCount + PayloadOffset[t3]
storei CellTag, Callee + TagOffset[t3]
storei CellTag, ScopeChain + TagOffset[t3]
addp CallerFrameAndPCSize, t3
callTargetFunction(t1, t3)
.opCallSlow:
slowPathForCall(slowPath)
end
_llint_op_tear_off_lexical_environment:
traceExecution()
loadi 4[PC], t0
bieq TagOffset[cfr, t0, 8], EmptyValueTag, .opTearOffActivationNotCreated
callSlowPath(_llint_slow_path_tear_off_lexical_environment)
.opTearOffActivationNotCreated:
dispatch(2)
_llint_op_tear_off_arguments:
traceExecution()
loadi 4[PC], t0
bieq TagOffset[cfr, t0, 8], EmptyValueTag, .opTearOffArgumentsNotCreated
callSlowPath(_llint_slow_path_tear_off_arguments)
.opTearOffArgumentsNotCreated:
dispatch(3)
_llint_op_ret:
traceExecution()
checkSwitchToJITForEpilogue()
loadi 4[PC], t2
loadConstantOrVariable(t2, t1, t0)
doReturn()
_llint_op_ret_object_or_this:
traceExecution()
checkSwitchToJITForEpilogue()
loadi 4[PC], t2
loadConstantOrVariable(t2, t1, t0)
bineq t1, CellTag, .opRetObjectOrThisNotObject
bbb JSCell::m_type[t0], ObjectType, .opRetObjectOrThisNotObject
doReturn()
.opRetObjectOrThisNotObject:
loadi 8[PC], t2
loadConstantOrVariable(t2, t1, t0)
doReturn()
_llint_op_to_primitive:
traceExecution()
loadi 8[PC], t2
loadi 4[PC], t3
loadConstantOrVariable(t2, t1, t0)
bineq t1, CellTag, .opToPrimitiveIsImm
bbneq JSCell::m_type[t0], StringType, .opToPrimitiveSlowCase
.opToPrimitiveIsImm:
storei t1, TagOffset[cfr, t3, 8]
storei t0, PayloadOffset[cfr, t3, 8]
dispatch(3)
.opToPrimitiveSlowCase:
callSlowPath(_slow_path_to_primitive)
dispatch(3)
_llint_op_catch:
# This is where we end up from the JIT's throw trampoline (because the
# machine code return address will be set to _llint_op_catch), and from
# the interpreter's throw trampoline (see _llint_throw_trampoline).
# The throwing code must have known that we were throwing to the interpreter,
# and have set VM::targetInterpreterPCForThrow.
loadp Callee + PayloadOffset[cfr], t3
andp MarkedBlockMask, t3
loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
loadp VM::callFrameForThrow[t3], cfr
loadp VM::vmEntryFrameForThrow[t3], t0
storep t0, VM::topVMEntryFrame[t3]
restoreStackPointerAfterCall()
loadi VM::targetInterpreterPCForThrow[t3], PC
loadi VM::m_exception + PayloadOffset[t3], t0
loadi VM::m_exception + TagOffset[t3], t1
storei 0, VM::m_exception + PayloadOffset[t3]
storei EmptyValueTag, VM::m_exception + TagOffset[t3]
loadi 4[PC], t2
storei t0, PayloadOffset[cfr, t2, 8]
storei t1, TagOffset[cfr, t2, 8]
traceExecution() # This needs to be here because we don't want to clobber t0, t1, t2, t3 above.
dispatch(2)
# Gives you the scope in t0, while allowing you to optionally perform additional checks on the
# scopes as they are traversed. scopeCheck() is called with two arguments: the register
# holding the scope, and a register that can be used for scratch. Note that this does not
# use t3, so you can hold stuff in t3 if need be.
macro getDeBruijnScope(deBruijinIndexOperand, scopeCheck)
loadp ScopeChain + PayloadOffset[cfr], t0
loadi deBruijinIndexOperand, t2
btiz t2, .done
loadp CodeBlock[cfr], t1
bineq CodeBlock::m_codeType[t1], FunctionCode, .loop
btbz CodeBlock::m_needsActivation[t1], .loop
loadi CodeBlock::m_lexicalEnvironmentRegister[t1], t1
# Need to conditionally skip over one scope.
bieq TagOffset[cfr, t1, 8], EmptyValueTag, .noActivation
scopeCheck(t0, t1)
loadp JSScope::m_next[t0], t0
.noActivation:
subi 1, t2
btiz t2, .done
.loop:
scopeCheck(t0, t1)
loadp JSScope::m_next[t0], t0
subi 1, t2
btinz t2, .loop
.done:
end
_llint_op_end:
traceExecution()
checkSwitchToJITForEpilogue()
loadi 4[PC], t0
assertNotConstant(t0)
loadi TagOffset[cfr, t0, 8], t1
loadi PayloadOffset[cfr, t0, 8], t0
doReturn()
_llint_throw_from_slow_path_trampoline:
callSlowPath(_llint_slow_path_handle_exception)
# When throwing from the interpreter (i.e. throwing from LLIntSlowPaths), so
# the throw target is not necessarily interpreted code, we come to here.
# This essentially emulates the JIT's throwing protocol.
loadp CodeBlock[cfr], t1
loadp CodeBlock::m_vm[t1], t1
jmp VM::targetMachinePCForThrow[t1]
_llint_throw_during_call_trampoline:
preserveReturnAddressAfterCall(t2)
jmp _llint_throw_from_slow_path_trampoline
macro nativeCallTrampoline(executableOffsetToFunction)
functionPrologue()
storep 0, CodeBlock[cfr]
loadp CallerFrame[cfr], t0
loadi ScopeChain + PayloadOffset[t0], t1
storei CellTag, ScopeChain + TagOffset[cfr]
storei t1, ScopeChain + PayloadOffset[cfr]
loadi Callee + PayloadOffset[t0], t1
if X86 or X86_WIN
subp 8, sp # align stack pointer
andp MarkedBlockMask, t1
loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t1], t3
storep cfr, VM::topCallFrame[t3]
move cfr, t2 # t2 = ecx
storep t2, [sp]
loadi Callee + PayloadOffset[cfr], t1
loadp JSFunction::m_executable[t1], t1
checkStackPointerAlignment(t3, 0xdead0001)
call executableOffsetToFunction[t1]
loadp Callee + PayloadOffset[cfr], t3
andp MarkedBlockMask, t3
loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
addp 8, sp
elsif ARM or ARMv7 or ARMv7_TRADITIONAL or C_LOOP or MIPS or SH4
subp 8, sp # align stack pointer
# t1 already contains the Callee.
andp MarkedBlockMask, t1
loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t1], t1
storep cfr, VM::topCallFrame[t1]
if MIPS or SH4
move cfr, a0
else
move cfr, t0
end
loadi Callee + PayloadOffset[cfr], t1
loadp JSFunction::m_executable[t1], t1
checkStackPointerAlignment(t3, 0xdead0001)
if C_LOOP
cloopCallNative executableOffsetToFunction[t1]
else
call executableOffsetToFunction[t1]
end
loadp Callee + PayloadOffset[cfr], t3
andp MarkedBlockMask, t3
loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
addp 8, sp
else
error
end
functionEpilogue()
bineq VM::m_exception + TagOffset[t3], EmptyValueTag, .handleException
ret
.handleException:
storep cfr, VM::topCallFrame[t3]
restoreStackPointerAfterCall()
jmp _llint_throw_from_slow_path_trampoline
end
macro getGlobalObject(dst)
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
loadisFromInstruction(dst, t1)
storei CellTag, TagOffset[cfr, t1, 8]
storei t0, PayloadOffset[cfr, t1, 8]
end
macro varInjectionCheck(slowPath)
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
loadp JSGlobalObject::m_varInjectionWatchpoint[t0], t0
bbeq WatchpointSet::m_state[t0], IsInvalidated, slowPath
end
macro resolveScope()
loadp CodeBlock[cfr], t0
loadisFromInstruction(4, t2)
loadp ScopeChain + PayloadOffset[cfr], t0
btiz t2, .resolveScopeLoopEnd
.resolveScopeLoop:
loadp JSScope::m_next[t0], t0
subi 1, t2
btinz t2, .resolveScopeLoop
.resolveScopeLoopEnd:
loadisFromInstruction(1, t1)
storei CellTag, TagOffset[cfr, t1, 8]
storei t0, PayloadOffset[cfr, t1, 8]
end
_llint_op_resolve_scope:
traceExecution()
loadisFromInstruction(3, t0)
#rGlobalProperty:
bineq t0, GlobalProperty, .rGlobalVar
getGlobalObject(1)
dispatch(6)
.rGlobalVar:
bineq t0, GlobalVar, .rClosureVar
getGlobalObject(1)
dispatch(6)
.rClosureVar:
bineq t0, ClosureVar, .rGlobalPropertyWithVarInjectionChecks
resolveScope()
dispatch(6)
.rGlobalPropertyWithVarInjectionChecks:
bineq t0, GlobalPropertyWithVarInjectionChecks, .rGlobalVarWithVarInjectionChecks
varInjectionCheck(.rDynamic)
getGlobalObject(1)
dispatch(6)
.rGlobalVarWithVarInjectionChecks:
bineq t0, GlobalVarWithVarInjectionChecks, .rClosureVarWithVarInjectionChecks
varInjectionCheck(.rDynamic)
getGlobalObject(1)
dispatch(6)
.rClosureVarWithVarInjectionChecks:
bineq t0, ClosureVarWithVarInjectionChecks, .rDynamic
varInjectionCheck(.rDynamic)
resolveScope()
dispatch(6)
.rDynamic:
callSlowPath(_llint_slow_path_resolve_scope)
dispatch(6)
macro loadWithStructureCheck(operand, slowPath)
loadisFromInstruction(operand, t0)
loadp PayloadOffset[cfr, t0, 8], t0
loadpFromInstruction(5, t1)
bpneq JSCell::m_structureID[t0], t1, slowPath
end
macro getProperty()
loadisFromInstruction(6, t3)
loadPropertyAtVariableOffset(t3, t0, t1, t2)
valueProfile(t1, t2, 28, t0)
loadisFromInstruction(1, t0)
storei t1, TagOffset[cfr, t0, 8]
storei t2, PayloadOffset[cfr, t0, 8]
end
macro getGlobalVar()
loadpFromInstruction(6, t0)
loadp TagOffset[t0], t1
loadp PayloadOffset[t0], t2
valueProfile(t1, t2, 28, t0)
loadisFromInstruction(1, t0)
storei t1, TagOffset[cfr, t0, 8]
storei t2, PayloadOffset[cfr, t0, 8]
end
macro getClosureVar()
loadp JSEnvironmentRecord::m_registers[t0], t0
loadisFromInstruction(6, t3)
loadp TagOffset[t0, t3, 8], t1
loadp PayloadOffset[t0, t3, 8], t2
valueProfile(t1, t2, 28, t0)
loadisFromInstruction(1, t0)
storei t1, TagOffset[cfr, t0, 8]
storei t2, PayloadOffset[cfr, t0, 8]
end
_llint_op_get_from_scope:
traceExecution()
loadisFromInstruction(4, t0)
andi ResolveModeMask, t0
#gGlobalProperty:
bineq t0, GlobalProperty, .gGlobalVar
loadWithStructureCheck(2, .gDynamic)
getProperty()
dispatch(8)
.gGlobalVar:
bineq t0, GlobalVar, .gClosureVar
getGlobalVar()
dispatch(8)
.gClosureVar:
bineq t0, ClosureVar, .gGlobalPropertyWithVarInjectionChecks
loadVariable(2, t2, t1, t0)
getClosureVar()
dispatch(8)
.gGlobalPropertyWithVarInjectionChecks:
bineq t0, GlobalPropertyWithVarInjectionChecks, .gGlobalVarWithVarInjectionChecks
loadWithStructureCheck(2, .gDynamic)
getProperty()
dispatch(8)
.gGlobalVarWithVarInjectionChecks:
bineq t0, GlobalVarWithVarInjectionChecks, .gClosureVarWithVarInjectionChecks
varInjectionCheck(.gDynamic)
loadVariable(2, t2, t1, t0)
getGlobalVar()
dispatch(8)
.gClosureVarWithVarInjectionChecks:
bineq t0, ClosureVarWithVarInjectionChecks, .gDynamic
varInjectionCheck(.gDynamic)
loadVariable(2, t2, t1, t0)
getClosureVar()
dispatch(8)
.gDynamic:
callSlowPath(_llint_slow_path_get_from_scope)
dispatch(8)
macro putProperty()
loadisFromInstruction(3, t1)
loadConstantOrVariable(t1, t2, t3)
loadisFromInstruction(6, t1)
storePropertyAtVariableOffset(t1, t0, t2, t3)
end
macro putGlobalVar()
loadisFromInstruction(3, t0)
loadConstantOrVariable(t0, t1, t2)
loadpFromInstruction(5, t3)
notifyWrite(t3, t1, t2, t0, .pDynamic)
loadpFromInstruction(6, t0)
storei t1, TagOffset[t0]
storei t2, PayloadOffset[t0]
end
macro putClosureVar()
loadisFromInstruction(3, t1)
loadConstantOrVariable(t1, t2, t3)
loadp JSEnvironmentRecord::m_registers[t0], t0
loadisFromInstruction(6, t1)
storei t2, TagOffset[t0, t1, 8]
storei t3, PayloadOffset[t0, t1, 8]
end
_llint_op_put_to_scope:
traceExecution()
loadisFromInstruction(4, t0)
andi ResolveModeMask, t0
#pGlobalProperty:
bineq t0, GlobalProperty, .pGlobalVar
writeBarrierOnOperands(1, 3)
loadWithStructureCheck(1, .pDynamic)
putProperty()
dispatch(7)
.pGlobalVar:
bineq t0, GlobalVar, .pClosureVar
writeBarrierOnGlobalObject(3)
putGlobalVar()
dispatch(7)
.pClosureVar:
bineq t0, ClosureVar, .pGlobalPropertyWithVarInjectionChecks
writeBarrierOnOperands(1, 3)
loadVariable(1, t2, t1, t0)
putClosureVar()
dispatch(7)
.pGlobalPropertyWithVarInjectionChecks:
bineq t0, GlobalPropertyWithVarInjectionChecks, .pGlobalVarWithVarInjectionChecks
writeBarrierOnOperands(1, 3)
loadWithStructureCheck(1, .pDynamic)
putProperty()
dispatch(7)
.pGlobalVarWithVarInjectionChecks:
bineq t0, GlobalVarWithVarInjectionChecks, .pClosureVarWithVarInjectionChecks
writeBarrierOnGlobalObject(3)
varInjectionCheck(.pDynamic)
putGlobalVar()
dispatch(7)
.pClosureVarWithVarInjectionChecks:
bineq t0, ClosureVarWithVarInjectionChecks, .pDynamic
writeBarrierOnOperands(1, 3)
varInjectionCheck(.pDynamic)
loadVariable(1, t2, t1, t0)
putClosureVar()
dispatch(7)
.pDynamic:
callSlowPath(_llint_slow_path_put_to_scope)
dispatch(7)
|