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/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 2769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2780 */ | 2780 */ |
2781 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptorOnly) { | 2781 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptorOnly) { |
2782 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); | 2782 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); |
2783 Handle<Name> name = | 2783 Handle<Name> name = |
2784 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); | 2784 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); |
2785 Handle<JSObject> receiver = | 2785 Handle<JSObject> receiver = |
2786 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); | 2786 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); |
2787 Handle<JSObject> holder = | 2787 Handle<JSObject> holder = |
2788 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); | 2788 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); |
2789 HandleScope scope(isolate); | 2789 HandleScope scope(isolate); |
2790 LookupIterator it(receiver, name, holder, LookupIterator::OWN); | 2790 |
2791 bool done; | 2791 InterceptorInfo* interceptor = holder->GetNamedInterceptor(); |
2792 Handle<Object> result; | 2792 PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver, |
2793 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2793 *holder, Object::DONT_THROW); |
2794 isolate, result, JSObject::GetPropertyWithInterceptor(&it, &done)); | 2794 |
2795 if (done) return *result; | 2795 v8::GenericNamedPropertyGetterCallback getter = |
2796 return isolate->heap()->no_interceptor_result_sentinel(); | 2796 v8::ToCData<v8::GenericNamedPropertyGetterCallback>( |
| 2797 interceptor->getter()); |
| 2798 LOG(isolate, ApiNamedPropertyAccess("interceptor-named-get", *holder, *name)); |
| 2799 v8::Local<v8::Value> result = |
| 2800 arguments.Call(getter, v8::Utils::ToLocal(name)); |
| 2801 |
| 2802 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 2803 |
| 2804 Handle<Object> result_internal; |
| 2805 if (result.IsEmpty()) { |
| 2806 return isolate->heap()->no_interceptor_result_sentinel(); |
| 2807 } |
| 2808 result_internal = v8::Utils::OpenHandle(*result); |
| 2809 result_internal->VerifyApiCallResultType(); |
| 2810 return *result_internal; |
2797 } | 2811 } |
2798 | 2812 |
2799 | 2813 |
2800 /** | 2814 /** |
2801 * Loads a property with an interceptor performing post interceptor | 2815 * Loads a property with an interceptor performing post interceptor |
2802 * lookup if interceptor failed. | 2816 * lookup if interceptor failed. |
2803 */ | 2817 */ |
2804 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptor) { | 2818 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptor) { |
2805 HandleScope scope(isolate); | 2819 HandleScope scope(isolate); |
2806 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); | 2820 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2862 return *result; | 2876 return *result; |
2863 } | 2877 } |
2864 | 2878 |
2865 | 2879 |
2866 RUNTIME_FUNCTION(Runtime_LoadElementWithInterceptor) { | 2880 RUNTIME_FUNCTION(Runtime_LoadElementWithInterceptor) { |
2867 // TODO(verwaest): This should probably get the holder and receiver as input. | 2881 // TODO(verwaest): This should probably get the holder and receiver as input. |
2868 HandleScope scope(isolate); | 2882 HandleScope scope(isolate); |
2869 Handle<JSObject> receiver = args.at<JSObject>(0); | 2883 Handle<JSObject> receiver = args.at<JSObject>(0); |
2870 DCHECK(args.smi_at(1) >= 0); | 2884 DCHECK(args.smi_at(1) >= 0); |
2871 uint32_t index = args.smi_at(1); | 2885 uint32_t index = args.smi_at(1); |
2872 Handle<Object> result; | 2886 |
2873 LookupIterator it(isolate, receiver, index, receiver); | 2887 InterceptorInfo* interceptor = receiver->GetIndexedInterceptor(); |
2874 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 2888 v8::Local<v8::Value> result; |
2875 return *result; | 2889 PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver, |
| 2890 *receiver, Object::DONT_THROW); |
| 2891 |
| 2892 v8::IndexedPropertyGetterCallback getter = |
| 2893 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); |
| 2894 LOG(isolate, |
| 2895 ApiIndexedPropertyAccess("interceptor-indexed-get", *receiver, index)); |
| 2896 result = arguments.Call(getter, index); |
| 2897 |
| 2898 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 2899 |
| 2900 Handle<Object> result_internal; |
| 2901 if (result.IsEmpty()) { |
| 2902 LookupIterator it(isolate, receiver, index, receiver); |
| 2903 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); |
| 2904 it.Next(); |
| 2905 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result_internal, |
| 2906 Object::GetProperty(&it)); |
| 2907 } else { |
| 2908 result_internal = v8::Utils::OpenHandle(*result); |
| 2909 result_internal->VerifyApiCallResultType(); |
| 2910 } |
| 2911 |
| 2912 return *result_internal; |
2876 } | 2913 } |
2877 | 2914 |
2878 | 2915 |
2879 RUNTIME_FUNCTION(Runtime_LoadIC_MissFromStubFailure) { | 2916 RUNTIME_FUNCTION(Runtime_LoadIC_MissFromStubFailure) { |
2880 TimerEventScope<TimerEventIcMiss> timer(isolate); | 2917 TimerEventScope<TimerEventIcMiss> timer(isolate); |
2881 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss"); | 2918 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss"); |
2882 HandleScope scope(isolate); | 2919 HandleScope scope(isolate); |
2883 Handle<Object> receiver = args.at<Object>(0); | 2920 Handle<Object> receiver = args.at<Object>(0); |
2884 Handle<Name> key = args.at<Name>(1); | 2921 Handle<Name> key = args.at<Name>(1); |
2885 Handle<Object> result; | 2922 Handle<Object> result; |
(...skipping 16 matching lines...) Expand all Loading... |
2902 KeyedLoadICNexus nexus(vector, vector_slot); | 2939 KeyedLoadICNexus nexus(vector, vector_slot); |
2903 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 2940 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
2904 ic.UpdateState(receiver, key); | 2941 ic.UpdateState(receiver, key); |
2905 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); | 2942 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); |
2906 } | 2943 } |
2907 | 2944 |
2908 return *result; | 2945 return *result; |
2909 } | 2946 } |
2910 } // namespace internal | 2947 } // namespace internal |
2911 } // namespace v8 | 2948 } // namespace v8 |
OLD | NEW |