Title: [201738] trunk/Source/WTF
- Revision
- 201738
- Author
- [email protected]
- Date
- 2016-06-06 20:24:54 -0700 (Mon, 06 Jun 2016)
Log Message
equal(StringView, StringView) for strings should have a fast path for pointer equality
https://bugs.webkit.org/show_bug.cgi?id=158452
Reviewed by Andreas Kling.
JSBench does a lot of StringView::operator== on StringViews that have
the same underlying characters pointer. This becomes hot inside JSBench
because JSBench heavily stresses JSC's UnlinkedCodeCache with a high
hit rate. This means that when we get a hit in the cache, we used to
do the long form of string compare. However, we were often comparing
two StringViews that had the same underlying buffer and length.
This patch speeds this case up to run in constant time instead of
linear time.
* wtf/text/StringCommon.h:
(WTF::equalCommon):
* wtf/text/StringImpl.h:
(WTF::StringImpl::StringImpl):
(WTF::StringImpl::data):
* wtf/text/StringView.h:
(WTF::StringView::data):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (201737 => 201738)
--- trunk/Source/WTF/ChangeLog 2016-06-07 03:02:06 UTC (rev 201737)
+++ trunk/Source/WTF/ChangeLog 2016-06-07 03:24:54 UTC (rev 201738)
@@ -1,3 +1,27 @@
+2016-06-06 Saam Barati <[email protected]>
+
+ equal(StringView, StringView) for strings should have a fast path for pointer equality
+ https://bugs.webkit.org/show_bug.cgi?id=158452
+
+ Reviewed by Andreas Kling.
+
+ JSBench does a lot of StringView::operator== on StringViews that have
+ the same underlying characters pointer. This becomes hot inside JSBench
+ because JSBench heavily stresses JSC's UnlinkedCodeCache with a high
+ hit rate. This means that when we get a hit in the cache, we used to
+ do the long form of string compare. However, we were often comparing
+ two StringViews that had the same underlying buffer and length.
+ This patch speeds this case up to run in constant time instead of
+ linear time.
+
+ * wtf/text/StringCommon.h:
+ (WTF::equalCommon):
+ * wtf/text/StringImpl.h:
+ (WTF::StringImpl::StringImpl):
+ (WTF::StringImpl::data):
+ * wtf/text/StringView.h:
+ (WTF::StringView::data):
+
2016-06-04 Anders Carlsson <[email protected]>
Get rid of WorkItemWin
Modified: trunk/Source/WTF/wtf/text/StringView.h (201737 => 201738)
--- trunk/Source/WTF/wtf/text/StringView.h 2016-06-07 03:02:06 UTC (rev 201737)
+++ trunk/Source/WTF/wtf/text/StringView.h 2016-06-07 03:24:54 UTC (rev 201738)
@@ -135,6 +135,8 @@
struct UnderlyingString;
private:
+ friend bool equal(StringView, StringView);
+
void initialize(const LChar*, unsigned length);
void initialize(const UChar*, unsigned length);
@@ -525,6 +527,11 @@
inline bool equal(StringView a, StringView b)
{
+ if (a.m_characters == b.m_characters) {
+ ASSERT(a.is8Bit() == b.is8Bit());
+ return a.length() == b.length();
+ }
+
return equalCommon(a, b);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes