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

Side by Side Diff: test/cctest/test-spaces.cc

Issue 9227007: Version 3.8.6 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 11 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
« no previous file with comments | « test/cctest/test-sockets.cc ('k') | test/cctest/test-utils.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 Isolate* isolate_; 118 Isolate* isolate_;
119 MemoryAllocator* old_allocator_; 119 MemoryAllocator* old_allocator_;
120 120
121 DISALLOW_COPY_AND_ASSIGN(TestMemoryAllocatorScope); 121 DISALLOW_COPY_AND_ASSIGN(TestMemoryAllocatorScope);
122 }; 122 };
123 123
124 } } // namespace v8::internal 124 } } // namespace v8::internal
125 125
126 126
127 TEST(MemoryAllocator) { 127 TEST(MemoryAllocator) {
128 OS::Setup(); 128 OS::SetUp();
129 Isolate* isolate = Isolate::Current(); 129 Isolate* isolate = Isolate::Current();
130 isolate->InitializeLoggingAndCounters(); 130 isolate->InitializeLoggingAndCounters();
131 Heap* heap = isolate->heap(); 131 Heap* heap = isolate->heap();
132 CHECK(isolate->heap()->ConfigureHeapDefault()); 132 CHECK(isolate->heap()->ConfigureHeapDefault());
133 133
134 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); 134 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
135 CHECK(memory_allocator->Setup(heap->MaxReserved(), 135 CHECK(memory_allocator->SetUp(heap->MaxReserved(),
136 heap->MaxExecutableSize())); 136 heap->MaxExecutableSize()));
137 137
138 int total_pages = 0; 138 int total_pages = 0;
139 OldSpace faked_space(heap, 139 OldSpace faked_space(heap,
140 heap->MaxReserved(), 140 heap->MaxReserved(),
141 OLD_POINTER_SPACE, 141 OLD_POINTER_SPACE,
142 NOT_EXECUTABLE); 142 NOT_EXECUTABLE);
143 Page* first_page = 143 Page* first_page =
144 memory_allocator->AllocatePage(&faked_space, NOT_EXECUTABLE); 144 memory_allocator->AllocatePage(&faked_space, NOT_EXECUTABLE);
145 145
(...skipping 22 matching lines...) Expand all
168 Page* second_page = first_page->next_page(); 168 Page* second_page = first_page->next_page();
169 CHECK(second_page->is_valid()); 169 CHECK(second_page->is_valid());
170 memory_allocator->Free(first_page); 170 memory_allocator->Free(first_page);
171 memory_allocator->Free(second_page); 171 memory_allocator->Free(second_page);
172 memory_allocator->TearDown(); 172 memory_allocator->TearDown();
173 delete memory_allocator; 173 delete memory_allocator;
174 } 174 }
175 175
176 176
177 TEST(NewSpace) { 177 TEST(NewSpace) {
178 OS::Setup(); 178 OS::SetUp();
179 Isolate* isolate = Isolate::Current(); 179 Isolate* isolate = Isolate::Current();
180 isolate->InitializeLoggingAndCounters(); 180 isolate->InitializeLoggingAndCounters();
181 Heap* heap = isolate->heap(); 181 Heap* heap = isolate->heap();
182 CHECK(heap->ConfigureHeapDefault()); 182 CHECK(heap->ConfigureHeapDefault());
183 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); 183 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
184 CHECK(memory_allocator->Setup(heap->MaxReserved(), 184 CHECK(memory_allocator->SetUp(heap->MaxReserved(),
185 heap->MaxExecutableSize())); 185 heap->MaxExecutableSize()));
186 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); 186 TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
187 187
188 NewSpace new_space(heap); 188 NewSpace new_space(heap);
189 189
190 CHECK(new_space.Setup(HEAP->ReservedSemiSpaceSize(), 190 CHECK(new_space.SetUp(HEAP->ReservedSemiSpaceSize(),
191 HEAP->ReservedSemiSpaceSize())); 191 HEAP->ReservedSemiSpaceSize()));
192 CHECK(new_space.HasBeenSetup()); 192 CHECK(new_space.HasBeenSetUp());
193 193
194 while (new_space.Available() >= Page::kMaxHeapObjectSize) { 194 while (new_space.Available() >= Page::kMaxHeapObjectSize) {
195 Object* obj = 195 Object* obj =
196 new_space.AllocateRaw(Page::kMaxHeapObjectSize)->ToObjectUnchecked(); 196 new_space.AllocateRaw(Page::kMaxHeapObjectSize)->ToObjectUnchecked();
197 CHECK(new_space.Contains(HeapObject::cast(obj))); 197 CHECK(new_space.Contains(HeapObject::cast(obj)));
198 } 198 }
199 199
200 new_space.TearDown(); 200 new_space.TearDown();
201 memory_allocator->TearDown(); 201 memory_allocator->TearDown();
202 delete memory_allocator; 202 delete memory_allocator;
203 } 203 }
204 204
205 205
206 TEST(OldSpace) { 206 TEST(OldSpace) {
207 OS::Setup(); 207 OS::SetUp();
208 Isolate* isolate = Isolate::Current(); 208 Isolate* isolate = Isolate::Current();
209 isolate->InitializeLoggingAndCounters(); 209 isolate->InitializeLoggingAndCounters();
210 Heap* heap = isolate->heap(); 210 Heap* heap = isolate->heap();
211 CHECK(heap->ConfigureHeapDefault()); 211 CHECK(heap->ConfigureHeapDefault());
212 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); 212 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
213 CHECK(memory_allocator->Setup(heap->MaxReserved(), 213 CHECK(memory_allocator->SetUp(heap->MaxReserved(),
214 heap->MaxExecutableSize())); 214 heap->MaxExecutableSize()));
215 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); 215 TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
216 216
217 OldSpace* s = new OldSpace(heap, 217 OldSpace* s = new OldSpace(heap,
218 heap->MaxOldGenerationSize(), 218 heap->MaxOldGenerationSize(),
219 OLD_POINTER_SPACE, 219 OLD_POINTER_SPACE,
220 NOT_EXECUTABLE); 220 NOT_EXECUTABLE);
221 CHECK(s != NULL); 221 CHECK(s != NULL);
222 222
223 CHECK(s->Setup()); 223 CHECK(s->SetUp());
224 224
225 while (s->Available() > 0) { 225 while (s->Available() > 0) {
226 s->AllocateRaw(Page::kMaxHeapObjectSize)->ToObjectUnchecked(); 226 s->AllocateRaw(Page::kMaxHeapObjectSize)->ToObjectUnchecked();
227 } 227 }
228 228
229 s->TearDown(); 229 s->TearDown();
230 delete s; 230 delete s;
231 memory_allocator->TearDown(); 231 memory_allocator->TearDown();
232 delete memory_allocator; 232 delete memory_allocator;
233 } 233 }
(...skipping 23 matching lines...) Expand all
257 { MaybeObject* maybe_obj = lo->AllocateRaw(lo_size, NOT_EXECUTABLE); 257 { MaybeObject* maybe_obj = lo->AllocateRaw(lo_size, NOT_EXECUTABLE);
258 if (!maybe_obj->ToObject(&obj)) break; 258 if (!maybe_obj->ToObject(&obj)) break;
259 } 259 }
260 CHECK(lo->Available() < available); 260 CHECK(lo->Available() < available);
261 }; 261 };
262 262
263 CHECK(!lo->IsEmpty()); 263 CHECK(!lo->IsEmpty());
264 264
265 CHECK(lo->AllocateRaw(lo_size, NOT_EXECUTABLE)->IsFailure()); 265 CHECK(lo->AllocateRaw(lo_size, NOT_EXECUTABLE)->IsFailure());
266 } 266 }
OLDNEW
« no previous file with comments | « test/cctest/test-sockets.cc ('k') | test/cctest/test-utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698