| Index: src/heap/objects-visiting.cc
|
| diff --git a/src/heap/objects-visiting.cc b/src/heap/objects-visiting.cc
|
| index 7b2e2d9a388939440e0aac0bb5c3263fedc4676f..b31abb8880d9e8bf4805653b61b036166fb2e964 100644
|
| --- a/src/heap/objects-visiting.cc
|
| +++ b/src/heap/objects-visiting.cc
|
| @@ -191,15 +191,22 @@ struct WeakListVisitor;
|
|
|
|
|
| template <class T>
|
| -Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer) {
|
| +Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer,
|
| + Object* last_young_object,
|
| + Object** last_young_object_recorded) {
|
| Object* undefined = heap->undefined_value();
|
| Object* head = undefined;
|
| T* tail = NULL;
|
| MarkCompactCollector* collector = heap->mark_compact_collector();
|
| bool record_slots = MustRecordSlots(heap);
|
| + bool last_young_object_found = false;
|
| while (list != undefined) {
|
| // Check whether to keep the candidate in the list.
|
| T* candidate = reinterpret_cast<T*>(list);
|
| + if (last_young_object && !last_young_object_found) {
|
| + last_young_object_found = last_young_object == candidate;
|
| + }
|
| +
|
| Object* retained = retainer->RetainAs(list);
|
| if (retained != NULL) {
|
| if (head == undefined) {
|
| @@ -227,6 +234,19 @@ Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer) {
|
| WeakListVisitor<T>::VisitPhantomObject(heap, candidate);
|
| }
|
|
|
| + if (last_young_object_recorded && !heap->InNewSpace(retained)) {
|
| + *last_young_object_recorded = retained;
|
| + }
|
| +
|
| + // The list of weak objects is usually order. It starts with objects
|
| + // recently allocated in the young generation followed by objects
|
| + // allocated in the old generation.
|
| + // For young generation collections we just have to visit until the last
|
| + // young generation objects.
|
| + if (last_young_object_found && retained) {
|
| + return head;
|
| + }
|
| +
|
| // Move to next element in the list.
|
| list = WeakListVisitor<T>::WeakNext(candidate);
|
| }
|
| @@ -235,6 +255,7 @@ Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer) {
|
| if (tail != NULL) {
|
| WeakListVisitor<T>::SetWeakNext(tail, undefined);
|
| }
|
| +
|
| return head;
|
| }
|
|
|
| @@ -316,7 +337,8 @@ struct WeakListVisitor<Context> {
|
| static void DoWeakList(Heap* heap, Context* context,
|
| WeakObjectRetainer* retainer, int index) {
|
| // Visit the weak list, removing dead intermediate elements.
|
| - Object* list_head = VisitWeakList<T>(heap, context->get(index), retainer);
|
| + Object* list_head =
|
| + VisitWeakList<T>(heap, context->get(index), retainer, NULL, NULL);
|
|
|
| // Update the list head.
|
| context->set(index, list_head, UPDATE_WRITE_BARRIER);
|
| @@ -368,7 +390,7 @@ struct WeakListVisitor<JSArrayBuffer> {
|
| static void VisitLiveObject(Heap* heap, JSArrayBuffer* array_buffer,
|
| WeakObjectRetainer* retainer) {
|
| Object* typed_array_obj = VisitWeakList<JSArrayBufferView>(
|
| - heap, array_buffer->weak_first_view(), retainer);
|
| + heap, array_buffer->weak_first_view(), retainer, NULL, NULL);
|
| array_buffer->set_weak_first_view(typed_array_obj);
|
| if (typed_array_obj != heap->undefined_value() && MustRecordSlots(heap)) {
|
| Object** slot = HeapObject::RawField(array_buffer,
|
| @@ -399,23 +421,19 @@ struct WeakListVisitor<AllocationSite> {
|
| };
|
|
|
|
|
| -template Object* VisitWeakList<Code>(Heap* heap, Object* list,
|
| - WeakObjectRetainer* retainer);
|
| -
|
| -
|
| -template Object* VisitWeakList<JSFunction>(Heap* heap, Object* list,
|
| - WeakObjectRetainer* retainer);
|
| -
|
| -
|
| template Object* VisitWeakList<Context>(Heap* heap, Object* list,
|
| - WeakObjectRetainer* retainer);
|
| + WeakObjectRetainer* retainer,
|
| + Object* last_young_object,
|
| + Object** last_young_object_recorded);
|
|
|
|
|
| -template Object* VisitWeakList<JSArrayBuffer>(Heap* heap, Object* list,
|
| - WeakObjectRetainer* retainer);
|
| +template Object* VisitWeakList<JSArrayBuffer>(
|
| + Heap* heap, Object* list, WeakObjectRetainer* retainer,
|
| + Object* last_young_object, Object** last_young_object_recorded);
|
|
|
|
|
| -template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list,
|
| - WeakObjectRetainer* retainer);
|
| +template Object* VisitWeakList<AllocationSite>(
|
| + Heap* heap, Object* list, WeakObjectRetainer* retainer,
|
| + Object* last_young_object, Object** last_young_object_recorded);
|
| }
|
| } // namespace v8::internal
|
|
|