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

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

Issue 1265443003: remove recursion from NewSpace::AllocateRaw* (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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
« src/heap/spaces.cc ('K') | « src/heap/spaces.cc ('k') | 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HEAP_SPACES_INL_H_ 5 #ifndef V8_HEAP_SPACES_INL_H_
6 #define V8_HEAP_SPACES_INL_H_ 6 #define V8_HEAP_SPACES_INL_H_
7 7
8 #include "src/heap/spaces.h" 8 #include "src/heap/spaces.h"
9 #include "src/heap-profiler.h" 9 #include "src/heap-profiler.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 #endif 338 #endif
339 } 339 }
340 340
341 341
342 // ----------------------------------------------------------------------------- 342 // -----------------------------------------------------------------------------
343 // NewSpace 343 // NewSpace
344 344
345 345
346 AllocationResult NewSpace::AllocateRawAligned(int size_in_bytes, 346 AllocationResult NewSpace::AllocateRawAligned(int size_in_bytes,
347 AllocationAlignment alignment) { 347 AllocationAlignment alignment) {
348 Address old_top = allocation_info_.top(); 348 int filler_size = Heap::GetFillToAlign(allocation_info_.top(), alignment);
Hannes Payer (out of office) 2015/07/30 10:38:25 Keep top in a temporary variable.
ofrobots 2015/07/30 20:26:17 Done.
349 int filler_size = Heap::GetFillToAlign(old_top, alignment);
350 int aligned_size_in_bytes = size_in_bytes + filler_size; 349 int aligned_size_in_bytes = size_in_bytes + filler_size;
351 350
352 if (allocation_info_.limit() - old_top < aligned_size_in_bytes) { 351 if (allocation_info_.limit() - allocation_info_.top() <
353 return SlowAllocateRaw(size_in_bytes, alignment); 352 aligned_size_in_bytes) {
353 // See if we can create room.
354 if (EnsureAllocation(size_in_bytes, alignment) == false) {
Hannes Payer (out of office) 2015/07/30 10:38:25 Instead of "== false" use "!".
ofrobots 2015/07/30 20:26:17 Done.
355 return AllocationResult::Retry();
356 }
357
Hannes Payer (out of office) 2015/07/30 10:38:25 if top changed, read out top again and recalculate
ofrobots 2015/07/30 20:26:17 Done.
358 if (allocation_info_.limit() - allocation_info_.top() <
359 aligned_size_in_bytes) {
Hannes Payer (out of office) 2015/07/30 10:38:25 This check should not be needed.
ofrobots 2015/07/30 20:26:17 Done.
360 // Still not enough room.
361 return AllocationResult::Retry();
362 }
354 } 363 }
355 364
356 HeapObject* obj = HeapObject::FromAddress(old_top); 365 HeapObject* obj = HeapObject::FromAddress(allocation_info_.top());
Hannes Payer (out of office) 2015/07/30 10:38:25 Use the temporary top variable here.
ofrobots 2015/07/30 20:26:17 Done.
357 allocation_info_.set_top(allocation_info_.top() + aligned_size_in_bytes); 366 allocation_info_.set_top(allocation_info_.top() + aligned_size_in_bytes);
358 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); 367 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
359 368
360 if (filler_size > 0) { 369 if (filler_size > 0) {
361 obj = heap()->PrecedeWithFiller(obj, filler_size); 370 obj = heap()->PrecedeWithFiller(obj, filler_size);
362 } 371 }
363 372
364 // The slow path above ultimately goes through AllocateRaw, so this suffices.
365 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(obj->address(), size_in_bytes); 373 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(obj->address(), size_in_bytes);
366 374
367 return obj; 375 return obj;
368 } 376 }
369 377
370 378
371 AllocationResult NewSpace::AllocateRawUnaligned(int size_in_bytes) { 379 AllocationResult NewSpace::AllocateRawUnaligned(int size_in_bytes) {
Hannes Payer (out of office) 2015/07/30 10:38:25 Comments from above apply also here.
ofrobots 2015/07/30 20:26:16 Done.
372 Address old_top = allocation_info_.top(); 380 if (allocation_info_.limit() - allocation_info_.top() < size_in_bytes) {
381 // See if we can create room.
382 if (EnsureAllocation(size_in_bytes, kWordAligned) == false) {
383 return AllocationResult::Retry();
384 }
373 385
374 if (allocation_info_.limit() - old_top < size_in_bytes) { 386 if (allocation_info_.limit() - allocation_info_.top() < size_in_bytes) {
375 return SlowAllocateRaw(size_in_bytes, kWordAligned); 387 // Still not enough room.
388 return AllocationResult::Retry();
389 }
376 } 390 }
377 391
378 HeapObject* obj = HeapObject::FromAddress(old_top); 392 HeapObject* obj = HeapObject::FromAddress(allocation_info_.top());
379 allocation_info_.set_top(allocation_info_.top() + size_in_bytes); 393 allocation_info_.set_top(allocation_info_.top() + size_in_bytes);
380 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); 394 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
381 395
382 // The slow path above ultimately goes through AllocateRaw, so this suffices.
383 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(obj->address(), size_in_bytes); 396 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(obj->address(), size_in_bytes);
384 397
385 return obj; 398 return obj;
386 } 399 }
387 400
388 401
389 AllocationResult NewSpace::AllocateRaw(int size_in_bytes, 402 AllocationResult NewSpace::AllocateRaw(int size_in_bytes,
390 AllocationAlignment alignment) { 403 AllocationAlignment alignment) {
391 #ifdef V8_HOST_ARCH_32_BIT 404 #ifdef V8_HOST_ARCH_32_BIT
392 return alignment == kDoubleAligned 405 return alignment == kDoubleAligned
(...skipping 12 matching lines...) Expand all
405 418
406 419
407 intptr_t LargeObjectSpace::Available() { 420 intptr_t LargeObjectSpace::Available() {
408 return ObjectSizeFor(heap()->isolate()->memory_allocator()->Available()); 421 return ObjectSizeFor(heap()->isolate()->memory_allocator()->Available());
409 } 422 }
410 423
411 } 424 }
412 } // namespace v8::internal 425 } // namespace v8::internal
413 426
414 #endif // V8_HEAP_SPACES_INL_H_ 427 #endif // V8_HEAP_SPACES_INL_H_
OLDNEW
« src/heap/spaces.cc ('K') | « src/heap/spaces.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698