Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: third_party/tcmalloc/chromium/src/windows/port.cc

Issue 9666033: Experiment for updating the tcmalloc chromium branch to r144 (gperftools 2.0). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* Copyright (c) 2007, Google Inc. 1 /* Copyright (c) 2007, Google Inc.
2 * All rights reserved. 2 * All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 static void NTAPI on_tls_callback(HINSTANCE h, DWORD dwReason, PVOID pv) { 144 static void NTAPI on_tls_callback(HINSTANCE h, DWORD dwReason, PVOID pv) {
145 if (dwReason == DLL_THREAD_DETACH) { // thread is being destroyed! 145 if (dwReason == DLL_THREAD_DETACH) { // thread is being destroyed!
146 on_process_term(); 146 on_process_term();
147 } 147 }
148 } 148 }
149 149
150 #ifdef _MSC_VER 150 #ifdef _MSC_VER
151 151
152 // extern "C" suppresses C++ name mangling so we know the symbol names for the 152 // extern "C" suppresses C++ name mangling so we know the symbol names
153 // linker /INCLUDE:symbol pragmas above. 153 // for the linker /INCLUDE:symbol pragmas above.
154 extern "C" { 154 extern "C" {
155 // This tells the linker to run these functions. 155 // This tells the linker to run these functions.
156 #pragma data_seg(push, old_seg) 156 #pragma data_seg(push, old_seg)
157 // Use CRT$XLY instead of CRT$XLB to ensure we're called LATER in sequence. 157 // Use CRT$XLY instead of CRT$XLB to ensure we're called LATER in sequence.
158 #pragma data_seg(".CRT$XLY") 158 #pragma data_seg(".CRT$XLY")
159 void (NTAPI *p_thread_callback_tcmalloc)( 159 void (NTAPI *p_thread_callback_tcmalloc)(
160 HINSTANCE h, DWORD dwReason, PVOID pv) = on_tls_callback; 160 HINSTANCE h, DWORD dwReason, PVOID pv) = on_tls_callback;
161 #pragma data_seg(".CRT$XTU") 161 #pragma data_seg(".CRT$XTU")
162 int (*p_process_term_tcmalloc)(void) = on_process_term; 162 int (*p_process_term_tcmalloc)(void) = on_process_term;
163 #pragma data_seg(pop, old_seg) 163 #pragma data_seg(pop, old_seg)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 } 213 }
214 } 214 }
215 return 0; 215 return 0;
216 } 216 }
217 217
218 218
219 // ----------------------------------------------------------------------- 219 // -----------------------------------------------------------------------
220 // These functions replace system-alloc.cc 220 // These functions replace system-alloc.cc
221 221
222 // The current system allocator. Because we don't link with system-alloc.cc,
223 // we need to define our own.
224 SysAllocator* sys_alloc = NULL;
225
226 // This is mostly like MmapSysAllocator::Alloc, except it does these weird 222 // This is mostly like MmapSysAllocator::Alloc, except it does these weird
227 // munmap's in the middle of the page, which is forbidden in windows. 223 // munmap's in the middle of the page, which is forbidden in windows.
228 extern void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size, 224 extern void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size,
229 size_t alignment) { 225 size_t alignment) {
230 // Align on the pagesize boundary 226 // Align on the pagesize boundary
231 const int pagesize = getpagesize(); 227 const int pagesize = getpagesize();
232 if (alignment < pagesize) alignment = pagesize; 228 if (alignment < pagesize) alignment = pagesize;
233 size = ((size + alignment - 1) / alignment) * alignment; 229 size = ((size + alignment - 1) / alignment) * alignment;
234 230
235 // Report the total number of bytes the OS actually delivered. This might be 231 // Report the total number of bytes the OS actually delivered. This might be
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 } 327 }
332 328
333 bool RegisterSystemAllocator(SysAllocator *allocator, int priority) { 329 bool RegisterSystemAllocator(SysAllocator *allocator, int priority) {
334 return false; // we don't allow registration on windows, right now 330 return false; // we don't allow registration on windows, right now
335 } 331 }
336 332
337 void DumpSystemAllocatorStats(TCMalloc_Printer* printer) { 333 void DumpSystemAllocatorStats(TCMalloc_Printer* printer) {
338 // We don't dump stats on windows, right now 334 // We don't dump stats on windows, right now
339 } 335 }
340 336
337 // The current system allocator
338 SysAllocator* sys_alloc = NULL;
339
341 340
342 // ----------------------------------------------------------------------- 341 // -----------------------------------------------------------------------
343 // These functions rework existing functions of the same name in the 342 // These functions rework existing functions of the same name in the
344 // Google codebase. 343 // Google codebase.
345 344
346 // A replacement for HeapProfiler::CleanupOldProfiles. 345 // A replacement for HeapProfiler::CleanupOldProfiles.
347 void DeleteMatchingFiles(const char* prefix, const char* full_glob) { 346 void DeleteMatchingFiles(const char* prefix, const char* full_glob) {
348 WIN32_FIND_DATAA found; // that final A is for Ansi (as opposed to Unicode) 347 WIN32_FIND_DATAA found; // that final A is for Ansi (as opposed to Unicode)
349 HANDLE hFind = FindFirstFileA(full_glob, &found); // A is for Ansi 348 HANDLE hFind = FindFirstFileA(full_glob, &found); // A is for Ansi
350 if (hFind != INVALID_HANDLE_VALUE) { 349 if (hFind != INVALID_HANDLE_VALUE) {
351 const int prefix_length = strlen(prefix); 350 const int prefix_length = strlen(prefix);
352 do { 351 do {
353 const char *fname = found.cFileName; 352 const char *fname = found.cFileName;
354 if ((strlen(fname) >= prefix_length) && 353 if ((strlen(fname) >= prefix_length) &&
355 (memcmp(fname, prefix, prefix_length) == 0)) { 354 (memcmp(fname, prefix, prefix_length) == 0)) {
356 RAW_VLOG(0, "Removing old heap profile %s\n", fname); 355 RAW_VLOG(0, "Removing old heap profile %s\n", fname);
357 // TODO(csilvers): we really need to unlink dirname + fname 356 // TODO(csilvers): we really need to unlink dirname + fname
358 _unlink(fname); 357 _unlink(fname);
359 } 358 }
360 } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi 359 } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi
361 FindClose(hFind); 360 FindClose(hFind);
362 } 361 }
363 } 362 }
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/windows/port.h ('k') | third_party/tcmalloc/chromium/src/windows/preamble_patcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698