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

Side by Side Diff: src/heap/objects-visiting-inl.h

Issue 871253005: Use weak cells in dependent code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 5 years, 10 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/mark-compact.cc ('k') | src/lithium.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 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 #ifndef V8_OBJECTS_VISITING_INL_H_ 5 #ifndef V8_OBJECTS_VISITING_INL_H_
6 #define V8_OBJECTS_VISITING_INL_H_ 6 #define V8_OBJECTS_VISITING_INL_H_
7 7
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 HeapObject::RawField(object, Map::kPointerFieldsEndOffset)); 319 HeapObject::RawField(object, Map::kPointerFieldsEndOffset));
320 } 320 }
321 } 321 }
322 322
323 323
324 template <typename StaticVisitor> 324 template <typename StaticVisitor>
325 void StaticMarkingVisitor<StaticVisitor>::VisitPropertyCell( 325 void StaticMarkingVisitor<StaticVisitor>::VisitPropertyCell(
326 Map* map, HeapObject* object) { 326 Map* map, HeapObject* object) {
327 Heap* heap = map->GetHeap(); 327 Heap* heap = map->GetHeap();
328 328
329 Object** slot =
330 HeapObject::RawField(object, PropertyCell::kDependentCodeOffset);
331 if (FLAG_collect_maps) {
332 // Mark property cell dependent codes array but do not push it onto marking
333 // stack, this will make references from it weak. We will clean dead
334 // codes when we iterate over property cells in ClearNonLiveReferences.
335 HeapObject* obj = HeapObject::cast(*slot);
336 heap->mark_compact_collector()->RecordSlot(slot, slot, obj);
337 StaticVisitor::MarkObjectWithoutPush(heap, obj);
338 } else {
339 StaticVisitor::VisitPointer(heap, slot);
340 }
341
342 StaticVisitor::VisitPointers( 329 StaticVisitor::VisitPointers(
343 heap, 330 heap,
344 HeapObject::RawField(object, PropertyCell::kPointerFieldsBeginOffset), 331 HeapObject::RawField(object, PropertyCell::kPointerFieldsBeginOffset),
345 HeapObject::RawField(object, PropertyCell::kPointerFieldsEndOffset)); 332 HeapObject::RawField(object, PropertyCell::kPointerFieldsEndOffset));
346 } 333 }
347 334
348 335
349 template <typename StaticVisitor> 336 template <typename StaticVisitor>
350 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCell(Map* map, 337 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCell(Map* map,
351 HeapObject* object) { 338 HeapObject* object) {
352 Heap* heap = map->GetHeap(); 339 Heap* heap = map->GetHeap();
353 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(object); 340 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(object);
354 Object* undefined = heap->undefined_value(); 341 Object* undefined = heap->undefined_value();
355 // Enqueue weak cell in linked list of encountered weak collections. 342 // Enqueue weak cell in linked list of encountered weak collections.
356 // We can ignore weak cells with cleared values because they will always 343 // We can ignore weak cells with cleared values because they will always
357 // contain smi zero. 344 // contain smi zero.
358 if (weak_cell->next() == undefined && !weak_cell->cleared()) { 345 if (weak_cell->next() == undefined && !weak_cell->cleared()) {
359 weak_cell->set_next(heap->encountered_weak_cells()); 346 weak_cell->set_next(heap->encountered_weak_cells());
360 heap->set_encountered_weak_cells(weak_cell); 347 heap->set_encountered_weak_cells(weak_cell);
361 } 348 }
362 } 349 }
363 350
364 351
365 template <typename StaticVisitor> 352 template <typename StaticVisitor>
366 void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite( 353 void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite(
367 Map* map, HeapObject* object) { 354 Map* map, HeapObject* object) {
368 Heap* heap = map->GetHeap(); 355 Heap* heap = map->GetHeap();
369 356
370 Object** slot =
371 HeapObject::RawField(object, AllocationSite::kDependentCodeOffset);
372 if (FLAG_collect_maps) {
373 // Mark allocation site dependent codes array but do not push it onto
374 // marking stack, this will make references from it weak. We will clean
375 // dead codes when we iterate over allocation sites in
376 // ClearNonLiveReferences.
377 HeapObject* obj = HeapObject::cast(*slot);
378 heap->mark_compact_collector()->RecordSlot(slot, slot, obj);
379 StaticVisitor::MarkObjectWithoutPush(heap, obj);
380 } else {
381 StaticVisitor::VisitPointer(heap, slot);
382 }
383
384 StaticVisitor::VisitPointers( 357 StaticVisitor::VisitPointers(
385 heap, 358 heap,
386 HeapObject::RawField(object, AllocationSite::kPointerFieldsBeginOffset), 359 HeapObject::RawField(object, AllocationSite::kPointerFieldsBeginOffset),
387 HeapObject::RawField(object, AllocationSite::kPointerFieldsEndOffset)); 360 HeapObject::RawField(object, AllocationSite::kPointerFieldsEndOffset));
388 } 361 }
389 362
390 363
391 template <typename StaticVisitor> 364 template <typename StaticVisitor>
392 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCollection( 365 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCollection(
393 Map* map, HeapObject* object) { 366 Map* map, HeapObject* object) {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 descriptors->GetDescriptorEndSlot(0)); 609 descriptors->GetDescriptorEndSlot(0));
637 } 610 }
638 int start = 0; 611 int start = 0;
639 int end = map->NumberOfOwnDescriptors(); 612 int end = map->NumberOfOwnDescriptors();
640 if (start < end) { 613 if (start < end) {
641 StaticVisitor::VisitPointers(heap, 614 StaticVisitor::VisitPointers(heap,
642 descriptors->GetDescriptorStartSlot(start), 615 descriptors->GetDescriptorStartSlot(start),
643 descriptors->GetDescriptorEndSlot(end)); 616 descriptors->GetDescriptorEndSlot(end));
644 } 617 }
645 618
646 // Mark prototype dependent codes array but do not push it onto marking
647 // stack, this will make references from it weak. We will clean dead
648 // codes when we iterate over maps in ClearNonLiveTransitions.
649 Object** slot = HeapObject::RawField(map, Map::kDependentCodeOffset);
650 HeapObject* obj = HeapObject::cast(*slot);
651 heap->mark_compact_collector()->RecordSlot(slot, slot, obj);
652 StaticVisitor::MarkObjectWithoutPush(heap, obj);
653
654 // Mark the pointer fields of the Map. Since the transitions array has 619 // Mark the pointer fields of the Map. Since the transitions array has
655 // been marked already, it is fine that one of these fields contains a 620 // been marked already, it is fine that one of these fields contains a
656 // pointer to it. 621 // pointer to it.
657 StaticVisitor::VisitPointers( 622 StaticVisitor::VisitPointers(
658 heap, HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), 623 heap, HeapObject::RawField(map, Map::kPointerFieldsBeginOffset),
659 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); 624 HeapObject::RawField(map, Map::kPointerFieldsEndOffset));
660 } 625 }
661 626
662 627
663 template <typename StaticVisitor> 628 template <typename StaticVisitor>
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 900
936 RelocIterator it(this, mode_mask); 901 RelocIterator it(this, mode_mask);
937 for (; !it.done(); it.next()) { 902 for (; !it.done(); it.next()) {
938 it.rinfo()->template Visit<StaticVisitor>(heap); 903 it.rinfo()->template Visit<StaticVisitor>(heap);
939 } 904 }
940 } 905 }
941 } 906 }
942 } // namespace v8::internal 907 } // namespace v8::internal
943 908
944 #endif // V8_OBJECTS_VISITING_INL_H_ 909 #endif // V8_OBJECTS_VISITING_INL_H_
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/lithium.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698