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

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

Issue 2915793002: [api] Prototype WeakRef implementation
Patch Set: Created 3 years, 6 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.cc ('k') | src/heap/scavenger.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 #include "src/heap/array-buffer-tracker.h" 8 #include "src/heap/array-buffer-tracker.h"
9 #include "src/heap/mark-compact.h" 9 #include "src/heap/mark-compact.h"
10 #include "src/heap/objects-visiting.h" 10 #include "src/heap/objects-visiting.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 table_.Register(kVisitBytecodeArray, &VisitBytecodeArray); 157 table_.Register(kVisitBytecodeArray, &VisitBytecodeArray);
158 158
159 table_.Register(kVisitFreeSpace, &DataObjectVisitor::Visit); 159 table_.Register(kVisitFreeSpace, &DataObjectVisitor::Visit);
160 160
161 table_.Register(kVisitSeqOneByteString, &DataObjectVisitor::Visit); 161 table_.Register(kVisitSeqOneByteString, &DataObjectVisitor::Visit);
162 162
163 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit); 163 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit);
164 164
165 table_.Register(kVisitJSWeakCollection, &VisitWeakCollection); 165 table_.Register(kVisitJSWeakCollection, &VisitWeakCollection);
166 166
167 table_.Register(kVisitJSWeakRef, &VisitWeakRef);
168
167 table_.Register( 169 table_.Register(
168 kVisitOddball, 170 kVisitOddball,
169 &FixedBodyVisitor<StaticVisitor, Oddball::BodyDescriptor, void>::Visit); 171 &FixedBodyVisitor<StaticVisitor, Oddball::BodyDescriptor, void>::Visit);
170 172
171 table_.Register(kVisitMap, &VisitMap); 173 table_.Register(kVisitMap, &VisitMap);
172 174
173 table_.Register(kVisitCode, &VisitCode); 175 table_.Register(kVisitCode, &VisitCode);
174 176
175 table_.Register(kVisitSharedFunctionInfo, &VisitSharedFunctionInfo); 177 table_.Register(kVisitSharedFunctionInfo, &VisitSharedFunctionInfo);
176 178
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // Partially initialized weak collection is enqueued, but table is ignored. 394 // Partially initialized weak collection is enqueued, but table is ignored.
393 if (!weak_collection->table()->IsHashTable()) return; 395 if (!weak_collection->table()->IsHashTable()) return;
394 396
395 // Mark the backing hash table without pushing it on the marking stack. 397 // Mark the backing hash table without pushing it on the marking stack.
396 Object** slot = HeapObject::RawField(object, JSWeakCollection::kTableOffset); 398 Object** slot = HeapObject::RawField(object, JSWeakCollection::kTableOffset);
397 HeapObject* obj = HeapObject::cast(*slot); 399 HeapObject* obj = HeapObject::cast(*slot);
398 heap->mark_compact_collector()->RecordSlot(object, slot, obj); 400 heap->mark_compact_collector()->RecordSlot(object, slot, obj);
399 StaticVisitor::MarkObjectWithoutPush(heap, obj); 401 StaticVisitor::MarkObjectWithoutPush(heap, obj);
400 } 402 }
401 403
404 template <typename StaticVisitor>
405 void StaticMarkingVisitor<StaticVisitor>::VisitWeakRef(
406 Map* map, HeapObject* object) {
407 Heap* heap = map->GetHeap();
408 JSWeakRef* weak_ref =
409 reinterpret_cast<JSWeakRef*>(object);
410
411 if (weak_ref->executor() != nullptr) {
412 StaticVisitor::MarkObject(heap, weak_ref->executor());
413 }
414 if (weak_ref->holdings() != nullptr && weak_ref->holdings()->IsHeapObject()) {
415 StaticVisitor::MarkObject(heap,
416 reinterpret_cast<HeapObject*>(weak_ref->holdings()));
417 }
418 if (weak_ref->target() != nullptr) {
419 StaticVisitor::MarkObject(heap, weak_ref->target());
420 if (weak_ref->held()) {
421 if (!weak_ref->target()->cleared()) {
422 StaticVisitor::MarkObject(heap,
423 reinterpret_cast<JSObject*>(weak_ref->target()->value()));
424 }
425 } else if (weak_ref->target()->cleared()) {
426 weak_ref->set_target(nullptr);
427 weak_ref->set_held(false);
428 weak_ref->set_queued(true);
429 }
430 }
431 }
432
402 433
403 template <typename StaticVisitor> 434 template <typename StaticVisitor>
404 void StaticMarkingVisitor<StaticVisitor>::VisitCode(Map* map, 435 void StaticMarkingVisitor<StaticVisitor>::VisitCode(Map* map,
405 HeapObject* object) { 436 HeapObject* object) {
406 typedef FlexibleBodyVisitor<StaticVisitor, Code::BodyDescriptor, void> 437 typedef FlexibleBodyVisitor<StaticVisitor, Code::BodyDescriptor, void>
407 CodeBodyVisitor; 438 CodeBodyVisitor;
408 Heap* heap = map->GetHeap(); 439 Heap* heap = map->GetHeap();
409 Code* code = Code::cast(object); 440 Code* code = Code::cast(object);
410 if (FLAG_age_code && !heap->isolate()->serializer_enabled()) { 441 if (FLAG_age_code && !heap->isolate()->serializer_enabled()) {
411 code->MakeOlder(); 442 code->MakeOlder();
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, 666 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode,
636 void> JSFunctionWeakCodeBodyVisitor; 667 void> JSFunctionWeakCodeBodyVisitor;
637 JSFunctionWeakCodeBodyVisitor::Visit(map, object); 668 JSFunctionWeakCodeBodyVisitor::Visit(map, object);
638 } 669 }
639 670
640 671
641 } // namespace internal 672 } // namespace internal
642 } // namespace v8 673 } // namespace v8
643 674
644 #endif // V8_OBJECTS_VISITING_INL_H_ 675 #endif // V8_OBJECTS_VISITING_INL_H_
OLDNEW
« no previous file with comments | « src/heap/objects-visiting.cc ('k') | src/heap/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698