Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 1fe8fb4ff05f475f8b183979d5be5b2b07bca6d8..5bcf877f0bf1cde8c691146684c075e8420e915c 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -12123,9 +12123,14 @@ void SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap( |
if (isolate->serializer_enabled()) return; |
DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); |
// Empty code maps are unsupported. |
- if (shared->OptimizedCodeMapIsCleared()) return; |
- Handle<WeakCell> cell = isolate->factory()->NewWeakCell(code); |
- shared->optimized_code_map()->set(kSharedCodeIndex, *cell); |
+ if (!shared->OptimizedCodeMapIsCleared()) { |
+ Handle<WeakCell> cell = isolate->factory()->NewWeakCell(code); |
+ // A collection may have occured and cleared the optimized code map in the |
+ // allocation above. |
+ if (!shared->OptimizedCodeMapIsCleared()) { |
+ shared->optimized_code_map()->set(kSharedCodeIndex, *cell); |
+ } |
+ } |
} |