| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/heap/heap.h" | 5 #include "src/heap/heap.h" | 
| 6 | 6 | 
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" | 
| 8 #include "src/api.h" | 8 #include "src/api.h" | 
| 9 #include "src/ast/context-slot-cache.h" | 9 #include "src/ast/context-slot-cache.h" | 
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" | 
| (...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1865         DCHECK((*p)->IsExternalString()); | 1865         DCHECK((*p)->IsExternalString()); | 
| 1866         visitor_->VisitExternalString( | 1866         visitor_->VisitExternalString( | 
| 1867             Utils::ToLocal(Handle<String>(String::cast(*p)))); | 1867             Utils::ToLocal(Handle<String>(String::cast(*p)))); | 
| 1868       } | 1868       } | 
| 1869     } | 1869     } | 
| 1870 | 1870 | 
| 1871    private: | 1871    private: | 
| 1872     v8::ExternalResourceVisitor* visitor_; | 1872     v8::ExternalResourceVisitor* visitor_; | 
| 1873   } external_string_table_visitor(visitor); | 1873   } external_string_table_visitor(visitor); | 
| 1874 | 1874 | 
| 1875   external_string_table_.Iterate(&external_string_table_visitor); | 1875   external_string_table_.IterateAll(&external_string_table_visitor); | 
| 1876 } | 1876 } | 
| 1877 | 1877 | 
| 1878 Address Heap::DoScavenge(ObjectVisitor* scavenge_visitor, | 1878 Address Heap::DoScavenge(ObjectVisitor* scavenge_visitor, | 
| 1879                          Address new_space_front) { | 1879                          Address new_space_front) { | 
| 1880   do { | 1880   do { | 
| 1881     SemiSpace::AssertValidRange(new_space_front, new_space_->top()); | 1881     SemiSpace::AssertValidRange(new_space_front, new_space_->top()); | 
| 1882     // The addresses new_space_front and new_space_.top() define a | 1882     // The addresses new_space_front and new_space_.top() define a | 
| 1883     // queue of unprocessed copied objects.  Process them until the | 1883     // queue of unprocessed copied objects.  Process them until the | 
| 1884     // queue is empty. | 1884     // queue is empty. | 
| 1885     while (new_space_front != new_space_->top()) { | 1885     while (new_space_front != new_space_->top()) { | 
| (...skipping 2938 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4824   IterateStrongRoots(v, mode); | 4824   IterateStrongRoots(v, mode); | 
| 4825   IterateWeakRoots(v, mode); | 4825   IterateWeakRoots(v, mode); | 
| 4826 } | 4826 } | 
| 4827 | 4827 | 
| 4828 | 4828 | 
| 4829 void Heap::IterateWeakRoots(ObjectVisitor* v, VisitMode mode) { | 4829 void Heap::IterateWeakRoots(ObjectVisitor* v, VisitMode mode) { | 
| 4830   v->VisitPointer(reinterpret_cast<Object**>(&roots_[kStringTableRootIndex])); | 4830   v->VisitPointer(reinterpret_cast<Object**>(&roots_[kStringTableRootIndex])); | 
| 4831   v->Synchronize(VisitorSynchronization::kStringTable); | 4831   v->Synchronize(VisitorSynchronization::kStringTable); | 
| 4832   if (mode != VISIT_ALL_IN_SCAVENGE && mode != VISIT_ALL_IN_SWEEP_NEWSPACE) { | 4832   if (mode != VISIT_ALL_IN_SCAVENGE && mode != VISIT_ALL_IN_SWEEP_NEWSPACE) { | 
| 4833     // Scavenge collections have special processing for this. | 4833     // Scavenge collections have special processing for this. | 
| 4834     external_string_table_.Iterate(v); | 4834     external_string_table_.IterateAll(v); | 
| 4835   } | 4835   } | 
| 4836   v->Synchronize(VisitorSynchronization::kExternalStringsTable); | 4836   v->Synchronize(VisitorSynchronization::kExternalStringsTable); | 
| 4837 } | 4837 } | 
| 4838 | 4838 | 
| 4839 | 4839 | 
| 4840 void Heap::IterateSmiRoots(ObjectVisitor* v) { | 4840 void Heap::IterateSmiRoots(ObjectVisitor* v) { | 
| 4841   // Acquire execution access since we are going to read stack limit values. | 4841   // Acquire execution access since we are going to read stack limit values. | 
| 4842   ExecutionAccess access(isolate()); | 4842   ExecutionAccess access(isolate()); | 
| 4843   v->VisitPointers(&roots_[kSmiRootsStart], &roots_[kRootListLength]); | 4843   v->VisitPointers(&roots_[kSmiRootsStart], &roots_[kRootListLength]); | 
| 4844   v->Synchronize(VisitorSynchronization::kSmiRootList); | 4844   v->Synchronize(VisitorSynchronization::kSmiRootList); | 
| (...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6315   IterateRoots(&tracer, VISIT_ONLY_STRONG); | 6315   IterateRoots(&tracer, VISIT_ONLY_STRONG); | 
| 6316 } | 6316 } | 
| 6317 #endif | 6317 #endif | 
| 6318 | 6318 | 
| 6319 void Heap::UpdateTotalGCTime(double duration) { | 6319 void Heap::UpdateTotalGCTime(double duration) { | 
| 6320   if (FLAG_trace_gc_verbose) { | 6320   if (FLAG_trace_gc_verbose) { | 
| 6321     total_gc_time_ms_ += duration; | 6321     total_gc_time_ms_ += duration; | 
| 6322   } | 6322   } | 
| 6323 } | 6323 } | 
| 6324 | 6324 | 
| 6325 void Heap::ExternalStringTable::CleanUp() { | 6325 void Heap::ExternalStringTable::CleanUpNewSpaceStrings() { | 
| 6326   int last = 0; | 6326   int last = 0; | 
| 6327   Isolate* isolate = heap_->isolate(); | 6327   Isolate* isolate = heap_->isolate(); | 
| 6328   for (int i = 0; i < new_space_strings_.length(); ++i) { | 6328   for (int i = 0; i < new_space_strings_.length(); ++i) { | 
| 6329     if (new_space_strings_[i]->IsTheHole(isolate)) { | 6329     if (new_space_strings_[i]->IsTheHole(isolate)) { | 
| 6330       continue; | 6330       continue; | 
| 6331     } | 6331     } | 
| 6332     DCHECK(new_space_strings_[i]->IsExternalString()); | 6332     DCHECK(new_space_strings_[i]->IsExternalString()); | 
| 6333     if (heap_->InNewSpace(new_space_strings_[i])) { | 6333     if (heap_->InNewSpace(new_space_strings_[i])) { | 
| 6334       new_space_strings_[last++] = new_space_strings_[i]; | 6334       new_space_strings_[last++] = new_space_strings_[i]; | 
| 6335     } else { | 6335     } else { | 
| 6336       old_space_strings_.Add(new_space_strings_[i]); | 6336       old_space_strings_.Add(new_space_strings_[i]); | 
| 6337     } | 6337     } | 
| 6338   } | 6338   } | 
| 6339   new_space_strings_.Rewind(last); | 6339   new_space_strings_.Rewind(last); | 
| 6340   new_space_strings_.Trim(); | 6340   new_space_strings_.Trim(); | 
|  | 6341 } | 
| 6341 | 6342 | 
| 6342   last = 0; | 6343 void Heap::ExternalStringTable::CleanUpAll() { | 
|  | 6344   CleanUpNewSpaceStrings(); | 
|  | 6345   int last = 0; | 
|  | 6346   Isolate* isolate = heap_->isolate(); | 
| 6343   for (int i = 0; i < old_space_strings_.length(); ++i) { | 6347   for (int i = 0; i < old_space_strings_.length(); ++i) { | 
| 6344     if (old_space_strings_[i]->IsTheHole(isolate)) { | 6348     if (old_space_strings_[i]->IsTheHole(isolate)) { | 
| 6345       continue; | 6349       continue; | 
| 6346     } | 6350     } | 
| 6347     DCHECK(old_space_strings_[i]->IsExternalString()); | 6351     DCHECK(old_space_strings_[i]->IsExternalString()); | 
| 6348     DCHECK(!heap_->InNewSpace(old_space_strings_[i])); | 6352     DCHECK(!heap_->InNewSpace(old_space_strings_[i])); | 
| 6349     old_space_strings_[last++] = old_space_strings_[i]; | 6353     old_space_strings_[last++] = old_space_strings_[i]; | 
| 6350   } | 6354   } | 
| 6351   old_space_strings_.Rewind(last); | 6355   old_space_strings_.Rewind(last); | 
| 6352   old_space_strings_.Trim(); | 6356   old_space_strings_.Trim(); | 
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6471 } | 6475 } | 
| 6472 | 6476 | 
| 6473 | 6477 | 
| 6474 // static | 6478 // static | 
| 6475 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6479 int Heap::GetStaticVisitorIdForMap(Map* map) { | 
| 6476   return StaticVisitorBase::GetVisitorId(map); | 6480   return StaticVisitorBase::GetVisitorId(map); | 
| 6477 } | 6481 } | 
| 6478 | 6482 | 
| 6479 }  // namespace internal | 6483 }  // namespace internal | 
| 6480 }  // namespace v8 | 6484 }  // namespace v8 | 
| OLD | NEW | 
|---|