OLD | NEW |
1 /* Copyright (c) 2006, Google Inc. | 1 /* Copyright (c) 2006, 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 20 matching lines...) Expand all Loading... |
31 // A low-level allocator that can be used by other low-level | 31 // A low-level allocator that can be used by other low-level |
32 // modules without introducing dependency cycles. | 32 // modules without introducing dependency cycles. |
33 // This allocator is slow and wasteful of memory; | 33 // This allocator is slow and wasteful of memory; |
34 // it should not be used when performance is key. | 34 // it should not be used when performance is key. |
35 | 35 |
36 #include "base/low_level_alloc.h" | 36 #include "base/low_level_alloc.h" |
37 #include "base/dynamic_annotations.h" | 37 #include "base/dynamic_annotations.h" |
38 #include "base/spinlock.h" | 38 #include "base/spinlock.h" |
39 #include "base/logging.h" | 39 #include "base/logging.h" |
40 #include "malloc_hook-inl.h" | 40 #include "malloc_hook-inl.h" |
41 #include <gperftools/malloc_hook.h> | 41 #include <google/malloc_hook.h> |
42 #include <errno.h> | 42 #include <errno.h> |
43 #ifdef HAVE_UNISTD_H | 43 #ifdef HAVE_UNISTD_H |
44 #include <unistd.h> | 44 #include <unistd.h> |
45 #endif | 45 #endif |
46 #ifdef HAVE_MMAP | 46 #ifdef HAVE_MMAP |
47 #include <sys/mman.h> | 47 #include <sys/mman.h> |
48 #endif | 48 #endif |
49 #include <new> // for placement-new | 49 #include <new> // for placement-new |
50 | 50 |
51 // On systems (like freebsd) that don't define MAP_ANONYMOUS, use the old | 51 // On systems (like freebsd) that don't define MAP_ANONYMOUS, use the old |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 sigfillset(&all); | 226 sigfillset(&all); |
227 this->mask_valid_ = | 227 this->mask_valid_ = |
228 (pthread_sigmask(SIG_BLOCK, &all, &this->mask_) == 0); | 228 (pthread_sigmask(SIG_BLOCK, &all, &this->mask_) == 0); |
229 #else | 229 #else |
230 RAW_CHECK(false, "We do not yet support async-signal-safe arena."); | 230 RAW_CHECK(false, "We do not yet support async-signal-safe arena."); |
231 #endif | 231 #endif |
232 } | 232 } |
233 this->arena_->mu.Lock(); | 233 this->arena_->mu.Lock(); |
234 } | 234 } |
235 ~ArenaLock() { RAW_CHECK(this->left_, "haven't left Arena region"); } | 235 ~ArenaLock() { RAW_CHECK(this->left_, "haven't left Arena region"); } |
236 void Leave() /*UNLOCK_FUNCTION()*/ { | 236 void Leave() UNLOCK_FUNCTION() { |
237 this->arena_->mu.Unlock(); | 237 this->arena_->mu.Unlock(); |
238 #if 0 | 238 #if 0 |
239 if (this->mask_valid_) { | 239 if (this->mask_valid_) { |
240 pthread_sigmask(SIG_SETMASK, &this->mask_, 0); | 240 pthread_sigmask(SIG_SETMASK, &this->mask_, 0); |
241 } | 241 } |
242 #endif | 242 #endif |
243 this->left_ = true; | 243 this->left_ = true; |
244 } | 244 } |
245 private: | 245 private: |
246 bool left_; // whether left region | 246 bool left_; // whether left region |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 // this call must be directly in the user-called allocator function | 513 // this call must be directly in the user-called allocator function |
514 // for MallocHook::GetCallerStackTrace to work properly | 514 // for MallocHook::GetCallerStackTrace to work properly |
515 MallocHook::InvokeNewHook(result, request); | 515 MallocHook::InvokeNewHook(result, request); |
516 } | 516 } |
517 return result; | 517 return result; |
518 } | 518 } |
519 | 519 |
520 LowLevelAlloc::Arena *LowLevelAlloc::DefaultArena() { | 520 LowLevelAlloc::Arena *LowLevelAlloc::DefaultArena() { |
521 return &default_arena; | 521 return &default_arena; |
522 } | 522 } |
OLD | NEW |