Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: test/cctest/test-serialize.cc

Issue 9535013: Merge r10809 from the bleeding_edge to the 3.8 branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.8/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-mark-compact.cc ('k') | test/cctest/test-spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. 1 // Copyright 2007-2010 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 CHECK(root2->IsContext()); 551 CHECK(root2->IsContext());
552 CHECK(*root_handle != root2); 552 CHECK(*root_handle != root2);
553 } 553 }
554 } 554 }
555 } 555 }
556 556
557 557
558 TEST(LinearAllocation) { 558 TEST(LinearAllocation) {
559 v8::V8::Initialize(); 559 v8::V8::Initialize();
560 int new_space_max = 512 * KB; 560 int new_space_max = 512 * KB;
561 int paged_space_max = Page::kMaxHeapObjectSize; 561 int paged_space_max = Page::kMaxNonCodeHeapObjectSize;
562 int code_space_max = HEAP->code_space()->AreaSize();
562 563
563 for (int size = 1000; size < 5 * MB; size += size >> 1) { 564 for (int size = 1000; size < 5 * MB; size += size >> 1) {
564 size &= ~8; // Round. 565 size &= ~8; // Round.
565 int new_space_size = (size < new_space_max) ? size : new_space_max; 566 int new_space_size = (size < new_space_max) ? size : new_space_max;
566 int paged_space_size = (size < paged_space_max) ? size : paged_space_max; 567 int paged_space_size = (size < paged_space_max) ? size : paged_space_max;
567 HEAP->ReserveSpace( 568 HEAP->ReserveSpace(
568 new_space_size, 569 new_space_size,
569 paged_space_size, // Old pointer space. 570 paged_space_size, // Old pointer space.
570 paged_space_size, // Old data space. 571 paged_space_size, // Old data space.
571 HEAP->code_space()->RoundSizeDownToObjectAlignment(paged_space_size), 572 HEAP->code_space()->RoundSizeDownToObjectAlignment(code_space_max),
572 HEAP->map_space()->RoundSizeDownToObjectAlignment(paged_space_size), 573 HEAP->map_space()->RoundSizeDownToObjectAlignment(paged_space_size),
573 HEAP->cell_space()->RoundSizeDownToObjectAlignment(paged_space_size), 574 HEAP->cell_space()->RoundSizeDownToObjectAlignment(paged_space_size),
574 size); // Large object space. 575 size); // Large object space.
575 LinearAllocationScope linear_allocation_scope; 576 LinearAllocationScope linear_allocation_scope;
576 const int kSmallFixedArrayLength = 4; 577 const int kSmallFixedArrayLength = 4;
577 const int kSmallFixedArraySize = 578 const int kSmallFixedArraySize =
578 FixedArray::kHeaderSize + kSmallFixedArrayLength * kPointerSize; 579 FixedArray::kHeaderSize + kSmallFixedArrayLength * kPointerSize;
579 const int kSmallStringLength = 16; 580 const int kSmallStringLength = 16;
580 const int kSmallStringSize = 581 const int kSmallStringSize =
581 (SeqAsciiString::kHeaderSize + kSmallStringLength + 582 (SeqAsciiString::kHeaderSize + kSmallStringLength +
(...skipping 15 matching lines...) Expand all
597 598
598 Object* pointer_last = NULL; 599 Object* pointer_last = NULL;
599 for (int i = 0; 600 for (int i = 0;
600 i + kSmallFixedArraySize <= paged_space_size; 601 i + kSmallFixedArraySize <= paged_space_size;
601 i += kSmallFixedArraySize) { 602 i += kSmallFixedArraySize) {
602 Object* obj = HEAP->AllocateFixedArray(kSmallFixedArrayLength, 603 Object* obj = HEAP->AllocateFixedArray(kSmallFixedArrayLength,
603 TENURED)->ToObjectChecked(); 604 TENURED)->ToObjectChecked();
604 int old_page_fullness = i % Page::kPageSize; 605 int old_page_fullness = i % Page::kPageSize;
605 int page_fullness = (i + kSmallFixedArraySize) % Page::kPageSize; 606 int page_fullness = (i + kSmallFixedArraySize) % Page::kPageSize;
606 if (page_fullness < old_page_fullness || 607 if (page_fullness < old_page_fullness ||
607 page_fullness > Page::kObjectAreaSize) { 608 page_fullness > HEAP->old_pointer_space()->AreaSize()) {
608 i = RoundUp(i, Page::kPageSize); 609 i = RoundUp(i, Page::kPageSize);
609 pointer_last = NULL; 610 pointer_last = NULL;
610 } 611 }
611 if (pointer_last != NULL) { 612 if (pointer_last != NULL) {
612 CHECK(reinterpret_cast<char*>(obj) == 613 CHECK(reinterpret_cast<char*>(obj) ==
613 reinterpret_cast<char*>(pointer_last) + kSmallFixedArraySize); 614 reinterpret_cast<char*>(pointer_last) + kSmallFixedArraySize);
614 } 615 }
615 pointer_last = obj; 616 pointer_last = obj;
616 } 617 }
617 618
618 Object* data_last = NULL; 619 Object* data_last = NULL;
619 for (int i = 0; 620 for (int i = 0;
620 i + kSmallStringSize <= paged_space_size; 621 i + kSmallStringSize <= paged_space_size;
621 i += kSmallStringSize) { 622 i += kSmallStringSize) {
622 Object* obj = HEAP->AllocateRawAsciiString(kSmallStringLength, 623 Object* obj = HEAP->AllocateRawAsciiString(kSmallStringLength,
623 TENURED)->ToObjectChecked(); 624 TENURED)->ToObjectChecked();
624 int old_page_fullness = i % Page::kPageSize; 625 int old_page_fullness = i % Page::kPageSize;
625 int page_fullness = (i + kSmallStringSize) % Page::kPageSize; 626 int page_fullness = (i + kSmallStringSize) % Page::kPageSize;
626 if (page_fullness < old_page_fullness || 627 if (page_fullness < old_page_fullness ||
627 page_fullness > Page::kObjectAreaSize) { 628 page_fullness > HEAP->old_data_space()->AreaSize()) {
628 i = RoundUp(i, Page::kPageSize); 629 i = RoundUp(i, Page::kPageSize);
629 data_last = NULL; 630 data_last = NULL;
630 } 631 }
631 if (data_last != NULL) { 632 if (data_last != NULL) {
632 CHECK(reinterpret_cast<char*>(obj) == 633 CHECK(reinterpret_cast<char*>(obj) ==
633 reinterpret_cast<char*>(data_last) + kSmallStringSize); 634 reinterpret_cast<char*>(data_last) + kSmallStringSize);
634 } 635 }
635 data_last = obj; 636 data_last = obj;
636 } 637 }
637 638
638 Object* map_last = NULL; 639 Object* map_last = NULL;
639 for (int i = 0; i + kMapSize <= paged_space_size; i += kMapSize) { 640 for (int i = 0; i + kMapSize <= paged_space_size; i += kMapSize) {
640 Object* obj = HEAP->AllocateMap(JS_OBJECT_TYPE, 641 Object* obj = HEAP->AllocateMap(JS_OBJECT_TYPE,
641 42 * kPointerSize)->ToObjectChecked(); 642 42 * kPointerSize)->ToObjectChecked();
642 int old_page_fullness = i % Page::kPageSize; 643 int old_page_fullness = i % Page::kPageSize;
643 int page_fullness = (i + kMapSize) % Page::kPageSize; 644 int page_fullness = (i + kMapSize) % Page::kPageSize;
644 if (page_fullness < old_page_fullness || 645 if (page_fullness < old_page_fullness ||
645 page_fullness > Page::kObjectAreaSize) { 646 page_fullness > HEAP->map_space()->AreaSize()) {
646 i = RoundUp(i, Page::kPageSize); 647 i = RoundUp(i, Page::kPageSize);
647 map_last = NULL; 648 map_last = NULL;
648 } 649 }
649 if (map_last != NULL) { 650 if (map_last != NULL) {
650 CHECK(reinterpret_cast<char*>(obj) == 651 CHECK(reinterpret_cast<char*>(obj) ==
651 reinterpret_cast<char*>(map_last) + kMapSize); 652 reinterpret_cast<char*>(map_last) + kMapSize);
652 } 653 }
653 map_last = obj; 654 map_last = obj;
654 } 655 }
655 656
656 if (size > Page::kObjectAreaSize) { 657 if (size > Page::kMaxNonCodeHeapObjectSize) {
657 // Support for reserving space in large object space is not there yet, 658 // Support for reserving space in large object space is not there yet,
658 // but using an always-allocate scope is fine for now. 659 // but using an always-allocate scope is fine for now.
659 AlwaysAllocateScope always; 660 AlwaysAllocateScope always;
660 int large_object_array_length = 661 int large_object_array_length =
661 (size - FixedArray::kHeaderSize) / kPointerSize; 662 (size - FixedArray::kHeaderSize) / kPointerSize;
662 Object* obj = HEAP->AllocateFixedArray(large_object_array_length, 663 Object* obj = HEAP->AllocateFixedArray(large_object_array_length,
663 TENURED)->ToObjectChecked(); 664 TENURED)->ToObjectChecked();
664 CHECK(!obj->IsFailure()); 665 CHECK(!obj->IsFailure());
665 } 666 }
666 } 667 }
667 } 668 }
668 669
669 670
670 TEST(TestThatAlwaysSucceeds) { 671 TEST(TestThatAlwaysSucceeds) {
671 } 672 }
672 673
673 674
674 TEST(TestThatAlwaysFails) { 675 TEST(TestThatAlwaysFails) {
675 bool ArtificialFailure = false; 676 bool ArtificialFailure = false;
676 CHECK(ArtificialFailure); 677 CHECK(ArtificialFailure);
677 } 678 }
678 679
679 680
680 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { 681 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
681 bool ArtificialFailure2 = false; 682 bool ArtificialFailure2 = false;
682 CHECK(ArtificialFailure2); 683 CHECK(ArtificialFailure2);
683 } 684 }
OLDNEW
« no previous file with comments | « test/cctest/test-mark-compact.cc ('k') | test/cctest/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698