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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // Return the begin/end iterators to all the regions. | 245 // Return the begin/end iterators to all the regions. |
246 // These need Lock/Unlock protection around their whole usage (loop). | 246 // These need Lock/Unlock protection around their whole usage (loop). |
247 // Even when the same thread causes modifications during such a loop | 247 // Even when the same thread causes modifications during such a loop |
248 // (which are permitted due to recursive locking) | 248 // (which are permitted due to recursive locking) |
249 // the loop iterator will still be valid as long as its region | 249 // the loop iterator will still be valid as long as its region |
250 // has not been deleted, but EndRegionLocked should be | 250 // has not been deleted, but EndRegionLocked should be |
251 // re-evaluated whenever the set of regions has changed. | 251 // re-evaluated whenever the set of regions has changed. |
252 static RegionIterator BeginRegionLocked(); | 252 static RegionIterator BeginRegionLocked(); |
253 static RegionIterator EndRegionLocked(); | 253 static RegionIterator EndRegionLocked(); |
254 | 254 |
255 // Return the accumulated sizes of mapped and unmapped regions. | |
256 static int64 MapSize() { return map_size_; } | |
257 static int64 UnmapSize() { return unmap_size_; } | |
258 | |
259 // Effectively private type from our .cc ================================= | 255 // Effectively private type from our .cc ================================= |
260 // public to let us declare global objects: | 256 // public to let us declare global objects: |
261 union RegionSetRep; | 257 union RegionSetRep; |
262 | 258 |
263 private: | 259 private: |
264 // representation =========================================================== | 260 // representation =========================================================== |
265 | 261 |
266 // Counter of clients of this module that have called Init(). | 262 // Counter of clients of this module that have called Init(). |
267 static int client_count_; | 263 static int client_count_; |
268 | 264 |
(...skipping 14 matching lines...) Expand all Loading... |
283 // Lock to protect regions_ variable and the data behind. | 279 // Lock to protect regions_ variable and the data behind. |
284 static SpinLock lock_; | 280 static SpinLock lock_; |
285 // Lock to protect the recursive lock itself. | 281 // Lock to protect the recursive lock itself. |
286 static SpinLock owner_lock_; | 282 static SpinLock owner_lock_; |
287 | 283 |
288 // Recursion count for the recursive lock. | 284 // Recursion count for the recursive lock. |
289 static int recursion_count_; | 285 static int recursion_count_; |
290 // The thread id of the thread that's inside the recursive lock. | 286 // The thread id of the thread that's inside the recursive lock. |
291 static pthread_t lock_owner_tid_; | 287 static pthread_t lock_owner_tid_; |
292 | 288 |
293 // Total size of all mapped pages so far | |
294 static int64 map_size_; | |
295 // Total size of all unmapped pages so far | |
296 static int64 unmap_size_; | |
297 | |
298 // helpers ================================================================== | 289 // helpers ================================================================== |
299 | 290 |
300 // Helper for FindRegion and FindAndMarkStackRegion: | 291 // Helper for FindRegion and FindAndMarkStackRegion: |
301 // returns the region covering 'addr' or NULL; assumes our lock_ is held. | 292 // returns the region covering 'addr' or NULL; assumes our lock_ is held. |
302 static const Region* DoFindRegionLocked(uintptr_t addr); | 293 static const Region* DoFindRegionLocked(uintptr_t addr); |
303 | 294 |
304 // Verifying wrapper around regions_->insert(region) | 295 // Verifying wrapper around regions_->insert(region) |
305 // To be called to do InsertRegionLocked's work only! | 296 // To be called to do InsertRegionLocked's work only! |
306 inline static void DoInsertRegionLocked(const Region& region); | 297 inline static void DoInsertRegionLocked(const Region& region); |
307 // Handle regions saved by InsertRegionLocked into a tmp static array | 298 // Handle regions saved by InsertRegionLocked into a tmp static array |
(...skipping 23 matching lines...) Expand all Loading... |
331 static void SbrkHook(const void* result, std::ptrdiff_t increment); | 322 static void SbrkHook(const void* result, std::ptrdiff_t increment); |
332 | 323 |
333 // Log all memory regions; Useful for debugging only. | 324 // Log all memory regions; Useful for debugging only. |
334 // Assumes Lock() is held | 325 // Assumes Lock() is held |
335 static void LogAllLocked(); | 326 static void LogAllLocked(); |
336 | 327 |
337 DISALLOW_COPY_AND_ASSIGN(MemoryRegionMap); | 328 DISALLOW_COPY_AND_ASSIGN(MemoryRegionMap); |
338 }; | 329 }; |
339 | 330 |
340 #endif // BASE_MEMORY_REGION_MAP_H_ | 331 #endif // BASE_MEMORY_REGION_MAP_H_ |
OLD | NEW |