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

Side by Side Diff: src/heap/heap.cc

Issue 2498583002: [heap] Minor MC: Add marking (Closed)
Patch Set: Fix uncommitting of markingdeque Created 4 years, 1 month 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
OLDNEW
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
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 std::vector<HeapObject*> objects_in_to_space;
1326 if (FLAG_verify_minor_mc_marking) {
1327 objects_in_to_space = mark_compact_collector()->GetObjectsInToSpace();
1328 mark_compact_collector()->MarkYoungGenerationForVerification();
1329 isolate()->global_handles()->ResetNewSpaceHandlesForTesting();
1330 }
1331 #endif // VERIFY_HEAP
1324 Scavenge(); 1332 Scavenge();
1333 #ifdef VERIFY_HEAP
1334 if (FLAG_verify_minor_mc_marking) {
1335 mark_compact_collector()
1336 ->VerifyYoungGenerationMarkbitsUsingForwardingPointers(
1337 objects_in_to_space);
1338 for (Page* p : NewSpacePageRange(new_space()->FromSpaceStart(),
1339 new_space()->FromSpaceEnd())) {
1340 p->ClearLiveness();
1341 }
1342 }
1343 #endif // VERIFY_HEAP
1325 break; 1344 break;
1326 } 1345 }
1327 1346
1328 ProcessPretenuringFeedback(); 1347 ProcessPretenuringFeedback();
1329 } 1348 }
1330 1349
1331 UpdateSurvivalStatistics(start_new_space_size); 1350 UpdateSurvivalStatistics(start_new_space_size);
1332 ConfigureInitialOldGenerationSize(); 1351 ConfigureInitialOldGenerationSize();
1333 1352
1334 isolate_->counters()->objs_since_last_young()->Set(0); 1353 isolate_->counters()->objs_since_last_young()->Set(0);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 survived_since_last_expansion_ = 0; 1514 survived_since_last_expansion_ = 0;
1496 } 1515 }
1497 } 1516 }
1498 1517
1499 1518
1500 static bool IsUnscavengedHeapObject(Heap* heap, Object** p) { 1519 static bool IsUnscavengedHeapObject(Heap* heap, Object** p) {
1501 return heap->InNewSpace(*p) && 1520 return heap->InNewSpace(*p) &&
1502 !HeapObject::cast(*p)->map_word().IsForwardingAddress(); 1521 !HeapObject::cast(*p)->map_word().IsForwardingAddress();
1503 } 1522 }
1504 1523
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() { 1524 void PromotionQueue::Initialize() {
1521 // The last to-space page may be used for promotion queue. On promotion 1525 // The last to-space page may be used for promotion queue. On promotion
1522 // conflict, we use the emergency stack. 1526 // conflict, we use the emergency stack.
1523 DCHECK((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) == 1527 DCHECK((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) ==
1524 0); 1528 0);
1525 front_ = rear_ = 1529 front_ = rear_ =
1526 reinterpret_cast<struct Entry*>(heap_->new_space()->ToSpaceEnd()); 1530 reinterpret_cast<struct Entry*>(heap_->new_space()->ToSpaceEnd());
1527 limit_ = reinterpret_cast<struct Entry*>( 1531 limit_ = reinterpret_cast<struct Entry*>(
1528 Page::FromAllocationAreaAddress(reinterpret_cast<Address>(rear_)) 1532 Page::FromAllocationAreaAddress(reinterpret_cast<Address>(rear_))
1529 ->area_start()); 1533 ->area_start());
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 } 1688 }
1685 1689
1686 { 1690 {
1687 TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_SEMISPACE); 1691 TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_SEMISPACE);
1688 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); 1692 new_space_front = DoScavenge(&scavenge_visitor, new_space_front);
1689 } 1693 }
1690 1694
1691 isolate()->global_handles()->MarkNewSpaceWeakUnmodifiedObjectsPending( 1695 isolate()->global_handles()->MarkNewSpaceWeakUnmodifiedObjectsPending(
1692 &IsUnscavengedHeapObject); 1696 &IsUnscavengedHeapObject);
1693 1697
1694 isolate()->global_handles()->IterateNewSpaceWeakUnmodifiedRoots( 1698 isolate()
1695 &scavenge_visitor); 1699 ->global_handles()
1700 ->IterateNewSpaceWeakUnmodifiedRoots<GlobalHandles::HANDLE_PHANTOM_NODES>(
1701 &scavenge_visitor);
1696 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); 1702 new_space_front = DoScavenge(&scavenge_visitor, new_space_front);
1697 1703
1698 UpdateNewSpaceReferencesInExternalStringTable( 1704 UpdateNewSpaceReferencesInExternalStringTable(
1699 &UpdateNewSpaceReferenceInExternalStringTableEntry); 1705 &UpdateNewSpaceReferenceInExternalStringTableEntry);
1700 1706
1701 promotion_queue_.Destroy(); 1707 promotion_queue_.Destroy();
1702 1708
1703 incremental_marking()->UpdateMarkingDequeAfterScavenge(); 1709 incremental_marking()->UpdateMarkingDequeAfterScavenge();
1704 1710
1705 ScavengeWeakObjectRetainer weak_object_retainer(this); 1711 ScavengeWeakObjectRetainer weak_object_retainer(this);
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2897 return false; 2903 return false;
2898 } 2904 }
2899 } 2905 }
2900 2906
2901 2907
2902 bool Heap::RootCanBeTreatedAsConstant(RootListIndex root_index) { 2908 bool Heap::RootCanBeTreatedAsConstant(RootListIndex root_index) {
2903 return !RootCanBeWrittenAfterInitialization(root_index) && 2909 return !RootCanBeWrittenAfterInitialization(root_index) &&
2904 !InNewSpace(root(root_index)); 2910 !InNewSpace(root(root_index));
2905 } 2911 }
2906 2912
2913 bool Heap::IsUnmodifiedHeapObject(Object** p) {
2914 Object* object = *p;
2915 if (object->IsSmi()) return false;
2916 HeapObject* heap_object = HeapObject::cast(object);
2917 if (!object->IsJSObject()) return false;
2918 JSObject* js_object = JSObject::cast(object);
2919 if (!js_object->WasConstructedFromApiFunction()) return false;
2920 JSFunction* constructor =
2921 JSFunction::cast(js_object->map()->GetConstructor());
2922
2923 return constructor->initial_map() == heap_object->map();
2924 }
2907 2925
2908 int Heap::FullSizeNumberStringCacheLength() { 2926 int Heap::FullSizeNumberStringCacheLength() {
2909 // Compute the size of the number string cache based on the max newspace size. 2927 // Compute the size of the number string cache based on the max newspace size.
2910 // The number string cache has a minimum size based on twice the initial cache 2928 // The number string cache has a minimum size based on twice the initial cache
2911 // size to ensure that it is bigger after being made 'full size'. 2929 // size to ensure that it is bigger after being made 'full size'.
2912 size_t number_string_cache_size = max_semi_space_size_ / 512; 2930 size_t number_string_cache_size = max_semi_space_size_ / 512;
2913 number_string_cache_size = 2931 number_string_cache_size =
2914 Max(static_cast<size_t>(kInitialNumberStringCacheSize * 2), 2932 Max(static_cast<size_t>(kInitialNumberStringCacheSize * 2),
2915 Min<size_t>(0x4000u, number_string_cache_size)); 2933 Min<size_t>(0x4000u, number_string_cache_size));
2916 // There is a string and a number per entry so the length is twice the number 2934 // 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
6463 } 6481 }
6464 6482
6465 6483
6466 // static 6484 // static
6467 int Heap::GetStaticVisitorIdForMap(Map* map) { 6485 int Heap::GetStaticVisitorIdForMap(Map* map) {
6468 return StaticVisitorBase::GetVisitorId(map); 6486 return StaticVisitorBase::GetVisitorId(map);
6469 } 6487 }
6470 6488
6471 } // namespace internal 6489 } // namespace internal
6472 } // namespace v8 6490 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698