Changeset 14256 in webkit for trunk/JavaScriptCore/wtf/FastMalloc.cpp
- Timestamp:
- May 9, 2006, 2:27:55 AM (19 years ago)
- Location:
- trunk/JavaScriptCore/wtf
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/FastMalloc.cpp
r14162 r14256 81 81 #endif 82 82 83 namespace KXMLCore{83 namespace WTF { 84 84 85 85 void *fastMalloc(size_t n) … … 109 109 #endif 110 110 111 } // namespace KXMLCore111 } // namespace WTF 112 112 113 113 #else … … 135 135 #include <unistd.h> 136 136 137 #if KXC_CHANGES138 namespace KXMLCore{137 #if WTF_CHANGES 138 namespace WTF { 139 139 140 140 #define malloc fastMalloc … … 537 537 } 538 538 539 #ifndef KXC_CHANGES539 #ifndef WTF_CHANGES 540 540 static int DLL_Length(const Span* list) { 541 541 int result = 0; … … 654 654 655 655 // Dump state to stderr 656 #ifndef KXC_CHANGES656 #ifndef WTF_CHANGES 657 657 void Dump(TCMalloc_Printer* out); 658 658 #endif … … 858 858 } 859 859 860 #ifndef KXC_CHANGES860 #ifndef WTF_CHANGES 861 861 void TCMalloc_PageHeap::Dump(TCMalloc_Printer* out) { 862 862 int nonempty_sizes = 0; … … 1371 1371 // may not release much memory, but if so we will call scavenge again 1372 1372 // pretty soon and the low-water marks will be high on that call. 1373 #ifndef KXC_CHANGES1373 #ifndef WTF_CHANGES 1374 1374 int64 start = CycleClock::Now(); 1375 1375 #endif … … 1385 1385 } 1386 1386 1387 #ifndef KXC_CHANGES1387 #ifndef WTF_CHANGES 1388 1388 int64 finish = CycleClock::Now(); 1389 1389 CycleTimer ct; … … 1589 1589 }; 1590 1590 1591 #ifndef KXC_CHANGES1591 #ifndef WTF_CHANGES 1592 1592 // Get stats into "r". Also get per-size-class counts if class_count != NULL 1593 1593 static void ExtractStats(TCMallocStats* r, uint64_t* class_count) { … … 1623 1623 #endif 1624 1624 1625 #ifndef KXC_CHANGES1625 #ifndef WTF_CHANGES 1626 1626 // WRITE stats to "out" 1627 1627 static void DumpStats(TCMalloc_Printer* out, int level) { … … 1727 1727 #endif 1728 1728 1729 #ifndef KXC_CHANGES1729 #ifndef WTF_CHANGES 1730 1730 1731 1731 // TCMalloc's support for extra malloc interfaces … … 1818 1818 // We hack around this problem by disabling all deallocations 1819 1819 // after a global object destructor in this module has been called. 1820 #ifndef KXC_CHANGES1820 #ifndef WTF_CHANGES 1821 1821 static bool tcmalloc_is_destroyed = false; 1822 1822 #endif … … 1826 1826 //------------------------------------------------------------------- 1827 1827 1828 #ifndef KXC_CHANGES1828 #ifndef WTF_CHANGES 1829 1829 1830 1830 static Span* DoSampledAllocation(size_t size) { … … 1857 1857 static ALWAYS_INLINE void* do_malloc(size_t size) { 1858 1858 1859 #ifndef KXC_CHANGES1859 #ifndef WTF_CHANGES 1860 1860 if (TCMallocDebug::level >= TCMallocDebug::kVerbose) 1861 1861 MESSAGE("In tcmalloc do_malloc(%" PRIuS")\n", size); 1862 1862 #endif 1863 1863 1864 #ifndef KXC_CHANGES1864 #ifndef WTF_CHANGES 1865 1865 // The following call forces module initialization 1866 1866 TCMalloc_ThreadCache* heap = TCMalloc_ThreadCache::GetCache(); … … 1883 1883 return reinterpret_cast<void*>(span->start << kPageShift); 1884 1884 } else { 1885 #ifdef KXC_CHANGES1885 #ifdef WTF_CHANGES 1886 1886 TCMalloc_ThreadCache* heap = TCMalloc_ThreadCache::GetCache(); 1887 1887 #endif … … 1891 1891 1892 1892 static ALWAYS_INLINE void do_free(void* ptr) { 1893 #ifndef KXC_CHANGES1893 #ifndef WTF_CHANGES 1894 1894 if (TCMallocDebug::level >= TCMallocDebug::kVerbose) 1895 1895 MESSAGE("In tcmalloc do_free(%p)\n", ptr); 1896 1896 #endif 1897 #if KXC_CHANGES1897 #if WTF_CHANGES 1898 1898 if (ptr == NULL) return; 1899 #else KXC_CHANGES1899 #else WTF_CHANGES 1900 1900 if (ptr == NULL || tcmalloc_is_destroyed) return; 1901 1901 #endif … … 1905 1905 Span* span = pageheap->GetDescriptor(p); 1906 1906 1907 #ifndef KXC_CHANGES1907 #ifndef WTF_CHANGES 1908 1908 if (span == NULL) { 1909 1909 // We've seen systems where a piece of memory allocated using the … … 1944 1944 } 1945 1945 1946 #ifndef KXC_CHANGES1946 #ifndef WTF_CHANGES 1947 1947 // For use by exported routines below that want specific alignments 1948 1948 // … … 2034 2034 public: 2035 2035 TCMallocGuard() { 2036 #ifndef KXC_CHANGES2036 #ifndef WTF_CHANGES 2037 2037 char *envval; 2038 2038 if ((envval = getenv("TCMALLOC_DEBUG"))) { … … 2044 2044 TCMalloc_ThreadCache::InitTSD(); 2045 2045 do_free(do_malloc(1)); 2046 #ifndef KXC_CHANGES2046 #ifndef WTF_CHANGES 2047 2047 MallocExtension::Register(new TCMallocImplementation); 2048 2048 #endif 2049 2049 } 2050 2050 2051 #ifndef KXC_CHANGES2051 #ifndef WTF_CHANGES 2052 2052 ~TCMallocGuard() { 2053 2053 const char* env = getenv("MALLOCSTATS"); … … 2073 2073 // the call to the (de)allocation function. 2074 2074 2075 #ifndef KXC_CHANGES2075 #ifndef WTF_CHANGES 2076 2076 extern "C" 2077 2077 #endif 2078 2078 void* malloc(size_t size) { 2079 2079 void* result = do_malloc(size); 2080 #ifndef KXC_CHANGES2080 #ifndef WTF_CHANGES 2081 2081 MallocHook::InvokeNewHook(result, size); 2082 2082 #endif … … 2084 2084 } 2085 2085 2086 #ifndef KXC_CHANGES2086 #ifndef WTF_CHANGES 2087 2087 extern "C" 2088 2088 #endif 2089 2089 void free(void* ptr) { 2090 #ifndef KXC_CHANGES2090 #ifndef WTF_CHANGES 2091 2091 MallocHook::InvokeDeleteHook(ptr); 2092 2092 #endif … … 2094 2094 } 2095 2095 2096 #ifndef KXC_CHANGES2096 #ifndef WTF_CHANGES 2097 2097 extern "C" 2098 2098 #endif … … 2102 2102 memset(result, 0, n * elem_size); 2103 2103 } 2104 #ifndef KXC_CHANGES2104 #ifndef WTF_CHANGES 2105 2105 MallocHook::InvokeNewHook(result, n * elem_size); 2106 2106 #endif … … 2108 2108 } 2109 2109 2110 #ifndef KXC_CHANGES2110 #ifndef WTF_CHANGES 2111 2111 extern "C" 2112 2112 #endif 2113 2113 void cfree(void* ptr) { 2114 #ifndef KXC_CHANGES2114 #ifndef WTF_CHANGES 2115 2115 MallocHook::InvokeDeleteHook(ptr); 2116 2116 #endif … … 2118 2118 } 2119 2119 2120 #ifndef KXC_CHANGES2120 #ifndef WTF_CHANGES 2121 2121 extern "C" 2122 2122 #endif … … 2124 2124 if (old_ptr == NULL) { 2125 2125 void* result = do_malloc(new_size); 2126 #ifndef KXC_CHANGES2126 #ifndef WTF_CHANGES 2127 2127 MallocHook::InvokeNewHook(result, new_size); 2128 2128 #endif … … 2130 2130 } 2131 2131 if (new_size == 0) { 2132 #ifndef KXC_CHANGES2132 #ifndef WTF_CHANGES 2133 2133 MallocHook::InvokeDeleteHook(old_ptr); 2134 2134 #endif … … 2155 2155 return NULL; 2156 2156 } 2157 #ifndef KXC_CHANGES2157 #ifndef WTF_CHANGES 2158 2158 MallocHook::InvokeNewHook(new_ptr, new_size); 2159 2159 #endif 2160 2160 memcpy(new_ptr, old_ptr, ((old_size < new_size) ? old_size : new_size)); 2161 #ifndef KXC_CHANGES2161 #ifndef WTF_CHANGES 2162 2162 MallocHook::InvokeDeleteHook(old_ptr); 2163 2163 #endif … … 2177 2177 #endif 2178 2178 2179 #ifndef KXC_CHANGES2179 #ifndef WTF_CHANGES 2180 2180 2181 2181 void* operator new(size_t size) OPNEW_THROW { … … 2320 2320 #endif 2321 2321 2322 #if KXC_CHANGES2323 } // namespace KXMLCore2322 #if WTF_CHANGES 2323 } // namespace WTF 2324 2324 #endif 2325 2325
Note:
See TracChangeset
for help on using the changeset viewer.