Commit 4af3b775 authored by Keishi Hattori's avatar Keishi Hattori Committed by Commit Bot

Oilpan: Use InAtomicMarkingPause to remove GCForbidenScope and NoAllocationScope usage

Use InAtomicMarkingPause to remove GCForbidenScope and NoAllocationScope usage

Change-Id: If723098063ea02d80dee0ae38257cdfa40959d66
Reviewed-on: https://chromium-review.googlesource.com/978792
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546002}
parent aeecb4f3
...@@ -4007,7 +4007,6 @@ TEST(HeapTest, CheckAndMarkPointer) { ...@@ -4007,7 +4007,6 @@ TEST(HeapTest, CheckAndMarkPointer) {
// to allocate anything again. We do this by forcing a GC after doing the // to allocate anything again. We do this by forcing a GC after doing the
// checkAndMarkPointer tests. // checkAndMarkPointer tests.
{ {
ThreadState::GCForbiddenScope gc_scope(ThreadState::Current());
TestGCScope scope(BlinkGC::kHeapPointersOnStack); TestGCScope scope(BlinkGC::kHeapPointersOnStack);
MarkingVisitor visitor(ThreadState::Current(), MarkingVisitor visitor(ThreadState::Current(),
MarkingVisitor::kGlobalMarking); MarkingVisitor::kGlobalMarking);
...@@ -4032,7 +4031,6 @@ TEST(HeapTest, CheckAndMarkPointer) { ...@@ -4032,7 +4031,6 @@ TEST(HeapTest, CheckAndMarkPointer) {
// however we don't rely on that below since we don't have any allocations. // however we don't rely on that below since we don't have any allocations.
ClearOutOldGarbage(); ClearOutOldGarbage();
{ {
ThreadState::GCForbiddenScope gc_scope(ThreadState::Current());
TestGCScope scope(BlinkGC::kHeapPointersOnStack); TestGCScope scope(BlinkGC::kHeapPointersOnStack);
MarkingVisitor visitor(ThreadState::Current(), MarkingVisitor visitor(ThreadState::Current(),
MarkingVisitor::kGlobalMarking); MarkingVisitor::kGlobalMarking);
......
...@@ -25,9 +25,7 @@ MarkingVisitor::MarkingVisitor(ThreadState* state, MarkingMode marking_mode) ...@@ -25,9 +25,7 @@ MarkingVisitor::MarkingVisitor(ThreadState* state, MarkingMode marking_mode)
weak_callback_worklist_(Heap().GetWeakCallbackWorklist(), weak_callback_worklist_(Heap().GetWeakCallbackWorklist(),
WorklistTaskId::MainThread), WorklistTaskId::MainThread),
marking_mode_(marking_mode) { marking_mode_(marking_mode) {
// See ThreadState::runScheduledGC() why we need to already be in a DCHECK(state->InAtomicMarkingPause());
// GCForbiddenScope before any safe point is entered.
DCHECK(state->IsGCForbidden());
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
DCHECK(state->CheckThread()); DCHECK(state->CheckThread());
#endif // DCHECK_IS_ON #endif // DCHECK_IS_ON
......
...@@ -1302,8 +1302,6 @@ void ThreadState::CollectGarbage(BlinkGC::StackState stack_state, ...@@ -1302,8 +1302,6 @@ void ThreadState::CollectGarbage(BlinkGC::StackState stack_state,
RUNTIME_CALL_TIMER_SCOPE_IF_ISOLATE_EXISTS( RUNTIME_CALL_TIMER_SCOPE_IF_ISOLATE_EXISTS(
GetIsolate(), RuntimeCallStats::CounterId::kCollectGarbage); GetIsolate(), RuntimeCallStats::CounterId::kCollectGarbage);
GCForbiddenScope gc_forbidden_scope(this);
{ {
AtomicPauseScope atomic_pause_scope(this); AtomicPauseScope atomic_pause_scope(this);
{ {
...@@ -1403,9 +1401,6 @@ void ThreadState::MarkPhasePrologue(BlinkGC::StackState stack_state, ...@@ -1403,9 +1401,6 @@ void ThreadState::MarkPhasePrologue(BlinkGC::StackState stack_state,
void ThreadState::MarkPhaseVisitRoots() { void ThreadState::MarkPhaseVisitRoots() {
double start_time = WTF::CurrentTimeTicksInMilliseconds(); double start_time = WTF::CurrentTimeTicksInMilliseconds();
// Disallow allocation during garbage collection (but not during the
// finalization that happens when the visitorScope is torn down).
NoAllocationScope no_allocation_scope(this);
// StackFrameDepth should be disabled so we don't trace most of the object // StackFrameDepth should be disabled so we don't trace most of the object
// graph in one incremental marking step. // graph in one incremental marking step.
DCHECK(!Heap().GetStackFrameDepth().IsEnabled()); DCHECK(!Heap().GetStackFrameDepth().IsEnabled());
...@@ -1428,9 +1423,6 @@ void ThreadState::MarkPhaseVisitRoots() { ...@@ -1428,9 +1423,6 @@ void ThreadState::MarkPhaseVisitRoots() {
bool ThreadState::MarkPhaseAdvanceMarking(double deadline_seconds) { bool ThreadState::MarkPhaseAdvanceMarking(double deadline_seconds) {
double start_time = WTF::CurrentTimeTicksInMilliseconds(); double start_time = WTF::CurrentTimeTicksInMilliseconds();
// Disallow allocation during garbage collection (but not during the
// finalization that happens when the visitorScope is torn down).
NoAllocationScope no_allocation_scope(this);
StackFrameDepthScope stack_depth_scope(&Heap().GetStackFrameDepth()); StackFrameDepthScope stack_depth_scope(&Heap().GetStackFrameDepth());
// 3. Transitive closure to trace objects including ephemerons. // 3. Transitive closure to trace objects including ephemerons.
......
...@@ -320,7 +320,11 @@ class PLATFORM_EXPORT ThreadState { ...@@ -320,7 +320,11 @@ class PLATFORM_EXPORT ThreadState {
// Support for disallowing allocation. Mainly used for sanity // Support for disallowing allocation. Mainly used for sanity
// checks asserts. // checks asserts.
bool IsAllocationAllowed() const { return !no_allocation_count_; } bool IsAllocationAllowed() const {
// Allocation is not allowed during atomic marking pause, but it is allowed
// during atomic sweeping pause.
return !InAtomicMarkingPause() && !no_allocation_count_;
}
void EnterNoAllocationScope() { no_allocation_count_++; } void EnterNoAllocationScope() { no_allocation_count_++; }
void LeaveNoAllocationScope() { no_allocation_count_--; } void LeaveNoAllocationScope() { no_allocation_count_--; }
bool IsWrapperTracingForbidden() { return IsMixinInConstruction(); } bool IsWrapperTracingForbidden() { return IsMixinInConstruction(); }
...@@ -406,7 +410,7 @@ class PLATFORM_EXPORT ThreadState { ...@@ -406,7 +410,7 @@ class PLATFORM_EXPORT ThreadState {
class AtomicPauseScope final { class AtomicPauseScope final {
public: public:
explicit AtomicPauseScope(ThreadState* thread_state) explicit AtomicPauseScope(ThreadState* thread_state)
: thread_state_(thread_state) { : thread_state_(thread_state), gc_forbidden_scope(thread_state) {
thread_state_->EnterAtomicPause(); thread_state_->EnterAtomicPause();
} }
~AtomicPauseScope() { thread_state_->LeaveAtomicPause(); } ~AtomicPauseScope() { thread_state_->LeaveAtomicPause(); }
...@@ -414,6 +418,7 @@ class PLATFORM_EXPORT ThreadState { ...@@ -414,6 +418,7 @@ class PLATFORM_EXPORT ThreadState {
private: private:
ThreadState* const thread_state_; ThreadState* const thread_state_;
ScriptForbiddenScope script_forbidden_scope; ScriptForbiddenScope script_forbidden_scope;
GCForbiddenScope gc_forbidden_scope;
}; };
void FlushHeapDoesNotContainCacheIfNeeded(); void FlushHeapDoesNotContainCacheIfNeeded();
......
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