Commit 471dd3ac authored by ofrobots's avatar ofrobots Committed by Commit bot

[heap] pause observers during mark-compact

Inline allocations performed during mark compact aren't real allocations. They
should not trigger inline-allocation-observer notifications.

R=hpayer@chromium.org, ulan@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1465223009

Cr-Commit-Position: refs/heads/master@{#32566}
parent 10910bc4
......@@ -1380,6 +1380,8 @@ void Heap::CallGCEpilogueCallbacks(GCType gc_type,
void Heap::MarkCompact() {
PauseInlineAllocationObserversScope pause_observers(new_space());
gc_state_ = MARK_COMPACT;
LOG(isolate_, ResourceEvent("markcompact", "begin"));
......@@ -1584,7 +1586,7 @@ void Heap::Scavenge() {
// Bump-pointer allocations done during scavenge are not real allocations.
// Pause the inline allocation steps.
new_space()->PauseInlineAllocationObservers();
PauseInlineAllocationObserversScope pause_observers(new_space());
#ifdef VERIFY_HEAP
if (FLAG_verify_heap) VerifyNonPointerSpacePointers(this);
......@@ -1715,8 +1717,6 @@ void Heap::Scavenge() {
// Set age mark.
new_space_.set_age_mark(new_space_.top());
new_space()->ResumeInlineAllocationObservers();
array_buffer_tracker()->FreeDead(true);
// Update how much has survived scavenge.
......
......@@ -1604,10 +1604,11 @@ bool NewSpace::EnsureAllocation(int size_in_bytes,
void NewSpace::StartNextInlineAllocationStep() {
DCHECK(!inline_allocation_observers_paused_);
top_on_previous_step_ =
inline_allocation_observers_.length() ? allocation_info_.top() : 0;
UpdateInlineAllocationLimit(0);
if (!inline_allocation_observers_paused_) {
top_on_previous_step_ =
inline_allocation_observers_.length() ? allocation_info_.top() : 0;
UpdateInlineAllocationLimit(0);
}
}
......
......@@ -2755,9 +2755,6 @@ class NewSpace : public Space {
// Removes a previously installed observer.
void RemoveInlineAllocationObserver(InlineAllocationObserver* observer);
void PauseInlineAllocationObservers();
void ResumeInlineAllocationObservers();
void DisableInlineAllocationSteps() {
top_on_previous_step_ = 0;
UpdateInlineAllocationLimit(0);
......@@ -2879,10 +2876,28 @@ class NewSpace : public Space {
size_t size);
intptr_t GetNextInlineAllocationStepSize();
void StartNextInlineAllocationStep();
void PauseInlineAllocationObservers();
void ResumeInlineAllocationObservers();
friend class PauseInlineAllocationObserversScope;
friend class SemiSpaceIterator;
};
class PauseInlineAllocationObserversScope {
public:
explicit PauseInlineAllocationObserversScope(NewSpace* new_space)
: new_space_(new_space) {
new_space_->PauseInlineAllocationObservers();
}
~PauseInlineAllocationObserversScope() {
new_space_->ResumeInlineAllocationObservers();
}
private:
NewSpace* new_space_;
DISALLOW_COPY_AND_ASSIGN(PauseInlineAllocationObserversScope);
};
// -----------------------------------------------------------------------------
// Compaction space that is used temporarily during compaction.
......
......@@ -872,14 +872,15 @@ UNINITIALIZED_TEST(InlineAllocationObserver) {
CHECK_EQ(observer1.count(), 20); // no more notifications.
CHECK_EQ(observer2.count(), 3); // this one is still active.
// Ensure that Pause/ResumeInlineAllocationObservers work correctly.
// Ensure that PauseInlineAllocationObserversScope work correctly.
AllocateUnaligned(new_space, 48);
CHECK_EQ(observer2.count(), 3);
new_space->PauseInlineAllocationObservers();
CHECK_EQ(observer2.count(), 3);
AllocateUnaligned(new_space, 384);
CHECK_EQ(observer2.count(), 3);
new_space->ResumeInlineAllocationObservers();
{
PauseInlineAllocationObserversScope pause_observers(new_space);
CHECK_EQ(observer2.count(), 3);
AllocateUnaligned(new_space, 384);
CHECK_EQ(observer2.count(), 3);
}
CHECK_EQ(observer2.count(), 3);
// Coupled with the 48 bytes allocated before the pause, another 48 bytes
// allocated here should trigger a notification.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment