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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 #include "regexp-macro-assembler.h" | 61 #include "regexp-macro-assembler.h" |
62 #include "mips/regexp-macro-assembler-mips.h" | 62 #include "mips/regexp-macro-assembler-mips.h" |
63 #endif | 63 #endif |
64 | 64 |
65 namespace v8 { | 65 namespace v8 { |
66 namespace internal { | 66 namespace internal { |
67 | 67 |
68 | 68 |
69 Heap::Heap() | 69 Heap::Heap() |
70 : isolate_(NULL), | 70 : isolate_(NULL), |
71 code_range_size_(kIs64BitArch ? 512 * MB : 0), | 71 code_range_size_(0), |
72 // semispace_size_ should be a power of 2 and old_generation_size_ should be | 72 // semispace_size_ should be a power of 2 and old_generation_size_ should be |
73 // a multiple of Page::kPageSize. | 73 // a multiple of Page::kPageSize. |
74 reserved_semispace_size_(8 * (kPointerSize / 4) * MB), | 74 reserved_semispace_size_(8 * (kPointerSize / 4) * MB), |
75 max_semispace_size_(8 * (kPointerSize / 4) * MB), | 75 max_semispace_size_(8 * (kPointerSize / 4) * MB), |
76 initial_semispace_size_(Page::kPageSize), | 76 initial_semispace_size_(Page::kPageSize), |
77 max_old_generation_size_(700ul * (kPointerSize / 4) * MB), | 77 max_old_generation_size_(700ul * (kPointerSize / 4) * MB), |
78 max_executable_size_(256ul * (kPointerSize / 4) * MB), | 78 max_executable_size_(256ul * (kPointerSize / 4) * MB), |
79 // Variables set based on semispace_size_ and old_generation_size_ in | 79 // Variables set based on semispace_size_ and old_generation_size_ in |
80 // ConfigureHeap (survived_since_last_expansion_, external_allocation_limit_) | 80 // ConfigureHeap (survived_since_last_expansion_, external_allocation_limit_) |
81 // Will be 4 * reserved_semispace_size_ to ensure that young | 81 // Will be 4 * reserved_semispace_size_ to ensure that young |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 // Allow build-time customization of the max semispace size. Building | 158 // Allow build-time customization of the max semispace size. Building |
159 // V8 with snapshots and a non-default max semispace size is much | 159 // V8 with snapshots and a non-default max semispace size is much |
160 // easier if you can define it as part of the build environment. | 160 // easier if you can define it as part of the build environment. |
161 #if defined(V8_MAX_SEMISPACE_SIZE) | 161 #if defined(V8_MAX_SEMISPACE_SIZE) |
162 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; | 162 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; |
163 #endif | 163 #endif |
164 | 164 |
165 // Ensure old_generation_size_ is a multiple of kPageSize. | 165 // Ensure old_generation_size_ is a multiple of kPageSize. |
166 ASSERT(MB >= Page::kPageSize); | 166 ASSERT(MB >= Page::kPageSize); |
167 | 167 |
168 intptr_t max_virtual = OS::MaxVirtualMemory(); | |
169 | |
170 if (max_virtual > 0) { | |
171 if (code_range_size_ > 0) { | |
172 // Reserve no more than 1/8 of the memory for the code range. | |
173 code_range_size_ = Min(code_range_size_, max_virtual >> 3); | |
174 } | |
175 } | |
176 | |
177 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); | 168 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); |
178 native_contexts_list_ = NULL; | 169 native_contexts_list_ = NULL; |
179 array_buffers_list_ = Smi::FromInt(0); | 170 array_buffers_list_ = Smi::FromInt(0); |
180 allocation_sites_list_ = Smi::FromInt(0); | 171 allocation_sites_list_ = Smi::FromInt(0); |
181 // Put a dummy entry in the remembered pages so we can find the list the | 172 // Put a dummy entry in the remembered pages so we can find the list the |
182 // minidump even if there are no real unmapped pages. | 173 // minidump even if there are no real unmapped pages. |
183 RememberUnmappedPage(NULL, false); | 174 RememberUnmappedPage(NULL, false); |
184 | 175 |
185 ClearObjectStats(true); | 176 ClearObjectStats(true); |
186 } | 177 } |
(...skipping 5943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6130 // deserializer are deliberately a little unsynchronized (see above) so the | 6121 // deserializer are deliberately a little unsynchronized (see above) so the |
6131 // checking of the sync flag in the snapshot would fail. | 6122 // checking of the sync flag in the snapshot would fail. |
6132 } | 6123 } |
6133 | 6124 |
6134 | 6125 |
6135 // TODO(1236194): Since the heap size is configurable on the command line | 6126 // TODO(1236194): Since the heap size is configurable on the command line |
6136 // and through the API, we should gracefully handle the case that the heap | 6127 // and through the API, we should gracefully handle the case that the heap |
6137 // size is not big enough to fit all the initial objects. | 6128 // size is not big enough to fit all the initial objects. |
6138 bool Heap::ConfigureHeap(int max_semispace_size, | 6129 bool Heap::ConfigureHeap(int max_semispace_size, |
6139 intptr_t max_old_gen_size, | 6130 intptr_t max_old_gen_size, |
6140 intptr_t max_executable_size) { | 6131 intptr_t max_executable_size, |
6132 intptr_t code_range_size) { | |
6141 if (HasBeenSetUp()) return false; | 6133 if (HasBeenSetUp()) return false; |
6142 | 6134 |
6143 if (FLAG_stress_compaction) { | 6135 if (FLAG_stress_compaction) { |
6144 // This will cause more frequent GCs when stressing. | 6136 // This will cause more frequent GCs when stressing. |
6145 max_semispace_size_ = Page::kPageSize; | 6137 max_semispace_size_ = Page::kPageSize; |
6146 } | 6138 } |
6147 | 6139 |
6148 if (max_semispace_size > 0) { | 6140 if (max_semispace_size > 0) { |
6149 if (max_semispace_size < Page::kPageSize) { | 6141 if (max_semispace_size < Page::kPageSize) { |
6150 max_semispace_size = Page::kPageSize; | 6142 max_semispace_size = Page::kPageSize; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6204 Page::kPageSize), | 6196 Page::kPageSize), |
6205 RoundUp(max_old_generation_size_, | 6197 RoundUp(max_old_generation_size_, |
6206 Page::kPageSize)); | 6198 Page::kPageSize)); |
6207 | 6199 |
6208 // We rely on being able to allocate new arrays in paged spaces. | 6200 // We rely on being able to allocate new arrays in paged spaces. |
6209 ASSERT(Page::kMaxRegularHeapObjectSize >= | 6201 ASSERT(Page::kMaxRegularHeapObjectSize >= |
6210 (JSArray::kSize + | 6202 (JSArray::kSize + |
6211 FixedArray::SizeFor(JSObject::kInitialMaxFastElementArray) + | 6203 FixedArray::SizeFor(JSObject::kInitialMaxFastElementArray) + |
6212 AllocationMemento::kSize)); | 6204 AllocationMemento::kSize)); |
6213 | 6205 |
6206 code_range_size_ = code_range_size; | |
6207 | |
6214 configured_ = true; | 6208 configured_ = true; |
6215 return true; | 6209 return true; |
6216 } | 6210 } |
6217 | 6211 |
6218 | 6212 |
6219 bool Heap::ConfigureHeapDefault() { | 6213 bool Heap::ConfigureHeapDefault() { |
6220 return ConfigureHeap(static_cast<intptr_t>(FLAG_max_new_space_size / 2) * KB, | 6214 return ConfigureHeap(static_cast<intptr_t>(FLAG_max_new_space_size / 2) * KB, |
6221 static_cast<intptr_t>(FLAG_max_old_space_size) * MB, | 6215 static_cast<intptr_t>(FLAG_max_old_space_size) * MB, |
6222 static_cast<intptr_t>(FLAG_max_executable_size) * MB); | 6216 static_cast<intptr_t>(FLAG_max_executable_size) * MB, |
6217 static_cast<intptr_t>(0)); | |
6223 } | 6218 } |
6224 | 6219 |
6225 | 6220 |
6226 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { | 6221 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { |
6227 *stats->start_marker = HeapStats::kStartMarker; | 6222 *stats->start_marker = HeapStats::kStartMarker; |
6228 *stats->end_marker = HeapStats::kEndMarker; | 6223 *stats->end_marker = HeapStats::kEndMarker; |
6229 *stats->new_space_size = new_space_.SizeAsInt(); | 6224 *stats->new_space_size = new_space_.SizeAsInt(); |
6230 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); | 6225 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); |
6231 *stats->old_pointer_space_size = old_pointer_space_->SizeOfObjects(); | 6226 *stats->old_pointer_space_size = old_pointer_space_->SizeOfObjects(); |
6232 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); | 6227 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6367 old_data_space_ = | 6362 old_data_space_ = |
6368 new OldSpace(this, | 6363 new OldSpace(this, |
6369 max_old_generation_size_, | 6364 max_old_generation_size_, |
6370 OLD_DATA_SPACE, | 6365 OLD_DATA_SPACE, |
6371 NOT_EXECUTABLE); | 6366 NOT_EXECUTABLE); |
6372 if (old_data_space_ == NULL) return false; | 6367 if (old_data_space_ == NULL) return false; |
6373 if (!old_data_space_->SetUp()) return false; | 6368 if (!old_data_space_->SetUp()) return false; |
6374 | 6369 |
6375 // Initialize the code space, set its maximum capacity to the old | 6370 // Initialize the code space, set its maximum capacity to the old |
6376 // generation size. It needs executable memory. | 6371 // generation size. It needs executable memory. |
6377 // On 64-bit platform(s), we put all code objects in a 2 GB range of | 6372 // On 64-bit platform(s), we put all code objects in a 2 GB range of |
Michael Starzinger
2014/04/09 12:03:04
nit: The comment looks very outdated. Can we adapt
jochen (gone - plz use gerrit)
2014/04/09 12:44:56
Done.
| |
6378 // virtual address space, so that they can call each other with near calls. | 6373 // virtual address space, so that they can call each other with near calls. |
6379 if (code_range_size_ > 0) { | 6374 if (!isolate_->code_range()->SetUp(code_range_size_)) { |
6380 if (!isolate_->code_range()->SetUp(code_range_size_)) { | 6375 return false; |
6381 return false; | |
6382 } | |
6383 } | 6376 } |
6384 | 6377 |
6385 code_space_ = | 6378 code_space_ = |
6386 new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); | 6379 new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); |
6387 if (code_space_ == NULL) return false; | 6380 if (code_space_ == NULL) return false; |
6388 if (!code_space_->SetUp()) return false; | 6381 if (!code_space_->SetUp()) return false; |
6389 | 6382 |
6390 // Initialize map space. | 6383 // Initialize map space. |
6391 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE); | 6384 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE); |
6392 if (map_space_ == NULL) return false; | 6385 if (map_space_ == NULL) return false; |
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7620 static_cast<int>(object_sizes_last_time_[index])); | 7613 static_cast<int>(object_sizes_last_time_[index])); |
7621 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7614 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
7622 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7615 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7623 | 7616 |
7624 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7617 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7625 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7618 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7626 ClearObjectStats(); | 7619 ClearObjectStats(); |
7627 } | 7620 } |
7628 | 7621 |
7629 } } // namespace v8::internal | 7622 } } // namespace v8::internal |
OLD | NEW |