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

Unified Diff: third_party/WebKit/Source/platform/heap/ThreadState.cpp

Issue 2692043008: Slightly tidy up the usage of SweepForbiddenScope and ScriptForbiddenScope (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/ThreadState.cpp
diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.cpp b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
index 2860b2c855581756d1d5312a3f0eee4e27b07b5c..16bdee265214e8ec5e6043ebfd81260c6a8a6fb1 100644
--- a/third_party/WebKit/Source/platform/heap/ThreadState.cpp
+++ b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
@@ -620,30 +620,27 @@ void ThreadState::performIdleLazySweep(double deadlineSeconds) {
"ThreadState::performIdleLazySweep", "idleDeltaInSeconds",
deadlineSeconds - monotonicallyIncreasingTime());
- bool sweepCompleted = true;
SweepForbiddenScope scope(this);
- {
- double startTime = WTF::currentTimeMS();
- ScriptForbiddenIfMainThreadScope scriptForbiddenScope;
-
- for (int i = 0; i < BlinkGC::NumberOfArenas; i++) {
- // lazySweepWithDeadline() won't check the deadline until it sweeps
- // 10 pages. So we give a small slack for safety.
- double slack = 0.001;
- double remainingBudget =
- deadlineSeconds - slack - monotonicallyIncreasingTime();
- if (remainingBudget <= 0 ||
- !m_arenas[i]->lazySweepWithDeadline(deadlineSeconds)) {
- // We couldn't finish the sweeping within the deadline.
- // We request another idle task for the remaining sweeping.
- scheduleIdleLazySweep();
- sweepCompleted = false;
- break;
- }
- }
+ ScriptForbiddenIfMainThreadScope scriptForbiddenScope;
- accumulateSweepingTime(WTF::currentTimeMS() - startTime);
+ double startTime = WTF::currentTimeMS();
+ bool sweepCompleted = true;
+ for (int i = 0; i < BlinkGC::NumberOfArenas; i++) {
+ // lazySweepWithDeadline() won't check the deadline until it sweeps
+ // 10 pages. So we give a small slack for safety.
+ double slack = 0.001;
+ double remainingBudget =
+ deadlineSeconds - slack - monotonicallyIncreasingTime();
+ if (remainingBudget <= 0 ||
+ !m_arenas[i]->lazySweepWithDeadline(deadlineSeconds)) {
+ // We couldn't finish the sweeping within the deadline.
+ // We request another idle task for the remaining sweeping.
+ scheduleIdleLazySweep();
+ sweepCompleted = false;
+ break;
+ }
}
+ accumulateSweepingTime(WTF::currentTimeMS() - startTime);
if (sweepCompleted)
postSweep();
@@ -982,25 +979,23 @@ void ThreadState::completeSweep() {
return;
SweepForbiddenScope scope(this);
- {
- ScriptForbiddenIfMainThreadScope scriptForbiddenScope;
+ ScriptForbiddenIfMainThreadScope scriptForbiddenScope;
- TRACE_EVENT0("blink_gc,devtools.timeline", "ThreadState::completeSweep");
- double startTime = WTF::currentTimeMS();
+ TRACE_EVENT0("blink_gc,devtools.timeline", "ThreadState::completeSweep");
+ double startTime = WTF::currentTimeMS();
- static_assert(BlinkGC::EagerSweepArenaIndex == 0,
- "Eagerly swept arenas must be processed first.");
- for (int i = 0; i < BlinkGC::NumberOfArenas; i++)
- m_arenas[i]->completeSweep();
+ static_assert(BlinkGC::EagerSweepArenaIndex == 0,
+ "Eagerly swept arenas must be processed first.");
+ for (int i = 0; i < BlinkGC::NumberOfArenas; i++)
+ m_arenas[i]->completeSweep();
- double timeForCompleteSweep = WTF::currentTimeMS() - startTime;
- accumulateSweepingTime(timeForCompleteSweep);
+ double timeForCompleteSweep = WTF::currentTimeMS() - startTime;
+ accumulateSweepingTime(timeForCompleteSweep);
- if (isMainThread()) {
- DEFINE_STATIC_LOCAL(CustomCountHistogram, completeSweepHistogram,
- ("BlinkGC.CompleteSweep", 1, 10 * 1000, 50));
- completeSweepHistogram.count(timeForCompleteSweep);
- }
+ if (isMainThread()) {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, completeSweepHistogram,
+ ("BlinkGC.CompleteSweep", 1, 10 * 1000, 50));
+ completeSweepHistogram.count(timeForCompleteSweep);
}
postSweep();
@@ -1281,11 +1276,11 @@ void ThreadState::invokePreFinalizers() {
ASSERT(!sweepForbidden());
TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers");
+ SweepForbiddenScope sweepForbidden(this);
haraken 2017/02/15 09:37:15 Actually this is not needed though.
+ ScriptForbiddenIfMainThreadScope scriptForbidden;
+
double startTime = WTF::currentTimeMS();
if (!m_orderedPreFinalizers.isEmpty()) {
- SweepForbiddenScope sweepForbidden(this);
- ScriptForbiddenIfMainThreadScope scriptForbidden;
-
// Call the prefinalizers in the opposite order to their registration.
//
// The prefinalizer callback wrapper returns |true| when its associated
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698