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

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: final version before commit 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
« no previous file with comments | « src/heap.h ('k') | src/mark-compact.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 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 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 1302
1303 template<LoggingAndProfiling logging_and_profiling_mode> 1303 template<LoggingAndProfiling logging_and_profiling_mode>
1304 class ScavengingVisitor : public StaticVisitorBase { 1304 class ScavengingVisitor : public StaticVisitorBase {
1305 public: 1305 public:
1306 static void Initialize() { 1306 static void Initialize() {
1307 table_.Register(kVisitSeqAsciiString, &EvacuateSeqAsciiString); 1307 table_.Register(kVisitSeqAsciiString, &EvacuateSeqAsciiString);
1308 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString); 1308 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString);
1309 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate); 1309 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate);
1310 table_.Register(kVisitByteArray, &EvacuateByteArray); 1310 table_.Register(kVisitByteArray, &EvacuateByteArray);
1311 table_.Register(kVisitFixedArray, &EvacuateFixedArray); 1311 table_.Register(kVisitFixedArray, &EvacuateFixedArray);
1312 table_.Register(kVisitFixedDoubleArray, &EvacuateFixedDoubleArray);
1312 1313
1313 table_.Register(kVisitGlobalContext, 1314 table_.Register(kVisitGlobalContext,
1314 &ObjectEvacuationStrategy<POINTER_OBJECT>:: 1315 &ObjectEvacuationStrategy<POINTER_OBJECT>::
1315 template VisitSpecialized<Context::kSize>); 1316 template VisitSpecialized<Context::kSize>);
1316 1317
1317 table_.Register(kVisitConsString, 1318 table_.Register(kVisitConsString,
1318 &ObjectEvacuationStrategy<POINTER_OBJECT>:: 1319 &ObjectEvacuationStrategy<POINTER_OBJECT>::
1319 template VisitSpecialized<ConsString::kSize>); 1320 template VisitSpecialized<ConsString::kSize>);
1320 1321
1321 table_.Register(kVisitSharedFunctionInfo, 1322 table_.Register(kVisitSharedFunctionInfo,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 HeapObject** slot, 1450 HeapObject** slot,
1450 HeapObject* object) { 1451 HeapObject* object) {
1451 int object_size = FixedArray::BodyDescriptor::SizeOf(map, object); 1452 int object_size = FixedArray::BodyDescriptor::SizeOf(map, object);
1452 EvacuateObject<POINTER_OBJECT, UNKNOWN_SIZE>(map, 1453 EvacuateObject<POINTER_OBJECT, UNKNOWN_SIZE>(map,
1453 slot, 1454 slot,
1454 object, 1455 object,
1455 object_size); 1456 object_size);
1456 } 1457 }
1457 1458
1458 1459
1460 static inline void EvacuateFixedDoubleArray(Map* map,
1461 HeapObject** slot,
1462 HeapObject* object) {
1463 int length = reinterpret_cast<FixedDoubleArray*>(object)->length();
1464 int object_size = FixedDoubleArray::SizeFor(length);
1465 EvacuateObject<DATA_OBJECT, UNKNOWN_SIZE>(map,
1466 slot,
1467 object,
1468 object_size);
1469 }
1470
1471
1459 static inline void EvacuateByteArray(Map* map, 1472 static inline void EvacuateByteArray(Map* map,
1460 HeapObject** slot, 1473 HeapObject** slot,
1461 HeapObject* object) { 1474 HeapObject* object) {
1462 int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize(); 1475 int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize();
1463 EvacuateObject<DATA_OBJECT, UNKNOWN_SIZE>(map, slot, object, object_size); 1476 EvacuateObject<DATA_OBJECT, UNKNOWN_SIZE>(map, slot, object, object_size);
1464 } 1477 }
1465 1478
1466 1479
1467 static inline void EvacuateSeqAsciiString(Map* map, 1480 static inline void EvacuateSeqAsciiString(Map* map,
1468 HeapObject** slot, 1481 HeapObject** slot,
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 Map::cast(obj)->set_is_undetectable(); 1801 Map::cast(obj)->set_is_undetectable();
1789 1802
1790 { MaybeObject* maybe_obj = 1803 { MaybeObject* maybe_obj =
1791 AllocateMap(ASCII_STRING_TYPE, kVariableSizeSentinel); 1804 AllocateMap(ASCII_STRING_TYPE, kVariableSizeSentinel);
1792 if (!maybe_obj->ToObject(&obj)) return false; 1805 if (!maybe_obj->ToObject(&obj)) return false;
1793 } 1806 }
1794 set_undetectable_ascii_string_map(Map::cast(obj)); 1807 set_undetectable_ascii_string_map(Map::cast(obj));
1795 Map::cast(obj)->set_is_undetectable(); 1808 Map::cast(obj)->set_is_undetectable();
1796 1809
1797 { MaybeObject* maybe_obj = 1810 { MaybeObject* maybe_obj =
1811 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel);
1812 if (!maybe_obj->ToObject(&obj)) return false;
1813 }
1814 set_fixed_double_array_map(Map::cast(obj));
1815
1816 { MaybeObject* maybe_obj =
1798 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); 1817 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel);
1799 if (!maybe_obj->ToObject(&obj)) return false; 1818 if (!maybe_obj->ToObject(&obj)) return false;
1800 } 1819 }
1801 set_byte_array_map(Map::cast(obj)); 1820 set_byte_array_map(Map::cast(obj));
1802 1821
1803 { MaybeObject* maybe_obj = AllocateByteArray(0, TENURED); 1822 { MaybeObject* maybe_obj = AllocateByteArray(0, TENURED);
1804 if (!maybe_obj->ToObject(&obj)) return false; 1823 if (!maybe_obj->ToObject(&obj)) return false;
1805 } 1824 }
1806 set_empty_byte_array(ByteArray::cast(obj)); 1825 set_empty_byte_array(ByteArray::cast(obj));
1807 1826
(...skipping 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after
3828 { MaybeObject* maybe_obj = AllocateRawFixedArray(length); 3847 { MaybeObject* maybe_obj = AllocateRawFixedArray(length);
3829 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 3848 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3830 } 3849 }
3831 3850
3832 reinterpret_cast<FixedArray*>(obj)->set_map(fixed_array_map()); 3851 reinterpret_cast<FixedArray*>(obj)->set_map(fixed_array_map());
3833 FixedArray::cast(obj)->set_length(length); 3852 FixedArray::cast(obj)->set_length(length);
3834 return obj; 3853 return obj;
3835 } 3854 }
3836 3855
3837 3856
3857 MaybeObject* Heap::AllocateEmptyFixedDoubleArray() {
3858 int size = FixedDoubleArray::SizeFor(0);
3859 Object* result;
3860 { MaybeObject* maybe_result =
3861 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE);
3862 if (!maybe_result->ToObject(&result)) return maybe_result;
3863 }
3864 // Initialize the object.
3865 reinterpret_cast<FixedDoubleArray*>(result)->set_map(
3866 fixed_double_array_map());
3867 reinterpret_cast<FixedDoubleArray*>(result)->set_length(0);
3868 return result;
3869 }
3870
3871
3872 MaybeObject* Heap::AllocateUninitializedFixedDoubleArray(
3873 int length,
3874 PretenureFlag pretenure) {
3875 if (length == 0) return empty_fixed_double_array();
3876
3877 Object* obj;
3878 { MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(length, pretenure);
3879 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3880 }
3881
3882 reinterpret_cast<FixedDoubleArray*>(obj)->set_map(fixed_double_array_map());
3883 FixedDoubleArray::cast(obj)->set_length(length);
3884 return obj;
3885 }
3886
3887
3888 MaybeObject* Heap::AllocateRawFixedDoubleArray(int length,
3889 PretenureFlag pretenure) {
3890 if (length < 0 || length > FixedDoubleArray::kMaxLength) {
3891 return Failure::OutOfMemoryException();
3892 }
3893
3894 AllocationSpace space =
3895 (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE;
3896 int size = FixedDoubleArray::SizeFor(length);
3897 if (space == NEW_SPACE && size > kMaxObjectSizeInNewSpace) {
3898 // Too big for new space.
3899 space = LO_SPACE;
3900 } else if (space == OLD_DATA_SPACE &&
3901 size > MaxObjectSizeInPagedSpace()) {
3902 // Too big for old data space.
3903 space = LO_SPACE;
3904 }
3905
3906 AllocationSpace retry_space =
3907 (size <= MaxObjectSizeInPagedSpace()) ? OLD_DATA_SPACE : LO_SPACE;
3908
3909 return AllocateRaw(size, space, retry_space);
3910 }
3911
3912
3838 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { 3913 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) {
3839 Object* result; 3914 Object* result;
3840 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); 3915 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure);
3841 if (!maybe_result->ToObject(&result)) return maybe_result; 3916 if (!maybe_result->ToObject(&result)) return maybe_result;
3842 } 3917 }
3843 reinterpret_cast<HeapObject*>(result)->set_map(hash_table_map()); 3918 reinterpret_cast<HeapObject*>(result)->set_map(hash_table_map());
3844 ASSERT(result->IsHashTable()); 3919 ASSERT(result->IsHashTable());
3845 return result; 3920 return result;
3846 } 3921 }
3847 3922
(...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after
5964 } 6039 }
5965 6040
5966 6041
5967 void ExternalStringTable::TearDown() { 6042 void ExternalStringTable::TearDown() {
5968 new_space_strings_.Free(); 6043 new_space_strings_.Free();
5969 old_space_strings_.Free(); 6044 old_space_strings_.Free();
5970 } 6045 }
5971 6046
5972 6047
5973 } } // namespace v8::internal 6048 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698