OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 | 1605 |
1606 // Handle call cache miss. | 1606 // Handle call cache miss. |
1607 __ bind(&miss); | 1607 __ bind(&miss); |
1608 GenerateMissBranch(); | 1608 GenerateMissBranch(); |
1609 | 1609 |
1610 // Return the generated code. | 1610 // Return the generated code. |
1611 return GetCode(Code::FIELD, name); | 1611 return GetCode(Code::FIELD, name); |
1612 } | 1612 } |
1613 | 1613 |
1614 | 1614 |
| 1615 Handle<Code> CallStubCompiler::CompileArrayCodeCall( |
| 1616 Handle<Object> object, |
| 1617 Handle<JSObject> holder, |
| 1618 Handle<Cell> cell, |
| 1619 Handle<JSFunction> function, |
| 1620 Handle<String> name, |
| 1621 Code::StubType type) { |
| 1622 Label miss; |
| 1623 |
| 1624 // Check that function is still array |
| 1625 const int argc = arguments().immediate(); |
| 1626 GenerateNameCheck(name, &miss); |
| 1627 |
| 1628 if (cell.is_null()) { |
| 1629 // Get the receiver from the stack. |
| 1630 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); |
| 1631 |
| 1632 // Check that the receiver isn't a smi. |
| 1633 __ JumpIfSmi(rdx, &miss); |
| 1634 CheckPrototypes(Handle<JSObject>::cast(object), rdx, holder, rbx, rax, rdi, |
| 1635 name, &miss); |
| 1636 } else { |
| 1637 ASSERT(cell->value() == *function); |
| 1638 GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name, |
| 1639 &miss); |
| 1640 GenerateLoadFunctionFromCell(cell, function, &miss); |
| 1641 } |
| 1642 |
| 1643 Handle<Smi> kind(Smi::FromInt(GetInitialFastElementsKind()), isolate()); |
| 1644 Handle<Cell> kind_feedback_cell = |
| 1645 isolate()->factory()->NewCell(kind); |
| 1646 __ movq(rax, Immediate(argc)); |
| 1647 __ Move(rbx, kind_feedback_cell); |
| 1648 __ Move(rdi, function); |
| 1649 |
| 1650 ArrayConstructorStub stub(isolate()); |
| 1651 __ TailCallStub(&stub); |
| 1652 |
| 1653 __ bind(&miss); |
| 1654 GenerateMissBranch(); |
| 1655 |
| 1656 // Return the generated code. |
| 1657 return GetCode(type, name); |
| 1658 } |
| 1659 |
| 1660 |
1615 Handle<Code> CallStubCompiler::CompileArrayPushCall( | 1661 Handle<Code> CallStubCompiler::CompileArrayPushCall( |
1616 Handle<Object> object, | 1662 Handle<Object> object, |
1617 Handle<JSObject> holder, | 1663 Handle<JSObject> holder, |
1618 Handle<Cell> cell, | 1664 Handle<Cell> cell, |
1619 Handle<JSFunction> function, | 1665 Handle<JSFunction> function, |
1620 Handle<String> name) { | 1666 Handle<String> name, |
| 1667 Code::StubType type) { |
1621 // ----------- S t a t e ------------- | 1668 // ----------- S t a t e ------------- |
1622 // -- rcx : name | 1669 // -- rcx : name |
1623 // -- rsp[0] : return address | 1670 // -- rsp[0] : return address |
1624 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) | 1671 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) |
1625 // -- ... | 1672 // -- ... |
1626 // -- rsp[(argc + 1) * 8] : receiver | 1673 // -- rsp[(argc + 1) * 8] : receiver |
1627 // ----------------------------------- | 1674 // ----------------------------------- |
1628 | 1675 |
1629 // If object is not an array, bail out to regular call. | 1676 // If object is not an array, bail out to regular call. |
1630 if (!object->IsJSArray() || !cell.is_null()) return Handle<Code>::null(); | 1677 if (!object->IsJSArray() || !cell.is_null()) return Handle<Code>::null(); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush, | 1898 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush, |
1852 isolate()), | 1899 isolate()), |
1853 argc + 1, | 1900 argc + 1, |
1854 1); | 1901 1); |
1855 } | 1902 } |
1856 | 1903 |
1857 __ bind(&miss); | 1904 __ bind(&miss); |
1858 GenerateMissBranch(); | 1905 GenerateMissBranch(); |
1859 | 1906 |
1860 // Return the generated code. | 1907 // Return the generated code. |
1861 return GetCode(function); | 1908 return GetCode(type, name); |
1862 } | 1909 } |
1863 | 1910 |
1864 | 1911 |
1865 Handle<Code> CallStubCompiler::CompileArrayPopCall( | 1912 Handle<Code> CallStubCompiler::CompileArrayPopCall( |
1866 Handle<Object> object, | 1913 Handle<Object> object, |
1867 Handle<JSObject> holder, | 1914 Handle<JSObject> holder, |
1868 Handle<Cell> cell, | 1915 Handle<Cell> cell, |
1869 Handle<JSFunction> function, | 1916 Handle<JSFunction> function, |
1870 Handle<String> name) { | 1917 Handle<String> name, |
| 1918 Code::StubType type) { |
1871 // ----------- S t a t e ------------- | 1919 // ----------- S t a t e ------------- |
1872 // -- rcx : name | 1920 // -- rcx : name |
1873 // -- rsp[0] : return address | 1921 // -- rsp[0] : return address |
1874 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) | 1922 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) |
1875 // -- ... | 1923 // -- ... |
1876 // -- rsp[(argc + 1) * 8] : receiver | 1924 // -- rsp[(argc + 1) * 8] : receiver |
1877 // ----------------------------------- | 1925 // ----------------------------------- |
1878 | 1926 |
1879 // If object is not an array, bail out to regular call. | 1927 // If object is not an array, bail out to regular call. |
1880 if (!object->IsJSArray() || !cell.is_null()) return Handle<Code>::null(); | 1928 if (!object->IsJSArray() || !cell.is_null()) return Handle<Code>::null(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 __ bind(&call_builtin); | 1980 __ bind(&call_builtin); |
1933 __ TailCallExternalReference( | 1981 __ TailCallExternalReference( |
1934 ExternalReference(Builtins::c_ArrayPop, isolate()), | 1982 ExternalReference(Builtins::c_ArrayPop, isolate()), |
1935 argc + 1, | 1983 argc + 1, |
1936 1); | 1984 1); |
1937 | 1985 |
1938 __ bind(&miss); | 1986 __ bind(&miss); |
1939 GenerateMissBranch(); | 1987 GenerateMissBranch(); |
1940 | 1988 |
1941 // Return the generated code. | 1989 // Return the generated code. |
1942 return GetCode(function); | 1990 return GetCode(type, name); |
1943 } | 1991 } |
1944 | 1992 |
1945 | 1993 |
1946 Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall( | 1994 Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall( |
1947 Handle<Object> object, | 1995 Handle<Object> object, |
1948 Handle<JSObject> holder, | 1996 Handle<JSObject> holder, |
1949 Handle<Cell> cell, | 1997 Handle<Cell> cell, |
1950 Handle<JSFunction> function, | 1998 Handle<JSFunction> function, |
1951 Handle<String> name) { | 1999 Handle<String> name, |
| 2000 Code::StubType type) { |
1952 // ----------- S t a t e ------------- | 2001 // ----------- S t a t e ------------- |
1953 // -- rcx : function name | 2002 // -- rcx : function name |
1954 // -- rsp[0] : return address | 2003 // -- rsp[0] : return address |
1955 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) | 2004 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) |
1956 // -- ... | 2005 // -- ... |
1957 // -- rsp[(argc + 1) * 8] : receiver | 2006 // -- rsp[(argc + 1) * 8] : receiver |
1958 // ----------------------------------- | 2007 // ----------------------------------- |
1959 | 2008 |
1960 // If object is not a string, bail out to regular call. | 2009 // If object is not a string, bail out to regular call. |
1961 if (!object->IsString() || !cell.is_null()) return Handle<Code>::null(); | 2010 if (!object->IsString() || !cell.is_null()) return Handle<Code>::null(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2012 __ ret((argc + 1) * kPointerSize); | 2061 __ ret((argc + 1) * kPointerSize); |
2013 } | 2062 } |
2014 | 2063 |
2015 __ bind(&miss); | 2064 __ bind(&miss); |
2016 // Restore function name in rcx. | 2065 // Restore function name in rcx. |
2017 __ Move(rcx, name); | 2066 __ Move(rcx, name); |
2018 __ bind(&name_miss); | 2067 __ bind(&name_miss); |
2019 GenerateMissBranch(); | 2068 GenerateMissBranch(); |
2020 | 2069 |
2021 // Return the generated code. | 2070 // Return the generated code. |
2022 return GetCode(function); | 2071 return GetCode(type, name); |
2023 } | 2072 } |
2024 | 2073 |
2025 | 2074 |
2026 Handle<Code> CallStubCompiler::CompileStringCharAtCall( | 2075 Handle<Code> CallStubCompiler::CompileStringCharAtCall( |
2027 Handle<Object> object, | 2076 Handle<Object> object, |
2028 Handle<JSObject> holder, | 2077 Handle<JSObject> holder, |
2029 Handle<Cell> cell, | 2078 Handle<Cell> cell, |
2030 Handle<JSFunction> function, | 2079 Handle<JSFunction> function, |
2031 Handle<String> name) { | 2080 Handle<String> name, |
| 2081 Code::StubType type) { |
2032 // ----------- S t a t e ------------- | 2082 // ----------- S t a t e ------------- |
2033 // -- rcx : function name | 2083 // -- rcx : function name |
2034 // -- rsp[0] : return address | 2084 // -- rsp[0] : return address |
2035 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) | 2085 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) |
2036 // -- ... | 2086 // -- ... |
2037 // -- rsp[(argc + 1) * 8] : receiver | 2087 // -- rsp[(argc + 1) * 8] : receiver |
2038 // ----------------------------------- | 2088 // ----------------------------------- |
2039 | 2089 |
2040 // If object is not a string, bail out to regular call. | 2090 // If object is not a string, bail out to regular call. |
2041 if (!object->IsString() || !cell.is_null()) return Handle<Code>::null(); | 2091 if (!object->IsString() || !cell.is_null()) return Handle<Code>::null(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 __ LoadRoot(rax, Heap::kempty_stringRootIndex); | 2142 __ LoadRoot(rax, Heap::kempty_stringRootIndex); |
2093 __ ret((argc + 1) * kPointerSize); | 2143 __ ret((argc + 1) * kPointerSize); |
2094 } | 2144 } |
2095 __ bind(&miss); | 2145 __ bind(&miss); |
2096 // Restore function name in rcx. | 2146 // Restore function name in rcx. |
2097 __ Move(rcx, name); | 2147 __ Move(rcx, name); |
2098 __ bind(&name_miss); | 2148 __ bind(&name_miss); |
2099 GenerateMissBranch(); | 2149 GenerateMissBranch(); |
2100 | 2150 |
2101 // Return the generated code. | 2151 // Return the generated code. |
2102 return GetCode(function); | 2152 return GetCode(type, name); |
2103 } | 2153 } |
2104 | 2154 |
2105 | 2155 |
2106 Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall( | 2156 Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall( |
2107 Handle<Object> object, | 2157 Handle<Object> object, |
2108 Handle<JSObject> holder, | 2158 Handle<JSObject> holder, |
2109 Handle<Cell> cell, | 2159 Handle<Cell> cell, |
2110 Handle<JSFunction> function, | 2160 Handle<JSFunction> function, |
2111 Handle<String> name) { | 2161 Handle<String> name, |
| 2162 Code::StubType type) { |
2112 // ----------- S t a t e ------------- | 2163 // ----------- S t a t e ------------- |
2113 // -- rcx : function name | 2164 // -- rcx : function name |
2114 // -- rsp[0] : return address | 2165 // -- rsp[0] : return address |
2115 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) | 2166 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) |
2116 // -- ... | 2167 // -- ... |
2117 // -- rsp[(argc + 1) * 8] : receiver | 2168 // -- rsp[(argc + 1) * 8] : receiver |
2118 // ----------------------------------- | 2169 // ----------------------------------- |
2119 | 2170 |
2120 // If the object is not a JSObject or we got an unexpected number of | 2171 // If the object is not a JSObject or we got an unexpected number of |
2121 // arguments, bail out to the regular call. | 2172 // arguments, bail out to the regular call. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2163 : CALL_AS_METHOD; | 2214 : CALL_AS_METHOD; |
2164 ParameterCount expected(function); | 2215 ParameterCount expected(function); |
2165 __ InvokeFunction(function, expected, arguments(), | 2216 __ InvokeFunction(function, expected, arguments(), |
2166 JUMP_FUNCTION, NullCallWrapper(), call_kind); | 2217 JUMP_FUNCTION, NullCallWrapper(), call_kind); |
2167 | 2218 |
2168 __ bind(&miss); | 2219 __ bind(&miss); |
2169 // rcx: function name. | 2220 // rcx: function name. |
2170 GenerateMissBranch(); | 2221 GenerateMissBranch(); |
2171 | 2222 |
2172 // Return the generated code. | 2223 // Return the generated code. |
2173 return cell.is_null() ? GetCode(function) : GetCode(Code::NORMAL, name); | 2224 return GetCode(type, name); |
2174 } | 2225 } |
2175 | 2226 |
2176 | 2227 |
2177 Handle<Code> CallStubCompiler::CompileMathFloorCall( | 2228 Handle<Code> CallStubCompiler::CompileMathFloorCall( |
2178 Handle<Object> object, | 2229 Handle<Object> object, |
2179 Handle<JSObject> holder, | 2230 Handle<JSObject> holder, |
2180 Handle<Cell> cell, | 2231 Handle<Cell> cell, |
2181 Handle<JSFunction> function, | 2232 Handle<JSFunction> function, |
2182 Handle<String> name) { | 2233 Handle<String> name, |
| 2234 Code::StubType type) { |
2183 // TODO(872): implement this. | 2235 // TODO(872): implement this. |
2184 return Handle<Code>::null(); | 2236 return Handle<Code>::null(); |
2185 } | 2237 } |
2186 | 2238 |
2187 | 2239 |
2188 Handle<Code> CallStubCompiler::CompileMathAbsCall( | 2240 Handle<Code> CallStubCompiler::CompileMathAbsCall( |
2189 Handle<Object> object, | 2241 Handle<Object> object, |
2190 Handle<JSObject> holder, | 2242 Handle<JSObject> holder, |
2191 Handle<Cell> cell, | 2243 Handle<Cell> cell, |
2192 Handle<JSFunction> function, | 2244 Handle<JSFunction> function, |
2193 Handle<String> name) { | 2245 Handle<String> name, |
| 2246 Code::StubType type) { |
2194 // ----------- S t a t e ------------- | 2247 // ----------- S t a t e ------------- |
2195 // -- rcx : function name | 2248 // -- rcx : function name |
2196 // -- rsp[0] : return address | 2249 // -- rsp[0] : return address |
2197 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) | 2250 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) |
2198 // -- ... | 2251 // -- ... |
2199 // -- rsp[(argc + 1) * 8] : receiver | 2252 // -- rsp[(argc + 1) * 8] : receiver |
2200 // ----------------------------------- | 2253 // ----------------------------------- |
2201 | 2254 |
2202 // If the object is not a JSObject or we got an unexpected number of | 2255 // If the object is not a JSObject or we got an unexpected number of |
2203 // arguments, bail out to the regular call. | 2256 // arguments, bail out to the regular call. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2279 : CALL_AS_METHOD; | 2332 : CALL_AS_METHOD; |
2280 ParameterCount expected(function); | 2333 ParameterCount expected(function); |
2281 __ InvokeFunction(function, expected, arguments(), | 2334 __ InvokeFunction(function, expected, arguments(), |
2282 JUMP_FUNCTION, NullCallWrapper(), call_kind); | 2335 JUMP_FUNCTION, NullCallWrapper(), call_kind); |
2283 | 2336 |
2284 __ bind(&miss); | 2337 __ bind(&miss); |
2285 // rcx: function name. | 2338 // rcx: function name. |
2286 GenerateMissBranch(); | 2339 GenerateMissBranch(); |
2287 | 2340 |
2288 // Return the generated code. | 2341 // Return the generated code. |
2289 return cell.is_null() ? GetCode(function) : GetCode(Code::NORMAL, name); | 2342 return GetCode(type, name); |
2290 } | 2343 } |
2291 | 2344 |
2292 | 2345 |
2293 Handle<Code> CallStubCompiler::CompileFastApiCall( | 2346 Handle<Code> CallStubCompiler::CompileFastApiCall( |
2294 const CallOptimization& optimization, | 2347 const CallOptimization& optimization, |
2295 Handle<Object> object, | 2348 Handle<Object> object, |
2296 Handle<JSObject> holder, | 2349 Handle<JSObject> holder, |
2297 Handle<Cell> cell, | 2350 Handle<Cell> cell, |
2298 Handle<JSFunction> function, | 2351 Handle<JSFunction> function, |
2299 Handle<String> name) { | 2352 Handle<String> name) { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2470 | 2523 |
2471 Handle<Code> CallStubCompiler::CompileCallConstant( | 2524 Handle<Code> CallStubCompiler::CompileCallConstant( |
2472 Handle<Object> object, | 2525 Handle<Object> object, |
2473 Handle<JSObject> holder, | 2526 Handle<JSObject> holder, |
2474 Handle<Name> name, | 2527 Handle<Name> name, |
2475 CheckType check, | 2528 CheckType check, |
2476 Handle<JSFunction> function) { | 2529 Handle<JSFunction> function) { |
2477 if (HasCustomCallGenerator(function)) { | 2530 if (HasCustomCallGenerator(function)) { |
2478 Handle<Code> code = CompileCustomCall(object, holder, | 2531 Handle<Code> code = CompileCustomCall(object, holder, |
2479 Handle<PropertyCell>::null(), | 2532 Handle<PropertyCell>::null(), |
2480 function, Handle<String>::cast(name)); | 2533 function, Handle<String>::cast(name), |
| 2534 Code::CONSTANT_FUNCTION); |
2481 // A null handle means bail out to the regular compiler code below. | 2535 // A null handle means bail out to the regular compiler code below. |
2482 if (!code.is_null()) return code; | 2536 if (!code.is_null()) return code; |
2483 } | 2537 } |
2484 | 2538 |
2485 Label success; | 2539 Label success; |
2486 | 2540 |
2487 CompileHandlerFrontend(object, holder, name, check, &success); | 2541 CompileHandlerFrontend(object, holder, name, check, &success); |
2488 __ bind(&success); | 2542 __ bind(&success); |
2489 CompileHandlerBackend(function); | 2543 CompileHandlerBackend(function); |
2490 | 2544 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2564 // rsp[0] : return address | 2618 // rsp[0] : return address |
2565 // rsp[8] : argument argc | 2619 // rsp[8] : argument argc |
2566 // rsp[16] : argument argc - 1 | 2620 // rsp[16] : argument argc - 1 |
2567 // ... | 2621 // ... |
2568 // rsp[argc * 8] : argument 1 | 2622 // rsp[argc * 8] : argument 1 |
2569 // rsp[(argc + 1) * 8] : argument 0 = receiver | 2623 // rsp[(argc + 1) * 8] : argument 0 = receiver |
2570 // ----------------------------------- | 2624 // ----------------------------------- |
2571 | 2625 |
2572 if (HasCustomCallGenerator(function)) { | 2626 if (HasCustomCallGenerator(function)) { |
2573 Handle<Code> code = CompileCustomCall( | 2627 Handle<Code> code = CompileCustomCall( |
2574 object, holder, cell, function, Handle<String>::cast(name)); | 2628 object, holder, cell, function, Handle<String>::cast(name), |
| 2629 Code::NORMAL); |
2575 // A null handle means bail out to the regular compiler code below. | 2630 // A null handle means bail out to the regular compiler code below. |
2576 if (!code.is_null()) return code; | 2631 if (!code.is_null()) return code; |
2577 } | 2632 } |
2578 | 2633 |
2579 Label miss; | 2634 Label miss; |
2580 GenerateNameCheck(name, &miss); | 2635 GenerateNameCheck(name, &miss); |
2581 | 2636 |
2582 // Get the number of arguments. | 2637 // Get the number of arguments. |
2583 const int argc = arguments().immediate(); | 2638 const int argc = arguments().immediate(); |
2584 GenerateGlobalReceiverCheck(object, holder, name, &miss); | 2639 GenerateGlobalReceiverCheck(object, holder, name, &miss); |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3517 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); | 3572 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |
3518 } | 3573 } |
3519 } | 3574 } |
3520 | 3575 |
3521 | 3576 |
3522 #undef __ | 3577 #undef __ |
3523 | 3578 |
3524 } } // namespace v8::internal | 3579 } } // namespace v8::internal |
3525 | 3580 |
3526 #endif // V8_TARGET_ARCH_X64 | 3581 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |