Title: [164261] trunk/Source
Revision
164261
Author
[email protected]
Date
2014-02-17 17:32:18 -0800 (Mon, 17 Feb 2014)

Log Message

Remove ENABLE_GLOBAL_FASTMALLOC_NEW
https://bugs.webkit.org/show_bug.cgi?id=127067

Reviewed by Geoffrey Garen.

Source/_javascript_Core:

* parser/Nodes.h:

Source/WebCore:

* platform/Timer.h:

Source/WTF:

Remove the global operator new/operator delete overrides. Having ALWAYS_INLINE operators
like we do is really undefined behavior according to the C++ standard and we've been lucky enough
to get away with it so far, but any code that calls operator new/operator delete inside from the C++ standard
library (not from headers that are included) will be mismatched and potentially crash. libc++ calls
delete in it's std::thread implementation for example.

The only supported way to override operator new and operator delete globally is to not use inline
functions, but that would mean that any application using WebKit would not be able to provide custom
operator new/operator delete functions so we'll just reuse the already existing infrastructure consisting
of the WTF_MAKE_FAST_ALLOCATED macro.

* wtf/FastMalloc.cpp:
(WTF::TCMalloc_ThreadCache::CreateCacheIfNecessary):
* wtf/FastMalloc.h:
* wtf/Platform.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (164260 => 164261)


--- trunk/Source/_javascript_Core/ChangeLog	2014-02-18 00:56:57 UTC (rev 164260)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-02-18 01:32:18 UTC (rev 164261)
@@ -1,3 +1,12 @@
+2014-02-17  Anders Carlsson  <[email protected]>
+
+        Remove ENABLE_GLOBAL_FASTMALLOC_NEW
+        https://bugs.webkit.org/show_bug.cgi?id=127067
+
+        Reviewed by Geoffrey Garen.
+
+        * parser/Nodes.h:
+
 2014-02-17  Sergio Correia  <[email protected]>
 
         Replace uses of PassOwnPtr/OwnPtr with std::unique_ptr in WebCore/inspector

Modified: trunk/Source/_javascript_Core/parser/Nodes.h (164260 => 164261)


--- trunk/Source/_javascript_Core/parser/Nodes.h	2014-02-18 00:56:57 UTC (rev 164260)
+++ trunk/Source/_javascript_Core/parser/Nodes.h	2014-02-18 01:32:18 UTC (rev 164261)
@@ -112,7 +112,7 @@
     };
 
     class ParserArenaRefCounted : public RefCounted<ParserArenaRefCounted> {
-        WTF_FASTMALLOC_OPERATORS;
+        WTF_MAKE_FAST_ALLOCATED;
     protected:
         ParserArenaRefCounted(VM*);
 

Modified: trunk/Source/WTF/ChangeLog (164260 => 164261)


--- trunk/Source/WTF/ChangeLog	2014-02-18 00:56:57 UTC (rev 164260)
+++ trunk/Source/WTF/ChangeLog	2014-02-18 01:32:18 UTC (rev 164261)
@@ -1,3 +1,26 @@
+2014-02-17  Anders Carlsson  <[email protected]>
+
+        Remove ENABLE_GLOBAL_FASTMALLOC_NEW
+        https://bugs.webkit.org/show_bug.cgi?id=127067
+
+        Reviewed by Geoffrey Garen.
+
+        Remove the global operator new/operator delete overrides. Having ALWAYS_INLINE operators
+        like we do is really undefined behavior according to the C++ standard and we've been lucky enough
+        to get away with it so far, but any code that calls operator new/operator delete inside from the C++ standard
+        library (not from headers that are included) will be mismatched and potentially crash. libc++ calls
+        delete in it's std::thread implementation for example.
+        
+        The only supported way to override operator new and operator delete globally is to not use inline
+        functions, but that would mean that any application using WebKit would not be able to provide custom
+        operator new/operator delete functions so we'll just reuse the already existing infrastructure consisting
+        of the WTF_MAKE_FAST_ALLOCATED macro.
+
+        * wtf/FastMalloc.cpp:
+        (WTF::TCMalloc_ThreadCache::CreateCacheIfNecessary):
+        * wtf/FastMalloc.h:
+        * wtf/Platform.h:
+
 2014-02-17  Ryan Lortie  <[email protected]>
 
         Enable DFG_JIT on FreeBSD

Modified: trunk/Source/WTF/wtf/FastMalloc.cpp (164260 => 164261)


--- trunk/Source/WTF/wtf/FastMalloc.cpp	2014-02-18 00:56:57 UTC (rev 164260)
+++ trunk/Source/WTF/wtf/FastMalloc.cpp	2014-02-18 01:32:18 UTC (rev 164261)
@@ -4531,64 +4531,6 @@
   }
 }
 
-#if ENABLE(GLOBAL_FASTMALLOC_NEW)
-
-void* operator new(size_t size) {
-  void* p = cpp_alloc(size, false);
-  // We keep this next instruction out of cpp_alloc for a reason: when
-  // it's in, and new just calls cpp_alloc, the optimizer may fold the
-  // new call into cpp_alloc, which messes up our whole section-based
-  // stacktracing (see ATTRIBUTE_SECTION, above).  This ensures cpp_alloc
-  // isn't the last thing this fn calls, and prevents the folding.
-  MallocHook::InvokeNewHook(p, size);
-  return p;
-}
-
-void* operator new(size_t size, const std::nothrow_t&) __THROW {
-  void* p = cpp_alloc(size, true);
-  MallocHook::InvokeNewHook(p, size);
-  return p;
-}
-
-void operator delete(void* p) __THROW {
-  MallocHook::InvokeDeleteHook(p);
-  do_free(p);
-}
-
-void operator delete(void* p, const std::nothrow_t&) __THROW {
-  MallocHook::InvokeDeleteHook(p);
-  do_free(p);
-}
-
-void* operator new[](size_t size) {
-  void* p = cpp_alloc(size, false);
-  // We keep this next instruction out of cpp_alloc for a reason: when
-  // it's in, and new just calls cpp_alloc, the optimizer may fold the
-  // new call into cpp_alloc, which messes up our whole section-based
-  // stacktracing (see ATTRIBUTE_SECTION, above).  This ensures cpp_alloc
-  // isn't the last thing this fn calls, and prevents the folding.
-  MallocHook::InvokeNewHook(p, size);
-  return p;
-}
-
-void* operator new[](size_t size, const std::nothrow_t&) __THROW {
-  void* p = cpp_alloc(size, true);
-  MallocHook::InvokeNewHook(p, size);
-  return p;
-}
-
-void operator delete[](void* p) __THROW {
-  MallocHook::InvokeDeleteHook(p);
-  do_free(p);
-}
-
-void operator delete[](void* p, const std::nothrow_t&) __THROW {
-  MallocHook::InvokeDeleteHook(p);
-  do_free(p);
-}
-
-#endif
-
 extern "C" void* memalign(size_t align, size_t size) __THROW {
   void* result = do_memalign(align, size);
   MallocHook::InvokeNewHook(result, size);

Modified: trunk/Source/WTF/wtf/FastMalloc.h (164260 => 164261)


--- trunk/Source/WTF/wtf/FastMalloc.h	2014-02-18 00:56:57 UTC (rev 164260)
+++ trunk/Source/WTF/wtf/FastMalloc.h	2014-02-18 01:32:18 UTC (rev 164261)
@@ -248,46 +248,7 @@
 #define WTF_PRIVATE_INLINE inline
 #endif
 
-#if !defined(_CRTDBG_MAP_ALLOC) && !(defined(USE_SYSTEM_MALLOC) && USE_SYSTEM_MALLOC)
-
-// The nothrow functions here are actually not all that helpful, because fastMalloc will
-// call CRASH() rather than returning 0, and returning 0 is what nothrow is all about.
-// But since WebKit code never uses exceptions or nothrow at all, this is probably OK.
-// Long term we will adopt FastAllocBase.h everywhere, and and replace this with
-// debug-only code to make sure we don't use the system malloc via the default operator
-// new by accident.
-
-#if ENABLE(GLOBAL_FASTMALLOC_NEW)
-
-#if COMPILER(MSVC)
-#pragma warning(push)
-#pragma warning(disable: 4290) // Disable the C++ exception specification ignored warning.
-#elif COMPILER(CLANG) && defined(__has_warning)
-#pragma clang diagnostic push
-#if __has_warning("-Winline-new-delete")
-// FIXME: The operator new, delete definitions cannot be inline per replacement.functions (17.6.4.6/3) of the C++
-// standard. As a workaround, disable warnings for such usage. See <https://bugs.webkit.org/show_bug.cgi?id=124186>.
-#pragma clang diagnostic ignored "-Winline-new-delete"
-#endif
-#endif
-WTF_PRIVATE_INLINE void* operator new(size_t size) throw (std::bad_alloc) { return fastMalloc(size); }
-WTF_PRIVATE_INLINE void* operator new(size_t size, const std::nothrow_t&) throw() { return fastMalloc(size); }
-WTF_PRIVATE_INLINE void operator delete(void* p) throw() { fastFree(p); }
-WTF_PRIVATE_INLINE void operator delete(void* p, const std::nothrow_t&) throw() { fastFree(p); }
-WTF_PRIVATE_INLINE void* operator new[](size_t size) throw (std::bad_alloc) { return fastMalloc(size); }
-WTF_PRIVATE_INLINE void* operator new[](size_t size, const std::nothrow_t&) throw() { return fastMalloc(size); }
-WTF_PRIVATE_INLINE void operator delete[](void* p) throw() { fastFree(p); }
-WTF_PRIVATE_INLINE void operator delete[](void* p, const std::nothrow_t&) throw() { fastFree(p); }
-#if COMPILER(MSVC)
-#pragma warning(pop)
-#elif COMPILER(CLANG) && defined(__has_warning)
-#pragma clang diagnostic pop
-#endif
-
-#endif // ENABLE(GLOBAL_FASTMALLOC_NEW)
-#endif // !defined(_CRTDBG_MAP_ALLOC) && !(defined(USE_SYSTEM_MALLOC) && USE_SYSTEM_MALLOC)
-
-#define WTF_FASTMALLOC_OPERATORS \
+#define WTF_MAKE_FAST_ALLOCATED \
 public: \
     void* operator new(size_t, void* p) { return p; } \
     void* operator new[](size_t, void* p) { return p; } \
@@ -325,11 +286,4 @@
 private: \
 typedef int __thisIsHereToForceASemicolonAfterThisMacro
 
-#if ENABLE(GLOBAL_FASTMALLOC_NEW)
-#define WTF_MAKE_FAST_ALLOCATED
-#else
-#define WTF_MAKE_FAST_ALLOCATED WTF_FASTMALLOC_OPERATORS
-#endif
-
-
 #endif /* WTF_FastMalloc_h */

Modified: trunk/Source/WTF/wtf/Platform.h (164260 => 164261)


--- trunk/Source/WTF/wtf/Platform.h	2014-02-18 00:56:57 UTC (rev 164260)
+++ trunk/Source/WTF/wtf/Platform.h	2014-02-18 01:32:18 UTC (rev 164261)
@@ -449,7 +449,6 @@
 #define WTF_USE_HARFBUZZ 1
 #define WTF_USE_SOUP 1
 #define WTF_USE_WEBP 1
-#define ENABLE_GLOBAL_FASTMALLOC_NEW 0
 #endif
 
 /* On Windows, use QueryPerformanceCounter by default */
@@ -601,19 +600,10 @@
 /* Include feature macros */
 #include <wtf/FeatureDefines.h>
 
-#if PLATFORM(EFL)
-#define ENABLE_GLOBAL_FASTMALLOC_NEW 0
-#endif
-
 #if OS(WINDOWS)
-#define ENABLE_GLOBAL_FASTMALLOC_NEW 0
 #define USE_SYSTEM_MALLOC 1
 #endif
 
-#if !defined(ENABLE_GLOBAL_FASTMALLOC_NEW)
-#define ENABLE_GLOBAL_FASTMALLOC_NEW 1
-#endif
-
 #define ENABLE_DEBUG_WITH_BREAKPOINT 0
 #define ENABLE_SAMPLING_COUNTERS 0
 #define ENABLE_SAMPLING_FLAGS 0

Modified: trunk/Source/WebCore/ChangeLog (164260 => 164261)


--- trunk/Source/WebCore/ChangeLog	2014-02-18 00:56:57 UTC (rev 164260)
+++ trunk/Source/WebCore/ChangeLog	2014-02-18 01:32:18 UTC (rev 164261)
@@ -1,3 +1,12 @@
+2014-02-17  Anders Carlsson  <[email protected]>
+
+        Remove ENABLE_GLOBAL_FASTMALLOC_NEW
+        https://bugs.webkit.org/show_bug.cgi?id=127067
+
+        Reviewed by Geoffrey Garen.
+
+        * platform/Timer.h:
+
 2014-02-17  Sam Weinig  <[email protected]>
 
         Move iOS only Settings into Settings.in and make them not-iOS only

Modified: trunk/Source/WebCore/platform/Timer.h (164260 => 164261)


--- trunk/Source/WebCore/platform/Timer.h	2014-02-18 00:56:57 UTC (rev 164260)
+++ trunk/Source/WebCore/platform/Timer.h	2014-02-18 01:32:18 UTC (rev 164261)
@@ -44,7 +44,7 @@
 
 class TimerBase {
     WTF_MAKE_NONCOPYABLE(TimerBase);
-    WTF_FASTMALLOC_OPERATORS;
+    WTF_MAKE_FAST_ALLOCATED;
 public:
     TimerBase();
     virtual ~TimerBase();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to