OLD | NEW |
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 table_.Register(kVisitJSFunction, &VisitJSFunction); | 59 table_.Register(kVisitJSFunction, &VisitJSFunction); |
60 | 60 |
61 table_.Register(kVisitJSArrayBuffer, &VisitJSArrayBuffer); | 61 table_.Register(kVisitJSArrayBuffer, &VisitJSArrayBuffer); |
62 | 62 |
63 table_.Register(kVisitJSTypedArray, &VisitJSTypedArray); | 63 table_.Register(kVisitJSTypedArray, &VisitJSTypedArray); |
64 | 64 |
65 table_.Register(kVisitJSDataView, &VisitJSDataView); | 65 table_.Register(kVisitJSDataView, &VisitJSDataView); |
66 | 66 |
67 table_.Register(kVisitFreeSpace, &VisitFreeSpace); | 67 table_.Register(kVisitFreeSpace, &VisitFreeSpace); |
68 | 68 |
69 table_.Register(kVisitJSWeakMap, &JSObjectVisitor::Visit); | 69 table_.Register(kVisitJSWeakCollection, &JSObjectVisitor::Visit); |
70 | |
71 table_.Register(kVisitJSWeakSet, &JSObjectVisitor::Visit); | |
72 | 70 |
73 table_.Register(kVisitJSRegExp, &JSObjectVisitor::Visit); | 71 table_.Register(kVisitJSRegExp, &JSObjectVisitor::Visit); |
74 | 72 |
75 table_.template RegisterSpecializations<DataObjectVisitor, | 73 table_.template RegisterSpecializations<DataObjectVisitor, |
76 kVisitDataObject, | 74 kVisitDataObject, |
77 kVisitDataObjectGeneric>(); | 75 kVisitDataObjectGeneric>(); |
78 | 76 |
79 table_.template RegisterSpecializations<JSObjectVisitor, | 77 table_.template RegisterSpecializations<JSObjectVisitor, |
80 kVisitJSObject, | 78 kVisitJSObject, |
81 kVisitJSObjectGeneric>(); | 79 kVisitJSObjectGeneric>(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 table_.Register(kVisitAllocationSite, &VisitAllocationSite); | 173 table_.Register(kVisitAllocationSite, &VisitAllocationSite); |
176 | 174 |
177 table_.Register(kVisitByteArray, &DataObjectVisitor::Visit); | 175 table_.Register(kVisitByteArray, &DataObjectVisitor::Visit); |
178 | 176 |
179 table_.Register(kVisitFreeSpace, &DataObjectVisitor::Visit); | 177 table_.Register(kVisitFreeSpace, &DataObjectVisitor::Visit); |
180 | 178 |
181 table_.Register(kVisitSeqOneByteString, &DataObjectVisitor::Visit); | 179 table_.Register(kVisitSeqOneByteString, &DataObjectVisitor::Visit); |
182 | 180 |
183 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit); | 181 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit); |
184 | 182 |
185 table_.Register(kVisitJSWeakMap, &StaticVisitor::VisitWeakCollection); | 183 table_.Register(kVisitJSWeakCollection, &VisitWeakCollection); |
186 | |
187 table_.Register(kVisitJSWeakSet, &StaticVisitor::VisitWeakCollection); | |
188 | 184 |
189 table_.Register(kVisitOddball, | 185 table_.Register(kVisitOddball, |
190 &FixedBodyVisitor<StaticVisitor, | 186 &FixedBodyVisitor<StaticVisitor, |
191 Oddball::BodyDescriptor, | 187 Oddball::BodyDescriptor, |
192 void>::Visit); | 188 void>::Visit); |
193 | 189 |
194 table_.Register(kVisitMap, &VisitMap); | 190 table_.Register(kVisitMap, &VisitMap); |
195 | 191 |
196 table_.Register(kVisitCode, &VisitCode); | 192 table_.Register(kVisitCode, &VisitCode); |
197 | 193 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 275 |
280 | 276 |
281 template<typename StaticVisitor> | 277 template<typename StaticVisitor> |
282 void StaticMarkingVisitor<StaticVisitor>::VisitCodeTarget( | 278 void StaticMarkingVisitor<StaticVisitor>::VisitCodeTarget( |
283 Heap* heap, RelocInfo* rinfo) { | 279 Heap* heap, RelocInfo* rinfo) { |
284 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); | 280 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); |
285 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 281 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
286 // Monomorphic ICs are preserved when possible, but need to be flushed | 282 // Monomorphic ICs are preserved when possible, but need to be flushed |
287 // when they might be keeping a Context alive, or when the heap is about | 283 // when they might be keeping a Context alive, or when the heap is about |
288 // to be serialized. | 284 // to be serialized. |
289 | |
290 if (FLAG_cleanup_code_caches_at_gc && target->is_inline_cache_stub() | 285 if (FLAG_cleanup_code_caches_at_gc && target->is_inline_cache_stub() |
291 && (target->ic_state() == MEGAMORPHIC || target->ic_state() == GENERIC || | 286 && (target->ic_state() == MEGAMORPHIC || target->ic_state() == GENERIC || |
292 target->ic_state() == POLYMORPHIC || heap->flush_monomorphic_ics() || | 287 target->ic_state() == POLYMORPHIC || heap->flush_monomorphic_ics() || |
293 heap->isolate()->serializer_enabled() || | 288 heap->isolate()->serializer_enabled() || |
294 target->ic_age() != heap->global_ic_age() || | 289 target->ic_age() != heap->global_ic_age() || |
295 target->is_invalidated_weak_stub())) { | 290 target->is_invalidated_weak_stub())) { |
296 IC::Clear(heap->isolate(), rinfo->pc(), rinfo->host()->constant_pool()); | 291 IC::Clear(heap->isolate(), rinfo->pc(), rinfo->host()->constant_pool()); |
297 target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 292 target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
298 } | 293 } |
299 heap->mark_compact_collector()->RecordRelocSlot(rinfo, target); | 294 heap->mark_compact_collector()->RecordRelocSlot(rinfo, target); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 StaticVisitor::VisitPointer(heap, slot); | 390 StaticVisitor::VisitPointer(heap, slot); |
396 } | 391 } |
397 | 392 |
398 StaticVisitor::VisitPointers(heap, | 393 StaticVisitor::VisitPointers(heap, |
399 HeapObject::RawField(object, AllocationSite::kPointerFieldsBeginOffset), | 394 HeapObject::RawField(object, AllocationSite::kPointerFieldsBeginOffset), |
400 HeapObject::RawField(object, AllocationSite::kPointerFieldsEndOffset)); | 395 HeapObject::RawField(object, AllocationSite::kPointerFieldsEndOffset)); |
401 } | 396 } |
402 | 397 |
403 | 398 |
404 template<typename StaticVisitor> | 399 template<typename StaticVisitor> |
| 400 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCollection( |
| 401 Map* map, HeapObject* object) { |
| 402 Heap* heap = map->GetHeap(); |
| 403 JSWeakCollection* weak_collection = |
| 404 reinterpret_cast<JSWeakCollection*>(object); |
| 405 MarkCompactCollector* collector = heap->mark_compact_collector(); |
| 406 |
| 407 // Enqueue weak map in linked list of encountered weak maps. |
| 408 if (weak_collection->next() == heap->undefined_value()) { |
| 409 weak_collection->set_next(collector->encountered_weak_collections()); |
| 410 collector->set_encountered_weak_collections(weak_collection); |
| 411 } |
| 412 |
| 413 // Skip visiting the backing hash table containing the mappings and the |
| 414 // pointer to the other enqueued weak collections, both are post-processed. |
| 415 StaticVisitor::VisitPointers(heap, |
| 416 HeapObject::RawField(object, JSWeakCollection::kPropertiesOffset), |
| 417 HeapObject::RawField(object, JSWeakCollection::kTableOffset)); |
| 418 STATIC_ASSERT(JSWeakCollection::kTableOffset + kPointerSize == |
| 419 JSWeakCollection::kNextOffset); |
| 420 STATIC_ASSERT(JSWeakCollection::kNextOffset + kPointerSize == |
| 421 JSWeakCollection::kSize); |
| 422 |
| 423 if (!weak_collection->table()->IsHashTable()) return; |
| 424 |
| 425 // Mark the backing hash table without pushing it on the marking stack. |
| 426 Object** slot = HeapObject::RawField(object, JSWeakCollection::kTableOffset); |
| 427 HeapObject* obj = HeapObject::cast(*slot); |
| 428 heap->mark_compact_collector()->RecordSlot(slot, slot, obj); |
| 429 StaticVisitor::MarkObjectWithoutPush(heap, obj); |
| 430 } |
| 431 |
| 432 |
| 433 template<typename StaticVisitor> |
405 void StaticMarkingVisitor<StaticVisitor>::VisitCode( | 434 void StaticMarkingVisitor<StaticVisitor>::VisitCode( |
406 Map* map, HeapObject* object) { | 435 Map* map, HeapObject* object) { |
407 Heap* heap = map->GetHeap(); | 436 Heap* heap = map->GetHeap(); |
408 Code* code = Code::cast(object); | 437 Code* code = Code::cast(object); |
409 if (FLAG_age_code && !heap->isolate()->serializer_enabled()) { | 438 if (FLAG_age_code && !heap->isolate()->serializer_enabled()) { |
410 code->MakeOlder(heap->mark_compact_collector()->marking_parity()); | 439 code->MakeOlder(heap->mark_compact_collector()->marking_parity()); |
411 } | 440 } |
412 code->CodeIterateBody<StaticVisitor>(heap); | 441 code->CodeIterateBody<StaticVisitor>(heap); |
413 } | 442 } |
414 | 443 |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 RelocIterator it(this, mode_mask); | 959 RelocIterator it(this, mode_mask); |
931 for (; !it.done(); it.next()) { | 960 for (; !it.done(); it.next()) { |
932 it.rinfo()->template Visit<StaticVisitor>(heap); | 961 it.rinfo()->template Visit<StaticVisitor>(heap); |
933 } | 962 } |
934 } | 963 } |
935 | 964 |
936 | 965 |
937 } } // namespace v8::internal | 966 } } // namespace v8::internal |
938 | 967 |
939 #endif // V8_OBJECTS_VISITING_INL_H_ | 968 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |