Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index 11bf9cd4d4a92909bc0d7b9cbc4260cf8622aaeb..468a01d6949bc2cdf20928dcb4eb33da3af36400 100644 |
--- a/src/heap.cc |
+++ b/src/heap.cc |
@@ -1576,13 +1576,40 @@ void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { |
void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { |
AssertNoAllocation no_allocation; |
- class VisitorAdapter : public ObjectVisitor { |
+ // Both the external string table and the symbol table may contain |
+ // external strings, but neither lists them exhaustively, nor is the |
+ // intersection set empty. Therefore we iterate over the external string |
+ // table first, ignoring symbols, and then over the symbol table. |
+ |
+ class ExternalStringTableVisitorAdapter : public ObjectVisitor { |
+ public: |
+ explicit ExternalStringTableVisitorAdapter( |
+ v8::ExternalResourceVisitor* visitor) : visitor_(visitor) {} |
+ virtual void VisitPointers(Object** start, Object** end) { |
+ for (Object** p = start; p < end; p++) { |
+ // Visit non-symbol external strings, |
+ // since symbols are listed in the symbol table. |
+ if (!(*p)->IsSymbol()) { |
+ ASSERT((*p)->IsExternalString()); |
+ visitor_->VisitExternalString(Utils::ToLocal( |
+ Handle<String>(String::cast(*p)))); |
+ } |
+ } |
+ } |
+ private: |
+ v8::ExternalResourceVisitor* visitor_; |
+ } external_string_table_visitor(visitor); |
+ |
+ external_string_table_.Iterate(&external_string_table_visitor); |
+ |
+ class SymbolTableVisitorAdapter : public ObjectVisitor { |
public: |
- explicit VisitorAdapter(v8::ExternalResourceVisitor* visitor) |
- : visitor_(visitor) {} |
+ explicit SymbolTableVisitorAdapter( |
+ v8::ExternalResourceVisitor* visitor) : visitor_(visitor) {} |
virtual void VisitPointers(Object** start, Object** end) { |
for (Object** p = start; p < end; p++) { |
if ((*p)->IsExternalString()) { |
+ ASSERT((*p)->IsSymbol()); |
visitor_->VisitExternalString(Utils::ToLocal( |
Handle<String>(String::cast(*p)))); |
} |
@@ -1590,8 +1617,9 @@ void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { |
} |
private: |
v8::ExternalResourceVisitor* visitor_; |
- } visitor_adapter(visitor); |
- external_string_table_.Iterate(&visitor_adapter); |
+ } symbol_table_visitor(visitor); |
+ |
+ symbol_table()->IterateElements(&symbol_table_visitor); |
} |