Reviewers: Hannes Payer,
Description:
improve allocation accounting for incremental mark
Add an assertion that allocated_bytes >=0 in IncrementalMark::Step and then
make it pass.
We were not being diligent in maintaining top_on_previous_step_ and as a
result inaccurate, and even negative values of allocated_bytes were being
reported to Step.
I need the value of allocated_bytes allocated on each step to be accurate
to enable some follow-on work I am planning to do.
BUG=
R=hpa...@chromium.org
Please review this at https://codereview.chromium.org/1252053003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+14, -7 lines):
M src/heap/incremental-marking.cc
M src/heap/spaces.h
M src/heap/spaces.cc
Index: src/heap/incremental-marking.cc
diff --git a/src/heap/incremental-marking.cc
b/src/heap/incremental-marking.cc
index
22051eaab2d5793681dbd6ba3df3ccfd1495dfec..fdf85a78d583f14aef57a32e3c8664eb7f8fa438
100644
--- a/src/heap/incremental-marking.cc
+++ b/src/heap/incremental-marking.cc
@@ -909,6 +909,8 @@ intptr_t IncrementalMarking::Step(intptr_t
allocated_bytes,
CompletionAction action,
ForceMarkingAction marking,
ForceCompletionAction completion) {
+ DCHECK(allocated_bytes >= 0);
+
if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking ||
!FLAG_incremental_marking_steps ||
(state_ != SWEEPING && state_ != MARKING)) {
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index
dfaac73ffd10a4c7722a4ebd70d33bb8aa7d063a..07be9fa076372d8ce0d0d6a16b425d5f1e40d572
100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -1400,6 +1400,10 @@ void NewSpace::ResetAllocationInfo() {
while (it.has_next()) {
Bitmap::Clear(it.next());
}
+ if (top_on_previous_step_) {
+ // Start a new step.
+ top_on_previous_step_ = allocation_info_.top();
+ }
}
@@ -1478,18 +1482,19 @@ AllocationResult NewSpace::SlowAllocateRaw(int
size_in_bytes,
// the new limit accordingly.
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);
UpdateInlineAllocationLimit(aligned_size_in_bytes);
+
+ AllocationResult result =
+ (alignment == kWordAligned)
+ ? AllocateRawUnaligned(size_in_bytes)
+ : AllocateRawAligned(size_in_bytes, alignment);
top_on_previous_step_ = new_top;
- if (alignment == kWordAligned) return
AllocateRawUnaligned(size_in_bytes);
- return AllocateRawAligned(size_in_bytes, alignment);
+ return result;
} else if (AddFreshPage()) {
// Switched to new page. Try allocating again.
- 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_ = to_space_.page_low();
if (alignment == kWordAligned) return
AllocateRawUnaligned(size_in_bytes);
return AllocateRawAligned(size_in_bytes, alignment);
} else {
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index
3461de3ef009f18d9549a8de8f18ce831ba2f572..ea56e6887f6076a0430b0f97d694323140bf67b6
100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -2534,7 +2534,7 @@ class NewSpace : public Space {
void LowerInlineAllocationLimit(intptr_t step) {
inline_allocation_limit_step_ = step;
UpdateInlineAllocationLimit(0);
- top_on_previous_step_ = allocation_info_.top();
+ top_on_previous_step_ = step ? allocation_info_.top() : 0;
}
// Get the extent of the inactive semispace (for use as a marking stack,
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.