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, | 311 OldSpace faked_space(heap, heap->MaxReserved(), OLD_SPACE, NOT_EXECUTABLE); |
312 heap->MaxReserved(), | |
313 OLD_POINTER_SPACE, | |
314 NOT_EXECUTABLE); | |
315 Page* first_page = memory_allocator->AllocatePage( | 312 Page* first_page = memory_allocator->AllocatePage( |
316 faked_space.AreaSize(), &faked_space, NOT_EXECUTABLE); | 313 faked_space.AreaSize(), &faked_space, NOT_EXECUTABLE); |
317 | 314 |
318 first_page->InsertAfter(faked_space.anchor()->prev_page()); | 315 first_page->InsertAfter(faked_space.anchor()->prev_page()); |
319 CHECK(first_page->is_valid()); | 316 CHECK(first_page->is_valid()); |
320 CHECK(first_page->next_page() == faked_space.anchor()); | 317 CHECK(first_page->next_page() == faked_space.anchor()); |
321 total_pages++; | 318 total_pages++; |
322 | 319 |
323 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()) { |
324 CHECK(p->owner() == &faked_space); | 321 CHECK(p->owner() == &faked_space); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 370 |
374 | 371 |
375 TEST(OldSpace) { | 372 TEST(OldSpace) { |
376 Isolate* isolate = CcTest::i_isolate(); | 373 Isolate* isolate = CcTest::i_isolate(); |
377 Heap* heap = isolate->heap(); | 374 Heap* heap = isolate->heap(); |
378 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 375 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
379 CHECK(memory_allocator->SetUp(heap->MaxReserved(), | 376 CHECK(memory_allocator->SetUp(heap->MaxReserved(), |
380 heap->MaxExecutableSize())); | 377 heap->MaxExecutableSize())); |
381 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); | 378 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); |
382 | 379 |
383 OldSpace* s = new OldSpace(heap, | 380 OldSpace* s = new OldSpace(heap, heap->MaxOldGenerationSize(), OLD_SPACE, |
384 heap->MaxOldGenerationSize(), | |
385 OLD_POINTER_SPACE, | |
386 NOT_EXECUTABLE); | 381 NOT_EXECUTABLE); |
387 CHECK(s != NULL); | 382 CHECK(s != NULL); |
388 | 383 |
389 CHECK(s->SetUp()); | 384 CHECK(s->SetUp()); |
390 | 385 |
391 while (s->Available() > 0) { | 386 while (s->Available() > 0) { |
392 s->AllocateRaw(Page::kMaxRegularHeapObjectSize).ToObjectChecked(); | 387 s->AllocateRaw(Page::kMaxRegularHeapObjectSize).ToObjectChecked(); |
393 } | 388 } |
394 | 389 |
395 s->TearDown(); | 390 s->TearDown(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 | 489 |
495 // 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 |
496 // crash. | 491 // crash. |
497 HeapObject* free_space = NULL; | 492 HeapObject* free_space = NULL; |
498 CHECK(allocation.To(&free_space)); | 493 CHECK(allocation.To(&free_space)); |
499 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80); | 494 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80); |
500 } | 495 } |
501 } | 496 } |
502 isolate->Dispose(); | 497 isolate->Dispose(); |
503 } | 498 } |
OLD | NEW |