| OLD | NEW |
| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 destr_fn_info.destr_fn = destr_fn; | 176 destr_fn_info.destr_fn = destr_fn; |
| 177 destr_fn_info.key_for_destr_fn_arg = key; | 177 destr_fn_info.key_for_destr_fn_arg = key; |
| 178 } | 178 } |
| 179 return key; | 179 return key; |
| 180 } | 180 } |
| 181 | 181 |
| 182 | 182 |
| 183 // ----------------------------------------------------------------------- | 183 // ----------------------------------------------------------------------- |
| 184 // These functions replace system-alloc.cc | 184 // These functions replace system-alloc.cc |
| 185 | 185 |
| 186 static SpinLock alloc_lock(SpinLock::LINKER_INITIALIZED); | |
| 187 | |
| 188 // This is mostly like MmapSysAllocator::Alloc, except it does these weird | 186 // This is mostly like MmapSysAllocator::Alloc, except it does these weird |
| 189 // munmap's in the middle of the page, which is forbidden in windows. | 187 // munmap's in the middle of the page, which is forbidden in windows. |
| 190 extern void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size, | 188 extern void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size, |
| 191 size_t alignment) { | 189 size_t alignment) { |
| 192 SpinLockHolder sh(&alloc_lock); | |
| 193 // Align on the pagesize boundary | 190 // Align on the pagesize boundary |
| 194 const int pagesize = getpagesize(); | 191 const int pagesize = getpagesize(); |
| 195 if (alignment < pagesize) alignment = pagesize; | 192 if (alignment < pagesize) alignment = pagesize; |
| 196 size = ((size + alignment - 1) / alignment) * alignment; | 193 size = ((size + alignment - 1) / alignment) * alignment; |
| 197 | 194 |
| 198 // Report the total number of bytes the OS actually delivered. This might be | 195 // Report the total number of bytes the OS actually delivered. This might be |
| 199 // greater than |size| because of alignment concerns. The full size is | 196 // greater than |size| because of alignment concerns. The full size is |
| 200 // necessary so that adjacent spans can be coalesced. | 197 // necessary so that adjacent spans can be coalesced. |
| 201 // TODO(antonm): proper processing of alignments | 198 // TODO(antonm): proper processing of alignments |
| 202 // in actual_size and decommitting. | 199 // in actual_size and decommitting. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 if ((strlen(fname) >= prefix_length) && | 290 if ((strlen(fname) >= prefix_length) && |
| 294 (memcmp(fname, prefix, prefix_length) == 0)) { | 291 (memcmp(fname, prefix, prefix_length) == 0)) { |
| 295 RAW_VLOG(0, "Removing old heap profile %s\n", fname); | 292 RAW_VLOG(0, "Removing old heap profile %s\n", fname); |
| 296 // TODO(csilvers): we really need to unlink dirname + fname | 293 // TODO(csilvers): we really need to unlink dirname + fname |
| 297 _unlink(fname); | 294 _unlink(fname); |
| 298 } | 295 } |
| 299 } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi | 296 } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi |
| 300 FindClose(hFind); | 297 FindClose(hFind); |
| 301 } | 298 } |
| 302 } | 299 } |
| OLD | NEW |