OLD | NEW |
---|---|
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
760 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); | 760 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); |
761 i::FixedArray* types = i::FixedArray::cast(info->types()); | 761 i::FixedArray* types = i::FixedArray::cast(info->types()); |
762 for (int i = 0; i < types->length(); i++) { | 762 for (int i = 0; i < types->length(); i++) { |
763 if (obj->IsInstanceOf(i::FunctionTemplateInfo::cast(types->get(i)))) | 763 if (obj->IsInstanceOf(i::FunctionTemplateInfo::cast(types->get(i)))) |
764 return i + 1; | 764 return i + 1; |
765 } | 765 } |
766 return 0; | 766 return 0; |
767 } | 767 } |
768 | 768 |
769 | 769 |
770 template<typename T, typename V> | |
771 static void SetFieldWrapped(void (T::*setter) (i::Object*, i::WriteBarrierMode) , | |
Erik Corry
2010/09/23 07:53:28
This doesn't lint, but presumably removing the dou
| |
772 i::Handle<T> a, | |
773 V value) { | |
774 i::Handle<i::Object> proxy = FromCData(value); | |
Vitaly Repeshko
2010/09/21 21:19:59
Isn't it true that by the time handle is created
| |
775 ((*a)->*setter)(*proxy, i::UPDATE_WRITE_BARRIER); | |
Erik Corry
2010/09/23 07:53:28
I don't like pointer-to-method, and I don't like h
| |
776 } | |
777 | |
778 | |
770 void FunctionTemplate::SetCallHandler(InvocationCallback callback, | 779 void FunctionTemplate::SetCallHandler(InvocationCallback callback, |
771 v8::Handle<Value> data) { | 780 v8::Handle<Value> data) { |
772 if (IsDeadCheck("v8::FunctionTemplate::SetCallHandler()")) return; | 781 if (IsDeadCheck("v8::FunctionTemplate::SetCallHandler()")) return; |
773 ENTER_V8; | 782 ENTER_V8; |
774 HandleScope scope; | 783 HandleScope scope; |
775 i::Handle<i::Struct> struct_obj = | 784 i::Handle<i::Struct> struct_obj = |
776 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE); | 785 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE); |
777 i::Handle<i::CallHandlerInfo> obj = | 786 i::Handle<i::CallHandlerInfo> obj = |
778 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 787 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
779 obj->set_callback(*FromCData(callback)); | 788 SetFieldWrapped(&i::CallHandlerInfo::set_callback, obj, callback); |
780 if (data.IsEmpty()) data = v8::Undefined(); | 789 if (data.IsEmpty()) data = v8::Undefined(); |
781 obj->set_data(*Utils::OpenHandle(*data)); | 790 obj->set_data(*Utils::OpenHandle(*data)); |
782 Utils::OpenHandle(this)->set_call_code(*obj); | 791 Utils::OpenHandle(this)->set_call_code(*obj); |
783 } | 792 } |
784 | 793 |
785 | 794 |
786 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 795 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
787 v8::Handle<String> name, | 796 v8::Handle<String> name, |
788 AccessorGetter getter, | 797 AccessorGetter getter, |
789 AccessorSetter setter, | 798 AccessorSetter setter, |
790 v8::Handle<Value> data, | 799 v8::Handle<Value> data, |
791 v8::AccessControl settings, | 800 v8::AccessControl settings, |
792 v8::PropertyAttribute attributes) { | 801 v8::PropertyAttribute attributes) { |
793 i::Handle<i::AccessorInfo> obj = i::Factory::NewAccessorInfo(); | 802 i::Handle<i::AccessorInfo> obj = i::Factory::NewAccessorInfo(); |
794 ASSERT(getter != NULL); | 803 ASSERT(getter != NULL); |
795 obj->set_getter(*FromCData(getter)); | 804 SetFieldWrapped(&i::AccessorInfo::set_getter, obj, getter); |
796 obj->set_setter(*FromCData(setter)); | 805 SetFieldWrapped(&i::AccessorInfo::set_setter, obj, setter); |
797 if (data.IsEmpty()) data = v8::Undefined(); | 806 if (data.IsEmpty()) data = v8::Undefined(); |
798 obj->set_data(*Utils::OpenHandle(*data)); | 807 obj->set_data(*Utils::OpenHandle(*data)); |
799 obj->set_name(*Utils::OpenHandle(*name)); | 808 obj->set_name(*Utils::OpenHandle(*name)); |
800 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); | 809 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); |
801 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); | 810 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); |
802 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); | 811 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); |
803 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); | 812 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); |
804 return obj; | 813 return obj; |
805 } | 814 } |
806 | 815 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
870 Handle<Value> data) { | 879 Handle<Value> data) { |
871 if (IsDeadCheck("v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) { | 880 if (IsDeadCheck("v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) { |
872 return; | 881 return; |
873 } | 882 } |
874 ENTER_V8; | 883 ENTER_V8; |
875 HandleScope scope; | 884 HandleScope scope; |
876 i::Handle<i::Struct> struct_obj = | 885 i::Handle<i::Struct> struct_obj = |
877 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE); | 886 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE); |
878 i::Handle<i::InterceptorInfo> obj = | 887 i::Handle<i::InterceptorInfo> obj = |
879 i::Handle<i::InterceptorInfo>::cast(struct_obj); | 888 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
880 if (getter != 0) obj->set_getter(*FromCData(getter)); | 889 |
881 if (setter != 0) obj->set_setter(*FromCData(setter)); | 890 if (getter != 0) { |
882 if (query != 0) obj->set_query(*FromCData(query)); | 891 SetFieldWrapped(&i::InterceptorInfo::set_getter, obj, getter); |
883 if (remover != 0) obj->set_deleter(*FromCData(remover)); | 892 } |
884 if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator)); | 893 |
894 if (setter != 0) { | |
895 SetFieldWrapped(&i::InterceptorInfo::set_setter, obj, setter); | |
896 } | |
897 | |
898 if (query != 0) { | |
899 SetFieldWrapped(&i::InterceptorInfo::set_query, obj, query); | |
900 } | |
901 | |
902 if (remover != 0) { | |
903 SetFieldWrapped(&i::InterceptorInfo::set_deleter, obj, remover); | |
904 } | |
905 | |
906 if (enumerator != 0) { | |
907 SetFieldWrapped(&i::InterceptorInfo::set_enumerator, obj, enumerator); | |
908 } | |
909 | |
885 if (data.IsEmpty()) data = v8::Undefined(); | 910 if (data.IsEmpty()) data = v8::Undefined(); |
886 obj->set_data(*Utils::OpenHandle(*data)); | 911 obj->set_data(*Utils::OpenHandle(*data)); |
887 Utils::OpenHandle(this)->set_named_property_handler(*obj); | 912 Utils::OpenHandle(this)->set_named_property_handler(*obj); |
888 } | 913 } |
889 | 914 |
890 | 915 |
891 void FunctionTemplate::SetIndexedInstancePropertyHandler( | 916 void FunctionTemplate::SetIndexedInstancePropertyHandler( |
892 IndexedPropertyGetter getter, | 917 IndexedPropertyGetter getter, |
893 IndexedPropertySetter setter, | 918 IndexedPropertySetter setter, |
894 IndexedPropertyQuery query, | 919 IndexedPropertyQuery query, |
895 IndexedPropertyDeleter remover, | 920 IndexedPropertyDeleter remover, |
896 IndexedPropertyEnumerator enumerator, | 921 IndexedPropertyEnumerator enumerator, |
897 Handle<Value> data) { | 922 Handle<Value> data) { |
898 if (IsDeadCheck( | 923 if (IsDeadCheck( |
899 "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) { | 924 "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) { |
900 return; | 925 return; |
901 } | 926 } |
902 ENTER_V8; | 927 ENTER_V8; |
903 HandleScope scope; | 928 HandleScope scope; |
904 i::Handle<i::Struct> struct_obj = | 929 i::Handle<i::Struct> struct_obj = |
905 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE); | 930 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE); |
906 i::Handle<i::InterceptorInfo> obj = | 931 i::Handle<i::InterceptorInfo> obj = |
907 i::Handle<i::InterceptorInfo>::cast(struct_obj); | 932 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
908 if (getter != 0) obj->set_getter(*FromCData(getter)); | 933 |
909 if (setter != 0) obj->set_setter(*FromCData(setter)); | 934 if (getter != 0) { |
910 if (query != 0) obj->set_query(*FromCData(query)); | 935 SetFieldWrapped(&i::InterceptorInfo::set_getter, obj, getter); |
911 if (remover != 0) obj->set_deleter(*FromCData(remover)); | 936 } |
912 if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator)); | 937 |
938 if (setter != 0) { | |
939 SetFieldWrapped(&i::InterceptorInfo::set_setter, obj, setter); | |
940 } | |
941 | |
942 if (query != 0) { | |
943 SetFieldWrapped(&i::InterceptorInfo::set_query, obj, query); | |
944 } | |
945 | |
946 if (remover != 0) { | |
947 SetFieldWrapped(&i::InterceptorInfo::set_deleter, obj, remover); | |
948 } | |
949 | |
950 if (enumerator != 0) { | |
951 SetFieldWrapped(&i::InterceptorInfo::set_enumerator, obj, enumerator); | |
952 } | |
953 | |
913 if (data.IsEmpty()) data = v8::Undefined(); | 954 if (data.IsEmpty()) data = v8::Undefined(); |
914 obj->set_data(*Utils::OpenHandle(*data)); | 955 obj->set_data(*Utils::OpenHandle(*data)); |
915 Utils::OpenHandle(this)->set_indexed_property_handler(*obj); | 956 Utils::OpenHandle(this)->set_indexed_property_handler(*obj); |
916 } | 957 } |
917 | 958 |
918 | 959 |
919 void FunctionTemplate::SetInstanceCallAsFunctionHandler( | 960 void FunctionTemplate::SetInstanceCallAsFunctionHandler( |
920 InvocationCallback callback, | 961 InvocationCallback callback, |
921 Handle<Value> data) { | 962 Handle<Value> data) { |
922 if (IsDeadCheck("v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) { | 963 if (IsDeadCheck("v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) { |
923 return; | 964 return; |
924 } | 965 } |
925 ENTER_V8; | 966 ENTER_V8; |
926 HandleScope scope; | 967 HandleScope scope; |
927 i::Handle<i::Struct> struct_obj = | 968 i::Handle<i::Struct> struct_obj = |
928 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE); | 969 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE); |
929 i::Handle<i::CallHandlerInfo> obj = | 970 i::Handle<i::CallHandlerInfo> obj = |
930 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 971 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
931 obj->set_callback(*FromCData(callback)); | 972 SetFieldWrapped(&i::CallHandlerInfo::set_callback, obj, callback); |
932 if (data.IsEmpty()) data = v8::Undefined(); | 973 if (data.IsEmpty()) data = v8::Undefined(); |
933 obj->set_data(*Utils::OpenHandle(*data)); | 974 obj->set_data(*Utils::OpenHandle(*data)); |
934 Utils::OpenHandle(this)->set_instance_call_handler(*obj); | 975 Utils::OpenHandle(this)->set_instance_call_handler(*obj); |
935 } | 976 } |
936 | 977 |
937 | 978 |
938 // --- O b j e c t T e m p l a t e --- | 979 // --- O b j e c t T e m p l a t e --- |
939 | 980 |
940 | 981 |
941 Local<ObjectTemplate> ObjectTemplate::New() { | 982 Local<ObjectTemplate> ObjectTemplate::New() { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1036 bool turned_on_by_default) { | 1077 bool turned_on_by_default) { |
1037 if (IsDeadCheck("v8::ObjectTemplate::SetAccessCheckCallbacks()")) return; | 1078 if (IsDeadCheck("v8::ObjectTemplate::SetAccessCheckCallbacks()")) return; |
1038 ENTER_V8; | 1079 ENTER_V8; |
1039 HandleScope scope; | 1080 HandleScope scope; |
1040 EnsureConstructor(this); | 1081 EnsureConstructor(this); |
1041 | 1082 |
1042 i::Handle<i::Struct> struct_info = | 1083 i::Handle<i::Struct> struct_info = |
1043 i::Factory::NewStruct(i::ACCESS_CHECK_INFO_TYPE); | 1084 i::Factory::NewStruct(i::ACCESS_CHECK_INFO_TYPE); |
1044 i::Handle<i::AccessCheckInfo> info = | 1085 i::Handle<i::AccessCheckInfo> info = |
1045 i::Handle<i::AccessCheckInfo>::cast(struct_info); | 1086 i::Handle<i::AccessCheckInfo>::cast(struct_info); |
1046 info->set_named_callback(*FromCData(named_callback)); | 1087 |
1047 info->set_indexed_callback(*FromCData(indexed_callback)); | 1088 SetFieldWrapped(&i::AccessCheckInfo::set_named_callback, |
1089 info, | |
1090 named_callback); | |
1091 | |
1092 SetFieldWrapped(&i::AccessCheckInfo::set_indexed_callback, | |
1093 info, | |
1094 indexed_callback); | |
1095 | |
1048 if (data.IsEmpty()) data = v8::Undefined(); | 1096 if (data.IsEmpty()) data = v8::Undefined(); |
1049 info->set_data(*Utils::OpenHandle(*data)); | 1097 info->set_data(*Utils::OpenHandle(*data)); |
1050 | 1098 |
1051 i::FunctionTemplateInfo* constructor = | 1099 i::FunctionTemplateInfo* constructor = |
1052 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 1100 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
1053 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1101 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1054 cons->set_access_check_info(*info); | 1102 cons->set_access_check_info(*info); |
1055 cons->set_needs_access_check(turned_on_by_default); | 1103 cons->set_needs_access_check(turned_on_by_default); |
1056 } | 1104 } |
1057 | 1105 |
(...skipping 3815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4873 | 4921 |
4874 | 4922 |
4875 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 4923 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
4876 HandleScopeImplementer* thread_local = | 4924 HandleScopeImplementer* thread_local = |
4877 reinterpret_cast<HandleScopeImplementer*>(storage); | 4925 reinterpret_cast<HandleScopeImplementer*>(storage); |
4878 thread_local->IterateThis(v); | 4926 thread_local->IterateThis(v); |
4879 return storage + ArchiveSpacePerThread(); | 4927 return storage + ArchiveSpacePerThread(); |
4880 } | 4928 } |
4881 | 4929 |
4882 } } // namespace v8::internal | 4930 } } // namespace v8::internal |
OLD | NEW |