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

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

Issue 6529055: [Isolates] Merge crankshaft (r5922 from bleeding_edge). (Closed)
Patch Set: Win32 port Created 9 years, 10 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-profile-generator.cc ('k') | test/cctest/test-version.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 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 Isolate* isolate = Isolate::Current(); 96 Isolate* isolate = Isolate::Current();
97 CHECK(HEAP->ConfigureHeapDefault()); 97 CHECK(HEAP->ConfigureHeapDefault());
98 CHECK(isolate->memory_allocator()->Setup(HEAP->MaxReserved(), 98 CHECK(isolate->memory_allocator()->Setup(HEAP->MaxReserved(),
99 HEAP->MaxExecutableSize())); 99 HEAP->MaxExecutableSize()));
100 100
101 OldSpace faked_space(HEAP, 101 OldSpace faked_space(HEAP,
102 HEAP->MaxReserved(), 102 HEAP->MaxReserved(),
103 OLD_POINTER_SPACE, 103 OLD_POINTER_SPACE,
104 NOT_EXECUTABLE); 104 NOT_EXECUTABLE);
105 int total_pages = 0; 105 int total_pages = 0;
106 int requested = 2; 106 int requested = MemoryAllocator::kPagesPerChunk;
107 int allocated; 107 int allocated;
108 // If we request two pages, we should get one or two. 108 // If we request n pages, we should get n or n - 1.
109 Page* first_page = 109 Page* first_page =
110 isolate->memory_allocator()->AllocatePages( 110 isolate->memory_allocator()->AllocatePages(
111 requested, &allocated, &faked_space); 111 requested, &allocated, &faked_space);
112 CHECK(first_page->is_valid()); 112 CHECK(first_page->is_valid());
113 CHECK(allocated > 0 && allocated <= 2); 113 CHECK(allocated == requested || allocated == requested - 1);
114 total_pages += allocated; 114 total_pages += allocated;
115 115
116 Page* last_page = first_page; 116 Page* last_page = first_page;
117 for (Page* p = first_page; p->is_valid(); p = p->next_page()) { 117 for (Page* p = first_page; p->is_valid(); p = p->next_page()) {
118 CHECK(isolate->memory_allocator()->IsPageInSpace(p, &faked_space)); 118 CHECK(isolate->memory_allocator()->IsPageInSpace(p, &faked_space));
119 last_page = p; 119 last_page = p;
120 } 120 }
121 121
122 // Again, we should get one or two pages. 122 // Again, we should get n or n - 1 pages.
123 Page* others = 123 Page* others =
124 isolate->memory_allocator()->AllocatePages( 124 isolate->memory_allocator()->AllocatePages(
125 requested, &allocated, &faked_space); 125 requested, &allocated, &faked_space);
126 CHECK(others->is_valid()); 126 CHECK(others->is_valid());
127 CHECK(allocated > 0 && allocated <= 2); 127 CHECK(allocated == requested || allocated == requested - 1);
128 total_pages += allocated; 128 total_pages += allocated;
129 129
130 isolate->memory_allocator()->SetNextPage(last_page, others); 130 isolate->memory_allocator()->SetNextPage(last_page, others);
131 int page_count = 0; 131 int page_count = 0;
132 for (Page* p = first_page; p->is_valid(); p = p->next_page()) { 132 for (Page* p = first_page; p->is_valid(); p = p->next_page()) {
133 CHECK(isolate->memory_allocator()->IsPageInSpace(p, &faked_space)); 133 CHECK(isolate->memory_allocator()->IsPageInSpace(p, &faked_space));
134 page_count++; 134 page_count++;
135 } 135 }
136 CHECK(total_pages == page_count); 136 CHECK(total_pages == page_count);
137 137
138 Page* second_page = first_page->next_page(); 138 Page* second_page = first_page->next_page();
139 CHECK(second_page->is_valid()); 139 CHECK(second_page->is_valid());
140 140
141 // Freeing pages at the first chunk starting at or after the second page 141 // Freeing pages at the first chunk starting at or after the second page
142 // should free the entire second chunk. It will return the last page in the 142 // should free the entire second chunk. It will return the page it was passed
143 // first chunk (if the second page was in the first chunk) or else an 143 // (since the second page was in the first chunk).
144 // invalid page (if the second page was the start of the second chunk).
145 Page* free_return = isolate->memory_allocator()->FreePages(second_page); 144 Page* free_return = isolate->memory_allocator()->FreePages(second_page);
146 CHECK(free_return == last_page || !free_return->is_valid()); 145 CHECK(free_return == second_page);
147 isolate->memory_allocator()->SetNextPage(first_page, free_return); 146 isolate->memory_allocator()->SetNextPage(first_page, free_return);
148 147
149 // Freeing pages in the first chunk starting at the first page should free 148 // Freeing pages in the first chunk starting at the first page should free
150 // the first chunk and return an invalid page. 149 // the first chunk and return an invalid page.
151 Page* invalid_page = isolate->memory_allocator()->FreePages(first_page); 150 Page* invalid_page = isolate->memory_allocator()->FreePages(first_page);
152 CHECK(!invalid_page->is_valid()); 151 CHECK(!invalid_page->is_valid());
153 152
154 isolate->memory_allocator()->TearDown(); 153 isolate->memory_allocator()->TearDown();
155 } 154 }
156 155
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 246
248 CHECK(!lo->IsEmpty()); 247 CHECK(!lo->IsEmpty());
249 248
250 CHECK(lo->AllocateRaw(lo_size)->IsFailure()); 249 CHECK(lo->AllocateRaw(lo_size)->IsFailure());
251 250
252 lo->TearDown(); 251 lo->TearDown();
253 delete lo; 252 delete lo;
254 253
255 Isolate::Current()->memory_allocator()->TearDown(); 254 Isolate::Current()->memory_allocator()->TearDown();
256 } 255 }
OLDNEW
« no previous file with comments | « test/cctest/test-profile-generator.cc ('k') | test/cctest/test-version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698