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

Side by Side Diff: src/heap.cc

Issue 202017: Do not use left-over space after new space alignment for other spaces.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 3 months 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3167 matching lines...) Expand 10 before | Expand all | Expand 10 after
3178 // call Heap::TearDown() to release allocated memory. 3178 // call Heap::TearDown() to release allocated memory.
3179 // 3179 //
3180 // If the heap is not yet configured (eg, through the API), configure it. 3180 // If the heap is not yet configured (eg, through the API), configure it.
3181 // Configuration is based on the flags new-space-size (really the semispace 3181 // Configuration is based on the flags new-space-size (really the semispace
3182 // size) and old-space-size if set or the initial values of semispace_size_ 3182 // size) and old-space-size if set or the initial values of semispace_size_
3183 // and old_generation_size_ otherwise. 3183 // and old_generation_size_ otherwise.
3184 if (!heap_configured) { 3184 if (!heap_configured) {
3185 if (!ConfigureHeapDefault()) return false; 3185 if (!ConfigureHeapDefault()) return false;
3186 } 3186 }
3187 3187
3188 // Setup memory allocator and allocate an initial chunk of memory. The 3188 // Setup memory allocator and reserve a chunk of memory for new
3189 // initial chunk is double the size of the new space to ensure that we can 3189 // space. The chunk is double the size of the new space to ensure
3190 // find a pair of semispaces that are contiguous and aligned to their size. 3190 // that we can find a pair of semispaces that are contiguous and
3191 // aligned to their size.
3191 if (!MemoryAllocator::Setup(MaxCapacity())) return false; 3192 if (!MemoryAllocator::Setup(MaxCapacity())) return false;
3192 void* chunk 3193 void* chunk =
3193 = MemoryAllocator::ReserveInitialChunk(2 * young_generation_size_); 3194 MemoryAllocator::ReserveInitialChunk(2 * young_generation_size_);
3194 if (chunk == NULL) return false; 3195 if (chunk == NULL) return false;
3195 3196
3196 // Put the initial chunk of the old space at the start of the initial 3197 // Align the pair of semispaces to their size, which must be a power
3197 // chunk, then the two new space semispaces, then the initial chunk of 3198 // of 2.
3198 // code space. Align the pair of semispaces to their size, which must be
3199 // a power of 2.
3200 ASSERT(IsPowerOf2(young_generation_size_)); 3199 ASSERT(IsPowerOf2(young_generation_size_));
3201 Address code_space_start = reinterpret_cast<Address>(chunk); 3200 Address new_space_start =
3202 Address new_space_start = RoundUp(code_space_start, young_generation_size_); 3201 RoundUp(reinterpret_cast<byte*>(chunk), young_generation_size_);
3203 Address old_space_start = new_space_start + young_generation_size_;
3204 int code_space_size = new_space_start - code_space_start;
3205 int old_space_size = young_generation_size_ - code_space_size;
3206
3207 // Initialize new space.
3208 if (!new_space_.Setup(new_space_start, young_generation_size_)) return false; 3202 if (!new_space_.Setup(new_space_start, young_generation_size_)) return false;
3209 3203
3210 // Initialize old space, set the maximum capacity to the old generation 3204 // Initialize old pointer space.
3211 // size. It will not contain code.
3212 old_pointer_space_ = 3205 old_pointer_space_ =
3213 new OldSpace(old_generation_size_, OLD_POINTER_SPACE, NOT_EXECUTABLE); 3206 new OldSpace(old_generation_size_, OLD_POINTER_SPACE, NOT_EXECUTABLE);
3214 if (old_pointer_space_ == NULL) return false; 3207 if (old_pointer_space_ == NULL) return false;
3215 if (!old_pointer_space_->Setup(old_space_start, old_space_size >> 1)) { 3208 if (!old_pointer_space_->Setup(NULL, 0)) return false;
3216 return false; 3209
3217 } 3210 // Initialize old data space.
3218 old_data_space_ = 3211 old_data_space_ =
3219 new OldSpace(old_generation_size_, OLD_DATA_SPACE, NOT_EXECUTABLE); 3212 new OldSpace(old_generation_size_, OLD_DATA_SPACE, NOT_EXECUTABLE);
3220 if (old_data_space_ == NULL) return false; 3213 if (old_data_space_ == NULL) return false;
3221 if (!old_data_space_->Setup(old_space_start + (old_space_size >> 1), 3214 if (!old_data_space_->Setup(NULL, 0)) return false;
3222 old_space_size >> 1)) {
3223 return false;
3224 }
3225 3215
3226 // Initialize the code space, set its maximum capacity to the old 3216 // Initialize the code space, set its maximum capacity to the old
3227 // generation size. It needs executable memory. 3217 // generation size. It needs executable memory.
3228 code_space_ = 3218 code_space_ =
3229 new OldSpace(old_generation_size_, CODE_SPACE, EXECUTABLE); 3219 new OldSpace(old_generation_size_, CODE_SPACE, EXECUTABLE);
3230 if (code_space_ == NULL) return false; 3220 if (code_space_ == NULL) return false;
3231 if (!code_space_->Setup(code_space_start, code_space_size)) return false; 3221 if (!code_space_->Setup(NULL, 0)) return false;
3232 3222
3233 // Initialize map space. 3223 // Initialize map space.
3234 map_space_ = new MapSpace(kMaxMapSpaceSize, MAP_SPACE); 3224 map_space_ = new MapSpace(kMaxMapSpaceSize, MAP_SPACE);
3235 if (map_space_ == NULL) return false; 3225 if (map_space_ == NULL) return false;
3236 // Setting up a paged space without giving it a virtual memory range big
3237 // enough to hold at least a page will cause it to allocate.
3238 if (!map_space_->Setup(NULL, 0)) return false; 3226 if (!map_space_->Setup(NULL, 0)) return false;
3239 3227
3240 // Initialize global property cell space. 3228 // Initialize global property cell space.
3241 cell_space_ = new CellSpace(old_generation_size_, CELL_SPACE); 3229 cell_space_ = new CellSpace(old_generation_size_, CELL_SPACE);
3242 if (cell_space_ == NULL) return false; 3230 if (cell_space_ == NULL) return false;
3243 // Setting up a paged space without giving it a virtual memory range big
3244 // enough to hold at least a page will cause it to allocate.
3245 if (!cell_space_->Setup(NULL, 0)) return false; 3231 if (!cell_space_->Setup(NULL, 0)) return false;
3246 3232
3247 // The large object code space may contain code or data. We set the memory 3233 // The large object code space may contain code or data. We set the memory
3248 // to be non-executable here for safety, but this means we need to enable it 3234 // to be non-executable here for safety, but this means we need to enable it
3249 // explicitly when allocating large code objects. 3235 // explicitly when allocating large code objects.
3250 lo_space_ = new LargeObjectSpace(LO_SPACE); 3236 lo_space_ = new LargeObjectSpace(LO_SPACE);
3251 if (lo_space_ == NULL) return false; 3237 if (lo_space_ == NULL) return false;
3252 if (!lo_space_->Setup()) return false; 3238 if (!lo_space_->Setup()) return false;
3253 3239
3254 if (create_heap_objects) { 3240 if (create_heap_objects) {
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
4007 for (int i = 0; i < kNumberOfCaches; i++) { 3993 for (int i = 0; i < kNumberOfCaches; i++) {
4008 if (caches_[i] != NULL) { 3994 if (caches_[i] != NULL) {
4009 delete caches_[i]; 3995 delete caches_[i];
4010 caches_[i] = NULL; 3996 caches_[i] = NULL;
4011 } 3997 }
4012 } 3998 }
4013 } 3999 }
4014 4000
4015 4001
4016 } } // namespace v8::internal 4002 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698