Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(712)

Side by Side Diff: src/heap.cc

Issue 355041: Made iteration of global handles more efficient on scavenges. (Closed)
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 // 726 //
727 // There is guaranteed to be enough room at the top of the to space 727 // There is guaranteed to be enough room at the top of the to space
728 // for the addresses of promoted objects: every object promoted 728 // for the addresses of promoted objects: every object promoted
729 // frees up its size in bytes from the top of the new space, and 729 // frees up its size in bytes from the top of the new space, and
730 // objects are at least one pointer in size. 730 // objects are at least one pointer in size.
731 Address new_space_front = new_space_.ToSpaceLow(); 731 Address new_space_front = new_space_.ToSpaceLow();
732 promotion_queue.Initialize(new_space_.ToSpaceHigh()); 732 promotion_queue.Initialize(new_space_.ToSpaceHigh());
733 733
734 ScavengeVisitor scavenge_visitor; 734 ScavengeVisitor scavenge_visitor;
735 // Copy roots. 735 // Copy roots.
736 IterateRoots(&scavenge_visitor); 736 IterateRoots(&scavenge_visitor, VISIT_ALL);
737
738 // Copy objects reachable from weak pointers.
739 GlobalHandles::IterateWeakRoots(&scavenge_visitor);
740 737
741 // Copy objects reachable from the old generation. By definition, 738 // Copy objects reachable from the old generation. By definition,
742 // there are no intergenerational pointers in code or data spaces. 739 // there are no intergenerational pointers in code or data spaces.
743 IterateRSet(old_pointer_space_, &ScavengePointer); 740 IterateRSet(old_pointer_space_, &ScavengePointer);
744 IterateRSet(map_space_, &ScavengePointer); 741 IterateRSet(map_space_, &ScavengePointer);
745 lo_space_->IterateRSet(&ScavengePointer); 742 lo_space_->IterateRSet(&ScavengePointer);
746 743
747 // Copy objects reachable from cells by scavenging cell values directly. 744 // Copy objects reachable from cells by scavenging cell values directly.
748 HeapObjectIterator cell_iterator(cell_space_); 745 HeapObjectIterator cell_iterator(cell_space_);
749 while (cell_iterator.has_next()) { 746 while (cell_iterator.has_next()) {
(...skipping 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after
3110 3107
3111 return false; 3108 return false;
3112 } 3109 }
3113 3110
3114 3111
3115 #ifdef DEBUG 3112 #ifdef DEBUG
3116 void Heap::Verify() { 3113 void Heap::Verify() {
3117 ASSERT(HasBeenSetup()); 3114 ASSERT(HasBeenSetup());
3118 3115
3119 VerifyPointersVisitor visitor; 3116 VerifyPointersVisitor visitor;
3120 IterateRoots(&visitor); 3117 IterateRoots(&visitor, VISIT_ONLY_STRONG);
3121 3118
3122 new_space_.Verify(); 3119 new_space_.Verify();
3123 3120
3124 VerifyPointersAndRSetVisitor rset_visitor; 3121 VerifyPointersAndRSetVisitor rset_visitor;
3125 old_pointer_space_->Verify(&rset_visitor); 3122 old_pointer_space_->Verify(&rset_visitor);
3126 map_space_->Verify(&rset_visitor); 3123 map_space_->Verify(&rset_visitor);
3127 3124
3128 VerifyPointersVisitor no_rset_visitor; 3125 VerifyPointersVisitor no_rset_visitor;
3129 old_data_space_->Verify(&no_rset_visitor); 3126 old_data_space_->Verify(&no_rset_visitor);
3130 code_space_->Verify(&no_rset_visitor); 3127 code_space_->Verify(&no_rset_visitor);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3237 Page* page = it.next(); 3234 Page* page = it.next();
3238 int count = IterateRSetRange(page->ObjectAreaStart(), page->AllocationTop(), 3235 int count = IterateRSetRange(page->ObjectAreaStart(), page->AllocationTop(),
3239 page->RSetStart(), copy_object_func); 3236 page->RSetStart(), copy_object_func);
3240 if (paged_rset_histogram != NULL) { 3237 if (paged_rset_histogram != NULL) {
3241 StatsTable::AddHistogramSample(paged_rset_histogram, count); 3238 StatsTable::AddHistogramSample(paged_rset_histogram, count);
3242 } 3239 }
3243 } 3240 }
3244 } 3241 }
3245 3242
3246 3243
3247 void Heap::IterateRoots(ObjectVisitor* v) { 3244 void Heap::IterateRoots(ObjectVisitor* v, VisitMode mode) {
3248 IterateStrongRoots(v); 3245 IterateStrongRoots(v, mode);
3249 v->VisitPointer(reinterpret_cast<Object**>(&roots_[kSymbolTableRootIndex])); 3246 v->VisitPointer(reinterpret_cast<Object**>(&roots_[kSymbolTableRootIndex]));
3250 v->Synchronize("symbol_table"); 3247 v->Synchronize("symbol_table");
3251 } 3248 }
3252 3249
3253 3250
3254 void Heap::IterateStrongRoots(ObjectVisitor* v) { 3251 void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) {
3255 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); 3252 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]);
3256 v->Synchronize("strong_root_list"); 3253 v->Synchronize("strong_root_list");
3257 3254
3258 v->VisitPointer(bit_cast<Object**, String**>(&hidden_symbol_)); 3255 v->VisitPointer(bit_cast<Object**, String**>(&hidden_symbol_));
3259 v->Synchronize("symbol"); 3256 v->Synchronize("symbol");
3260 3257
3261 Bootstrapper::Iterate(v); 3258 Bootstrapper::Iterate(v);
3262 v->Synchronize("bootstrapper"); 3259 v->Synchronize("bootstrapper");
3263 Top::Iterate(v); 3260 Top::Iterate(v);
3264 v->Synchronize("top"); 3261 v->Synchronize("top");
(...skipping 12 matching lines...) Expand all
3277 v->Synchronize("handlescope"); 3274 v->Synchronize("handlescope");
3278 3275
3279 // Iterate over the builtin code objects and code stubs in the heap. Note 3276 // Iterate over the builtin code objects and code stubs in the heap. Note
3280 // that it is not strictly necessary to iterate over code objects on 3277 // that it is not strictly necessary to iterate over code objects on
3281 // scavenge collections. We still do it here because this same function 3278 // scavenge collections. We still do it here because this same function
3282 // is used by the mark-sweep collector and the deserializer. 3279 // is used by the mark-sweep collector and the deserializer.
3283 Builtins::IterateBuiltins(v); 3280 Builtins::IterateBuiltins(v);
3284 v->Synchronize("builtins"); 3281 v->Synchronize("builtins");
3285 3282
3286 // Iterate over global handles. 3283 // Iterate over global handles.
3287 GlobalHandles::IterateRoots(v); 3284 if (mode == VISIT_ONLY_STRONG) {
3285 GlobalHandles::IterateStrongRoots(v);
3286 } else {
3287 GlobalHandles::IterateAllRoots(v);
3288 }
3288 v->Synchronize("globalhandles"); 3289 v->Synchronize("globalhandles");
3289 3290
3290 // Iterate over pointers being held by inactive threads. 3291 // Iterate over pointers being held by inactive threads.
3291 ThreadManager::Iterate(v); 3292 ThreadManager::Iterate(v);
3292 v->Synchronize("threadmanager"); 3293 v->Synchronize("threadmanager");
3293 } 3294 }
3294 3295
3295 3296
3296 // Flag is set when the heap has been configured. The heap can be repeatedly 3297 // Flag is set when the heap has been configured. The heap can be repeatedly
3297 // configured through the API until it is setup. 3298 // configured through the API until it is setup.
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
3882 }; 3883 };
3883 3884
3884 3885
3885 // Triggers a depth-first traversal of reachable objects from roots 3886 // Triggers a depth-first traversal of reachable objects from roots
3886 // and finds a path to a specific heap object and prints it. 3887 // and finds a path to a specific heap object and prints it.
3887 void Heap::TracePathToObject() { 3888 void Heap::TracePathToObject() {
3888 search_target = NULL; 3889 search_target = NULL;
3889 search_for_any_global = false; 3890 search_for_any_global = false;
3890 3891
3891 MarkRootVisitor root_visitor; 3892 MarkRootVisitor root_visitor;
3892 IterateRoots(&root_visitor); 3893 IterateRoots(&root_visitor, VISIT_ONLY_STRONG);
3893 } 3894 }
3894 3895
3895 3896
3896 // Triggers a depth-first traversal of reachable objects from roots 3897 // Triggers a depth-first traversal of reachable objects from roots
3897 // and finds a path to any global object and prints it. Useful for 3898 // and finds a path to any global object and prints it. Useful for
3898 // determining the source for leaks of global objects. 3899 // determining the source for leaks of global objects.
3899 void Heap::TracePathToGlobal() { 3900 void Heap::TracePathToGlobal() {
3900 search_target = NULL; 3901 search_target = NULL;
3901 search_for_any_global = true; 3902 search_for_any_global = true;
3902 3903
3903 MarkRootVisitor root_visitor; 3904 MarkRootVisitor root_visitor;
3904 IterateRoots(&root_visitor); 3905 IterateRoots(&root_visitor, VISIT_ONLY_STRONG);
3905 } 3906 }
3906 #endif 3907 #endif
3907 3908
3908 3909
3909 GCTracer::GCTracer() 3910 GCTracer::GCTracer()
3910 : start_time_(0.0), 3911 : start_time_(0.0),
3911 start_size_(0.0), 3912 start_size_(0.0),
3912 gc_count_(0), 3913 gc_count_(0),
3913 full_gc_count_(0), 3914 full_gc_count_(0),
3914 is_compacting_(false), 3915 is_compacting_(false),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
4030 for (int i = 0; i < kNumberOfCaches; i++) { 4031 for (int i = 0; i < kNumberOfCaches; i++) {
4031 if (caches_[i] != NULL) { 4032 if (caches_[i] != NULL) {
4032 delete caches_[i]; 4033 delete caches_[i];
4033 caches_[i] = NULL; 4034 caches_[i] = NULL;
4034 } 4035 }
4035 } 4036 }
4036 } 4037 }
4037 4038
4038 4039
4039 } } // namespace v8::internal 4040 } } // namespace v8::internal
OLDNEW
« src/global-handles.cc ('K') | « src/heap.h ('k') | src/heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698