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

Side by Side Diff: src/ic.cc

Issue 12221064: Implement many KeyedStoreStubs using Crankshaft (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Final review feedback Created 7 years, 9 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/ic.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 if (state == UNINITIALIZED) { 1348 if (state == UNINITIALIZED) {
1349 stub = string_stub(); 1349 stub = string_stub();
1350 } 1350 }
1351 } else if (object->IsJSObject()) { 1351 } else if (object->IsJSObject()) {
1352 Handle<JSObject> receiver = Handle<JSObject>::cast(object); 1352 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1353 if (receiver->elements()->map() == 1353 if (receiver->elements()->map() ==
1354 isolate()->heap()->non_strict_arguments_elements_map()) { 1354 isolate()->heap()->non_strict_arguments_elements_map()) {
1355 stub = non_strict_arguments_stub(); 1355 stub = non_strict_arguments_stub();
1356 } else if (receiver->HasIndexedInterceptor()) { 1356 } else if (receiver->HasIndexedInterceptor()) {
1357 stub = indexed_interceptor_stub(); 1357 stub = indexed_interceptor_stub();
1358 } else if (key->IsSmi() && (target() != *non_strict_arguments_stub())) { 1358 } else if (!key->ToSmi()->IsFailure() &&
1359 (target() != *non_strict_arguments_stub())) {
1359 stub = LoadElementStub(receiver); 1360 stub = LoadElementStub(receiver);
1360 } 1361 }
1361 } 1362 }
1362 } else { 1363 } else {
1363 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "force generic"); 1364 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "force generic");
1364 } 1365 }
1365 ASSERT(!stub.is_null()); 1366 ASSERT(!stub.is_null());
1366 set_target(*stub); 1367 set_target(*stub);
1367 TRACE_IC("KeyedLoadIC", key, state, target()); 1368 TRACE_IC("KeyedLoadIC", key, state, target());
1368 } 1369 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 KeyedAccessStoreMode store_mode, 1643 KeyedAccessStoreMode store_mode,
1643 StrictModeFlag strict_mode) { 1644 StrictModeFlag strict_mode) {
1644 // Don't handle megamorphic property accesses for INTERCEPTORS or CALLBACKS 1645 // Don't handle megamorphic property accesses for INTERCEPTORS or CALLBACKS
1645 // via megamorphic stubs, since they don't have a map in their relocation info 1646 // via megamorphic stubs, since they don't have a map in their relocation info
1646 // and so the stubs can't be harvested for the object needed for a map check. 1647 // and so the stubs can't be harvested for the object needed for a map check.
1647 if (target()->type() != Code::NORMAL) { 1648 if (target()->type() != Code::NORMAL) {
1648 TRACE_GENERIC_IC(isolate(), "KeyedIC", "non-NORMAL target type"); 1649 TRACE_GENERIC_IC(isolate(), "KeyedIC", "non-NORMAL target type");
1649 return strict_mode == kStrictMode ? generic_stub_strict() : generic_stub(); 1650 return strict_mode == kStrictMode ? generic_stub_strict() : generic_stub();
1650 } 1651 }
1651 1652
1652 if ((store_mode == STORE_NO_TRANSITION_HANDLE_COW || 1653 if (!FLAG_compiled_keyed_stores &&
1654 (store_mode == STORE_NO_TRANSITION_HANDLE_COW ||
1653 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS)) { 1655 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS)) {
1654 // TODO(danno): We'll soon handle MONOMORPHIC ICs that also support 1656 // TODO(danno): We'll soon handle MONOMORPHIC ICs that also support
1655 // copying COW arrays and silently ignoring some OOB stores into external 1657 // copying COW arrays and silently ignoring some OOB stores into external
1656 // arrays, but for now use the generic. 1658 // arrays, but for now use the generic.
1657 TRACE_GENERIC_IC(isolate(), "KeyedIC", "COW/OOB external array"); 1659 TRACE_GENERIC_IC(isolate(), "KeyedIC", "COW/OOB external array");
1658 return strict_mode == kStrictMode 1660 return strict_mode == kStrictMode
1659 ? generic_stub_strict() 1661 ? generic_stub_strict()
1660 : generic_stub(); 1662 : generic_stub();
1661 } 1663 }
1662 1664
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 transitioned_kind); 1707 transitioned_kind);
1706 Map* transitioned_previous_map = more_general_transition 1708 Map* transitioned_previous_map = more_general_transition
1707 ? previous_receiver_map->LookupElementsTransitionMap(transitioned_kind) 1709 ? previous_receiver_map->LookupElementsTransitionMap(transitioned_kind)
1708 : NULL; 1710 : NULL;
1709 if (transitioned_previous_map == *transitioned_receiver_map) { 1711 if (transitioned_previous_map == *transitioned_receiver_map) {
1710 // Element family is the same, use the "worst" case map. 1712 // Element family is the same, use the "worst" case map.
1711 store_mode = GetNonTransitioningStoreMode(store_mode); 1713 store_mode = GetNonTransitioningStoreMode(store_mode);
1712 return isolate()->stub_cache()->ComputeKeyedStoreElement( 1714 return isolate()->stub_cache()->ComputeKeyedStoreElement(
1713 transitioned_receiver_map, strict_mode, store_mode); 1715 transitioned_receiver_map, strict_mode, store_mode);
1714 } else if (*previous_receiver_map == receiver->map()) { 1716 } else if (*previous_receiver_map == receiver->map()) {
1715 if (IsGrowStoreMode(store_mode)) { 1717 if (IsGrowStoreMode(store_mode) ||
1718 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
1719 store_mode == STORE_NO_TRANSITION_HANDLE_COW) {
1716 // A "normal" IC that handles stores can switch to a version that can 1720 // A "normal" IC that handles stores can switch to a version that can
1717 // grow at the end of the array and still stay MONOMORPHIC. 1721 // grow at the end of the array, handle OOB accesses or copy COW arrays
1722 // and still stay MONOMORPHIC.
1718 return isolate()->stub_cache()->ComputeKeyedStoreElement( 1723 return isolate()->stub_cache()->ComputeKeyedStoreElement(
1719 receiver_map, strict_mode, store_mode); 1724 receiver_map, strict_mode, store_mode);
1720 } 1725 }
1721 } 1726 }
1722 } 1727 }
1723 1728
1724 ASSERT(ic_state != GENERIC); 1729 ASSERT(ic_state != GENERIC);
1725 1730
1726 bool map_added = 1731 bool map_added =
1727 AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map); 1732 AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 return JSArray::cast(*receiver)->length()->IsSmi() && 1811 return JSArray::cast(*receiver)->length()->IsSmi() &&
1807 index >= Smi::cast(JSArray::cast(*receiver)->length())->value(); 1812 index >= Smi::cast(JSArray::cast(*receiver)->length())->value();
1808 } 1813 }
1809 return index >= receiver->elements()->length(); 1814 return index >= receiver->elements()->length();
1810 } 1815 }
1811 1816
1812 1817
1813 KeyedAccessStoreMode KeyedStoreIC::GetStoreMode(Handle<JSObject> receiver, 1818 KeyedAccessStoreMode KeyedStoreIC::GetStoreMode(Handle<JSObject> receiver,
1814 Handle<Object> key, 1819 Handle<Object> key,
1815 Handle<Object> value) { 1820 Handle<Object> value) {
1816 ASSERT(key->IsSmi()); 1821 ASSERT(!key->ToSmi()->IsFailure());
1817 int index = Smi::cast(*key)->value(); 1822 Smi* smi_key = NULL;
1823 key->ToSmi()->To(&smi_key);
1824 int index = smi_key->value();
1818 bool oob_access = IsOutOfBoundsAccess(receiver, index); 1825 bool oob_access = IsOutOfBoundsAccess(receiver, index);
1819 bool allow_growth = receiver->IsJSArray() && oob_access; 1826 bool allow_growth = receiver->IsJSArray() && oob_access;
1820 if (allow_growth) { 1827 if (allow_growth) {
1821 // Handle growing array in stub if necessary. 1828 // Handle growing array in stub if necessary.
1822 if (receiver->HasFastSmiElements()) { 1829 if (receiver->HasFastSmiElements()) {
1823 if (value->IsHeapNumber()) { 1830 if (value->IsHeapNumber()) {
1824 if (receiver->HasFastHoleyElements()) { 1831 if (receiver->HasFastHoleyElements()) {
1825 return STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_DOUBLE; 1832 return STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_DOUBLE;
1826 } else { 1833 } else {
1827 return STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE; 1834 return STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 if (receiver->HasFastHoleyElements()) { 1872 if (receiver->HasFastHoleyElements()) {
1866 return STORE_TRANSITION_HOLEY_DOUBLE_TO_OBJECT; 1873 return STORE_TRANSITION_HOLEY_DOUBLE_TO_OBJECT;
1867 } else { 1874 } else {
1868 return STORE_TRANSITION_DOUBLE_TO_OBJECT; 1875 return STORE_TRANSITION_DOUBLE_TO_OBJECT;
1869 } 1876 }
1870 } 1877 }
1871 } 1878 }
1872 if (!FLAG_trace_external_array_abuse && 1879 if (!FLAG_trace_external_array_abuse &&
1873 receiver->map()->has_external_array_elements() && oob_access) { 1880 receiver->map()->has_external_array_elements() && oob_access) {
1874 return STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS; 1881 return STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS;
1882 }
1883 Heap* heap = receiver->GetHeap();
1884 if (receiver->elements()->map() == heap->fixed_cow_array_map()) {
1885 return STORE_NO_TRANSITION_HANDLE_COW;
1875 } else { 1886 } else {
1876 return STANDARD_STORE; 1887 return STANDARD_STORE;
1877 } 1888 }
1878 } 1889 }
1879 } 1890 }
1880 1891
1881 1892
1882 MaybeObject* KeyedStoreIC::Store(State state, 1893 MaybeObject* KeyedStoreIC::Store(State state,
1883 StrictModeFlag strict_mode, 1894 StrictModeFlag strict_mode,
1884 Handle<Object> object, 1895 Handle<Object> object,
(...skipping 18 matching lines...) Expand all
1903 JSObject::cast(*object)->map()->is_observed()); 1914 JSObject::cast(*object)->map()->is_observed());
1904 ASSERT(!(use_ic && object->IsJSGlobalProxy())); 1915 ASSERT(!(use_ic && object->IsJSGlobalProxy()));
1905 1916
1906 if (use_ic) { 1917 if (use_ic) {
1907 Handle<Code> stub = (strict_mode == kStrictMode) 1918 Handle<Code> stub = (strict_mode == kStrictMode)
1908 ? generic_stub_strict() 1919 ? generic_stub_strict()
1909 : generic_stub(); 1920 : generic_stub();
1910 if (miss_mode != MISS_FORCE_GENERIC) { 1921 if (miss_mode != MISS_FORCE_GENERIC) {
1911 if (object->IsJSObject()) { 1922 if (object->IsJSObject()) {
1912 Handle<JSObject> receiver = Handle<JSObject>::cast(object); 1923 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1924 bool key_is_smi_like = key->IsSmi() ||
1925 (FLAG_compiled_keyed_stores && !key->ToSmi()->IsFailure());
1913 if (receiver->elements()->map() == 1926 if (receiver->elements()->map() ==
1914 isolate()->heap()->non_strict_arguments_elements_map()) { 1927 isolate()->heap()->non_strict_arguments_elements_map()) {
1915 stub = non_strict_arguments_stub(); 1928 stub = non_strict_arguments_stub();
1916 } else if (key->IsSmi() && (target() != *non_strict_arguments_stub())) { 1929 } else if (key_is_smi_like &&
1930 (target() != *non_strict_arguments_stub())) {
1917 KeyedAccessStoreMode store_mode = GetStoreMode(receiver, key, value); 1931 KeyedAccessStoreMode store_mode = GetStoreMode(receiver, key, value);
1918 stub = StoreElementStub(receiver, store_mode, strict_mode); 1932 stub = StoreElementStub(receiver, store_mode, strict_mode);
1933 } else {
1934 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "key not a number");
1919 } 1935 }
1936 } else {
1937 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "not an object");
1920 } 1938 }
1921 } else { 1939 } else {
1922 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "force generic"); 1940 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "force generic");
1923 } 1941 }
1924 ASSERT(!stub.is_null()); 1942 ASSERT(!stub.is_null());
1925 set_target(*stub); 1943 set_target(*stub);
1926 TRACE_IC("KeyedStoreIC", key, state, target()); 1944 TRACE_IC("KeyedStoreIC", key, state, target());
1927 } 1945 }
1928 1946
1929 return Runtime::SetObjectProperty( 1947 return Runtime::SetObjectProperty(
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 args.at<Object>(0), 2085 args.at<Object>(0),
2068 args.at<Object>(1), 2086 args.at<Object>(1),
2069 MISS_FORCE_GENERIC); 2087 MISS_FORCE_GENERIC);
2070 } 2088 }
2071 2089
2072 2090
2073 // Used from ic-<arch>.cc. 2091 // Used from ic-<arch>.cc.
2074 RUNTIME_FUNCTION(MaybeObject*, StoreIC_Miss) { 2092 RUNTIME_FUNCTION(MaybeObject*, StoreIC_Miss) {
2075 HandleScope scope(isolate); 2093 HandleScope scope(isolate);
2076 ASSERT(args.length() == 3); 2094 ASSERT(args.length() == 3);
2077 StoreIC ic(isolate); 2095 StoreIC ic(IC::NO_EXTRA_FRAME, isolate);
2078 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); 2096 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
2079 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); 2097 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2080 return ic.Store(state, 2098 return ic.Store(state,
2081 Code::GetStrictMode(extra_ic_state), 2099 Code::GetStrictMode(extra_ic_state),
2082 args.at<Object>(0), 2100 args.at<Object>(0),
2083 args.at<String>(1), 2101 args.at<String>(1),
2084 args.at<Object>(2)); 2102 args.at<Object>(2));
2085 } 2103 }
2086 2104
2087 2105
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 2161
2144 // Return the stored value. 2162 // Return the stored value.
2145 return value; 2163 return value;
2146 } 2164 }
2147 2165
2148 2166
2149 // Used from ic-<arch>.cc. 2167 // Used from ic-<arch>.cc.
2150 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Miss) { 2168 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Miss) {
2151 HandleScope scope(isolate); 2169 HandleScope scope(isolate);
2152 ASSERT(args.length() == 3); 2170 ASSERT(args.length() == 3);
2153 KeyedStoreIC ic(isolate); 2171 KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate);
2154 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); 2172 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
2155 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); 2173 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2156 return ic.Store(state, 2174 return ic.Store(state,
2175 Code::GetStrictMode(extra_ic_state),
2176 args.at<Object>(0),
2177 args.at<Object>(1),
2178 args.at<Object>(2),
2179 MISS);
2180 }
2181
2182
2183 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure) {
2184 HandleScope scope(isolate);
2185 ASSERT(args.length() == 3);
2186 KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate);
2187 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
2188 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2189 return ic.Store(state,
2157 Code::GetStrictMode(extra_ic_state), 2190 Code::GetStrictMode(extra_ic_state),
2158 args.at<Object>(0), 2191 args.at<Object>(0),
2159 args.at<Object>(1), 2192 args.at<Object>(1),
2160 args.at<Object>(2), 2193 args.at<Object>(2),
2161 MISS); 2194 MISS);
2162 } 2195 }
2163 2196
2164 2197
2165 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) { 2198 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) {
2166 NoHandleAllocation na(isolate); 2199 NoHandleAllocation na(isolate);
2167 ASSERT(args.length() == 3); 2200 ASSERT(args.length() == 3);
2168 KeyedStoreIC ic(isolate); 2201 KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate);
2169 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); 2202 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2170 Handle<Object> object = args.at<Object>(0); 2203 Handle<Object> object = args.at<Object>(0);
2171 Handle<Object> key = args.at<Object>(1); 2204 Handle<Object> key = args.at<Object>(1);
2172 Handle<Object> value = args.at<Object>(2); 2205 Handle<Object> value = args.at<Object>(2);
2173 StrictModeFlag strict_mode = Code::GetStrictMode(extra_ic_state); 2206 StrictModeFlag strict_mode = Code::GetStrictMode(extra_ic_state);
2174 return Runtime::SetObjectProperty(isolate, 2207 return Runtime::SetObjectProperty(isolate,
2175 object, 2208 object,
2176 key, 2209 key,
2177 value, 2210 value,
2178 NONE, 2211 NONE,
2179 strict_mode); 2212 strict_mode);
2180 } 2213 }
2181 2214
2182 2215
2183 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissForceGeneric) { 2216 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissForceGeneric) {
2184 HandleScope scope(isolate); 2217 HandleScope scope(isolate);
2185 ASSERT(args.length() == 3); 2218 ASSERT(args.length() == 3);
2186 KeyedStoreIC ic(isolate); 2219 KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate);
2187 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); 2220 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
2188 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); 2221 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2189 return ic.Store(state, 2222 return ic.Store(state,
2190 Code::GetStrictMode(extra_ic_state), 2223 Code::GetStrictMode(extra_ic_state),
2191 args.at<Object>(0), 2224 args.at<Object>(0),
2192 args.at<Object>(1), 2225 args.at<Object>(1),
2193 args.at<Object>(2), 2226 args.at<Object>(2),
2194 MISS_FORCE_GENERIC); 2227 MISS_FORCE_GENERIC);
2195 } 2228 }
2196 2229
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 #undef ADDR 2770 #undef ADDR
2738 }; 2771 };
2739 2772
2740 2773
2741 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2774 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2742 return IC_utilities[id]; 2775 return IC_utilities[id];
2743 } 2776 }
2744 2777
2745 2778
2746 } } // namespace v8::internal 2779 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698