| 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 return next_gc_likely_to_collect_more; | 704 return next_gc_likely_to_collect_more; |
| 705 } | 705 } |
| 706 | 706 |
| 707 | 707 |
| 708 int Heap::NotifyContextDisposed() { | 708 int Heap::NotifyContextDisposed() { |
| 709 if (FLAG_concurrent_recompilation) { | 709 if (FLAG_concurrent_recompilation) { |
| 710 // Flush the queued recompilation tasks. | 710 // Flush the queued recompilation tasks. |
| 711 isolate()->optimizing_compiler_thread()->Flush(); | 711 isolate()->optimizing_compiler_thread()->Flush(); |
| 712 } | 712 } |
| 713 flush_monomorphic_ics_ = true; | 713 flush_monomorphic_ics_ = true; |
| 714 AgeInlineCaches(); |
| 714 return ++contexts_disposed_; | 715 return ++contexts_disposed_; |
| 715 } | 716 } |
| 716 | 717 |
| 717 | 718 |
| 718 void Heap::PerformScavenge() { | 719 void Heap::PerformScavenge() { |
| 719 GCTracer tracer(this, NULL, NULL); | 720 GCTracer tracer(this, NULL, NULL); |
| 720 if (incremental_marking()->IsStopped()) { | 721 if (incremental_marking()->IsStopped()) { |
| 721 PerformGarbageCollection(SCAVENGER, &tracer); | 722 PerformGarbageCollection(SCAVENGER, &tracer); |
| 722 } else { | 723 } else { |
| 723 PerformGarbageCollection(MARK_COMPACTOR, &tracer); | 724 PerformGarbageCollection(MARK_COMPACTOR, &tracer); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 MarkCompactPrologue(); | 1091 MarkCompactPrologue(); |
| 1091 | 1092 |
| 1092 mark_compact_collector_.CollectGarbage(); | 1093 mark_compact_collector_.CollectGarbage(); |
| 1093 | 1094 |
| 1094 LOG(isolate_, ResourceEvent("markcompact", "end")); | 1095 LOG(isolate_, ResourceEvent("markcompact", "end")); |
| 1095 | 1096 |
| 1096 gc_state_ = NOT_IN_GC; | 1097 gc_state_ = NOT_IN_GC; |
| 1097 | 1098 |
| 1098 isolate_->counters()->objs_since_last_full()->Set(0); | 1099 isolate_->counters()->objs_since_last_full()->Set(0); |
| 1099 | 1100 |
| 1100 contexts_disposed_ = 0; | |
| 1101 | |
| 1102 flush_monomorphic_ics_ = false; | 1101 flush_monomorphic_ics_ = false; |
| 1103 } | 1102 } |
| 1104 | 1103 |
| 1105 | 1104 |
| 1106 void Heap::MarkCompactPrologue() { | 1105 void Heap::MarkCompactPrologue() { |
| 1107 // At any old GC clear the keyed lookup cache to enable collection of unused | 1106 // At any old GC clear the keyed lookup cache to enable collection of unused |
| 1108 // maps. | 1107 // maps. |
| 1109 isolate_->keyed_lookup_cache()->Clear(); | 1108 isolate_->keyed_lookup_cache()->Clear(); |
| 1110 isolate_->context_slot_cache()->Clear(); | 1109 isolate_->context_slot_cache()->Clear(); |
| 1111 isolate_->descriptor_lookup_cache()->Clear(); | 1110 isolate_->descriptor_lookup_cache()->Clear(); |
| (...skipping 4881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5993 // Minimal hint that allows to do full GC. | 5992 // Minimal hint that allows to do full GC. |
| 5994 const int kMinHintForFullGC = 100; | 5993 const int kMinHintForFullGC = 100; |
| 5995 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; | 5994 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; |
| 5996 // The size factor is in range [5..250]. The numbers here are chosen from | 5995 // The size factor is in range [5..250]. The numbers here are chosen from |
| 5997 // experiments. If you changes them, make sure to test with | 5996 // experiments. If you changes them, make sure to test with |
| 5998 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* | 5997 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* |
| 5999 intptr_t step_size = | 5998 intptr_t step_size = |
| 6000 size_factor * IncrementalMarking::kAllocatedThreshold; | 5999 size_factor * IncrementalMarking::kAllocatedThreshold; |
| 6001 | 6000 |
| 6002 if (contexts_disposed_ > 0) { | 6001 if (contexts_disposed_ > 0) { |
| 6003 if (hint >= kMaxHint) { | 6002 contexts_disposed_ = 0; |
| 6004 // The embedder is requesting a lot of GC work after context disposal, | |
| 6005 // we age inline caches so that they don't keep objects from | |
| 6006 // the old context alive. | |
| 6007 AgeInlineCaches(); | |
| 6008 } | |
| 6009 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000); | 6003 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000); |
| 6010 if (hint >= mark_sweep_time && !FLAG_expose_gc && | 6004 if (hint >= mark_sweep_time && !FLAG_expose_gc && |
| 6011 incremental_marking()->IsStopped()) { | 6005 incremental_marking()->IsStopped()) { |
| 6012 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 6006 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
| 6013 CollectAllGarbage(kReduceMemoryFootprintMask, | 6007 CollectAllGarbage(kReduceMemoryFootprintMask, |
| 6014 "idle notification: contexts disposed"); | 6008 "idle notification: contexts disposed"); |
| 6015 } else { | 6009 } else { |
| 6016 AdvanceIdleIncrementalMarking(step_size); | 6010 AdvanceIdleIncrementalMarking(step_size); |
| 6017 contexts_disposed_ = 0; | |
| 6018 } | 6011 } |
| 6012 |
| 6019 // After context disposal there is likely a lot of garbage remaining, reset | 6013 // After context disposal there is likely a lot of garbage remaining, reset |
| 6020 // the idle notification counters in order to trigger more incremental GCs | 6014 // the idle notification counters in order to trigger more incremental GCs |
| 6021 // on subsequent idle notifications. | 6015 // on subsequent idle notifications. |
| 6022 StartIdleRound(); | 6016 StartIdleRound(); |
| 6023 return false; | 6017 return false; |
| 6024 } | 6018 } |
| 6025 | 6019 |
| 6026 if (!FLAG_incremental_marking || FLAG_expose_gc || Serializer::enabled()) { | 6020 if (!FLAG_incremental_marking || FLAG_expose_gc || Serializer::enabled()) { |
| 6027 return IdleGlobalGC(); | 6021 return IdleGlobalGC(); |
| 6028 } | 6022 } |
| (...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8101 if (FLAG_concurrent_recompilation) { | 8095 if (FLAG_concurrent_recompilation) { |
| 8102 heap_->relocation_mutex_->Lock(); | 8096 heap_->relocation_mutex_->Lock(); |
| 8103 #ifdef DEBUG | 8097 #ifdef DEBUG |
| 8104 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 8098 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
| 8105 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 8099 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
| 8106 #endif // DEBUG | 8100 #endif // DEBUG |
| 8107 } | 8101 } |
| 8108 } | 8102 } |
| 8109 | 8103 |
| 8110 } } // namespace v8::internal | 8104 } } // namespace v8::internal |
| OLD | NEW |