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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« src/heap/spaces.cc ('K') | « src/heap/spaces.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces-inl.h
diff --git a/src/heap/spaces-inl.h b/src/heap/spaces-inl.h
index f2bdbfcfa0aaf561b9fa8382633731e335204834..b1dc05d27f44417eab76230a55d3fe0f69fed743 100644
--- a/src/heap/spaces-inl.h
+++ b/src/heap/spaces-inl.h
@@ -345,15 +345,24 @@ AllocationResult PagedSpace::AllocateRaw(int size_in_bytes,
AllocationResult NewSpace::AllocateRawAligned(int size_in_bytes,
AllocationAlignment alignment) {
- Address old_top = allocation_info_.top();
- int filler_size = Heap::GetFillToAlign(old_top, alignment);
+ 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.
int aligned_size_in_bytes = size_in_bytes + filler_size;
- if (allocation_info_.limit() - old_top < aligned_size_in_bytes) {
- return SlowAllocateRaw(size_in_bytes, alignment);
+ if (allocation_info_.limit() - allocation_info_.top() <
+ aligned_size_in_bytes) {
+ // See if we can create room.
+ 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.
+ return AllocationResult::Retry();
+ }
+
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.
+ if (allocation_info_.limit() - allocation_info_.top() <
+ 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.
+ // Still not enough room.
+ return AllocationResult::Retry();
+ }
}
- HeapObject* obj = HeapObject::FromAddress(old_top);
+ 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.
allocation_info_.set_top(allocation_info_.top() + aligned_size_in_bytes);
DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
@@ -361,7 +370,6 @@ AllocationResult NewSpace::AllocateRawAligned(int size_in_bytes,
obj = heap()->PrecedeWithFiller(obj, filler_size);
}
- // The slow path above ultimately goes through AllocateRaw, so this suffices.
MSAN_ALLOCATED_UNINITIALIZED_MEMORY(obj->address(), size_in_bytes);
return obj;
@@ -369,17 +377,22 @@ AllocationResult NewSpace::AllocateRawAligned(int size_in_bytes,
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.
- Address old_top = allocation_info_.top();
+ if (allocation_info_.limit() - allocation_info_.top() < size_in_bytes) {
+ // See if we can create room.
+ if (EnsureAllocation(size_in_bytes, kWordAligned) == false) {
+ return AllocationResult::Retry();
+ }
- if (allocation_info_.limit() - old_top < size_in_bytes) {
- return SlowAllocateRaw(size_in_bytes, kWordAligned);
+ if (allocation_info_.limit() - allocation_info_.top() < size_in_bytes) {
+ // Still not enough room.
+ return AllocationResult::Retry();
+ }
}
- HeapObject* obj = HeapObject::FromAddress(old_top);
+ HeapObject* obj = HeapObject::FromAddress(allocation_info_.top());
allocation_info_.set_top(allocation_info_.top() + size_in_bytes);
DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
- // The slow path above ultimately goes through AllocateRaw, so this suffices.
MSAN_ALLOCATED_UNINITIALIZED_MEMORY(obj->address(), size_in_bytes);
return obj;
« 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