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

Side by Side Diff: src/stub-cache.cc

Issue 155682: Get rid of unnecessary handle management when invoking interceptors. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 // Leaving JavaScript. 782 // Leaving JavaScript.
783 VMState state(EXTERNAL); 783 VMState state(EXTERNAL);
784 fun(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); 784 fun(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info);
785 } 785 }
786 RETURN_IF_SCHEDULED_EXCEPTION(); 786 RETURN_IF_SCHEDULED_EXCEPTION();
787 return *value; 787 return *value;
788 } 788 }
789 789
790 790
791 Object* LoadInterceptorProperty(Arguments args) { 791 Object* LoadInterceptorProperty(Arguments args) {
792 JSObject* recv = JSObject::cast(args[0]); 792 Handle<JSObject> receiver_handle = args.at<JSObject>(0);
793 JSObject* holder = JSObject::cast(args[1]); 793 Handle<JSObject> holder_handle = args.at<JSObject>(1);
794 String* name = String::cast(args[2]); 794 Handle<String> name_handle = args.at<String>(2);
795 Smi* lookup_hint = Smi::cast(args[3]); 795 Smi* lookup_hint = Smi::cast(args[3]);
796 ASSERT(holder->HasNamedInterceptor()); 796 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(4);
797 PropertyAttributes attr = NONE; 797 Handle<Object> data_handle = args.at<Object>(5);
798 798
799 Object* result = holder->GetInterceptorPropertyWithLookupHint( 799 Address getter_address = v8::ToCData<Address>(interceptor_info->getter());
800 recv, lookup_hint, name, &attr); 800 v8::NamedPropertyGetter getter =
801 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address);
802 ASSERT(getter != NULL);
803
804 PropertyAttributes attributes = ABSENT;
805 Object* result = Heap::undefined_value();
806
807 {
808 // Use the interceptor getter.
809 v8::AccessorInfo info(v8::Utils::ToLocal(receiver_handle),
810 v8::Utils::ToLocal(data_handle),
811 v8::Utils::ToLocal(holder_handle));
812 HandleScope scope;
813 v8::Handle<v8::Value> r;
814 {
815 // Leaving JavaScript.
816 VMState state(EXTERNAL);
817 r = getter(v8::Utils::ToLocal(name_handle), info);
818 }
819 RETURN_IF_SCHEDULED_EXCEPTION();
820 if (!r.IsEmpty()) {
821 return *v8::Utils::OpenHandle(*r);
822 }
823 }
824
825 int property_index = lookup_hint->value();
826 if (property_index >= 0) {
827 result = holder_handle->FastPropertyAt(property_index);
828 } else {
829 switch (property_index) {
830 case JSObject::kLookupInPrototype: {
831 Object* pt = holder_handle->GetPrototype();
832 if (pt == Heap::null_value()) return Heap::undefined_value();
833 result = pt->GetPropertyWithReceiver(
834 *receiver_handle,
835 *name_handle,
836 &attributes);
837 RETURN_IF_SCHEDULED_EXCEPTION();
838 }
839 break;
840
841 case JSObject::kLookupInHolder:
842 result = holder_handle->GetPropertyPostInterceptor(
843 *receiver_handle,
844 *name_handle,
845 &attributes);
846 RETURN_IF_SCHEDULED_EXCEPTION();
847 break;
848
849 default:
850 UNREACHABLE();
851 }
852 }
853
801 if (result->IsFailure()) return result; 854 if (result->IsFailure()) return result;
802 855 if (attributes != ABSENT) return result;
803 // If the property is present, return it.
804 if (attr != ABSENT) return result;
805 856
806 // If the top frame is an internal frame, this is really a call 857 // If the top frame is an internal frame, this is really a call
807 // IC. In this case, we simply return the undefined result which 858 // IC. In this case, we simply return the undefined result which
808 // will lead to an exception when trying to invoke the result as a 859 // will lead to an exception when trying to invoke the result as a
809 // function. 860 // function.
810 StackFrameIterator it; 861 StackFrameIterator it;
811 it.Advance(); // skip exit frame 862 it.Advance(); // skip exit frame
812 if (it.frame()->is_internal()) return result; 863 if (it.frame()->is_internal()) return result;
813 864
814 // If the load is non-contextual, just return the undefined result. 865 // If the load is non-contextual, just return the undefined result.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 int argc = arguments_.immediate(); 1062 int argc = arguments_.immediate();
1012 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, 1063 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC,
1013 type, 1064 type,
1014 in_loop_, 1065 in_loop_,
1015 argc); 1066 argc);
1016 return GetCodeWithFlags(flags, name); 1067 return GetCodeWithFlags(flags, name);
1017 } 1068 }
1018 1069
1019 1070
1020 } } // namespace v8::internal 1071 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698