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

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 17155010: Use type feedback for Array (non-constructor) call sites. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Nit fixin' Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.cc ('k') | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 1689
1690 // Handle call cache miss. 1690 // Handle call cache miss.
1691 __ bind(&miss); 1691 __ bind(&miss);
1692 GenerateMissBranch(); 1692 GenerateMissBranch();
1693 1693
1694 // Return the generated code. 1694 // Return the generated code.
1695 return GetCode(Code::FIELD, name); 1695 return GetCode(Code::FIELD, name);
1696 } 1696 }
1697 1697
1698 1698
1699 Handle<Code> CallStubCompiler::CompileArrayCodeCall(
1700 Handle<Object> object,
1701 Handle<JSObject> holder,
1702 Handle<Cell> cell,
1703 Handle<JSFunction> function,
1704 Handle<String> name,
1705 Code::StubType type) {
1706 Label miss;
1707
1708 // Check that function is still array
1709 const int argc = arguments().immediate();
1710 GenerateNameCheck(name, &miss);
1711
1712 if (cell.is_null()) {
1713 // Get the receiver from the stack.
1714 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
1715
1716 // Check that the receiver isn't a smi.
1717 __ JumpIfSmi(edx, &miss);
1718 CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi,
1719 name, &miss);
1720 } else {
1721 ASSERT(cell->value() == *function);
1722 GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name,
1723 &miss);
1724 GenerateLoadFunctionFromCell(cell, function, &miss);
1725 }
1726
1727 Handle<Smi> kind(Smi::FromInt(GetInitialFastElementsKind()), isolate());
1728 Handle<Cell> kind_feedback_cell =
1729 isolate()->factory()->NewCell(kind);
1730 __ mov(eax, Immediate(argc));
1731 __ mov(ebx, kind_feedback_cell);
1732 __ mov(edi, function);
1733
1734 ArrayConstructorStub stub(isolate());
1735 __ TailCallStub(&stub);
1736
1737 __ bind(&miss);
1738 GenerateMissBranch();
1739
1740 // Return the generated code.
1741 return GetCode(type, name);
1742 }
1743
1744
1699 Handle<Code> CallStubCompiler::CompileArrayPushCall( 1745 Handle<Code> CallStubCompiler::CompileArrayPushCall(
1700 Handle<Object> object, 1746 Handle<Object> object,
1701 Handle<JSObject> holder, 1747 Handle<JSObject> holder,
1702 Handle<Cell> cell, 1748 Handle<Cell> cell,
1703 Handle<JSFunction> function, 1749 Handle<JSFunction> function,
1704 Handle<String> name) { 1750 Handle<String> name,
1751 Code::StubType type) {
1705 // ----------- S t a t e ------------- 1752 // ----------- S t a t e -------------
1706 // -- ecx : name 1753 // -- ecx : name
1707 // -- esp[0] : return address 1754 // -- esp[0] : return address
1708 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 1755 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
1709 // -- ... 1756 // -- ...
1710 // -- esp[(argc + 1) * 4] : receiver 1757 // -- esp[(argc + 1) * 4] : receiver
1711 // ----------------------------------- 1758 // -----------------------------------
1712 1759
1713 // If object is not an array, bail out to regular call. 1760 // If object is not an array, bail out to regular call.
1714 if (!object->IsJSArray() || !cell.is_null()) { 1761 if (!object->IsJSArray() || !cell.is_null()) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 __ TailCallExternalReference( 1990 __ TailCallExternalReference(
1944 ExternalReference(Builtins::c_ArrayPush, isolate()), 1991 ExternalReference(Builtins::c_ArrayPush, isolate()),
1945 argc + 1, 1992 argc + 1,
1946 1); 1993 1);
1947 } 1994 }
1948 1995
1949 __ bind(&miss); 1996 __ bind(&miss);
1950 GenerateMissBranch(); 1997 GenerateMissBranch();
1951 1998
1952 // Return the generated code. 1999 // Return the generated code.
1953 return GetCode(function); 2000 return GetCode(type, name);
1954 } 2001 }
1955 2002
1956 2003
1957 Handle<Code> CallStubCompiler::CompileArrayPopCall( 2004 Handle<Code> CallStubCompiler::CompileArrayPopCall(
1958 Handle<Object> object, 2005 Handle<Object> object,
1959 Handle<JSObject> holder, 2006 Handle<JSObject> holder,
1960 Handle<Cell> cell, 2007 Handle<Cell> cell,
1961 Handle<JSFunction> function, 2008 Handle<JSFunction> function,
1962 Handle<String> name) { 2009 Handle<String> name,
2010 Code::StubType type) {
1963 // ----------- S t a t e ------------- 2011 // ----------- S t a t e -------------
1964 // -- ecx : name 2012 // -- ecx : name
1965 // -- esp[0] : return address 2013 // -- esp[0] : return address
1966 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 2014 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
1967 // -- ... 2015 // -- ...
1968 // -- esp[(argc + 1) * 4] : receiver 2016 // -- esp[(argc + 1) * 4] : receiver
1969 // ----------------------------------- 2017 // -----------------------------------
1970 2018
1971 // If object is not an array, bail out to regular call. 2019 // If object is not an array, bail out to regular call.
1972 if (!object->IsJSArray() || !cell.is_null()) { 2020 if (!object->IsJSArray() || !cell.is_null()) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 __ bind(&call_builtin); 2073 __ bind(&call_builtin);
2026 __ TailCallExternalReference( 2074 __ TailCallExternalReference(
2027 ExternalReference(Builtins::c_ArrayPop, isolate()), 2075 ExternalReference(Builtins::c_ArrayPop, isolate()),
2028 argc + 1, 2076 argc + 1,
2029 1); 2077 1);
2030 2078
2031 __ bind(&miss); 2079 __ bind(&miss);
2032 GenerateMissBranch(); 2080 GenerateMissBranch();
2033 2081
2034 // Return the generated code. 2082 // Return the generated code.
2035 return GetCode(function); 2083 return GetCode(type, name);
2036 } 2084 }
2037 2085
2038 2086
2039 Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall( 2087 Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
2040 Handle<Object> object, 2088 Handle<Object> object,
2041 Handle<JSObject> holder, 2089 Handle<JSObject> holder,
2042 Handle<Cell> cell, 2090 Handle<Cell> cell,
2043 Handle<JSFunction> function, 2091 Handle<JSFunction> function,
2044 Handle<String> name) { 2092 Handle<String> name,
2093 Code::StubType type) {
2045 // ----------- S t a t e ------------- 2094 // ----------- S t a t e -------------
2046 // -- ecx : function name 2095 // -- ecx : function name
2047 // -- esp[0] : return address 2096 // -- esp[0] : return address
2048 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 2097 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
2049 // -- ... 2098 // -- ...
2050 // -- esp[(argc + 1) * 4] : receiver 2099 // -- esp[(argc + 1) * 4] : receiver
2051 // ----------------------------------- 2100 // -----------------------------------
2052 2101
2053 // If object is not a string, bail out to regular call. 2102 // If object is not a string, bail out to regular call.
2054 if (!object->IsString() || !cell.is_null()) { 2103 if (!object->IsString() || !cell.is_null()) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 __ ret((argc + 1) * kPointerSize); 2158 __ ret((argc + 1) * kPointerSize);
2110 } 2159 }
2111 2160
2112 __ bind(&miss); 2161 __ bind(&miss);
2113 // Restore function name in ecx. 2162 // Restore function name in ecx.
2114 __ Set(ecx, Immediate(name)); 2163 __ Set(ecx, Immediate(name));
2115 __ bind(&name_miss); 2164 __ bind(&name_miss);
2116 GenerateMissBranch(); 2165 GenerateMissBranch();
2117 2166
2118 // Return the generated code. 2167 // Return the generated code.
2119 return GetCode(function); 2168 return GetCode(type, name);
2120 } 2169 }
2121 2170
2122 2171
2123 Handle<Code> CallStubCompiler::CompileStringCharAtCall( 2172 Handle<Code> CallStubCompiler::CompileStringCharAtCall(
2124 Handle<Object> object, 2173 Handle<Object> object,
2125 Handle<JSObject> holder, 2174 Handle<JSObject> holder,
2126 Handle<Cell> cell, 2175 Handle<Cell> cell,
2127 Handle<JSFunction> function, 2176 Handle<JSFunction> function,
2128 Handle<String> name) { 2177 Handle<String> name,
2178 Code::StubType type) {
2129 // ----------- S t a t e ------------- 2179 // ----------- S t a t e -------------
2130 // -- ecx : function name 2180 // -- ecx : function name
2131 // -- esp[0] : return address 2181 // -- esp[0] : return address
2132 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 2182 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
2133 // -- ... 2183 // -- ...
2134 // -- esp[(argc + 1) * 4] : receiver 2184 // -- esp[(argc + 1) * 4] : receiver
2135 // ----------------------------------- 2185 // -----------------------------------
2136 2186
2137 // If object is not a string, bail out to regular call. 2187 // If object is not a string, bail out to regular call.
2138 if (!object->IsString() || !cell.is_null()) { 2188 if (!object->IsString() || !cell.is_null()) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 __ ret((argc + 1) * kPointerSize); 2245 __ ret((argc + 1) * kPointerSize);
2196 } 2246 }
2197 2247
2198 __ bind(&miss); 2248 __ bind(&miss);
2199 // Restore function name in ecx. 2249 // Restore function name in ecx.
2200 __ Set(ecx, Immediate(name)); 2250 __ Set(ecx, Immediate(name));
2201 __ bind(&name_miss); 2251 __ bind(&name_miss);
2202 GenerateMissBranch(); 2252 GenerateMissBranch();
2203 2253
2204 // Return the generated code. 2254 // Return the generated code.
2205 return GetCode(function); 2255 return GetCode(type, name);
2206 } 2256 }
2207 2257
2208 2258
2209 Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall( 2259 Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
2210 Handle<Object> object, 2260 Handle<Object> object,
2211 Handle<JSObject> holder, 2261 Handle<JSObject> holder,
2212 Handle<Cell> cell, 2262 Handle<Cell> cell,
2213 Handle<JSFunction> function, 2263 Handle<JSFunction> function,
2214 Handle<String> name) { 2264 Handle<String> name,
2265 Code::StubType type) {
2215 // ----------- S t a t e ------------- 2266 // ----------- S t a t e -------------
2216 // -- ecx : function name 2267 // -- ecx : function name
2217 // -- esp[0] : return address 2268 // -- esp[0] : return address
2218 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 2269 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
2219 // -- ... 2270 // -- ...
2220 // -- esp[(argc + 1) * 4] : receiver 2271 // -- esp[(argc + 1) * 4] : receiver
2221 // ----------------------------------- 2272 // -----------------------------------
2222 2273
2223 const int argc = arguments().immediate(); 2274 const int argc = arguments().immediate();
2224 2275
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 : CALL_AS_METHOD; 2322 : CALL_AS_METHOD;
2272 ParameterCount expected(function); 2323 ParameterCount expected(function);
2273 __ InvokeFunction(function, expected, arguments(), 2324 __ InvokeFunction(function, expected, arguments(),
2274 JUMP_FUNCTION, NullCallWrapper(), call_kind); 2325 JUMP_FUNCTION, NullCallWrapper(), call_kind);
2275 2326
2276 __ bind(&miss); 2327 __ bind(&miss);
2277 // ecx: function name. 2328 // ecx: function name.
2278 GenerateMissBranch(); 2329 GenerateMissBranch();
2279 2330
2280 // Return the generated code. 2331 // Return the generated code.
2281 return cell.is_null() ? GetCode(function) : GetCode(Code::NORMAL, name); 2332 return GetCode(type, name);
2282 } 2333 }
2283 2334
2284 2335
2285 Handle<Code> CallStubCompiler::CompileMathFloorCall( 2336 Handle<Code> CallStubCompiler::CompileMathFloorCall(
2286 Handle<Object> object, 2337 Handle<Object> object,
2287 Handle<JSObject> holder, 2338 Handle<JSObject> holder,
2288 Handle<Cell> cell, 2339 Handle<Cell> cell,
2289 Handle<JSFunction> function, 2340 Handle<JSFunction> function,
2290 Handle<String> name) { 2341 Handle<String> name,
2342 Code::StubType type) {
2291 // ----------- S t a t e ------------- 2343 // ----------- S t a t e -------------
2292 // -- ecx : name 2344 // -- ecx : name
2293 // -- esp[0] : return address 2345 // -- esp[0] : return address
2294 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 2346 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
2295 // -- ... 2347 // -- ...
2296 // -- esp[(argc + 1) * 4] : receiver 2348 // -- esp[(argc + 1) * 4] : receiver
2297 // ----------------------------------- 2349 // -----------------------------------
2298 2350
2299 if (!CpuFeatures::IsSupported(SSE2)) { 2351 if (!CpuFeatures::IsSupported(SSE2)) {
2300 return Handle<Code>::null(); 2352 return Handle<Code>::null();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 __ bind(&slow); 2454 __ bind(&slow);
2403 ParameterCount expected(function); 2455 ParameterCount expected(function);
2404 __ InvokeFunction(function, expected, arguments(), 2456 __ InvokeFunction(function, expected, arguments(),
2405 JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); 2457 JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD);
2406 2458
2407 __ bind(&miss); 2459 __ bind(&miss);
2408 // ecx: function name. 2460 // ecx: function name.
2409 GenerateMissBranch(); 2461 GenerateMissBranch();
2410 2462
2411 // Return the generated code. 2463 // Return the generated code.
2412 return cell.is_null() ? GetCode(function) : GetCode(Code::NORMAL, name); 2464 return GetCode(type, name);
2413 } 2465 }
2414 2466
2415 2467
2416 Handle<Code> CallStubCompiler::CompileMathAbsCall( 2468 Handle<Code> CallStubCompiler::CompileMathAbsCall(
2417 Handle<Object> object, 2469 Handle<Object> object,
2418 Handle<JSObject> holder, 2470 Handle<JSObject> holder,
2419 Handle<Cell> cell, 2471 Handle<Cell> cell,
2420 Handle<JSFunction> function, 2472 Handle<JSFunction> function,
2421 Handle<String> name) { 2473 Handle<String> name,
2474 Code::StubType type) {
2422 // ----------- S t a t e ------------- 2475 // ----------- S t a t e -------------
2423 // -- ecx : name 2476 // -- ecx : name
2424 // -- esp[0] : return address 2477 // -- esp[0] : return address
2425 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 2478 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
2426 // -- ... 2479 // -- ...
2427 // -- esp[(argc + 1) * 4] : receiver 2480 // -- esp[(argc + 1) * 4] : receiver
2428 // ----------------------------------- 2481 // -----------------------------------
2429 2482
2430 const int argc = arguments().immediate(); 2483 const int argc = arguments().immediate();
2431 2484
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 __ bind(&slow); 2561 __ bind(&slow);
2509 ParameterCount expected(function); 2562 ParameterCount expected(function);
2510 __ InvokeFunction(function, expected, arguments(), 2563 __ InvokeFunction(function, expected, arguments(),
2511 JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); 2564 JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD);
2512 2565
2513 __ bind(&miss); 2566 __ bind(&miss);
2514 // ecx: function name. 2567 // ecx: function name.
2515 GenerateMissBranch(); 2568 GenerateMissBranch();
2516 2569
2517 // Return the generated code. 2570 // Return the generated code.
2518 return cell.is_null() ? GetCode(function) : GetCode(Code::NORMAL, name); 2571 return GetCode(type, name);
2519 } 2572 }
2520 2573
2521 2574
2522 Handle<Code> CallStubCompiler::CompileFastApiCall( 2575 Handle<Code> CallStubCompiler::CompileFastApiCall(
2523 const CallOptimization& optimization, 2576 const CallOptimization& optimization,
2524 Handle<Object> object, 2577 Handle<Object> object,
2525 Handle<JSObject> holder, 2578 Handle<JSObject> holder,
2526 Handle<Cell> cell, 2579 Handle<Cell> cell,
2527 Handle<JSFunction> function, 2580 Handle<JSFunction> function,
2528 Handle<String> name) { 2581 Handle<String> name) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2699 Handle<Code> CallStubCompiler::CompileCallConstant( 2752 Handle<Code> CallStubCompiler::CompileCallConstant(
2700 Handle<Object> object, 2753 Handle<Object> object,
2701 Handle<JSObject> holder, 2754 Handle<JSObject> holder,
2702 Handle<Name> name, 2755 Handle<Name> name,
2703 CheckType check, 2756 CheckType check,
2704 Handle<JSFunction> function) { 2757 Handle<JSFunction> function) {
2705 2758
2706 if (HasCustomCallGenerator(function)) { 2759 if (HasCustomCallGenerator(function)) {
2707 Handle<Code> code = CompileCustomCall(object, holder, 2760 Handle<Code> code = CompileCustomCall(object, holder,
2708 Handle<Cell>::null(), 2761 Handle<Cell>::null(),
2709 function, Handle<String>::cast(name)); 2762 function, Handle<String>::cast(name),
2763 Code::CONSTANT_FUNCTION);
2710 // A null handle means bail out to the regular compiler code below. 2764 // A null handle means bail out to the regular compiler code below.
2711 if (!code.is_null()) return code; 2765 if (!code.is_null()) return code;
2712 } 2766 }
2713 2767
2714 Label success; 2768 Label success;
2715 2769
2716 CompileHandlerFrontend(object, holder, name, check, &success); 2770 CompileHandlerFrontend(object, holder, name, check, &success);
2717 __ bind(&success); 2771 __ bind(&success);
2718 CompileHandlerBackend(function); 2772 CompileHandlerBackend(function);
2719 2773
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 // ----------- S t a t e ------------- 2844 // ----------- S t a t e -------------
2791 // -- ecx : name 2845 // -- ecx : name
2792 // -- esp[0] : return address 2846 // -- esp[0] : return address
2793 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 2847 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
2794 // -- ... 2848 // -- ...
2795 // -- esp[(argc + 1) * 4] : receiver 2849 // -- esp[(argc + 1) * 4] : receiver
2796 // ----------------------------------- 2850 // -----------------------------------
2797 2851
2798 if (HasCustomCallGenerator(function)) { 2852 if (HasCustomCallGenerator(function)) {
2799 Handle<Code> code = CompileCustomCall( 2853 Handle<Code> code = CompileCustomCall(
2800 object, holder, cell, function, Handle<String>::cast(name)); 2854 object, holder, cell, function, Handle<String>::cast(name),
2855 Code::NORMAL);
2801 // A null handle means bail out to the regular compiler code below. 2856 // A null handle means bail out to the regular compiler code below.
2802 if (!code.is_null()) return code; 2857 if (!code.is_null()) return code;
2803 } 2858 }
2804 2859
2805 Label miss; 2860 Label miss;
2806 GenerateNameCheck(name, &miss); 2861 GenerateNameCheck(name, &miss);
2807 2862
2808 // Get the number of arguments. 2863 // Get the number of arguments.
2809 const int argc = arguments().immediate(); 2864 const int argc = arguments().immediate();
2810 GenerateGlobalReceiverCheck(object, holder, name, &miss); 2865 GenerateGlobalReceiverCheck(object, holder, name, &miss);
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
3775 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); 3830 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
3776 } 3831 }
3777 } 3832 }
3778 3833
3779 3834
3780 #undef __ 3835 #undef __
3781 3836
3782 } } // namespace v8::internal 3837 } } // namespace v8::internal
3783 3838
3784 #endif // V8_TARGET_ARCH_IA32 3839 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698