OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 last_idle_notification_gc_count_init_(false), | 155 last_idle_notification_gc_count_init_(false), |
156 mark_sweeps_since_idle_round_started_(0), | 156 mark_sweeps_since_idle_round_started_(0), |
157 ms_count_at_last_idle_notification_(0), | 157 ms_count_at_last_idle_notification_(0), |
158 gc_count_at_last_idle_gc_(0), | 158 gc_count_at_last_idle_gc_(0), |
159 scavenges_since_last_idle_round_(kIdleScavengeThreshold), | 159 scavenges_since_last_idle_round_(kIdleScavengeThreshold), |
160 #ifdef VERIFY_HEAP | 160 #ifdef VERIFY_HEAP |
161 no_weak_embedded_maps_verification_scope_depth_(0), | 161 no_weak_embedded_maps_verification_scope_depth_(0), |
162 #endif | 162 #endif |
163 promotion_queue_(this), | 163 promotion_queue_(this), |
164 configured_(false), | 164 configured_(false), |
165 chunks_queued_for_free_(NULL), | 165 chunks_queued_for_free_(NULL) { |
166 relocation_mutex_(NULL) { | |
167 // Allow build-time customization of the max semispace size. Building | 166 // Allow build-time customization of the max semispace size. Building |
168 // V8 with snapshots and a non-default max semispace size is much | 167 // V8 with snapshots and a non-default max semispace size is much |
169 // easier if you can define it as part of the build environment. | 168 // easier if you can define it as part of the build environment. |
170 #if defined(V8_MAX_SEMISPACE_SIZE) | 169 #if defined(V8_MAX_SEMISPACE_SIZE) |
171 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; | 170 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; |
172 #endif | 171 #endif |
173 | 172 |
174 intptr_t max_virtual = OS::MaxVirtualMemory(); | 173 intptr_t max_virtual = OS::MaxVirtualMemory(); |
175 | 174 |
176 if (max_virtual > 0) { | 175 if (max_virtual > 0) { |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 } | 1274 } |
1276 return NULL; | 1275 return NULL; |
1277 } | 1276 } |
1278 | 1277 |
1279 private: | 1278 private: |
1280 Heap* heap_; | 1279 Heap* heap_; |
1281 }; | 1280 }; |
1282 | 1281 |
1283 | 1282 |
1284 void Heap::Scavenge() { | 1283 void Heap::Scavenge() { |
1285 RelocationLock relocation_lock(this); | |
1286 | |
1287 #ifdef VERIFY_HEAP | 1284 #ifdef VERIFY_HEAP |
1288 if (FLAG_verify_heap) VerifyNonPointerSpacePointers(); | 1285 if (FLAG_verify_heap) VerifyNonPointerSpacePointers(); |
1289 #endif | 1286 #endif |
1290 | 1287 |
1291 gc_state_ = SCAVENGE; | 1288 gc_state_ = SCAVENGE; |
1292 | 1289 |
1293 // Implements Cheney's copying algorithm | 1290 // Implements Cheney's copying algorithm |
1294 LOG(isolate_, ResourceEvent("scavenge", "begin")); | 1291 LOG(isolate_, ResourceEvent("scavenge", "begin")); |
1295 | 1292 |
1296 // Clear descriptor cache. | 1293 // Clear descriptor cache. |
(...skipping 5297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6594 } else { | 6591 } else { |
6595 set_hash_seed(Smi::FromInt(FLAG_hash_seed)); | 6592 set_hash_seed(Smi::FromInt(FLAG_hash_seed)); |
6596 } | 6593 } |
6597 } | 6594 } |
6598 | 6595 |
6599 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); | 6596 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); |
6600 LOG(isolate_, IntPtrTEvent("heap-available", Available())); | 6597 LOG(isolate_, IntPtrTEvent("heap-available", Available())); |
6601 | 6598 |
6602 store_buffer()->SetUp(); | 6599 store_buffer()->SetUp(); |
6603 | 6600 |
6604 if (FLAG_parallel_recompilation) relocation_mutex_ = OS::CreateMutex(); | |
6605 #ifdef DEBUG | |
6606 relocation_mutex_locked_ = false; | |
6607 #endif // DEBUG | |
6608 | |
6609 return true; | 6601 return true; |
6610 } | 6602 } |
6611 | 6603 |
6612 bool Heap::CreateHeapObjects() { | 6604 bool Heap::CreateHeapObjects() { |
6613 // Create initial maps. | 6605 // Create initial maps. |
6614 if (!CreateInitialMaps()) return false; | 6606 if (!CreateInitialMaps()) return false; |
6615 if (!CreateApiObjects()) return false; | 6607 if (!CreateApiObjects()) return false; |
6616 | 6608 |
6617 // Create initial objects | 6609 // Create initial objects |
6618 if (!CreateInitialObjects()) return false; | 6610 if (!CreateInitialObjects()) return false; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6701 if (lo_space_ != NULL) { | 6693 if (lo_space_ != NULL) { |
6702 lo_space_->TearDown(); | 6694 lo_space_->TearDown(); |
6703 delete lo_space_; | 6695 delete lo_space_; |
6704 lo_space_ = NULL; | 6696 lo_space_ = NULL; |
6705 } | 6697 } |
6706 | 6698 |
6707 store_buffer()->TearDown(); | 6699 store_buffer()->TearDown(); |
6708 incremental_marking()->TearDown(); | 6700 incremental_marking()->TearDown(); |
6709 | 6701 |
6710 isolate_->memory_allocator()->TearDown(); | 6702 isolate_->memory_allocator()->TearDown(); |
6711 | |
6712 delete relocation_mutex_; | |
6713 } | 6703 } |
6714 | 6704 |
6715 | 6705 |
6716 void Heap::AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type) { | 6706 void Heap::AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type) { |
6717 ASSERT(callback != NULL); | 6707 ASSERT(callback != NULL); |
6718 GCPrologueCallbackPair pair(callback, gc_type); | 6708 GCPrologueCallbackPair pair(callback, gc_type); |
6719 ASSERT(!gc_prologue_callbacks_.Contains(pair)); | 6709 ASSERT(!gc_prologue_callbacks_.Contains(pair)); |
6720 return gc_prologue_callbacks_.Add(pair); | 6710 return gc_prologue_callbacks_.Add(pair); |
6721 } | 6711 } |
6722 | 6712 |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7833 static_cast<int>(object_sizes_last_time_[index])); | 7823 static_cast<int>(object_sizes_last_time_[index])); |
7834 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7824 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7835 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7825 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7836 | 7826 |
7837 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7827 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7838 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7828 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7839 ClearObjectStats(); | 7829 ClearObjectStats(); |
7840 } | 7830 } |
7841 | 7831 |
7842 } } // namespace v8::internal | 7832 } } // namespace v8::internal |
OLD | NEW |