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