Index: src/compiler.cc |
diff --git a/src/compiler.cc b/src/compiler.cc |
index 2a0eda0a551229eface54be75d02400b6c0be6ff..997103f18f83c40c314f4cc8fc0abdd7873c8662 100644 |
--- a/src/compiler.cc |
+++ b/src/compiler.cc |
@@ -284,9 +284,14 @@ void AddWeakObjectToCodeDependency(Isolate* isolate, Handle<HeapObject> object, |
Handle<Code> code) { |
Handle<WeakCell> cell = Code::WeakCellFor(code); |
Heap* heap = isolate->heap(); |
- Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(object)); |
- dep = DependentCode::InsertWeakCode(dep, DependentCode::kWeakCodeGroup, cell); |
- heap->AddWeakObjectToCodeDependency(object, dep); |
+ if (heap->InNewSpace(*object)) { |
+ heap->AddWeakNewSpaceObjectToCodeDependency(object, cell); |
+ } else { |
+ Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(object)); |
+ dep = |
+ DependentCode::InsertWeakCode(dep, DependentCode::kWeakCodeGroup, cell); |
+ heap->AddWeakObjectToCodeDependency(object, dep); |
+ } |
} |
} // namespace |