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

Side by Side Diff: src/api.cc

Issue 3446028: Merge r5509, r5512, r5530 to 2.3 branch ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/2.3/
Patch Set: '' Created 10 years, 2 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 | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \
771 i::Handle<i::Object> proxy = FromCData(cdata); \
772 (obj)->setter(*proxy); \
773 } while (false)
774
775
770 void FunctionTemplate::SetCallHandler(InvocationCallback callback, 776 void FunctionTemplate::SetCallHandler(InvocationCallback callback,
771 v8::Handle<Value> data) { 777 v8::Handle<Value> data) {
772 if (IsDeadCheck("v8::FunctionTemplate::SetCallHandler()")) return; 778 if (IsDeadCheck("v8::FunctionTemplate::SetCallHandler()")) return;
773 ENTER_V8; 779 ENTER_V8;
774 HandleScope scope; 780 HandleScope scope;
775 i::Handle<i::Struct> struct_obj = 781 i::Handle<i::Struct> struct_obj =
776 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE); 782 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE);
777 i::Handle<i::CallHandlerInfo> obj = 783 i::Handle<i::CallHandlerInfo> obj =
778 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 784 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
779 obj->set_callback(*FromCData(callback)); 785 SET_FIELD_WRAPPED(obj, set_callback, callback);
780 if (data.IsEmpty()) data = v8::Undefined(); 786 if (data.IsEmpty()) data = v8::Undefined();
781 obj->set_data(*Utils::OpenHandle(*data)); 787 obj->set_data(*Utils::OpenHandle(*data));
782 Utils::OpenHandle(this)->set_call_code(*obj); 788 Utils::OpenHandle(this)->set_call_code(*obj);
783 } 789 }
784 790
785 791
786 static i::Handle<i::AccessorInfo> MakeAccessorInfo( 792 static i::Handle<i::AccessorInfo> MakeAccessorInfo(
787 v8::Handle<String> name, 793 v8::Handle<String> name,
788 AccessorGetter getter, 794 AccessorGetter getter,
789 AccessorSetter setter, 795 AccessorSetter setter,
790 v8::Handle<Value> data, 796 v8::Handle<Value> data,
791 v8::AccessControl settings, 797 v8::AccessControl settings,
792 v8::PropertyAttribute attributes) { 798 v8::PropertyAttribute attributes) {
793 i::Handle<i::AccessorInfo> obj = i::Factory::NewAccessorInfo(); 799 i::Handle<i::AccessorInfo> obj = i::Factory::NewAccessorInfo();
794 ASSERT(getter != NULL); 800 ASSERT(getter != NULL);
795 obj->set_getter(*FromCData(getter)); 801 SET_FIELD_WRAPPED(obj, set_getter, getter);
796 obj->set_setter(*FromCData(setter)); 802 SET_FIELD_WRAPPED(obj, set_setter, setter);
797 if (data.IsEmpty()) data = v8::Undefined(); 803 if (data.IsEmpty()) data = v8::Undefined();
798 obj->set_data(*Utils::OpenHandle(*data)); 804 obj->set_data(*Utils::OpenHandle(*data));
799 obj->set_name(*Utils::OpenHandle(*name)); 805 obj->set_name(*Utils::OpenHandle(*name));
800 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); 806 if (settings & ALL_CAN_READ) obj->set_all_can_read(true);
801 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); 807 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true);
802 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); 808 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true);
803 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); 809 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes));
804 return obj; 810 return obj;
805 } 811 }
806 812
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 Handle<Value> data) { 876 Handle<Value> data) {
871 if (IsDeadCheck("v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) { 877 if (IsDeadCheck("v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) {
872 return; 878 return;
873 } 879 }
874 ENTER_V8; 880 ENTER_V8;
875 HandleScope scope; 881 HandleScope scope;
876 i::Handle<i::Struct> struct_obj = 882 i::Handle<i::Struct> struct_obj =
877 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE); 883 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE);
878 i::Handle<i::InterceptorInfo> obj = 884 i::Handle<i::InterceptorInfo> obj =
879 i::Handle<i::InterceptorInfo>::cast(struct_obj); 885 i::Handle<i::InterceptorInfo>::cast(struct_obj);
880 if (getter != 0) obj->set_getter(*FromCData(getter)); 886
881 if (setter != 0) obj->set_setter(*FromCData(setter)); 887 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
882 if (query != 0) obj->set_query(*FromCData(query)); 888 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
883 if (remover != 0) obj->set_deleter(*FromCData(remover)); 889 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
884 if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator)); 890 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
891 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
892
885 if (data.IsEmpty()) data = v8::Undefined(); 893 if (data.IsEmpty()) data = v8::Undefined();
886 obj->set_data(*Utils::OpenHandle(*data)); 894 obj->set_data(*Utils::OpenHandle(*data));
887 Utils::OpenHandle(this)->set_named_property_handler(*obj); 895 Utils::OpenHandle(this)->set_named_property_handler(*obj);
888 } 896 }
889 897
890 898
891 void FunctionTemplate::SetIndexedInstancePropertyHandler( 899 void FunctionTemplate::SetIndexedInstancePropertyHandler(
892 IndexedPropertyGetter getter, 900 IndexedPropertyGetter getter,
893 IndexedPropertySetter setter, 901 IndexedPropertySetter setter,
894 IndexedPropertyQuery query, 902 IndexedPropertyQuery query,
895 IndexedPropertyDeleter remover, 903 IndexedPropertyDeleter remover,
896 IndexedPropertyEnumerator enumerator, 904 IndexedPropertyEnumerator enumerator,
897 Handle<Value> data) { 905 Handle<Value> data) {
898 if (IsDeadCheck( 906 if (IsDeadCheck(
899 "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) { 907 "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) {
900 return; 908 return;
901 } 909 }
902 ENTER_V8; 910 ENTER_V8;
903 HandleScope scope; 911 HandleScope scope;
904 i::Handle<i::Struct> struct_obj = 912 i::Handle<i::Struct> struct_obj =
905 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE); 913 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE);
906 i::Handle<i::InterceptorInfo> obj = 914 i::Handle<i::InterceptorInfo> obj =
907 i::Handle<i::InterceptorInfo>::cast(struct_obj); 915 i::Handle<i::InterceptorInfo>::cast(struct_obj);
908 if (getter != 0) obj->set_getter(*FromCData(getter)); 916
909 if (setter != 0) obj->set_setter(*FromCData(setter)); 917 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
910 if (query != 0) obj->set_query(*FromCData(query)); 918 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
911 if (remover != 0) obj->set_deleter(*FromCData(remover)); 919 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
912 if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator)); 920 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
921 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
922
913 if (data.IsEmpty()) data = v8::Undefined(); 923 if (data.IsEmpty()) data = v8::Undefined();
914 obj->set_data(*Utils::OpenHandle(*data)); 924 obj->set_data(*Utils::OpenHandle(*data));
915 Utils::OpenHandle(this)->set_indexed_property_handler(*obj); 925 Utils::OpenHandle(this)->set_indexed_property_handler(*obj);
916 } 926 }
917 927
918 928
919 void FunctionTemplate::SetInstanceCallAsFunctionHandler( 929 void FunctionTemplate::SetInstanceCallAsFunctionHandler(
920 InvocationCallback callback, 930 InvocationCallback callback,
921 Handle<Value> data) { 931 Handle<Value> data) {
922 if (IsDeadCheck("v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) { 932 if (IsDeadCheck("v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) {
923 return; 933 return;
924 } 934 }
925 ENTER_V8; 935 ENTER_V8;
926 HandleScope scope; 936 HandleScope scope;
927 i::Handle<i::Struct> struct_obj = 937 i::Handle<i::Struct> struct_obj =
928 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE); 938 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE);
929 i::Handle<i::CallHandlerInfo> obj = 939 i::Handle<i::CallHandlerInfo> obj =
930 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 940 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
931 obj->set_callback(*FromCData(callback)); 941 SET_FIELD_WRAPPED(obj, set_callback, callback);
932 if (data.IsEmpty()) data = v8::Undefined(); 942 if (data.IsEmpty()) data = v8::Undefined();
933 obj->set_data(*Utils::OpenHandle(*data)); 943 obj->set_data(*Utils::OpenHandle(*data));
934 Utils::OpenHandle(this)->set_instance_call_handler(*obj); 944 Utils::OpenHandle(this)->set_instance_call_handler(*obj);
935 } 945 }
936 946
937 947
938 // --- O b j e c t T e m p l a t e --- 948 // --- O b j e c t T e m p l a t e ---
939 949
940 950
941 Local<ObjectTemplate> ObjectTemplate::New() { 951 Local<ObjectTemplate> ObjectTemplate::New() {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 bool turned_on_by_default) { 1046 bool turned_on_by_default) {
1037 if (IsDeadCheck("v8::ObjectTemplate::SetAccessCheckCallbacks()")) return; 1047 if (IsDeadCheck("v8::ObjectTemplate::SetAccessCheckCallbacks()")) return;
1038 ENTER_V8; 1048 ENTER_V8;
1039 HandleScope scope; 1049 HandleScope scope;
1040 EnsureConstructor(this); 1050 EnsureConstructor(this);
1041 1051
1042 i::Handle<i::Struct> struct_info = 1052 i::Handle<i::Struct> struct_info =
1043 i::Factory::NewStruct(i::ACCESS_CHECK_INFO_TYPE); 1053 i::Factory::NewStruct(i::ACCESS_CHECK_INFO_TYPE);
1044 i::Handle<i::AccessCheckInfo> info = 1054 i::Handle<i::AccessCheckInfo> info =
1045 i::Handle<i::AccessCheckInfo>::cast(struct_info); 1055 i::Handle<i::AccessCheckInfo>::cast(struct_info);
1046 info->set_named_callback(*FromCData(named_callback)); 1056
1047 info->set_indexed_callback(*FromCData(indexed_callback)); 1057 SET_FIELD_WRAPPED(info, set_named_callback, named_callback);
1058 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback);
1059
1048 if (data.IsEmpty()) data = v8::Undefined(); 1060 if (data.IsEmpty()) data = v8::Undefined();
1049 info->set_data(*Utils::OpenHandle(*data)); 1061 info->set_data(*Utils::OpenHandle(*data));
1050 1062
1051 i::FunctionTemplateInfo* constructor = 1063 i::FunctionTemplateInfo* constructor =
1052 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1064 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1053 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1065 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1054 cons->set_access_check_info(*info); 1066 cons->set_access_check_info(*info);
1055 cons->set_needs_access_check(turned_on_by_default); 1067 cons->set_needs_access_check(turned_on_by_default);
1056 } 1068 }
1057 1069
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 "length exceeds max acceptable value")) { 2646 "length exceeds max acceptable value")) {
2635 return; 2647 return;
2636 } 2648 }
2637 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2649 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2638 if (!ApiCheck(!self->IsJSArray(), 2650 if (!ApiCheck(!self->IsJSArray(),
2639 "v8::Object::SetIndexedPropertiesToPixelData()", 2651 "v8::Object::SetIndexedPropertiesToPixelData()",
2640 "JSArray is not supported")) { 2652 "JSArray is not supported")) {
2641 return; 2653 return;
2642 } 2654 }
2643 i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(length, data); 2655 i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(length, data);
2644 self->set_map( 2656 i::Handle<i::Map> slow_map =
2645 *i::Factory::GetSlowElementsMap(i::Handle<i::Map>(self->map()))); 2657 i::Factory::GetSlowElementsMap(i::Handle<i::Map>(self->map()));
2658 self->set_map(*slow_map);
2646 self->set_elements(*pixels); 2659 self->set_elements(*pixels);
2647 } 2660 }
2648 2661
2649 2662
2650 bool v8::Object::HasIndexedPropertiesInPixelData() { 2663 bool v8::Object::HasIndexedPropertiesInPixelData() {
2651 ON_BAILOUT("v8::HasIndexedPropertiesInPixelData()", return false); 2664 ON_BAILOUT("v8::HasIndexedPropertiesInPixelData()", return false);
2652 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2665 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2653 return self->HasPixelElements(); 2666 return self->HasPixelElements();
2654 } 2667 }
2655 2668
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2689 return; 2702 return;
2690 } 2703 }
2691 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2704 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2692 if (!ApiCheck(!self->IsJSArray(), 2705 if (!ApiCheck(!self->IsJSArray(),
2693 "v8::Object::SetIndexedPropertiesToExternalArrayData()", 2706 "v8::Object::SetIndexedPropertiesToExternalArrayData()",
2694 "JSArray is not supported")) { 2707 "JSArray is not supported")) {
2695 return; 2708 return;
2696 } 2709 }
2697 i::Handle<i::ExternalArray> array = 2710 i::Handle<i::ExternalArray> array =
2698 i::Factory::NewExternalArray(length, array_type, data); 2711 i::Factory::NewExternalArray(length, array_type, data);
2699 self->set_map( 2712 i::Handle<i::Map> slow_map =
2700 *i::Factory::GetSlowElementsMap(i::Handle<i::Map>(self->map()))); 2713 i::Factory::GetSlowElementsMap(i::Handle<i::Map>(self->map()));
2714 self->set_map(*slow_map);
2701 self->set_elements(*array); 2715 self->set_elements(*array);
2702 } 2716 }
2703 2717
2704 2718
2705 bool v8::Object::HasIndexedPropertiesInExternalArrayData() { 2719 bool v8::Object::HasIndexedPropertiesInExternalArrayData() {
2706 ON_BAILOUT("v8::HasIndexedPropertiesInExternalArrayData()", return false); 2720 ON_BAILOUT("v8::HasIndexedPropertiesInExternalArrayData()", return false);
2707 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2721 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2708 return self->HasExternalArrayElements(); 2722 return self->HasExternalArrayElements();
2709 } 2723 }
2710 2724
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after
4835 4849
4836 4850
4837 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 4851 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
4838 HandleScopeImplementer* thread_local = 4852 HandleScopeImplementer* thread_local =
4839 reinterpret_cast<HandleScopeImplementer*>(storage); 4853 reinterpret_cast<HandleScopeImplementer*>(storage);
4840 thread_local->IterateThis(v); 4854 thread_local->IterateThis(v);
4841 return storage + ArchiveSpacePerThread(); 4855 return storage + ArchiveSpacePerThread();
4842 } 4856 }
4843 4857
4844 } } // namespace v8::internal 4858 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698