OLD | NEW |
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // generation can be aligned to its size. | 106 // generation can be aligned to its size. |
107 int Heap::survived_since_last_expansion_ = 0; | 107 int Heap::survived_since_last_expansion_ = 0; |
108 int Heap::external_allocation_limit_ = 0; | 108 int Heap::external_allocation_limit_ = 0; |
109 | 109 |
110 Heap::HeapState Heap::gc_state_ = NOT_IN_GC; | 110 Heap::HeapState Heap::gc_state_ = NOT_IN_GC; |
111 | 111 |
112 int Heap::mc_count_ = 0; | 112 int Heap::mc_count_ = 0; |
113 int Heap::gc_count_ = 0; | 113 int Heap::gc_count_ = 0; |
114 | 114 |
115 int Heap::always_allocate_scope_depth_ = 0; | 115 int Heap::always_allocate_scope_depth_ = 0; |
| 116 int Heap::linear_allocation_scope_depth_ = 0; |
116 bool Heap::context_disposed_pending_ = false; | 117 bool Heap::context_disposed_pending_ = false; |
117 | 118 |
118 #ifdef DEBUG | 119 #ifdef DEBUG |
119 bool Heap::allocation_allowed_ = true; | 120 bool Heap::allocation_allowed_ = true; |
120 | 121 |
121 int Heap::allocation_timeout_ = 0; | 122 int Heap::allocation_timeout_ = 0; |
122 bool Heap::disallow_allocation_failure_ = false; | 123 bool Heap::disallow_allocation_failure_ = false; |
123 #endif // DEBUG | 124 #endif // DEBUG |
124 | 125 |
125 | 126 |
(...skipping 3109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3235 Page* page = it.next(); | 3236 Page* page = it.next(); |
3236 int count = IterateRSetRange(page->ObjectAreaStart(), page->AllocationTop(), | 3237 int count = IterateRSetRange(page->ObjectAreaStart(), page->AllocationTop(), |
3237 page->RSetStart(), copy_object_func); | 3238 page->RSetStart(), copy_object_func); |
3238 if (paged_rset_histogram != NULL) { | 3239 if (paged_rset_histogram != NULL) { |
3239 StatsTable::AddHistogramSample(paged_rset_histogram, count); | 3240 StatsTable::AddHistogramSample(paged_rset_histogram, count); |
3240 } | 3241 } |
3241 } | 3242 } |
3242 } | 3243 } |
3243 | 3244 |
3244 | 3245 |
3245 #ifdef DEBUG | |
3246 #define SYNCHRONIZE_TAG(tag) v->Synchronize(tag) | |
3247 #else | |
3248 #define SYNCHRONIZE_TAG(tag) | |
3249 #endif | |
3250 | |
3251 void Heap::IterateRoots(ObjectVisitor* v) { | 3246 void Heap::IterateRoots(ObjectVisitor* v) { |
3252 IterateStrongRoots(v); | 3247 IterateStrongRoots(v); |
3253 v->VisitPointer(reinterpret_cast<Object**>(&roots_[kSymbolTableRootIndex])); | 3248 v->VisitPointer(reinterpret_cast<Object**>(&roots_[kSymbolTableRootIndex])); |
3254 SYNCHRONIZE_TAG("symbol_table"); | 3249 v->Synchronize("symbol_table"); |
3255 } | 3250 } |
3256 | 3251 |
3257 | 3252 |
3258 void Heap::IterateStrongRoots(ObjectVisitor* v) { | 3253 void Heap::IterateStrongRoots(ObjectVisitor* v) { |
3259 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); | 3254 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); |
3260 SYNCHRONIZE_TAG("strong_root_list"); | 3255 v->Synchronize("strong_root_list"); |
3261 | 3256 |
3262 v->VisitPointer(bit_cast<Object**, String**>(&hidden_symbol_)); | 3257 v->VisitPointer(bit_cast<Object**, String**>(&hidden_symbol_)); |
3263 SYNCHRONIZE_TAG("symbol"); | 3258 v->Synchronize("symbol"); |
3264 | 3259 |
3265 Bootstrapper::Iterate(v); | 3260 Bootstrapper::Iterate(v); |
3266 SYNCHRONIZE_TAG("bootstrapper"); | 3261 v->Synchronize("bootstrapper"); |
3267 Top::Iterate(v); | 3262 Top::Iterate(v); |
3268 SYNCHRONIZE_TAG("top"); | 3263 v->Synchronize("top"); |
3269 Relocatable::Iterate(v); | 3264 Relocatable::Iterate(v); |
3270 SYNCHRONIZE_TAG("relocatable"); | 3265 v->Synchronize("relocatable"); |
3271 | 3266 |
3272 #ifdef ENABLE_DEBUGGER_SUPPORT | 3267 #ifdef ENABLE_DEBUGGER_SUPPORT |
3273 Debug::Iterate(v); | 3268 Debug::Iterate(v); |
3274 #endif | 3269 #endif |
3275 SYNCHRONIZE_TAG("debug"); | 3270 v->Synchronize("debug"); |
3276 CompilationCache::Iterate(v); | 3271 CompilationCache::Iterate(v); |
3277 SYNCHRONIZE_TAG("compilationcache"); | 3272 v->Synchronize("compilationcache"); |
3278 | 3273 |
3279 // Iterate over local handles in handle scopes. | 3274 // Iterate over local handles in handle scopes. |
3280 HandleScopeImplementer::Iterate(v); | 3275 HandleScopeImplementer::Iterate(v); |
3281 SYNCHRONIZE_TAG("handlescope"); | 3276 v->Synchronize("handlescope"); |
3282 | 3277 |
3283 // Iterate over the builtin code objects and code stubs in the heap. Note | 3278 // Iterate over the builtin code objects and code stubs in the heap. Note |
3284 // that it is not strictly necessary to iterate over code objects on | 3279 // that it is not strictly necessary to iterate over code objects on |
3285 // scavenge collections. We still do it here because this same function | 3280 // scavenge collections. We still do it here because this same function |
3286 // is used by the mark-sweep collector and the deserializer. | 3281 // is used by the mark-sweep collector and the deserializer. |
3287 Builtins::IterateBuiltins(v); | 3282 Builtins::IterateBuiltins(v); |
3288 SYNCHRONIZE_TAG("builtins"); | 3283 v->Synchronize("builtins"); |
3289 | 3284 |
3290 // Iterate over global handles. | 3285 // Iterate over global handles. |
3291 GlobalHandles::IterateRoots(v); | 3286 GlobalHandles::IterateRoots(v); |
3292 SYNCHRONIZE_TAG("globalhandles"); | 3287 v->Synchronize("globalhandles"); |
3293 | 3288 |
3294 // Iterate over pointers being held by inactive threads. | 3289 // Iterate over pointers being held by inactive threads. |
3295 ThreadManager::Iterate(v); | 3290 ThreadManager::Iterate(v); |
3296 SYNCHRONIZE_TAG("threadmanager"); | 3291 v->Synchronize("threadmanager"); |
3297 } | 3292 } |
3298 #undef SYNCHRONIZE_TAG | |
3299 | 3293 |
3300 | 3294 |
3301 // Flag is set when the heap has been configured. The heap can be repeatedly | 3295 // Flag is set when the heap has been configured. The heap can be repeatedly |
3302 // configured through the API until it is setup. | 3296 // configured through the API until it is setup. |
3303 static bool heap_configured = false; | 3297 static bool heap_configured = false; |
3304 | 3298 |
3305 // TODO(1236194): Since the heap size is configurable on the command line | 3299 // TODO(1236194): Since the heap size is configurable on the command line |
3306 // and through the API, we should gracefully handle the case that the heap | 3300 // and through the API, we should gracefully handle the case that the heap |
3307 // size is not big enough to fit all the initial objects. | 3301 // size is not big enough to fit all the initial objects. |
3308 bool Heap::ConfigureHeap(int max_semispace_size, int max_old_gen_size) { | 3302 bool Heap::ConfigureHeap(int max_semispace_size, int max_old_gen_size) { |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4035 for (int i = 0; i < kNumberOfCaches; i++) { | 4029 for (int i = 0; i < kNumberOfCaches; i++) { |
4036 if (caches_[i] != NULL) { | 4030 if (caches_[i] != NULL) { |
4037 delete caches_[i]; | 4031 delete caches_[i]; |
4038 caches_[i] = NULL; | 4032 caches_[i] = NULL; |
4039 } | 4033 } |
4040 } | 4034 } |
4041 } | 4035 } |
4042 | 4036 |
4043 | 4037 |
4044 } } // namespace v8::internal | 4038 } } // namespace v8::internal |
OLD | NEW |