| 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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 // The optimizing compiler may be unnecessarily holding on to memory. | 732 // The optimizing compiler may be unnecessarily holding on to memory. |
| 733 DisallowHeapAllocation no_recursive_gc; | 733 DisallowHeapAllocation no_recursive_gc; |
| 734 isolate()->optimizing_compiler_thread()->Flush(); | 734 isolate()->optimizing_compiler_thread()->Flush(); |
| 735 } | 735 } |
| 736 mark_compact_collector()->SetFlags(kMakeHeapIterableMask | | 736 mark_compact_collector()->SetFlags(kMakeHeapIterableMask | |
| 737 kReduceMemoryFootprintMask); | 737 kReduceMemoryFootprintMask); |
| 738 isolate_->compilation_cache()->Clear(); | 738 isolate_->compilation_cache()->Clear(); |
| 739 const int kMaxNumberOfAttempts = 7; | 739 const int kMaxNumberOfAttempts = 7; |
| 740 const int kMinNumberOfAttempts = 2; | 740 const int kMinNumberOfAttempts = 2; |
| 741 for (int attempt = 0; attempt < kMaxNumberOfAttempts; attempt++) { | 741 for (int attempt = 0; attempt < kMaxNumberOfAttempts; attempt++) { |
| 742 if (!CollectGarbage(OLD_POINTER_SPACE, MARK_COMPACTOR, gc_reason, NULL) && | 742 if (!CollectGarbage(MARK_COMPACTOR, gc_reason, NULL) && |
| 743 attempt + 1 >= kMinNumberOfAttempts) { | 743 attempt + 1 >= kMinNumberOfAttempts) { |
| 744 break; | 744 break; |
| 745 } | 745 } |
| 746 } | 746 } |
| 747 mark_compact_collector()->SetFlags(kNoGCFlags); | 747 mark_compact_collector()->SetFlags(kNoGCFlags); |
| 748 new_space_.Shrink(); | 748 new_space_.Shrink(); |
| 749 UncommitFromSpace(); | 749 UncommitFromSpace(); |
| 750 incremental_marking()->UncommitMarkingDeque(); | 750 incremental_marking()->UncommitMarkingDeque(); |
| 751 } | 751 } |
| 752 | 752 |
| 753 | 753 |
| 754 bool Heap::CollectGarbage(AllocationSpace space, | 754 bool Heap::CollectGarbage(GarbageCollector collector, |
| 755 GarbageCollector collector, | |
| 756 const char* gc_reason, | 755 const char* gc_reason, |
| 757 const char* collector_reason, | 756 const char* collector_reason, |
| 758 const v8::GCCallbackFlags gc_callback_flags) { | 757 const v8::GCCallbackFlags gc_callback_flags) { |
| 759 // The VM is in the GC state until exiting this function. | 758 // The VM is in the GC state until exiting this function. |
| 760 VMState<GC> state(isolate_); | 759 VMState<GC> state(isolate_); |
| 761 | 760 |
| 762 #ifdef DEBUG | 761 #ifdef DEBUG |
| 763 // Reset the allocation timeout to the GC interval, but make sure to | 762 // Reset the allocation timeout to the GC interval, but make sure to |
| 764 // allow at least a few allocations after a collection. The reason | 763 // allow at least a few allocations after a collection. The reason |
| 765 // for this is that we have a lot of allocation sequences and we | 764 // for this is that we have a lot of allocation sequences and we |
| (...skipping 6900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7666 static_cast<int>(object_sizes_last_time_[index])); | 7665 static_cast<int>(object_sizes_last_time_[index])); |
| 7667 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7666 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7668 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7667 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7669 | 7668 |
| 7670 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7669 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7671 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7670 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7672 ClearObjectStats(); | 7671 ClearObjectStats(); |
| 7673 } | 7672 } |
| 7674 | 7673 |
| 7675 } } // namespace v8::internal | 7674 } } // namespace v8::internal |
| OLD | NEW |