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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 #endif // DEBUG | 122 #endif // DEBUG |
123 new_space_high_promotion_mode_active_(false), | 123 new_space_high_promotion_mode_active_(false), |
124 old_generation_allocation_limit_(kMinimumOldGenerationAllocationLimit), | 124 old_generation_allocation_limit_(kMinimumOldGenerationAllocationLimit), |
125 size_of_old_gen_at_last_old_space_gc_(0), | 125 size_of_old_gen_at_last_old_space_gc_(0), |
126 external_allocation_limit_(0), | 126 external_allocation_limit_(0), |
127 amount_of_external_allocated_memory_(0), | 127 amount_of_external_allocated_memory_(0), |
128 amount_of_external_allocated_memory_at_last_global_gc_(0), | 128 amount_of_external_allocated_memory_at_last_global_gc_(0), |
129 old_gen_exhausted_(false), | 129 old_gen_exhausted_(false), |
130 store_buffer_rebuilder_(store_buffer()), | 130 store_buffer_rebuilder_(store_buffer()), |
131 hidden_string_(NULL), | 131 hidden_string_(NULL), |
132 global_gc_prologue_callback_(NULL), | |
133 global_gc_epilogue_callback_(NULL), | |
134 gc_safe_size_of_old_object_(NULL), | 132 gc_safe_size_of_old_object_(NULL), |
135 total_regexp_code_generated_(0), | 133 total_regexp_code_generated_(0), |
136 tracer_(NULL), | 134 tracer_(NULL), |
137 young_survivors_after_last_gc_(0), | 135 young_survivors_after_last_gc_(0), |
138 high_survival_rate_period_length_(0), | 136 high_survival_rate_period_length_(0), |
139 low_survival_rate_period_length_(0), | 137 low_survival_rate_period_length_(0), |
140 survival_rate_(0), | 138 survival_rate_(0), |
141 previous_survival_rate_trend_(Heap::STABLE), | 139 previous_survival_rate_trend_(Heap::STABLE), |
142 survival_rate_trend_(Heap::STABLE), | 140 survival_rate_trend_(Heap::STABLE), |
143 max_gc_pause_(0.0), | 141 max_gc_pause_(0.0), |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 if (FLAG_verify_heap) { | 1046 if (FLAG_verify_heap) { |
1049 VerifyStringTable(this); | 1047 VerifyStringTable(this); |
1050 } | 1048 } |
1051 #endif | 1049 #endif |
1052 | 1050 |
1053 return next_gc_likely_to_collect_more; | 1051 return next_gc_likely_to_collect_more; |
1054 } | 1052 } |
1055 | 1053 |
1056 | 1054 |
1057 void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) { | 1055 void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) { |
1058 if (gc_type == kGCTypeMarkSweepCompact && global_gc_prologue_callback_) { | |
1059 global_gc_prologue_callback_(); | |
1060 } | |
1061 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { | 1056 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { |
1062 if (gc_type & gc_prologue_callbacks_[i].gc_type) { | 1057 if (gc_type & gc_prologue_callbacks_[i].gc_type) { |
1063 gc_prologue_callbacks_[i].callback(gc_type, flags); | 1058 if (!gc_prologue_callbacks_[i].pass_isolate_) { |
| 1059 v8::GCPrologueCallback callback = |
| 1060 reinterpret_cast<v8::GCPrologueCallback>( |
| 1061 gc_prologue_callbacks_[i].callback); |
| 1062 callback(gc_type, flags); |
| 1063 } else { |
| 1064 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate()); |
| 1065 gc_prologue_callbacks_[i].callback(isolate, gc_type, flags); |
| 1066 } |
1064 } | 1067 } |
1065 } | 1068 } |
1066 } | 1069 } |
1067 | 1070 |
1068 | 1071 |
1069 void Heap::CallGCEpilogueCallbacks(GCType gc_type) { | 1072 void Heap::CallGCEpilogueCallbacks(GCType gc_type) { |
1070 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { | 1073 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { |
1071 if (gc_type & gc_epilogue_callbacks_[i].gc_type) { | 1074 if (gc_type & gc_epilogue_callbacks_[i].gc_type) { |
1072 gc_epilogue_callbacks_[i].callback(gc_type, kNoGCCallbackFlags); | 1075 if (!gc_epilogue_callbacks_[i].pass_isolate_) { |
| 1076 v8::GCPrologueCallback callback = |
| 1077 reinterpret_cast<v8::GCPrologueCallback>( |
| 1078 gc_epilogue_callbacks_[i].callback); |
| 1079 callback(gc_type, kNoGCCallbackFlags); |
| 1080 } else { |
| 1081 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate()); |
| 1082 gc_epilogue_callbacks_[i].callback( |
| 1083 isolate, gc_type, kNoGCCallbackFlags); |
| 1084 } |
1073 } | 1085 } |
1074 } | 1086 } |
1075 if (gc_type == kGCTypeMarkSweepCompact && global_gc_epilogue_callback_) { | |
1076 global_gc_epilogue_callback_(); | |
1077 } | |
1078 } | 1087 } |
1079 | 1088 |
1080 | 1089 |
1081 void Heap::MarkCompact(GCTracer* tracer) { | 1090 void Heap::MarkCompact(GCTracer* tracer) { |
1082 gc_state_ = MARK_COMPACT; | 1091 gc_state_ = MARK_COMPACT; |
1083 LOG(isolate_, ResourceEvent("markcompact", "begin")); | 1092 LOG(isolate_, ResourceEvent("markcompact", "begin")); |
1084 | 1093 |
1085 mark_compact_collector_.Prepare(tracer); | 1094 mark_compact_collector_.Prepare(tracer); |
1086 | 1095 |
1087 ms_count_++; | 1096 ms_count_++; |
(...skipping 5976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7064 | 7073 |
7065 store_buffer()->TearDown(); | 7074 store_buffer()->TearDown(); |
7066 incremental_marking()->TearDown(); | 7075 incremental_marking()->TearDown(); |
7067 | 7076 |
7068 isolate_->memory_allocator()->TearDown(); | 7077 isolate_->memory_allocator()->TearDown(); |
7069 | 7078 |
7070 delete relocation_mutex_; | 7079 delete relocation_mutex_; |
7071 } | 7080 } |
7072 | 7081 |
7073 | 7082 |
7074 void Heap::AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type) { | 7083 void Heap::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback callback, |
| 7084 GCType gc_type, |
| 7085 bool pass_isolate) { |
7075 ASSERT(callback != NULL); | 7086 ASSERT(callback != NULL); |
7076 GCPrologueCallbackPair pair(callback, gc_type); | 7087 GCPrologueCallbackPair pair(callback, gc_type, pass_isolate); |
7077 ASSERT(!gc_prologue_callbacks_.Contains(pair)); | 7088 ASSERT(!gc_prologue_callbacks_.Contains(pair)); |
7078 return gc_prologue_callbacks_.Add(pair); | 7089 return gc_prologue_callbacks_.Add(pair); |
7079 } | 7090 } |
7080 | 7091 |
7081 | 7092 |
7082 void Heap::RemoveGCPrologueCallback(GCPrologueCallback callback) { | 7093 void Heap::RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback) { |
7083 ASSERT(callback != NULL); | 7094 ASSERT(callback != NULL); |
7084 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { | 7095 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { |
7085 if (gc_prologue_callbacks_[i].callback == callback) { | 7096 if (gc_prologue_callbacks_[i].callback == callback) { |
7086 gc_prologue_callbacks_.Remove(i); | 7097 gc_prologue_callbacks_.Remove(i); |
7087 return; | 7098 return; |
7088 } | 7099 } |
7089 } | 7100 } |
7090 UNREACHABLE(); | 7101 UNREACHABLE(); |
7091 } | 7102 } |
7092 | 7103 |
7093 | 7104 |
7094 void Heap::AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type) { | 7105 void Heap::AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback, |
| 7106 GCType gc_type, |
| 7107 bool pass_isolate) { |
7095 ASSERT(callback != NULL); | 7108 ASSERT(callback != NULL); |
7096 GCEpilogueCallbackPair pair(callback, gc_type); | 7109 GCEpilogueCallbackPair pair(callback, gc_type, pass_isolate); |
7097 ASSERT(!gc_epilogue_callbacks_.Contains(pair)); | 7110 ASSERT(!gc_epilogue_callbacks_.Contains(pair)); |
7098 return gc_epilogue_callbacks_.Add(pair); | 7111 return gc_epilogue_callbacks_.Add(pair); |
7099 } | 7112 } |
7100 | 7113 |
7101 | 7114 |
7102 void Heap::RemoveGCEpilogueCallback(GCEpilogueCallback callback) { | 7115 void Heap::RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback) { |
7103 ASSERT(callback != NULL); | 7116 ASSERT(callback != NULL); |
7104 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { | 7117 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { |
7105 if (gc_epilogue_callbacks_[i].callback == callback) { | 7118 if (gc_epilogue_callbacks_[i].callback == callback) { |
7106 gc_epilogue_callbacks_.Remove(i); | 7119 gc_epilogue_callbacks_.Remove(i); |
7107 return; | 7120 return; |
7108 } | 7121 } |
7109 } | 7122 } |
7110 UNREACHABLE(); | 7123 UNREACHABLE(); |
7111 } | 7124 } |
7112 | 7125 |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8104 if (FLAG_concurrent_recompilation) { | 8117 if (FLAG_concurrent_recompilation) { |
8105 heap_->relocation_mutex_->Lock(); | 8118 heap_->relocation_mutex_->Lock(); |
8106 #ifdef DEBUG | 8119 #ifdef DEBUG |
8107 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 8120 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
8108 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 8121 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
8109 #endif // DEBUG | 8122 #endif // DEBUG |
8110 } | 8123 } |
8111 } | 8124 } |
8112 | 8125 |
8113 } } // namespace v8::internal | 8126 } } // namespace v8::internal |
OLD | NEW |