| 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 4820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4831 gc_count_at_last_idle_gc_ = gc_count_; | 4831 gc_count_at_last_idle_gc_ = gc_count_; |
| 4832 if (uncommit) { | 4832 if (uncommit) { |
| 4833 new_space_.Shrink(); | 4833 new_space_.Shrink(); |
| 4834 UncommitFromSpace(); | 4834 UncommitFromSpace(); |
| 4835 } | 4835 } |
| 4836 } | 4836 } |
| 4837 } | 4837 } |
| 4838 | 4838 |
| 4839 | 4839 |
| 4840 bool Heap::IdleNotification(int hint) { | 4840 bool Heap::IdleNotification(int hint) { |
| 4841 intptr_t size_factor = Min(Max(hint, 30), 1000) / 10; | 4841 const int kMaxHint = 1000; |
| 4842 intptr_t size_factor = Min(Max(hint, 30), kMaxHint) / 10; |
| 4842 // The size factor is in range [3..100]. | 4843 // The size factor is in range [3..100]. |
| 4843 intptr_t step_size = size_factor * IncrementalMarking::kAllocatedThreshold; | 4844 intptr_t step_size = size_factor * IncrementalMarking::kAllocatedThreshold; |
| 4844 | 4845 |
| 4845 if (contexts_disposed_ > 0) { | 4846 if (contexts_disposed_ > 0) { |
| 4846 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000); | 4847 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000); |
| 4847 if (hint >= mark_sweep_time && !FLAG_expose_gc) { | 4848 if (hint >= mark_sweep_time && !FLAG_expose_gc) { |
| 4848 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 4849 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
| 4849 CollectAllGarbage(kReduceMemoryFootprintMask, | 4850 if (hint >= kMaxHint) { |
| 4850 "idle notification: contexts disposed"); | 4851 // The embedder can tolerate long pauses, do precise GC. |
| 4852 CollectAllGarbage(kReduceMemoryFootprintMask | |
| 4853 kAbortIncrementalMarkingMask, |
| 4854 "idle notification: contexts disposed" |
| 4855 " (abort incremental marking)"); |
| 4856 } else { |
| 4857 CollectAllGarbage(kReduceMemoryFootprintMask, |
| 4858 "idle notification: contexts disposed"); |
| 4859 } |
| 4851 } else { | 4860 } else { |
| 4852 AdvanceIdleIncrementalMarking(step_size); | 4861 AdvanceIdleIncrementalMarking(step_size); |
| 4853 contexts_disposed_ = 0; | 4862 contexts_disposed_ = 0; |
| 4854 } | 4863 } |
| 4855 // Make sure that we have no pending context disposals. | 4864 // Make sure that we have no pending context disposals. |
| 4856 // Take into account that we might have decided to delay full collection | 4865 // Take into account that we might have decided to delay full collection |
| 4857 // because incremental marking is in progress. | 4866 // because incremental marking is in progress. |
| 4858 ASSERT((contexts_disposed_ == 0) || !incremental_marking()->IsStopped()); | 4867 ASSERT((contexts_disposed_ == 0) || !incremental_marking()->IsStopped()); |
| 4859 return false; | 4868 return false; |
| 4860 } | 4869 } |
| 4861 | 4870 |
| 4862 if (hint >= 1000 || !FLAG_incremental_marking || | 4871 if (hint >= kMaxHint || !FLAG_incremental_marking || |
| 4863 FLAG_expose_gc || Serializer::enabled()) { | 4872 FLAG_expose_gc || Serializer::enabled()) { |
| 4864 return IdleGlobalGC(); | 4873 return IdleGlobalGC(); |
| 4865 } | 4874 } |
| 4866 | 4875 |
| 4867 // By doing small chunks of GC work in each IdleNotification, | 4876 // By doing small chunks of GC work in each IdleNotification, |
| 4868 // perform a round of incremental GCs and after that wait until | 4877 // perform a round of incremental GCs and after that wait until |
| 4869 // the mutator creates enough garbage to justify a new round. | 4878 // the mutator creates enough garbage to justify a new round. |
| 4870 // An incremental GC progresses as follows: | 4879 // An incremental GC progresses as follows: |
| 4871 // 1. many incremental marking steps, | 4880 // 1. many incremental marking steps, |
| 4872 // 2. one old space mark-sweep-compact, | 4881 // 2. one old space mark-sweep-compact, |
| (...skipping 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6967 } else { | 6976 } else { |
| 6968 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. | 6977 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. |
| 6969 } | 6978 } |
| 6970 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = | 6979 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = |
| 6971 reinterpret_cast<Address>(p); | 6980 reinterpret_cast<Address>(p); |
| 6972 remembered_unmapped_pages_index_++; | 6981 remembered_unmapped_pages_index_++; |
| 6973 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages; | 6982 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages; |
| 6974 } | 6983 } |
| 6975 | 6984 |
| 6976 } } // namespace v8::internal | 6985 } } // namespace v8::internal |
| OLD | NEW |