OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 int counter = 0; | 597 int counter = 0; |
598 static const int kThreshold = 20; | 598 static const int kThreshold = 20; |
599 while (gc_performed && counter++ < kThreshold) { | 599 while (gc_performed && counter++ < kThreshold) { |
600 gc_performed = false; | 600 gc_performed = false; |
601 if (!new_space->ReserveSpace(new_space_size)) { | 601 if (!new_space->ReserveSpace(new_space_size)) { |
602 Heap::CollectGarbage(NEW_SPACE, | 602 Heap::CollectGarbage(NEW_SPACE, |
603 "failed to reserve space in the new space"); | 603 "failed to reserve space in the new space"); |
604 gc_performed = true; | 604 gc_performed = true; |
605 } | 605 } |
606 if (!old_pointer_space->ReserveSpace(pointer_space_size)) { | 606 if (!old_pointer_space->ReserveSpace(pointer_space_size)) { |
607 Heap::CollectGarbage(OLD_POINTER_SPACE, | 607 Heap::AbortIncrementalMarkingAndCollectGarbage( |
608 "failed to reserve space in the old pointer space"); | 608 OLD_POINTER_SPACE, |
| 609 "failed to reserve space in the old pointer space"); |
609 gc_performed = true; | 610 gc_performed = true; |
610 } | 611 } |
611 if (!(old_data_space->ReserveSpace(data_space_size))) { | 612 if (!(old_data_space->ReserveSpace(data_space_size))) { |
612 Heap::CollectGarbage(OLD_DATA_SPACE, | 613 Heap::AbortIncrementalMarkingAndCollectGarbage( |
613 "failed to reserve space in the old data space"); | 614 OLD_DATA_SPACE, "failed to reserve space in the old data space"); |
614 gc_performed = true; | 615 gc_performed = true; |
615 } | 616 } |
616 if (!(code_space->ReserveSpace(code_space_size))) { | 617 if (!(code_space->ReserveSpace(code_space_size))) { |
617 Heap::CollectGarbage(CODE_SPACE, | 618 Heap::AbortIncrementalMarkingAndCollectGarbage( |
618 "failed to reserve space in the code space"); | 619 CODE_SPACE, "failed to reserve space in the code space"); |
619 gc_performed = true; | 620 gc_performed = true; |
620 } | 621 } |
621 if (!(map_space->ReserveSpace(map_space_size))) { | 622 if (!(map_space->ReserveSpace(map_space_size))) { |
622 Heap::CollectGarbage(MAP_SPACE, | 623 Heap::AbortIncrementalMarkingAndCollectGarbage( |
623 "failed to reserve space in the map space"); | 624 MAP_SPACE, "failed to reserve space in the map space"); |
624 gc_performed = true; | 625 gc_performed = true; |
625 } | 626 } |
626 if (!(cell_space->ReserveSpace(cell_space_size))) { | 627 if (!(cell_space->ReserveSpace(cell_space_size))) { |
627 Heap::CollectGarbage(CELL_SPACE, | 628 Heap::AbortIncrementalMarkingAndCollectGarbage( |
628 "failed to reserve space in the cell space"); | 629 CELL_SPACE, "failed to reserve space in the cell space"); |
629 gc_performed = true; | 630 gc_performed = true; |
630 } | 631 } |
631 // We add a slack-factor of 2 in order to have space for a series of | 632 // We add a slack-factor of 2 in order to have space for a series of |
632 // large-object allocations that are only just larger than the page size. | 633 // large-object allocations that are only just larger than the page size. |
633 large_object_size *= 2; | 634 large_object_size *= 2; |
634 // The ReserveSpace method on the large object space checks how much | 635 // The ReserveSpace method on the large object space checks how much |
635 // we can expand the old generation. This includes expansion caused by | 636 // we can expand the old generation. This includes expansion caused by |
636 // allocation in the other spaces. | 637 // allocation in the other spaces. |
637 large_object_size += cell_space_size + map_space_size + code_space_size + | 638 large_object_size += cell_space_size + map_space_size + code_space_size + |
638 data_space_size + pointer_space_size; | 639 data_space_size + pointer_space_size; |
639 if (!(lo_space->ReserveSpace(large_object_size))) { | 640 if (!(lo_space->ReserveSpace(large_object_size))) { |
640 Heap::CollectGarbage(LO_SPACE, | 641 Heap::AbortIncrementalMarkingAndCollectGarbage( |
641 "failed to reserve space in the large object space"); | 642 LO_SPACE, "failed to reserve space in the large object space"); |
642 gc_performed = true; | 643 gc_performed = true; |
643 } | 644 } |
644 } | 645 } |
645 | 646 |
646 if (gc_performed) { | 647 if (gc_performed) { |
647 // Failed to reserve the space after several attempts. | 648 // Failed to reserve the space after several attempts. |
648 V8::FatalProcessOutOfMemory("Heap::ReserveSpace"); | 649 V8::FatalProcessOutOfMemory("Heap::ReserveSpace"); |
649 } | 650 } |
650 } | 651 } |
651 | 652 |
(...skipping 6289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6941 isolate_->heap()->store_buffer()->Compact(); | 6942 isolate_->heap()->store_buffer()->Compact(); |
6942 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); | 6943 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); |
6943 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { | 6944 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { |
6944 next = chunk->next_chunk(); | 6945 next = chunk->next_chunk(); |
6945 isolate_->memory_allocator()->Free(chunk); | 6946 isolate_->memory_allocator()->Free(chunk); |
6946 } | 6947 } |
6947 chunks_queued_for_free_ = NULL; | 6948 chunks_queued_for_free_ = NULL; |
6948 } | 6949 } |
6949 | 6950 |
6950 } } // namespace v8::internal | 6951 } } // namespace v8::internal |
OLD | NEW |