| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8cf3472 commit 642ad4f
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -449,6 +449,31 @@ void Heap::CopyBlock(Address dst, Address src, int byte_size) { | |||
| 449 | 449 | static_cast<size_t>(byte_size / kPointerSize)); | |
| 450 | 450 | } | |
| 451 | 451 | ||
| 452 | + bool Heap::PurgeLeftTrimmedObject(Object** object) { | ||
| 453 | + HeapObject* current = reinterpret_cast<HeapObject*>(*object); | ||
| 454 | + const MapWord map_word = current->map_word(); | ||
| 455 | + if (current->IsFiller() && !map_word.IsForwardingAddress()) { | ||
| 456 | + #ifdef DEBUG | ||
| 457 | + // We need to find a FixedArrayBase map after walking the fillers. | ||
| 458 | + while (current->IsFiller()) { | ||
| 459 | + Address next = reinterpret_cast<Address>(current); | ||
| 460 | + if (current->map() == one_pointer_filler_map()) { | ||
| 461 | + next += kPointerSize; | ||
| 462 | + } else if (current->map() == two_pointer_filler_map()) { | ||
| 463 | + next += 2 * kPointerSize; | ||
| 464 | + } else { | ||
| 465 | + next += current->Size(); | ||
| 466 | + } | ||
| 467 | + current = reinterpret_cast<HeapObject*>(next); | ||
| 468 | + } | ||
| 469 | + DCHECK(current->IsFixedArrayBase()); | ||
| 470 | + #endif // DEBUG | ||
| 471 | + *object = nullptr; | ||
| 472 | + return true; | ||
| 473 | + } | ||
| 474 | + return false; | ||
| 475 | + } | ||
| 476 | + | ||
| 452 | 477 | template <Heap::FindMementoMode mode> | |
| 453 | 478 | AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) { | |
| 454 | 479 | // Check if there is potentially a memento behind the object. If | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -602,6 +602,12 @@ class Heap { | |||
| 602 | 602 | // stored on the map to facilitate fast dispatch for {StaticVisitorBase}. | |
| 603 | 603 | static int GetStaticVisitorIdForMap(Map* map); | |
| 604 | 604 | ||
| 605 | + // We cannot avoid stale handles to left-trimmed objects, but can only make | ||
| 606 | + // sure all handles still needed are updated. Filter out a stale pointer | ||
| 607 | + // and clear the slot to allow post processing of handles (needed because | ||
| 608 | + // the sweeper might actually free the underlying page). | ||
| 609 | + inline bool PurgeLeftTrimmedObject(Object** object); | ||
| 610 | + | ||
| 605 | 611 | // Notifies the heap that is ok to start marking or other activities that | |
| 606 | 612 | // should not happen during deserialization. | |
| 607 | 613 | void NotifyDeserializationComplete(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1376,31 +1376,7 @@ class RootMarkingVisitor : public ObjectVisitor { | |||
| 1376 | 1376 | ||
| 1377 | 1377 | HeapObject* object = HeapObject::cast(*p); | |
| 1378 | 1378 | ||
| 1379 | - // We cannot avoid stale handles to left-trimmed objects, but can only make | ||
| 1380 | - // sure all handles still needed are updated. Filter out any stale pointers | ||
| 1381 | - // and clear the slot to allow post processing of handles (needed because | ||
| 1382 | - // the sweeper might actually free the underlying page). | ||
| 1383 | - if (object->IsFiller()) { | ||
| 1384 | - #ifdef DEBUG | ||
| 1385 | - // We need to find a FixedArrayBase map after walking the fillers. | ||
| 1386 | - Heap* heap = collector_->heap(); | ||
| 1387 | - HeapObject* current = object; | ||
| 1388 | - while (current->IsFiller()) { | ||
| 1389 | - Address next = reinterpret_cast<Address>(current); | ||
| 1390 | - if (current->map() == heap->one_pointer_filler_map()) { | ||
| 1391 | - next += kPointerSize; | ||
| 1392 | - } else if (current->map() == heap->two_pointer_filler_map()) { | ||
| 1393 | - next += 2 * kPointerSize; | ||
| 1394 | - } else { | ||
| 1395 | - next += current->Size(); | ||
| 1396 | - } | ||
| 1397 | - current = reinterpret_cast<HeapObject*>(next); | ||
| 1398 | - } | ||
| 1399 | - DCHECK(current->IsFixedArrayBase()); | ||
| 1400 | - #endif // DEBUG | ||
| 1401 | - *p = nullptr; | ||
| 1402 | - return; | ||
| 1403 | - } | ||
| 1379 | + if (collector_->heap()->PurgeLeftTrimmedObject(p)) return; | ||
| 1404 | 1380 | ||
| 1405 | 1381 | MarkBit mark_bit = Marking::MarkBitFrom(object); | |
| 1406 | 1382 | if (Marking::IsBlackOrGrey(mark_bit)) return; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -462,6 +462,9 @@ void ScavengeVisitor::VisitPointers(Object** start, Object** end) { | |||
| 462 | 462 | void ScavengeVisitor::ScavengePointer(Object** p) { | |
| 463 | 463 | Object* object = *p; | |
| 464 | 464 | if (!heap_->InNewSpace(object)) return; | |
| 465 | + | ||
| 466 | + if (heap_->PurgeLeftTrimmedObject(p)) return; | ||
| 467 | + | ||
| 465 | 468 | Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), | |
| 466 | 469 | reinterpret_cast<HeapObject*>(object)); | |
| 467 | 470 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1261,8 +1261,7 @@ Map* MapWord::ToMap() { | |||
| 1261 | 1261 | return reinterpret_cast<Map*>(value_); | |
| 1262 | 1262 | } | |
| 1263 | 1263 | ||
| 1264 | - | ||
| 1265 | - bool MapWord::IsForwardingAddress() { | ||
| 1264 | + bool MapWord::IsForwardingAddress() const { | ||
| 1266 | 1265 | return HAS_SMI_TAG(reinterpret_cast<Object*>(value_)); | |
| 1267 | 1266 | } | |
| 1268 | 1267 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1476,7 +1476,7 @@ class MapWord BASE_EMBEDDED { | |||
| 1476 | 1476 | // True if this map word is a forwarding address for a scavenge | |
| 1477 | 1477 | // collection. Only valid during a scavenge collection (specifically, | |
| 1478 | 1478 | // when all map words are heap object pointers, i.e. not during a full GC). | |
| 1479 | - inline bool IsForwardingAddress(); | ||
| 1479 | + inline bool IsForwardingAddress() const; | ||
| 1480 | 1480 | ||
| 1481 | 1481 | // Create a map word from a forwarding address. | |
| 1482 | 1482 | static inline MapWord FromForwardingAddress(HeapObject* object); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,18 @@ | |||
| 1 | + // Copyright 2016 the V8 project authors. All rights reserved. | ||
| 2 | + // Use of this source code is governed by a BSD-style license that can be | ||
| 3 | + // found in the LICENSE file. | ||
| 4 | + | ||
| 5 | + // Flags: --expose-gc | ||
| 6 | + | ||
| 7 | + var o0 = []; | ||
| 8 | + var o1 = []; | ||
| 9 | + var cnt = 0; | ||
| 10 | + var only_scavenge = true; | ||
| 11 | + o1.__defineGetter__(0, function() { | ||
| 12 | + if (cnt++ > 2) return; | ||
| 13 | + o0.shift(); | ||
| 14 | + gc(only_scavenge); | ||
| 15 | + o0.push((64)); | ||
| 16 | + o0.concat(o1); | ||
| 17 | + }); | ||
| 18 | + o1[0]; | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments