| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 217 |
| 218 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { | 218 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { |
| 219 ASSERT(!Heap::InNewSpace(object)); // Code only works for old objects. | 219 ASSERT(!Heap::InNewSpace(object)); // Code only works for old objects. |
| 220 ASSERT(!MarkCompactCollector::are_map_pointers_encoded()); | 220 ASSERT(!MarkCompactCollector::are_map_pointers_encoded()); |
| 221 MapWord map_word = object->map_word(); | 221 MapWord map_word = object->map_word(); |
| 222 map_word.ClearMark(); | 222 map_word.ClearMark(); |
| 223 map_word.ClearOverflow(); | 223 map_word.ClearOverflow(); |
| 224 return object->SizeFromMap(map_word.ToMap()); | 224 return object->SizeFromMap(map_word.ToMap()); |
| 225 } | 225 } |
| 226 | 226 |
| 227 | 227 #ifndef BASELINE_GC |
| 228 int Heap::GcSafeSizeOfOldObjectWithEncodedMap(HeapObject* object) { | 228 int Heap::GcSafeSizeOfOldObjectWithEncodedMap(HeapObject* object) { |
| 229 ASSERT(!Heap::InNewSpace(object)); // Code only works for old objects. | 229 ASSERT(!Heap::InNewSpace(object)); // Code only works for old objects. |
| 230 ASSERT(MarkCompactCollector::are_map_pointers_encoded()); | 230 ASSERT(MarkCompactCollector::are_map_pointers_encoded()); |
| 231 uint32_t marker = Memory::uint32_at(object->address()); | 231 uint32_t marker = Memory::uint32_at(object->address()); |
| 232 if (marker == MarkCompactCollector::kSingleFreeEncoding) { | 232 if (marker == MarkCompactCollector::kSingleFreeEncoding) { |
| 233 return kIntSize; | 233 return kIntSize; |
| 234 } else if (marker == MarkCompactCollector::kMultiFreeEncoding) { | 234 } else if (marker == MarkCompactCollector::kMultiFreeEncoding) { |
| 235 return Memory::int_at(object->address() + kIntSize); | 235 return Memory::int_at(object->address() + kIntSize); |
| 236 } else { | 236 } else { |
| 237 MapWord map_word = object->map_word(); | 237 MapWord map_word = object->map_word(); |
| 238 Address map_address = map_word.DecodeMapAddress(Heap::map_space()); | 238 Address map_address = map_word.DecodeMapAddress(Heap::map_space()); |
| 239 Map* map = reinterpret_cast<Map*>(HeapObject::FromAddress(map_address)); | 239 Map* map = reinterpret_cast<Map*>(HeapObject::FromAddress(map_address)); |
| 240 return object->SizeFromMap(map); | 240 return object->SizeFromMap(map); |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 #endif |
| 243 | 244 |
| 244 | 245 |
| 245 GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space) { | 246 GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space) { |
| 246 // Is global GC requested? | 247 // Is global GC requested? |
| 247 if (space != NEW_SPACE || FLAG_gc_global) { | 248 if (space != NEW_SPACE || FLAG_gc_global) { |
| 248 Counters::gc_compactor_caused_by_request.Increment(); | 249 Counters::gc_compactor_caused_by_request.Increment(); |
| 249 return MARK_COMPACTOR; | 250 return MARK_COMPACTOR; |
| 250 } | 251 } |
| 251 | 252 |
| 252 // Is enough data promoted to justify a global GC? | 253 // Is enough data promoted to justify a global GC? |
| (...skipping 3724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3977 | 3978 |
| 3978 | 3979 |
| 3979 void Heap::Verify() { | 3980 void Heap::Verify() { |
| 3980 ASSERT(HasBeenSetup()); | 3981 ASSERT(HasBeenSetup()); |
| 3981 | 3982 |
| 3982 VerifyPointersVisitor visitor; | 3983 VerifyPointersVisitor visitor; |
| 3983 IterateRoots(&visitor, VISIT_ONLY_STRONG); | 3984 IterateRoots(&visitor, VISIT_ONLY_STRONG); |
| 3984 | 3985 |
| 3985 new_space_.Verify(); | 3986 new_space_.Verify(); |
| 3986 | 3987 |
| 3988 #ifndef BASELINE_GC |
| 3987 VerifyPointersAndDirtyRegionsVisitor dirty_regions_visitor; | 3989 VerifyPointersAndDirtyRegionsVisitor dirty_regions_visitor; |
| 3988 old_pointer_space_->Verify(&dirty_regions_visitor); | 3990 old_pointer_space_->Verify(&dirty_regions_visitor); |
| 3989 map_space_->Verify(&dirty_regions_visitor); | 3991 map_space_->Verify(&dirty_regions_visitor); |
| 3992 #else |
| 3993 old_pointer_space_->Verify(&visitor); |
| 3994 map_space_->Verify(&visitor); |
| 3995 #endif |
| 3990 | 3996 |
| 3991 VerifyPointersUnderWatermark(old_pointer_space_, | 3997 VerifyPointersUnderWatermark(old_pointer_space_, |
| 3992 &IteratePointersInDirtyRegion); | 3998 &IteratePointersInDirtyRegion); |
| 3993 VerifyPointersUnderWatermark(map_space_, | 3999 VerifyPointersUnderWatermark(map_space_, |
| 3994 &IteratePointersInDirtyMapsRegion); | 4000 &IteratePointersInDirtyMapsRegion); |
| 3995 VerifyPointersUnderWatermark(lo_space_); | 4001 VerifyPointersUnderWatermark(lo_space_); |
| 3996 | 4002 |
| 3997 VerifyPageWatermarkValidity(old_pointer_space_, ALL_INVALID); | 4003 VerifyPageWatermarkValidity(old_pointer_space_, ALL_INVALID); |
| 3998 VerifyPageWatermarkValidity(map_space_, ALL_INVALID); | 4004 VerifyPageWatermarkValidity(map_space_, ALL_INVALID); |
| 3999 | 4005 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4175 return contains_pointers_to_new_space; | 4181 return contains_pointers_to_new_space; |
| 4176 } | 4182 } |
| 4177 | 4183 |
| 4178 | 4184 |
| 4179 void Heap::IterateAndMarkPointersToFromSpace(Address start, | 4185 void Heap::IterateAndMarkPointersToFromSpace(Address start, |
| 4180 Address end, | 4186 Address end, |
| 4181 ObjectSlotCallback callback) { | 4187 ObjectSlotCallback callback) { |
| 4182 Address slot_address = start; | 4188 Address slot_address = start; |
| 4183 Page* page = Page::FromAddress(start); | 4189 Page* page = Page::FromAddress(start); |
| 4184 | 4190 |
| 4191 #ifndef BASELINE_GC |
| 4185 uint32_t marks = page->GetRegionMarks(); | 4192 uint32_t marks = page->GetRegionMarks(); |
| 4193 #else |
| 4194 uint32_t marks = 0; |
| 4195 #endif |
| 4186 | 4196 |
| 4187 while (slot_address < end) { | 4197 while (slot_address < end) { |
| 4188 Object** slot = reinterpret_cast<Object**>(slot_address); | 4198 Object** slot = reinterpret_cast<Object**>(slot_address); |
| 4189 if (Heap::InFromSpace(*slot)) { | 4199 if (Heap::InFromSpace(*slot)) { |
| 4190 ASSERT((*slot)->IsHeapObject()); | 4200 ASSERT((*slot)->IsHeapObject()); |
| 4191 callback(reinterpret_cast<HeapObject**>(slot)); | 4201 callback(reinterpret_cast<HeapObject**>(slot)); |
| 4192 if (Heap::InNewSpace(*slot)) { | 4202 if (Heap::InNewSpace(*slot)) { |
| 4193 ASSERT((*slot)->IsHeapObject()); | 4203 ASSERT((*slot)->IsHeapObject()); |
| 4194 marks |= page->GetRegionMaskForAddress(slot_address); | 4204 marks |= page->GetRegionMaskForAddress(slot_address); |
| 4195 } | 4205 } |
| 4196 } | 4206 } |
| 4197 slot_address += kPointerSize; | 4207 slot_address += kPointerSize; |
| 4198 } | 4208 } |
| 4199 | 4209 |
| 4210 #ifndef BASELINE_GC |
| 4200 page->SetRegionMarks(marks); | 4211 page->SetRegionMarks(marks); |
| 4212 #endif |
| 4201 } | 4213 } |
| 4202 | 4214 |
| 4203 | 4215 |
| 4204 uint32_t Heap::IterateDirtyRegions( | 4216 uint32_t Heap::IterateDirtyRegions( |
| 4205 uint32_t marks, | 4217 uint32_t marks, |
| 4206 Address area_start, | 4218 Address area_start, |
| 4207 Address area_end, | 4219 Address area_end, |
| 4208 DirtyRegionCallback visit_dirty_region, | 4220 DirtyRegionCallback visit_dirty_region, |
| 4209 ObjectSlotCallback copy_object_func) { | 4221 ObjectSlotCallback copy_object_func) { |
| 4222 #ifndef BASELINE_GC |
| 4210 uint32_t newmarks = 0; | 4223 uint32_t newmarks = 0; |
| 4211 uint32_t mask = 1; | 4224 uint32_t mask = 1; |
| 4212 | 4225 |
| 4213 if (area_start >= area_end) { | 4226 if (area_start >= area_end) { |
| 4214 return newmarks; | 4227 return newmarks; |
| 4215 } | 4228 } |
| 4216 | 4229 |
| 4217 Address region_start = area_start; | 4230 Address region_start = area_start; |
| 4218 | 4231 |
| 4219 // area_start does not necessarily coincide with start of the first region. | 4232 // area_start does not necessarily coincide with start of the first region. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4256 // with region end. Check whether region covering last part of area is | 4269 // with region end. Check whether region covering last part of area is |
| 4257 // dirty. | 4270 // dirty. |
| 4258 if (marks & mask) { | 4271 if (marks & mask) { |
| 4259 if (visit_dirty_region(region_start, area_end, copy_object_func)) { | 4272 if (visit_dirty_region(region_start, area_end, copy_object_func)) { |
| 4260 newmarks |= mask; | 4273 newmarks |= mask; |
| 4261 } | 4274 } |
| 4262 } | 4275 } |
| 4263 } | 4276 } |
| 4264 | 4277 |
| 4265 return newmarks; | 4278 return newmarks; |
| 4279 #else |
| 4280 visit_dirty_region(area_start, area_end, copy_object_func); |
| 4281 return 0; |
| 4282 #endif |
| 4266 } | 4283 } |
| 4267 | 4284 |
| 4268 | 4285 |
| 4269 | 4286 |
| 4270 void Heap::IterateDirtyRegions( | 4287 void Heap::IterateDirtyRegions( |
| 4271 PagedSpace* space, | 4288 PagedSpace* space, |
| 4272 DirtyRegionCallback visit_dirty_region, | 4289 DirtyRegionCallback visit_dirty_region, |
| 4273 ObjectSlotCallback copy_object_func, | 4290 ObjectSlotCallback copy_object_func, |
| 4274 ExpectedPageWatermarkState expected_page_watermark_state) { | 4291 ExpectedPageWatermarkState expected_page_watermark_state) { |
| 4275 | 4292 |
| (...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5438 void ExternalStringTable::TearDown() { | 5455 void ExternalStringTable::TearDown() { |
| 5439 new_space_strings_.Free(); | 5456 new_space_strings_.Free(); |
| 5440 old_space_strings_.Free(); | 5457 old_space_strings_.Free(); |
| 5441 } | 5458 } |
| 5442 | 5459 |
| 5443 | 5460 |
| 5444 List<Object*> ExternalStringTable::new_space_strings_; | 5461 List<Object*> ExternalStringTable::new_space_strings_; |
| 5445 List<Object*> ExternalStringTable::old_space_strings_; | 5462 List<Object*> ExternalStringTable::old_space_strings_; |
| 5446 | 5463 |
| 5447 } } // namespace v8::internal | 5464 } } // namespace v8::internal |
| OLD | NEW |