Title: [254871] trunk/Source/bmalloc
Revision
254871
Author
[email protected]
Date
2020-01-21 12:33:40 -0800 (Tue, 21 Jan 2020)

Log Message

[bmalloc] Make use of LockHolder strict in some methods of Scavenger
https://bugs.webkit.org/show_bug.cgi?id=206460

Reviewed by Darin Adler.

For instance, Scavenger::runHoldingLock() assume the caller has lock and express that by its function name. This rule can be
strict by passing LockHolder and that's the way as other code do.

Same change to runSoonHoldingLock and scheduleIfUnderMemoryPressureHoldingLock.

* bmalloc/Scavenger.cpp:
(bmalloc::Scavenger::run):
(bmalloc::Scavenger::runSoon):
(bmalloc::Scavenger::scheduleIfUnderMemoryPressure):
(bmalloc::Scavenger::schedule):
(bmalloc::Scavenger::runHoldingLock): Renamed.
(bmalloc::Scavenger::runSoonHoldingLock): Renamed.
(bmalloc::Scavenger::scheduleIfUnderMemoryPressureHoldingLock): Renamed.
* bmalloc/Scavenger.h:

Modified Paths

Diff

Modified: trunk/Source/bmalloc/ChangeLog (254870 => 254871)


--- trunk/Source/bmalloc/ChangeLog	2020-01-21 20:05:49 UTC (rev 254870)
+++ trunk/Source/bmalloc/ChangeLog	2020-01-21 20:33:40 UTC (rev 254871)
@@ -1,3 +1,25 @@
+2020-01-21  Basuke Suzuki  <[email protected]>
+
+        [bmalloc] Make use of LockHolder strict in some methods of Scavenger
+        https://bugs.webkit.org/show_bug.cgi?id=206460
+
+        Reviewed by Darin Adler.
+
+        For instance, Scavenger::runHoldingLock() assume the caller has lock and express that by its function name. This rule can be
+        strict by passing LockHolder and that's the way as other code do.
+
+        Same change to runSoonHoldingLock and scheduleIfUnderMemoryPressureHoldingLock.
+
+        * bmalloc/Scavenger.cpp:
+        (bmalloc::Scavenger::run):
+        (bmalloc::Scavenger::runSoon):
+        (bmalloc::Scavenger::scheduleIfUnderMemoryPressure):
+        (bmalloc::Scavenger::schedule):
+        (bmalloc::Scavenger::runHoldingLock): Renamed.
+        (bmalloc::Scavenger::runSoonHoldingLock): Renamed.
+        (bmalloc::Scavenger::scheduleIfUnderMemoryPressureHoldingLock): Renamed.
+        * bmalloc/Scavenger.h:
+
 2020-01-17  Sam Weinig  <[email protected]>
 
         Platform.h is out of control Part 8: Macros are used inconsistently

Modified: trunk/Source/bmalloc/bmalloc/Scavenger.cpp (254870 => 254871)


--- trunk/Source/bmalloc/bmalloc/Scavenger.cpp	2020-01-21 20:05:49 UTC (rev 254870)
+++ trunk/Source/bmalloc/bmalloc/Scavenger.cpp	2020-01-21 20:33:40 UTC (rev 254871)
@@ -93,10 +93,10 @@
 void Scavenger::run()
 {
     LockHolder lock(mutex());
-    runHoldingLock();
+    run(lock);
 }
 
-void Scavenger::runHoldingLock()
+void Scavenger::run(const LockHolder&)
 {
     m_state = State::Run;
     m_condition.notify_all();
@@ -105,10 +105,10 @@
 void Scavenger::runSoon()
 {
     LockHolder lock(mutex());
-    runSoonHoldingLock();
+    runSoon(lock);
 }
 
-void Scavenger::runSoonHoldingLock()
+void Scavenger::runSoon(const LockHolder&)
 {
     if (willRunSoon())
         return;
@@ -125,10 +125,10 @@
 void Scavenger::scheduleIfUnderMemoryPressure(size_t bytes)
 {
     LockHolder lock(mutex());
-    scheduleIfUnderMemoryPressureHoldingLock(bytes);
+    scheduleIfUnderMemoryPressure(lock, bytes);
 }
 
-void Scavenger::scheduleIfUnderMemoryPressureHoldingLock(size_t bytes)
+void Scavenger::scheduleIfUnderMemoryPressure(const LockHolder& lock, size_t bytes)
 {
     m_scavengerBytes += bytes;
     if (m_scavengerBytes < scavengerBytesPerMemoryPressureCheck)
@@ -143,19 +143,19 @@
         return;
 
     m_isProbablyGrowing = false;
-    runHoldingLock();
+    run(lock);
 }
 
 void Scavenger::schedule(size_t bytes)
 {
     LockHolder lock(mutex());
-    scheduleIfUnderMemoryPressureHoldingLock(bytes);
+    scheduleIfUnderMemoryPressure(lock, bytes);
     
     if (willRunSoon())
         return;
     
     m_isProbablyGrowing = false;
-    runSoonHoldingLock();
+    runSoon(lock);
 }
 
 inline void dumpStats()

Modified: trunk/Source/bmalloc/bmalloc/Scavenger.h (254870 => 254871)


--- trunk/Source/bmalloc/bmalloc/Scavenger.h	2020-01-21 20:05:49 UTC (rev 254870)
+++ trunk/Source/bmalloc/bmalloc/Scavenger.h	2020-01-21 20:33:40 UTC (rev 254871)
@@ -77,10 +77,10 @@
 private:
     enum class State { Sleep, Run, RunSoon };
     
-    void runHoldingLock();
-    void runSoonHoldingLock();
+    void run(const LockHolder&);
+    void runSoon(const LockHolder&);
 
-    void scheduleIfUnderMemoryPressureHoldingLock(size_t bytes);
+    void scheduleIfUnderMemoryPressure(const LockHolder&, size_t bytes);
 
     BNO_RETURN static void threadEntryPoint(Scavenger*);
     BNO_RETURN void threadRunLoop();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to