< prev index next >

src/share/vm/jfr/support/jfrFlush.hpp

Print this page
rev 9055 : 8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
Reviewed-by: egahlin, rwestberg


  31 
  32 class Thread;
  33 
  34 class JfrFlush : public StackObj {
  35  public:
  36   typedef JfrBuffer Type;
  37   JfrFlush(Type* old, size_t used, size_t requested, Thread* t);
  38   Type* result() const { return _result; }
  39  private:
  40   Type* _result;
  41 };
  42 
  43 void jfr_conditional_flush(JfrEventId id, size_t size, Thread* t);
  44 bool jfr_is_event_enabled(JfrEventId id);
  45 bool jfr_has_stacktrace_enabled(JfrEventId id);
  46 bool jfr_save_stacktrace(Thread* t);
  47 void jfr_clear_stacktrace(Thread* t);
  48 
  49 template <typename Event>
  50 class JfrConditionalFlush {


  51  public:
  52   typedef JfrBuffer Type;
  53   JfrConditionalFlush(Thread* t) {
  54     if (jfr_is_event_enabled(Event::eventId)) {
  55       jfr_conditional_flush(Event::eventId, sizeof(Event), t);
  56     }
  57   }
  58 };
  59 
  60 template <typename Event>
  61 class JfrConditionalFlushWithStacktrace : public JfrConditionalFlush<Event> {
  62   Thread* _t;
  63   bool _owner;
  64  public:
  65   JfrConditionalFlushWithStacktrace(Thread* t) : JfrConditionalFlush<Event>(t), _t(t), _owner(false) {
  66     if (Event::has_stacktrace() && jfr_has_stacktrace_enabled(Event::eventId)) {
  67       _owner = jfr_save_stacktrace(t);
  68     }
  69   }
  70   ~JfrConditionalFlushWithStacktrace() {
  71     if (_owner) {
  72       jfr_clear_stacktrace(_t);
  73     }
  74   }
  75 };
  76 
  77 #endif // SHARE_VM_JFR_SUPPORT_JFRFLUSH_HPP


  31 
  32 class Thread;
  33 
  34 class JfrFlush : public StackObj {
  35  public:
  36   typedef JfrBuffer Type;
  37   JfrFlush(Type* old, size_t used, size_t requested, Thread* t);
  38   Type* result() const { return _result; }
  39  private:
  40   Type* _result;
  41 };
  42 
  43 void jfr_conditional_flush(JfrEventId id, size_t size, Thread* t);
  44 bool jfr_is_event_enabled(JfrEventId id);
  45 bool jfr_has_stacktrace_enabled(JfrEventId id);
  46 bool jfr_save_stacktrace(Thread* t);
  47 void jfr_clear_stacktrace(Thread* t);
  48 
  49 template <typename Event>
  50 class JfrConditionalFlush {
  51  protected:
  52   bool _enabled;
  53  public:
  54   typedef JfrBuffer Type;
  55   JfrConditionalFlush(Thread* t) : _enabled(jfr_is_event_enabled(Event::eventId)) {
  56     if (_enabled) {
  57       jfr_conditional_flush(Event::eventId, sizeof(Event), t);
  58     }
  59   }
  60 };
  61 
  62 template <typename Event>
  63 class JfrConditionalFlushWithStacktrace : public JfrConditionalFlush<Event> {
  64   Thread* _t;
  65   bool _owner;
  66  public:
  67   JfrConditionalFlushWithStacktrace(Thread* t) : JfrConditionalFlush<Event>(t), _t(t), _owner(false) {
  68     if (this->_enabled && Event::has_stacktrace() && jfr_has_stacktrace_enabled(Event::eventId)) {
  69       _owner = jfr_save_stacktrace(t);
  70     }
  71   }
  72   ~JfrConditionalFlushWithStacktrace() {
  73     if (_owner) {
  74       jfr_clear_stacktrace(_t);
  75     }
  76   }
  77 };
  78 
  79 #endif // SHARE_VM_JFR_SUPPORT_JFRFLUSH_HPP
< prev index next >