Chromium Code Reviews| 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 "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/api-arguments.h" | 9 #include "src/api-arguments.h" |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1017 TRACE_HANDLER_STATS(isolate(), LoadIC_FunctionPrototypeStub); | 1017 TRACE_HANDLER_STATS(isolate(), LoadIC_FunctionPrototypeStub); |
| 1018 FunctionPrototypeStub function_prototype_stub(isolate()); | 1018 FunctionPrototypeStub function_prototype_stub(isolate()); |
| 1019 return function_prototype_stub.GetCode(); | 1019 return function_prototype_stub.GetCode(); |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 Handle<Map> map = receiver_map(); | 1022 Handle<Map> map = receiver_map(); |
| 1023 Handle<JSObject> holder = lookup->GetHolder<JSObject>(); | 1023 Handle<JSObject> holder = lookup->GetHolder<JSObject>(); |
| 1024 bool receiver_is_holder = receiver.is_identical_to(holder); | 1024 bool receiver_is_holder = receiver.is_identical_to(holder); |
| 1025 switch (lookup->state()) { | 1025 switch (lookup->state()) { |
| 1026 case LookupIterator::INTERCEPTOR: { | 1026 case LookupIterator::INTERCEPTOR: { |
| 1027 if (!receiver->IsJSReceiver()) break; | |
|
Toon Verwaest
2016/05/11 14:19:36
This shouldn't be necessary given your change belo
| |
| 1027 DCHECK(!holder->GetNamedInterceptor()->getter()->IsUndefined()); | 1028 DCHECK(!holder->GetNamedInterceptor()->getter()->IsUndefined()); |
| 1028 TRACE_HANDLER_STATS(isolate(), LoadIC_LoadInterceptor); | 1029 TRACE_HANDLER_STATS(isolate(), LoadIC_LoadInterceptor); |
| 1029 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder); | 1030 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder); |
| 1030 // Perform a lookup behind the interceptor. Copy the LookupIterator since | 1031 // Perform a lookup behind the interceptor. Copy the LookupIterator since |
| 1031 // the original iterator will be used to fetch the value. | 1032 // the original iterator will be used to fetch the value. |
| 1032 LookupIterator it = *lookup; | 1033 LookupIterator it = *lookup; |
| 1033 it.Next(); | 1034 it.Next(); |
| 1034 LookupForRead(&it); | 1035 LookupForRead(&it); |
| 1035 return compiler.CompileLoadInterceptor(&it); | 1036 return compiler.CompileLoadInterceptor(&it); |
| 1036 } | 1037 } |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1544 break; | 1545 break; |
| 1545 } | 1546 } |
| 1546 | 1547 |
| 1547 DCHECK(lookup->IsCacheableTransition()); | 1548 DCHECK(lookup->IsCacheableTransition()); |
| 1548 TRACE_HANDLER_STATS(isolate(), StoreIC_StoreTransition); | 1549 TRACE_HANDLER_STATS(isolate(), StoreIC_StoreTransition); |
| 1549 NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder); | 1550 NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder); |
| 1550 return compiler.CompileStoreTransition(transition, lookup->name()); | 1551 return compiler.CompileStoreTransition(transition, lookup->name()); |
| 1551 } | 1552 } |
| 1552 | 1553 |
| 1553 case LookupIterator::INTERCEPTOR: { | 1554 case LookupIterator::INTERCEPTOR: { |
| 1555 DCHECK(receiver->IsJSReceiver()); | |
| 1554 DCHECK(!holder->GetNamedInterceptor()->setter()->IsUndefined()); | 1556 DCHECK(!holder->GetNamedInterceptor()->setter()->IsUndefined()); |
| 1555 TRACE_HANDLER_STATS(isolate(), StoreIC_StoreInterceptorStub); | 1557 TRACE_HANDLER_STATS(isolate(), StoreIC_StoreInterceptorStub); |
| 1556 StoreInterceptorStub stub(isolate()); | 1558 StoreInterceptorStub stub(isolate()); |
| 1557 return stub.GetCode(); | 1559 return stub.GetCode(); |
| 1558 } | 1560 } |
| 1559 | 1561 |
| 1560 case LookupIterator::ACCESSOR: { | 1562 case LookupIterator::ACCESSOR: { |
| 1561 if (!holder->HasFastProperties()) { | 1563 if (!holder->HasFastProperties()) { |
| 1562 TRACE_GENERIC_IC(isolate(), "StoreIC", "accessor on slow map"); | 1564 TRACE_GENERIC_IC(isolate(), "StoreIC", "accessor on slow map"); |
| 1563 break; | 1565 break; |
| (...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2608 * Attempts to load a property with an interceptor (which must be present), | 2610 * Attempts to load a property with an interceptor (which must be present), |
| 2609 * but doesn't search the prototype chain. | 2611 * but doesn't search the prototype chain. |
| 2610 * | 2612 * |
| 2611 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't | 2613 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't |
| 2612 * provide any value for the given name. | 2614 * provide any value for the given name. |
| 2613 */ | 2615 */ |
| 2614 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptorOnly) { | 2616 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptorOnly) { |
| 2615 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); | 2617 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); |
| 2616 Handle<Name> name = | 2618 Handle<Name> name = |
| 2617 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); | 2619 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); |
| 2618 Handle<JSObject> receiver = | 2620 Handle<Object> receiver = |
| 2619 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); | 2621 args.at<Object>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); |
| 2620 Handle<JSObject> holder = | 2622 Handle<JSObject> holder = |
| 2621 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); | 2623 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); |
| 2622 HandleScope scope(isolate); | 2624 HandleScope scope(isolate); |
| 2623 | 2625 |
| 2626 if (!receiver->IsJSReceiver()) { | |
| 2627 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 2628 isolate, receiver, Object::ConvertReceiver(isolate, receiver)); | |
| 2629 } | |
| 2630 | |
| 2624 InterceptorInfo* interceptor = holder->GetNamedInterceptor(); | 2631 InterceptorInfo* interceptor = holder->GetNamedInterceptor(); |
| 2625 PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver, | 2632 PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver, |
| 2626 *holder, Object::DONT_THROW); | 2633 *holder, Object::DONT_THROW); |
| 2627 | 2634 |
| 2628 v8::GenericNamedPropertyGetterCallback getter = | 2635 v8::GenericNamedPropertyGetterCallback getter = |
| 2629 v8::ToCData<v8::GenericNamedPropertyGetterCallback>( | 2636 v8::ToCData<v8::GenericNamedPropertyGetterCallback>( |
| 2630 interceptor->getter()); | 2637 interceptor->getter()); |
| 2631 Handle<Object> result = arguments.Call(getter, name); | 2638 Handle<Object> result = arguments.Call(getter, name); |
| 2632 | 2639 |
| 2633 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 2640 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 2634 | 2641 |
| 2635 if (!result.is_null()) return *result; | 2642 if (!result.is_null()) return *result; |
| 2636 return isolate->heap()->no_interceptor_result_sentinel(); | 2643 return isolate->heap()->no_interceptor_result_sentinel(); |
| 2637 } | 2644 } |
| 2638 | 2645 |
| 2639 | 2646 |
| 2640 /** | 2647 /** |
| 2641 * Loads a property with an interceptor performing post interceptor | 2648 * Loads a property with an interceptor performing post interceptor |
| 2642 * lookup if interceptor failed. | 2649 * lookup if interceptor failed. |
| 2643 */ | 2650 */ |
| 2644 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptor) { | 2651 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptor) { |
| 2645 HandleScope scope(isolate); | 2652 HandleScope scope(isolate); |
| 2646 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); | 2653 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); |
| 2647 Handle<Name> name = | 2654 Handle<Name> name = |
| 2648 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); | 2655 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); |
| 2649 Handle<JSObject> receiver = | 2656 Handle<Object> receiver = |
| 2650 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); | 2657 args.at<Object>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); |
| 2651 Handle<JSObject> holder = | 2658 Handle<JSObject> holder = |
| 2652 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); | 2659 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); |
| 2653 | 2660 |
| 2661 if (!receiver->IsJSReceiver()) { | |
| 2662 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 2663 isolate, receiver, Object::ConvertReceiver(isolate, receiver)); | |
| 2664 } | |
| 2665 | |
| 2654 InterceptorInfo* interceptor = holder->GetNamedInterceptor(); | 2666 InterceptorInfo* interceptor = holder->GetNamedInterceptor(); |
| 2655 PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver, | 2667 PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver, |
| 2656 *holder, Object::DONT_THROW); | 2668 *holder, Object::DONT_THROW); |
| 2657 | 2669 |
| 2658 v8::GenericNamedPropertyGetterCallback getter = | 2670 v8::GenericNamedPropertyGetterCallback getter = |
| 2659 v8::ToCData<v8::GenericNamedPropertyGetterCallback>( | 2671 v8::ToCData<v8::GenericNamedPropertyGetterCallback>( |
| 2660 interceptor->getter()); | 2672 interceptor->getter()); |
| 2661 Handle<Object> result = arguments.Call(getter, name); | 2673 Handle<Object> result = arguments.Call(getter, name); |
| 2662 | 2674 |
| 2663 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 2675 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2783 KeyedLoadICNexus nexus(vector, vector_slot); | 2795 KeyedLoadICNexus nexus(vector, vector_slot); |
| 2784 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 2796 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
| 2785 ic.UpdateState(receiver, key); | 2797 ic.UpdateState(receiver, key); |
| 2786 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); | 2798 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); |
| 2787 } | 2799 } |
| 2788 | 2800 |
| 2789 return *result; | 2801 return *result; |
| 2790 } | 2802 } |
| 2791 } // namespace internal | 2803 } // namespace internal |
| 2792 } // namespace v8 | 2804 } // namespace v8 |
| OLD | NEW |