jdk

Форк
0
/x
/
xTracer.cpp 
146 строк · 4.5 Кб
1
/*
2
 * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
 *
5
 * This code is free software; you can redistribute it and/or modify it
6
 * under the terms of the GNU General Public License version 2 only, as
7
 * published by the Free Software Foundation.
8
 *
9
 * This code is distributed in the hope that it will be useful, but WITHOUT
10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
 * version 2 for more details (a copy is included in the LICENSE file that
13
 * accompanied this code).
14
 *
15
 * You should have received a copy of the GNU General Public License version
16
 * 2 along with this work; if not, write to the Free Software Foundation,
17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
 *
19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
 * or visit www.oracle.com if you need additional information or have any
21
 * questions.
22
 */
23

24
#include "precompiled.hpp"
25
#include "gc/shared/gcId.hpp"
26
#include "gc/x/xGlobals.hpp"
27
#include "gc/x/xStat.hpp"
28
#include "gc/x/xTracer.hpp"
29
#include "jfr/jfrEvents.hpp"
30
#include "runtime/safepointVerifiers.hpp"
31
#include "utilities/debug.hpp"
32
#include "utilities/macros.hpp"
33
#if INCLUDE_JFR
34
#include "jfr/metadata/jfrSerializer.hpp"
35
#endif
36

37
#if INCLUDE_JFR
38

39
class XPageTypeConstant : public JfrSerializer {
40
public:
41
  virtual void serialize(JfrCheckpointWriter& writer) {
42
    writer.write_count(3);
43
    writer.write_key(XPageTypeSmall);
44
    writer.write("Small");
45
    writer.write_key(XPageTypeMedium);
46
    writer.write("Medium");
47
    writer.write_key(XPageTypeLarge);
48
    writer.write("Large");
49
  }
50
};
51

52
class XStatisticsCounterTypeConstant : public JfrSerializer {
53
public:
54
  virtual void serialize(JfrCheckpointWriter& writer) {
55
    writer.write_count(XStatCounter::count());
56
    for (XStatCounter* counter = XStatCounter::first(); counter != nullptr; counter = counter->next()) {
57
      writer.write_key(counter->id());
58
      writer.write(counter->name());
59
    }
60
  }
61
};
62

63
class XStatisticsSamplerTypeConstant : public JfrSerializer {
64
public:
65
  virtual void serialize(JfrCheckpointWriter& writer) {
66
    writer.write_count(XStatSampler::count());
67
    for (XStatSampler* sampler = XStatSampler::first(); sampler != nullptr; sampler = sampler->next()) {
68
      writer.write_key(sampler->id());
69
      writer.write(sampler->name());
70
    }
71
  }
72
};
73

74
static void register_jfr_type_serializers() {
75
  JfrSerializer::register_serializer(TYPE_ZPAGETYPETYPE,
76
                                     true /* permit_cache */,
77
                                     new XPageTypeConstant());
78
  JfrSerializer::register_serializer(TYPE_ZSTATISTICSCOUNTERTYPE,
79
                                     true /* permit_cache */,
80
                                     new XStatisticsCounterTypeConstant());
81
  JfrSerializer::register_serializer(TYPE_ZSTATISTICSSAMPLERTYPE,
82
                                     true /* permit_cache */,
83
                                     new XStatisticsSamplerTypeConstant());
84
}
85

86
#endif // INCLUDE_JFR
87

88
XTracer* XTracer::_tracer = nullptr;
89

90
XTracer::XTracer() :
91
    GCTracer(Z) {}
92

93
void XTracer::initialize() {
94
  assert(_tracer == nullptr, "Already initialized");
95
  _tracer = new XTracer();
96
  JFR_ONLY(register_jfr_type_serializers();)
97
}
98

99
void XTracer::send_stat_counter(const XStatCounter& counter, uint64_t increment, uint64_t value) {
100
  NoSafepointVerifier nsv;
101

102
  EventZStatisticsCounter e;
103
  if (e.should_commit()) {
104
    e.set_id(counter.id());
105
    e.set_increment(increment);
106
    e.set_value(value);
107
    e.commit();
108
  }
109
}
110

111
void XTracer::send_stat_sampler(const XStatSampler& sampler, uint64_t value) {
112
  NoSafepointVerifier nsv;
113

114
  EventZStatisticsSampler e;
115
  if (e.should_commit()) {
116
    e.set_id(sampler.id());
117
    e.set_value(value);
118
    e.commit();
119
  }
120
}
121

122
void XTracer::send_thread_phase(const char* name, const Ticks& start, const Ticks& end) {
123
  NoSafepointVerifier nsv;
124

125
  EventZThreadPhase e(UNTIMED);
126
  if (e.should_commit()) {
127
    e.set_gcId(GCId::current_or_undefined());
128
    e.set_name(name);
129
    e.set_starttime(start);
130
    e.set_endtime(end);
131
    e.commit();
132
  }
133
}
134

135
void XTracer::send_thread_debug(const char* name, const Ticks& start, const Ticks& end) {
136
  NoSafepointVerifier nsv;
137

138
  EventZThreadDebug e(UNTIMED);
139
  if (e.should_commit()) {
140
    e.set_gcId(GCId::current_or_undefined());
141
    e.set_name(name);
142
    e.set_starttime(start);
143
    e.set_endtime(end);
144
    e.commit();
145
  }
146
}
147

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.