Index: src/heap/heap.cc |
diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
index f830b4dd1bcfaf26a5a743a250f9bdef2ed3c522..55f76dff72b8e56d972ee6e8d1d96715334d706b 100644 |
--- a/src/heap/heap.cc |
+++ b/src/heap/heap.cc |
@@ -1471,38 +1471,6 @@ void Heap::MarkCompactPrologue() { |
} |
-#ifdef VERIFY_HEAP |
-// Visitor class to verify pointers in code or data space do not point into |
-// new space. |
-class VerifyNonPointerSpacePointersVisitor : public ObjectVisitor { |
- public: |
- explicit VerifyNonPointerSpacePointersVisitor(Heap* heap) : heap_(heap) {} |
- |
- void VisitPointers(Object** start, Object** end) override { |
- for (Object** current = start; current < end; current++) { |
- if ((*current)->IsHeapObject()) { |
- CHECK(!heap_->InNewSpace(HeapObject::cast(*current))); |
- } |
- } |
- } |
- |
- private: |
- Heap* heap_; |
-}; |
- |
- |
-static void VerifyNonPointerSpacePointers(Heap* heap) { |
- // Verify that there are no pointers to new space in spaces where we |
- // do not expect them. |
- VerifyNonPointerSpacePointersVisitor v(heap); |
- HeapObjectIterator code_it(heap->code_space()); |
- for (HeapObject* object = code_it.Next(); object != NULL; |
- object = code_it.Next()) |
- object->Iterate(&v); |
-} |
-#endif // VERIFY_HEAP |
- |
- |
void Heap::CheckNewSpaceExpansionCriteria() { |
if (FLAG_experimental_new_space_growth_heuristic) { |
if (new_space_.TotalCapacity() < new_space_.MaximumCapacity() && |
@@ -1613,10 +1581,6 @@ void Heap::Scavenge() { |
// Pause the inline allocation steps. |
PauseAllocationObserversScope pause_observers(this); |
-#ifdef VERIFY_HEAP |
- if (FLAG_verify_heap) VerifyNonPointerSpacePointers(this); |
-#endif |
- |
gc_state_ = SCAVENGE; |
// Implements Cheney's copying algorithm |
@@ -2859,6 +2823,10 @@ void Heap::CreateInitialObjects() { |
*WeakHashTable::New(isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY, |
TENURED)); |
+ set_weak_code_to_new_space_ref_list( |
+ ArrayList::cast(*(factory->NewFixedArray(16, TENURED)))); |
+ weak_code_to_new_space_ref_list()->SetLength(0); |
+ |
set_script_list(Smi::FromInt(0)); |
Handle<SeededNumberDictionary> slow_element_dictionary = |
@@ -2915,7 +2883,6 @@ void Heap::CreateInitialObjects() { |
CreateFixedStubs(); |
} |
- |
bool Heap::RootCanBeWrittenAfterInitialization(Heap::RootListIndex root_index) { |
switch (root_index) { |
case kNumberStringCacheRootIndex: |
@@ -2930,6 +2897,7 @@ bool Heap::RootCanBeWrittenAfterInitialization(Heap::RootListIndex root_index) { |
case kMicrotaskQueueRootIndex: |
case kDetachedContextsRootIndex: |
case kWeakObjectToCodeTableRootIndex: |
+ case kWeakCodeToNewSpaceRefListRootIndex: |
case kRetainedMapsRootIndex: |
case kNoScriptSharedFunctionInfosRootIndex: |
case kWeakStackTraceListRootIndex: |
@@ -5592,6 +5560,18 @@ void Heap::RemoveGCEpilogueCallback(v8::Isolate::GCCallback callback) { |
} |
// TODO(ishell): Find a better place for this. |
+void Heap::RecordWeakCodeToNewSpaceReference(Handle<HeapObject> obj, |
+ Handle<WeakCell> code) { |
+ DCHECK(InNewSpace(*obj)); |
+ DCHECK(!InNewSpace(*code)); |
+ Handle<ArrayList> list(weak_code_to_new_space_ref_list(), isolate()); |
+ list = ArrayList::Add(list, isolate()->factory()->NewWeakCell(obj), code); |
+ if (*list != weak_code_to_new_space_ref_list()) { |
+ set_weak_code_to_new_space_ref_list(*list); |
+ } |
+} |
+ |
+// TODO(ishell): Find a better place for this. |
void Heap::AddWeakObjectToCodeDependency(Handle<HeapObject> obj, |
Handle<DependentCode> dep) { |
DCHECK(!InNewSpace(*obj)); |