OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/ic/ic.h" | 5 #include "src/ic/ic.h" |
6 | 6 |
7 #include <iostream> | 7 #include <iostream> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/api-arguments-inl.h" | 10 #include "src/api-arguments-inl.h" |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 } else { | 596 } else { |
597 DCHECK(kind() == Code::KEYED_STORE_IC); | 597 DCHECK(kind() == Code::KEYED_STORE_IC); |
598 KeyedStoreICNexus* nexus = casted_nexus<KeyedStoreICNexus>(); | 598 KeyedStoreICNexus* nexus = casted_nexus<KeyedStoreICNexus>(); |
599 nexus->ConfigurePolymorphic(name, maps, handlers); | 599 nexus->ConfigurePolymorphic(name, maps, handlers); |
600 } | 600 } |
601 | 601 |
602 vector_set_ = true; | 602 vector_set_ = true; |
603 OnTypeFeedbackChanged(isolate(), get_host()); | 603 OnTypeFeedbackChanged(isolate(), get_host()); |
604 } | 604 } |
605 | 605 |
606 | |
607 void IC::ConfigureVectorState(MapHandleList* maps, | 606 void IC::ConfigureVectorState(MapHandleList* maps, |
608 MapHandleList* transitioned_maps, | 607 MapHandleList* transitioned_maps, |
609 CodeHandleList* handlers) { | 608 List<Handle<Object>>* handlers) { |
610 DCHECK(UseVector()); | 609 DCHECK(UseVector()); |
611 DCHECK(kind() == Code::KEYED_STORE_IC); | 610 DCHECK(kind() == Code::KEYED_STORE_IC); |
612 KeyedStoreICNexus* nexus = casted_nexus<KeyedStoreICNexus>(); | 611 KeyedStoreICNexus* nexus = casted_nexus<KeyedStoreICNexus>(); |
613 nexus->ConfigurePolymorphic(maps, transitioned_maps, handlers); | 612 nexus->ConfigurePolymorphic(maps, transitioned_maps, handlers); |
614 | 613 |
615 vector_set_ = true; | 614 vector_set_ = true; |
616 OnTypeFeedbackChanged(isolate(), get_host()); | 615 OnTypeFeedbackChanged(isolate(), get_host()); |
617 } | 616 } |
618 | 617 |
619 | 618 |
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 } | 2200 } |
2202 | 2201 |
2203 void KeyedStoreIC::UpdateStoreElement(Handle<Map> receiver_map, | 2202 void KeyedStoreIC::UpdateStoreElement(Handle<Map> receiver_map, |
2204 KeyedAccessStoreMode store_mode) { | 2203 KeyedAccessStoreMode store_mode) { |
2205 MapHandleList target_receiver_maps; | 2204 MapHandleList target_receiver_maps; |
2206 TargetMaps(&target_receiver_maps); | 2205 TargetMaps(&target_receiver_maps); |
2207 if (target_receiver_maps.length() == 0) { | 2206 if (target_receiver_maps.length() == 0) { |
2208 Handle<Map> monomorphic_map = | 2207 Handle<Map> monomorphic_map = |
2209 ComputeTransitionedMap(receiver_map, store_mode); | 2208 ComputeTransitionedMap(receiver_map, store_mode); |
2210 store_mode = GetNonTransitioningStoreMode(store_mode); | 2209 store_mode = GetNonTransitioningStoreMode(store_mode); |
2211 Handle<Code> handler = | 2210 Handle<Object> handler = |
2212 PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(monomorphic_map, | 2211 PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(monomorphic_map, |
2213 store_mode); | 2212 store_mode); |
2214 return ConfigureVectorState(Handle<Name>(), monomorphic_map, handler); | 2213 return ConfigureVectorState(Handle<Name>(), monomorphic_map, handler); |
2215 } | 2214 } |
2216 | 2215 |
2217 for (int i = 0; i < target_receiver_maps.length(); i++) { | 2216 for (int i = 0; i < target_receiver_maps.length(); i++) { |
2218 if (!target_receiver_maps.at(i).is_null() && | 2217 if (!target_receiver_maps.at(i).is_null() && |
2219 target_receiver_maps.at(i)->instance_type() == JS_VALUE_TYPE) { | 2218 target_receiver_maps.at(i)->instance_type() == JS_VALUE_TYPE) { |
2220 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "JSValue"); | 2219 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "JSValue"); |
2221 return; | 2220 return; |
(...skipping 13 matching lines...) Expand all Loading... |
2235 ComputeTransitionedMap(receiver_map, store_mode); | 2234 ComputeTransitionedMap(receiver_map, store_mode); |
2236 } | 2235 } |
2237 if ((receiver_map.is_identical_to(previous_receiver_map) && | 2236 if ((receiver_map.is_identical_to(previous_receiver_map) && |
2238 IsTransitionStoreMode(store_mode)) || | 2237 IsTransitionStoreMode(store_mode)) || |
2239 IsTransitionOfMonomorphicTarget(*previous_receiver_map, | 2238 IsTransitionOfMonomorphicTarget(*previous_receiver_map, |
2240 *transitioned_receiver_map)) { | 2239 *transitioned_receiver_map)) { |
2241 // If the "old" and "new" maps are in the same elements map family, or | 2240 // If the "old" and "new" maps are in the same elements map family, or |
2242 // if they at least come from the same origin for a transitioning store, | 2241 // if they at least come from the same origin for a transitioning store, |
2243 // stay MONOMORPHIC and use the map for the most generic ElementsKind. | 2242 // stay MONOMORPHIC and use the map for the most generic ElementsKind. |
2244 store_mode = GetNonTransitioningStoreMode(store_mode); | 2243 store_mode = GetNonTransitioningStoreMode(store_mode); |
2245 Handle<Code> handler = | 2244 Handle<Object> handler = |
2246 PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler( | 2245 PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler( |
2247 transitioned_receiver_map, store_mode); | 2246 transitioned_receiver_map, store_mode); |
2248 ConfigureVectorState(Handle<Name>(), transitioned_receiver_map, handler); | 2247 ConfigureVectorState(Handle<Name>(), transitioned_receiver_map, handler); |
2249 return; | 2248 return; |
2250 } | 2249 } |
2251 if (receiver_map.is_identical_to(previous_receiver_map) && | 2250 if (receiver_map.is_identical_to(previous_receiver_map) && |
2252 old_store_mode == STANDARD_STORE && | 2251 old_store_mode == STANDARD_STORE && |
2253 (store_mode == STORE_AND_GROW_NO_TRANSITION || | 2252 (store_mode == STORE_AND_GROW_NO_TRANSITION || |
2254 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || | 2253 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || |
2255 store_mode == STORE_NO_TRANSITION_HANDLE_COW)) { | 2254 store_mode == STORE_NO_TRANSITION_HANDLE_COW)) { |
2256 // A "normal" IC that handles stores can switch to a version that can | 2255 // A "normal" IC that handles stores can switch to a version that can |
2257 // grow at the end of the array, handle OOB accesses or copy COW arrays | 2256 // grow at the end of the array, handle OOB accesses or copy COW arrays |
2258 // and still stay MONOMORPHIC. | 2257 // and still stay MONOMORPHIC. |
2259 Handle<Code> handler = | 2258 Handle<Object> handler = |
2260 PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(receiver_map, | 2259 PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(receiver_map, |
2261 store_mode); | 2260 store_mode); |
2262 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); | 2261 return ConfigureVectorState(Handle<Name>(), receiver_map, handler); |
2263 } | 2262 } |
2264 } | 2263 } |
2265 | 2264 |
2266 DCHECK(state() != GENERIC); | 2265 DCHECK(state() != GENERIC); |
2267 | 2266 |
2268 bool map_added = | 2267 bool map_added = |
2269 AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map); | 2268 AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2310 } | 2309 } |
2311 if (external_arrays != 0 && | 2310 if (external_arrays != 0 && |
2312 external_arrays != target_receiver_maps.length()) { | 2311 external_arrays != target_receiver_maps.length()) { |
2313 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", | 2312 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", |
2314 "unsupported combination of external and normal arrays"); | 2313 "unsupported combination of external and normal arrays"); |
2315 return; | 2314 return; |
2316 } | 2315 } |
2317 } | 2316 } |
2318 | 2317 |
2319 MapHandleList transitioned_maps(target_receiver_maps.length()); | 2318 MapHandleList transitioned_maps(target_receiver_maps.length()); |
2320 CodeHandleList handlers(target_receiver_maps.length()); | 2319 List<Handle<Object>> handlers(target_receiver_maps.length()); |
2321 PropertyICCompiler::ComputeKeyedStorePolymorphicHandlers( | 2320 PropertyICCompiler::ComputeKeyedStorePolymorphicHandlers( |
2322 &target_receiver_maps, &transitioned_maps, &handlers, store_mode); | 2321 &target_receiver_maps, &transitioned_maps, &handlers, store_mode); |
2323 ConfigureVectorState(&target_receiver_maps, &transitioned_maps, &handlers); | 2322 ConfigureVectorState(&target_receiver_maps, &transitioned_maps, &handlers); |
2324 } | 2323 } |
2325 | 2324 |
2326 | 2325 |
2327 Handle<Map> KeyedStoreIC::ComputeTransitionedMap( | 2326 Handle<Map> KeyedStoreIC::ComputeTransitionedMap( |
2328 Handle<Map> map, KeyedAccessStoreMode store_mode) { | 2327 Handle<Map> map, KeyedAccessStoreMode store_mode) { |
2329 switch (store_mode) { | 2328 switch (store_mode) { |
2330 case STORE_TRANSITION_TO_OBJECT: | 2329 case STORE_TRANSITION_TO_OBJECT: |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3224 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); | 3223 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); |
3225 it.Next(); | 3224 it.Next(); |
3226 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 3225 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
3227 Object::GetProperty(&it)); | 3226 Object::GetProperty(&it)); |
3228 } | 3227 } |
3229 | 3228 |
3230 return *result; | 3229 return *result; |
3231 } | 3230 } |
3232 } // namespace internal | 3231 } // namespace internal |
3233 } // namespace v8 | 3232 } // namespace v8 |
OLD | NEW |