OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/heap/heap.h" | 5 #include "src/heap/heap.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/ast/context-slot-cache.h" | 9 #include "src/ast/context-slot-cache.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 // can cause another GC. Take into account the objects promoted during | 1314 // can cause another GC. Take into account the objects promoted during |
1315 // GC. | 1315 // GC. |
1316 old_generation_allocation_counter_at_last_gc_ += | 1316 old_generation_allocation_counter_at_last_gc_ += |
1317 static_cast<size_t>(promoted_objects_size_); | 1317 static_cast<size_t>(promoted_objects_size_); |
1318 old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects(); | 1318 old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects(); |
1319 break; | 1319 break; |
1320 case MINOR_MARK_COMPACTOR: | 1320 case MINOR_MARK_COMPACTOR: |
1321 MinorMarkCompact(); | 1321 MinorMarkCompact(); |
1322 break; | 1322 break; |
1323 case SCAVENGER: | 1323 case SCAVENGER: |
| 1324 #ifdef VERIFY_HEAP |
| 1325 MarkCompactCollector::YounGenerationMarkingVerificationState state; |
| 1326 if (FLAG_verify_minor_mc_marking) { |
| 1327 state = |
| 1328 mark_compact_collector()->MarkYoungGenerationForVerification(); |
| 1329 } |
| 1330 #endif // VERIFY_HEAP |
1324 Scavenge(); | 1331 Scavenge(); |
| 1332 #ifdef VERIFY_HEAP |
| 1333 if (FLAG_verify_minor_mc_marking) { |
| 1334 mark_compact_collector() |
| 1335 ->VerifyYoungGenerationMarkbitsUsingForwardingPointers(state); |
| 1336 } |
| 1337 #endif // VERIFY_HEAP |
1325 break; | 1338 break; |
1326 } | 1339 } |
1327 | 1340 |
1328 ProcessPretenuringFeedback(); | 1341 ProcessPretenuringFeedback(); |
1329 } | 1342 } |
1330 | 1343 |
1331 UpdateSurvivalStatistics(start_new_space_size); | 1344 UpdateSurvivalStatistics(start_new_space_size); |
1332 ConfigureInitialOldGenerationSize(); | 1345 ConfigureInitialOldGenerationSize(); |
1333 | 1346 |
1334 isolate_->counters()->objs_since_last_young()->Set(0); | 1347 isolate_->counters()->objs_since_last_young()->Set(0); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 survived_since_last_expansion_ = 0; | 1508 survived_since_last_expansion_ = 0; |
1496 } | 1509 } |
1497 } | 1510 } |
1498 | 1511 |
1499 | 1512 |
1500 static bool IsUnscavengedHeapObject(Heap* heap, Object** p) { | 1513 static bool IsUnscavengedHeapObject(Heap* heap, Object** p) { |
1501 return heap->InNewSpace(*p) && | 1514 return heap->InNewSpace(*p) && |
1502 !HeapObject::cast(*p)->map_word().IsForwardingAddress(); | 1515 !HeapObject::cast(*p)->map_word().IsForwardingAddress(); |
1503 } | 1516 } |
1504 | 1517 |
1505 | |
1506 static bool IsUnmodifiedHeapObject(Object** p) { | |
1507 Object* object = *p; | |
1508 if (object->IsSmi()) return false; | |
1509 HeapObject* heap_object = HeapObject::cast(object); | |
1510 if (!object->IsJSObject()) return false; | |
1511 JSObject* js_object = JSObject::cast(object); | |
1512 if (!js_object->WasConstructedFromApiFunction()) return false; | |
1513 JSFunction* constructor = | |
1514 JSFunction::cast(js_object->map()->GetConstructor()); | |
1515 | |
1516 return constructor->initial_map() == heap_object->map(); | |
1517 } | |
1518 | |
1519 | |
1520 void PromotionQueue::Initialize() { | 1518 void PromotionQueue::Initialize() { |
1521 // The last to-space page may be used for promotion queue. On promotion | 1519 // The last to-space page may be used for promotion queue. On promotion |
1522 // conflict, we use the emergency stack. | 1520 // conflict, we use the emergency stack. |
1523 DCHECK((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) == | 1521 DCHECK((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) == |
1524 0); | 1522 0); |
1525 front_ = rear_ = | 1523 front_ = rear_ = |
1526 reinterpret_cast<struct Entry*>(heap_->new_space()->ToSpaceEnd()); | 1524 reinterpret_cast<struct Entry*>(heap_->new_space()->ToSpaceEnd()); |
1527 limit_ = reinterpret_cast<struct Entry*>( | 1525 limit_ = reinterpret_cast<struct Entry*>( |
1528 Page::FromAllocationAreaAddress(reinterpret_cast<Address>(rear_)) | 1526 Page::FromAllocationAreaAddress(reinterpret_cast<Address>(rear_)) |
1529 ->area_start()); | 1527 ->area_start()); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 } | 1682 } |
1685 | 1683 |
1686 { | 1684 { |
1687 TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_SEMISPACE); | 1685 TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_SEMISPACE); |
1688 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1686 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
1689 } | 1687 } |
1690 | 1688 |
1691 isolate()->global_handles()->MarkNewSpaceWeakUnmodifiedObjectsPending( | 1689 isolate()->global_handles()->MarkNewSpaceWeakUnmodifiedObjectsPending( |
1692 &IsUnscavengedHeapObject); | 1690 &IsUnscavengedHeapObject); |
1693 | 1691 |
1694 isolate()->global_handles()->IterateNewSpaceWeakUnmodifiedRoots( | 1692 isolate() |
1695 &scavenge_visitor); | 1693 ->global_handles() |
| 1694 ->IterateNewSpaceWeakUnmodifiedRoots<GlobalHandles::HANDLE_PHANTOM_NODES>( |
| 1695 &scavenge_visitor); |
1696 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1696 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
1697 | 1697 |
1698 UpdateNewSpaceReferencesInExternalStringTable( | 1698 UpdateNewSpaceReferencesInExternalStringTable( |
1699 &UpdateNewSpaceReferenceInExternalStringTableEntry); | 1699 &UpdateNewSpaceReferenceInExternalStringTableEntry); |
1700 | 1700 |
1701 promotion_queue_.Destroy(); | 1701 promotion_queue_.Destroy(); |
1702 | 1702 |
1703 incremental_marking()->UpdateMarkingDequeAfterScavenge(); | 1703 incremental_marking()->UpdateMarkingDequeAfterScavenge(); |
1704 | 1704 |
1705 ScavengeWeakObjectRetainer weak_object_retainer(this); | 1705 ScavengeWeakObjectRetainer weak_object_retainer(this); |
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2905 return false; | 2905 return false; |
2906 } | 2906 } |
2907 } | 2907 } |
2908 | 2908 |
2909 | 2909 |
2910 bool Heap::RootCanBeTreatedAsConstant(RootListIndex root_index) { | 2910 bool Heap::RootCanBeTreatedAsConstant(RootListIndex root_index) { |
2911 return !RootCanBeWrittenAfterInitialization(root_index) && | 2911 return !RootCanBeWrittenAfterInitialization(root_index) && |
2912 !InNewSpace(root(root_index)); | 2912 !InNewSpace(root(root_index)); |
2913 } | 2913 } |
2914 | 2914 |
| 2915 bool Heap::IsUnmodifiedHeapObject(Object** p) { |
| 2916 Object* object = *p; |
| 2917 if (object->IsSmi()) return false; |
| 2918 HeapObject* heap_object = HeapObject::cast(object); |
| 2919 if (!object->IsJSObject()) return false; |
| 2920 JSObject* js_object = JSObject::cast(object); |
| 2921 if (!js_object->WasConstructedFromApiFunction()) return false; |
| 2922 JSFunction* constructor = |
| 2923 JSFunction::cast(js_object->map()->GetConstructor()); |
| 2924 |
| 2925 return constructor->initial_map() == heap_object->map(); |
| 2926 } |
2915 | 2927 |
2916 int Heap::FullSizeNumberStringCacheLength() { | 2928 int Heap::FullSizeNumberStringCacheLength() { |
2917 // Compute the size of the number string cache based on the max newspace size. | 2929 // Compute the size of the number string cache based on the max newspace size. |
2918 // The number string cache has a minimum size based on twice the initial cache | 2930 // The number string cache has a minimum size based on twice the initial cache |
2919 // size to ensure that it is bigger after being made 'full size'. | 2931 // size to ensure that it is bigger after being made 'full size'. |
2920 size_t number_string_cache_size = max_semi_space_size_ / 512; | 2932 size_t number_string_cache_size = max_semi_space_size_ / 512; |
2921 number_string_cache_size = | 2933 number_string_cache_size = |
2922 Max(static_cast<size_t>(kInitialNumberStringCacheSize * 2), | 2934 Max(static_cast<size_t>(kInitialNumberStringCacheSize * 2), |
2923 Min<size_t>(0x4000u, number_string_cache_size)); | 2935 Min<size_t>(0x4000u, number_string_cache_size)); |
2924 // There is a string and a number per entry so the length is twice the number | 2936 // There is a string and a number per entry so the length is twice the number |
(...skipping 3546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6471 } | 6483 } |
6472 | 6484 |
6473 | 6485 |
6474 // static | 6486 // static |
6475 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6487 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6476 return StaticVisitorBase::GetVisitorId(map); | 6488 return StaticVisitorBase::GetVisitorId(map); |
6477 } | 6489 } |
6478 | 6490 |
6479 } // namespace internal | 6491 } // namespace internal |
6480 } // namespace v8 | 6492 } // namespace v8 |
OLD | NEW |