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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 if (!isolate->snapshot_available()) return; | 493 if (!isolate->snapshot_available()) return; |
494 HandleScope scope(isolate); | 494 HandleScope scope(isolate); |
495 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); | 495 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); |
496 // Skip this test on the custom snapshot builder. | 496 // Skip this test on the custom snapshot builder. |
497 if (!CcTest::global() | 497 if (!CcTest::global() |
498 ->Get(context, v8_str("assertEquals")) | 498 ->Get(context, v8_str("assertEquals")) |
499 .ToLocalChecked() | 499 .ToLocalChecked() |
500 ->IsUndefined()) { | 500 ->IsUndefined()) { |
501 return; | 501 return; |
502 } | 502 } |
| 503 // Initial size of LO_SPACE |
| 504 size_t initial_lo_space = isolate->heap()->lo_space()->Size(); |
503 | 505 |
504 // The limit for each space for an empty isolate containing just the | 506 // The limit for each space for an empty isolate containing just the |
505 // snapshot. | 507 // snapshot. |
506 const size_t kMaxInitialSizePerSpace = 2 * MB; | 508 const size_t kMaxInitialSizePerSpace = 2 * MB; |
507 | 509 |
508 // Freshly initialized VM gets by with the snapshot size (which is below | 510 // Freshly initialized VM gets by with the snapshot size (which is below |
509 // kMaxInitialSizePerSpace per space). | 511 // kMaxInitialSizePerSpace per space). |
510 Heap* heap = isolate->heap(); | 512 Heap* heap = isolate->heap(); |
511 int page_count[LAST_PAGED_SPACE + 1] = {0, 0, 0, 0}; | 513 int page_count[LAST_PAGED_SPACE + 1] = {0, 0, 0, 0}; |
512 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { | 514 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { |
513 // Debug code can be very large, so skip CODE_SPACE if we are generating it. | 515 // Debug code can be very large, so skip CODE_SPACE if we are generating it. |
514 if (i == CODE_SPACE && i::FLAG_debug_code) continue; | 516 if (i == CODE_SPACE && i::FLAG_debug_code) continue; |
515 | 517 |
516 page_count[i] = heap->paged_space(i)->CountTotalPages(); | 518 page_count[i] = heap->paged_space(i)->CountTotalPages(); |
517 // Check that the initial heap is also below the limit. | 519 // Check that the initial heap is also below the limit. |
518 CHECK_LT(heap->paged_space(i)->CommittedMemory(), kMaxInitialSizePerSpace); | 520 CHECK_LT(heap->paged_space(i)->CommittedMemory(), kMaxInitialSizePerSpace); |
519 } | 521 } |
520 | 522 |
521 // Executing the empty script gets by with the same number of pages, i.e., | 523 // Executing the empty script gets by with the same number of pages, i.e., |
522 // requires no extra space. | 524 // requires no extra space. |
523 CompileRun("/*empty*/"); | 525 CompileRun("/*empty*/"); |
524 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { | 526 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { |
525 // Debug code can be very large, so skip CODE_SPACE if we are generating it. | 527 // Debug code can be very large, so skip CODE_SPACE if we are generating it. |
526 if (i == CODE_SPACE && i::FLAG_debug_code) continue; | 528 if (i == CODE_SPACE && i::FLAG_debug_code) continue; |
527 CHECK_EQ(page_count[i], isolate->heap()->paged_space(i)->CountTotalPages()); | 529 CHECK_EQ(page_count[i], isolate->heap()->paged_space(i)->CountTotalPages()); |
528 } | 530 } |
529 | 531 |
530 // No large objects required to perform the above steps. | 532 // No large objects required to perform the above steps. |
531 CHECK(isolate->heap()->lo_space()->IsEmpty()); | 533 CHECK_EQ(initial_lo_space, isolate->heap()->lo_space()->Size()); |
532 } | 534 } |
533 | 535 |
534 static HeapObject* AllocateUnaligned(NewSpace* space, int size) { | 536 static HeapObject* AllocateUnaligned(NewSpace* space, int size) { |
535 AllocationResult allocation = space->AllocateRawUnaligned(size); | 537 AllocationResult allocation = space->AllocateRawUnaligned(size); |
536 CHECK(!allocation.IsRetry()); | 538 CHECK(!allocation.IsRetry()); |
537 HeapObject* filler = NULL; | 539 HeapObject* filler = NULL; |
538 CHECK(allocation.To(&filler)); | 540 CHECK(allocation.To(&filler)); |
539 space->heap()->CreateFillerObjectAt(filler->address(), size, | 541 space->heap()->CreateFillerObjectAt(filler->address(), size, |
540 ClearRecordedSlots::kNo); | 542 ClearRecordedSlots::kNo); |
541 return filler; | 543 return filler; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 HeapObject* filler = | 791 HeapObject* filler = |
790 HeapObject::FromAddress(array->address() + array->Size()); | 792 HeapObject::FromAddress(array->address() + array->Size()); |
791 CHECK_EQ(filler->map(), CcTest::heap()->two_pointer_filler_map()); | 793 CHECK_EQ(filler->map(), CcTest::heap()->two_pointer_filler_map()); |
792 | 794 |
793 const size_t shrinked = page->ShrinkToHighWaterMark(); | 795 const size_t shrinked = page->ShrinkToHighWaterMark(); |
794 CHECK_EQ(0, shrinked); | 796 CHECK_EQ(0, shrinked); |
795 } | 797 } |
796 | 798 |
797 } // namespace internal | 799 } // namespace internal |
798 } // namespace v8 | 800 } // namespace v8 |
OLD | NEW |