src/hotspot/share/jfr/leakprofiler/sampling/objectSample.hpp
author egahlin
Wed, 05 Dec 2018 16:40:12 +0100
changeset 52850 f527b24990d7
parent 50880 e1117321adaf
child 53244 9807daeb47c4
permissions -rw-r--r--
8205516: JFR tool Reviewed-by: mgronlun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     1
/*
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     2
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     4
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     8
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    13
 * accompanied this code).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    14
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    18
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    21
 * questions.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    22
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    23
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    24
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    25
#ifndef SHARE_VM_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLE_HPP
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    26
#define SHARE_VM_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLE_HPP
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    27
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    28
#include "jfr/recorder/checkpoint/jfrCheckpointBlob.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    29
#include "jfr/utilities/jfrAllocation.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    30
#include "jfr/utilities/jfrTime.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    31
#include "jfr/utilities/jfrTypes.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    32
#include "memory/allocation.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    33
#include "oops/oop.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    34
#include "utilities/ticks.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    35
/*
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    36
 * Handle for diagnosing Java memory leaks.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    37
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    38
 * The class tracks the time the object was
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    39
 * allocated, the thread and the stack trace.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    40
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    41
class ObjectSample : public JfrCHeapObj {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    42
  friend class ObjectSampler;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    43
  friend class SampleList;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    44
 private:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    45
  ObjectSample* _next;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    46
  ObjectSample* _previous;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    47
  JfrCheckpointBlobHandle _thread_cp;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    48
  JfrCheckpointBlobHandle _klass_cp;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    49
  oop _object;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    50
  Ticks _allocation_time;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    51
  traceid _stack_trace_id;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    52
  traceid _thread_id;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    53
  int _index;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    54
  size_t _span;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    55
  size_t _allocated;
50880
e1117321adaf 8197425: Liveset information for Old Object sample event
egahlin
parents: 50113
diff changeset
    56
  size_t _heap_used_at_last_gc;
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    57
  unsigned int _stack_trace_hash;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    58
  bool _dead;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    59
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    60
  void set_dead() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    61
    _dead = true;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    62
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    63
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    64
  void release_references() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    65
    if (_thread_cp.valid()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    66
      _thread_cp.~JfrCheckpointBlobHandle();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    67
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    68
    if (_klass_cp.valid()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    69
      _klass_cp.~JfrCheckpointBlobHandle();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    70
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    71
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    72
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    73
  void reset() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    74
    set_stack_trace_id(0);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    75
    set_stack_trace_hash(0),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    76
    release_references();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    77
    _dead = false;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    78
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    79
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    80
 public:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    81
  ObjectSample() : _next(NULL),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    82
                   _previous(NULL),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    83
                   _thread_cp(),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    84
                   _klass_cp(),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    85
                   _object(NULL),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    86
                   _allocation_time(),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    87
                   _stack_trace_id(0),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    88
                   _thread_id(0),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    89
                   _index(0),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    90
                   _span(0),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    91
                   _allocated(0),
50880
e1117321adaf 8197425: Liveset information for Old Object sample event
egahlin
parents: 50113
diff changeset
    92
                   _heap_used_at_last_gc(0),
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    93
                   _stack_trace_hash(0),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    94
                   _dead(false) {}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    95
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    96
  ObjectSample* next() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    97
    return _next;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    98
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    99
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   100
  void set_next(ObjectSample* next) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   101
    _next = next;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   102
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   103
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   104
  ObjectSample* prev() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   105
    return _previous;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   106
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   107
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   108
  void set_prev(ObjectSample* prev) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   109
    _previous = prev;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   110
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   111
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   112
  bool is_dead() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   113
    return _dead;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   114
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   115
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   116
  const oop object() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   117
    return _object;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   118
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   119
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   120
  const oop* object_addr() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   121
    return &_object;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   122
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   123
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   124
  void set_object(oop object) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   125
    _object = object;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   126
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   127
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   128
  const Klass* klass() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   129
    assert(_object != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   130
    return _object->klass();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   131
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   132
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   133
  int index() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   134
    return _index;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   135
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   136
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   137
  void set_index(int index) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   138
    _index = index;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   139
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   140
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   141
  size_t span() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   142
    return _span;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   143
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   144
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   145
  void set_span(size_t span) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   146
    _span = span;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   147
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   148
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   149
  void add_span(size_t span) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   150
    _span += span;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   151
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   152
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   153
  size_t allocated() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   154
    return _allocated;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   155
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   156
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   157
  void set_allocated(size_t size) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   158
    _allocated = size;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   159
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   160
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   161
  const Ticks& allocation_time() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   162
    return _allocation_time;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   163
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   164
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   165
  const void set_allocation_time(const JfrTicks& time) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   166
    _allocation_time = Ticks(time.value());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   167
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   168
50880
e1117321adaf 8197425: Liveset information for Old Object sample event
egahlin
parents: 50113
diff changeset
   169
  void set_heap_used_at_last_gc(size_t heap_used) {
e1117321adaf 8197425: Liveset information for Old Object sample event
egahlin
parents: 50113
diff changeset
   170
    _heap_used_at_last_gc = heap_used;
e1117321adaf 8197425: Liveset information for Old Object sample event
egahlin
parents: 50113
diff changeset
   171
  }
e1117321adaf 8197425: Liveset information for Old Object sample event
egahlin
parents: 50113
diff changeset
   172
e1117321adaf 8197425: Liveset information for Old Object sample event
egahlin
parents: 50113
diff changeset
   173
  size_t heap_used_at_last_gc() const {
e1117321adaf 8197425: Liveset information for Old Object sample event
egahlin
parents: 50113
diff changeset
   174
    return _heap_used_at_last_gc;
e1117321adaf 8197425: Liveset information for Old Object sample event
egahlin
parents: 50113
diff changeset
   175
  }
e1117321adaf 8197425: Liveset information for Old Object sample event
egahlin
parents: 50113
diff changeset
   176
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   177
  bool has_stack_trace() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   178
    return stack_trace_id() != 0;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   179
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   180
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   181
  traceid stack_trace_id() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   182
    return _stack_trace_id;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   183
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   184
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   185
  void set_stack_trace_id(traceid id) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   186
    _stack_trace_id = id;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   187
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   188
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   189
  unsigned int stack_trace_hash() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   190
    return _stack_trace_hash;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   191
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   192
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   193
  void set_stack_trace_hash(unsigned int hash) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   194
    _stack_trace_hash = hash;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   195
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   196
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   197
  bool has_thread() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   198
    return _thread_id != 0;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   199
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   200
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   201
  traceid thread_id() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   202
    return _thread_id;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   203
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   204
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   205
  void set_thread_id(traceid id) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   206
    _thread_id = id;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   207
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   208
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   209
  bool is_alive_and_older_than(jlong time_stamp) const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   210
    return !is_dead() && (JfrTime::is_ft_enabled() ?
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   211
      _allocation_time.ft_value() : _allocation_time.value()) < time_stamp;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   212
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   213
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   214
  const JfrCheckpointBlobHandle& thread_checkpoint() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   215
    return _thread_cp;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   216
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   217
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   218
  bool has_thread_checkpoint() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   219
    return _thread_cp.valid();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   220
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   221
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   222
  // JfrCheckpointBlobHandle assignment operator
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   223
  // maintains proper reference counting
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   224
  void set_thread_checkpoint(const JfrCheckpointBlobHandle& ref) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   225
    if (_thread_cp != ref) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   226
      _thread_cp = ref;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   227
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   228
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   229
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   230
  const JfrCheckpointBlobHandle& klass_checkpoint() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   231
    return _klass_cp;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   232
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   233
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   234
  bool has_klass_checkpoint() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   235
    return _klass_cp.valid();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   236
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   237
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   238
  void set_klass_checkpoint(const JfrCheckpointBlobHandle& ref) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   239
    if (_klass_cp != ref) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   240
      if (_klass_cp.valid()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   241
        _klass_cp->set_next(ref);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   242
        return;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   243
      }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   244
      _klass_cp = ref;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   245
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   246
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   247
};
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   248
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   249
#endif // SHARE_VM_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLE_HPP