Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/shared/gcTraceTime.cpp @ 13400:86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
Reviewed-by: dholmes, egahlin
author | mgronlun |
---|---|
date | Sat, 23 Nov 2013 12:25:13 +0100 |
parents | f2110083203d |
children | 0982ec23da03 |
comparison
equal
deleted
inserted
replaced
13399:260ac69dc096 | 13400:86e6d691f2e1 |
---|---|
29 #include "runtime/os.hpp" | 29 #include "runtime/os.hpp" |
30 #include "runtime/safepoint.hpp" | 30 #include "runtime/safepoint.hpp" |
31 #include "runtime/thread.inline.hpp" | 31 #include "runtime/thread.inline.hpp" |
32 #include "runtime/timer.hpp" | 32 #include "runtime/timer.hpp" |
33 #include "utilities/ostream.hpp" | 33 #include "utilities/ostream.hpp" |
34 #include "utilities/ticks.inline.hpp" | |
34 | 35 |
35 | 36 |
36 GCTraceTime::GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer) : | 37 GCTraceTime::GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer) : |
37 _title(title), _doit(doit), _print_cr(print_cr), _timer(timer) { | 38 _title(title), _doit(doit), _print_cr(print_cr), _timer(timer), _start_counter() { |
38 if (_doit || _timer != NULL) { | 39 if (_doit || _timer != NULL) { |
39 _start_counter = os::elapsed_counter(); | 40 _start_counter.stamp(); |
40 } | 41 } |
41 | 42 |
42 if (_timer != NULL) { | 43 if (_timer != NULL) { |
43 assert(SafepointSynchronize::is_at_safepoint(), "Tracing currently only supported at safepoints"); | 44 assert(SafepointSynchronize::is_at_safepoint(), "Tracing currently only supported at safepoints"); |
44 assert(Thread::current()->is_VM_thread(), "Tracing currently only supported from the VM thread"); | 45 assert(Thread::current()->is_VM_thread(), "Tracing currently only supported from the VM thread"); |
55 gclog_or_tty->flush(); | 56 gclog_or_tty->flush(); |
56 } | 57 } |
57 } | 58 } |
58 | 59 |
59 GCTraceTime::~GCTraceTime() { | 60 GCTraceTime::~GCTraceTime() { |
60 jlong stop_counter = 0; | 61 Ticks stop_counter; |
61 | 62 |
62 if (_doit || _timer != NULL) { | 63 if (_doit || _timer != NULL) { |
63 stop_counter = os::elapsed_counter(); | 64 stop_counter.stamp(); |
64 } | 65 } |
65 | 66 |
66 if (_timer != NULL) { | 67 if (_timer != NULL) { |
67 _timer->register_gc_phase_end(stop_counter); | 68 _timer->register_gc_phase_end(stop_counter); |
68 } | 69 } |
69 | 70 |
70 if (_doit) { | 71 if (_doit) { |
71 double seconds = TimeHelper::counter_to_seconds(stop_counter - _start_counter); | 72 const Tickspan duration = stop_counter - _start_counter; |
73 double duration_in_seconds = TicksToTimeHelper::seconds(duration); | |
72 if (_print_cr) { | 74 if (_print_cr) { |
73 gclog_or_tty->print_cr(", %3.7f secs]", seconds); | 75 gclog_or_tty->print_cr(", %3.7f secs]", duration_in_seconds); |
74 } else { | 76 } else { |
75 gclog_or_tty->print(", %3.7f secs]", seconds); | 77 gclog_or_tty->print(", %3.7f secs]", duration_in_seconds); |
76 } | 78 } |
77 gclog_or_tty->flush(); | 79 gclog_or_tty->flush(); |
78 } | 80 } |
79 } | 81 } |