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 2404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2415 // expect to be able to trap element sets to objects with those maps in | 2415 // expect to be able to trap element sets to objects with those maps in |
2416 // the runtime to enable optimization of element hole access. | 2416 // the runtime to enable optimization of element hole access. |
2417 Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object); | 2417 Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object); |
2418 if (heap_object->map()->IsMapInArrayPrototypeChain()) { | 2418 if (heap_object->map()->IsMapInArrayPrototypeChain()) { |
2419 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "map in array prototype"); | 2419 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "map in array prototype"); |
2420 use_ic = false; | 2420 use_ic = false; |
2421 } | 2421 } |
2422 } | 2422 } |
2423 | 2423 |
2424 Handle<Map> old_receiver_map; | 2424 Handle<Map> old_receiver_map; |
2425 bool sloppy_arguments_elements = false; | 2425 bool is_arguments = false; |
2426 bool key_is_valid_index = false; | 2426 bool key_is_valid_index = false; |
2427 KeyedAccessStoreMode store_mode = STANDARD_STORE; | 2427 KeyedAccessStoreMode store_mode = STANDARD_STORE; |
2428 if (use_ic && object->IsJSObject()) { | 2428 if (use_ic && object->IsJSObject()) { |
2429 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 2429 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
2430 old_receiver_map = handle(receiver->map(), isolate()); | 2430 old_receiver_map = handle(receiver->map(), isolate()); |
2431 sloppy_arguments_elements = | 2431 is_arguments = receiver->IsJSArgumentsObject(); |
2432 !is_sloppy(language_mode()) && | 2432 if (!is_arguments) { |
2433 receiver->elements()->map() == | |
2434 isolate()->heap()->sloppy_arguments_elements_map(); | |
2435 if (!sloppy_arguments_elements) { | |
2436 key_is_valid_index = key->IsSmi() && Smi::cast(*key)->value() >= 0; | 2433 key_is_valid_index = key->IsSmi() && Smi::cast(*key)->value() >= 0; |
2437 if (key_is_valid_index) { | 2434 if (key_is_valid_index) { |
2438 uint32_t index = static_cast<uint32_t>(Smi::cast(*key)->value()); | 2435 uint32_t index = static_cast<uint32_t>(Smi::cast(*key)->value()); |
2439 store_mode = GetStoreMode(receiver, index, value); | 2436 store_mode = GetStoreMode(receiver, index, value); |
2440 } | 2437 } |
2441 } | 2438 } |
2442 } | 2439 } |
2443 | 2440 |
2444 DCHECK(store_handle.is_null()); | 2441 DCHECK(store_handle.is_null()); |
2445 ASSIGN_RETURN_ON_EXCEPTION(isolate(), store_handle, | 2442 ASSIGN_RETURN_ON_EXCEPTION(isolate(), store_handle, |
2446 Runtime::SetObjectProperty(isolate(), object, key, | 2443 Runtime::SetObjectProperty(isolate(), object, key, |
2447 value, language_mode()), | 2444 value, language_mode()), |
2448 Object); | 2445 Object); |
2449 | 2446 |
2450 if (use_ic) { | 2447 if (use_ic) { |
2451 if (!old_receiver_map.is_null()) { | 2448 if (!old_receiver_map.is_null()) { |
2452 if (sloppy_arguments_elements) { | 2449 if (is_arguments) { |
2453 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "arguments receiver"); | 2450 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "arguments receiver"); |
2454 } else if (key_is_valid_index) { | 2451 } else if (key_is_valid_index) { |
2455 // We should go generic if receiver isn't a dictionary, but our | 2452 // We should go generic if receiver isn't a dictionary, but our |
2456 // prototype chain does have dictionary elements. This ensures that | 2453 // prototype chain does have dictionary elements. This ensures that |
2457 // other non-dictionary receivers in the polymorphic case benefit | 2454 // other non-dictionary receivers in the polymorphic case benefit |
2458 // from fast path keyed stores. | 2455 // from fast path keyed stores. |
2459 if (!old_receiver_map->DictionaryElementsInPrototypeChainOnly()) { | 2456 if (!old_receiver_map->DictionaryElementsInPrototypeChainOnly()) { |
2460 UpdateStoreElement(old_receiver_map, store_mode); | 2457 UpdateStoreElement(old_receiver_map, store_mode); |
2461 } else { | 2458 } else { |
2462 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", | 2459 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3215 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); | 3212 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); |
3216 it.Next(); | 3213 it.Next(); |
3217 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 3214 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
3218 Object::GetProperty(&it)); | 3215 Object::GetProperty(&it)); |
3219 } | 3216 } |
3220 | 3217 |
3221 return *result; | 3218 return *result; |
3222 } | 3219 } |
3223 } // namespace internal | 3220 } // namespace internal |
3224 } // namespace v8 | 3221 } // namespace v8 |
OLD | NEW |