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 |
255 // Effectively private type from our .cc ================================= | 259 // Effectively private type from our .cc ================================= |
256 // public to let us declare global objects: | 260 // public to let us declare global objects: |
257 union RegionSetRep; | 261 union RegionSetRep; |
258 | 262 |
259 private: | 263 private: |
260 // representation =========================================================== | 264 // representation =========================================================== |
261 | 265 |
262 // Counter of clients of this module that have called Init(). | 266 // Counter of clients of this module that have called Init(). |
263 static int client_count_; | 267 static int client_count_; |
264 | 268 |
(...skipping 14 matching lines...) Expand all Loading... |
279 // Lock to protect regions_ variable and the data behind. | 283 // Lock to protect regions_ variable and the data behind. |
280 static SpinLock lock_; | 284 static SpinLock lock_; |
281 // Lock to protect the recursive lock itself. | 285 // Lock to protect the recursive lock itself. |
282 static SpinLock owner_lock_; | 286 static SpinLock owner_lock_; |
283 | 287 |
284 // Recursion count for the recursive lock. | 288 // Recursion count for the recursive lock. |
285 static int recursion_count_; | 289 static int recursion_count_; |
286 // The thread id of the thread that's inside the recursive lock. | 290 // The thread id of the thread that's inside the recursive lock. |
287 static pthread_t lock_owner_tid_; | 291 static pthread_t lock_owner_tid_; |
288 | 292 |
| 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 |
289 // helpers ================================================================== | 298 // helpers ================================================================== |
290 | 299 |
291 // Helper for FindRegion and FindAndMarkStackRegion: | 300 // Helper for FindRegion and FindAndMarkStackRegion: |
292 // returns the region covering 'addr' or NULL; assumes our lock_ is held. | 301 // returns the region covering 'addr' or NULL; assumes our lock_ is held. |
293 static const Region* DoFindRegionLocked(uintptr_t addr); | 302 static const Region* DoFindRegionLocked(uintptr_t addr); |
294 | 303 |
295 // Verifying wrapper around regions_->insert(region) | 304 // Verifying wrapper around regions_->insert(region) |
296 // To be called to do InsertRegionLocked's work only! | 305 // To be called to do InsertRegionLocked's work only! |
297 inline static void DoInsertRegionLocked(const Region& region); | 306 inline static void DoInsertRegionLocked(const Region& region); |
298 // Handle regions saved by InsertRegionLocked into a tmp static array | 307 // Handle regions saved by InsertRegionLocked into a tmp static array |
(...skipping 23 matching lines...) Expand all Loading... |
322 static void SbrkHook(const void* result, std::ptrdiff_t increment); | 331 static void SbrkHook(const void* result, std::ptrdiff_t increment); |
323 | 332 |
324 // Log all memory regions; Useful for debugging only. | 333 // Log all memory regions; Useful for debugging only. |
325 // Assumes Lock() is held | 334 // Assumes Lock() is held |
326 static void LogAllLocked(); | 335 static void LogAllLocked(); |
327 | 336 |
328 DISALLOW_COPY_AND_ASSIGN(MemoryRegionMap); | 337 DISALLOW_COPY_AND_ASSIGN(MemoryRegionMap); |
329 }; | 338 }; |
330 | 339 |
331 #endif // BASE_MEMORY_REGION_MAP_H_ | 340 #endif // BASE_MEMORY_REGION_MAP_H_ |
OLD | NEW |