| 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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 return next_gc_likely_to_collect_more; | 728 return next_gc_likely_to_collect_more; |
| 729 } | 729 } |
| 730 | 730 |
| 731 | 731 |
| 732 int Heap::NotifyContextDisposed() { | 732 int Heap::NotifyContextDisposed() { |
| 733 if (FLAG_concurrent_recompilation) { | 733 if (FLAG_concurrent_recompilation) { |
| 734 // Flush the queued recompilation tasks. | 734 // Flush the queued recompilation tasks. |
| 735 isolate()->optimizing_compiler_thread()->Flush(); | 735 isolate()->optimizing_compiler_thread()->Flush(); |
| 736 } | 736 } |
| 737 flush_monomorphic_ics_ = true; | 737 flush_monomorphic_ics_ = true; |
| 738 AgeInlineCaches(); |
| 738 return ++contexts_disposed_; | 739 return ++contexts_disposed_; |
| 739 } | 740 } |
| 740 | 741 |
| 741 | 742 |
| 742 void Heap::PerformScavenge() { | 743 void Heap::PerformScavenge() { |
| 743 GCTracer tracer(this, NULL, NULL); | 744 GCTracer tracer(this, NULL, NULL); |
| 744 if (incremental_marking()->IsStopped()) { | 745 if (incremental_marking()->IsStopped()) { |
| 745 PerformGarbageCollection(SCAVENGER, &tracer); | 746 PerformGarbageCollection(SCAVENGER, &tracer); |
| 746 } else { | 747 } else { |
| 747 PerformGarbageCollection(MARK_COMPACTOR, &tracer); | 748 PerformGarbageCollection(MARK_COMPACTOR, &tracer); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 MarkCompactPrologue(); | 1126 MarkCompactPrologue(); |
| 1126 | 1127 |
| 1127 mark_compact_collector_.CollectGarbage(); | 1128 mark_compact_collector_.CollectGarbage(); |
| 1128 | 1129 |
| 1129 LOG(isolate_, ResourceEvent("markcompact", "end")); | 1130 LOG(isolate_, ResourceEvent("markcompact", "end")); |
| 1130 | 1131 |
| 1131 gc_state_ = NOT_IN_GC; | 1132 gc_state_ = NOT_IN_GC; |
| 1132 | 1133 |
| 1133 isolate_->counters()->objs_since_last_full()->Set(0); | 1134 isolate_->counters()->objs_since_last_full()->Set(0); |
| 1134 | 1135 |
| 1135 contexts_disposed_ = 0; | |
| 1136 | |
| 1137 flush_monomorphic_ics_ = false; | 1136 flush_monomorphic_ics_ = false; |
| 1138 } | 1137 } |
| 1139 | 1138 |
| 1140 | 1139 |
| 1141 void Heap::MarkCompactPrologue() { | 1140 void Heap::MarkCompactPrologue() { |
| 1142 // At any old GC clear the keyed lookup cache to enable collection of unused | 1141 // At any old GC clear the keyed lookup cache to enable collection of unused |
| 1143 // maps. | 1142 // maps. |
| 1144 isolate_->keyed_lookup_cache()->Clear(); | 1143 isolate_->keyed_lookup_cache()->Clear(); |
| 1145 isolate_->context_slot_cache()->Clear(); | 1144 isolate_->context_slot_cache()->Clear(); |
| 1146 isolate_->descriptor_lookup_cache()->Clear(); | 1145 isolate_->descriptor_lookup_cache()->Clear(); |
| (...skipping 2926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4073 buffer[0] = static_cast<uint8_t>(code); | 4072 buffer[0] = static_cast<uint8_t>(code); |
| 4074 Object* result; | 4073 Object* result; |
| 4075 MaybeObject* maybe_result = | 4074 MaybeObject* maybe_result = |
| 4076 InternalizeOneByteString(Vector<const uint8_t>(buffer, 1)); | 4075 InternalizeOneByteString(Vector<const uint8_t>(buffer, 1)); |
| 4077 | 4076 |
| 4078 if (!maybe_result->ToObject(&result)) return maybe_result; | 4077 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 4079 single_character_string_cache()->set(code, result); | 4078 single_character_string_cache()->set(code, result); |
| 4080 return result; | 4079 return result; |
| 4081 } | 4080 } |
| 4082 | 4081 |
| 4083 Object* result; | 4082 SeqTwoByteString* result; |
| 4084 { MaybeObject* maybe_result = AllocateRawTwoByteString(1); | 4083 { MaybeObject* maybe_result = AllocateRawTwoByteString(1); |
| 4085 if (!maybe_result->ToObject(&result)) return maybe_result; | 4084 if (!maybe_result->To<SeqTwoByteString>(&result)) return maybe_result; |
| 4086 } | 4085 } |
| 4087 String* answer = String::cast(result); | 4086 result->SeqTwoByteStringSet(0, code); |
| 4088 answer->Set(0, code); | 4087 return result; |
| 4089 return answer; | |
| 4090 } | 4088 } |
| 4091 | 4089 |
| 4092 | 4090 |
| 4093 MaybeObject* Heap::AllocateByteArray(int length, PretenureFlag pretenure) { | 4091 MaybeObject* Heap::AllocateByteArray(int length, PretenureFlag pretenure) { |
| 4094 if (length < 0 || length > ByteArray::kMaxLength) { | 4092 if (length < 0 || length > ByteArray::kMaxLength) { |
| 4095 return Failure::OutOfMemoryException(0x7); | 4093 return Failure::OutOfMemoryException(0x7); |
| 4096 } | 4094 } |
| 4097 int size = ByteArray::SizeFor(length); | 4095 int size = ByteArray::SizeFor(length); |
| 4098 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | 4096 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 4099 Object* result; | 4097 Object* result; |
| (...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5811 // Minimal hint that allows to do full GC. | 5809 // Minimal hint that allows to do full GC. |
| 5812 const int kMinHintForFullGC = 100; | 5810 const int kMinHintForFullGC = 100; |
| 5813 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; | 5811 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; |
| 5814 // The size factor is in range [5..250]. The numbers here are chosen from | 5812 // The size factor is in range [5..250]. The numbers here are chosen from |
| 5815 // experiments. If you changes them, make sure to test with | 5813 // experiments. If you changes them, make sure to test with |
| 5816 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* | 5814 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* |
| 5817 intptr_t step_size = | 5815 intptr_t step_size = |
| 5818 size_factor * IncrementalMarking::kAllocatedThreshold; | 5816 size_factor * IncrementalMarking::kAllocatedThreshold; |
| 5819 | 5817 |
| 5820 if (contexts_disposed_ > 0) { | 5818 if (contexts_disposed_ > 0) { |
| 5821 if (hint >= kMaxHint) { | 5819 contexts_disposed_ = 0; |
| 5822 // The embedder is requesting a lot of GC work after context disposal, | |
| 5823 // we age inline caches so that they don't keep objects from | |
| 5824 // the old context alive. | |
| 5825 AgeInlineCaches(); | |
| 5826 } | |
| 5827 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000); | 5820 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000); |
| 5828 if (hint >= mark_sweep_time && !FLAG_expose_gc && | 5821 if (hint >= mark_sweep_time && !FLAG_expose_gc && |
| 5829 incremental_marking()->IsStopped()) { | 5822 incremental_marking()->IsStopped()) { |
| 5830 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 5823 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
| 5831 CollectAllGarbage(kReduceMemoryFootprintMask, | 5824 CollectAllGarbage(kReduceMemoryFootprintMask, |
| 5832 "idle notification: contexts disposed"); | 5825 "idle notification: contexts disposed"); |
| 5833 } else { | 5826 } else { |
| 5834 AdvanceIdleIncrementalMarking(step_size); | 5827 AdvanceIdleIncrementalMarking(step_size); |
| 5835 contexts_disposed_ = 0; | |
| 5836 } | 5828 } |
| 5829 |
| 5837 // After context disposal there is likely a lot of garbage remaining, reset | 5830 // After context disposal there is likely a lot of garbage remaining, reset |
| 5838 // the idle notification counters in order to trigger more incremental GCs | 5831 // the idle notification counters in order to trigger more incremental GCs |
| 5839 // on subsequent idle notifications. | 5832 // on subsequent idle notifications. |
| 5840 StartIdleRound(); | 5833 StartIdleRound(); |
| 5841 return false; | 5834 return false; |
| 5842 } | 5835 } |
| 5843 | 5836 |
| 5844 if (!FLAG_incremental_marking || FLAG_expose_gc || Serializer::enabled()) { | 5837 if (!FLAG_incremental_marking || FLAG_expose_gc || Serializer::enabled()) { |
| 5845 return IdleGlobalGC(); | 5838 return IdleGlobalGC(); |
| 5846 } | 5839 } |
| (...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7967 if (FLAG_concurrent_recompilation) { | 7960 if (FLAG_concurrent_recompilation) { |
| 7968 heap_->relocation_mutex_->Lock(); | 7961 heap_->relocation_mutex_->Lock(); |
| 7969 #ifdef DEBUG | 7962 #ifdef DEBUG |
| 7970 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 7963 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
| 7971 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 7964 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
| 7972 #endif // DEBUG | 7965 #endif // DEBUG |
| 7973 } | 7966 } |
| 7974 } | 7967 } |
| 7975 | 7968 |
| 7976 } } // namespace v8::internal | 7969 } } // namespace v8::internal |
| OLD | NEW |