Title: [244352] trunk/Source
Revision
244352
Author
[email protected]
Date
2019-04-16 12:46:27 -0700 (Tue, 16 Apr 2019)

Log Message

[WTF] holdLock should be marked WARN_UNUSED_RETURN
https://bugs.webkit.org/show_bug.cgi?id=196922

Reviewed by Keith Miller.

Source/_javascript_Core:

There was one case where holdLock was used and the result ignored.
>From a comment that was deleted in https://bugs.webkit.org/attachment.cgi?id=328438&action="" I believe that it is on purpose.
So I brought back a variant of the comment, and made the ignoring of the return explicit.

* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::isPagedOut):

Source/WTF:

* wtf/Locker.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (244351 => 244352)


--- trunk/Source/_javascript_Core/ChangeLog	2019-04-16 19:37:27 UTC (rev 244351)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-04-16 19:46:27 UTC (rev 244352)
@@ -1,3 +1,17 @@
+2019-04-16  Robin Morisset  <[email protected]>
+
+        [WTF] holdLock should be marked WARN_UNUSED_RETURN
+        https://bugs.webkit.org/show_bug.cgi?id=196922
+
+        Reviewed by Keith Miller.
+
+        There was one case where holdLock was used and the result ignored.
+        From a comment that was deleted in https://bugs.webkit.org/attachment.cgi?id=328438&action="" I believe that it is on purpose.
+        So I brought back a variant of the comment, and made the ignoring of the return explicit.
+
+        * heap/BlockDirectory.cpp:
+        (JSC::BlockDirectory::isPagedOut):
+
 2019-04-16  Caitlin Potter  <[email protected]>
 
         [JSC] Filter DontEnum properties in ProxyObject::getOwnPropertyNames()

Modified: trunk/Source/_javascript_Core/heap/BlockDirectory.cpp (244351 => 244352)


--- trunk/Source/_javascript_Core/heap/BlockDirectory.cpp	2019-04-16 19:37:27 UTC (rev 244351)
+++ trunk/Source/_javascript_Core/heap/BlockDirectory.cpp	2019-04-16 19:46:27 UTC (rev 244352)
@@ -61,8 +61,11 @@
 {
     unsigned itersSinceLastTimeCheck = 0;
     for (auto* block : m_blocks) {
-        if (block)
-            holdLock(block->block().lock());
+        if (block) {
+            // We take and drop the lock as a way of touching that page of memory.
+            // FIXME: should we instead do a cheaper thing like a volatile load in the page?
+            (void) holdLock(block->block().lock());
+        }
         ++itersSinceLastTimeCheck;
         if (itersSinceLastTimeCheck >= Heap::s_timeCheckResolution) {
             MonotonicTime currentTime = MonotonicTime::now();

Modified: trunk/Source/WTF/ChangeLog (244351 => 244352)


--- trunk/Source/WTF/ChangeLog	2019-04-16 19:37:27 UTC (rev 244351)
+++ trunk/Source/WTF/ChangeLog	2019-04-16 19:46:27 UTC (rev 244352)
@@ -1,3 +1,12 @@
+2019-04-16  Robin Morisset  <[email protected]>
+
+        [WTF] holdLock should be marked WARN_UNUSED_RETURN
+        https://bugs.webkit.org/show_bug.cgi?id=196922
+
+        Reviewed by Keith Miller.
+
+        * wtf/Locker.h:
+
 2019-04-16  Don Olmstead  <[email protected]>
 
         [CMake] Set WTF_SCRIPTS_DIR

Modified: trunk/Source/WTF/wtf/Locker.h (244351 => 244352)


--- trunk/Source/WTF/wtf/Locker.h	2019-04-16 19:37:27 UTC (rev 244351)
+++ trunk/Source/WTF/wtf/Locker.h	2019-04-16 19:46:27 UTC (rev 244352)
@@ -30,6 +30,7 @@
 
 #include <wtf/Assertions.h>
 #include <wtf/Atomics.h>
+#include <wtf/Compiler.h>
 #include <wtf/Noncopyable.h>
 
 namespace WTF {
@@ -119,6 +120,8 @@
 // Use this lock scope like so:
 // auto locker = holdLock(lock);
 template<typename LockType>
+Locker<LockType> holdLock(LockType&) WARN_UNUSED_RETURN;
+template<typename LockType>
 Locker<LockType> holdLock(LockType& lock)
 {
     return Locker<LockType>(lock);
@@ -125,6 +128,8 @@
 }
 
 template<typename LockType>
+Locker<LockType> holdLockIf(LockType&, bool predicate) WARN_UNUSED_RETURN;
+template<typename LockType>
 Locker<LockType> holdLockIf(LockType& lock, bool predicate)
 {
     return Locker<LockType>(predicate ? &lock : nullptr);
@@ -131,6 +136,8 @@
 }
 
 template<typename LockType>
+Locker<LockType> tryHoldLock(LockType&) WARN_UNUSED_RETURN;
+template<typename LockType>
 Locker<LockType> tryHoldLock(LockType& lock)
 {
     return Locker<LockType>::tryLock(lock);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to