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

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

Issue 2255004: Cardmarking writebarrier. (Closed)
Patch Set: Created 10 years, 7 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 | « test/cctest/test-heap.cc ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 14 matching lines...) Expand all
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 29
30 #include "v8.h" 30 #include "v8.h"
31 #include "cctest.h" 31 #include "cctest.h"
32 32
33 using namespace v8::internal; 33 using namespace v8::internal;
34 34
35 static void VerifyRSet(Address page_start) { 35 static void VerifyRegionMarking(Address page_start) {
36 #ifdef DEBUG
37 Page::set_rset_state(Page::IN_USE);
38 #endif
39
40 Page* p = Page::FromAddress(page_start); 36 Page* p = Page::FromAddress(page_start);
41 37
42 p->ClearRSet(); 38 p->SetRegionMarks(Page::kAllRegionsCleanMarks);
43 39
44 for (Address addr = p->ObjectAreaStart(); 40 for (Address addr = p->ObjectAreaStart();
45 addr < p->ObjectAreaEnd(); 41 addr < p->ObjectAreaEnd();
46 addr += kPointerSize) { 42 addr += kPointerSize) {
47 CHECK(!Page::IsRSetSet(addr, 0)); 43 CHECK(!Page::FromAddress(addr)->IsRegionDirty(addr));
48 } 44 }
49 45
50 for (Address addr = p->ObjectAreaStart(); 46 for (Address addr = p->ObjectAreaStart();
51 addr < p->ObjectAreaEnd(); 47 addr < p->ObjectAreaEnd();
52 addr += kPointerSize) { 48 addr += kPointerSize) {
53 Page::SetRSet(addr, 0); 49 Page::FromAddress(addr)->MarkRegionDirty(addr);
54 } 50 }
55 51
56 for (Address addr = p->ObjectAreaStart(); 52 for (Address addr = p->ObjectAreaStart();
57 addr < p->ObjectAreaEnd(); 53 addr < p->ObjectAreaEnd();
58 addr += kPointerSize) { 54 addr += kPointerSize) {
59 CHECK(Page::IsRSetSet(addr, 0)); 55 CHECK(Page::FromAddress(addr)->IsRegionDirty(addr));
60 } 56 }
61 } 57 }
62 58
63 59
64 TEST(Page) { 60 TEST(Page) {
65 #ifdef DEBUG
66 Page::set_rset_state(Page::NOT_IN_USE);
67 #endif
68
69 byte* mem = NewArray<byte>(2*Page::kPageSize); 61 byte* mem = NewArray<byte>(2*Page::kPageSize);
70 CHECK(mem != NULL); 62 CHECK(mem != NULL);
71 63
72 Address start = reinterpret_cast<Address>(mem); 64 Address start = reinterpret_cast<Address>(mem);
73 Address page_start = RoundUp(start, Page::kPageSize); 65 Address page_start = RoundUp(start, Page::kPageSize);
74 66
75 Page* p = Page::FromAddress(page_start); 67 Page* p = Page::FromAddress(page_start);
76 CHECK(p->address() == page_start); 68 CHECK(p->address() == page_start);
77 CHECK(p->is_valid()); 69 CHECK(p->is_valid());
78 70
79 p->opaque_header = 0; 71 p->opaque_header = 0;
80 p->SetIsLargeObjectPage(false); 72 p->SetIsLargeObjectPage(false);
81 CHECK(!p->next_page()->is_valid()); 73 CHECK(!p->next_page()->is_valid());
82 74
83 CHECK(p->ObjectAreaStart() == page_start + Page::kObjectStartOffset); 75 CHECK(p->ObjectAreaStart() == page_start + Page::kObjectStartOffset);
84 CHECK(p->ObjectAreaEnd() == page_start + Page::kPageSize); 76 CHECK(p->ObjectAreaEnd() == page_start + Page::kPageSize);
85 77
86 CHECK(p->Offset(page_start + Page::kObjectStartOffset) == 78 CHECK(p->Offset(page_start + Page::kObjectStartOffset) ==
87 Page::kObjectStartOffset); 79 Page::kObjectStartOffset);
88 CHECK(p->Offset(page_start + Page::kPageSize) == Page::kPageSize); 80 CHECK(p->Offset(page_start + Page::kPageSize) == Page::kPageSize);
89 81
90 CHECK(p->OffsetToAddress(Page::kObjectStartOffset) == p->ObjectAreaStart()); 82 CHECK(p->OffsetToAddress(Page::kObjectStartOffset) == p->ObjectAreaStart());
91 CHECK(p->OffsetToAddress(Page::kPageSize) == p->ObjectAreaEnd()); 83 CHECK(p->OffsetToAddress(Page::kPageSize) == p->ObjectAreaEnd());
92 84
93 // test remember set 85 // test region marking
94 VerifyRSet(page_start); 86 VerifyRegionMarking(page_start);
95 87
96 DeleteArray(mem); 88 DeleteArray(mem);
97 } 89 }
98 90
99 91
100 TEST(MemoryAllocator) { 92 TEST(MemoryAllocator) {
101 CHECK(Heap::ConfigureHeapDefault()); 93 CHECK(Heap::ConfigureHeapDefault());
102 CHECK(MemoryAllocator::Setup(Heap::MaxReserved())); 94 CHECK(MemoryAllocator::Setup(Heap::MaxReserved()));
103 95
104 OldSpace faked_space(Heap::MaxReserved(), OLD_POINTER_SPACE, NOT_EXECUTABLE); 96 OldSpace faked_space(Heap::MaxReserved(), OLD_POINTER_SPACE, NOT_EXECUTABLE);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 CHECK(!lo->IsEmpty()); 231 CHECK(!lo->IsEmpty());
240 232
241 obj = lo->AllocateRaw(lo_size); 233 obj = lo->AllocateRaw(lo_size);
242 CHECK(obj->IsFailure()); 234 CHECK(obj->IsFailure());
243 235
244 lo->TearDown(); 236 lo->TearDown();
245 delete lo; 237 delete lo;
246 238
247 MemoryAllocator::TearDown(); 239 MemoryAllocator::TearDown();
248 } 240 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698