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

Side by Side Diff: src/heap.cc

Issue 8716009: Distinguish weak references in heap snapshots, group GC roots. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 5045 matching lines...) Expand 10 before | Expand all | Expand 10 after
5056 5056
5057 5057
5058 void Heap::IterateRoots(ObjectVisitor* v, VisitMode mode) { 5058 void Heap::IterateRoots(ObjectVisitor* v, VisitMode mode) {
5059 IterateStrongRoots(v, mode); 5059 IterateStrongRoots(v, mode);
5060 IterateWeakRoots(v, mode); 5060 IterateWeakRoots(v, mode);
5061 } 5061 }
5062 5062
5063 5063
5064 void Heap::IterateWeakRoots(ObjectVisitor* v, VisitMode mode) { 5064 void Heap::IterateWeakRoots(ObjectVisitor* v, VisitMode mode) {
5065 v->VisitPointer(reinterpret_cast<Object**>(&roots_[kSymbolTableRootIndex])); 5065 v->VisitPointer(reinterpret_cast<Object**>(&roots_[kSymbolTableRootIndex]));
5066 v->Synchronize("symbol_table"); 5066 v->Synchronize(VisitorSynchronization::kSymbolTable);
5067 if (mode != VISIT_ALL_IN_SCAVENGE && 5067 if (mode != VISIT_ALL_IN_SCAVENGE &&
5068 mode != VISIT_ALL_IN_SWEEP_NEWSPACE) { 5068 mode != VISIT_ALL_IN_SWEEP_NEWSPACE) {
5069 // Scavenge collections have special processing for this. 5069 // Scavenge collections have special processing for this.
5070 external_string_table_.Iterate(v); 5070 external_string_table_.Iterate(v);
5071 } 5071 }
5072 v->Synchronize("external_string_table"); 5072 v->Synchronize(VisitorSynchronization::kExternalStringsTable);
5073 } 5073 }
5074 5074
5075 5075
5076 void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) { 5076 void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) {
5077 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); 5077 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]);
5078 v->Synchronize("strong_root_list"); 5078 v->Synchronize(VisitorSynchronization::kStrongRootList);
5079 5079
5080 v->VisitPointer(BitCast<Object**>(&hidden_symbol_)); 5080 v->VisitPointer(BitCast<Object**>(&hidden_symbol_));
5081 v->Synchronize("symbol"); 5081 v->Synchronize(VisitorSynchronization::kSymbol);
5082 5082
5083 isolate_->bootstrapper()->Iterate(v); 5083 isolate_->bootstrapper()->Iterate(v);
5084 v->Synchronize("bootstrapper"); 5084 v->Synchronize(VisitorSynchronization::kBootstrapper);
5085 isolate_->Iterate(v); 5085 isolate_->Iterate(v);
5086 v->Synchronize("top"); 5086 v->Synchronize(VisitorSynchronization::kTop);
5087 Relocatable::Iterate(v); 5087 Relocatable::Iterate(v);
5088 v->Synchronize("relocatable"); 5088 v->Synchronize(VisitorSynchronization::kRelocatable);
5089 5089
5090 #ifdef ENABLE_DEBUGGER_SUPPORT 5090 #ifdef ENABLE_DEBUGGER_SUPPORT
5091 isolate_->debug()->Iterate(v); 5091 isolate_->debug()->Iterate(v);
5092 if (isolate_->deoptimizer_data() != NULL) { 5092 if (isolate_->deoptimizer_data() != NULL) {
5093 isolate_->deoptimizer_data()->Iterate(v); 5093 isolate_->deoptimizer_data()->Iterate(v);
5094 } 5094 }
5095 #endif 5095 #endif
5096 v->Synchronize("debug"); 5096 v->Synchronize(VisitorSynchronization::kDebug);
5097 isolate_->compilation_cache()->Iterate(v); 5097 isolate_->compilation_cache()->Iterate(v);
5098 v->Synchronize("compilationcache"); 5098 v->Synchronize(VisitorSynchronization::kCompilationCache);
5099 5099
5100 // Iterate over local handles in handle scopes. 5100 // Iterate over local handles in handle scopes.
5101 isolate_->handle_scope_implementer()->Iterate(v); 5101 isolate_->handle_scope_implementer()->Iterate(v);
5102 v->Synchronize("handlescope"); 5102 v->Synchronize(VisitorSynchronization::kHandleScope);
5103 5103
5104 // Iterate over the builtin code objects and code stubs in the 5104 // Iterate over the builtin code objects and code stubs in the
5105 // heap. Note that it is not necessary to iterate over code objects 5105 // heap. Note that it is not necessary to iterate over code objects
5106 // on scavenge collections. 5106 // on scavenge collections.
5107 if (mode != VISIT_ALL_IN_SCAVENGE) { 5107 if (mode != VISIT_ALL_IN_SCAVENGE) {
5108 isolate_->builtins()->IterateBuiltins(v); 5108 isolate_->builtins()->IterateBuiltins(v);
5109 } 5109 }
5110 v->Synchronize("builtins"); 5110 v->Synchronize(VisitorSynchronization::kBuiltins);
5111 5111
5112 // Iterate over global handles. 5112 // Iterate over global handles.
5113 switch (mode) { 5113 switch (mode) {
5114 case VISIT_ONLY_STRONG: 5114 case VISIT_ONLY_STRONG:
5115 isolate_->global_handles()->IterateStrongRoots(v); 5115 isolate_->global_handles()->IterateStrongRoots(v);
5116 break; 5116 break;
5117 case VISIT_ALL_IN_SCAVENGE: 5117 case VISIT_ALL_IN_SCAVENGE:
5118 isolate_->global_handles()->IterateNewSpaceStrongAndDependentRoots(v); 5118 isolate_->global_handles()->IterateNewSpaceStrongAndDependentRoots(v);
5119 break; 5119 break;
5120 case VISIT_ALL_IN_SWEEP_NEWSPACE: 5120 case VISIT_ALL_IN_SWEEP_NEWSPACE:
5121 case VISIT_ALL: 5121 case VISIT_ALL:
5122 isolate_->global_handles()->IterateAllRoots(v); 5122 isolate_->global_handles()->IterateAllRoots(v);
5123 break; 5123 break;
5124 } 5124 }
5125 v->Synchronize("globalhandles"); 5125 v->Synchronize(VisitorSynchronization::kGlobalHandles);
5126 5126
5127 // Iterate over pointers being held by inactive threads. 5127 // Iterate over pointers being held by inactive threads.
5128 isolate_->thread_manager()->Iterate(v); 5128 isolate_->thread_manager()->Iterate(v);
5129 v->Synchronize("threadmanager"); 5129 v->Synchronize(VisitorSynchronization::kThreadManager);
5130 5130
5131 // Iterate over the pointers the Serialization/Deserialization code is 5131 // Iterate over the pointers the Serialization/Deserialization code is
5132 // holding. 5132 // holding.
5133 // During garbage collection this keeps the partial snapshot cache alive. 5133 // During garbage collection this keeps the partial snapshot cache alive.
5134 // During deserialization of the startup snapshot this creates the partial 5134 // During deserialization of the startup snapshot this creates the partial
5135 // snapshot cache and deserializes the objects it refers to. During 5135 // snapshot cache and deserializes the objects it refers to. During
5136 // serialization this does nothing, since the partial snapshot cache is 5136 // serialization this does nothing, since the partial snapshot cache is
5137 // empty. However the next thing we do is create the partial snapshot, 5137 // empty. However the next thing we do is create the partial snapshot,
5138 // filling up the partial snapshot cache with objects it needs as we go. 5138 // filling up the partial snapshot cache with objects it needs as we go.
5139 SerializerDeserializer::Iterate(v); 5139 SerializerDeserializer::Iterate(v);
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
6483 isolate_->heap()->store_buffer()->Compact(); 6483 isolate_->heap()->store_buffer()->Compact();
6484 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6484 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6485 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6485 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6486 next = chunk->next_chunk(); 6486 next = chunk->next_chunk();
6487 isolate_->memory_allocator()->Free(chunk); 6487 isolate_->memory_allocator()->Free(chunk);
6488 } 6488 }
6489 chunks_queued_for_free_ = NULL; 6489 chunks_queued_for_free_ = NULL;
6490 } 6490 }
6491 6491
6492 } } // namespace v8::internal 6492 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698