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

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

Issue 7945009: Merge experimental/gc branch to the bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 3 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-reloc-info.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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 encoder.Encode(the_hole_value_location.address())); 120 encoder.Encode(the_hole_value_location.address()));
121 ExternalReference stack_limit_address = 121 ExternalReference stack_limit_address =
122 ExternalReference::address_of_stack_limit(isolate); 122 ExternalReference::address_of_stack_limit(isolate);
123 CHECK_EQ(make_code(UNCLASSIFIED, 4), 123 CHECK_EQ(make_code(UNCLASSIFIED, 4),
124 encoder.Encode(stack_limit_address.address())); 124 encoder.Encode(stack_limit_address.address()));
125 ExternalReference real_stack_limit_address = 125 ExternalReference real_stack_limit_address =
126 ExternalReference::address_of_real_stack_limit(isolate); 126 ExternalReference::address_of_real_stack_limit(isolate);
127 CHECK_EQ(make_code(UNCLASSIFIED, 5), 127 CHECK_EQ(make_code(UNCLASSIFIED, 5),
128 encoder.Encode(real_stack_limit_address.address())); 128 encoder.Encode(real_stack_limit_address.address()));
129 #ifdef ENABLE_DEBUGGER_SUPPORT 129 #ifdef ENABLE_DEBUGGER_SUPPORT
130 CHECK_EQ(make_code(UNCLASSIFIED, 15), 130 CHECK_EQ(make_code(UNCLASSIFIED, 16),
131 encoder.Encode(ExternalReference::debug_break(isolate).address())); 131 encoder.Encode(ExternalReference::debug_break(isolate).address()));
132 #endif // ENABLE_DEBUGGER_SUPPORT 132 #endif // ENABLE_DEBUGGER_SUPPORT
133 CHECK_EQ(make_code(UNCLASSIFIED, 10), 133 CHECK_EQ(make_code(UNCLASSIFIED, 10),
134 encoder.Encode( 134 encoder.Encode(
135 ExternalReference::new_space_start(isolate).address())); 135 ExternalReference::new_space_start(isolate).address()));
136 CHECK_EQ(make_code(UNCLASSIFIED, 3), 136 CHECK_EQ(make_code(UNCLASSIFIED, 3),
137 encoder.Encode(ExternalReference::roots_address(isolate).address())); 137 encoder.Encode(ExternalReference::roots_address(isolate).address()));
138 } 138 }
139 139
140 140
(...skipping 17 matching lines...) Expand all
158 make_code(STATS_COUNTER, 158 make_code(STATS_COUNTER,
159 Counters::k_keyed_load_function_prototype))); 159 Counters::k_keyed_load_function_prototype)));
160 CHECK_EQ(ExternalReference::the_hole_value_location(isolate).address(), 160 CHECK_EQ(ExternalReference::the_hole_value_location(isolate).address(),
161 decoder.Decode(make_code(UNCLASSIFIED, 2))); 161 decoder.Decode(make_code(UNCLASSIFIED, 2)));
162 CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(), 162 CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(),
163 decoder.Decode(make_code(UNCLASSIFIED, 4))); 163 decoder.Decode(make_code(UNCLASSIFIED, 4)));
164 CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(), 164 CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(),
165 decoder.Decode(make_code(UNCLASSIFIED, 5))); 165 decoder.Decode(make_code(UNCLASSIFIED, 5)));
166 #ifdef ENABLE_DEBUGGER_SUPPORT 166 #ifdef ENABLE_DEBUGGER_SUPPORT
167 CHECK_EQ(ExternalReference::debug_break(isolate).address(), 167 CHECK_EQ(ExternalReference::debug_break(isolate).address(),
168 decoder.Decode(make_code(UNCLASSIFIED, 15))); 168 decoder.Decode(make_code(UNCLASSIFIED, 16)));
169 #endif // ENABLE_DEBUGGER_SUPPORT 169 #endif // ENABLE_DEBUGGER_SUPPORT
170 CHECK_EQ(ExternalReference::new_space_start(isolate).address(), 170 CHECK_EQ(ExternalReference::new_space_start(isolate).address(),
171 decoder.Decode(make_code(UNCLASSIFIED, 10))); 171 decoder.Decode(make_code(UNCLASSIFIED, 10)));
172 } 172 }
173 173
174 174
175 class FileByteSink : public SnapshotByteSink { 175 class FileByteSink : public SnapshotByteSink {
176 public: 176 public:
177 explicit FileByteSink(const char* snapshot_file) { 177 explicit FileByteSink(const char* snapshot_file) {
178 fp_ = OS::FOpen(snapshot_file, "wb"); 178 fp_ = OS::FOpen(snapshot_file, "wb");
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 358
359 v8::Persistent<v8::Context> env = v8::Context::New(); 359 v8::Persistent<v8::Context> env = v8::Context::New();
360 ASSERT(!env.IsEmpty()); 360 ASSERT(!env.IsEmpty());
361 env->Enter(); 361 env->Enter();
362 // Make sure all builtin scripts are cached. 362 // Make sure all builtin scripts are cached.
363 { HandleScope scope; 363 { HandleScope scope;
364 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { 364 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
365 Isolate::Current()->bootstrapper()->NativesSourceLookup(i); 365 Isolate::Current()->bootstrapper()->NativesSourceLookup(i);
366 } 366 }
367 } 367 }
368 HEAP->CollectAllGarbage(true); 368 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
369 HEAP->CollectAllGarbage(true); 369 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
370 370
371 Object* raw_foo; 371 Object* raw_foo;
372 { 372 {
373 v8::HandleScope handle_scope; 373 v8::HandleScope handle_scope;
374 v8::Local<v8::String> foo = v8::String::New("foo"); 374 v8::Local<v8::String> foo = v8::String::New("foo");
375 ASSERT(!foo.IsEmpty()); 375 ASSERT(!foo.IsEmpty());
376 raw_foo = *(v8::Utils::OpenHandle(*foo)); 376 raw_foo = *(v8::Utils::OpenHandle(*foo));
377 } 377 }
378 378
379 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 379 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 ASSERT(!env.IsEmpty()); 483 ASSERT(!env.IsEmpty());
484 env->Enter(); 484 env->Enter();
485 // Make sure all builtin scripts are cached. 485 // Make sure all builtin scripts are cached.
486 { HandleScope scope; 486 { HandleScope scope;
487 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { 487 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
488 Isolate::Current()->bootstrapper()->NativesSourceLookup(i); 488 Isolate::Current()->bootstrapper()->NativesSourceLookup(i);
489 } 489 }
490 } 490 }
491 // If we don't do this then we end up with a stray root pointing at the 491 // If we don't do this then we end up with a stray root pointing at the
492 // context even after we have disposed of env. 492 // context even after we have disposed of env.
493 HEAP->CollectAllGarbage(true); 493 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
494 494
495 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 495 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
496 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 496 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
497 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 497 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
498 498
499 env->Exit(); 499 env->Exit();
500 500
501 Object* raw_context = *(v8::Utils::OpenHandle(*env)); 501 Object* raw_context = *(v8::Utils::OpenHandle(*env));
502 502
503 env.Dispose(); 503 env.Dispose();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 CHECK(root2->IsContext()); 556 CHECK(root2->IsContext());
557 CHECK(*root_handle != root2); 557 CHECK(*root_handle != root2);
558 } 558 }
559 } 559 }
560 } 560 }
561 561
562 562
563 TEST(LinearAllocation) { 563 TEST(LinearAllocation) {
564 v8::V8::Initialize(); 564 v8::V8::Initialize();
565 int new_space_max = 512 * KB; 565 int new_space_max = 512 * KB;
566 int paged_space_max = Page::kMaxHeapObjectSize;
566 567
567 for (int size = 1000; size < 5 * MB; size += size >> 1) { 568 for (int size = 1000; size < 5 * MB; size += size >> 1) {
569 size &= ~8; // Round.
568 int new_space_size = (size < new_space_max) ? size : new_space_max; 570 int new_space_size = (size < new_space_max) ? size : new_space_max;
571 int paged_space_size = (size < paged_space_max) ? size : paged_space_max;
569 HEAP->ReserveSpace( 572 HEAP->ReserveSpace(
570 new_space_size, 573 new_space_size,
571 size, // Old pointer space. 574 paged_space_size, // Old pointer space.
572 size, // Old data space. 575 paged_space_size, // Old data space.
573 size, // Code space. 576 HEAP->code_space()->RoundSizeDownToObjectAlignment(paged_space_size),
574 size, // Map space. 577 HEAP->map_space()->RoundSizeDownToObjectAlignment(paged_space_size),
575 size, // Cell space. 578 HEAP->cell_space()->RoundSizeDownToObjectAlignment(paged_space_size),
576 size); // Large object space. 579 size); // Large object space.
577 LinearAllocationScope linear_allocation_scope; 580 LinearAllocationScope linear_allocation_scope;
578 const int kSmallFixedArrayLength = 4; 581 const int kSmallFixedArrayLength = 4;
579 const int kSmallFixedArraySize = 582 const int kSmallFixedArraySize =
580 FixedArray::kHeaderSize + kSmallFixedArrayLength * kPointerSize; 583 FixedArray::kHeaderSize + kSmallFixedArrayLength * kPointerSize;
581 const int kSmallStringLength = 16; 584 const int kSmallStringLength = 16;
582 const int kSmallStringSize = 585 const int kSmallStringSize =
583 (SeqAsciiString::kHeaderSize + kSmallStringLength + 586 (SeqAsciiString::kHeaderSize + kSmallStringLength +
584 kObjectAlignmentMask) & ~kObjectAlignmentMask; 587 kObjectAlignmentMask) & ~kObjectAlignmentMask;
585 const int kMapSize = Map::kSize; 588 const int kMapSize = Map::kSize;
586 589
587 Object* new_last = NULL; 590 Object* new_last = NULL;
588 for (int i = 0; 591 for (int i = 0;
589 i + kSmallFixedArraySize <= new_space_size; 592 i + kSmallFixedArraySize <= new_space_size;
590 i += kSmallFixedArraySize) { 593 i += kSmallFixedArraySize) {
591 Object* obj = 594 Object* obj =
592 HEAP->AllocateFixedArray(kSmallFixedArrayLength)->ToObjectChecked(); 595 HEAP->AllocateFixedArray(kSmallFixedArrayLength)->ToObjectChecked();
593 if (new_last != NULL) { 596 if (new_last != NULL) {
594 CHECK(reinterpret_cast<char*>(obj) == 597 CHECK(reinterpret_cast<char*>(obj) ==
595 reinterpret_cast<char*>(new_last) + kSmallFixedArraySize); 598 reinterpret_cast<char*>(new_last) + kSmallFixedArraySize);
596 } 599 }
597 new_last = obj; 600 new_last = obj;
598 } 601 }
599 602
600 Object* pointer_last = NULL; 603 Object* pointer_last = NULL;
601 for (int i = 0; 604 for (int i = 0;
602 i + kSmallFixedArraySize <= size; 605 i + kSmallFixedArraySize <= paged_space_size;
603 i += kSmallFixedArraySize) { 606 i += kSmallFixedArraySize) {
604 Object* obj = HEAP->AllocateFixedArray(kSmallFixedArrayLength, 607 Object* obj = HEAP->AllocateFixedArray(kSmallFixedArrayLength,
605 TENURED)->ToObjectChecked(); 608 TENURED)->ToObjectChecked();
606 int old_page_fullness = i % Page::kPageSize; 609 int old_page_fullness = i % Page::kPageSize;
607 int page_fullness = (i + kSmallFixedArraySize) % Page::kPageSize; 610 int page_fullness = (i + kSmallFixedArraySize) % Page::kPageSize;
608 if (page_fullness < old_page_fullness || 611 if (page_fullness < old_page_fullness ||
609 page_fullness > Page::kObjectAreaSize) { 612 page_fullness > Page::kObjectAreaSize) {
610 i = RoundUp(i, Page::kPageSize); 613 i = RoundUp(i, Page::kPageSize);
611 pointer_last = NULL; 614 pointer_last = NULL;
612 } 615 }
613 if (pointer_last != NULL) { 616 if (pointer_last != NULL) {
614 CHECK(reinterpret_cast<char*>(obj) == 617 CHECK(reinterpret_cast<char*>(obj) ==
615 reinterpret_cast<char*>(pointer_last) + kSmallFixedArraySize); 618 reinterpret_cast<char*>(pointer_last) + kSmallFixedArraySize);
616 } 619 }
617 pointer_last = obj; 620 pointer_last = obj;
618 } 621 }
619 622
620 Object* data_last = NULL; 623 Object* data_last = NULL;
621 for (int i = 0; i + kSmallStringSize <= size; i += kSmallStringSize) { 624 for (int i = 0;
625 i + kSmallStringSize <= paged_space_size;
626 i += kSmallStringSize) {
622 Object* obj = HEAP->AllocateRawAsciiString(kSmallStringLength, 627 Object* obj = HEAP->AllocateRawAsciiString(kSmallStringLength,
623 TENURED)->ToObjectChecked(); 628 TENURED)->ToObjectChecked();
624 int old_page_fullness = i % Page::kPageSize; 629 int old_page_fullness = i % Page::kPageSize;
625 int page_fullness = (i + kSmallStringSize) % Page::kPageSize; 630 int page_fullness = (i + kSmallStringSize) % Page::kPageSize;
626 if (page_fullness < old_page_fullness || 631 if (page_fullness < old_page_fullness ||
627 page_fullness > Page::kObjectAreaSize) { 632 page_fullness > Page::kObjectAreaSize) {
628 i = RoundUp(i, Page::kPageSize); 633 i = RoundUp(i, Page::kPageSize);
629 data_last = NULL; 634 data_last = NULL;
630 } 635 }
631 if (data_last != NULL) { 636 if (data_last != NULL) {
632 CHECK(reinterpret_cast<char*>(obj) == 637 CHECK(reinterpret_cast<char*>(obj) ==
633 reinterpret_cast<char*>(data_last) + kSmallStringSize); 638 reinterpret_cast<char*>(data_last) + kSmallStringSize);
634 } 639 }
635 data_last = obj; 640 data_last = obj;
636 } 641 }
637 642
638 Object* map_last = NULL; 643 Object* map_last = NULL;
639 for (int i = 0; i + kMapSize <= size; i += kMapSize) { 644 for (int i = 0; i + kMapSize <= paged_space_size; i += kMapSize) {
640 Object* obj = HEAP->AllocateMap(JS_OBJECT_TYPE, 645 Object* obj = HEAP->AllocateMap(JS_OBJECT_TYPE,
641 42 * kPointerSize)->ToObjectChecked(); 646 42 * kPointerSize)->ToObjectChecked();
642 int old_page_fullness = i % Page::kPageSize; 647 int old_page_fullness = i % Page::kPageSize;
643 int page_fullness = (i + kMapSize) % Page::kPageSize; 648 int page_fullness = (i + kMapSize) % Page::kPageSize;
644 if (page_fullness < old_page_fullness || 649 if (page_fullness < old_page_fullness ||
645 page_fullness > Page::kObjectAreaSize) { 650 page_fullness > Page::kObjectAreaSize) {
646 i = RoundUp(i, Page::kPageSize); 651 i = RoundUp(i, Page::kPageSize);
647 map_last = NULL; 652 map_last = NULL;
648 } 653 }
649 if (map_last != NULL) { 654 if (map_last != NULL) {
(...skipping 24 matching lines...) Expand all
674 TEST(TestThatAlwaysFails) { 679 TEST(TestThatAlwaysFails) {
675 bool ArtificialFailure = false; 680 bool ArtificialFailure = false;
676 CHECK(ArtificialFailure); 681 CHECK(ArtificialFailure);
677 } 682 }
678 683
679 684
680 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { 685 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
681 bool ArtificialFailure2 = false; 686 bool ArtificialFailure2 = false;
682 CHECK(ArtificialFailure2); 687 CHECK(ArtificialFailure2);
683 } 688 }
OLDNEW
« no previous file with comments | « test/cctest/test-reloc-info.cc ('k') | test/cctest/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698