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 2464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2475 if (!is_vector_set()) { | 2475 if (!is_vector_set()) { |
2476 ConfigureVectorState(MEGAMORPHIC, key); | 2476 ConfigureVectorState(MEGAMORPHIC, key); |
2477 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "set generic"); | 2477 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "set generic"); |
2478 } | 2478 } |
2479 TRACE_IC("StoreIC", key); | 2479 TRACE_IC("StoreIC", key); |
2480 | 2480 |
2481 return store_handle; | 2481 return store_handle; |
2482 } | 2482 } |
2483 | 2483 |
2484 | 2484 |
2485 void CallIC::HandleMiss(Handle<Object> function) { | |
2486 Handle<Object> name = isolate()->factory()->empty_string(); | |
2487 CallICNexus* nexus = casted_nexus<CallICNexus>(); | |
2488 Object* feedback = nexus->GetFeedback(); | |
2489 | |
2490 // Hand-coded MISS handling is easier if CallIC slots don't contain smis. | |
2491 DCHECK(!feedback->IsSmi()); | |
2492 | |
2493 if (feedback->IsWeakCell() || !function->IsJSFunction() || | |
2494 feedback->IsAllocationSite()) { | |
2495 // We are going generic. | |
2496 nexus->ConfigureMegamorphic(); | |
2497 } else { | |
2498 DCHECK(feedback == *TypeFeedbackVector::UninitializedSentinel(isolate())); | |
2499 Handle<JSFunction> js_function = Handle<JSFunction>::cast(function); | |
2500 | |
2501 Handle<JSFunction> array_function = | |
2502 Handle<JSFunction>(isolate()->native_context()->array_function()); | |
2503 if (array_function.is_identical_to(js_function)) { | |
2504 // Alter the slot. | |
2505 nexus->ConfigureMonomorphicArray(); | |
2506 } else if (js_function->context()->native_context() != | |
2507 *isolate()->native_context()) { | |
2508 // Don't collect cross-native context feedback for the CallIC. | |
2509 // TODO(bmeurer): We should collect the SharedFunctionInfo as | |
2510 // feedback in this case instead. | |
2511 nexus->ConfigureMegamorphic(); | |
2512 } else { | |
2513 nexus->ConfigureMonomorphic(js_function); | |
2514 } | |
2515 } | |
2516 | |
2517 if (function->IsJSFunction()) { | |
2518 Handle<JSFunction> js_function = Handle<JSFunction>::cast(function); | |
2519 name = handle(js_function->shared()->name(), isolate()); | |
2520 } | |
2521 | |
2522 OnTypeFeedbackChanged(isolate(), get_host()); | |
2523 TRACE_IC("CallIC", name); | |
2524 } | |
2525 | |
2526 | |
2527 #undef TRACE_IC | 2485 #undef TRACE_IC |
2528 | 2486 |
2529 | 2487 |
2530 // ---------------------------------------------------------------------------- | 2488 // ---------------------------------------------------------------------------- |
2531 // Static IC stub generators. | 2489 // Static IC stub generators. |
2532 // | 2490 // |
2533 | 2491 |
2534 // Used from ic-<arch>.cc. | 2492 // Used from ic-<arch>.cc. |
2535 RUNTIME_FUNCTION(Runtime_CallIC_Miss) { | |
2536 HandleScope scope(isolate); | |
2537 DCHECK_EQ(3, args.length()); | |
2538 // Runtime functions don't follow the IC's calling convention. | |
2539 Handle<Object> function = args.at(0); | |
2540 Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(1); | |
2541 Handle<Smi> slot = args.at<Smi>(2); | |
2542 FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value()); | |
2543 CallICNexus nexus(vector, vector_slot); | |
2544 CallIC ic(isolate, &nexus); | |
2545 ic.HandleMiss(function); | |
2546 return *function; | |
2547 } | |
2548 | |
2549 | |
2550 // Used from ic-<arch>.cc. | |
2551 RUNTIME_FUNCTION(Runtime_LoadIC_Miss) { | 2493 RUNTIME_FUNCTION(Runtime_LoadIC_Miss) { |
2552 HandleScope scope(isolate); | 2494 HandleScope scope(isolate); |
2553 DCHECK_EQ(4, args.length()); | 2495 DCHECK_EQ(4, args.length()); |
2554 // Runtime functions don't follow the IC's calling convention. | 2496 // Runtime functions don't follow the IC's calling convention. |
2555 Handle<Object> receiver = args.at(0); | 2497 Handle<Object> receiver = args.at(0); |
2556 Handle<Name> key = args.at<Name>(1); | 2498 Handle<Name> key = args.at<Name>(1); |
2557 Handle<Smi> slot = args.at<Smi>(2); | 2499 Handle<Smi> slot = args.at<Smi>(2); |
2558 Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3); | 2500 Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3); |
2559 FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value()); | 2501 FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value()); |
2560 // A monomorphic or polymorphic KeyedLoadIC with a string key can call the | 2502 // A monomorphic or polymorphic KeyedLoadIC with a string key can call the |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3198 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); | 3140 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); |
3199 it.Next(); | 3141 it.Next(); |
3200 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 3142 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
3201 Object::GetProperty(&it)); | 3143 Object::GetProperty(&it)); |
3202 } | 3144 } |
3203 | 3145 |
3204 return *result; | 3146 return *result; |
3205 } | 3147 } |
3206 } // namespace internal | 3148 } // namespace internal |
3207 } // namespace v8 | 3149 } // namespace v8 |
OLD | NEW |