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

Side by Side Diff: src/heap.cc

Issue 4634003: Landing for Justin Schuh.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 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 | Annotate | Revision Log
« no previous file with comments | « src/heap.h ('k') | src/spaces.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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) {
4349 max_executable_size_ = RoundUp(max_executable_size_, Page::kPageSize);
4350 }
4337 4351
4338 // The new space size must be a power of two to support single-bit testing 4352 // The new space size must be a power of two to support single-bit testing
4339 // for containment. 4353 // for containment.
4340 max_semispace_size_ = RoundUpToPowerOf2(max_semispace_size_); 4354 max_semispace_size_ = RoundUpToPowerOf2(max_semispace_size_);
4341 reserved_semispace_size_ = RoundUpToPowerOf2(reserved_semispace_size_); 4355 reserved_semispace_size_ = RoundUpToPowerOf2(reserved_semispace_size_);
4342 initial_semispace_size_ = Min(initial_semispace_size_, max_semispace_size_); 4356 initial_semispace_size_ = Min(initial_semispace_size_, max_semispace_size_);
4343 external_allocation_limit_ = 10 * max_semispace_size_; 4357 external_allocation_limit_ = 10 * max_semispace_size_;
4344 4358
4345 // The old generation is paged. 4359 // The old generation is paged.
4346 max_old_generation_size_ = RoundUp(max_old_generation_size_, Page::kPageSize); 4360 max_old_generation_size_ = RoundUp(max_old_generation_size_, Page::kPageSize);
4347 4361
4348 heap_configured = true; 4362 heap_configured = true;
4349 return true; 4363 return true;
4350 } 4364 }
4351 4365
4352 4366
4353 bool Heap::ConfigureHeapDefault() { 4367 bool Heap::ConfigureHeapDefault() {
4354 return ConfigureHeap( 4368 return ConfigureHeap(FLAG_max_new_space_size / 2 * KB,
4355 FLAG_max_new_space_size * (KB / 2), FLAG_max_old_space_size * MB); 4369 FLAG_max_old_space_size * MB,
4370 FLAG_max_executable_size * MB);
4356 } 4371 }
4357 4372
4358 4373
4359 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { 4374 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) {
4360 *stats->start_marker = HeapStats::kStartMarker; 4375 *stats->start_marker = HeapStats::kStartMarker;
4361 *stats->end_marker = HeapStats::kEndMarker; 4376 *stats->end_marker = HeapStats::kEndMarker;
4362 *stats->new_space_size = new_space_.SizeAsInt(); 4377 *stats->new_space_size = new_space_.SizeAsInt();
4363 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); 4378 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity());
4364 *stats->old_pointer_space_size = old_pointer_space_->Size(); 4379 *stats->old_pointer_space_size = old_pointer_space_->Size();
4365 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); 4380 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4428 ScavengingVisitor::Initialize(); 4443 ScavengingVisitor::Initialize();
4429 NewSpaceScavenger::Initialize(); 4444 NewSpaceScavenger::Initialize();
4430 MarkCompactCollector::Initialize(); 4445 MarkCompactCollector::Initialize();
4431 4446
4432 MarkMapPointersAsEncoded(false); 4447 MarkMapPointersAsEncoded(false);
4433 4448
4434 // Setup memory allocator and reserve a chunk of memory for new 4449 // Setup memory allocator and reserve a chunk of memory for new
4435 // space. The chunk is double the size of the requested reserved 4450 // 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 4451 // new space size to ensure that we can find a pair of semispaces that
4437 // are contiguous and aligned to their size. 4452 // are contiguous and aligned to their size.
4438 if (!MemoryAllocator::Setup(MaxReserved())) return false; 4453 if (!MemoryAllocator::Setup(MaxReserved(), MaxExecutableSize())) return false;
4439 void* chunk = 4454 void* chunk =
4440 MemoryAllocator::ReserveInitialChunk(4 * reserved_semispace_size_); 4455 MemoryAllocator::ReserveInitialChunk(4 * reserved_semispace_size_);
4441 if (chunk == NULL) return false; 4456 if (chunk == NULL) return false;
4442 4457
4443 // Align the pair of semispaces to their size, which must be a power 4458 // Align the pair of semispaces to their size, which must be a power
4444 // of 2. 4459 // of 2.
4445 Address new_space_start = 4460 Address new_space_start =
4446 RoundUp(reinterpret_cast<byte*>(chunk), 2 * reserved_semispace_size_); 4461 RoundUp(reinterpret_cast<byte*>(chunk), 2 * reserved_semispace_size_);
4447 if (!new_space_.Setup(new_space_start, 2 * reserved_semispace_size_)) { 4462 if (!new_space_.Setup(new_space_start, 2 * reserved_semispace_size_)) {
4448 return false; 4463 return false;
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
5265 void ExternalStringTable::TearDown() { 5280 void ExternalStringTable::TearDown() {
5266 new_space_strings_.Free(); 5281 new_space_strings_.Free();
5267 old_space_strings_.Free(); 5282 old_space_strings_.Free();
5268 } 5283 }
5269 5284
5270 5285
5271 List<Object*> ExternalStringTable::new_space_strings_; 5286 List<Object*> ExternalStringTable::new_space_strings_;
5272 List<Object*> ExternalStringTable::old_space_strings_; 5287 List<Object*> ExternalStringTable::old_space_strings_;
5273 5288
5274 } } // namespace v8::internal 5289 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698