Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 int Heap::amount_of_external_allocated_memory_ = 0; | 76 int Heap::amount_of_external_allocated_memory_ = 0; |
| 77 int Heap::amount_of_external_allocated_memory_at_last_global_gc_ = 0; | 77 int Heap::amount_of_external_allocated_memory_at_last_global_gc_ = 0; |
| 78 | 78 |
| 79 // semispace_size_ should be a power of 2 and old_generation_size_ should be | 79 // semispace_size_ should be a power of 2 and old_generation_size_ should be |
| 80 // a multiple of Page::kPageSize. | 80 // a multiple of Page::kPageSize. |
| 81 #if defined(ANDROID) | 81 #if defined(ANDROID) |
| 82 int Heap::max_semispace_size_ = 2*MB; | 82 int Heap::max_semispace_size_ = 2*MB; |
| 83 intptr_t Heap::max_old_generation_size_ = 192*MB; | 83 intptr_t Heap::max_old_generation_size_ = 192*MB; |
| 84 int Heap::initial_semispace_size_ = 128*KB; | 84 int Heap::initial_semispace_size_ = 128*KB; |
| 85 intptr_t Heap::code_range_size_ = 0; | 85 intptr_t Heap::code_range_size_ = 0; |
| 86 intptr_t Heap::max_executable_size_ = max_old_generation_size_; | |
| 86 #elif defined(V8_TARGET_ARCH_X64) | 87 #elif defined(V8_TARGET_ARCH_X64) |
| 87 int Heap::max_semispace_size_ = 16*MB; | 88 int Heap::max_semispace_size_ = 16*MB; |
| 88 intptr_t Heap::max_old_generation_size_ = 1*GB; | 89 intptr_t Heap::max_old_generation_size_ = 1*GB; |
| 89 int Heap::initial_semispace_size_ = 1*MB; | 90 int Heap::initial_semispace_size_ = 1*MB; |
| 90 intptr_t Heap::code_range_size_ = 512*MB; | 91 intptr_t Heap::code_range_size_ = 512*MB; |
| 92 intptr_t Heap::max_executable_size_ = 256*MB; | |
| 91 #else | 93 #else |
| 92 int Heap::max_semispace_size_ = 8*MB; | 94 int Heap::max_semispace_size_ = 8*MB; |
| 93 intptr_t Heap::max_old_generation_size_ = 512*MB; | 95 intptr_t Heap::max_old_generation_size_ = 512*MB; |
| 94 int Heap::initial_semispace_size_ = 512*KB; | 96 int Heap::initial_semispace_size_ = 512*KB; |
| 95 intptr_t Heap::code_range_size_ = 0; | 97 intptr_t Heap::code_range_size_ = 0; |
| 98 intptr_t Heap::max_executable_size_ = 128*MB; | |
| 96 #endif | 99 #endif |
| 97 | 100 |
| 98 // The snapshot semispace size will be the default semispace size if | 101 // The snapshot semispace size will be the default semispace size if |
| 99 // snapshotting is used and will be the requested semispace size as | 102 // snapshotting is used and will be the requested semispace size as |
| 100 // set up by ConfigureHeap otherwise. | 103 // set up by ConfigureHeap otherwise. |
| 101 int Heap::reserved_semispace_size_ = Heap::max_semispace_size_; | 104 int Heap::reserved_semispace_size_ = Heap::max_semispace_size_; |
| 102 | 105 |
| 103 List<Heap::GCPrologueCallbackPair> Heap::gc_prologue_callbacks_; | 106 List<Heap::GCPrologueCallbackPair> Heap::gc_prologue_callbacks_; |
| 104 List<Heap::GCEpilogueCallbackPair> Heap::gc_epilogue_callbacks_; | 107 List<Heap::GCEpilogueCallbackPair> Heap::gc_epilogue_callbacks_; |
| 105 | 108 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 | 168 |
| 166 return new_space_.CommittedMemory() + | 169 return new_space_.CommittedMemory() + |
| 167 old_pointer_space_->CommittedMemory() + | 170 old_pointer_space_->CommittedMemory() + |
| 168 old_data_space_->CommittedMemory() + | 171 old_data_space_->CommittedMemory() + |
| 169 code_space_->CommittedMemory() + | 172 code_space_->CommittedMemory() + |
| 170 map_space_->CommittedMemory() + | 173 map_space_->CommittedMemory() + |
| 171 cell_space_->CommittedMemory() + | 174 cell_space_->CommittedMemory() + |
| 172 lo_space_->Size(); | 175 lo_space_->Size(); |
| 173 } | 176 } |
| 174 | 177 |
| 178 intptr_t Heap::CommittedMemoryExecutable() { | |
| 179 if (!HasBeenSetup()) return 0; | |
| 180 | |
| 181 return MemoryAllocator::SizeExecutable(); | |
| 182 } | |
| 183 | |
| 175 | 184 |
| 176 intptr_t Heap::Available() { | 185 intptr_t Heap::Available() { |
| 177 if (!HasBeenSetup()) return 0; | 186 if (!HasBeenSetup()) return 0; |
| 178 | 187 |
| 179 return new_space_.Available() + | 188 return new_space_.Available() + |
| 180 old_pointer_space_->Available() + | 189 old_pointer_space_->Available() + |
| 181 old_data_space_->Available() + | 190 old_data_space_->Available() + |
| 182 code_space_->Available() + | 191 code_space_->Available() + |
| 183 map_space_->Available() + | 192 map_space_->Available() + |
| 184 cell_space_->Available(); | 193 cell_space_->Available(); |
| (...skipping 4121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4306 } | 4315 } |
| 4307 | 4316 |
| 4308 | 4317 |
| 4309 // Flag is set when the heap has been configured. The heap can be repeatedly | 4318 // Flag is set when the heap has been configured. The heap can be repeatedly |
| 4310 // configured through the API until it is setup. | 4319 // configured through the API until it is setup. |
| 4311 static bool heap_configured = false; | 4320 static bool heap_configured = false; |
| 4312 | 4321 |
| 4313 // TODO(1236194): Since the heap size is configurable on the command line | 4322 // TODO(1236194): Since the heap size is configurable on the command line |
| 4314 // and through the API, we should gracefully handle the case that the heap | 4323 // and through the API, we should gracefully handle the case that the heap |
| 4315 // size is not big enough to fit all the initial objects. | 4324 // size is not big enough to fit all the initial objects. |
| 4316 bool Heap::ConfigureHeap(int max_semispace_size, int max_old_gen_size) { | 4325 bool Heap::ConfigureHeap(int max_semispace_size, |
| 4326 int max_old_gen_size, | |
| 4327 int max_executable_size) { | |
| 4317 if (HasBeenSetup()) return false; | 4328 if (HasBeenSetup()) return false; |
| 4318 | 4329 |
| 4319 if (max_semispace_size > 0) max_semispace_size_ = max_semispace_size; | 4330 if (max_semispace_size > 0) max_semispace_size_ = max_semispace_size; |
| 4320 | 4331 |
| 4321 if (Snapshot::IsEnabled()) { | 4332 if (Snapshot::IsEnabled()) { |
| 4322 // If we are using a snapshot we always reserve the default amount | 4333 // If we are using a snapshot we always reserve the default amount |
| 4323 // of memory for each semispace because code in the snapshot has | 4334 // of memory for each semispace because code in the snapshot has |
| 4324 // write-barrier code that relies on the size and alignment of new | 4335 // write-barrier code that relies on the size and alignment of new |
| 4325 // space. We therefore cannot use a larger max semispace size | 4336 // space. We therefore cannot use a larger max semispace size |
| 4326 // than the default reserved semispace size. | 4337 // than the default reserved semispace size. |
| 4327 if (max_semispace_size_ > reserved_semispace_size_) { | 4338 if (max_semispace_size_ > reserved_semispace_size_) { |
| 4328 max_semispace_size_ = reserved_semispace_size_; | 4339 max_semispace_size_ = reserved_semispace_size_; |
| 4329 } | 4340 } |
| 4330 } else { | 4341 } else { |
| 4331 // If we are not using snapshots we reserve space for the actual | 4342 // If we are not using snapshots we reserve space for the actual |
| 4332 // max semispace size. | 4343 // max semispace size. |
| 4333 reserved_semispace_size_ = max_semispace_size_; | 4344 reserved_semispace_size_ = max_semispace_size_; |
| 4334 } | 4345 } |
| 4335 | 4346 |
| 4336 if (max_old_gen_size > 0) max_old_generation_size_ = max_old_gen_size; | 4347 if (max_old_gen_size > 0) max_old_generation_size_ = max_old_gen_size; |
| 4348 if (max_executable_size > 0) | |
|
Mads Ager (chromium)
2010/11/10 08:14:24
Let's add braces here.
| |
| 4349 max_executable_size_ = RoundUp(max_executable_size_, Page::kPageSize); | |
| 4337 | 4350 |
| 4338 // The new space size must be a power of two to support single-bit testing | 4351 // The new space size must be a power of two to support single-bit testing |
| 4339 // for containment. | 4352 // for containment. |
| 4340 max_semispace_size_ = RoundUpToPowerOf2(max_semispace_size_); | 4353 max_semispace_size_ = RoundUpToPowerOf2(max_semispace_size_); |
| 4341 reserved_semispace_size_ = RoundUpToPowerOf2(reserved_semispace_size_); | 4354 reserved_semispace_size_ = RoundUpToPowerOf2(reserved_semispace_size_); |
| 4342 initial_semispace_size_ = Min(initial_semispace_size_, max_semispace_size_); | 4355 initial_semispace_size_ = Min(initial_semispace_size_, max_semispace_size_); |
| 4343 external_allocation_limit_ = 10 * max_semispace_size_; | 4356 external_allocation_limit_ = 10 * max_semispace_size_; |
| 4344 | 4357 |
| 4345 // The old generation is paged. | 4358 // The old generation is paged. |
| 4346 max_old_generation_size_ = RoundUp(max_old_generation_size_, Page::kPageSize); | 4359 max_old_generation_size_ = RoundUp(max_old_generation_size_, Page::kPageSize); |
| 4347 | 4360 |
| 4348 heap_configured = true; | 4361 heap_configured = true; |
| 4349 return true; | 4362 return true; |
| 4350 } | 4363 } |
| 4351 | 4364 |
| 4352 | 4365 |
| 4353 bool Heap::ConfigureHeapDefault() { | 4366 bool Heap::ConfigureHeapDefault() { |
| 4354 return ConfigureHeap( | 4367 return ConfigureHeap(FLAG_max_new_space_size / 2, FLAG_max_old_space_size, |
|
Mads Ager (chromium)
2010/11/10 08:32:29
Removing the units here and not changing flag-defi
| |
| 4355 FLAG_max_new_space_size * (KB / 2), FLAG_max_old_space_size * MB); | 4368 FLAG_max_executable_size); |
| 4356 } | 4369 } |
| 4357 | 4370 |
| 4358 | 4371 |
| 4359 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { | 4372 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { |
| 4360 *stats->start_marker = HeapStats::kStartMarker; | 4373 *stats->start_marker = HeapStats::kStartMarker; |
| 4361 *stats->end_marker = HeapStats::kEndMarker; | 4374 *stats->end_marker = HeapStats::kEndMarker; |
| 4362 *stats->new_space_size = new_space_.SizeAsInt(); | 4375 *stats->new_space_size = new_space_.SizeAsInt(); |
| 4363 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); | 4376 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); |
| 4364 *stats->old_pointer_space_size = old_pointer_space_->Size(); | 4377 *stats->old_pointer_space_size = old_pointer_space_->Size(); |
| 4365 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); | 4378 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4428 ScavengingVisitor::Initialize(); | 4441 ScavengingVisitor::Initialize(); |
| 4429 NewSpaceScavenger::Initialize(); | 4442 NewSpaceScavenger::Initialize(); |
| 4430 MarkCompactCollector::Initialize(); | 4443 MarkCompactCollector::Initialize(); |
| 4431 | 4444 |
| 4432 MarkMapPointersAsEncoded(false); | 4445 MarkMapPointersAsEncoded(false); |
| 4433 | 4446 |
| 4434 // Setup memory allocator and reserve a chunk of memory for new | 4447 // Setup memory allocator and reserve a chunk of memory for new |
| 4435 // space. The chunk is double the size of the requested reserved | 4448 // space. The chunk is double the size of the requested reserved |
| 4436 // new space size to ensure that we can find a pair of semispaces that | 4449 // new space size to ensure that we can find a pair of semispaces that |
| 4437 // are contiguous and aligned to their size. | 4450 // are contiguous and aligned to their size. |
| 4438 if (!MemoryAllocator::Setup(MaxReserved())) return false; | 4451 if (!MemoryAllocator::Setup(MaxReserved(), MaxExecutableSize())) return false; |
| 4439 void* chunk = | 4452 void* chunk = |
| 4440 MemoryAllocator::ReserveInitialChunk(4 * reserved_semispace_size_); | 4453 MemoryAllocator::ReserveInitialChunk(4 * reserved_semispace_size_); |
| 4441 if (chunk == NULL) return false; | 4454 if (chunk == NULL) return false; |
| 4442 | 4455 |
| 4443 // Align the pair of semispaces to their size, which must be a power | 4456 // Align the pair of semispaces to their size, which must be a power |
| 4444 // of 2. | 4457 // of 2. |
| 4445 Address new_space_start = | 4458 Address new_space_start = |
| 4446 RoundUp(reinterpret_cast<byte*>(chunk), 2 * reserved_semispace_size_); | 4459 RoundUp(reinterpret_cast<byte*>(chunk), 2 * reserved_semispace_size_); |
| 4447 if (!new_space_.Setup(new_space_start, 2 * reserved_semispace_size_)) { | 4460 if (!new_space_.Setup(new_space_start, 2 * reserved_semispace_size_)) { |
| 4448 return false; | 4461 return false; |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5265 void ExternalStringTable::TearDown() { | 5278 void ExternalStringTable::TearDown() { |
| 5266 new_space_strings_.Free(); | 5279 new_space_strings_.Free(); |
| 5267 old_space_strings_.Free(); | 5280 old_space_strings_.Free(); |
| 5268 } | 5281 } |
| 5269 | 5282 |
| 5270 | 5283 |
| 5271 List<Object*> ExternalStringTable::new_space_strings_; | 5284 List<Object*> ExternalStringTable::new_space_strings_; |
| 5272 List<Object*> ExternalStringTable::old_space_strings_; | 5285 List<Object*> ExternalStringTable::old_space_strings_; |
| 5273 | 5286 |
| 5274 } } // namespace v8::internal | 5287 } } // namespace v8::internal |
| OLD | NEW |