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