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

Side by Side 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: Deoptimize code and generate optimized code when switching allocations tracking Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags; 73 typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags;
74 #define DEFINE_EXTENSION_FLAG(Name, Ident) \ 74 #define DEFINE_EXTENSION_FLAG(Name, Ident) \
75 static const CcTestExtensionFlags Name(1 << Name##_ID); 75 static const CcTestExtensionFlags Name(1 << Name##_ID);
76 static const CcTestExtensionFlags NO_EXTENSIONS(0); 76 static const CcTestExtensionFlags NO_EXTENSIONS(0);
77 static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1); 77 static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1);
78 EXTENSION_LIST(DEFINE_EXTENSION_FLAG) 78 EXTENSION_LIST(DEFINE_EXTENSION_FLAG)
79 #undef DEFINE_EXTENSION_FLAG 79 #undef DEFINE_EXTENSION_FLAG
80 80
81 81
82 void RunAndTrackAllocations(void (*test)());
83
84 #ifndef TEST_TRACK_ALLOCATIONS
85 #define TEST_TRACK_ALLOCATIONS(Name) \
86 static void Test##Name(); \
87 TEST(Name##TrackAllocations) { \
88 RunAndTrackAllocations(&Test##Name); \
89 } \
90 TEST(Name)
91 #endif
92
82 class CcTest { 93 class CcTest {
83 public: 94 public:
84 typedef void (TestFunction)(); 95 typedef void (TestFunction)();
85 CcTest(TestFunction* callback, const char* file, const char* name, 96 CcTest(TestFunction* callback, const char* file, const char* name,
86 const char* dependency, bool enabled, bool initialize); 97 const char* dependency, bool enabled, bool initialize);
87 void Run(); 98 void Run();
88 static CcTest* last() { return last_; } 99 static CcTest* last() { return last_; }
89 CcTest* prev() { return prev_; } 100 CcTest* prev() { return prev_; }
90 const char* file() { return file_; } 101 const char* file() { return file_; }
91 const char* name() { return name_; } 102 const char* name() { return name_; }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // Helper function that simulates a full old-space in the heap. 344 // Helper function that simulates a full old-space in the heap.
334 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { 345 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) {
335 int old_linear_size = static_cast<int>(space->limit() - space->top()); 346 int old_linear_size = static_cast<int>(space->limit() - space->top());
336 space->Free(space->top(), old_linear_size); 347 space->Free(space->top(), old_linear_size);
337 space->SetTop(space->limit(), space->limit()); 348 space->SetTop(space->limit(), space->limit());
338 space->ResetFreeList(); 349 space->ResetFreeList();
339 space->ClearStats(); 350 space->ClearStats();
340 } 351 }
341 352
342 353
354 // Helper class for new allocations tracking and checking.
355 // To use checking of JS allocations tracking in a test,
356 // use TEST_TRACK_ALLOCATIONS macro or just create an instance
357 // of this class.
358 class HeapObjectsTracker {
359 public:
360 HeapObjectsTracker() {
361 heap_profiler_ = i::Isolate::Current()->heap_profiler();
362 CHECK_NE(NULL, heap_profiler_);
363 heap_profiler_->StartHeapAllocationsRecording();
364 untracked_on_start_ = heap_profiler_->FindUntrackedObjects();
365 }
366
367 virtual ~HeapObjectsTracker() {
368 i::Isolate::Current()->heap()->CollectAllAvailableGarbage();
369 CHECK_EQ(0, CountUntrackedObjects());
370 heap_profiler_->StopHeapAllocationsRecording();
371 }
372
373 private:
374 int CountUntrackedObjects() {
375 return heap_profiler_->FindUntrackedObjects() - untracked_on_start_;
376 }
377
378 i::HeapProfiler* heap_profiler_;
379 int untracked_on_start_;
380 };
381
382
343 #endif // ifndef CCTEST_H_ 383 #endif // ifndef CCTEST_H_
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | test/cctest/cctest.cc » ('j') | test/cctest/cctest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698