Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/sweeper.cpp @ 13451:02f27ecb4f3a
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 18 Dec 2013 00:00:24 +0100 |
parents | 096c224171c4 86e6d691f2e1 |
children | 810f2c413ace |
comparison
equal
deleted
inserted
replaced
13371:4db09b7304da | 13451:02f27ecb4f3a |
---|---|
36 #include "runtime/os.hpp" | 36 #include "runtime/os.hpp" |
37 #include "runtime/sweeper.hpp" | 37 #include "runtime/sweeper.hpp" |
38 #include "runtime/vm_operations.hpp" | 38 #include "runtime/vm_operations.hpp" |
39 #include "trace/tracing.hpp" | 39 #include "trace/tracing.hpp" |
40 #include "utilities/events.hpp" | 40 #include "utilities/events.hpp" |
41 #include "utilities/ticks.inline.hpp" | |
41 #include "utilities/xmlstream.hpp" | 42 #include "utilities/xmlstream.hpp" |
42 | 43 |
43 #ifdef ASSERT | 44 #ifdef ASSERT |
44 | 45 |
45 #define SWEEP(nm) record_sweep(nm, __LINE__) | 46 #define SWEEP(nm) record_sweep(nm, __LINE__) |
142 // 1) alive -> not_entrant | 143 // 1) alive -> not_entrant |
143 // 2) not_entrant -> zombie | 144 // 2) not_entrant -> zombie |
144 // 3) zombie -> marked_for_reclamation | 145 // 3) zombie -> marked_for_reclamation |
145 | 146 |
146 int NMethodSweeper::_total_nof_methods_reclaimed = 0; // Accumulated nof methods flushed | 147 int NMethodSweeper::_total_nof_methods_reclaimed = 0; // Accumulated nof methods flushed |
147 jlong NMethodSweeper::_total_time_sweeping = 0; // Accumulated time sweeping | 148 Tickspan NMethodSweeper::_total_time_sweeping; // Accumulated time sweeping |
148 jlong NMethodSweeper::_total_time_this_sweep = 0; // Total time this sweep | 149 Tickspan NMethodSweeper::_total_time_this_sweep; // Total time this sweep |
149 jlong NMethodSweeper::_peak_sweep_time = 0; // Peak time for a full sweep | 150 Tickspan NMethodSweeper::_peak_sweep_time; // Peak time for a full sweep |
150 jlong NMethodSweeper::_peak_sweep_fraction_time = 0; // Peak time sweeping one fraction | 151 Tickspan NMethodSweeper::_peak_sweep_fraction_time; // Peak time sweeping one fraction |
151 int NMethodSweeper::_hotness_counter_reset_val = 0; | 152 int NMethodSweeper::_hotness_counter_reset_val = 0; |
152 | 153 |
153 | 154 |
154 class MarkActivationClosure: public CodeBlobClosure { | 155 class MarkActivationClosure: public CodeBlobClosure { |
155 public: | 156 public: |
207 if (!sweep_in_progress()) { | 208 if (!sweep_in_progress()) { |
208 _seen = 0; | 209 _seen = 0; |
209 _sweep_fractions_left = NmethodSweepFraction; | 210 _sweep_fractions_left = NmethodSweepFraction; |
210 _current = CodeCache::first_nmethod(); | 211 _current = CodeCache::first_nmethod(); |
211 _traversals += 1; | 212 _traversals += 1; |
212 _total_time_this_sweep = 0; | 213 _total_time_this_sweep = Tickspan(); |
213 | 214 |
214 if (PrintMethodFlushing) { | 215 if (PrintMethodFlushing) { |
215 tty->print_cr("### Sweep: stack traversal %d", _traversals); | 216 tty->print_cr("### Sweep: stack traversal %d", _traversals); |
216 } | 217 } |
217 Threads::nmethods_do(&mark_activation_closure); | 218 Threads::nmethods_do(&mark_activation_closure); |
229 * (2) There are sufficient state changes in/since the last sweep. | 230 * (2) There are sufficient state changes in/since the last sweep. |
230 * (3) We have not been sweeping for 'some time' | 231 * (3) We have not been sweeping for 'some time' |
231 */ | 232 */ |
232 void NMethodSweeper::possibly_sweep() { | 233 void NMethodSweeper::possibly_sweep() { |
233 assert(JavaThread::current()->thread_state() == _thread_in_vm, "must run in vm mode"); | 234 assert(JavaThread::current()->thread_state() == _thread_in_vm, "must run in vm mode"); |
234 if (!MethodFlushing || !sweep_in_progress()) { | 235 // Only compiler threads are allowed to sweep |
236 if (!MethodFlushing || !sweep_in_progress() || !Thread::current()->is_Compiler_thread()) { | |
235 return; | 237 return; |
236 } | 238 } |
237 | 239 |
238 // If there was no state change while nmethod sweeping, 'should_sweep' will be false. | 240 // If there was no state change while nmethod sweeping, 'should_sweep' will be false. |
239 // This is one of the two places where should_sweep can be set to true. The general | 241 // This is one of the two places where should_sweep can be set to true. The general |
300 _sweep_started = 0; | 302 _sweep_started = 0; |
301 } | 303 } |
302 } | 304 } |
303 | 305 |
304 void NMethodSweeper::sweep_code_cache() { | 306 void NMethodSweeper::sweep_code_cache() { |
305 jlong sweep_start_counter = os::elapsed_counter(); | 307 Ticks sweep_start_counter = Ticks::now(); |
306 | 308 |
307 _flushed_count = 0; | 309 _flushed_count = 0; |
308 _zombified_count = 0; | 310 _zombified_count = 0; |
309 _marked_for_reclamation_count = 0; | 311 _marked_for_reclamation_count = 0; |
310 | 312 |
364 } | 366 } |
365 } | 367 } |
366 | 368 |
367 assert(_sweep_fractions_left > 1 || _current == NULL, "must have scanned the whole cache"); | 369 assert(_sweep_fractions_left > 1 || _current == NULL, "must have scanned the whole cache"); |
368 | 370 |
369 jlong sweep_end_counter = os::elapsed_counter(); | 371 const Ticks sweep_end_counter = Ticks::now(); |
370 jlong sweep_time = sweep_end_counter - sweep_start_counter; | 372 const Tickspan sweep_time = sweep_end_counter - sweep_start_counter; |
371 _total_time_sweeping += sweep_time; | 373 _total_time_sweeping += sweep_time; |
372 _total_time_this_sweep += sweep_time; | 374 _total_time_this_sweep += sweep_time; |
373 _peak_sweep_fraction_time = MAX2(sweep_time, _peak_sweep_fraction_time); | 375 _peak_sweep_fraction_time = MAX2(sweep_time, _peak_sweep_fraction_time); |
374 _total_nof_methods_reclaimed += _flushed_count; | 376 _total_nof_methods_reclaimed += _flushed_count; |
375 | 377 |
386 event.commit(); | 388 event.commit(); |
387 } | 389 } |
388 | 390 |
389 #ifdef ASSERT | 391 #ifdef ASSERT |
390 if(PrintMethodFlushing) { | 392 if(PrintMethodFlushing) { |
391 tty->print_cr("### sweeper: sweep time(%d): " INT64_FORMAT, _sweep_fractions_left, (jlong)sweep_time); | 393 tty->print_cr("### sweeper: sweep time(%d): " |
394 INT64_FORMAT, _sweep_fractions_left, (jlong)sweep_time.value()); | |
392 } | 395 } |
393 #endif | 396 #endif |
394 | 397 |
395 if (_sweep_fractions_left == 1) { | 398 if (_sweep_fractions_left == 1) { |
396 _peak_sweep_time = MAX2(_peak_sweep_time, _total_time_this_sweep); | 399 _peak_sweep_time = MAX2(_peak_sweep_time, _total_time_this_sweep); |