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

Side by Side Diff: test/cctest/test-mark-compact.cc

Issue 1293283003: [heap,cctest] Get rid of protected-for-sake-of-testing scope. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add heap-tester.h to cctest.gyp 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-heap.cc ('k') | test/cctest/test-unboxed-doubles.cc » ('j') | 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 24 matching lines...) Expand all
35 #include <unistd.h> 35 #include <unistd.h>
36 #endif 36 #endif
37 37
38 #include <utility> 38 #include <utility>
39 39
40 #include "src/v8.h" 40 #include "src/v8.h"
41 41
42 #include "src/full-codegen/full-codegen.h" 42 #include "src/full-codegen/full-codegen.h"
43 #include "src/global-handles.h" 43 #include "src/global-handles.h"
44 #include "test/cctest/cctest.h" 44 #include "test/cctest/cctest.h"
45 #include "test/cctest/heap-tester.h"
45 46
46 using namespace v8::internal; 47 using namespace v8::internal;
47 using v8::Just; 48 using v8::Just;
48 49
49 50
50 TEST(MarkingDeque) { 51 TEST(MarkingDeque) {
51 CcTest::InitializeVM(); 52 CcTest::InitializeVM();
52 int mem_size = 20 * kPointerSize; 53 int mem_size = 20 * kPointerSize;
53 byte* mem = NewArray<byte>(20*kPointerSize); 54 byte* mem = NewArray<byte>(20*kPointerSize);
54 Address low = reinterpret_cast<Address>(mem); 55 Address low = reinterpret_cast<Address>(mem);
(...skipping 12 matching lines...) Expand all
67 Address value = s.Pop()->address(); 68 Address value = s.Pop()->address();
68 current_address -= kPointerSize; 69 current_address -= kPointerSize;
69 CHECK_EQ(current_address, value); 70 CHECK_EQ(current_address, value);
70 } 71 }
71 72
72 CHECK_EQ(original_address, current_address); 73 CHECK_EQ(original_address, current_address);
73 DeleteArray(mem); 74 DeleteArray(mem);
74 } 75 }
75 76
76 77
77 TEST(Promotion) { 78 HEAP_TEST(Promotion) {
78 CcTest::InitializeVM(); 79 CcTest::InitializeVM();
79 TestHeap* heap = CcTest::test_heap(); 80 Heap* heap = CcTest::heap();
80 heap->ConfigureHeap(1, 1, 1, 0); 81 heap->ConfigureHeap(1, 1, 1, 0);
81 82
82 v8::HandleScope sc(CcTest::isolate()); 83 v8::HandleScope sc(CcTest::isolate());
83 84
84 // Allocate a fixed array in the new space. 85 // Allocate a fixed array in the new space.
85 int array_length = 86 int array_length =
86 (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) / 87 (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) /
87 (4 * kPointerSize); 88 (4 * kPointerSize);
88 Object* obj = heap->AllocateFixedArray(array_length).ToObjectChecked(); 89 Object* obj = heap->AllocateFixedArray(array_length).ToObjectChecked();
89 Handle<FixedArray> array(FixedArray::cast(obj)); 90 Handle<FixedArray> array(FixedArray::cast(obj));
90 91
91 // Array should be in the new space. 92 // Array should be in the new space.
92 CHECK(heap->InSpace(*array, NEW_SPACE)); 93 CHECK(heap->InSpace(*array, NEW_SPACE));
93 94
94 // Call mark compact GC, so array becomes an old object. 95 // Call mark compact GC, so array becomes an old object.
95 heap->CollectAllGarbage(); 96 heap->CollectAllGarbage();
96 heap->CollectAllGarbage(); 97 heap->CollectAllGarbage();
97 98
98 // Array now sits in the old space 99 // Array now sits in the old space
99 CHECK(heap->InSpace(*array, OLD_SPACE)); 100 CHECK(heap->InSpace(*array, OLD_SPACE));
100 } 101 }
101 102
102 103
103 TEST(NoPromotion) { 104 HEAP_TEST(NoPromotion) {
104 CcTest::InitializeVM(); 105 CcTest::InitializeVM();
105 TestHeap* heap = CcTest::test_heap(); 106 Heap* heap = CcTest::heap();
106 heap->ConfigureHeap(1, 1, 1, 0); 107 heap->ConfigureHeap(1, 1, 1, 0);
107 108
108 v8::HandleScope sc(CcTest::isolate()); 109 v8::HandleScope sc(CcTest::isolate());
109 110
110 // Allocate a big fixed array in the new space. 111 // Allocate a big fixed array in the new space.
111 int array_length = 112 int array_length =
112 (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) / 113 (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) /
113 (2 * kPointerSize); 114 (2 * kPointerSize);
114 Object* obj = heap->AllocateFixedArray(array_length).ToObjectChecked(); 115 Object* obj = heap->AllocateFixedArray(array_length).ToObjectChecked();
115 Handle<FixedArray> array(FixedArray::cast(obj)); 116 Handle<FixedArray> array(FixedArray::cast(obj));
116 117
117 // Array should be in the new space. 118 // Array should be in the new space.
118 CHECK(heap->InSpace(*array, NEW_SPACE)); 119 CHECK(heap->InSpace(*array, NEW_SPACE));
119 120
120 // Simulate a full old space to make promotion fail. 121 // Simulate a full old space to make promotion fail.
121 SimulateFullSpace(heap->old_space()); 122 SimulateFullSpace(heap->old_space());
122 123
123 // Call mark compact GC, and it should pass. 124 // Call mark compact GC, and it should pass.
124 heap->CollectGarbage(OLD_SPACE); 125 heap->CollectGarbage(OLD_SPACE);
125 } 126 }
126 127
127 128
128 TEST(MarkCompactCollector) { 129 HEAP_TEST(MarkCompactCollector) {
129 FLAG_incremental_marking = false; 130 FLAG_incremental_marking = false;
130 FLAG_retain_maps_for_n_gc = 0; 131 FLAG_retain_maps_for_n_gc = 0;
131 CcTest::InitializeVM(); 132 CcTest::InitializeVM();
132 Isolate* isolate = CcTest::i_isolate(); 133 Isolate* isolate = CcTest::i_isolate();
133 TestHeap* heap = CcTest::test_heap(); 134 Heap* heap = CcTest::heap();
134 Factory* factory = isolate->factory(); 135 Factory* factory = isolate->factory();
135 136
136 v8::HandleScope sc(CcTest::isolate()); 137 v8::HandleScope sc(CcTest::isolate());
137 Handle<GlobalObject> global(isolate->context()->global_object()); 138 Handle<GlobalObject> global(isolate->context()->global_object());
138 139
139 // call mark-compact when heap is empty 140 // call mark-compact when heap is empty
140 heap->CollectGarbage(OLD_SPACE, "trigger 1"); 141 heap->CollectGarbage(OLD_SPACE, "trigger 1");
141 142
142 // keep allocating garbage in new space until it fails 143 // keep allocating garbage in new space until it fails
143 const int arraysize = 100; 144 const int arraysize = 100;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 const v8::WeakCallbackData<v8::Value, void>& data) { 238 const v8::WeakCallbackData<v8::Value, void>& data) {
238 std::pair<v8::Persistent<v8::Value>*, int>* p = 239 std::pair<v8::Persistent<v8::Value>*, int>* p =
239 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( 240 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
240 data.GetParameter()); 241 data.GetParameter());
241 DCHECK_EQ(1234, p->second); 242 DCHECK_EQ(1234, p->second);
242 NumberOfWeakCalls++; 243 NumberOfWeakCalls++;
243 p->first->Reset(); 244 p->first->Reset();
244 } 245 }
245 246
246 247
247 TEST(ObjectGroups) { 248 HEAP_TEST(ObjectGroups) {
248 FLAG_incremental_marking = false; 249 FLAG_incremental_marking = false;
249 CcTest::InitializeVM(); 250 CcTest::InitializeVM();
250 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); 251 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles();
251 TestHeap* heap = CcTest::test_heap(); 252 Heap* heap = CcTest::heap();
252 NumberOfWeakCalls = 0; 253 NumberOfWeakCalls = 0;
253 v8::HandleScope handle_scope(CcTest::isolate()); 254 v8::HandleScope handle_scope(CcTest::isolate());
254 255
255 Handle<Object> g1s1 = 256 Handle<Object> g1s1 =
256 global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); 257 global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked());
257 Handle<Object> g1s2 = 258 Handle<Object> g1s2 =
258 global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); 259 global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked());
259 Handle<Object> g1c1 = 260 Handle<Object> g1c1 =
260 global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); 261 global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked());
261 std::pair<Handle<Object>*, int> g1s1_and_id(&g1s1, 1234); 262 std::pair<Handle<Object>*, int> g1s1_and_id(&g1s1, 1234);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 486
486 487
487 TEST(RegressJoinThreadsOnIsolateDeinit) { 488 TEST(RegressJoinThreadsOnIsolateDeinit) {
488 intptr_t size_limit = ShortLivingIsolate() * 2; 489 intptr_t size_limit = ShortLivingIsolate() * 2;
489 for (int i = 0; i < 10; i++) { 490 for (int i = 0; i < 10; i++) {
490 CHECK_GT(size_limit, ShortLivingIsolate()); 491 CHECK_GT(size_limit, ShortLivingIsolate());
491 } 492 }
492 } 493 }
493 494
494 #endif // __linux__ and !USE_SIMULATOR 495 #endif // __linux__ and !USE_SIMULATOR
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-unboxed-doubles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698