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

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

Issue 9667026: Revert 126020 - 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 152 // extern "C" suppresses C++ name mangling so we know the symbol names for the
153 // for the linker /INCLUDE:symbol pragmas above. 153 // 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
222 // This is mostly like MmapSysAllocator::Alloc, except it does these weird 226 // This is mostly like MmapSysAllocator::Alloc, except it does these weird
223 // munmap's in the middle of the page, which is forbidden in windows. 227 // munmap's in the middle of the page, which is forbidden in windows.
224 extern void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size, 228 extern void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size,
225 size_t alignment) { 229 size_t alignment) {
226 // Align on the pagesize boundary 230 // Align on the pagesize boundary
227 const int pagesize = getpagesize(); 231 const int pagesize = getpagesize();
228 if (alignment < pagesize) alignment = pagesize; 232 if (alignment < pagesize) alignment = pagesize;
229 size = ((size + alignment - 1) / alignment) * alignment; 233 size = ((size + alignment - 1) / alignment) * alignment;
230 234
231 // Report the total number of bytes the OS actually delivered. This might be 235 // 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
327 } 331 }
328 332
329 bool RegisterSystemAllocator(SysAllocator *allocator, int priority) { 333 bool RegisterSystemAllocator(SysAllocator *allocator, int priority) {
330 return false; // we don't allow registration on windows, right now 334 return false; // we don't allow registration on windows, right now
331 } 335 }
332 336
333 void DumpSystemAllocatorStats(TCMalloc_Printer* printer) { 337 void DumpSystemAllocatorStats(TCMalloc_Printer* printer) {
334 // We don't dump stats on windows, right now 338 // We don't dump stats on windows, right now
335 } 339 }
336 340
337 // The current system allocator
338 SysAllocator* sys_alloc = NULL;
339
340 341
341 // ----------------------------------------------------------------------- 342 // -----------------------------------------------------------------------
342 // These functions rework existing functions of the same name in the 343 // These functions rework existing functions of the same name in the
343 // Google codebase. 344 // Google codebase.
344 345
345 // A replacement for HeapProfiler::CleanupOldProfiles. 346 // A replacement for HeapProfiler::CleanupOldProfiles.
346 void DeleteMatchingFiles(const char* prefix, const char* full_glob) { 347 void DeleteMatchingFiles(const char* prefix, const char* full_glob) {
347 WIN32_FIND_DATAA found; // that final A is for Ansi (as opposed to Unicode) 348 WIN32_FIND_DATAA found; // that final A is for Ansi (as opposed to Unicode)
348 HANDLE hFind = FindFirstFileA(full_glob, &found); // A is for Ansi 349 HANDLE hFind = FindFirstFileA(full_glob, &found); // A is for Ansi
349 if (hFind != INVALID_HANDLE_VALUE) { 350 if (hFind != INVALID_HANDLE_VALUE) {
350 const int prefix_length = strlen(prefix); 351 const int prefix_length = strlen(prefix);
351 do { 352 do {
352 const char *fname = found.cFileName; 353 const char *fname = found.cFileName;
353 if ((strlen(fname) >= prefix_length) && 354 if ((strlen(fname) >= prefix_length) &&
354 (memcmp(fname, prefix, prefix_length) == 0)) { 355 (memcmp(fname, prefix, prefix_length) == 0)) {
355 RAW_VLOG(0, "Removing old heap profile %s\n", fname); 356 RAW_VLOG(0, "Removing old heap profile %s\n", fname);
356 // TODO(csilvers): we really need to unlink dirname + fname 357 // TODO(csilvers): we really need to unlink dirname + fname
357 _unlink(fname); 358 _unlink(fname);
358 } 359 }
359 } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi 360 } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi
360 FindClose(hFind); 361 FindClose(hFind);
361 } 362 }
362 } 363 }
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