Chromium Code Reviews| Index: src/heap.cc | 
| diff --git a/src/heap.cc b/src/heap.cc | 
| index 11bf9cd4d4a92909bc0d7b9cbc4260cf8622aaeb..6339cd763248dfbe044b6ee01339fcbeb2e69afe 100644 | 
| --- a/src/heap.cc | 
| +++ b/src/heap.cc | 
| @@ -1576,13 +1576,39 @@ 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); | 
| 
 
erikcorry
2012/11/02 12:02:58
Please add a blank line here between the class def
 
 | 
| + 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 +1616,8 @@ void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { | 
| } | 
| private: | 
| v8::ExternalResourceVisitor* visitor_; | 
| - } visitor_adapter(visitor); | 
| - external_string_table_.Iterate(&visitor_adapter); | 
| + } symbol_table_visitor(visitor); | 
| 
 
erikcorry
2012/11/02 12:02:58
Blank line here please.
 
 | 
| + symbol_table()->IterateElements(&symbol_table_visitor); | 
| } |