Index: src/heap/objects-visiting.cc |
diff --git a/src/heap/objects-visiting.cc b/src/heap/objects-visiting.cc |
index 20d92de2f9724270d51d2e4bd3c44277d8d44df3..7b2e2d9a388939440e0aac0bb5c3263fedc4676f 100644 |
--- a/src/heap/objects-visiting.cc |
+++ b/src/heap/objects-visiting.cc |
@@ -303,8 +303,13 @@ struct WeakListVisitor<Context> { |
// Process the three weak lists linked off the context. |
DoWeakList<JSFunction>(heap, context, retainer, |
Context::OPTIMIZED_FUNCTIONS_LIST); |
- DoWeakList<Code>(heap, context, retainer, Context::OPTIMIZED_CODE_LIST); |
- DoWeakList<Code>(heap, context, retainer, Context::DEOPTIMIZED_CODE_LIST); |
+ |
+ // Code objects are always allocated in Code space, we do not have to visit |
+ // them during scavenges. |
+ if (heap->gc_state() == Heap::MARK_COMPACT) { |
+ DoWeakList<Code>(heap, context, retainer, Context::OPTIMIZED_CODE_LIST); |
+ DoWeakList<Code>(heap, context, retainer, Context::DEOPTIMIZED_CODE_LIST); |
+ } |
} |
template <class T> |