Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: src/ic/ic.cc

Issue 1776913005: Simplify the interface of PropertyCallbackArguments (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after
2754 ? AccessorInfo::cast(WeakCell::cast(*callback_or_cell)->value()) 2754 ? AccessorInfo::cast(WeakCell::cast(*callback_or_cell)->value())
2755 : AccessorInfo::cast(*callback_or_cell)); 2755 : AccessorInfo::cast(*callback_or_cell));
2756 2756
2757 DCHECK(callback->IsCompatibleReceiver(*receiver)); 2757 DCHECK(callback->IsCompatibleReceiver(*receiver));
2758 2758
2759 Address setter_address = v8::ToCData<Address>(callback->setter()); 2759 Address setter_address = v8::ToCData<Address>(callback->setter());
2760 v8::AccessorNameSetterCallback fun = 2760 v8::AccessorNameSetterCallback fun =
2761 FUNCTION_CAST<v8::AccessorNameSetterCallback>(setter_address); 2761 FUNCTION_CAST<v8::AccessorNameSetterCallback>(setter_address);
2762 DCHECK(fun != NULL); 2762 DCHECK(fun != NULL);
2763 2763
2764 LOG(isolate, ApiNamedPropertyAccess("store", *receiver, *name));
2765 Object::ShouldThrow should_throw = 2764 Object::ShouldThrow should_throw =
2766 is_sloppy(language_mode) ? Object::DONT_THROW : Object::THROW_ON_ERROR; 2765 is_sloppy(language_mode) ? Object::DONT_THROW : Object::THROW_ON_ERROR;
2767 PropertyCallbackArguments custom_args(isolate, callback->data(), *receiver, 2766 PropertyCallbackArguments custom_args(isolate, callback->data(), *receiver,
2768 *holder, should_throw); 2767 *holder, should_throw);
2769 custom_args.Call(fun, v8::Utils::ToLocal(name), v8::Utils::ToLocal(value)); 2768 custom_args.Call(fun, name, value);
2770 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); 2769 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
2771 return *value; 2770 return *value;
2772 } 2771 }
2773 2772
2774 2773
2775 /** 2774 /**
2776 * Attempts to load a property with an interceptor (which must be present), 2775 * Attempts to load a property with an interceptor (which must be present),
2777 * but doesn't search the prototype chain. 2776 * but doesn't search the prototype chain.
2778 * 2777 *
2779 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't 2778 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't
2780 * provide any value for the given name. 2779 * provide any value for the given name.
2781 */ 2780 */
2782 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptorOnly) { 2781 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptorOnly) {
2783 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); 2782 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength);
2784 Handle<Name> name = 2783 Handle<Name> name =
2785 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); 2784 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex);
2786 Handle<JSObject> receiver = 2785 Handle<JSObject> receiver =
2787 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); 2786 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex);
2788 Handle<JSObject> holder = 2787 Handle<JSObject> holder =
2789 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); 2788 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex);
2790 HandleScope scope(isolate); 2789 HandleScope scope(isolate);
2791 2790
2792 InterceptorInfo* interceptor = holder->GetNamedInterceptor(); 2791 InterceptorInfo* interceptor = holder->GetNamedInterceptor();
2793 PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver, 2792 PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver,
2794 *holder, Object::DONT_THROW); 2793 *holder, Object::DONT_THROW);
2795 2794
2796 v8::GenericNamedPropertyGetterCallback getter = 2795 v8::GenericNamedPropertyGetterCallback getter =
2797 v8::ToCData<v8::GenericNamedPropertyGetterCallback>( 2796 v8::ToCData<v8::GenericNamedPropertyGetterCallback>(
2798 interceptor->getter()); 2797 interceptor->getter());
2799 LOG(isolate, ApiNamedPropertyAccess("interceptor-named-get", *holder, *name)); 2798 Handle<Object> result = arguments.Call(getter, name);
2800 v8::Local<v8::Value> result =
2801 arguments.Call(getter, v8::Utils::ToLocal(name));
2802 2799
2803 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); 2800 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
2804 2801
2805 Handle<Object> result_internal; 2802 Handle<Object> result_internal;
2806 if (result.IsEmpty()) { 2803 if (result.is_null()) {
2807 return isolate->heap()->no_interceptor_result_sentinel(); 2804 return isolate->heap()->no_interceptor_result_sentinel();
2808 } 2805 }
2809 result_internal = v8::Utils::OpenHandle(*result); 2806 return *result;
2810 result_internal->VerifyApiCallResultType();
2811 return *result_internal;
2812 } 2807 }
2813 2808
2814 2809
2815 /** 2810 /**
2816 * Loads a property with an interceptor performing post interceptor 2811 * Loads a property with an interceptor performing post interceptor
2817 * lookup if interceptor failed. 2812 * lookup if interceptor failed.
2818 */ 2813 */
2819 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptor) { 2814 RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptor) {
2820 HandleScope scope(isolate); 2815 HandleScope scope(isolate);
2821 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); 2816 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2879 2874
2880 2875
2881 RUNTIME_FUNCTION(Runtime_LoadElementWithInterceptor) { 2876 RUNTIME_FUNCTION(Runtime_LoadElementWithInterceptor) {
2882 // TODO(verwaest): This should probably get the holder and receiver as input. 2877 // TODO(verwaest): This should probably get the holder and receiver as input.
2883 HandleScope scope(isolate); 2878 HandleScope scope(isolate);
2884 Handle<JSObject> receiver = args.at<JSObject>(0); 2879 Handle<JSObject> receiver = args.at<JSObject>(0);
2885 DCHECK(args.smi_at(1) >= 0); 2880 DCHECK(args.smi_at(1) >= 0);
2886 uint32_t index = args.smi_at(1); 2881 uint32_t index = args.smi_at(1);
2887 2882
2888 InterceptorInfo* interceptor = receiver->GetIndexedInterceptor(); 2883 InterceptorInfo* interceptor = receiver->GetIndexedInterceptor();
2889 v8::Local<v8::Value> result;
2890 PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver, 2884 PropertyCallbackArguments arguments(isolate, interceptor->data(), *receiver,
2891 *receiver, Object::DONT_THROW); 2885 *receiver, Object::DONT_THROW);
2892 2886
2893 v8::IndexedPropertyGetterCallback getter = 2887 v8::IndexedPropertyGetterCallback getter =
2894 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); 2888 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter());
2895 LOG(isolate, 2889 Handle<Object> result = arguments.Call(getter, index);
2896 ApiIndexedPropertyAccess("interceptor-indexed-get", *receiver, index));
2897 result = arguments.Call(getter, index);
2898 2890
2899 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); 2891 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
2900 2892
2901 Handle<Object> result_internal; 2893 if (result.is_null()) {
2902 if (result.IsEmpty()) {
2903 LookupIterator it(isolate, receiver, index, receiver); 2894 LookupIterator it(isolate, receiver, index, receiver);
2904 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); 2895 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state());
2905 it.Next(); 2896 it.Next();
2906 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result_internal, 2897 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
2907 Object::GetProperty(&it)); 2898 Object::GetProperty(&it));
2908 } else {
2909 result_internal = v8::Utils::OpenHandle(*result);
2910 result_internal->VerifyApiCallResultType();
2911 } 2899 }
2912 2900
2913 return *result_internal; 2901 return *result;
2914 } 2902 }
2915 2903
2916 2904
2917 RUNTIME_FUNCTION(Runtime_LoadIC_MissFromStubFailure) { 2905 RUNTIME_FUNCTION(Runtime_LoadIC_MissFromStubFailure) {
2918 TimerEventScope<TimerEventIcMiss> timer(isolate); 2906 TimerEventScope<TimerEventIcMiss> timer(isolate);
2919 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss"); 2907 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss");
2920 HandleScope scope(isolate); 2908 HandleScope scope(isolate);
2921 Handle<Object> receiver = args.at<Object>(0); 2909 Handle<Object> receiver = args.at<Object>(0);
2922 Handle<Name> key = args.at<Name>(1); 2910 Handle<Name> key = args.at<Name>(1);
2923 Handle<Object> result; 2911 Handle<Object> result;
(...skipping 16 matching lines...) Expand all
2940 KeyedLoadICNexus nexus(vector, vector_slot); 2928 KeyedLoadICNexus nexus(vector, vector_slot);
2941 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); 2929 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
2942 ic.UpdateState(receiver, key); 2930 ic.UpdateState(receiver, key);
2943 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); 2931 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
2944 } 2932 }
2945 2933
2946 return *result; 2934 return *result;
2947 } 2935 }
2948 } // namespace internal 2936 } // namespace internal
2949 } // namespace v8 2937 } // namespace v8
OLDNEW
« src/api-arguments.h ('K') | « src/builtins.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698