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

Unified Diff: src/heap/spaces.cc

Issue 1351983002: [heap] refactor inline allocation step code (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix the additional nit Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/spaces.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index c74b93f52c1672417ffbf9d250ffebee234b8b76..a74ee978c945313b38ed85742f50183feaf48d75 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -1400,12 +1400,7 @@ void NewSpace::ResetAllocationInfo() {
while (it.has_next()) {
Bitmap::Clear(it.next());
}
- if (top_on_previous_step_) {
- int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_);
- heap()->incremental_marking()->Step(bytes_allocated,
- IncrementalMarking::GC_VIA_STACK_GUARD);
- top_on_previous_step_ = allocation_info_.top();
- }
+ InlineAllocationStep(old_top, allocation_info_.top());
}
@@ -1484,13 +1479,7 @@ bool NewSpace::EnsureAllocation(int size_in_bytes,
return false;
}
- if (top_on_previous_step_) {
- // Do a step for the bytes allocated on the last page.
- int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_);
- heap()->incremental_marking()->Step(
- bytes_allocated, IncrementalMarking::GC_VIA_STACK_GUARD);
- top_on_previous_step_ = allocation_info_.top();
- }
+ InlineAllocationStep(old_top, allocation_info_.top());
old_top = allocation_info_.top();
high = to_space_.page_high();
@@ -1504,19 +1493,23 @@ bool NewSpace::EnsureAllocation(int size_in_bytes,
// Either the limit has been lowered because linear allocation was disabled
// or because incremental marking wants to get a chance to do a step. Set
// the new limit accordingly.
- if (top_on_previous_step_) {
- Address new_top = old_top + aligned_size_in_bytes;
- int bytes_allocated = static_cast<int>(new_top - top_on_previous_step_);
- heap()->incremental_marking()->Step(
- bytes_allocated, IncrementalMarking::GC_VIA_STACK_GUARD);
- top_on_previous_step_ = new_top;
- }
+ Address new_top = old_top + aligned_size_in_bytes;
+ InlineAllocationStep(new_top, new_top);
UpdateInlineAllocationLimit(aligned_size_in_bytes);
}
return true;
}
+void NewSpace::InlineAllocationStep(Address top, Address new_top) {
+ if (top_on_previous_step_) {
+ int bytes_allocated = static_cast<int>(top - top_on_previous_step_);
+ heap()->incremental_marking()->Step(bytes_allocated,
+ IncrementalMarking::GC_VIA_STACK_GUARD);
+ top_on_previous_step_ = new_top;
+ }
+}
+
#ifdef VERIFY_HEAP
// We do not use the SemiSpaceIterator because verification doesn't assume
// that it works (it depends on the invariants we are checking).
« no previous file with comments | « src/heap/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698