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

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

Issue 140069: Store a lookup result when compiling interceptor ICs.... (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/stub-cache.h ('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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 v8::Utils::ToLocal(recv)); 780 v8::Utils::ToLocal(recv));
781 { 781 {
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 * Attempts to load a property with an interceptor (which must be present),
792 * but doesn't search the prototype chain.
793 *
794 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't
795 * provide any value for the given name.
796 */
797 Object* LoadPropertyWithInterceptorOnly(Arguments args) {
792 Handle<JSObject> receiver_handle = args.at<JSObject>(0); 798 Handle<JSObject> receiver_handle = args.at<JSObject>(0);
793 Handle<JSObject> holder_handle = args.at<JSObject>(1); 799 Handle<JSObject> holder_handle = args.at<JSObject>(1);
794 Handle<String> name_handle = args.at<String>(2); 800 Handle<String> name_handle = args.at<String>(2);
795 Smi* lookup_hint = Smi::cast(args[3]); 801 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(3);
796 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(4); 802 Handle<Object> data_handle = args.at<Object>(4);
797 Handle<Object> data_handle = args.at<Object>(5);
798 803
799 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); 804 Address getter_address = v8::ToCData<Address>(interceptor_info->getter());
800 v8::NamedPropertyGetter getter = 805 v8::NamedPropertyGetter getter =
801 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); 806 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address);
802 ASSERT(getter != NULL); 807 ASSERT(getter != NULL);
803 808
804 PropertyAttributes attributes = ABSENT;
805 Object* result = Heap::undefined_value();
806
807 { 809 {
808 // Use the interceptor getter. 810 // Use the interceptor getter.
809 v8::AccessorInfo info(v8::Utils::ToLocal(receiver_handle), 811 v8::AccessorInfo info(v8::Utils::ToLocal(receiver_handle),
810 v8::Utils::ToLocal(data_handle), 812 v8::Utils::ToLocal(data_handle),
811 v8::Utils::ToLocal(holder_handle)); 813 v8::Utils::ToLocal(holder_handle));
812 HandleScope scope; 814 HandleScope scope;
813 v8::Handle<v8::Value> r; 815 v8::Handle<v8::Value> r;
814 { 816 {
815 // Leaving JavaScript. 817 // Leaving JavaScript.
816 VMState state(EXTERNAL); 818 VMState state(EXTERNAL);
817 r = getter(v8::Utils::ToLocal(name_handle), info); 819 r = getter(v8::Utils::ToLocal(name_handle), info);
818 } 820 }
819 RETURN_IF_SCHEDULED_EXCEPTION(); 821 RETURN_IF_SCHEDULED_EXCEPTION();
820 if (!r.IsEmpty()) { 822 if (!r.IsEmpty()) {
821 return *v8::Utils::OpenHandle(*r); 823 return *v8::Utils::OpenHandle(*r);
822 } 824 }
823 } 825 }
824 826
825 int property_index = lookup_hint->value(); 827 return Heap::no_interceptor_result_sentinel();
826 if (property_index >= 0) { 828 }
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 829
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 830
849 default: 831 static Object* ThrowReferenceError(String* name) {
850 UNREACHABLE();
851 }
852 }
853
854 if (result->IsFailure()) return result;
855 if (attributes != ABSENT) return result;
856
857 // If the top frame is an internal frame, this is really a call
858 // IC. In this case, we simply return the undefined result which
859 // will lead to an exception when trying to invoke the result as a
860 // function.
861 StackFrameIterator it;
862 it.Advance(); // skip exit frame
863 if (it.frame()->is_internal()) return result;
864
865 // If the load is non-contextual, just return the undefined result. 832 // If the load is non-contextual, just return the undefined result.
866 // Note that both keyed and non-keyed loads may end up here, so we 833 // Note that both keyed and non-keyed loads may end up here, so we
867 // can't use either LoadIC or KeyedLoadIC constructors. 834 // can't use either LoadIC or KeyedLoadIC constructors.
868 IC ic(IC::NO_EXTRA_FRAME); 835 IC ic(IC::NO_EXTRA_FRAME);
869 ASSERT(ic.target()->is_load_stub() || ic.target()->is_keyed_load_stub()); 836 ASSERT(ic.target()->is_load_stub() || ic.target()->is_keyed_load_stub());
870 if (!ic.is_contextual()) return result; 837 if (!ic.is_contextual()) return Heap::undefined_value();
871 838
872 // Throw a reference error. 839 // Throw a reference error.
840 HandleScope scope;
841 Handle<String> name_handle(name);
842 Handle<Object> error =
843 Factory::NewReferenceError("not_defined",
844 HandleVector(&name_handle, 1));
845 return Top::Throw(*error);
846 }
847
848
849 static Object* LoadWithInterceptor(Arguments* args,
850 PropertyAttributes* attrs) {
851 Handle<JSObject> receiver_handle = args->at<JSObject>(0);
852 Handle<JSObject> holder_handle = args->at<JSObject>(1);
853 Handle<String> name_handle = args->at<String>(2);
854 Handle<InterceptorInfo> interceptor_info = args->at<InterceptorInfo>(3);
855 Handle<Object> data_handle = args->at<Object>(4);
856
857 Address getter_address = v8::ToCData<Address>(interceptor_info->getter());
858 v8::NamedPropertyGetter getter =
859 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address);
860 ASSERT(getter != NULL);
861
873 { 862 {
863 // Use the interceptor getter.
864 v8::AccessorInfo info(v8::Utils::ToLocal(receiver_handle),
865 v8::Utils::ToLocal(data_handle),
866 v8::Utils::ToLocal(holder_handle));
874 HandleScope scope; 867 HandleScope scope;
875 // We cannot use the raw name pointer here since getting the 868 v8::Handle<v8::Value> r;
876 // property might cause a GC. However, we can get the name from 869 {
877 // the stack using the arguments object. 870 // Leaving JavaScript.
878 Handle<String> name_handle = args.at<String>(2); 871 VMState state(EXTERNAL);
879 Handle<Object> error = 872 r = getter(v8::Utils::ToLocal(name_handle), info);
880 Factory::NewReferenceError("not_defined", 873 }
881 HandleVector(&name_handle, 1)); 874 RETURN_IF_SCHEDULED_EXCEPTION();
882 return Top::Throw(*error); 875 if (!r.IsEmpty()) {
876 *attrs = NONE;
877 return *v8::Utils::OpenHandle(*r);
878 }
883 } 879 }
880
881 Object* result = holder_handle->GetPropertyPostInterceptor(
882 *receiver_handle,
883 *name_handle,
884 attrs);
885 RETURN_IF_SCHEDULED_EXCEPTION();
886 return result;
887 }
888
889
890 /**
891 * Loads a property with an interceptor performing post interceptor
892 * lookup if interceptor failed.
893 */
894 Object* LoadPropertyWithInterceptorForLoad(Arguments args) {
895 PropertyAttributes attr = NONE;
896 Object* result = LoadWithInterceptor(&args, &attr);
897 if (result->IsFailure()) return result;
898
899 // If the property is present, return it.
900 if (attr != ABSENT) return result;
901 return ThrowReferenceError(String::cast(args[2]));
902 }
903
904
905 Object* LoadPropertyWithInterceptorForCall(Arguments args) {
906 PropertyAttributes attr;
907 Object* result = LoadWithInterceptor(&args, &attr);
908 RETURN_IF_SCHEDULED_EXCEPTION();
909 // This is call IC. In this case, we simply return the undefined result which
910 // will lead to an exception when trying to invoke the result as a
911 // function.
912 return result;
884 } 913 }
885 914
886 915
887 Object* StoreInterceptorProperty(Arguments args) { 916 Object* StoreInterceptorProperty(Arguments args) {
888 JSObject* recv = JSObject::cast(args[0]); 917 JSObject* recv = JSObject::cast(args[0]);
889 String* name = String::cast(args[1]); 918 String* name = String::cast(args[1]);
890 Object* value = args[2]; 919 Object* value = args[2];
891 ASSERT(recv->HasNamedInterceptor()); 920 ASSERT(recv->HasNamedInterceptor());
892 PropertyAttributes attr = NONE; 921 PropertyAttributes attr = NONE;
893 Object* result = recv->SetPropertyWithInterceptor(name, value, attr); 922 Object* result = recv->SetPropertyWithInterceptor(name, value, attr);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 int argc = arguments_.immediate(); 1091 int argc = arguments_.immediate();
1063 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, 1092 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC,
1064 type, 1093 type,
1065 in_loop_, 1094 in_loop_,
1066 argc); 1095 argc);
1067 return GetCodeWithFlags(flags, name); 1096 return GetCodeWithFlags(flags, name);
1068 } 1097 }
1069 1098
1070 1099
1071 } } // namespace v8::internal 1100 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/stub-cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698