Index: src/mark-compact.cc |
diff --git a/src/mark-compact.cc b/src/mark-compact.cc |
index bfb4031f3e42831d0c381efa05f542f2117c56e9..f8261c28ff2c4c1bb5e000de1609bf3aa9810731 100644 |
--- a/src/mark-compact.cc |
+++ b/src/mark-compact.cc |
@@ -85,7 +85,7 @@ class VerifyMarkingVisitor: public ObjectVisitor { |
void VisitEmbeddedPointer(RelocInfo* rinfo) { |
ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); |
- if (!FLAG_weak_embedded_maps_in_optimized_code || |
+ if (!FLAG_weak_embedded_maps_in_optimized_code || !FLAG_collect_maps || |
rinfo->host()->kind() != Code::OPTIMIZED_FUNCTION || |
!rinfo->target_object()->IsMap() || |
!Map::cast(rinfo->target_object())->CanTransition()) { |
@@ -412,6 +412,13 @@ void MarkCompactCollector::CollectGarbage() { |
} |
#endif |
+#ifdef VERIFY_HEAP |
+ if (FLAG_collect_maps && FLAG_weak_embedded_maps_in_optimized_code && |
+ heap()->weak_embedded_maps_verification_enabled()) { |
+ VerifyWeakEmbeddedMapsInOptimizedCode(); |
+ } |
+#endif |
+ |
Finish(); |
if (marking_parity_ == EVEN_MARKING_PARITY) { |
@@ -463,6 +470,19 @@ void MarkCompactCollector::VerifyMarkbitsAreClean() { |
CHECK_EQ(0, Page::FromAddress(obj->address())->LiveBytes()); |
} |
} |
+ |
+ |
+void MarkCompactCollector::VerifyWeakEmbeddedMapsInOptimizedCode() { |
+ HeapObjectIterator code_iterator(heap()->code_space()); |
+ for (HeapObject* obj = code_iterator.Next(); |
+ obj != NULL; |
+ obj = code_iterator.Next()) { |
+ Code* code = Code::cast(obj); |
+ if (code->kind() != Code::OPTIMIZED_FUNCTION) continue; |
+ if (code->marked_for_deoptimization()) continue; |
+ code->VerifyEmbeddedMapsDependency(); |
+ } |
+} |
#endif // VERIFY_HEAP |
@@ -833,6 +853,7 @@ void MarkCompactCollector::Prepare(GCTracer* tracer) { |
#endif |
} |
+ |
class DeoptimizeMarkedCodeFilter : public OptimizedFunctionFilter { |
public: |
virtual bool TakeFunction(JSFunction* function) { |
@@ -2310,10 +2331,10 @@ void MarkCompactCollector::ClearNonLiveDependentCodes(Map* map) { |
if (IsMarked(code) && !code->marked_for_deoptimization()) { |
if (new_number_of_codes != i) { |
codes->set_code_at(new_number_of_codes, code); |
- Object** slot = codes->code_slot_at(new_number_of_codes); |
- RecordSlot(slot, slot, code); |
- new_number_of_codes++; |
} |
+ Object** slot = codes->code_slot_at(new_number_of_codes); |
+ RecordSlot(slot, slot, code); |
+ new_number_of_codes++; |
} |
} |
for (int i = new_number_of_codes; i < number_of_codes; i++) { |