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

Side by Side Diff: src/heap-inl.h

Issue 14208005: Use worst-fit allocation in old space for prentured objects. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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 | « src/heap.cc ('k') | src/mark-compact.cc » ('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 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return Failure::OutOfMemoryException(0x2); 138 return Failure::OutOfMemoryException(0x2);
139 } 139 }
140 // Compute map and object size. 140 // Compute map and object size.
141 Map* map = ascii_internalized_string_map(); 141 Map* map = ascii_internalized_string_map();
142 int size = SeqOneByteString::SizeFor(str.length()); 142 int size = SeqOneByteString::SizeFor(str.length());
143 143
144 // Allocate string. 144 // Allocate string.
145 Object* result; 145 Object* result;
146 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize) 146 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize)
147 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) 147 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE)
148 : old_data_space_->AllocateRaw(size); 148 : old_data_space_->AllocateRaw<FreeList::BEST_FIT>(size);
149 if (!maybe_result->ToObject(&result)) return maybe_result; 149 if (!maybe_result->ToObject(&result)) return maybe_result;
150 } 150 }
151 151
152 // String maps are all immortal immovable objects. 152 // String maps are all immortal immovable objects.
153 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map); 153 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map);
154 // Set length and hash fields of the allocated string. 154 // Set length and hash fields of the allocated string.
155 String* answer = String::cast(result); 155 String* answer = String::cast(result);
156 answer->set_length(str.length()); 156 answer->set_length(str.length());
157 answer->set_hash_field(hash_field); 157 answer->set_hash_field(hash_field);
158 158
(...skipping 13 matching lines...) Expand all
172 return Failure::OutOfMemoryException(0x3); 172 return Failure::OutOfMemoryException(0x3);
173 } 173 }
174 // Compute map and object size. 174 // Compute map and object size.
175 Map* map = internalized_string_map(); 175 Map* map = internalized_string_map();
176 int size = SeqTwoByteString::SizeFor(str.length()); 176 int size = SeqTwoByteString::SizeFor(str.length());
177 177
178 // Allocate string. 178 // Allocate string.
179 Object* result; 179 Object* result;
180 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize) 180 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize)
181 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) 181 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE)
182 : old_data_space_->AllocateRaw(size); 182 : old_data_space_->AllocateRaw<FreeList::BEST_FIT>(size);
183 if (!maybe_result->ToObject(&result)) return maybe_result; 183 if (!maybe_result->ToObject(&result)) return maybe_result;
184 } 184 }
185 185
186 reinterpret_cast<HeapObject*>(result)->set_map(map); 186 reinterpret_cast<HeapObject*>(result)->set_map(map);
187 // Set length and hash fields of the allocated string. 187 // Set length and hash fields of the allocated string.
188 String* answer = String::cast(result); 188 String* answer = String::cast(result);
189 answer->set_length(str.length()); 189 answer->set_length(str.length());
190 answer->set_hash_field(hash_field); 190 answer->set_hash_field(hash_field);
191 191
192 ASSERT_EQ(size, answer->Size()); 192 ASSERT_EQ(size, answer->Size());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (NEW_SPACE == space) { 229 if (NEW_SPACE == space) {
230 result = new_space_.AllocateRaw(size_in_bytes); 230 result = new_space_.AllocateRaw(size_in_bytes);
231 if (always_allocate() && result->IsFailure()) { 231 if (always_allocate() && result->IsFailure()) {
232 space = retry_space; 232 space = retry_space;
233 } else { 233 } else {
234 return result; 234 return result;
235 } 235 }
236 } 236 }
237 237
238 if (OLD_POINTER_SPACE == space) { 238 if (OLD_POINTER_SPACE == space) {
239 result = old_pointer_space_->AllocateRaw(size_in_bytes); 239 result = old_pointer_space_->AllocateRaw<FreeList::BEST_FIT>(size_in_bytes);
240 } else if (OLD_DATA_SPACE == space) { 240 } else if (OLD_DATA_SPACE == space) {
241 result = old_data_space_->AllocateRaw(size_in_bytes); 241 result = old_data_space_->AllocateRaw<FreeList::BEST_FIT>(size_in_bytes);
242 } else if (CODE_SPACE == space) { 242 } else if (CODE_SPACE == space) {
243 result = code_space_->AllocateRaw(size_in_bytes); 243 result = code_space_->AllocateRaw<FreeList::BEST_FIT>(size_in_bytes);
244 } else if (LO_SPACE == space) { 244 } else if (LO_SPACE == space) {
245 result = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE); 245 result = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE);
246 } else if (CELL_SPACE == space) { 246 } else if (CELL_SPACE == space) {
247 result = cell_space_->AllocateRaw(size_in_bytes); 247 result = cell_space_->AllocateRaw<FreeList::BEST_FIT>(size_in_bytes);
248 } else { 248 } else {
249 ASSERT(MAP_SPACE == space); 249 ASSERT(MAP_SPACE == space);
250 result = map_space_->AllocateRaw(size_in_bytes); 250 result = map_space_->AllocateRaw<FreeList::BEST_FIT>(size_in_bytes);
251 } 251 }
252 if (result->IsFailure()) old_gen_exhausted_ = true; 252 if (result->IsFailure()) old_gen_exhausted_ = true;
253 return result; 253 return result;
254 } 254 }
255 255
256 256
257 MaybeObject* Heap::NumberFromInt32( 257 MaybeObject* Heap::NumberFromInt32(
258 int32_t value, PretenureFlag pretenure) { 258 int32_t value, PretenureFlag pretenure) {
259 if (Smi::IsValid(value)) return Smi::FromInt(value); 259 if (Smi::IsValid(value)) return Smi::FromInt(value);
260 // Bypass NumberFromDouble to avoid various redundant checks. 260 // Bypass NumberFromDouble to avoid various redundant checks.
(...skipping 26 matching lines...) Expand all
287 *resource_addr = NULL; 287 *resource_addr = NULL;
288 } 288 }
289 } 289 }
290 290
291 291
292 MaybeObject* Heap::AllocateRawMap() { 292 MaybeObject* Heap::AllocateRawMap() {
293 #ifdef DEBUG 293 #ifdef DEBUG
294 isolate_->counters()->objs_since_last_full()->Increment(); 294 isolate_->counters()->objs_since_last_full()->Increment();
295 isolate_->counters()->objs_since_last_young()->Increment(); 295 isolate_->counters()->objs_since_last_young()->Increment();
296 #endif 296 #endif
297 MaybeObject* result = map_space_->AllocateRaw(Map::kSize); 297 MaybeObject* result = map_space_->AllocateRaw<FreeList::BEST_FIT>(Map::kSize);
298 if (result->IsFailure()) old_gen_exhausted_ = true; 298 if (result->IsFailure()) old_gen_exhausted_ = true;
299 return result; 299 return result;
300 } 300 }
301 301
302 302
303 MaybeObject* Heap::AllocateRawCell() { 303 MaybeObject* Heap::AllocateRawCell() {
304 #ifdef DEBUG 304 #ifdef DEBUG
305 isolate_->counters()->objs_since_last_full()->Increment(); 305 isolate_->counters()->objs_since_last_full()->Increment();
306 isolate_->counters()->objs_since_last_young()->Increment(); 306 isolate_->counters()->objs_since_last_young()->Increment();
307 #endif 307 #endif
308 MaybeObject* result = cell_space_->AllocateRaw(JSGlobalPropertyCell::kSize); 308 MaybeObject* result =
309 cell_space_->AllocateRaw<FreeList::BEST_FIT>(JSGlobalPropertyCell::kSize);
309 if (result->IsFailure()) old_gen_exhausted_ = true; 310 if (result->IsFailure()) old_gen_exhausted_ = true;
310 return result; 311 return result;
311 } 312 }
312 313
313 314
314 bool Heap::InNewSpace(Object* object) { 315 bool Heap::InNewSpace(Object* object) {
315 bool result = new_space_.Contains(object); 316 bool result = new_space_.Contains(object);
316 ASSERT(!result || // Either not in new space 317 ASSERT(!result || // Either not in new space
317 gc_state_ != NOT_IN_GC || // ... or in the middle of GC 318 gc_state_ != NOT_IN_GC || // ... or in the middle of GC
318 InToSpace(object)); // ... or in to-space (where we allocate). 319 InToSpace(object)); // ... or in to-space (where we allocate).
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 AssertNoAllocation::~AssertNoAllocation() { } 897 AssertNoAllocation::~AssertNoAllocation() { }
897 DisableAssertNoAllocation::DisableAssertNoAllocation() { } 898 DisableAssertNoAllocation::DisableAssertNoAllocation() { }
898 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } 899 DisableAssertNoAllocation::~DisableAssertNoAllocation() { }
899 900
900 #endif 901 #endif
901 902
902 903
903 } } // namespace v8::internal 904 } } // namespace v8::internal
904 905
905 #endif // V8_HEAP_INL_H_ 906 #endif // V8_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698