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

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

Issue 640303006: Weak Cells (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Skip cleared weak cells Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/heap/objects-visiting.cc ('k') | src/objects.h » ('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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 table_.Register(kVisitJSDataView, &VisitJSDataView); 184 table_.Register(kVisitJSDataView, &VisitJSDataView);
185 185
186 // Registration for kVisitJSRegExp is done by StaticVisitor. 186 // Registration for kVisitJSRegExp is done by StaticVisitor.
187 187
188 table_.Register( 188 table_.Register(
189 kVisitCell, 189 kVisitCell,
190 &FixedBodyVisitor<StaticVisitor, Cell::BodyDescriptor, void>::Visit); 190 &FixedBodyVisitor<StaticVisitor, Cell::BodyDescriptor, void>::Visit);
191 191
192 table_.Register(kVisitPropertyCell, &VisitPropertyCell); 192 table_.Register(kVisitPropertyCell, &VisitPropertyCell);
193 193
194 table_.Register(kVisitWeakCell, &VisitWeakCell);
195
194 table_.template RegisterSpecializations<DataObjectVisitor, kVisitDataObject, 196 table_.template RegisterSpecializations<DataObjectVisitor, kVisitDataObject,
195 kVisitDataObjectGeneric>(); 197 kVisitDataObjectGeneric>();
196 198
197 table_.template RegisterSpecializations<JSObjectVisitor, kVisitJSObject, 199 table_.template RegisterSpecializations<JSObjectVisitor, kVisitJSObject,
198 kVisitJSObjectGeneric>(); 200 kVisitJSObjectGeneric>();
199 201
200 table_.template RegisterSpecializations<StructObjectVisitor, kVisitStruct, 202 table_.template RegisterSpecializations<StructObjectVisitor, kVisitStruct,
201 kVisitStructGeneric>(); 203 kVisitStructGeneric>();
202 } 204 }
203 205
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 345 }
344 346
345 StaticVisitor::VisitPointers( 347 StaticVisitor::VisitPointers(
346 heap, 348 heap,
347 HeapObject::RawField(object, PropertyCell::kPointerFieldsBeginOffset), 349 HeapObject::RawField(object, PropertyCell::kPointerFieldsBeginOffset),
348 HeapObject::RawField(object, PropertyCell::kPointerFieldsEndOffset)); 350 HeapObject::RawField(object, PropertyCell::kPointerFieldsEndOffset));
349 } 351 }
350 352
351 353
352 template <typename StaticVisitor> 354 template <typename StaticVisitor>
355 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCell(Map* map,
356 HeapObject* object) {
357 Heap* heap = map->GetHeap();
358 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(object);
359 Object* undefined = heap->undefined_value();
360 // Enqueue weak cell in linked list of encountered weak collections.
361 // We can ignore weak cells with cleared values because they will always point
362 // to the undefined_value.
363 if (weak_cell->next() == undefined && weak_cell->value() != undefined) {
364 weak_cell->set_next(heap->encountered_weak_cells());
365 heap->set_encountered_weak_cells(weak_cell);
366 }
367 }
368
369
370 template <typename StaticVisitor>
353 void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite( 371 void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite(
354 Map* map, HeapObject* object) { 372 Map* map, HeapObject* object) {
355 Heap* heap = map->GetHeap(); 373 Heap* heap = map->GetHeap();
356 374
357 Object** slot = 375 Object** slot =
358 HeapObject::RawField(object, AllocationSite::kDependentCodeOffset); 376 HeapObject::RawField(object, AllocationSite::kDependentCodeOffset);
359 if (FLAG_collect_maps) { 377 if (FLAG_collect_maps) {
360 // Mark allocation site dependent codes array but do not push it onto 378 // Mark allocation site dependent codes array but do not push it onto
361 // marking stack, this will make references from it weak. We will clean 379 // marking stack, this will make references from it weak. We will clean
362 // dead codes when we iterate over allocation sites in 380 // dead codes when we iterate over allocation sites in
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 943
926 RelocIterator it(this, mode_mask); 944 RelocIterator it(this, mode_mask);
927 for (; !it.done(); it.next()) { 945 for (; !it.done(); it.next()) {
928 it.rinfo()->template Visit<StaticVisitor>(heap); 946 it.rinfo()->template Visit<StaticVisitor>(heap);
929 } 947 }
930 } 948 }
931 } 949 }
932 } // namespace v8::internal 950 } // namespace v8::internal
933 951
934 #endif // V8_OBJECTS_VISITING_INL_H_ 952 #endif // V8_OBJECTS_VISITING_INL_H_
OLDNEW
« no previous file with comments | « src/heap/objects-visiting.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698