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-spaces.cc

Issue 23534067: bulk replace Isolate::Current in tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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-serialize.cc ('k') | test/cctest/test-strings.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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 201
202 static unsigned int Pseudorandom() { 202 static unsigned int Pseudorandom() {
203 static uint32_t lo = 2345; 203 static uint32_t lo = 2345;
204 lo = 18273 * (lo & 0xFFFFF) + (lo >> 16); 204 lo = 18273 * (lo & 0xFFFFF) + (lo >> 16);
205 return lo & 0xFFFFF; 205 return lo & 0xFFFFF;
206 } 206 }
207 207
208 208
209 TEST(MemoryChunk) { 209 TEST(MemoryChunk) {
210 Isolate* isolate = Isolate::Current(); 210 Isolate* isolate = CcTest::i_isolate();
211 isolate->InitializeLoggingAndCounters(); 211 isolate->InitializeLoggingAndCounters();
212 Heap* heap = isolate->heap(); 212 Heap* heap = isolate->heap();
213 CHECK(heap->ConfigureHeapDefault()); 213 CHECK(heap->ConfigureHeapDefault());
214 214
215 size_t reserve_area_size = 1 * MB; 215 size_t reserve_area_size = 1 * MB;
216 size_t initial_commit_area_size, second_commit_area_size; 216 size_t initial_commit_area_size, second_commit_area_size;
217 217
218 for (int i = 0; i < 100; i++) { 218 for (int i = 0; i < 100; i++) {
219 initial_commit_area_size = Pseudorandom(); 219 initial_commit_area_size = Pseudorandom();
220 second_commit_area_size = Pseudorandom(); 220 second_commit_area_size = Pseudorandom();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 code_range, 256 code_range,
257 reserve_area_size, 257 reserve_area_size,
258 initial_commit_area_size, 258 initial_commit_area_size,
259 second_commit_area_size, 259 second_commit_area_size,
260 NOT_EXECUTABLE); 260 NOT_EXECUTABLE);
261 } 261 }
262 } 262 }
263 263
264 264
265 TEST(MemoryAllocator) { 265 TEST(MemoryAllocator) {
266 Isolate* isolate = Isolate::Current(); 266 Isolate* isolate = CcTest::i_isolate();
267 isolate->InitializeLoggingAndCounters(); 267 isolate->InitializeLoggingAndCounters();
268 Heap* heap = isolate->heap(); 268 Heap* heap = isolate->heap();
269 CHECK(isolate->heap()->ConfigureHeapDefault()); 269 CHECK(isolate->heap()->ConfigureHeapDefault());
270 270
271 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); 271 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
272 CHECK(memory_allocator->SetUp(heap->MaxReserved(), 272 CHECK(memory_allocator->SetUp(heap->MaxReserved(),
273 heap->MaxExecutableSize())); 273 heap->MaxExecutableSize()));
274 274
275 int total_pages = 0; 275 int total_pages = 0;
276 OldSpace faked_space(heap, 276 OldSpace faked_space(heap,
(...skipping 28 matching lines...) Expand all
305 Page* second_page = first_page->next_page(); 305 Page* second_page = first_page->next_page();
306 CHECK(second_page->is_valid()); 306 CHECK(second_page->is_valid());
307 memory_allocator->Free(first_page); 307 memory_allocator->Free(first_page);
308 memory_allocator->Free(second_page); 308 memory_allocator->Free(second_page);
309 memory_allocator->TearDown(); 309 memory_allocator->TearDown();
310 delete memory_allocator; 310 delete memory_allocator;
311 } 311 }
312 312
313 313
314 TEST(NewSpace) { 314 TEST(NewSpace) {
315 Isolate* isolate = Isolate::Current(); 315 Isolate* isolate = CcTest::i_isolate();
316 isolate->InitializeLoggingAndCounters(); 316 isolate->InitializeLoggingAndCounters();
317 Heap* heap = isolate->heap(); 317 Heap* heap = isolate->heap();
318 CHECK(heap->ConfigureHeapDefault()); 318 CHECK(heap->ConfigureHeapDefault());
319 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); 319 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
320 CHECK(memory_allocator->SetUp(heap->MaxReserved(), 320 CHECK(memory_allocator->SetUp(heap->MaxReserved(),
321 heap->MaxExecutableSize())); 321 heap->MaxExecutableSize()));
322 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); 322 TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
323 323
324 NewSpace new_space(heap); 324 NewSpace new_space(heap);
325 325
326 CHECK(new_space.SetUp(HEAP->ReservedSemiSpaceSize(), 326 CHECK(new_space.SetUp(HEAP->ReservedSemiSpaceSize(),
327 HEAP->ReservedSemiSpaceSize())); 327 HEAP->ReservedSemiSpaceSize()));
328 CHECK(new_space.HasBeenSetUp()); 328 CHECK(new_space.HasBeenSetUp());
329 329
330 while (new_space.Available() >= Page::kMaxNonCodeHeapObjectSize) { 330 while (new_space.Available() >= Page::kMaxNonCodeHeapObjectSize) {
331 Object* obj = 331 Object* obj =
332 new_space.AllocateRaw(Page::kMaxNonCodeHeapObjectSize)-> 332 new_space.AllocateRaw(Page::kMaxNonCodeHeapObjectSize)->
333 ToObjectUnchecked(); 333 ToObjectUnchecked();
334 CHECK(new_space.Contains(HeapObject::cast(obj))); 334 CHECK(new_space.Contains(HeapObject::cast(obj)));
335 } 335 }
336 336
337 new_space.TearDown(); 337 new_space.TearDown();
338 memory_allocator->TearDown(); 338 memory_allocator->TearDown();
339 delete memory_allocator; 339 delete memory_allocator;
340 } 340 }
341 341
342 342
343 TEST(OldSpace) { 343 TEST(OldSpace) {
344 Isolate* isolate = Isolate::Current(); 344 Isolate* isolate = CcTest::i_isolate();
345 isolate->InitializeLoggingAndCounters(); 345 isolate->InitializeLoggingAndCounters();
346 Heap* heap = isolate->heap(); 346 Heap* heap = isolate->heap();
347 CHECK(heap->ConfigureHeapDefault()); 347 CHECK(heap->ConfigureHeapDefault());
348 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); 348 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
349 CHECK(memory_allocator->SetUp(heap->MaxReserved(), 349 CHECK(memory_allocator->SetUp(heap->MaxReserved(),
350 heap->MaxExecutableSize())); 350 heap->MaxExecutableSize()));
351 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); 351 TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
352 352
353 OldSpace* s = new OldSpace(heap, 353 OldSpace* s = new OldSpace(heap,
354 heap->MaxOldGenerationSize(), 354 heap->MaxOldGenerationSize(),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 { MaybeObject* maybe_obj = lo->AllocateRaw(lo_size, NOT_EXECUTABLE); 393 { MaybeObject* maybe_obj = lo->AllocateRaw(lo_size, NOT_EXECUTABLE);
394 if (!maybe_obj->ToObject(&obj)) break; 394 if (!maybe_obj->ToObject(&obj)) break;
395 } 395 }
396 CHECK(lo->Available() < available); 396 CHECK(lo->Available() < available);
397 }; 397 };
398 398
399 CHECK(!lo->IsEmpty()); 399 CHECK(!lo->IsEmpty());
400 400
401 CHECK(lo->AllocateRaw(lo_size, NOT_EXECUTABLE)->IsFailure()); 401 CHECK(lo->AllocateRaw(lo_size, NOT_EXECUTABLE)->IsFailure());
402 } 402 }
OLDNEW
« no previous file with comments | « test/cctest/test-serialize.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698