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

Side by Side Diff: src/heap.cc

Issue 7089002: Implement core support for FixedDoubleArrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: tweaks Created 9 years, 6 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 Map::cast(obj)->set_is_undetectable(); 1779 Map::cast(obj)->set_is_undetectable();
1780 1780
1781 { MaybeObject* maybe_obj = 1781 { MaybeObject* maybe_obj =
1782 AllocateMap(ASCII_STRING_TYPE, kVariableSizeSentinel); 1782 AllocateMap(ASCII_STRING_TYPE, kVariableSizeSentinel);
1783 if (!maybe_obj->ToObject(&obj)) return false; 1783 if (!maybe_obj->ToObject(&obj)) return false;
1784 } 1784 }
1785 set_undetectable_ascii_string_map(Map::cast(obj)); 1785 set_undetectable_ascii_string_map(Map::cast(obj));
1786 Map::cast(obj)->set_is_undetectable(); 1786 Map::cast(obj)->set_is_undetectable();
1787 1787
1788 { MaybeObject* maybe_obj = 1788 { MaybeObject* maybe_obj =
1789 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel);
1790 if (!maybe_obj->ToObject(&obj)) return false;
1791 }
1792 set_fixed_double_array_map(Map::cast(obj));
1793
1794 { MaybeObject* maybe_obj =
1789 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); 1795 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel);
1790 if (!maybe_obj->ToObject(&obj)) return false; 1796 if (!maybe_obj->ToObject(&obj)) return false;
1791 } 1797 }
1792 set_byte_array_map(Map::cast(obj)); 1798 set_byte_array_map(Map::cast(obj));
1793 1799
1794 { MaybeObject* maybe_obj = AllocateByteArray(0, TENURED); 1800 { MaybeObject* maybe_obj = AllocateByteArray(0, TENURED);
1795 if (!maybe_obj->ToObject(&obj)) return false; 1801 if (!maybe_obj->ToObject(&obj)) return false;
1796 } 1802 }
1797 set_empty_byte_array(ByteArray::cast(obj)); 1803 set_empty_byte_array(ByteArray::cast(obj));
1798 1804
(...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after
3814 { MaybeObject* maybe_obj = AllocateRawFixedArray(length); 3820 { MaybeObject* maybe_obj = AllocateRawFixedArray(length);
3815 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 3821 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3816 } 3822 }
3817 3823
3818 reinterpret_cast<FixedArray*>(obj)->set_map(fixed_array_map()); 3824 reinterpret_cast<FixedArray*>(obj)->set_map(fixed_array_map());
3819 FixedArray::cast(obj)->set_length(length); 3825 FixedArray::cast(obj)->set_length(length);
3820 return obj; 3826 return obj;
3821 } 3827 }
3822 3828
3823 3829
3830 MaybeObject* Heap::AllocateEmptyFixedDoubleArray() {
3831 int size = FixedDoubleArray::SizeFor(0);
3832 Object* result;
3833 { MaybeObject* maybe_result =
3834 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE);
3835 if (!maybe_result->ToObject(&result)) return maybe_result;
3836 }
3837 // Initialize the object.
3838 reinterpret_cast<FixedDoubleArray*>(result)->set_map(
3839 fixed_double_array_map());
3840 reinterpret_cast<FixedDoubleArray*>(result)->set_length(0);
3841 return result;
3842 }
3843
3844
3845 MaybeObject* Heap::AllocateFixedDoubleArray(int length,
3846 PretenureFlag pretenure) {
3847 if (length == 0) return empty_fixed_double_array();
3848
3849 Object* obj;
3850 { MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(length, pretenure);
3851 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3852 }
3853
3854 reinterpret_cast<FixedDoubleArray*>(obj)->set_map(fixed_double_array_map());
Mads Ager (chromium) 2011/06/06 07:58:23 No initialization of the body at all? Could you ca
danno 2011/06/08 12:09:43 Done.
3855 FixedDoubleArray::cast(obj)->set_length(length);
3856 return obj;
3857 }
3858
3859
3860 MaybeObject* Heap::AllocateRawFixedDoubleArray(int length,
3861 PretenureFlag pretenure) {
3862 if (length < 0 || length > FixedDoubleArray::kMaxLength) {
3863 return Failure::OutOfMemoryException();
3864 }
3865
3866 AllocationSpace space =
3867 (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE;
3868 int size = FixedDoubleArray::SizeFor(length);
3869 if (space == NEW_SPACE && size > kMaxObjectSizeInNewSpace) {
3870 // Too big for new space.
3871 space = LO_SPACE;
3872 } else if (space == OLD_DATA_SPACE &&
3873 size > MaxObjectSizeInPagedSpace()) {
3874 // Too big for old data space.
3875 space = LO_SPACE;
3876 }
3877
3878 AllocationSpace retry_space =
3879 (size <= MaxObjectSizeInPagedSpace()) ? OLD_DATA_SPACE : LO_SPACE;
3880
3881 return AllocateRaw(size, space, retry_space);
3882 }
3883
3884
3824 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { 3885 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) {
3825 Object* result; 3886 Object* result;
3826 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); 3887 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure);
3827 if (!maybe_result->ToObject(&result)) return maybe_result; 3888 if (!maybe_result->ToObject(&result)) return maybe_result;
3828 } 3889 }
3829 reinterpret_cast<HeapObject*>(result)->set_map(hash_table_map()); 3890 reinterpret_cast<HeapObject*>(result)->set_map(hash_table_map());
3830 ASSERT(result->IsHashTable()); 3891 ASSERT(result->IsHashTable());
3831 return result; 3892 return result;
3832 } 3893 }
3833 3894
(...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after
5950 } 6011 }
5951 6012
5952 6013
5953 void ExternalStringTable::TearDown() { 6014 void ExternalStringTable::TearDown() {
5954 new_space_strings_.Free(); 6015 new_space_strings_.Free();
5955 old_space_strings_.Free(); 6016 old_space_strings_.Free();
5956 } 6017 }
5957 6018
5958 6019
5959 } } // namespace v8::internal 6020 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698