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

Unified Diff: test/cctest/test-heap.cc

Issue 1301183002: [heap] Cleanup and fix GC flags / add testing infra (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed Hannes' comments Created 5 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
« no previous file with comments | « test/cctest/test-debug.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 1c09752b726e4a2cfe32ff36b698086edc60b78c..ec20f759206b2cdf9684aabccec00f6ba4ecf284 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -41,9 +41,32 @@
#include "src/snapshot/snapshot.h"
#include "test/cctest/cctest.h"
-using namespace v8::internal;
using v8::Just;
+namespace v8 {
+namespace internal {
+
+// Tests that should have access to private methods of {v8::internal::Heap}.
+// Those tests need to be defined using HEAP_TEST(Name) { ... }.
+#define HEAP_TEST_METHODS(V) \
+ V(GCFlags)
+
+
+#define HEAP_TEST(Name) \
+ CcTest register_test_##Name(HeapTester::Test##Name, __FILE__, #Name, NULL, \
+ true, true); \
+ void HeapTester::Test##Name()
+
+
+class HeapTester {
+ public:
+#define DECLARE_STATIC(Name) static void Test##Name();
+
+ HEAP_TEST_METHODS(DECLARE_STATIC)
+#undef HEAP_TEST_METHODS
+};
+
+
static void CheckMap(Map* map, int type, int instance_size) {
CHECK(map->IsHeapObject());
#ifdef DEBUG
@@ -2768,6 +2791,36 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) {
}
+HEAP_TEST(GCFlags) {
+ CcTest::InitializeVM();
+ Heap* heap = CcTest::heap();
+
+ heap->set_current_gc_flags(Heap::kNoGCFlags);
+ CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags());
+
+ // Set the flags to check whether we appropriately resets them after the GC.
+ heap->set_current_gc_flags(Heap::kAbortIncrementalMarkingMask);
+ heap->CollectAllGarbage(Heap::kReduceMemoryFootprintMask);
+ CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags());
+
+ MarkCompactCollector* collector = heap->mark_compact_collector();
+ if (collector->sweeping_in_progress()) {
+ collector->EnsureSweepingCompleted();
+ }
+
+ IncrementalMarking* marking = heap->incremental_marking();
+ marking->Stop();
+ marking->Start(Heap::kReduceMemoryFootprintMask);
+ CHECK_NE(0, heap->current_gc_flags() & Heap::kReduceMemoryFootprintMask);
+
+ heap->Scavenge();
+ CHECK_NE(0, heap->current_gc_flags() & Heap::kReduceMemoryFootprintMask);
+
+ heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags());
+}
+
+
TEST(IdleNotificationFinishMarking) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
@@ -6387,3 +6440,6 @@ TEST(ContextMeasure) {
CHECK_LE(measure.Count(), count_upper_limit);
CHECK_LE(measure.Size(), size_upper_limit);
}
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « test/cctest/test-debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698