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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « test/cctest/test-debug.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 23 matching lines...) Expand all
34 #include "src/context-measure.h" 34 #include "src/context-measure.h"
35 #include "src/deoptimizer.h" 35 #include "src/deoptimizer.h"
36 #include "src/execution.h" 36 #include "src/execution.h"
37 #include "src/factory.h" 37 #include "src/factory.h"
38 #include "src/global-handles.h" 38 #include "src/global-handles.h"
39 #include "src/ic/ic.h" 39 #include "src/ic/ic.h"
40 #include "src/macro-assembler.h" 40 #include "src/macro-assembler.h"
41 #include "src/snapshot/snapshot.h" 41 #include "src/snapshot/snapshot.h"
42 #include "test/cctest/cctest.h" 42 #include "test/cctest/cctest.h"
43 43
44 using namespace v8::internal;
45 using v8::Just; 44 using v8::Just;
46 45
46 namespace v8 {
47 namespace internal {
48
49 // Tests that should have access to private methods of {v8::internal::Heap}.
50 // Those tests need to be defined using HEAP_TEST(Name) { ... }.
51 #define HEAP_TEST_METHODS(V) \
52 V(GCFlags)
53
54
55 #define HEAP_TEST(Name) \
56 CcTest register_test_##Name(HeapTester::Test##Name, __FILE__, #Name, NULL, \
57 true, true); \
58 void HeapTester::Test##Name()
59
60
61 class HeapTester {
62 public:
63 #define DECLARE_STATIC(Name) static void Test##Name();
64
65 HEAP_TEST_METHODS(DECLARE_STATIC)
66 #undef HEAP_TEST_METHODS
67 };
68
69
47 static void CheckMap(Map* map, int type, int instance_size) { 70 static void CheckMap(Map* map, int type, int instance_size) {
48 CHECK(map->IsHeapObject()); 71 CHECK(map->IsHeapObject());
49 #ifdef DEBUG 72 #ifdef DEBUG
50 CHECK(CcTest::heap()->Contains(map)); 73 CHECK(CcTest::heap()->Contains(map));
51 #endif 74 #endif
52 CHECK_EQ(CcTest::heap()->meta_map(), map->map()); 75 CHECK_EQ(CcTest::heap()->meta_map(), map->map());
53 CHECK_EQ(type, map->instance_type()); 76 CHECK_EQ(type, map->instance_type());
54 CHECK_EQ(instance_size, map->instance_size()); 77 CHECK_EQ(instance_size, map->instance_size());
55 } 78 }
56 79
(...skipping 2704 matching lines...) Expand 10 before | Expand all | Expand 10 after
2761 // The following two calls will increment CcTest::heap()->global_ic_age(). 2784 // The following two calls will increment CcTest::heap()->global_ic_age().
2762 CcTest::isolate()->ContextDisposedNotification(); 2785 CcTest::isolate()->ContextDisposedNotification();
2763 CcTest::heap()->CollectAllGarbage(); 2786 CcTest::heap()->CollectAllGarbage();
2764 2787
2765 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); 2788 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
2766 CHECK_EQ(0, f->shared()->opt_count()); 2789 CHECK_EQ(0, f->shared()->opt_count());
2767 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2790 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2768 } 2791 }
2769 2792
2770 2793
2794 HEAP_TEST(GCFlags) {
2795 CcTest::InitializeVM();
2796 Heap* heap = CcTest::heap();
2797
2798 heap->set_current_gc_flags(Heap::kNoGCFlags);
2799 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags());
2800
2801 // Set the flags to check whether we appropriately resets them after the GC.
2802 heap->set_current_gc_flags(Heap::kAbortIncrementalMarkingMask);
2803 heap->CollectAllGarbage(Heap::kReduceMemoryFootprintMask);
2804 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags());
2805
2806 MarkCompactCollector* collector = heap->mark_compact_collector();
2807 if (collector->sweeping_in_progress()) {
2808 collector->EnsureSweepingCompleted();
2809 }
2810
2811 IncrementalMarking* marking = heap->incremental_marking();
2812 marking->Stop();
2813 marking->Start(Heap::kReduceMemoryFootprintMask);
2814 CHECK_NE(0, heap->current_gc_flags() & Heap::kReduceMemoryFootprintMask);
2815
2816 heap->Scavenge();
2817 CHECK_NE(0, heap->current_gc_flags() & Heap::kReduceMemoryFootprintMask);
2818
2819 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
2820 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags());
2821 }
2822
2823
2771 TEST(IdleNotificationFinishMarking) { 2824 TEST(IdleNotificationFinishMarking) {
2772 i::FLAG_allow_natives_syntax = true; 2825 i::FLAG_allow_natives_syntax = true;
2773 CcTest::InitializeVM(); 2826 CcTest::InitializeVM();
2774 SimulateFullSpace(CcTest::heap()->old_space()); 2827 SimulateFullSpace(CcTest::heap()->old_space());
2775 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 2828 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2776 marking->Stop(); 2829 marking->Stop();
2777 marking->Start(Heap::kNoGCFlags); 2830 marking->Start(Heap::kNoGCFlags);
2778 2831
2779 CHECK_EQ(CcTest::heap()->gc_count(), 0); 2832 CHECK_EQ(CcTest::heap()->gc_count(), 0);
2780 2833
(...skipping 3599 matching lines...) Expand 10 before | Expand all | Expand 10 after
6380 6433
6381 PrintF("Context size : %d bytes\n", measure.Size()); 6434 PrintF("Context size : %d bytes\n", measure.Size());
6382 PrintF("Context object count: %d\n", measure.Count()); 6435 PrintF("Context object count: %d\n", measure.Count());
6383 6436
6384 CHECK_LE(1000, measure.Count()); 6437 CHECK_LE(1000, measure.Count());
6385 CHECK_LE(50000, measure.Size()); 6438 CHECK_LE(50000, measure.Size());
6386 6439
6387 CHECK_LE(measure.Count(), count_upper_limit); 6440 CHECK_LE(measure.Count(), count_upper_limit);
6388 CHECK_LE(measure.Size(), size_upper_limit); 6441 CHECK_LE(measure.Size(), size_upper_limit);
6389 } 6442 }
6443
6444 } // namespace internal
6445 } // namespace v8
OLDNEW
« 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