| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 #if 0 | 65 #if 0 |
| 66 TEST(Page) { | 66 TEST(Page) { |
| 67 byte* mem = NewArray<byte>(2*Page::kPageSize); | 67 byte* mem = NewArray<byte>(2*Page::kPageSize); |
| 68 CHECK(mem != NULL); | 68 CHECK(mem != NULL); |
| 69 | 69 |
| 70 Address start = reinterpret_cast<Address>(mem); | 70 Address start = reinterpret_cast<Address>(mem); |
| 71 Address page_start = RoundUp(start, Page::kPageSize); | 71 Address page_start = RoundUp(start, Page::kPageSize); |
| 72 | 72 |
| 73 Page* p = Page::FromAddress(page_start); | 73 Page* p = Page::FromAddress(page_start); |
| 74 // Initialized Page has heap pointer, normally set by memory_allocator. | 74 // Initialized Page has heap pointer, normally set by memory_allocator. |
| 75 p->heap_ = HEAP; | 75 p->heap_ = CcTest::heap(); |
| 76 CHECK(p->address() == page_start); | 76 CHECK(p->address() == page_start); |
| 77 CHECK(p->is_valid()); | 77 CHECK(p->is_valid()); |
| 78 | 78 |
| 79 p->opaque_header = 0; | 79 p->opaque_header = 0; |
| 80 p->SetIsLargeObjectPage(false); | 80 p->SetIsLargeObjectPage(false); |
| 81 CHECK(!p->next_page()->is_valid()); | 81 CHECK(!p->next_page()->is_valid()); |
| 82 | 82 |
| 83 CHECK(p->ObjectAreaStart() == page_start + Page::kObjectStartOffset); | 83 CHECK(p->ObjectAreaStart() == page_start + Page::kObjectStartOffset); |
| 84 CHECK(p->ObjectAreaEnd() == page_start + Page::kPageSize); | 84 CHECK(p->ObjectAreaEnd() == page_start + Page::kPageSize); |
| 85 | 85 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(CcTest::heap()->ReservedSemiSpaceSize(), |
| 327 HEAP->ReservedSemiSpaceSize())); | 327 CcTest::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(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 365 s->TearDown(); | 365 s->TearDown(); |
| 366 delete s; | 366 delete s; |
| 367 memory_allocator->TearDown(); | 367 memory_allocator->TearDown(); |
| 368 delete memory_allocator; | 368 delete memory_allocator; |
| 369 } | 369 } |
| 370 | 370 |
| 371 | 371 |
| 372 TEST(LargeObjectSpace) { | 372 TEST(LargeObjectSpace) { |
| 373 v8::V8::Initialize(); | 373 v8::V8::Initialize(); |
| 374 | 374 |
| 375 LargeObjectSpace* lo = HEAP->lo_space(); | 375 LargeObjectSpace* lo = CcTest::heap()->lo_space(); |
| 376 CHECK(lo != NULL); | 376 CHECK(lo != NULL); |
| 377 | 377 |
| 378 int lo_size = Page::kPageSize; | 378 int lo_size = Page::kPageSize; |
| 379 | 379 |
| 380 Object* obj = lo->AllocateRaw(lo_size, NOT_EXECUTABLE)->ToObjectUnchecked(); | 380 Object* obj = lo->AllocateRaw(lo_size, NOT_EXECUTABLE)->ToObjectUnchecked(); |
| 381 CHECK(obj->IsHeapObject()); | 381 CHECK(obj->IsHeapObject()); |
| 382 | 382 |
| 383 HeapObject* ho = HeapObject::cast(obj); | 383 HeapObject* ho = HeapObject::cast(obj); |
| 384 | 384 |
| 385 CHECK(lo->Contains(HeapObject::cast(obj))); | 385 CHECK(lo->Contains(HeapObject::cast(obj))); |
| 386 | 386 |
| 387 CHECK(lo->FindObject(ho->address()) == obj); | 387 CHECK(lo->FindObject(ho->address()) == obj); |
| 388 | 388 |
| 389 CHECK(lo->Contains(ho)); | 389 CHECK(lo->Contains(ho)); |
| 390 | 390 |
| 391 while (true) { | 391 while (true) { |
| 392 intptr_t available = lo->Available(); | 392 intptr_t available = lo->Available(); |
| 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 } |
| OLD | NEW |