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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 old_gen_promotion_limit_(kMinimumPromotionLimit), | 121 old_gen_promotion_limit_(kMinimumPromotionLimit), |
122 old_gen_allocation_limit_(kMinimumAllocationLimit), | 122 old_gen_allocation_limit_(kMinimumAllocationLimit), |
123 old_gen_limit_factor_(1), | 123 old_gen_limit_factor_(1), |
124 size_of_old_gen_at_last_old_space_gc_(0), | 124 size_of_old_gen_at_last_old_space_gc_(0), |
125 external_allocation_limit_(0), | 125 external_allocation_limit_(0), |
126 amount_of_external_allocated_memory_(0), | 126 amount_of_external_allocated_memory_(0), |
127 amount_of_external_allocated_memory_at_last_global_gc_(0), | 127 amount_of_external_allocated_memory_at_last_global_gc_(0), |
128 old_gen_exhausted_(false), | 128 old_gen_exhausted_(false), |
129 store_buffer_rebuilder_(store_buffer()), | 129 store_buffer_rebuilder_(store_buffer()), |
130 hidden_symbol_(NULL), | 130 hidden_symbol_(NULL), |
131 global_gc_prologue_callback_(NULL), | |
132 global_gc_epilogue_callback_(NULL), | |
133 gc_safe_size_of_old_object_(NULL), | 131 gc_safe_size_of_old_object_(NULL), |
134 total_regexp_code_generated_(0), | 132 total_regexp_code_generated_(0), |
135 tracer_(NULL), | 133 tracer_(NULL), |
136 young_survivors_after_last_gc_(0), | 134 young_survivors_after_last_gc_(0), |
137 high_survival_rate_period_length_(0), | 135 high_survival_rate_period_length_(0), |
138 low_survival_rate_period_length_(0), | 136 low_survival_rate_period_length_(0), |
139 survival_rate_(0), | 137 survival_rate_(0), |
140 previous_survival_rate_trend_(Heap::STABLE), | 138 previous_survival_rate_trend_(Heap::STABLE), |
141 survival_rate_trend_(Heap::STABLE), | 139 survival_rate_trend_(Heap::STABLE), |
142 max_gc_pause_(0), | 140 max_gc_pause_(0), |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 if (collector != SCAVENGER) { | 873 if (collector != SCAVENGER) { |
876 PROFILE(isolate_, CodeMovingGCEvent()); | 874 PROFILE(isolate_, CodeMovingGCEvent()); |
877 } | 875 } |
878 | 876 |
879 #ifdef VERIFY_HEAP | 877 #ifdef VERIFY_HEAP |
880 if (FLAG_verify_heap) { | 878 if (FLAG_verify_heap) { |
881 VerifySymbolTable(); | 879 VerifySymbolTable(); |
882 } | 880 } |
883 #endif | 881 #endif |
884 | 882 |
885 if (collector == MARK_COMPACTOR && global_gc_prologue_callback_) { | |
886 ASSERT(!allocation_allowed_); | |
887 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); | |
888 VMState state(isolate_, EXTERNAL); | |
889 global_gc_prologue_callback_(); | |
890 } | |
891 | |
892 GCType gc_type = | 883 GCType gc_type = |
893 collector == MARK_COMPACTOR ? kGCTypeMarkSweepCompact : kGCTypeScavenge; | 884 collector == MARK_COMPACTOR ? kGCTypeMarkSweepCompact : kGCTypeScavenge; |
894 | 885 |
895 { | 886 { |
896 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); | 887 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); |
897 VMState state(isolate_, EXTERNAL); | 888 VMState state(isolate_, EXTERNAL); |
898 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { | 889 CallGCPrologueCallbacks(gc_type); |
899 if (gc_type & gc_prologue_callbacks_[i].gc_type) { | |
900 gc_prologue_callbacks_[i].callback(gc_type, kNoGCCallbackFlags); | |
901 } | |
902 } | |
903 } | 890 } |
904 | 891 |
905 EnsureFromSpaceIsCommitted(); | 892 EnsureFromSpaceIsCommitted(); |
906 | 893 |
907 int start_new_space_size = Heap::new_space()->SizeAsInt(); | 894 int start_new_space_size = Heap::new_space()->SizeAsInt(); |
908 | 895 |
909 if (IsHighSurvivalRate()) { | 896 if (IsHighSurvivalRate()) { |
910 // We speed up the incremental marker if it is running so that it | 897 // We speed up the incremental marker if it is running so that it |
911 // does not fall behind the rate of promotion, which would cause a | 898 // does not fall behind the rate of promotion, which would cause a |
912 // constantly growing old space. | 899 // constantly growing old space. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 | 989 |
1003 if (collector == MARK_COMPACTOR) { | 990 if (collector == MARK_COMPACTOR) { |
1004 // Register the amount of external allocated memory. | 991 // Register the amount of external allocated memory. |
1005 amount_of_external_allocated_memory_at_last_global_gc_ = | 992 amount_of_external_allocated_memory_at_last_global_gc_ = |
1006 amount_of_external_allocated_memory_; | 993 amount_of_external_allocated_memory_; |
1007 } | 994 } |
1008 | 995 |
1009 { | 996 { |
1010 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); | 997 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); |
1011 VMState state(isolate_, EXTERNAL); | 998 VMState state(isolate_, EXTERNAL); |
1012 GCCallbackFlags callback_flags = kNoGCCallbackFlags; | 999 CallGCEpilogueCallbacks(gc_type); |
1013 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { | |
1014 if (gc_type & gc_epilogue_callbacks_[i].gc_type) { | |
1015 gc_epilogue_callbacks_[i].callback(gc_type, callback_flags); | |
1016 } | |
1017 } | |
1018 } | |
1019 | |
1020 if (collector == MARK_COMPACTOR && global_gc_epilogue_callback_) { | |
1021 ASSERT(!allocation_allowed_); | |
1022 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); | |
1023 VMState state(isolate_, EXTERNAL); | |
1024 global_gc_epilogue_callback_(); | |
1025 } | 1000 } |
1026 | 1001 |
1027 #ifdef VERIFY_HEAP | 1002 #ifdef VERIFY_HEAP |
1028 if (FLAG_verify_heap) { | 1003 if (FLAG_verify_heap) { |
1029 VerifySymbolTable(); | 1004 VerifySymbolTable(); |
1030 } | 1005 } |
1031 #endif | 1006 #endif |
1032 | 1007 |
1033 return next_gc_likely_to_collect_more; | 1008 return next_gc_likely_to_collect_more; |
1034 } | 1009 } |
1035 | 1010 |
1036 | 1011 |
| 1012 void Heap::CallGCPrologueCallbacks(GCType gc_type) { |
| 1013 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { |
| 1014 if (gc_type & gc_prologue_callbacks_[i].gc_type) { |
| 1015 gc_prologue_callbacks_[i].callback(gc_type, kNoGCCallbackFlags); |
| 1016 } |
| 1017 } |
| 1018 } |
| 1019 |
| 1020 |
| 1021 void Heap::CallGCEpilogueCallbacks(GCType gc_type) { |
| 1022 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { |
| 1023 if (gc_type & gc_epilogue_callbacks_[i].gc_type) { |
| 1024 gc_epilogue_callbacks_[i].callback(gc_type, kNoGCCallbackFlags); |
| 1025 } |
| 1026 } |
| 1027 } |
| 1028 |
| 1029 |
1037 void Heap::MarkCompact(GCTracer* tracer) { | 1030 void Heap::MarkCompact(GCTracer* tracer) { |
1038 gc_state_ = MARK_COMPACT; | 1031 gc_state_ = MARK_COMPACT; |
1039 LOG(isolate_, ResourceEvent("markcompact", "begin")); | 1032 LOG(isolate_, ResourceEvent("markcompact", "begin")); |
1040 | 1033 |
1041 mark_compact_collector_.Prepare(tracer); | 1034 mark_compact_collector_.Prepare(tracer); |
1042 | 1035 |
1043 ms_count_++; | 1036 ms_count_++; |
1044 tracer->set_full_gc_count(ms_count_); | 1037 tracer->set_full_gc_count(ms_count_); |
1045 | 1038 |
1046 MarkCompactPrologue(); | 1039 MarkCompactPrologue(); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 // Scavenge object reachable from the native contexts list directly. | 1362 // Scavenge object reachable from the native contexts list directly. |
1370 scavenge_visitor.VisitPointer(BitCast<Object**>(&native_contexts_list_)); | 1363 scavenge_visitor.VisitPointer(BitCast<Object**>(&native_contexts_list_)); |
1371 | 1364 |
1372 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1365 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
1373 | 1366 |
1374 while (isolate()->global_handles()->IterateObjectGroups( | 1367 while (isolate()->global_handles()->IterateObjectGroups( |
1375 &scavenge_visitor, &IsUnscavengedHeapObject)) { | 1368 &scavenge_visitor, &IsUnscavengedHeapObject)) { |
1376 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1369 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
1377 } | 1370 } |
1378 isolate()->global_handles()->RemoveObjectGroups(); | 1371 isolate()->global_handles()->RemoveObjectGroups(); |
| 1372 isolate()->global_handles()->RemoveImplicitRefGroups(); |
1379 | 1373 |
1380 isolate_->global_handles()->IdentifyNewSpaceWeakIndependentHandles( | 1374 isolate_->global_handles()->IdentifyNewSpaceWeakIndependentHandles( |
1381 &IsUnscavengedHeapObject); | 1375 &IsUnscavengedHeapObject); |
1382 isolate_->global_handles()->IterateNewSpaceWeakIndependentRoots( | 1376 isolate_->global_handles()->IterateNewSpaceWeakIndependentRoots( |
1383 &scavenge_visitor); | 1377 &scavenge_visitor); |
1384 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1378 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
1385 | 1379 |
1386 UpdateNewSpaceReferencesInExternalStringTable( | 1380 UpdateNewSpaceReferencesInExternalStringTable( |
1387 &UpdateNewSpaceReferenceInExternalStringTableEntry); | 1381 &UpdateNewSpaceReferenceInExternalStringTableEntry); |
1388 | 1382 |
(...skipping 6119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7508 static_cast<int>(object_sizes_last_time_[index])); | 7502 static_cast<int>(object_sizes_last_time_[index])); |
7509 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7503 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7510 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7504 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7511 | 7505 |
7512 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7506 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7513 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7507 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7514 ClearObjectStats(); | 7508 ClearObjectStats(); |
7515 } | 7509 } |
7516 | 7510 |
7517 } } // namespace v8::internal | 7511 } } // namespace v8::internal |
OLD | NEW |