1 // Copyright 2015 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef HEAP_HEAP_TESTER_H_ 6 #define HEAP_HEAP_TESTER_H_ 7 8 #include "src/handles.h" 9 #include "src/heap/spaces.h" 10 11 // Tests that should have access to private methods of {v8::internal::Heap}. 12 // Those tests need to be defined using HEAP_TEST(Name) { ... }. 13 #define HEAP_TEST_METHODS(V) \ 14 V(CompactionFullAbortedPage) \ 15 V(CompactionPartiallyAbortedPage) \ 16 V(CompactionPartiallyAbortedPageIntraAbortedPointers) \ 17 V(CompactionPartiallyAbortedPageWithStoreBufferEntries) \ 18 V(CompactionSpaceDivideMultiplePages) \ 19 V(CompactionSpaceDivideSinglePage) \ 20 V(GCFlags) \ 21 V(MarkCompactCollector) \ 22 V(NoPromotion) \ 23 V(NumberStringCacheSize) \ 24 V(ObjectGroups) \ 25 V(Promotion) \ 26 V(Regression39128) \ 27 V(ResetWeakHandle) \ 28 V(StressHandles) \ 29 V(TestMemoryReducerSampleJsCalls) \ 30 V(TestSizeOfObjects) \ 31 V(WriteBarriersInCopyJSObject) 32 33 34 #define HEAP_TEST(Name) \ 35 CcTest register_test_##Name(v8::internal::HeapTester::Test##Name, __FILE__, \ 36 #Name, NULL, true, true); \ 37 void v8::internal::HeapTester::Test##Name() 38 39 40 #define THREADED_HEAP_TEST(Name) \ 41 RegisterThreadedTest register_##Name(v8::internal::HeapTester::Test##Name, \ 42 #Name); \ 43 /* */ HEAP_TEST(Name) 44 45 46 namespace v8 { 47 namespace internal { 48 49 class HeapTester { 50 public: 51 #define DECLARE_STATIC(Name) static void Test##Name(); 52 53 HEAP_TEST_METHODS(DECLARE_STATIC) 54 #undef HEAP_TEST_METHODS 55 56 /* test-alloc.cc */ 57 static AllocationResult AllocateAfterFailures(); 58 static Handle<Object> TestAllocateAfterFailures(); 59 60 /* test-api.cc */ 61 static void ResetWeakHandle(bool global_gc); 62 63 /* test-spaces.cc */ 64 static CompactionSpaceCollection** InitializeCompactionSpaces(Heap* heap, 65 int num_spaces); 66 static void DestroyCompactionSpaces(CompactionSpaceCollection** spaces, 67 int num_spaces); 68 static void MergeCompactionSpaces(PagedSpace* space, 69 CompactionSpaceCollection** spaces, 70 int num_spaces); 71 static void AllocateInCompactionSpaces(CompactionSpaceCollection** spaces, 72 AllocationSpace id, int num_spaces, 73 int num_objects, int object_size); 74 static void CompactionStats(CompactionSpaceCollection** spaces, 75 AllocationSpace id, int num_spaces, 76 intptr_t* capacity, intptr_t* size); 77 static void TestCompactionSpaceDivide(int num_additional_objects, 78 int object_size, 79 int num_compaction_spaces, 80 int additional_capacity_in_bytes); 81 }; 82 83 } // namespace internal 84 } // namespace v8 85 86 #endif // HEAP_HEAP_TESTER_H_ 87