Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1742)

Unified Diff: test/cctest/cctest.h

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
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/cctest/cctest.h
diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h
index 193126a0818e91a1aac21a900c0b0db476c7467d..41f11307ca61a1ba624140358ccaaa18b0b1df87 100644
--- a/test/cctest/cctest.h
+++ b/test/cctest/cctest.h
@@ -71,6 +71,17 @@ typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags;
EXTENSION_LIST(DEFINE_EXTENSION_FLAG)
#undef DEFINE_EXTENSION_FLAG
+void RunAndTrackAllocations(void (*test)());
+
+#ifndef TEST_TRACK_ALLOCATIONS
+#define TEST_TRACK_ALLOCATIONS(Name) \
+ static void Test##Name(); \
+ TEST(Name##TrackAllocations) { \
+ RunAndTrackAllocations(&Test##Name); \
+ } \
+ TEST(Name)
+#endif
+
class CcTest {
public:
typedef void (TestFunction)();
@@ -300,4 +311,38 @@ static inline void SimulateFullSpace(v8::internal::PagedSpace* space) {
}
+// Helper class for new allocations tracking and checking
+class HeapObjectsTracker {
+ public:
+ HeapObjectsTracker() {
+ heap_profiler_ = i::Isolate::Current()->heap_profiler();
+ CHECK_NE(NULL, heap_profiler_);
+
+ heap_profiler_->StartHeapObjectsTracking();
+
+ HEAP->CollectAllAvailableGarbage();
+ HEAP->CollectAllAvailableGarbage();
+ HEAP->CollectAllAvailableGarbage();
+ untracked_on_start_ = heap_profiler_->FindUntrackedObjects();
+ }
+
+ virtual ~HeapObjectsTracker() {
+ CHECK_GE(0, test());
+ heap_profiler_->StopHeapObjectsTracking();
+ }
+
+ int test() {
yurys 2013/08/26 06:32:25 GetUntrackedObjectsCount
Alexandra Mikhaylova 2013/08/26 15:48:40 Done.
+ HEAP->CollectAllAvailableGarbage();
+ HEAP->CollectAllAvailableGarbage();
+ HEAP->CollectAllAvailableGarbage();
+
+ return heap_profiler_->FindUntrackedObjects() - untracked_on_start_;
+ }
+
+ private:
+ i::HeapProfiler* heap_profiler_;
+ int untracked_on_start_;
+};
+
+
#endif // ifndef CCTEST_H_

Powered by Google App Engine
This is Rietveld 408576698