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

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

Issue 1314953004: [interpreter] Add constant_pool() to BytecodeArray. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_args
Patch Set: Fix test flag. Created 5 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
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 CHECK(WeakPointerCleared); 706 CHECK(WeakPointerCleared);
707 } 707 }
708 708
709 709
710 TEST(BytecodeArray) { 710 TEST(BytecodeArray) {
711 static const uint8_t kRawBytes[] = {0xc3, 0x7e, 0xa5, 0x5a}; 711 static const uint8_t kRawBytes[] = {0xc3, 0x7e, 0xa5, 0x5a};
712 static const int kRawBytesSize = sizeof(kRawBytes); 712 static const int kRawBytesSize = sizeof(kRawBytes);
713 static const int kFrameSize = 32; 713 static const int kFrameSize = 32;
714 static const int kParameterCount = 2; 714 static const int kParameterCount = 2;
715 715
716 i::FLAG_manual_evacuation_candidates_selection = true;
716 CcTest::InitializeVM(); 717 CcTest::InitializeVM();
717 Isolate* isolate = CcTest::i_isolate(); 718 Isolate* isolate = CcTest::i_isolate();
718 Heap* heap = isolate->heap(); 719 Heap* heap = isolate->heap();
719 Factory* factory = isolate->factory(); 720 Factory* factory = isolate->factory();
720 HandleScope scope(isolate); 721 HandleScope scope(isolate);
721 722
723 SimulateFullSpace(heap->old_space());
724 Handle<FixedArray> constant_pool = factory->NewFixedArray(5, TENURED);
725 for (int i = 0; i < 5; i++) {
726 constant_pool->set(i, *factory->NewHeapNumber(i));
727 }
728
722 // Allocate and initialize BytecodeArray 729 // Allocate and initialize BytecodeArray
723 Handle<BytecodeArray> array = factory->NewBytecodeArray( 730 Handle<BytecodeArray> array = factory->NewBytecodeArray(
724 kRawBytesSize, kRawBytes, kFrameSize, kParameterCount); 731 kRawBytesSize, kRawBytes, kFrameSize, kParameterCount, constant_pool);
725 732
726 CHECK(array->IsBytecodeArray()); 733 CHECK(array->IsBytecodeArray());
727 CHECK_EQ(array->length(), (int)sizeof(kRawBytes)); 734 CHECK_EQ(array->length(), (int)sizeof(kRawBytes));
728 CHECK_EQ(array->frame_size(), kFrameSize); 735 CHECK_EQ(array->frame_size(), kFrameSize);
729 CHECK_EQ(array->parameter_count(), kParameterCount); 736 CHECK_EQ(array->parameter_count(), kParameterCount);
737 CHECK_EQ(array->constant_pool(), *constant_pool);
730 CHECK_LE(array->address(), array->GetFirstBytecodeAddress()); 738 CHECK_LE(array->address(), array->GetFirstBytecodeAddress());
731 CHECK_GE(array->address() + array->BytecodeArraySize(), 739 CHECK_GE(array->address() + array->BytecodeArraySize(),
732 array->GetFirstBytecodeAddress() + array->length()); 740 array->GetFirstBytecodeAddress() + array->length());
733 for (int i = 0; i < kRawBytesSize; i++) { 741 for (int i = 0; i < kRawBytesSize; i++) {
734 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]); 742 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
735 CHECK_EQ(array->get(i), kRawBytes[i]); 743 CHECK_EQ(array->get(i), kRawBytes[i]);
736 } 744 }
737 745
738 // Full garbage collection 746 FixedArray* old_constant_pool_address = *constant_pool;
747
748 // Perform a full garbage collection and force the constant pool to be on an
749 // evacuation candidate.
750 Page* evac_page = Page::FromAddress(constant_pool->address());
751 evac_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING);
739 heap->CollectAllGarbage(); 752 heap->CollectAllGarbage();
740 753
741 // BytecodeArray should survive 754 // BytecodeArray should survive.
742 CHECK_EQ(array->length(), kRawBytesSize); 755 CHECK_EQ(array->length(), kRawBytesSize);
743 CHECK_EQ(array->frame_size(), kFrameSize); 756 CHECK_EQ(array->frame_size(), kFrameSize);
744
745 for (int i = 0; i < kRawBytesSize; i++) { 757 for (int i = 0; i < kRawBytesSize; i++) {
746 CHECK_EQ(array->get(i), kRawBytes[i]); 758 CHECK_EQ(array->get(i), kRawBytes[i]);
747 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]); 759 CHECK_EQ(array->GetFirstBytecodeAddress()[i], kRawBytes[i]);
748 } 760 }
761
762 // Constant pool should have been migrated.
763 CHECK_EQ(array->constant_pool(), *constant_pool);
764 CHECK_NE(array->constant_pool(), old_constant_pool_address);
749 } 765 }
750 766
751 767
752 static const char* not_so_random_string_table[] = { 768 static const char* not_so_random_string_table[] = {
753 "abstract", 769 "abstract",
754 "boolean", 770 "boolean",
755 "break", 771 "break",
756 "byte", 772 "byte",
757 "case", 773 "case",
758 "catch", 774 "catch",
(...skipping 5809 matching lines...) Expand 10 before | Expand all | Expand 10 after
6568 { 6584 {
6569 SharedFunctionInfo::Iterator iterator(isolate); 6585 SharedFunctionInfo::Iterator iterator(isolate);
6570 while (iterator.Next()) sfi_count--; 6586 while (iterator.Next()) sfi_count--;
6571 } 6587 }
6572 6588
6573 CHECK_EQ(0, sfi_count); 6589 CHECK_EQ(0, sfi_count);
6574 } 6590 }
6575 6591
6576 } // namespace internal 6592 } // namespace internal
6577 } // namespace v8 6593 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698