| OLD | NEW |
| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 301 |
| 302 TEST(MemoryAllocator) { | 302 TEST(MemoryAllocator) { |
| 303 Isolate* isolate = CcTest::i_isolate(); | 303 Isolate* isolate = CcTest::i_isolate(); |
| 304 Heap* heap = isolate->heap(); | 304 Heap* heap = isolate->heap(); |
| 305 | 305 |
| 306 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 306 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
| 307 CHECK(memory_allocator->SetUp(heap->MaxReserved(), | 307 CHECK(memory_allocator->SetUp(heap->MaxReserved(), |
| 308 heap->MaxExecutableSize())); | 308 heap->MaxExecutableSize())); |
| 309 | 309 |
| 310 int total_pages = 0; | 310 int total_pages = 0; |
| 311 OldSpace faked_space(heap, heap->MaxReserved(), OLD_POINTER_SPACE, | 311 OldSpace faked_space(heap, heap->MaxReserved(), OLD_SPACE, NOT_EXECUTABLE); |
| 312 NOT_EXECUTABLE); | |
| 313 Page* first_page = memory_allocator->AllocatePage( | 312 Page* first_page = memory_allocator->AllocatePage( |
| 314 faked_space.AreaSize(), &faked_space, NOT_EXECUTABLE); | 313 faked_space.AreaSize(), &faked_space, NOT_EXECUTABLE); |
| 315 | 314 |
| 316 first_page->InsertAfter(faked_space.anchor()->prev_page()); | 315 first_page->InsertAfter(faked_space.anchor()->prev_page()); |
| 317 CHECK(first_page->is_valid()); | 316 CHECK(first_page->is_valid()); |
| 318 CHECK(first_page->next_page() == faked_space.anchor()); | 317 CHECK(first_page->next_page() == faked_space.anchor()); |
| 319 total_pages++; | 318 total_pages++; |
| 320 | 319 |
| 321 for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) { | 320 for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) { |
| 322 CHECK(p->owner() == &faked_space); | 321 CHECK(p->owner() == &faked_space); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 370 |
| 372 | 371 |
| 373 TEST(OldSpace) { | 372 TEST(OldSpace) { |
| 374 Isolate* isolate = CcTest::i_isolate(); | 373 Isolate* isolate = CcTest::i_isolate(); |
| 375 Heap* heap = isolate->heap(); | 374 Heap* heap = isolate->heap(); |
| 376 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 375 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
| 377 CHECK(memory_allocator->SetUp(heap->MaxReserved(), | 376 CHECK(memory_allocator->SetUp(heap->MaxReserved(), |
| 378 heap->MaxExecutableSize())); | 377 heap->MaxExecutableSize())); |
| 379 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); | 378 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); |
| 380 | 379 |
| 381 OldSpace* s = new OldSpace(heap, heap->MaxOldGenerationSize(), | 380 OldSpace* s = new OldSpace(heap, heap->MaxOldGenerationSize(), OLD_SPACE, |
| 382 OLD_POINTER_SPACE, NOT_EXECUTABLE); | 381 NOT_EXECUTABLE); |
| 383 CHECK(s != NULL); | 382 CHECK(s != NULL); |
| 384 | 383 |
| 385 CHECK(s->SetUp()); | 384 CHECK(s->SetUp()); |
| 386 | 385 |
| 387 while (s->Available() > 0) { | 386 while (s->Available() > 0) { |
| 388 s->AllocateRaw(Page::kMaxRegularHeapObjectSize).ToObjectChecked(); | 387 s->AllocateRaw(Page::kMaxRegularHeapObjectSize).ToObjectChecked(); |
| 389 } | 388 } |
| 390 | 389 |
| 391 s->TearDown(); | 390 s->TearDown(); |
| 392 delete s; | 391 delete s; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 489 |
| 491 // Turn the allocation into a proper object so isolate teardown won't | 490 // Turn the allocation into a proper object so isolate teardown won't |
| 492 // crash. | 491 // crash. |
| 493 HeapObject* free_space = NULL; | 492 HeapObject* free_space = NULL; |
| 494 CHECK(allocation.To(&free_space)); | 493 CHECK(allocation.To(&free_space)); |
| 495 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80); | 494 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80); |
| 496 } | 495 } |
| 497 } | 496 } |
| 498 isolate->Dispose(); | 497 isolate->Dispose(); |
| 499 } | 498 } |
| OLD | NEW |