Title: [179644] trunk/Source/WTF
Revision
179644
Author
[email protected]
Date
2015-02-04 15:38:42 -0800 (Wed, 04 Feb 2015)

Log Message

Optimized equal() functions in StringImpl.h are not ASan compatible
https://bugs.webkit.org/show_bug.cgi?id=141258

Reviewed by Daniel Bates.

* wtf/text/StringImpl.h: (WTF::equal): Add custom implementations for ASan.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (179643 => 179644)


--- trunk/Source/WTF/ChangeLog	2015-02-04 23:29:30 UTC (rev 179643)
+++ trunk/Source/WTF/ChangeLog	2015-02-04 23:38:42 UTC (rev 179644)
@@ -1,3 +1,12 @@
+2015-02-04  Alexey Proskuryakov  <[email protected]>
+
+        Optimized equal() functions in StringImpl.h are not ASan compatible
+        https://bugs.webkit.org/show_bug.cgi?id=141258
+
+        Reviewed by Daniel Bates.
+
+        * wtf/text/StringImpl.h: (WTF::equal): Add custom implementations for ASan.
+
 2015-02-04  Chris Dumez  <[email protected]>
 
         Add removeFirst(value) / removeAll(value) methods to WTF::Vector

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (179643 => 179644)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2015-02-04 23:29:30 UTC (rev 179643)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2015-02-04 23:38:42 UTC (rev 179644)
@@ -875,7 +875,7 @@
 }
 
 // Do comparisons 8 or 4 bytes-at-a-time on architectures where it's safe.
-#if CPU(X86_64) || CPU(ARM64)
+#if (CPU(X86_64) || CPU(ARM64)) && !ASAN_ENABLED
 ALWAYS_INLINE bool equal(const LChar* aLChar, const LChar* bLChar, unsigned length)
 {
     unsigned dwordLength = length >> 3;
@@ -945,7 +945,7 @@
 
     return true;
 }
-#elif CPU(X86)
+#elif CPU(X86) && !ASAN_ENABLED
 ALWAYS_INLINE bool equal(const LChar* aLChar, const LChar* bLChar, unsigned length)
 {
     const char* a = reinterpret_cast<const char*>(aLChar);
@@ -992,7 +992,7 @@
 
     return true;
 }
-#elif PLATFORM(IOS) && WTF_ARM_ARCH_AT_LEAST(7)
+#elif PLATFORM(IOS) && WTF_ARM_ARCH_AT_LEAST(7) && !ASAN_ENABLED
 ALWAYS_INLINE bool equal(const LChar* a, const LChar* b, unsigned length)
 {
     bool isEqual = false;
@@ -1080,9 +1080,26 @@
         );
     return isEqual;
 }
-#else
+#elif !ASAN_ENABLED
 ALWAYS_INLINE bool equal(const LChar* a, const LChar* b, unsigned length) { return !memcmp(a, b, length); }
 ALWAYS_INLINE bool equal(const UChar* a, const UChar* b, unsigned length) { return !memcmp(a, b, length * sizeof(UChar)); }
+#else
+ALWAYS_INLINE bool equal(const LChar* a, const LChar* b, unsigned length)
+{
+    for (unsigned i = 0; i < length; ++i) {
+        if (a[i] != b[i])
+            return false;
+    }
+    return true;
+}
+ALWAYS_INLINE bool equal(const UChar* a, const UChar* b, unsigned length)
+{
+    for (unsigned i = 0; i < length; ++i) {
+        if (a[i] != b[i])
+            return false;
+    }
+    return true;
+}
 #endif
 
 ALWAYS_INLINE bool equal(const LChar* a, const UChar* b, unsigned length)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to