26 #include "code/codeCache.hpp" |
26 #include "code/codeCache.hpp" |
27 #include "code/compiledIC.hpp" |
27 #include "code/compiledIC.hpp" |
28 #include "code/icBuffer.hpp" |
28 #include "code/icBuffer.hpp" |
29 #include "code/nmethod.hpp" |
29 #include "code/nmethod.hpp" |
30 #include "compiler/compileBroker.hpp" |
30 #include "compiler/compileBroker.hpp" |
|
31 #include "jfr/jfrEvents.hpp" |
31 #include "memory/resourceArea.hpp" |
32 #include "memory/resourceArea.hpp" |
32 #include "oops/method.hpp" |
33 #include "oops/method.hpp" |
33 #include "runtime/atomic.hpp" |
34 #include "runtime/atomic.hpp" |
34 #include "runtime/compilationPolicy.hpp" |
35 #include "runtime/compilationPolicy.hpp" |
35 #include "runtime/mutexLocker.hpp" |
36 #include "runtime/mutexLocker.hpp" |
36 #include "runtime/orderAccess.inline.hpp" |
37 #include "runtime/orderAccess.inline.hpp" |
37 #include "runtime/os.hpp" |
38 #include "runtime/os.hpp" |
38 #include "runtime/sweeper.hpp" |
39 #include "runtime/sweeper.hpp" |
39 #include "runtime/thread.inline.hpp" |
40 #include "runtime/thread.inline.hpp" |
40 #include "runtime/vm_operations.hpp" |
41 #include "runtime/vm_operations.hpp" |
41 #include "trace/tracing.hpp" |
|
42 #include "utilities/events.hpp" |
42 #include "utilities/events.hpp" |
43 #include "utilities/ticks.inline.hpp" |
43 #include "utilities/ticks.hpp" |
44 #include "utilities/xmlstream.hpp" |
44 #include "utilities/xmlstream.hpp" |
45 |
45 |
46 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
46 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
47 |
47 |
48 #ifdef ASSERT |
48 #ifdef ASSERT |
316 // Release work, because another compiler thread could continue. |
316 // Release work, because another compiler thread could continue. |
317 OrderAccess::release_store((int*)&_sweep_started, 0); |
317 OrderAccess::release_store((int*)&_sweep_started, 0); |
318 } |
318 } |
319 } |
319 } |
320 |
320 |
|
321 static void post_sweep_event(EventSweepCodeCache* event, |
|
322 const Ticks& start, |
|
323 const Ticks& end, |
|
324 s4 traversals, |
|
325 int swept, |
|
326 int flushed, |
|
327 int zombified) { |
|
328 assert(event != NULL, "invariant"); |
|
329 assert(event->should_commit(), "invariant"); |
|
330 event->set_starttime(start); |
|
331 event->set_endtime(end); |
|
332 event->set_sweepId(traversals); |
|
333 event->set_sweptCount(swept); |
|
334 event->set_flushedCount(flushed); |
|
335 event->set_zombifiedCount(zombified); |
|
336 event->commit(); |
|
337 } |
|
338 |
321 void NMethodSweeper::sweep_code_cache() { |
339 void NMethodSweeper::sweep_code_cache() { |
322 ResourceMark rm; |
340 ResourceMark rm; |
323 Ticks sweep_start_counter = Ticks::now(); |
341 Ticks sweep_start_counter = Ticks::now(); |
324 |
342 |
325 _flushed_count = 0; |
343 _flushed_count = 0; |
392 _total_flushed_size += freed_memory; |
410 _total_flushed_size += freed_memory; |
393 _total_nof_methods_reclaimed += _flushed_count; |
411 _total_nof_methods_reclaimed += _flushed_count; |
394 |
412 |
395 EventSweepCodeCache event(UNTIMED); |
413 EventSweepCodeCache event(UNTIMED); |
396 if (event.should_commit()) { |
414 if (event.should_commit()) { |
397 event.set_starttime(sweep_start_counter); |
415 post_sweep_event(&event, sweep_start_counter, sweep_end_counter, (s4)_traversals, swept_count, _flushed_count, _zombified_count); |
398 event.set_endtime(sweep_end_counter); |
|
399 event.set_sweepIndex(_traversals); |
|
400 event.set_sweepFractionIndex(NmethodSweepFraction - _sweep_fractions_left + 1); |
|
401 event.set_sweptCount(swept_count); |
|
402 event.set_flushedCount(_flushed_count); |
|
403 event.set_markedCount(_marked_for_reclamation_count); |
|
404 event.set_zombifiedCount(_zombified_count); |
|
405 event.commit(); |
|
406 } |
416 } |
407 |
417 |
408 #ifdef ASSERT |
418 #ifdef ASSERT |
409 if(PrintMethodFlushing) { |
419 if(PrintMethodFlushing) { |
410 tty->print_cr("### sweeper: sweep time(%d): " |
420 tty->print_cr("### sweeper: sweep time(%d): " |