OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 v8::Local<v8::Value> result = CompileRun(code); | 479 v8::Local<v8::Value> result = CompileRun(code); |
480 CHECK(result->IsUndefined()); | 480 CHECK(result->IsUndefined()); |
481 } | 481 } |
482 | 482 |
483 | 483 |
484 // Helper function that simulates a full new-space in the heap. | 484 // Helper function that simulates a full new-space in the heap. |
485 static inline bool FillUpOnePage(v8::internal::NewSpace* space) { | 485 static inline bool FillUpOnePage(v8::internal::NewSpace* space) { |
486 v8::internal::AllocationResult allocation = | 486 v8::internal::AllocationResult allocation = |
487 space->AllocateRaw(v8::internal::Page::kMaxRegularHeapObjectSize); | 487 space->AllocateRaw(v8::internal::Page::kMaxRegularHeapObjectSize); |
488 if (allocation.IsRetry()) return false; | 488 if (allocation.IsRetry()) return false; |
489 v8::internal::FreeListNode* node = | 489 v8::internal::HeapObject* free_space = NULL; |
490 v8::internal::FreeListNode::cast(allocation.ToObjectChecked()); | 490 CHECK(allocation.To(&free_space)); |
491 node->set_size(space->heap(), v8::internal::Page::kMaxRegularHeapObjectSize); | 491 space->heap()->CreateFillerObjectAt( |
| 492 free_space->address(), v8::internal::Page::kMaxRegularHeapObjectSize); |
492 return true; | 493 return true; |
493 } | 494 } |
494 | 495 |
495 | 496 |
496 static inline void SimulateFullSpace(v8::internal::NewSpace* space) { | 497 // Helper function that simulates a fill new-space in the heap. |
497 int new_linear_size = static_cast<int>(*space->allocation_limit_address() - | 498 static inline void AllocateAllButNBytes(v8::internal::NewSpace* space, |
| 499 int extra_bytes) { |
| 500 int space_remaining = static_cast<int>(*space->allocation_limit_address() - |
498 *space->allocation_top_address()); | 501 *space->allocation_top_address()); |
499 if (new_linear_size > 0) { | 502 CHECK(space_remaining >= extra_bytes); |
500 // Fill up the current page. | 503 int new_linear_size = space_remaining - extra_bytes; |
501 v8::internal::AllocationResult allocation = | 504 if (new_linear_size == 0) return; |
502 space->AllocateRaw(new_linear_size); | 505 v8::internal::AllocationResult allocation = |
503 v8::internal::FreeListNode* node = | 506 space->AllocateRaw(new_linear_size); |
504 v8::internal::FreeListNode::cast(allocation.ToObjectChecked()); | 507 v8::internal::HeapObject* free_space = NULL; |
505 node->set_size(space->heap(), new_linear_size); | 508 CHECK(allocation.To(&free_space)); |
506 } | 509 space->heap()->CreateFillerObjectAt(free_space->address(), new_linear_size); |
507 // Fill up all remaining pages. | |
508 while (FillUpOnePage(space)) | |
509 ; | |
510 } | 510 } |
511 | 511 |
512 | 512 |
| 513 static inline void FillCurrentPage(v8::internal::NewSpace* space) { |
| 514 AllocateAllButNBytes(space, 0); |
| 515 } |
| 516 |
| 517 |
| 518 static inline void SimulateFullSpace(v8::internal::NewSpace* space) { |
| 519 FillCurrentPage(space); |
| 520 while (FillUpOnePage(space)) { |
| 521 } |
| 522 } |
| 523 |
| 524 |
513 // Helper function that simulates a full old-space in the heap. | 525 // Helper function that simulates a full old-space in the heap. |
514 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { | 526 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { |
515 space->EmptyAllocationInfo(); | 527 space->EmptyAllocationInfo(); |
516 space->ResetFreeList(); | 528 space->ResetFreeList(); |
517 space->ClearStats(); | 529 space->ClearStats(); |
518 } | 530 } |
519 | 531 |
520 | 532 |
521 // Helper function that simulates many incremental marking steps until | 533 // Helper function that simulates many incremental marking steps until |
522 // marking is completed. | 534 // marking is completed. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 HandleAndZoneScope() {} | 592 HandleAndZoneScope() {} |
581 | 593 |
582 // Prefixing the below with main_ reduces a lot of naming clashes. | 594 // Prefixing the below with main_ reduces a lot of naming clashes. |
583 i::Zone* main_zone() { return &main_zone_; } | 595 i::Zone* main_zone() { return &main_zone_; } |
584 | 596 |
585 private: | 597 private: |
586 i::Zone main_zone_; | 598 i::Zone main_zone_; |
587 }; | 599 }; |
588 | 600 |
589 #endif // ifndef CCTEST_H_ | 601 #endif // ifndef CCTEST_H_ |
OLD | NEW |