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

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

Issue 1138643005: Clean-up aligned allocation logic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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') | 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 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 heap->MaxExecutableSize())); 351 heap->MaxExecutableSize()));
352 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); 352 TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
353 353
354 NewSpace new_space(heap); 354 NewSpace new_space(heap);
355 355
356 CHECK(new_space.SetUp(CcTest::heap()->ReservedSemiSpaceSize(), 356 CHECK(new_space.SetUp(CcTest::heap()->ReservedSemiSpaceSize(),
357 CcTest::heap()->ReservedSemiSpaceSize())); 357 CcTest::heap()->ReservedSemiSpaceSize()));
358 CHECK(new_space.HasBeenSetUp()); 358 CHECK(new_space.HasBeenSetUp());
359 359
360 while (new_space.Available() >= Page::kMaxRegularHeapObjectSize) { 360 while (new_space.Available() >= Page::kMaxRegularHeapObjectSize) {
361 Object* obj = new_space.AllocateRaw( 361 Object* obj =
362 Page::kMaxRegularHeapObjectSize).ToObjectChecked(); 362 new_space.AllocateRawUnaligned(Page::kMaxRegularHeapObjectSize)
363 .ToObjectChecked();
363 CHECK(new_space.Contains(HeapObject::cast(obj))); 364 CHECK(new_space.Contains(HeapObject::cast(obj)));
364 } 365 }
365 366
366 new_space.TearDown(); 367 new_space.TearDown();
367 memory_allocator->TearDown(); 368 memory_allocator->TearDown();
368 delete memory_allocator; 369 delete memory_allocator;
369 } 370 }
370 371
371 372
372 TEST(OldSpace) { 373 TEST(OldSpace) {
373 Isolate* isolate = CcTest::i_isolate(); 374 Isolate* isolate = CcTest::i_isolate();
374 Heap* heap = isolate->heap(); 375 Heap* heap = isolate->heap();
375 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); 376 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
376 CHECK(memory_allocator->SetUp(heap->MaxReserved(), 377 CHECK(memory_allocator->SetUp(heap->MaxReserved(),
377 heap->MaxExecutableSize())); 378 heap->MaxExecutableSize()));
378 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); 379 TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
379 380
380 OldSpace* s = new OldSpace(heap, heap->MaxOldGenerationSize(), OLD_SPACE, 381 OldSpace* s = new OldSpace(heap, heap->MaxOldGenerationSize(), OLD_SPACE,
381 NOT_EXECUTABLE); 382 NOT_EXECUTABLE);
382 CHECK(s != NULL); 383 CHECK(s != NULL);
383 384
384 CHECK(s->SetUp()); 385 CHECK(s->SetUp());
385 386
386 while (s->Available() > 0) { 387 while (s->Available() > 0) {
387 s->AllocateRaw(Page::kMaxRegularHeapObjectSize).ToObjectChecked(); 388 s->AllocateRawUnaligned(Page::kMaxRegularHeapObjectSize).ToObjectChecked();
388 } 389 }
389 390
390 s->TearDown(); 391 s->TearDown();
391 delete s; 392 delete s;
392 memory_allocator->TearDown(); 393 memory_allocator->TearDown();
393 delete memory_allocator; 394 delete memory_allocator;
394 } 395 }
395 396
396 397
397 TEST(LargeObjectSpace) { 398 TEST(LargeObjectSpace) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // configuration. 479 // configuration.
479 if (new_space->InitialTotalCapacity() == Page::kPageSize) { 480 if (new_space->InitialTotalCapacity() == Page::kPageSize) {
480 CHECK(new_space->CommittedMemory() == new_space->InitialTotalCapacity()); 481 CHECK(new_space->CommittedMemory() == new_space->InitialTotalCapacity());
481 482
482 // Fill up the first (and only) page of the semi space. 483 // Fill up the first (and only) page of the semi space.
483 FillCurrentPage(new_space); 484 FillCurrentPage(new_space);
484 485
485 // Try to allocate out of the new space. A new page should be added and 486 // Try to allocate out of the new space. A new page should be added and
486 // the 487 // the
487 // allocation should succeed. 488 // allocation should succeed.
488 v8::internal::AllocationResult allocation = new_space->AllocateRaw(80); 489 v8::internal::AllocationResult allocation =
490 new_space->AllocateRawUnaligned(80);
489 CHECK(!allocation.IsRetry()); 491 CHECK(!allocation.IsRetry());
490 CHECK(new_space->CommittedMemory() == 2 * Page::kPageSize); 492 CHECK(new_space->CommittedMemory() == 2 * Page::kPageSize);
491 493
492 // Turn the allocation into a proper object so isolate teardown won't 494 // Turn the allocation into a proper object so isolate teardown won't
493 // crash. 495 // crash.
494 HeapObject* free_space = NULL; 496 HeapObject* free_space = NULL;
495 CHECK(allocation.To(&free_space)); 497 CHECK(allocation.To(&free_space));
496 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80); 498 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80);
497 } 499 }
498 } 500 }
499 isolate->Dispose(); 501 isolate->Dispose();
500 } 502 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698