&ObjectEvacuationStrategy<POINTER_OBJECT>::
template VisitSpecialized<SharedFunctionInfo::kSize>);
- table_.Register(kVisitJSWeakMap,
- &ObjectEvacuationStrategy<POINTER_OBJECT>::
- Visit);
-
- table_.Register(kVisitJSWeakSet,
+ table_.Register(kVisitJSWeakCollection,
&ObjectEvacuationStrategy<POINTER_OBJECT>::
Visit);
VisitNativeContext(map, context);
}
- static void VisitWeakCollection(Map* map, HeapObject* object) {
- Heap* heap = map->GetHeap();
- VisitPointers(heap,
- HeapObject::RawField(object,
- JSWeakCollection::kPropertiesOffset),
- HeapObject::RawField(object, JSWeakCollection::kSize));
- }
-
INLINE(static void VisitPointer(Heap* heap, Object** p)) {
Object* obj = *p;
if (obj->IsHeapObject()) {
return true;
}
- static void VisitWeakCollection(Map* map, HeapObject* object) {
- MarkCompactCollector* collector = map->GetHeap()->mark_compact_collector();
- JSWeakCollection* weak_collection =
- reinterpret_cast<JSWeakCollection*>(object);
-
- // Enqueue weak map in linked list of encountered weak maps.
- if (weak_collection->next() == Smi::FromInt(0)) {
- weak_collection->set_next(collector->encountered_weak_collections());
- collector->set_encountered_weak_collections(weak_collection);
- }
-
- // Skip visiting the backing hash table containing the mappings.
- int object_size = JSWeakCollection::BodyDescriptor::SizeOf(map, object);
- BodyVisitorBase<MarkCompactMarkingVisitor>::IteratePointers(
- map->GetHeap(),
- object,
- JSWeakCollection::BodyDescriptor::kStartOffset,
- JSWeakCollection::kTableOffset);
- BodyVisitorBase<MarkCompactMarkingVisitor>::IteratePointers(
- map->GetHeap(),
- object,
- JSWeakCollection::kTableOffset + kPointerSize,
- object_size);
-
- // Mark the backing hash table without pushing it on the marking stack.
- Object* table_object = weak_collection->table();
- if (!table_object->IsHashTable()) return;
- WeakHashTable* table = WeakHashTable::cast(table_object);
- Object** table_slot =
- HeapObject::RawField(weak_collection, JSWeakCollection::kTableOffset);
- MarkBit table_mark = Marking::MarkBitFrom(table);
- collector->RecordSlot(table_slot, table_slot, table);
- if (!table_mark.Get()) collector->SetMark(table, table_mark);
- // Recording the map slot can be skipped, because maps are not compacted.
- collector->MarkObject(table->map(), Marking::MarkBitFrom(table->map()));
- ASSERT(MarkCompactCollector::IsMarked(table->map()));
- }
-
private:
template<int id>
static inline void TrackObjectStatsAndVisit(Map* map, HeapObject* obj);
}
}
weak_collection_obj = weak_collection->next();
- weak_collection->set_next(Smi::FromInt(0));
+ weak_collection->set_next(heap()->undefined_value());
}
set_encountered_weak_collections(Smi::FromInt(0));
}
table_.Register(kVisitFreeSpace, &VisitFreeSpace);
- table_.Register(kVisitJSWeakMap, &JSObjectVisitor::Visit);
-
- table_.Register(kVisitJSWeakSet, &JSObjectVisitor::Visit);
+ table_.Register(kVisitJSWeakCollection, &JSObjectVisitor::Visit);
table_.Register(kVisitJSRegExp, &JSObjectVisitor::Visit);
table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit);
- table_.Register(kVisitJSWeakMap, &StaticVisitor::VisitWeakCollection);
-
- table_.Register(kVisitJSWeakSet, &StaticVisitor::VisitWeakCollection);
+ table_.Register(kVisitJSWeakCollection, &VisitWeakCollection);
table_.Register(kVisitOddball,
&FixedBodyVisitor<StaticVisitor,
// Monomorphic ICs are preserved when possible, but need to be flushed
// when they might be keeping a Context alive, or when the heap is about
// to be serialized.
-
if (FLAG_cleanup_code_caches_at_gc && target->is_inline_cache_stub()
&& (target->ic_state() == MEGAMORPHIC || target->ic_state() == GENERIC ||
target->ic_state() == POLYMORPHIC || heap->flush_monomorphic_ics() ||
template<typename StaticVisitor>
+void StaticMarkingVisitor<StaticVisitor>::VisitWeakCollection(
+ Map* map, HeapObject* object) {
+ Heap* heap = map->GetHeap();
+ JSWeakCollection* weak_collection =
+ reinterpret_cast<JSWeakCollection*>(object);
+ MarkCompactCollector* collector = heap->mark_compact_collector();
+
+ // Enqueue weak map in linked list of encountered weak maps.
+ if (weak_collection->next() == heap->undefined_value()) {
+ weak_collection->set_next(collector->encountered_weak_collections());
+ collector->set_encountered_weak_collections(weak_collection);
+ }
+
+ // Skip visiting the backing hash table containing the mappings and the
+ // pointer to the other enqueued weak collections, both are post-processed.
+ StaticVisitor::VisitPointers(heap,
+ HeapObject::RawField(object, JSWeakCollection::kPropertiesOffset),
+ HeapObject::RawField(object, JSWeakCollection::kTableOffset));
+ STATIC_ASSERT(JSWeakCollection::kTableOffset + kPointerSize ==
+ JSWeakCollection::kNextOffset);
+ STATIC_ASSERT(JSWeakCollection::kNextOffset + kPointerSize ==
+ JSWeakCollection::kSize);
+
+ if (!weak_collection->table()->IsHashTable()) return;
+
+ // Mark the backing hash table without pushing it on the marking stack.
+ Object** slot = HeapObject::RawField(object, JSWeakCollection::kTableOffset);
+ HeapObject* obj = HeapObject::cast(*slot);
+ heap->mark_compact_collector()->RecordSlot(slot, slot, obj);
+ StaticVisitor::MarkObjectWithoutPush(heap, obj);
+}
+
+
+template<typename StaticVisitor>
void StaticMarkingVisitor<StaticVisitor>::VisitCode(
Map* map, HeapObject* object) {
Heap* heap = map->GetHeap();
JSMap::kSize);
case JS_WEAK_MAP_TYPE:
- return kVisitJSWeakMap;
-
case JS_WEAK_SET_TYPE:
- return kVisitJSWeakSet;
+ return kVisitJSWeakCollection;
case JS_REGEXP_TYPE:
return kVisitJSRegExp;
V(PropertyCell) \
V(SharedFunctionInfo) \
V(JSFunction) \
- V(JSWeakMap) \
- V(JSWeakSet) \
+ V(JSWeakCollection) \
V(JSArrayBuffer) \
V(JSTypedArray) \
V(JSDataView) \
}
INLINE(static void VisitPropertyCell(Map* map, HeapObject* object));
- INLINE(static void VisitAllocationSite(Map* map, HeapObject* object));
INLINE(static void VisitCodeEntry(Heap* heap, Address entry_address));
INLINE(static void VisitEmbeddedPointer(Heap* heap, RelocInfo* rinfo));
INLINE(static void VisitCell(Heap* heap, RelocInfo* rinfo));
INLINE(static void VisitCode(Map* map, HeapObject* object));
INLINE(static void VisitSharedFunctionInfo(Map* map, HeapObject* object));
INLINE(static void VisitConstantPoolArray(Map* map, HeapObject* object));
+ INLINE(static void VisitAllocationSite(Map* map, HeapObject* object));
+ INLINE(static void VisitWeakCollection(Map* map, HeapObject* object));
INLINE(static void VisitJSFunction(Map* map, HeapObject* object));
INLINE(static void VisitJSRegExp(Map* map, HeapObject* object));
INLINE(static void VisitJSArrayBuffer(Map* map, HeapObject* object));
ASSERT(weak_collection->map()->inobject_properties() == 0);
Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 0);
weak_collection->set_table(*table);
- weak_collection->set_next(Smi::FromInt(0));
return weak_collection;
}
Handle<Map> map = factory->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize);
Handle<JSObject> weakmap_obj = factory->NewJSObjectFromMap(map);
Handle<JSWeakMap> weakmap(JSWeakMap::cast(*weakmap_obj));
- // Do not use handles for the hash table, it would make entries strong.
- Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 1);
- weakmap->set_table(*table);
- weakmap->set_next(Smi::FromInt(0));
+ // Do not leak handles for the hash table, it would make entries strong.
+ {
+ HandleScope scope(isolate);
+ Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 1);
+ weakmap->set_table(*table);
+ }
return weakmap;
}
Handle<Map> map = factory->NewMap(JS_WEAK_SET_TYPE, JSWeakSet::kSize);
Handle<JSObject> weakset_obj = factory->NewJSObjectFromMap(map);
Handle<JSWeakSet> weakset(JSWeakSet::cast(*weakset_obj));
- // Do not use handles for the hash table, it would make entries strong.
- Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 1);
- weakset->set_table(*table);
- weakset->set_next(Smi::FromInt(0));
+ // Do not leak handles for the hash table, it would make entries strong.
+ {
+ HandleScope scope(isolate);
+ Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 1);
+ weakset->set_table(*table);
+ }
return weakset;
}