OLD | NEW |
---|---|
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 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1300 } | 1300 } |
1301 | 1301 |
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); |
Vyacheslav Egorov (Chromium)
2011/06/08 12:31:16
If FixedDoubleArray can be in the new space you ne
danno
2011/06/09 09:45:40
Done.
| |
1311 table_.Register(kVisitFixedArray, &EvacuateFixedArray); | 1311 table_.Register(kVisitFixedArray, &EvacuateFixedArray); |
1312 | 1312 |
1313 table_.Register(kVisitGlobalContext, | 1313 table_.Register(kVisitGlobalContext, |
1314 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 1314 &ObjectEvacuationStrategy<POINTER_OBJECT>:: |
1315 template VisitSpecialized<Context::kSize>); | 1315 template VisitSpecialized<Context::kSize>); |
1316 | 1316 |
1317 table_.Register(kVisitConsString, | 1317 table_.Register(kVisitConsString, |
1318 &ObjectEvacuationStrategy<POINTER_OBJECT>:: | 1318 &ObjectEvacuationStrategy<POINTER_OBJECT>:: |
1319 template VisitSpecialized<ConsString::kSize>); | 1319 template VisitSpecialized<ConsString::kSize>); |
1320 | 1320 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1788 Map::cast(obj)->set_is_undetectable(); | 1788 Map::cast(obj)->set_is_undetectable(); |
1789 | 1789 |
1790 { MaybeObject* maybe_obj = | 1790 { MaybeObject* maybe_obj = |
1791 AllocateMap(ASCII_STRING_TYPE, kVariableSizeSentinel); | 1791 AllocateMap(ASCII_STRING_TYPE, kVariableSizeSentinel); |
1792 if (!maybe_obj->ToObject(&obj)) return false; | 1792 if (!maybe_obj->ToObject(&obj)) return false; |
1793 } | 1793 } |
1794 set_undetectable_ascii_string_map(Map::cast(obj)); | 1794 set_undetectable_ascii_string_map(Map::cast(obj)); |
1795 Map::cast(obj)->set_is_undetectable(); | 1795 Map::cast(obj)->set_is_undetectable(); |
1796 | 1796 |
1797 { MaybeObject* maybe_obj = | 1797 { MaybeObject* maybe_obj = |
1798 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel); | |
1799 if (!maybe_obj->ToObject(&obj)) return false; | |
1800 } | |
1801 set_fixed_double_array_map(Map::cast(obj)); | |
1802 | |
1803 { MaybeObject* maybe_obj = | |
1798 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); | 1804 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); |
1799 if (!maybe_obj->ToObject(&obj)) return false; | 1805 if (!maybe_obj->ToObject(&obj)) return false; |
1800 } | 1806 } |
1801 set_byte_array_map(Map::cast(obj)); | 1807 set_byte_array_map(Map::cast(obj)); |
1802 | 1808 |
1803 { MaybeObject* maybe_obj = AllocateByteArray(0, TENURED); | 1809 { MaybeObject* maybe_obj = AllocateByteArray(0, TENURED); |
1804 if (!maybe_obj->ToObject(&obj)) return false; | 1810 if (!maybe_obj->ToObject(&obj)) return false; |
1805 } | 1811 } |
1806 set_empty_byte_array(ByteArray::cast(obj)); | 1812 set_empty_byte_array(ByteArray::cast(obj)); |
1807 | 1813 |
(...skipping 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3828 { MaybeObject* maybe_obj = AllocateRawFixedArray(length); | 3834 { MaybeObject* maybe_obj = AllocateRawFixedArray(length); |
3829 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 3835 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
3830 } | 3836 } |
3831 | 3837 |
3832 reinterpret_cast<FixedArray*>(obj)->set_map(fixed_array_map()); | 3838 reinterpret_cast<FixedArray*>(obj)->set_map(fixed_array_map()); |
3833 FixedArray::cast(obj)->set_length(length); | 3839 FixedArray::cast(obj)->set_length(length); |
3834 return obj; | 3840 return obj; |
3835 } | 3841 } |
3836 | 3842 |
3837 | 3843 |
3844 MaybeObject* Heap::AllocateEmptyFixedDoubleArray() { | |
3845 int size = FixedDoubleArray::SizeFor(0); | |
3846 Object* result; | |
3847 { MaybeObject* maybe_result = | |
3848 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); | |
3849 if (!maybe_result->ToObject(&result)) return maybe_result; | |
3850 } | |
3851 // Initialize the object. | |
3852 reinterpret_cast<FixedDoubleArray*>(result)->set_map( | |
3853 fixed_double_array_map()); | |
3854 reinterpret_cast<FixedDoubleArray*>(result)->set_length(0); | |
3855 return result; | |
3856 } | |
3857 | |
3858 | |
3859 MaybeObject* Heap::AllocateUninitializedFixedDoubleArray( | |
3860 int length, | |
3861 PretenureFlag pretenure) { | |
3862 if (length == 0) return empty_fixed_double_array(); | |
3863 | |
3864 Object* obj; | |
3865 { MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(length, pretenure); | |
3866 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | |
3867 } | |
3868 | |
3869 reinterpret_cast<FixedDoubleArray*>(obj)->set_map(fixed_double_array_map()); | |
3870 FixedDoubleArray::cast(obj)->set_length(length); | |
3871 return obj; | |
3872 } | |
3873 | |
3874 | |
3875 MaybeObject* Heap::AllocateRawFixedDoubleArray(int length, | |
3876 PretenureFlag pretenure) { | |
3877 if (length < 0 || length > FixedDoubleArray::kMaxLength) { | |
3878 return Failure::OutOfMemoryException(); | |
3879 } | |
3880 | |
3881 AllocationSpace space = | |
3882 (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | |
3883 int size = FixedDoubleArray::SizeFor(length); | |
3884 if (space == NEW_SPACE && size > kMaxObjectSizeInNewSpace) { | |
3885 // Too big for new space. | |
3886 space = LO_SPACE; | |
3887 } else if (space == OLD_DATA_SPACE && | |
3888 size > MaxObjectSizeInPagedSpace()) { | |
3889 // Too big for old data space. | |
3890 space = LO_SPACE; | |
3891 } | |
3892 | |
3893 AllocationSpace retry_space = | |
3894 (size <= MaxObjectSizeInPagedSpace()) ? OLD_DATA_SPACE : LO_SPACE; | |
3895 | |
3896 return AllocateRaw(size, space, retry_space); | |
3897 } | |
3898 | |
3899 | |
3838 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { | 3900 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { |
3839 Object* result; | 3901 Object* result; |
3840 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); | 3902 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); |
3841 if (!maybe_result->ToObject(&result)) return maybe_result; | 3903 if (!maybe_result->ToObject(&result)) return maybe_result; |
3842 } | 3904 } |
3843 reinterpret_cast<HeapObject*>(result)->set_map(hash_table_map()); | 3905 reinterpret_cast<HeapObject*>(result)->set_map(hash_table_map()); |
3844 ASSERT(result->IsHashTable()); | 3906 ASSERT(result->IsHashTable()); |
3845 return result; | 3907 return result; |
3846 } | 3908 } |
3847 | 3909 |
(...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5964 } | 6026 } |
5965 | 6027 |
5966 | 6028 |
5967 void ExternalStringTable::TearDown() { | 6029 void ExternalStringTable::TearDown() { |
5968 new_space_strings_.Free(); | 6030 new_space_strings_.Free(); |
5969 old_space_strings_.Free(); | 6031 old_space_strings_.Free(); |
5970 } | 6032 } |
5971 | 6033 |
5972 | 6034 |
5973 } } // namespace v8::internal | 6035 } } // namespace v8::internal |
OLD | NEW |