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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 int map_space_size, | 573 int map_space_size, |
574 int cell_space_size, | 574 int cell_space_size, |
575 int large_object_size) { | 575 int large_object_size) { |
576 NewSpace* new_space = Heap::new_space(); | 576 NewSpace* new_space = Heap::new_space(); |
577 PagedSpace* old_pointer_space = Heap::old_pointer_space(); | 577 PagedSpace* old_pointer_space = Heap::old_pointer_space(); |
578 PagedSpace* old_data_space = Heap::old_data_space(); | 578 PagedSpace* old_data_space = Heap::old_data_space(); |
579 PagedSpace* code_space = Heap::code_space(); | 579 PagedSpace* code_space = Heap::code_space(); |
580 PagedSpace* map_space = Heap::map_space(); | 580 PagedSpace* map_space = Heap::map_space(); |
581 PagedSpace* cell_space = Heap::cell_space(); | 581 PagedSpace* cell_space = Heap::cell_space(); |
582 LargeObjectSpace* lo_space = Heap::lo_space(); | 582 LargeObjectSpace* lo_space = Heap::lo_space(); |
583 bool one_gc_has_been_performed = false; | |
583 bool gc_performed = true; | 584 bool gc_performed = true; |
584 while (gc_performed) { | 585 while (gc_performed) { |
585 gc_performed = false; | 586 gc_performed = false; |
586 if (!new_space->ReserveSpace(new_space_size)) { | 587 if (!new_space->ReserveSpace(new_space_size)) { |
587 Heap::CollectGarbage(NEW_SPACE); | 588 Heap::CollectGarbage(NEW_SPACE); |
588 gc_performed = true; | 589 gc_performed = true; |
589 } | 590 } |
590 if (!old_pointer_space->ReserveSpace(pointer_space_size)) { | 591 if (!old_pointer_space->ReserveSpace(pointer_space_size)) { |
591 Heap::CollectGarbage(OLD_POINTER_SPACE); | 592 Heap::CollectGarbage(OLD_POINTER_SPACE); |
592 gc_performed = true; | 593 gc_performed = true; |
(...skipping 15 matching lines...) Expand all Loading... | |
608 gc_performed = true; | 609 gc_performed = true; |
609 } | 610 } |
610 // We add a slack-factor of 2 in order to have space for a series of | 611 // We add a slack-factor of 2 in order to have space for a series of |
611 // large-object allocations that are only just larger than the page size. | 612 // large-object allocations that are only just larger than the page size. |
612 large_object_size *= 2; | 613 large_object_size *= 2; |
613 // The ReserveSpace method on the large object space checks how much | 614 // The ReserveSpace method on the large object space checks how much |
614 // we can expand the old generation. This includes expansion caused by | 615 // we can expand the old generation. This includes expansion caused by |
615 // allocation in the other spaces. | 616 // allocation in the other spaces. |
616 large_object_size += cell_space_size + map_space_size + code_space_size + | 617 large_object_size += cell_space_size + map_space_size + code_space_size + |
617 data_space_size + pointer_space_size; | 618 data_space_size + pointer_space_size; |
618 if (!(lo_space->ReserveSpace(large_object_size))) { | 619 |
620 // If we already did one GC in order to make space in old space, there is | |
621 // no sense in doing another one. We will attempt to force through the | |
622 // large object space allocation, which comes directly from the OS, | |
623 // regardless of any soft limit. | |
624 if (!one_gc_has_been_performed && | |
625 !(lo_space->ReserveSpace(large_object_size))) { | |
619 Heap::CollectGarbage(LO_SPACE); | 626 Heap::CollectGarbage(LO_SPACE); |
620 gc_performed = true; | 627 gc_performed = true; |
621 } | 628 } |
629 if (gc_performed) one_gc_has_been_performed = true; | |
Vyacheslav Egorov (Chromium)
2011/12/21 13:22:12
scavenge will not free any space in LO.
gc_perfor
| |
622 } | 630 } |
623 } | 631 } |
624 | 632 |
625 | 633 |
626 void Heap::EnsureFromSpaceIsCommitted() { | 634 void Heap::EnsureFromSpaceIsCommitted() { |
627 if (new_space_.CommitFromSpaceIfNeeded()) return; | 635 if (new_space_.CommitFromSpaceIfNeeded()) return; |
628 | 636 |
629 // Committing memory to from space failed. | 637 // Committing memory to from space failed. |
630 // Try shrinking and try again. | 638 // Try shrinking and try again. |
631 Shrink(); | 639 Shrink(); |
(...skipping 4662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5294 } | 5302 } |
5295 | 5303 |
5296 // The max executable size must be less than or equal to the max old | 5304 // The max executable size must be less than or equal to the max old |
5297 // generation size. | 5305 // generation size. |
5298 if (max_executable_size_ > max_old_generation_size_) { | 5306 if (max_executable_size_ > max_old_generation_size_) { |
5299 max_executable_size_ = max_old_generation_size_; | 5307 max_executable_size_ = max_old_generation_size_; |
5300 } | 5308 } |
5301 | 5309 |
5302 // The new space size must be a power of two to support single-bit testing | 5310 // The new space size must be a power of two to support single-bit testing |
5303 // for containment. | 5311 // for containment. |
5304 max_semispace_size_ = RoundUpToPowerOf2(max_semispace_size_); | 5312 max_semispace_size_ = SignedRoundUpToPowerOf2(max_semispace_size_); |
Vyacheslav Egorov (Chromium)
2011/12/21 13:22:12
what's the point of these fields being signed? loo
| |
5305 reserved_semispace_size_ = RoundUpToPowerOf2(reserved_semispace_size_); | 5313 reserved_semispace_size_ = SignedRoundUpToPowerOf2(reserved_semispace_size_); |
5306 initial_semispace_size_ = Min(initial_semispace_size_, max_semispace_size_); | 5314 initial_semispace_size_ = Min(initial_semispace_size_, max_semispace_size_); |
5307 external_allocation_limit_ = 10 * max_semispace_size_; | 5315 external_allocation_limit_ = 10 * max_semispace_size_; |
5308 | 5316 |
5309 // The old generation is paged and needs at least one page for each space. | 5317 // The old generation is paged and needs at least one page for each space. |
5310 int paged_space_count = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1; | 5318 int paged_space_count = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1; |
5311 max_old_generation_size_ = Max(static_cast<intptr_t>(paged_space_count * | 5319 max_old_generation_size_ = Max(static_cast<intptr_t>(paged_space_count * |
5312 Page::kPageSize), | 5320 Page::kPageSize), |
5313 RoundUp(max_old_generation_size_, | 5321 RoundUp(max_old_generation_size_, |
5314 Page::kPageSize)); | 5322 Page::kPageSize)); |
5315 | 5323 |
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6601 isolate_->heap()->store_buffer()->Compact(); | 6609 isolate_->heap()->store_buffer()->Compact(); |
6602 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); | 6610 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); |
6603 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { | 6611 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { |
6604 next = chunk->next_chunk(); | 6612 next = chunk->next_chunk(); |
6605 isolate_->memory_allocator()->Free(chunk); | 6613 isolate_->memory_allocator()->Free(chunk); |
6606 } | 6614 } |
6607 chunks_queued_for_free_ = NULL; | 6615 chunks_queued_for_free_ = NULL; |
6608 } | 6616 } |
6609 | 6617 |
6610 } } // namespace v8::internal | 6618 } } // namespace v8::internal |
OLD | NEW |