src/share/vm/classfile/classLoader.cpp

changeset 2459
75efcee5ac47
parent 2322
828eafbd85cc
child 2497
3582bf76420e
     1.1 --- a/src/share/vm/classfile/classLoader.cpp	Thu Jan 13 22:54:23 2011 -0800
     1.2 +++ b/src/share/vm/classfile/classLoader.cpp	Thu Oct 07 13:49:40 2010 -0700
     1.3 @@ -1382,3 +1382,61 @@
     1.4  }
     1.5  
     1.6  #endif //PRODUCT
     1.7 +
     1.8 +// Please keep following two functions at end of this file. With them placed at top or in middle of the file,
     1.9 +// they could get inlined by agressive compiler, an unknown trick, see bug 6966589.
    1.10 +void PerfClassTraceTime::initialize() {
    1.11 +  if (!UsePerfData) return;
    1.12 +
    1.13 +  if (_eventp != NULL) {
    1.14 +    // increment the event counter
    1.15 +    _eventp->inc();
    1.16 +  }
    1.17 +
    1.18 +  // stop the current active thread-local timer to measure inclusive time
    1.19 +  _prev_active_event = -1;
    1.20 +  for (int i=0; i < EVENT_TYPE_COUNT; i++) {
    1.21 +     if (_timers[i].is_active()) {
    1.22 +       assert(_prev_active_event == -1, "should have only one active timer");
    1.23 +       _prev_active_event = i;
    1.24 +       _timers[i].stop();
    1.25 +     }
    1.26 +  }
    1.27 +
    1.28 +  if (_recursion_counters == NULL || (_recursion_counters[_event_type])++ == 0) {
    1.29 +    // start the inclusive timer if not recursively called
    1.30 +    _t.start();
    1.31 +  }
    1.32 +
    1.33 +  // start thread-local timer of the given event type
    1.34 +   if (!_timers[_event_type].is_active()) {
    1.35 +    _timers[_event_type].start();
    1.36 +  }
    1.37 +}
    1.38 +
    1.39 +PerfClassTraceTime::~PerfClassTraceTime() {
    1.40 +  if (!UsePerfData) return;
    1.41 +
    1.42 +  // stop the thread-local timer as the event completes
    1.43 +  // and resume the thread-local timer of the event next on the stack
    1.44 +  _timers[_event_type].stop();
    1.45 +  jlong selftime = _timers[_event_type].ticks();
    1.46 +
    1.47 +  if (_prev_active_event >= 0) {
    1.48 +    _timers[_prev_active_event].start();
    1.49 +  }
    1.50 +
    1.51 +  if (_recursion_counters != NULL && --(_recursion_counters[_event_type]) > 0) return;
    1.52 +
    1.53 +  // increment the counters only on the leaf call
    1.54 +  _t.stop();
    1.55 +  _timep->inc(_t.ticks());
    1.56 +  if (_selftimep != NULL) {
    1.57 +    _selftimep->inc(selftime);
    1.58 +  }
    1.59 +  // add all class loading related event selftime to the accumulated time counter
    1.60 +  ClassLoader::perf_accumulated_time()->inc(selftime);
    1.61 +
    1.62 +  // reset the timer
    1.63 +  _timers[_event_type].reset();
    1.64 +}

mercurial