OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 second_commit_area_size); | 198 second_commit_area_size); |
199 | 199 |
200 memory_allocator->Free(memory_chunk); | 200 memory_allocator->Free(memory_chunk); |
201 memory_allocator->TearDown(); | 201 memory_allocator->TearDown(); |
202 delete memory_allocator; | 202 delete memory_allocator; |
203 } | 203 } |
204 | 204 |
205 | 205 |
206 TEST(Regress3540) { | 206 TEST(Regress3540) { |
207 Isolate* isolate = CcTest::i_isolate(); | 207 Isolate* isolate = CcTest::i_isolate(); |
| 208 isolate->InitializeLoggingAndCounters(); |
208 Heap* heap = isolate->heap(); | 209 Heap* heap = isolate->heap(); |
| 210 CHECK(heap->ConfigureHeapDefault()); |
209 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 211 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
210 CHECK( | 212 CHECK( |
211 memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize())); | 213 memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize())); |
212 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); | 214 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); |
213 CodeRange* code_range = new CodeRange(isolate); | 215 CodeRange* code_range = new CodeRange(isolate); |
214 const size_t code_range_size = 4 * MB; | 216 const size_t code_range_size = 4 * MB; |
215 if (!code_range->SetUp(code_range_size)) return; | 217 if (!code_range->SetUp(code_range_size)) return; |
216 Address address; | 218 Address address; |
217 size_t size; | 219 size_t size; |
218 address = code_range->AllocateRawMemory(code_range_size - MB, | 220 address = code_range->AllocateRawMemory(code_range_size - MB, |
(...skipping 13 matching lines...) Expand all Loading... |
232 | 234 |
233 static unsigned int Pseudorandom() { | 235 static unsigned int Pseudorandom() { |
234 static uint32_t lo = 2345; | 236 static uint32_t lo = 2345; |
235 lo = 18273 * (lo & 0xFFFFF) + (lo >> 16); | 237 lo = 18273 * (lo & 0xFFFFF) + (lo >> 16); |
236 return lo & 0xFFFFF; | 238 return lo & 0xFFFFF; |
237 } | 239 } |
238 | 240 |
239 | 241 |
240 TEST(MemoryChunk) { | 242 TEST(MemoryChunk) { |
241 Isolate* isolate = CcTest::i_isolate(); | 243 Isolate* isolate = CcTest::i_isolate(); |
| 244 isolate->InitializeLoggingAndCounters(); |
242 Heap* heap = isolate->heap(); | 245 Heap* heap = isolate->heap(); |
| 246 CHECK(heap->ConfigureHeapDefault()); |
243 | 247 |
244 size_t reserve_area_size = 1 * MB; | 248 size_t reserve_area_size = 1 * MB; |
245 size_t initial_commit_area_size, second_commit_area_size; | 249 size_t initial_commit_area_size, second_commit_area_size; |
246 | 250 |
247 for (int i = 0; i < 100; i++) { | 251 for (int i = 0; i < 100; i++) { |
248 initial_commit_area_size = Pseudorandom(); | 252 initial_commit_area_size = Pseudorandom(); |
249 second_commit_area_size = Pseudorandom(); | 253 second_commit_area_size = Pseudorandom(); |
250 | 254 |
251 // With CodeRange. | 255 // With CodeRange. |
252 CodeRange* code_range = new CodeRange(isolate); | 256 CodeRange* code_range = new CodeRange(isolate); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 reserve_area_size, | 290 reserve_area_size, |
287 initial_commit_area_size, | 291 initial_commit_area_size, |
288 second_commit_area_size, | 292 second_commit_area_size, |
289 NOT_EXECUTABLE); | 293 NOT_EXECUTABLE); |
290 } | 294 } |
291 } | 295 } |
292 | 296 |
293 | 297 |
294 TEST(MemoryAllocator) { | 298 TEST(MemoryAllocator) { |
295 Isolate* isolate = CcTest::i_isolate(); | 299 Isolate* isolate = CcTest::i_isolate(); |
| 300 isolate->InitializeLoggingAndCounters(); |
296 Heap* heap = isolate->heap(); | 301 Heap* heap = isolate->heap(); |
| 302 CHECK(isolate->heap()->ConfigureHeapDefault()); |
297 | 303 |
298 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 304 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
299 CHECK(memory_allocator->SetUp(heap->MaxReserved(), | 305 CHECK(memory_allocator->SetUp(heap->MaxReserved(), |
300 heap->MaxExecutableSize())); | 306 heap->MaxExecutableSize())); |
301 | 307 |
302 int total_pages = 0; | 308 int total_pages = 0; |
303 OldSpace faked_space(heap, | 309 OldSpace faked_space(heap, |
304 heap->MaxReserved(), | 310 heap->MaxReserved(), |
305 OLD_POINTER_SPACE, | 311 OLD_POINTER_SPACE, |
306 NOT_EXECUTABLE); | 312 NOT_EXECUTABLE); |
(...skipping 26 matching lines...) Expand all Loading... |
333 CHECK(second_page->is_valid()); | 339 CHECK(second_page->is_valid()); |
334 memory_allocator->Free(first_page); | 340 memory_allocator->Free(first_page); |
335 memory_allocator->Free(second_page); | 341 memory_allocator->Free(second_page); |
336 memory_allocator->TearDown(); | 342 memory_allocator->TearDown(); |
337 delete memory_allocator; | 343 delete memory_allocator; |
338 } | 344 } |
339 | 345 |
340 | 346 |
341 TEST(NewSpace) { | 347 TEST(NewSpace) { |
342 Isolate* isolate = CcTest::i_isolate(); | 348 Isolate* isolate = CcTest::i_isolate(); |
| 349 isolate->InitializeLoggingAndCounters(); |
343 Heap* heap = isolate->heap(); | 350 Heap* heap = isolate->heap(); |
| 351 CHECK(heap->ConfigureHeapDefault()); |
344 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 352 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
345 CHECK(memory_allocator->SetUp(heap->MaxReserved(), | 353 CHECK(memory_allocator->SetUp(heap->MaxReserved(), |
346 heap->MaxExecutableSize())); | 354 heap->MaxExecutableSize())); |
347 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); | 355 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); |
348 | 356 |
349 NewSpace new_space(heap); | 357 NewSpace new_space(heap); |
350 | 358 |
351 CHECK(new_space.SetUp(CcTest::heap()->ReservedSemiSpaceSize(), | 359 CHECK(new_space.SetUp(CcTest::heap()->ReservedSemiSpaceSize(), |
352 CcTest::heap()->ReservedSemiSpaceSize())); | 360 CcTest::heap()->ReservedSemiSpaceSize())); |
353 CHECK(new_space.HasBeenSetUp()); | 361 CHECK(new_space.HasBeenSetUp()); |
354 | 362 |
355 while (new_space.Available() >= Page::kMaxRegularHeapObjectSize) { | 363 while (new_space.Available() >= Page::kMaxRegularHeapObjectSize) { |
356 Object* obj = new_space.AllocateRaw( | 364 Object* obj = new_space.AllocateRaw( |
357 Page::kMaxRegularHeapObjectSize).ToObjectChecked(); | 365 Page::kMaxRegularHeapObjectSize).ToObjectChecked(); |
358 CHECK(new_space.Contains(HeapObject::cast(obj))); | 366 CHECK(new_space.Contains(HeapObject::cast(obj))); |
359 } | 367 } |
360 | 368 |
361 new_space.TearDown(); | 369 new_space.TearDown(); |
362 memory_allocator->TearDown(); | 370 memory_allocator->TearDown(); |
363 delete memory_allocator; | 371 delete memory_allocator; |
364 } | 372 } |
365 | 373 |
366 | 374 |
367 TEST(OldSpace) { | 375 TEST(OldSpace) { |
368 Isolate* isolate = CcTest::i_isolate(); | 376 Isolate* isolate = CcTest::i_isolate(); |
| 377 isolate->InitializeLoggingAndCounters(); |
369 Heap* heap = isolate->heap(); | 378 Heap* heap = isolate->heap(); |
| 379 CHECK(heap->ConfigureHeapDefault()); |
370 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 380 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
371 CHECK(memory_allocator->SetUp(heap->MaxReserved(), | 381 CHECK(memory_allocator->SetUp(heap->MaxReserved(), |
372 heap->MaxExecutableSize())); | 382 heap->MaxExecutableSize())); |
373 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); | 383 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); |
374 | 384 |
375 OldSpace* s = new OldSpace(heap, | 385 OldSpace* s = new OldSpace(heap, |
376 heap->MaxOldGenerationSize(), | 386 heap->MaxOldGenerationSize(), |
377 OLD_POINTER_SPACE, | 387 OLD_POINTER_SPACE, |
378 NOT_EXECUTABLE); | 388 NOT_EXECUTABLE); |
379 CHECK(s != NULL); | 389 CHECK(s != NULL); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 CompileRun("/*empty*/"); | 453 CompileRun("/*empty*/"); |
444 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { | 454 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { |
445 // Debug code can be very large, so skip CODE_SPACE if we are generating it. | 455 // Debug code can be very large, so skip CODE_SPACE if we are generating it. |
446 if (i == CODE_SPACE && i::FLAG_debug_code) continue; | 456 if (i == CODE_SPACE && i::FLAG_debug_code) continue; |
447 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages()); | 457 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages()); |
448 } | 458 } |
449 | 459 |
450 // No large objects required to perform the above steps. | 460 // No large objects required to perform the above steps. |
451 CHECK(isolate->heap()->lo_space()->IsEmpty()); | 461 CHECK(isolate->heap()->lo_space()->IsEmpty()); |
452 } | 462 } |
OLD | NEW |