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

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

Issue 1844413002: Use EmbedderHeapTracer instead of object grouping when trace_embedder_heap flag is set (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move logic from heap to mark compact Created 4 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/mark-compact.cc ('k') | src/heap/objects-visiting.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_H_ 5 #ifndef V8_OBJECTS_VISITING_H_
6 #define V8_OBJECTS_VISITING_H_ 6 #define V8_OBJECTS_VISITING_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/heap/heap.h" 9 #include "src/heap/heap.h"
10 #include "src/heap/spaces.h" 10 #include "src/heap/spaces.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 V(DataObjectGeneric) \ 51 V(DataObjectGeneric) \
52 V(JSObject2) \ 52 V(JSObject2) \
53 V(JSObject3) \ 53 V(JSObject3) \
54 V(JSObject4) \ 54 V(JSObject4) \
55 V(JSObject5) \ 55 V(JSObject5) \
56 V(JSObject6) \ 56 V(JSObject6) \
57 V(JSObject7) \ 57 V(JSObject7) \
58 V(JSObject8) \ 58 V(JSObject8) \
59 V(JSObject9) \ 59 V(JSObject9) \
60 V(JSObjectGeneric) \ 60 V(JSObjectGeneric) \
61 V(JSApiObject2) \
62 V(JSApiObject3) \
63 V(JSApiObject4) \
64 V(JSApiObject5) \
65 V(JSApiObject6) \
66 V(JSApiObject7) \
67 V(JSApiObject8) \
68 V(JSApiObject9) \
69 V(JSApiObjectGeneric) \
61 V(Struct2) \ 70 V(Struct2) \
62 V(Struct3) \ 71 V(Struct3) \
63 V(Struct4) \ 72 V(Struct4) \
64 V(Struct5) \ 73 V(Struct5) \
65 V(Struct6) \ 74 V(Struct6) \
66 V(Struct7) \ 75 V(Struct7) \
67 V(Struct8) \ 76 V(Struct8) \
68 V(Struct9) \ 77 V(Struct9) \
69 V(StructGeneric) \ 78 V(StructGeneric) \
70 V(ConsString) \ 79 V(ConsString) \
(...skipping 18 matching lines...) Expand all
89 // Ids of specialized visitors are declared in a linear order (without 98 // Ids of specialized visitors are declared in a linear order (without
90 // holes) starting from the id of visitor specialized for 2 words objects 99 // holes) starting from the id of visitor specialized for 2 words objects
91 // (base visitor id) and ending with the id of generic visitor. 100 // (base visitor id) and ending with the id of generic visitor.
92 // Method GetVisitorIdForSize depends on this ordering to calculate visitor 101 // Method GetVisitorIdForSize depends on this ordering to calculate visitor
93 // id of specialized visitor from given instance size, base visitor id and 102 // id of specialized visitor from given instance size, base visitor id and
94 // generic visitor's id. 103 // generic visitor's id.
95 enum VisitorId { 104 enum VisitorId {
96 #define VISITOR_ID_ENUM_DECL(id) kVisit##id, 105 #define VISITOR_ID_ENUM_DECL(id) kVisit##id,
97 VISITOR_ID_LIST(VISITOR_ID_ENUM_DECL) 106 VISITOR_ID_LIST(VISITOR_ID_ENUM_DECL)
98 #undef VISITOR_ID_ENUM_DECL 107 #undef VISITOR_ID_ENUM_DECL
99 kVisitorIdCount, 108 kVisitorIdCount,
100 kVisitDataObject = kVisitDataObject2, 109 kVisitDataObject = kVisitDataObject2,
101 kVisitJSObject = kVisitJSObject2, 110 kVisitJSObject = kVisitJSObject2,
111 kVisitJSApiObject = kVisitJSApiObject2,
102 kVisitStruct = kVisitStruct2, 112 kVisitStruct = kVisitStruct2,
103 }; 113 };
104 114
105 // Visitor ID should fit in one byte. 115 // Visitor ID should fit in one byte.
106 STATIC_ASSERT(kVisitorIdCount <= 256); 116 STATIC_ASSERT(kVisitorIdCount <= 256);
107 117
108 // Determine which specialized visitor should be used for given instance type 118 // Determine which specialized visitor should be used for given instance type
109 // and instance type. 119 // and instance type.
110 static VisitorId GetVisitorId(int instance_type, int instance_size, 120 static VisitorId GetVisitorId(int instance_type, int instance_size,
111 bool has_unboxed_fields); 121 bool has_unboxed_fields);
112 122
113 // Determine which specialized visitor should be used for given map. 123 // Determine which specialized visitor should be used for given map.
114 static VisitorId GetVisitorId(Map* map); 124 static VisitorId GetVisitorId(Map* map);
115 125
116 // For visitors that allow specialization by size calculate VisitorId based 126 // For visitors that allow specialization by size calculate VisitorId based
117 // on size, base visitor id and generic visitor id. 127 // on size, base visitor id and generic visitor id.
118 static VisitorId GetVisitorIdForSize(VisitorId base, VisitorId generic, 128 static VisitorId GetVisitorIdForSize(VisitorId base, VisitorId generic,
119 int object_size, 129 int object_size,
120 bool has_unboxed_fields) { 130 bool has_unboxed_fields) {
121 DCHECK((base == kVisitDataObject) || (base == kVisitStruct) || 131 DCHECK((base == kVisitDataObject) || (base == kVisitStruct) ||
122 (base == kVisitJSObject)); 132 (base == kVisitJSObject) || (base == kVisitJSApiObject));
123 DCHECK(IsAligned(object_size, kPointerSize)); 133 DCHECK(IsAligned(object_size, kPointerSize));
124 DCHECK(Heap::kMinObjectSizeInWords * kPointerSize <= object_size); 134 DCHECK(Heap::kMinObjectSizeInWords * kPointerSize <= object_size);
125 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); 135 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize);
126 DCHECK(!has_unboxed_fields || (base == kVisitJSObject)); 136 DCHECK(!has_unboxed_fields || (base == kVisitJSObject) ||
137 (base == kVisitJSApiObject));
127 138
128 if (has_unboxed_fields) return generic; 139 if (has_unboxed_fields) return generic;
129 140
130 int visitor_id = Min( 141 int visitor_id = Min(
131 base + (object_size >> kPointerSizeLog2) - Heap::kMinObjectSizeInWords, 142 base + (object_size >> kPointerSizeLog2) - Heap::kMinObjectSizeInWords,
132 static_cast<int>(generic)); 143 static_cast<int>(generic));
133 144
134 return static_cast<VisitorId>(visitor_id); 145 return static_cast<VisitorId>(visitor_id);
135 } 146 }
136 }; 147 };
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 404
394 INLINE(static void Visit(Map* map, HeapObject* object)) {} 405 INLINE(static void Visit(Map* map, HeapObject* object)) {}
395 }; 406 };
396 407
397 typedef FlexibleBodyVisitor<StaticVisitor, FixedArray::BodyDescriptor, void> 408 typedef FlexibleBodyVisitor<StaticVisitor, FixedArray::BodyDescriptor, void>
398 FixedArrayVisitor; 409 FixedArrayVisitor;
399 410
400 typedef FlexibleBodyVisitor<StaticVisitor, JSObject::BodyDescriptor, void> 411 typedef FlexibleBodyVisitor<StaticVisitor, JSObject::BodyDescriptor, void>
401 JSObjectVisitor; 412 JSObjectVisitor;
402 413
414 class JSApiObjectVisitor : AllStatic {
415 public:
416 template <int size>
417 static inline void VisitSpecialized(Map* map, HeapObject* object) {
418 TracePossibleWrapper(object);
419 JSObjectVisitor::template VisitSpecialized<size>(map, object);
420 }
421
422 INLINE(static void Visit(Map* map, HeapObject* object)) {
423 TracePossibleWrapper(object);
424 JSObjectVisitor::Visit(map, object);
425 }
426
427 private:
428 INLINE(static void TracePossibleWrapper(HeapObject* object)) {
429 if (object->GetHeap()->UsingEmbedderHeapTracer()) {
430 DCHECK(object->IsJSObject());
431 object->GetHeap()->TracePossibleWrapper(JSObject::cast(object));
432 }
433 }
434 };
435
403 typedef FlexibleBodyVisitor<StaticVisitor, StructBodyDescriptor, void> 436 typedef FlexibleBodyVisitor<StaticVisitor, StructBodyDescriptor, void>
404 StructObjectVisitor; 437 StructObjectVisitor;
405 438
406 typedef void (*Callback)(Map* map, HeapObject* object); 439 typedef void (*Callback)(Map* map, HeapObject* object);
407 440
408 static VisitorDispatchTable<Callback> table_; 441 static VisitorDispatchTable<Callback> table_;
409 }; 442 };
410 443
411 444
412 template <typename StaticVisitor> 445 template <typename StaticVisitor>
413 VisitorDispatchTable<typename StaticMarkingVisitor<StaticVisitor>::Callback> 446 VisitorDispatchTable<typename StaticMarkingVisitor<StaticVisitor>::Callback>
414 StaticMarkingVisitor<StaticVisitor>::table_; 447 StaticMarkingVisitor<StaticVisitor>::table_;
415 448
416 449
417 class WeakObjectRetainer; 450 class WeakObjectRetainer;
418 451
419 452
420 // A weak list is single linked list where each element has a weak pointer to 453 // A weak list is single linked list where each element has a weak pointer to
421 // the next element. Given the head of the list, this function removes dead 454 // the next element. Given the head of the list, this function removes dead
422 // elements from the list and if requested records slots for next-element 455 // elements from the list and if requested records slots for next-element
423 // pointers. The template parameter T is a WeakListVisitor that defines how to 456 // pointers. The template parameter T is a WeakListVisitor that defines how to
424 // access the next-element pointers. 457 // access the next-element pointers.
425 template <class T> 458 template <class T>
426 Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer); 459 Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer);
427 } // namespace internal 460 } // namespace internal
428 } // namespace v8 461 } // namespace v8
429 462
430 #endif // V8_OBJECTS_VISITING_H_ 463 #endif // V8_OBJECTS_VISITING_H_
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/objects-visiting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698