Reviewers: ulan,
Message:
Hi Ulan, PTAL, thx.
--Michael
Description:
Bugfix: dependent code field in AllocationSite was keeping code
objects alive even after context death.
BUG=
Please review this at https://codereview.chromium.org/62803008/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+46, -8 lines):
M src/heap.cc
M src/mark-compact.h
M src/objects-visiting-inl.h
M src/objects-visiting.h
M src/objects.h
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
dfb24783d016d6d2c5cde5106e93df6ce399cf5d..bf682f94f73ab208b420f9da70efaf27e5ef9a05
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -1784,7 +1784,9 @@ void Heap::ProcessWeakReferences(WeakObjectRetainer*
retainer) {
mark_compact_collector()->is_compacting();
ProcessArrayBuffers(retainer, record_slots);
ProcessNativeContexts(retainer, record_slots);
- ProcessAllocationSites(retainer, record_slots);
+ if (gc_state() == MARK_COMPACT) {
+ ProcessAllocationSites(retainer, record_slots);
+ }
}
void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer,
@@ -1889,9 +1891,13 @@ struct WeakListVisitor<AllocationSite> {
}
static void VisitLiveObject(Heap* heap,
- AllocationSite* array_buffer,
+ AllocationSite* site,
WeakObjectRetainer* retainer,
- bool record_slots) {}
+ bool record_slots) {
+ // We are only called during old space collection.
+ heap->mark_compact_collector()->ClearNonLiveDependentCode(
+ site->dependent_code());
+ }
static void VisitPhantomObject(Heap* heap, AllocationSite* phantom) {}
@@ -1903,6 +1909,7 @@ struct WeakListVisitor<AllocationSite> {
void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer,
bool record_slots) {
+ ASSERT(gc_state() == MARK_COMPACT);
Object* allocation_site_obj =
VisitWeakList<AllocationSite>(this,
allocation_sites_list(),
Index: src/mark-compact.h
diff --git a/src/mark-compact.h b/src/mark-compact.h
index
aea5e1cf66249267d9afa35a868a193e930fa50e..72d18d1522a23c837fcca45b74c55ecfbb540a89
100644
--- a/src/mark-compact.h
+++ b/src/mark-compact.h
@@ -739,6 +739,10 @@ class MarkCompactCollector {
// marking its contents.
void MarkWeakObjectToCodeTable();
+ // Objects with 1) weak lists and 2) dependent code fields need to clear
+ // dependent code when the weak list is traversed.
+ void ClearNonLiveDependentCode(DependentCode* dependent_code);
+
private:
MarkCompactCollector();
~MarkCompactCollector();
@@ -889,7 +893,6 @@ class MarkCompactCollector {
void ClearNonLiveMapTransitions(Map* map, MarkBit map_mark);
void ClearAndDeoptimizeDependentCode(DependentCode* dependent_code);
- void ClearNonLiveDependentCode(DependentCode* dependent_code);
// Marking detaches initial maps from SharedFunctionInfo objects
// to make this reference weak. We need to reattach initial maps
Index: src/objects-visiting-inl.h
diff --git a/src/objects-visiting-inl.h b/src/objects-visiting-inl.h
index
93b7cb96adb019c03a33a931edd174fee4817597..3a21ace3193b93a61f60486a8a456b096c55483b
100644
--- a/src/objects-visiting-inl.h
+++ b/src/objects-visiting-inl.h
@@ -189,10 +189,7 @@ void StaticMarkingVisitor<StaticVisitor>::Initialize()
{
table_.Register(kVisitNativeContext, &VisitNativeContext);
- table_.Register(kVisitAllocationSite,
- &FixedBodyVisitor<StaticVisitor,
- AllocationSite::BodyDescriptor,
- void>::Visit);
+ table_.Register(kVisitAllocationSite, &VisitAllocationSite);
table_.Register(kVisitByteArray, &DataObjectVisitor::Visit);
@@ -389,6 +386,30 @@ void
StaticMarkingVisitor<StaticVisitor>::VisitPropertyCell(
template<typename StaticVisitor>
+void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite(
+ Map* map, HeapObject* object) {
+ Heap* heap = map->GetHeap();
+
+ Object** slot =
+ HeapObject::RawField(object, AllocationSite::kDependentCodeOffset);
+ if (FLAG_collect_maps) {
+ // Mark property cell dependent codes array but do not push it onto
marking
+ // stack, this will make references from it weak. We will clean dead
+ // codes when we iterate over property cells in ClearNonLiveReferences.
+ HeapObject* obj = HeapObject::cast(*slot);
+ heap->mark_compact_collector()->RecordSlot(slot, slot, obj);
+ StaticVisitor::MarkObjectWithoutPush(heap, obj);
+ } else {
+ StaticVisitor::VisitPointer(heap, slot);
+ }
+
+ StaticVisitor::VisitPointers(heap,
+ HeapObject::RawField(object,
AllocationSite::kPointerFieldsBeginOffset),
+ HeapObject::RawField(object,
AllocationSite::kPointerFieldsEndOffset));
+}
+
+
+template<typename StaticVisitor>
void StaticMarkingVisitor<StaticVisitor>::VisitCode(
Map* map, HeapObject* object) {
Heap* heap = map->GetHeap();
Index: src/objects-visiting.h
diff --git a/src/objects-visiting.h b/src/objects-visiting.h
index
60e6f67471e67d1f12b04162723ce178bfecf05d..f7758fdf4fcfed374698e35c8f68515e03c35cbb
100644
--- a/src/objects-visiting.h
+++ b/src/objects-visiting.h
@@ -399,6 +399,7 @@ class StaticMarkingVisitor : public StaticVisitorBase {
}
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));
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
25c2210d5fa7ab96d2e9b0bf474f6c01765b4408..249b15fcc243337a3ac858ce793e32a9d83dcbfb
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -8192,6 +8192,12 @@ class AllocationSite: public Struct {
static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize;
static const int kSize = kWeakNextOffset + kPointerSize;
+ // During mark compact we need to take special care for the dependent
code
+ // field.
+ static const int kPointerFieldsBeginOffset = kTransitionInfoOffset;
+ static const int kPointerFieldsEndOffset = kDependentCodeOffset;
+
+ // For other visitors, use the fixed body descriptor below.
typedef FixedBodyDescriptor<HeapObject::kHeaderSize,
kDependentCodeOffset + kPointerSize,
kSize> BodyDescriptor;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.