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());
}
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();
// 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).
bool EnsureAllocation(int size_in_bytes, AllocationAlignment alignment);
+ // If we are doing inline allocation in steps, this method performs the 'step'
+ // operation. Right now incremental marking is the only consumer of inline
+ // allocation steps. top is the memory address of the bump pointer at the last
+ // inline allocation (i.e. it determines the numbers of bytes actually
+ // allocated since the last step.) new_top is the address of the bump pointer
+ // where the next byte is going to be allocated from. top and new_top may be
+ // different when we cross a page boundary or reset the space.
+ void InlineAllocationStep(Address top, Address new_top);
+
friend class SemiSpaceIterator;
};