| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2780 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); | 2780 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); |
| 2781 if (hidden_props->IsUndefined()) { | 2781 if (hidden_props->IsUndefined()) { |
| 2782 return true; | 2782 return true; |
| 2783 } | 2783 } |
| 2784 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props)); | 2784 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props)); |
| 2785 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 2785 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
| 2786 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); | 2786 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); |
| 2787 } | 2787 } |
| 2788 | 2788 |
| 2789 | 2789 |
| 2790 namespace { |
| 2791 |
| 2792 void PrepareExternalArrayElements(i::Handle<i::JSObject> object, |
| 2793 void* data, |
| 2794 ExternalArrayType array_type, |
| 2795 int length) { |
| 2796 i::Handle<i::ExternalArray> array = |
| 2797 FACTORY->NewExternalArray(length, array_type, data); |
| 2798 |
| 2799 // If the object already has external elements, create a new, unique |
| 2800 // map if the element type is now changing, because assumptions about |
| 2801 // generated code based on the receiver's map will be invalid. |
| 2802 i::Handle<i::HeapObject> elements(object->elements()); |
| 2803 bool force_unique_map = |
| 2804 elements->map()->IsUndefined() || |
| 2805 !elements->map()->has_external_array_elements() || |
| 2806 elements->map() != HEAP->MapForExternalArrayType(array_type); |
| 2807 if (force_unique_map) { |
| 2808 i::Handle<i::Map> external_array_map = |
| 2809 FACTORY->NewExternalArrayElementsMap( |
| 2810 i::Handle<i::Map>(object->map())); |
| 2811 object->set_map(*external_array_map); |
| 2812 } |
| 2813 object->set_elements(*array); |
| 2814 } |
| 2815 |
| 2816 } // namespace |
| 2817 |
| 2818 |
| 2790 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { | 2819 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { |
| 2791 ON_BAILOUT("v8::SetElementsToPixelData()", return); | 2820 ON_BAILOUT("v8::SetElementsToPixelData()", return); |
| 2792 ENTER_V8; | 2821 ENTER_V8; |
| 2793 HandleScope scope; | 2822 HandleScope scope; |
| 2794 if (!ApiCheck(length <= i::PixelArray::kMaxLength, | 2823 if (!ApiCheck(length <= i::ExternalPixelArray::kMaxLength, |
| 2795 "v8::Object::SetIndexedPropertiesToPixelData()", | 2824 "v8::Object::SetIndexedPropertiesToPixelData()", |
| 2796 "length exceeds max acceptable value")) { | 2825 "length exceeds max acceptable value")) { |
| 2797 return; | 2826 return; |
| 2798 } | 2827 } |
| 2799 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2828 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2800 if (!ApiCheck(!self->IsJSArray(), | 2829 if (!ApiCheck(!self->IsJSArray(), |
| 2801 "v8::Object::SetIndexedPropertiesToPixelData()", | 2830 "v8::Object::SetIndexedPropertiesToPixelData()", |
| 2802 "JSArray is not supported")) { | 2831 "JSArray is not supported")) { |
| 2803 return; | 2832 return; |
| 2804 } | 2833 } |
| 2805 i::Handle<i::PixelArray> pixels = FACTORY->NewPixelArray(length, data); | 2834 PrepareExternalArrayElements(self, data, kExternalPixelArray, length); |
| 2806 i::Handle<i::Map> pixel_array_map = | |
| 2807 FACTORY->GetPixelArrayElementsMap(i::Handle<i::Map>(self->map())); | |
| 2808 self->set_map(*pixel_array_map); | |
| 2809 self->set_elements(*pixels); | |
| 2810 } | 2835 } |
| 2811 | 2836 |
| 2812 | 2837 |
| 2813 bool v8::Object::HasIndexedPropertiesInPixelData() { | 2838 bool v8::Object::HasIndexedPropertiesInPixelData() { |
| 2814 ON_BAILOUT("v8::HasIndexedPropertiesInPixelData()", return false); | 2839 ON_BAILOUT("v8::HasIndexedPropertiesInPixelData()", return false); |
| 2815 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2840 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2816 return self->HasPixelElements(); | 2841 return self->HasExternalPixelElements(); |
| 2817 } | 2842 } |
| 2818 | 2843 |
| 2819 | 2844 |
| 2820 uint8_t* v8::Object::GetIndexedPropertiesPixelData() { | 2845 uint8_t* v8::Object::GetIndexedPropertiesPixelData() { |
| 2821 ON_BAILOUT("v8::GetIndexedPropertiesPixelData()", return NULL); | 2846 ON_BAILOUT("v8::GetIndexedPropertiesPixelData()", return NULL); |
| 2822 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2847 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2823 if (self->HasPixelElements()) { | 2848 if (self->HasExternalPixelElements()) { |
| 2824 return i::PixelArray::cast(self->elements())->external_pointer(); | 2849 return i::ExternalPixelArray::cast(self->elements())-> |
| 2850 external_pixel_pointer(); |
| 2825 } else { | 2851 } else { |
| 2826 return NULL; | 2852 return NULL; |
| 2827 } | 2853 } |
| 2828 } | 2854 } |
| 2829 | 2855 |
| 2830 | 2856 |
| 2831 int v8::Object::GetIndexedPropertiesPixelDataLength() { | 2857 int v8::Object::GetIndexedPropertiesPixelDataLength() { |
| 2832 ON_BAILOUT("v8::GetIndexedPropertiesPixelDataLength()", return -1); | 2858 ON_BAILOUT("v8::GetIndexedPropertiesPixelDataLength()", return -1); |
| 2833 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2859 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2834 if (self->HasPixelElements()) { | 2860 if (self->HasExternalPixelElements()) { |
| 2835 return i::PixelArray::cast(self->elements())->length(); | 2861 return i::ExternalPixelArray::cast(self->elements())->length(); |
| 2836 } else { | 2862 } else { |
| 2837 return -1; | 2863 return -1; |
| 2838 } | 2864 } |
| 2839 } | 2865 } |
| 2840 | 2866 |
| 2841 | |
| 2842 void v8::Object::SetIndexedPropertiesToExternalArrayData( | 2867 void v8::Object::SetIndexedPropertiesToExternalArrayData( |
| 2843 void* data, | 2868 void* data, |
| 2844 ExternalArrayType array_type, | 2869 ExternalArrayType array_type, |
| 2845 int length) { | 2870 int length) { |
| 2846 ON_BAILOUT("v8::SetIndexedPropertiesToExternalArrayData()", return); | 2871 ON_BAILOUT("v8::SetIndexedPropertiesToExternalArrayData()", return); |
| 2847 ENTER_V8; | 2872 ENTER_V8; |
| 2848 HandleScope scope; | 2873 HandleScope scope; |
| 2849 if (!ApiCheck(length <= i::ExternalArray::kMaxLength, | 2874 if (!ApiCheck(length <= i::ExternalArray::kMaxLength, |
| 2850 "v8::Object::SetIndexedPropertiesToExternalArrayData()", | 2875 "v8::Object::SetIndexedPropertiesToExternalArrayData()", |
| 2851 "length exceeds max acceptable value")) { | 2876 "length exceeds max acceptable value")) { |
| 2852 return; | 2877 return; |
| 2853 } | 2878 } |
| 2854 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2879 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2855 if (!ApiCheck(!self->IsJSArray(), | 2880 if (!ApiCheck(!self->IsJSArray(), |
| 2856 "v8::Object::SetIndexedPropertiesToExternalArrayData()", | 2881 "v8::Object::SetIndexedPropertiesToExternalArrayData()", |
| 2857 "JSArray is not supported")) { | 2882 "JSArray is not supported")) { |
| 2858 return; | 2883 return; |
| 2859 } | 2884 } |
| 2860 i::Handle<i::ExternalArray> array = | 2885 PrepareExternalArrayElements(self, data, array_type, length); |
| 2861 FACTORY->NewExternalArray(length, array_type, data); | |
| 2862 i::Handle<i::Map> slow_map = | |
| 2863 FACTORY->GetSlowElementsMap(i::Handle<i::Map>(self->map())); | |
| 2864 self->set_map(*slow_map); | |
| 2865 self->set_elements(*array); | |
| 2866 } | 2886 } |
| 2867 | 2887 |
| 2868 | 2888 |
| 2869 bool v8::Object::HasIndexedPropertiesInExternalArrayData() { | 2889 bool v8::Object::HasIndexedPropertiesInExternalArrayData() { |
| 2870 ON_BAILOUT("v8::HasIndexedPropertiesInExternalArrayData()", return false); | 2890 ON_BAILOUT("v8::HasIndexedPropertiesInExternalArrayData()", return false); |
| 2871 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2891 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2872 return self->HasExternalArrayElements(); | 2892 return self->HasExternalArrayElements(); |
| 2873 } | 2893 } |
| 2874 | 2894 |
| 2875 | 2895 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2896 case i::EXTERNAL_SHORT_ARRAY_TYPE: | 2916 case i::EXTERNAL_SHORT_ARRAY_TYPE: |
| 2897 return kExternalShortArray; | 2917 return kExternalShortArray; |
| 2898 case i::EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: | 2918 case i::EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 2899 return kExternalUnsignedShortArray; | 2919 return kExternalUnsignedShortArray; |
| 2900 case i::EXTERNAL_INT_ARRAY_TYPE: | 2920 case i::EXTERNAL_INT_ARRAY_TYPE: |
| 2901 return kExternalIntArray; | 2921 return kExternalIntArray; |
| 2902 case i::EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: | 2922 case i::EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 2903 return kExternalUnsignedIntArray; | 2923 return kExternalUnsignedIntArray; |
| 2904 case i::EXTERNAL_FLOAT_ARRAY_TYPE: | 2924 case i::EXTERNAL_FLOAT_ARRAY_TYPE: |
| 2905 return kExternalFloatArray; | 2925 return kExternalFloatArray; |
| 2926 case i::EXTERNAL_PIXEL_ARRAY_TYPE: |
| 2927 return kExternalPixelArray; |
| 2906 default: | 2928 default: |
| 2907 return static_cast<ExternalArrayType>(-1); | 2929 return static_cast<ExternalArrayType>(-1); |
| 2908 } | 2930 } |
| 2909 } | 2931 } |
| 2910 | 2932 |
| 2911 | 2933 |
| 2912 int v8::Object::GetIndexedPropertiesExternalArrayDataLength() { | 2934 int v8::Object::GetIndexedPropertiesExternalArrayDataLength() { |
| 2913 ON_BAILOUT("v8::GetIndexedPropertiesExternalArrayDataLength()", return 0); | 2935 ON_BAILOUT("v8::GetIndexedPropertiesExternalArrayDataLength()", return 0); |
| 2914 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2936 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2915 if (self->HasExternalArrayElements()) { | 2937 if (self->HasExternalArrayElements()) { |
| (...skipping 2289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5205 | 5227 |
| 5206 | 5228 |
| 5207 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 5229 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 5208 HandleScopeImplementer* thread_local = | 5230 HandleScopeImplementer* thread_local = |
| 5209 reinterpret_cast<HandleScopeImplementer*>(storage); | 5231 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 5210 thread_local->IterateThis(v); | 5232 thread_local->IterateThis(v); |
| 5211 return storage + ArchiveSpacePerThread(); | 5233 return storage + ArchiveSpacePerThread(); |
| 5212 } | 5234 } |
| 5213 | 5235 |
| 5214 } } // namespace v8::internal | 5236 } } // namespace v8::internal |
| OLD | NEW |