OLD | NEW |
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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 } | 783 } |
784 | 784 |
785 /** | 785 /** |
786 * Attempts to load a property with an interceptor (which must be present), | 786 * Attempts to load a property with an interceptor (which must be present), |
787 * but doesn't search the prototype chain. | 787 * but doesn't search the prototype chain. |
788 * | 788 * |
789 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't | 789 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't |
790 * provide any value for the given name. | 790 * provide any value for the given name. |
791 */ | 791 */ |
792 Object* LoadPropertyWithInterceptorOnly(Arguments args) { | 792 Object* LoadPropertyWithInterceptorOnly(Arguments args) { |
793 JSObject* receiver_handle = JSObject::cast(args[0]); | 793 Handle<String> name_handle = args.at<String>(0); |
794 JSObject* holder_handle = JSObject::cast(args[1]); | 794 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(1); |
795 Handle<String> name_handle = args.at<String>(2); | 795 ASSERT(args[2]->IsJSObject()); // Receiver. |
796 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(3); | 796 ASSERT(args[3]->IsJSObject()); // Holder. |
797 Object* data_handle = args[4]; | 797 ASSERT(args.length() == 5); // Last arg is data object. |
798 | 798 |
799 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); | 799 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
800 v8::NamedPropertyGetter getter = | 800 v8::NamedPropertyGetter getter = |
801 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); | 801 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); |
802 ASSERT(getter != NULL); | 802 ASSERT(getter != NULL); |
803 | 803 |
804 { | 804 { |
805 // Use the interceptor getter. | 805 // Use the interceptor getter. |
806 CustomArguments args(data_handle, receiver_handle, holder_handle); | 806 v8::AccessorInfo info(args.arguments() - 2); |
807 v8::AccessorInfo info(args.end()); | |
808 HandleScope scope; | 807 HandleScope scope; |
809 v8::Handle<v8::Value> r; | 808 v8::Handle<v8::Value> r; |
810 { | 809 { |
811 // Leaving JavaScript. | 810 // Leaving JavaScript. |
812 VMState state(EXTERNAL); | 811 VMState state(EXTERNAL); |
813 r = getter(v8::Utils::ToLocal(name_handle), info); | 812 r = getter(v8::Utils::ToLocal(name_handle), info); |
814 } | 813 } |
815 RETURN_IF_SCHEDULED_EXCEPTION(); | 814 RETURN_IF_SCHEDULED_EXCEPTION(); |
816 if (!r.IsEmpty()) { | 815 if (!r.IsEmpty()) { |
817 return *v8::Utils::OpenHandle(*r); | 816 return *v8::Utils::OpenHandle(*r); |
(...skipping 17 matching lines...) Expand all Loading... |
835 Handle<String> name_handle(name); | 834 Handle<String> name_handle(name); |
836 Handle<Object> error = | 835 Handle<Object> error = |
837 Factory::NewReferenceError("not_defined", | 836 Factory::NewReferenceError("not_defined", |
838 HandleVector(&name_handle, 1)); | 837 HandleVector(&name_handle, 1)); |
839 return Top::Throw(*error); | 838 return Top::Throw(*error); |
840 } | 839 } |
841 | 840 |
842 | 841 |
843 static Object* LoadWithInterceptor(Arguments* args, | 842 static Object* LoadWithInterceptor(Arguments* args, |
844 PropertyAttributes* attrs) { | 843 PropertyAttributes* attrs) { |
845 Handle<JSObject> receiver_handle = args->at<JSObject>(0); | 844 Handle<String> name_handle = args->at<String>(0); |
846 Handle<JSObject> holder_handle = args->at<JSObject>(1); | 845 Handle<InterceptorInfo> interceptor_info = args->at<InterceptorInfo>(1); |
847 Handle<String> name_handle = args->at<String>(2); | 846 Handle<JSObject> receiver_handle = args->at<JSObject>(2); |
848 Handle<InterceptorInfo> interceptor_info = args->at<InterceptorInfo>(3); | 847 Handle<JSObject> holder_handle = args->at<JSObject>(3); |
849 Handle<Object> data_handle = args->at<Object>(4); | 848 ASSERT(args->length() == 5); // Last arg is data object. |
850 | 849 |
851 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); | 850 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
852 v8::NamedPropertyGetter getter = | 851 v8::NamedPropertyGetter getter = |
853 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); | 852 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); |
854 ASSERT(getter != NULL); | 853 ASSERT(getter != NULL); |
855 | 854 |
856 { | 855 { |
857 // Use the interceptor getter. | 856 // Use the interceptor getter. |
858 CustomArguments args(*data_handle, *receiver_handle, *holder_handle); | 857 v8::AccessorInfo info(args->arguments() - 2); |
859 v8::AccessorInfo info(args.end()); | |
860 HandleScope scope; | 858 HandleScope scope; |
861 v8::Handle<v8::Value> r; | 859 v8::Handle<v8::Value> r; |
862 { | 860 { |
863 // Leaving JavaScript. | 861 // Leaving JavaScript. |
864 VMState state(EXTERNAL); | 862 VMState state(EXTERNAL); |
865 r = getter(v8::Utils::ToLocal(name_handle), info); | 863 r = getter(v8::Utils::ToLocal(name_handle), info); |
866 } | 864 } |
867 RETURN_IF_SCHEDULED_EXCEPTION(); | 865 RETURN_IF_SCHEDULED_EXCEPTION(); |
868 if (!r.IsEmpty()) { | 866 if (!r.IsEmpty()) { |
869 *attrs = NONE; | 867 *attrs = NONE; |
(...skipping 14 matching lines...) Expand all Loading... |
884 * Loads a property with an interceptor performing post interceptor | 882 * Loads a property with an interceptor performing post interceptor |
885 * lookup if interceptor failed. | 883 * lookup if interceptor failed. |
886 */ | 884 */ |
887 Object* LoadPropertyWithInterceptorForLoad(Arguments args) { | 885 Object* LoadPropertyWithInterceptorForLoad(Arguments args) { |
888 PropertyAttributes attr = NONE; | 886 PropertyAttributes attr = NONE; |
889 Object* result = LoadWithInterceptor(&args, &attr); | 887 Object* result = LoadWithInterceptor(&args, &attr); |
890 if (result->IsFailure()) return result; | 888 if (result->IsFailure()) return result; |
891 | 889 |
892 // If the property is present, return it. | 890 // If the property is present, return it. |
893 if (attr != ABSENT) return result; | 891 if (attr != ABSENT) return result; |
894 return ThrowReferenceError(String::cast(args[2])); | 892 return ThrowReferenceError(String::cast(args[0])); |
895 } | 893 } |
896 | 894 |
897 | 895 |
898 Object* LoadPropertyWithInterceptorForCall(Arguments args) { | 896 Object* LoadPropertyWithInterceptorForCall(Arguments args) { |
899 PropertyAttributes attr; | 897 PropertyAttributes attr; |
900 Object* result = LoadWithInterceptor(&args, &attr); | 898 Object* result = LoadWithInterceptor(&args, &attr); |
901 RETURN_IF_SCHEDULED_EXCEPTION(); | 899 RETURN_IF_SCHEDULED_EXCEPTION(); |
902 // This is call IC. In this case, we simply return the undefined result which | 900 // This is call IC. In this case, we simply return the undefined result which |
903 // will lead to an exception when trying to invoke the result as a | 901 // will lead to an exception when trying to invoke the result as a |
904 // function. | 902 // function. |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 if (!result->IsFailure()) { | 1116 if (!result->IsFailure()) { |
1119 Code* code = Code::cast(result); | 1117 Code* code = Code::cast(result); |
1120 USE(code); | 1118 USE(code); |
1121 LOG(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); | 1119 LOG(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); |
1122 } | 1120 } |
1123 return result; | 1121 return result; |
1124 } | 1122 } |
1125 | 1123 |
1126 | 1124 |
1127 } } // namespace v8::internal | 1125 } } // namespace v8::internal |
OLD | NEW |