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

Side by Side Diff: src/heap/objects-visiting.cc

Issue 1079923003: Put newly allocated buffers at the right end of the buffers list (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months 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
« no previous file with comments | « src/heap/objects-visiting.h ('k') | src/runtime/runtime-typedarray.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/heap/objects-visiting.h" 7 #include "src/heap/objects-visiting.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 heap->mark_compact_collector()->is_compacting(); 185 heap->mark_compact_collector()->is_compacting();
186 } 186 }
187 187
188 188
189 template <class T> 189 template <class T>
190 struct WeakListVisitor; 190 struct WeakListVisitor;
191 191
192 192
193 template <class T> 193 template <class T>
194 Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer, 194 Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer,
195 bool stop_after_young) { 195 bool stop_after_young, Object** list_tail) {
196 Object* undefined = heap->undefined_value(); 196 Object* undefined = heap->undefined_value();
197 Object* head = undefined; 197 Object* head = undefined;
198 T* tail = NULL; 198 T* tail = NULL;
199 MarkCompactCollector* collector = heap->mark_compact_collector(); 199 MarkCompactCollector* collector = heap->mark_compact_collector();
200 bool record_slots = MustRecordSlots(heap); 200 bool record_slots = MustRecordSlots(heap);
201 201
202 while (list != undefined) { 202 while (list != undefined) {
203 // Check whether to keep the candidate in the list. 203 // Check whether to keep the candidate in the list.
204 T* candidate = reinterpret_cast<T*>(list); 204 T* candidate = reinterpret_cast<T*>(list);
205 205
(...skipping 24 matching lines...) Expand all
230 WeakListVisitor<T>::VisitPhantomObject(heap, candidate); 230 WeakListVisitor<T>::VisitPhantomObject(heap, candidate);
231 } 231 }
232 232
233 // Move to next element in the list. 233 // Move to next element in the list.
234 list = WeakListVisitor<T>::WeakNext(candidate); 234 list = WeakListVisitor<T>::WeakNext(candidate);
235 } 235 }
236 236
237 // Terminate the list if there is one or more elements. 237 // Terminate the list if there is one or more elements.
238 if (tail != NULL) { 238 if (tail != NULL) {
239 WeakListVisitor<T>::SetWeakNext(tail, undefined); 239 WeakListVisitor<T>::SetWeakNext(tail, undefined);
240 if (list_tail) *list_tail = tail;
240 } 241 }
241 return head; 242 return head;
242 } 243 }
243 244
244 245
245 Object* VisitNewArrayBufferViewsWeakList(Heap* heap, Object* list, 246 Object* VisitNewArrayBufferViewsWeakList(Heap* heap, Object* list,
246 WeakObjectRetainer* retainer) { 247 WeakObjectRetainer* retainer) {
247 Object* undefined = heap->undefined_value(); 248 Object* undefined = heap->undefined_value();
248 Object* previous = undefined; 249 Object* previous = undefined;
249 Object* head = undefined; 250 Object* head = undefined;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 DoWeakList<Code>(heap, context, retainer, Context::OPTIMIZED_CODE_LIST); 364 DoWeakList<Code>(heap, context, retainer, Context::OPTIMIZED_CODE_LIST);
364 DoWeakList<Code>(heap, context, retainer, Context::DEOPTIMIZED_CODE_LIST); 365 DoWeakList<Code>(heap, context, retainer, Context::DEOPTIMIZED_CODE_LIST);
365 } 366 }
366 } 367 }
367 368
368 template <class T> 369 template <class T>
369 static void DoWeakList(Heap* heap, Context* context, 370 static void DoWeakList(Heap* heap, Context* context,
370 WeakObjectRetainer* retainer, int index) { 371 WeakObjectRetainer* retainer, int index) {
371 // Visit the weak list, removing dead intermediate elements. 372 // Visit the weak list, removing dead intermediate elements.
372 Object* list_head = 373 Object* list_head =
373 VisitWeakList<T>(heap, context->get(index), retainer, false); 374 VisitWeakList<T>(heap, context->get(index), retainer, false, NULL);
374 375
375 // Update the list head. 376 // Update the list head.
376 context->set(index, list_head, UPDATE_WRITE_BARRIER); 377 context->set(index, list_head, UPDATE_WRITE_BARRIER);
377 378
378 if (MustRecordSlots(heap)) { 379 if (MustRecordSlots(heap)) {
379 // Record the updated slot if necessary. 380 // Record the updated slot if necessary.
380 Object** head_slot = 381 Object** head_slot =
381 HeapObject::RawField(context, FixedArray::SizeFor(index)); 382 HeapObject::RawField(context, FixedArray::SizeFor(index));
382 heap->mark_compact_collector()->RecordSlot(head_slot, head_slot, 383 heap->mark_compact_collector()->RecordSlot(head_slot, head_slot,
383 list_head); 384 list_head);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 obj->set_weak_next(next); 416 obj->set_weak_next(next);
416 } 417 }
417 418
418 static Object* WeakNext(JSArrayBuffer* obj) { return obj->weak_next(); } 419 static Object* WeakNext(JSArrayBuffer* obj) { return obj->weak_next(); }
419 420
420 static int WeakNextOffset() { return JSArrayBuffer::kWeakNextOffset; } 421 static int WeakNextOffset() { return JSArrayBuffer::kWeakNextOffset; }
421 422
422 static void VisitLiveObject(Heap* heap, JSArrayBuffer* array_buffer, 423 static void VisitLiveObject(Heap* heap, JSArrayBuffer* array_buffer,
423 WeakObjectRetainer* retainer) { 424 WeakObjectRetainer* retainer) {
424 Object* typed_array_obj = VisitWeakList<JSArrayBufferView>( 425 Object* typed_array_obj = VisitWeakList<JSArrayBufferView>(
425 heap, array_buffer->weak_first_view(), retainer, false); 426 heap, array_buffer->weak_first_view(), retainer, false, NULL);
426 array_buffer->set_weak_first_view(typed_array_obj); 427 array_buffer->set_weak_first_view(typed_array_obj);
427 if (typed_array_obj != heap->undefined_value() && MustRecordSlots(heap)) { 428 if (typed_array_obj != heap->undefined_value() && MustRecordSlots(heap)) {
428 Object** slot = HeapObject::RawField(array_buffer, 429 Object** slot = HeapObject::RawField(array_buffer,
429 JSArrayBuffer::kWeakFirstViewOffset); 430 JSArrayBuffer::kWeakFirstViewOffset);
430 heap->mark_compact_collector()->RecordSlot(slot, slot, typed_array_obj); 431 heap->mark_compact_collector()->RecordSlot(slot, slot, typed_array_obj);
431 } 432 }
432 } 433 }
433 434
434 static void VisitPhantomObject(Heap* heap, JSArrayBuffer* phantom) { 435 static void VisitPhantomObject(Heap* heap, JSArrayBuffer* phantom) {
435 Runtime::FreeArrayBuffer(heap->isolate(), phantom); 436 Runtime::FreeArrayBuffer(heap->isolate(), phantom);
(...skipping 12 matching lines...) Expand all
448 static int WeakNextOffset() { return AllocationSite::kWeakNextOffset; } 449 static int WeakNextOffset() { return AllocationSite::kWeakNextOffset; }
449 450
450 static void VisitLiveObject(Heap*, AllocationSite*, WeakObjectRetainer*) {} 451 static void VisitLiveObject(Heap*, AllocationSite*, WeakObjectRetainer*) {}
451 452
452 static void VisitPhantomObject(Heap*, AllocationSite*) {} 453 static void VisitPhantomObject(Heap*, AllocationSite*) {}
453 }; 454 };
454 455
455 456
456 template Object* VisitWeakList<Context>(Heap* heap, Object* list, 457 template Object* VisitWeakList<Context>(Heap* heap, Object* list,
457 WeakObjectRetainer* retainer, 458 WeakObjectRetainer* retainer,
458 bool stop_after_young); 459 bool stop_after_young,
460 Object** list_tail);
459 461
460 462
461 template Object* VisitWeakList<JSArrayBuffer>(Heap* heap, Object* list, 463 template Object* VisitWeakList<JSArrayBuffer>(Heap* heap, Object* list,
462 WeakObjectRetainer* retainer, 464 WeakObjectRetainer* retainer,
463 bool stop_after_young); 465 bool stop_after_young,
466 Object** list_tail);
464 467
465 template Object* VisitWeakList<JSArrayBufferView>(Heap* heap, Object* list, 468 template Object* VisitWeakList<JSArrayBufferView>(Heap* heap, Object* list,
466 WeakObjectRetainer* retainer, 469 WeakObjectRetainer* retainer,
467 bool stop_after_young); 470 bool stop_after_young,
471 Object** list_tail);
468 472
469 template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list, 473 template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list,
470 WeakObjectRetainer* retainer, 474 WeakObjectRetainer* retainer,
471 bool stop_after_young); 475 bool stop_after_young,
476 Object** list_tail);
472 } 477 }
473 } // namespace v8::internal 478 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/objects-visiting.h ('k') | src/runtime/runtime-typedarray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698