| 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 COMPACT_FREE_LISTS, | 624 COMPACT_FREE_LISTS, |
| 625 REDUCE_MEMORY_FOOTPRINT | 625 REDUCE_MEMORY_FOOTPRINT |
| 626 }; | 626 }; |
| 627 | 627 |
| 628 CompactionMode mode = COMPACT_FREE_LISTS; | 628 CompactionMode mode = COMPACT_FREE_LISTS; |
| 629 | 629 |
| 630 intptr_t reserved = number_of_pages * space->AreaSize(); | 630 intptr_t reserved = number_of_pages * space->AreaSize(); |
| 631 intptr_t over_reserved = reserved - space->SizeOfObjects(); | 631 intptr_t over_reserved = reserved - space->SizeOfObjects(); |
| 632 static const intptr_t kFreenessThreshold = 50; | 632 static const intptr_t kFreenessThreshold = 50; |
| 633 | 633 |
| 634 if (over_reserved >= 2 * space->AreaSize()) { | 634 //if (over_reserved >= 2 * space->AreaSize() || |
| 635 //(reduce_memory_footprint_ && over_reserved >= space->AreaSize())) { |
| 636 if (reduce_memory_footprint_ && over_reserved >= space->AreaSize()) { |
| 635 // If reduction of memory footprint was requested, we are aggressive | 637 // If reduction of memory footprint was requested, we are aggressive |
| 636 // about choosing pages to free. We expect that half-empty pages | 638 // about choosing pages to free. We expect that half-empty pages |
| 637 // are easier to compact so slightly bump the limit. | 639 // are easier to compact so slightly bump the limit. |
| 638 if (reduce_memory_footprint_) { | 640 mode = REDUCE_MEMORY_FOOTPRINT; |
| 639 mode = REDUCE_MEMORY_FOOTPRINT; | 641 max_evacuation_candidates += 2; |
| 640 max_evacuation_candidates += 2; | 642 } |
| 641 } | |
| 642 | 643 |
| 644 |
| 645 if (over_reserved > reserved / 3 && over_reserved >= 2 * space->AreaSize()) { |
| 643 // If over-usage is very high (more than a third of the space), we | 646 // If over-usage is very high (more than a third of the space), we |
| 644 // try to free all mostly empty pages. We expect that almost empty | 647 // try to free all mostly empty pages. We expect that almost empty |
| 645 // pages are even easier to compact so bump the limit even more. | 648 // pages are even easier to compact so bump the limit even more. |
| 646 if (over_reserved > reserved / 3) { | 649 if (over_reserved > reserved / 3) { |
| 647 mode = REDUCE_MEMORY_FOOTPRINT; | 650 mode = REDUCE_MEMORY_FOOTPRINT; |
| 648 max_evacuation_candidates *= 2; | 651 max_evacuation_candidates *= 2; |
| 649 } | 652 } |
| 653 } |
| 650 | 654 |
| 651 if (FLAG_trace_fragmentation && mode == REDUCE_MEMORY_FOOTPRINT) { | 655 if (FLAG_trace_fragmentation && mode == REDUCE_MEMORY_FOOTPRINT) { |
| 652 PrintF("Estimated over reserved memory: %.1f / %.1f MB (threshold %d)\n", | 656 PrintF("Estimated over reserved memory: %.1f / %.1f MB (threshold %d)\n", |
| 653 static_cast<double>(over_reserved) / MB, | 657 static_cast<double>(over_reserved) / MB, |
| 654 static_cast<double>(reserved) / MB, | 658 static_cast<double>(reserved) / MB, |
| 655 static_cast<int>(kFreenessThreshold)); | 659 static_cast<int>(kFreenessThreshold)); |
| 656 } | |
| 657 } | 660 } |
| 658 | 661 |
| 659 intptr_t estimated_release = 0; | 662 intptr_t estimated_release = 0; |
| 660 | 663 |
| 661 Candidate candidates[kMaxMaxEvacuationCandidates]; | 664 Candidate candidates[kMaxMaxEvacuationCandidates]; |
| 662 | 665 |
| 663 max_evacuation_candidates = | 666 max_evacuation_candidates = |
| 664 Min(kMaxMaxEvacuationCandidates, max_evacuation_candidates); | 667 Min(kMaxMaxEvacuationCandidates, max_evacuation_candidates); |
| 665 | 668 |
| 666 int count = 0; | 669 int count = 0; |
| (...skipping 3540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4207 while (buffer != NULL) { | 4210 while (buffer != NULL) { |
| 4208 SlotsBuffer* next_buffer = buffer->next(); | 4211 SlotsBuffer* next_buffer = buffer->next(); |
| 4209 DeallocateBuffer(buffer); | 4212 DeallocateBuffer(buffer); |
| 4210 buffer = next_buffer; | 4213 buffer = next_buffer; |
| 4211 } | 4214 } |
| 4212 *buffer_address = NULL; | 4215 *buffer_address = NULL; |
| 4213 } | 4216 } |
| 4214 | 4217 |
| 4215 | 4218 |
| 4216 } } // namespace v8::internal | 4219 } } // namespace v8::internal |
| OLD | NEW |