Index: src/mark-compact.cc |
diff --git a/src/mark-compact.cc b/src/mark-compact.cc |
index 7da765dfa2968fbe64c3f1cee689d8bb66b91959..32baf24347654d46471949442963943244930845 100644 |
--- a/src/mark-compact.cc |
+++ b/src/mark-compact.cc |
@@ -1839,6 +1839,7 @@ class RootMarkingVisitor : public ObjectVisitor { |
// Helper class for pruning the string table. |
+template<bool finalize_external_strings> |
class StringTableCleaner : public ObjectVisitor { |
public: |
explicit StringTableCleaner(Heap* heap) |
@@ -1850,22 +1851,21 @@ class StringTableCleaner : public ObjectVisitor { |
Object* o = *p; |
if (o->IsHeapObject() && |
!Marking::MarkBitFrom(HeapObject::cast(o)).Get()) { |
- // Check if the internalized string being pruned is external. We need to |
- // delete the associated external data as this string is going away. |
- |
- // Since no objects have yet been moved we can safely access the map of |
- // the object. |
- if (o->IsExternalString()) { |
- heap_->FinalizeExternalString(String::cast(*p)); |
+ if (finalize_external_strings) { |
+ if (o->IsExternalString()) { |
+ heap_->FinalizeExternalString(String::cast(*p)); |
+ } |
+ } else { |
+ pointers_removed_++; |
} |
// Set the entry to the_hole_value (as deleted). |
*p = heap_->the_hole_value(); |
- pointers_removed_++; |
} |
} |
} |
int PointersRemoved() { |
+ ASSERT(!finalize_external_strings); |
return pointers_removed_; |
} |
@@ -1875,6 +1875,10 @@ class StringTableCleaner : public ObjectVisitor { |
}; |
+typedef StringTableCleaner<false> InternalizedStringTableCleaner; |
+typedef StringTableCleaner<true> ExternalStringTableCleaner; |
+ |
+ |
// Implementation of WeakObjectRetainer for mark compact GCs. All marked objects |
// are retained. |
class MarkCompactWeakObjectRetainer : public WeakObjectRetainer { |
@@ -2398,10 +2402,12 @@ void MarkCompactCollector::AfterMarking() { |
// string table. Cannot use string_table() here because the string |
// table is marked. |
StringTable* string_table = heap()->string_table(); |
- StringTableCleaner v(heap()); |
- string_table->IterateElements(&v); |
- string_table->ElementsRemoved(v.PointersRemoved()); |
- heap()->external_string_table_.Iterate(&v); |
+ InternalizedStringTableCleaner internalized_visitor(heap()); |
+ string_table->IterateElements(&internalized_visitor); |
+ string_table->ElementsRemoved(internalized_visitor.PointersRemoved()); |
+ |
+ ExternalStringTableCleaner external_visitor(heap()); |
+ heap()->external_string_table_.Iterate(&external_visitor); |
heap()->external_string_table_.CleanUp(); |
// Process the weak references. |