 Chromium Code Reviews
 Chromium Code Reviews Issue 22852024:
  Track JS allocations as they arrive with no affection on performance when tracking is switched off  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 22852024:
  Track JS allocations as they arrive with no affection on performance when tracking is switched off  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| OLD | NEW | 
|---|---|
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright | 
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. | 
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above | 
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following | 
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 #undef DEFINE_EXTENSION_ID | 64 #undef DEFINE_EXTENSION_ID | 
| 65 | 65 | 
| 66 typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags; | 66 typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags; | 
| 67 #define DEFINE_EXTENSION_FLAG(Name, Ident) \ | 67 #define DEFINE_EXTENSION_FLAG(Name, Ident) \ | 
| 68 static const CcTestExtensionFlags Name(1 << Name##_ID); | 68 static const CcTestExtensionFlags Name(1 << Name##_ID); | 
| 69 static const CcTestExtensionFlags NO_EXTENSIONS(0); | 69 static const CcTestExtensionFlags NO_EXTENSIONS(0); | 
| 70 static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1); | 70 static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1); | 
| 71 EXTENSION_LIST(DEFINE_EXTENSION_FLAG) | 71 EXTENSION_LIST(DEFINE_EXTENSION_FLAG) | 
| 72 #undef DEFINE_EXTENSION_FLAG | 72 #undef DEFINE_EXTENSION_FLAG | 
| 73 | 73 | 
| 74 void RunAndTrackAllocations(void (*test)()); | |
| 75 | |
| 76 #ifndef TEST_TRACK_ALLOCATIONS | |
| 77 #define TEST_TRACK_ALLOCATIONS(Name) \ | |
| 78 static void Test##Name(); \ | |
| 79 TEST(Name##TrackAllocations) { \ | |
| 80 RunAndTrackAllocations(&Test##Name); \ | |
| 81 } \ | |
| 82 TEST(Name) | |
| 83 #endif | |
| 84 | |
| 74 class CcTest { | 85 class CcTest { | 
| 75 public: | 86 public: | 
| 76 typedef void (TestFunction)(); | 87 typedef void (TestFunction)(); | 
| 77 CcTest(TestFunction* callback, const char* file, const char* name, | 88 CcTest(TestFunction* callback, const char* file, const char* name, | 
| 78 const char* dependency, bool enabled); | 89 const char* dependency, bool enabled); | 
| 79 void Run() { callback_(); } | 90 void Run() { callback_(); } | 
| 80 static CcTest* last() { return last_; } | 91 static CcTest* last() { return last_; } | 
| 81 CcTest* prev() { return prev_; } | 92 CcTest* prev() { return prev_; } | 
| 82 const char* file() { return file_; } | 93 const char* file() { return file_; } | 
| 83 const char* name() { return name_; } | 94 const char* name() { return name_; } | 
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 // Helper function that simulates a full old-space in the heap. | 304 // Helper function that simulates a full old-space in the heap. | 
| 294 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { | 305 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { | 
| 295 int old_linear_size = static_cast<int>(space->limit() - space->top()); | 306 int old_linear_size = static_cast<int>(space->limit() - space->top()); | 
| 296 space->Free(space->top(), old_linear_size); | 307 space->Free(space->top(), old_linear_size); | 
| 297 space->SetTop(space->limit(), space->limit()); | 308 space->SetTop(space->limit(), space->limit()); | 
| 298 space->ResetFreeList(); | 309 space->ResetFreeList(); | 
| 299 space->ClearStats(); | 310 space->ClearStats(); | 
| 300 } | 311 } | 
| 301 | 312 | 
| 302 | 313 | 
| 314 // Helper class for new allocations tracking and checking | |
| 315 class HeapObjectsTracker { | |
| 316 public: | |
| 317 HeapObjectsTracker() { | |
| 318 heap_profiler_ = i::Isolate::Current()->heap_profiler(); | |
| 319 CHECK_NE(NULL, heap_profiler_); | |
| 320 | |
| 321 heap_profiler_->StartHeapObjectsTracking(); | |
| 322 | |
| 323 HEAP->CollectAllAvailableGarbage(); | |
| 324 HEAP->CollectAllAvailableGarbage(); | |
| 325 HEAP->CollectAllAvailableGarbage(); | |
| 326 untracked_on_start_ = heap_profiler_->FindUntrackedObjects(); | |
| 327 } | |
| 328 | |
| 329 virtual ~HeapObjectsTracker() { | |
| 330 CHECK_GE(0, test()); | |
| 331 heap_profiler_->StopHeapObjectsTracking(); | |
| 332 } | |
| 333 | |
| 334 int test() { | |
| 
yurys
2013/08/26 06:32:25
GetUntrackedObjectsCount
 
Alexandra Mikhaylova
2013/08/26 15:48:40
Done.
 | |
| 335 HEAP->CollectAllAvailableGarbage(); | |
| 336 HEAP->CollectAllAvailableGarbage(); | |
| 337 HEAP->CollectAllAvailableGarbage(); | |
| 338 | |
| 339 return heap_profiler_->FindUntrackedObjects() - untracked_on_start_; | |
| 340 } | |
| 341 | |
| 342 private: | |
| 343 i::HeapProfiler* heap_profiler_; | |
| 344 int untracked_on_start_; | |
| 345 }; | |
| 346 | |
| 347 | |
| 303 #endif // ifndef CCTEST_H_ | 348 #endif // ifndef CCTEST_H_ | 
| OLD | NEW |