Title: [89547] trunk/Source/_javascript_Core
- Revision
- 89547
- Author
- [email protected]
- Date
- 2011-06-23 02:55:37 -0700 (Thu, 23 Jun 2011)
Log Message
2011-06-23 Timur Iskhodzhanov <[email protected]>
Reviewed by David Levin.
Make dynamic annotations weak symbols and prevent identical code folding by the linker
https://bugs.webkit.org/show_bug.cgi?id=62443
* wtf/DynamicAnnotations.cpp:
(WTFAnnotateBenignRaceSized):
(WTFAnnotateHappensBefore):
(WTFAnnotateHappensAfter):
* wtf/DynamicAnnotations.h:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (89546 => 89547)
--- trunk/Source/_javascript_Core/ChangeLog 2011-06-23 09:54:52 UTC (rev 89546)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-06-23 09:55:37 UTC (rev 89547)
@@ -1,3 +1,16 @@
+2011-06-23 Timur Iskhodzhanov <[email protected]>
+
+ Reviewed by David Levin.
+
+ Make dynamic annotations weak symbols and prevent identical code folding by the linker
+ https://bugs.webkit.org/show_bug.cgi?id=62443
+
+ * wtf/DynamicAnnotations.cpp:
+ (WTFAnnotateBenignRaceSized):
+ (WTFAnnotateHappensBefore):
+ (WTFAnnotateHappensAfter):
+ * wtf/DynamicAnnotations.h:
+
2011-06-22 Yael Aharon <[email protected]>
Reviewed by Andreas Kling.
Modified: trunk/Source/_javascript_Core/wtf/DynamicAnnotations.cpp (89546 => 89547)
--- trunk/Source/_javascript_Core/wtf/DynamicAnnotations.cpp 2011-06-23 09:54:52 UTC (rev 89546)
+++ trunk/Source/_javascript_Core/wtf/DynamicAnnotations.cpp 2011-06-23 09:55:37 UTC (rev 89547)
@@ -29,7 +29,22 @@
#include "DynamicAnnotations.h"
#if USE(DYNAMIC_ANNOTATIONS)
-void WTFAnnotateBenignRaceSized(const char*, int, const volatile void*, long, const char*) { }
-void WTFAnnotateHappensBefore(const char*, int, const volatile void*) { }
-void WTFAnnotateHappensAfter(const char*, int, const volatile void*) { }
+
+/* Identical code folding(-Wl,--icf=all) countermeasures.
+ * This makes all Annotate* functions different, which prevents the linker from folding them.
+ */
+#ifdef __COUNTER__
+#define DYNAMIC_ANNOTATIONS_IMPL \
+ volatile short lineno = (__LINE__ << 8) + __COUNTER__; \
+ (void)lineno;
+#else
+#define DYNAMIC_ANNOTATIONS_IMPL \
+ volatile short lineno = (__LINE__ << 8); \
+ (void)lineno;
+#endif
+
+void WTFAnnotateBenignRaceSized(const char*, int, const volatile void*, long, const char*) { DYNAMIC_ANNOTATIONS_IMPL }
+void WTFAnnotateHappensBefore(const char*, int, const volatile void*) { DYNAMIC_ANNOTATIONS_IMPL }
+void WTFAnnotateHappensAfter(const char*, int, const volatile void*) { DYNAMIC_ANNOTATIONS_IMPL }
#endif // USE(DYNAMIC_ANNOTATIONS)
+
Modified: trunk/Source/_javascript_Core/wtf/DynamicAnnotations.h (89546 => 89547)
--- trunk/Source/_javascript_Core/wtf/DynamicAnnotations.h 2011-06-23 09:54:52 UTC (rev 89546)
+++ trunk/Source/_javascript_Core/wtf/DynamicAnnotations.h 2011-06-23 09:55:37 UTC (rev 89547)
@@ -73,17 +73,26 @@
#define WTF_ANNOTATE_HAPPENS_BEFORE(address) WTFAnnotateHappensBefore(__FILE__, __LINE__, address)
#define WTF_ANNOTATE_HAPPENS_AFTER(address) WTFAnnotateHappensAfter(__FILE__, __LINE__, address)
+/* The dynamic annotations must be weak symbols to be interceptable by a linker. */
+#if defined(__GNUC__)
+#define WTF_DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK __attribute__((weak))
+#else
+#define WTF_DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
/* Don't use these directly, use the above macros instead. */
-void WTFAnnotateBenignRaceSized(const char* file, int line, const volatile void* memory, long size, const char* description);
-void WTFAnnotateHappensBefore(const char* file, int line, const volatile void* address);
-void WTFAnnotateHappensAfter(const char* file, int line, const volatile void* address);
+void WTFAnnotateBenignRaceSized(const char* file, int line, const volatile void* memory, long size, const char* description) WTF_DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK;
+void WTFAnnotateHappensBefore(const char* file, int line, const volatile void* address) WTF_DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK;
+void WTFAnnotateHappensAfter(const char* file, int line, const volatile void* address) WTF_DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK;
#ifdef __cplusplus
} // extern "C"
#endif
+#undef WTF_DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK
+
#else // USE(DYNAMIC_ANNOTATIONS)
/* These macros are empty when dynamic annotations are not enabled so you can
* use them without affecting the performance of release binaries. */
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes