OLD | NEW |
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 CHECK(!invalid_page->is_valid()); | 150 CHECK(!invalid_page->is_valid()); |
151 | 151 |
152 MemoryAllocator::TearDown(); | 152 MemoryAllocator::TearDown(); |
153 } | 153 } |
154 | 154 |
155 | 155 |
156 TEST(NewSpace) { | 156 TEST(NewSpace) { |
157 CHECK(Heap::ConfigureHeapDefault()); | 157 CHECK(Heap::ConfigureHeapDefault()); |
158 CHECK(MemoryAllocator::Setup(Heap::MaxCapacity())); | 158 CHECK(MemoryAllocator::Setup(Heap::MaxCapacity())); |
159 | 159 |
160 NewSpace* s = new NewSpace(Heap::InitialSemiSpaceSize(), | 160 NewSpace new_space; |
161 Heap::SemiSpaceSize(), | |
162 NEW_SPACE); | |
163 CHECK(s != NULL); | |
164 | 161 |
165 void* chunk = | 162 void* chunk = |
166 MemoryAllocator::ReserveInitialChunk(2 * Heap::YoungGenerationSize()); | 163 MemoryAllocator::ReserveInitialChunk(2 * Heap::YoungGenerationSize()); |
167 CHECK(chunk != NULL); | 164 CHECK(chunk != NULL); |
168 Address start = RoundUp(static_cast<Address>(chunk), | 165 Address start = RoundUp(static_cast<Address>(chunk), |
169 Heap::YoungGenerationSize()); | 166 Heap::YoungGenerationSize()); |
170 CHECK(s->Setup(start, Heap::YoungGenerationSize())); | 167 CHECK(new_space.Setup(start, Heap::YoungGenerationSize())); |
171 CHECK(s->HasBeenSetup()); | 168 CHECK(new_space.HasBeenSetup()); |
172 | 169 |
173 while (s->Available() >= Page::kMaxHeapObjectSize) { | 170 while (new_space.Available() >= Page::kMaxHeapObjectSize) { |
174 Object* obj = s->AllocateRaw(Page::kMaxHeapObjectSize); | 171 Object* obj = new_space.AllocateRaw(Page::kMaxHeapObjectSize); |
175 CHECK(!obj->IsFailure()); | 172 CHECK(!obj->IsFailure()); |
176 CHECK(s->Contains(HeapObject::cast(obj))); | 173 CHECK(new_space.Contains(HeapObject::cast(obj))); |
177 } | 174 } |
178 | 175 |
179 s->TearDown(); | 176 new_space.TearDown(); |
180 delete s; | |
181 MemoryAllocator::TearDown(); | 177 MemoryAllocator::TearDown(); |
182 } | 178 } |
183 | 179 |
184 | 180 |
185 TEST(OldSpace) { | 181 TEST(OldSpace) { |
186 CHECK(Heap::ConfigureHeapDefault()); | 182 CHECK(Heap::ConfigureHeapDefault()); |
187 CHECK(MemoryAllocator::Setup(Heap::MaxCapacity())); | 183 CHECK(MemoryAllocator::Setup(Heap::MaxCapacity())); |
188 | 184 |
189 OldSpace* s = new OldSpace(Heap::OldGenerationSize(), | 185 OldSpace* s = new OldSpace(Heap::OldGenerationSize(), |
190 OLD_POINTER_SPACE, | 186 OLD_POINTER_SPACE, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 CHECK(!lo->IsEmpty()); | 242 CHECK(!lo->IsEmpty()); |
247 | 243 |
248 obj = lo->AllocateRaw(lo_size); | 244 obj = lo->AllocateRaw(lo_size); |
249 CHECK(obj->IsFailure()); | 245 CHECK(obj->IsFailure()); |
250 | 246 |
251 lo->TearDown(); | 247 lo->TearDown(); |
252 delete lo; | 248 delete lo; |
253 | 249 |
254 MemoryAllocator::TearDown(); | 250 MemoryAllocator::TearDown(); |
255 } | 251 } |
OLD | NEW |