Title: [255993] trunk/Source/WTF
- Revision
- 255993
- Author
- [email protected]
- Date
- 2020-02-06 16:59:59 -0800 (Thu, 06 Feb 2020)
Log Message
Add a comment in StringView::setUnderlyingString(const StringView&) for clarification.
https://bugs.webkit.org/show_bug.cgi?id=207368
<rdar://problem/59211075>
Reviewed by Keith Miller.
Every time I read this code, I have to re-deduce why this code is thread safe.
So, I'm just going to add a comment to document it.
* wtf/text/StringView.cpp:
(WTF::StringView::setUnderlyingString):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (255992 => 255993)
--- trunk/Source/WTF/ChangeLog 2020-02-07 00:44:34 UTC (rev 255992)
+++ trunk/Source/WTF/ChangeLog 2020-02-07 00:59:59 UTC (rev 255993)
@@ -1,3 +1,17 @@
+2020-02-06 Mark Lam <[email protected]>
+
+ Add a comment in StringView::setUnderlyingString(const StringView&) for clarification.
+ https://bugs.webkit.org/show_bug.cgi?id=207368
+ <rdar://problem/59211075>
+
+ Reviewed by Keith Miller.
+
+ Every time I read this code, I have to re-deduce why this code is thread safe.
+ So, I'm just going to add a comment to document it.
+
+ * wtf/text/StringView.cpp:
+ (WTF::StringView::setUnderlyingString):
+
2020-02-06 Myles C. Maxfield <[email protected]>
REGRESSION(r254534): 1-3% regression on PLT
Modified: trunk/Source/WTF/wtf/text/StringView.cpp (255992 => 255993)
--- trunk/Source/WTF/wtf/text/StringView.cpp 2020-02-07 00:44:34 UTC (rev 255992)
+++ trunk/Source/WTF/wtf/text/StringView.cpp 2020-02-07 00:59:59 UTC (rev 255993)
@@ -356,8 +356,14 @@
void StringView::setUnderlyingString(const StringView& otherString)
{
UnderlyingString* underlyingString = otherString.m_underlyingString;
- if (underlyingString)
+ if (underlyingString) {
+ // It's safe to inc the refCount here without locking underlyingStringsMutex
+ // because UnderlyingString::refCount is a std::atomic_uint, and we're
+ // guaranteed that the StringView we're copying it from will at least
+ // have 1 ref on it, thereby keeping it alive regardless of what other
+ // threads may be doing.
++underlyingString->refCount;
+ }
adoptUnderlyingString(underlyingString);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes