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