Skip to content

Commit 49fff01

Browse files
author
Markus Grönlund
committed
8211238: @deprecated JFR event
Reviewed-by: egahlin, jbachorik
1 parent 656b446 commit 49fff01

File tree

67 files changed

+2226
-320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2226
-320
lines changed

make/src/classes/build/tools/jfr/GenerateJfrFiles.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -198,6 +198,7 @@ static class TypeElement {
198198
String period = "";
199199
boolean cutoff;
200200
boolean throttle;
201+
String level = "";
201202
boolean experimental;
202203
boolean internal;
203204
long id;
@@ -222,6 +223,7 @@ public void persist(DataOutputStream pos) throws IOException {
222223
pos.writeUTF(period);
223224
pos.writeBoolean(cutoff);
224225
pos.writeBoolean(throttle);
226+
pos.writeUTF(level);
225227
pos.writeBoolean(experimental);
226228
pos.writeBoolean(internal);
227229
pos.writeLong(id);
@@ -520,6 +522,7 @@ public void startElement(String uri, String localName, String qName, Attributes
520522
currentType.startTime = getBoolean(attributes, "startTime", true);
521523
currentType.period = getString(attributes, "period");
522524
currentType.cutoff = getBoolean(attributes, "cutoff", false);
525+
currentType.level = getString(attributes, "level");
523526
currentType.throttle = getBoolean(attributes, "throttle", false);
524527
currentType.commitState = getString(attributes, "commitState");
525528
currentType.isEvent = "Event".equals(qName);
@@ -651,7 +654,7 @@ private static void printJfrEventControlHpp(Metadata metadata, File outputFile)
651654
out.write("");
652655
out.write("struct jfrNativeEventSetting {");
653656
out.write(" jlong threshold_ticks;");
654-
out.write(" jlong cutoff_ticks;");
657+
out.write(" jlong miscellaneous;");
655658
out.write(" u1 stacktrace;");
656659
out.write(" u1 enabled;");
657660
out.write(" u1 large;");

src/hotspot/share/ci/ciMethod.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ class ciMethod : public ciMetadata {
200200
bool intrinsic_candidate() const { return get_Method()->intrinsic_candidate(); }
201201
bool is_static_initializer() const { return get_Method()->is_static_initializer(); }
202202
bool changes_current_thread() const { return get_Method()->changes_current_thread(); }
203+
bool deprecated() const { return is_loaded() && get_Method()->deprecated(); }
203204

204205
bool check_intrinsic_candidate() const {
205206
if (intrinsic_id() == vmIntrinsics::_blackhole) {

src/hotspot/share/classfile/classFileParser.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,8 @@ class AnnotationCollector : public ResourceObj{
951951
_field_Stable,
952952
_jdk_internal_vm_annotation_ReservedStackAccess,
953953
_jdk_internal_ValueBased,
954+
_java_lang_Deprecated,
955+
_java_lang_Deprecated_for_removal,
954956
_annotation_LIMIT
955957
};
956958
const Location _location;
@@ -1122,6 +1124,7 @@ static void parse_annotations(const ConstantPool* const cp,
11221124
s_tag_val = 's', // payload is String
11231125
s_con_off = 7, // utf8 payload, such as 'Ljava/lang/String;'
11241126
s_size = 9,
1127+
b_tag_val = 'Z', // payload is boolean
11251128
min_size = 6 // smallest possible size (zero members)
11261129
};
11271130
// Cannot add min_size to index in case of overflow MAX_INT
@@ -1144,6 +1147,32 @@ static void parse_annotations(const ConstantPool* const cp,
11441147
AnnotationCollector::ID id = coll->annotation_index(loader_data, aname, can_access_vm_annotations);
11451148
if (AnnotationCollector::_unknown == id) continue;
11461149
coll->set_annotation(id);
1150+
if (AnnotationCollector::_java_lang_Deprecated == id) {
1151+
assert(count <= 2, "change this if more element-value pairs are added to the @Deprecated annotation");
1152+
// @Deprecated can specify forRemoval=true
1153+
const u1* offset = abase + member_off;
1154+
for (int i = 0; i < count; ++i) {
1155+
int member_index = Bytes::get_Java_u2((address)offset);
1156+
offset += 2;
1157+
member = check_symbol_at(cp, member_index);
1158+
if (member == vmSymbols::since()) {
1159+
assert(*((address)offset) == s_tag_val, "invariant");
1160+
offset += 3;
1161+
continue;
1162+
}
1163+
if (member == vmSymbols::for_removal()) {
1164+
assert(*((address)offset) == b_tag_val, "invariant");
1165+
const u2 boolean_value_index = Bytes::get_Java_u2((address)offset + 1);
1166+
if (cp->int_at(boolean_value_index) == 1) {
1167+
// forRemoval == true
1168+
coll->set_annotation(AnnotationCollector::_java_lang_Deprecated_for_removal);
1169+
}
1170+
break;
1171+
}
1172+
1173+
}
1174+
continue;
1175+
}
11471176

11481177
if (AnnotationCollector::_jdk_internal_vm_annotation_Contended == id) {
11491178
// @Contended can optionally specify the contention group.
@@ -1959,6 +1988,9 @@ AnnotationCollector::annotation_index(const ClassLoaderData* loader_data,
19591988
if (!privileged) break; // only allow in privileged code
19601989
return _jdk_internal_ValueBased;
19611990
}
1991+
case VM_SYMBOL_ENUM_NAME(java_lang_Deprecated): {
1992+
return _java_lang_Deprecated;
1993+
}
19621994
default: {
19631995
break;
19641996
}
@@ -2003,6 +2035,10 @@ void MethodAnnotationCollector::apply_to(const methodHandle& m) {
20032035
m->set_intrinsic_candidate();
20042036
if (has_annotation(_jdk_internal_vm_annotation_ReservedStackAccess))
20052037
m->set_has_reserved_stack_access();
2038+
if (has_annotation(_java_lang_Deprecated))
2039+
m->set_deprecated();
2040+
if (has_annotation(_java_lang_Deprecated_for_removal))
2041+
m->set_deprecated_for_removal();
20062042
}
20072043

20082044
void ClassFileParser::ClassAnnotationCollector::apply_to(InstanceKlass* ik) {
@@ -2016,6 +2052,22 @@ void ClassFileParser::ClassAnnotationCollector::apply_to(InstanceKlass* ik) {
20162052
ik->set_is_value_based();
20172053
}
20182054
}
2055+
if (has_annotation(_java_lang_Deprecated)) {
2056+
Array<Method*>* methods = ik->methods();
2057+
int length = ik->methods()->length();
2058+
for (int i = 0; i < length; i++) {
2059+
Method* m = methods->at(i);
2060+
m->set_deprecated();
2061+
}
2062+
}
2063+
if (has_annotation(_java_lang_Deprecated_for_removal)) {
2064+
Array<Method*>* methods = ik->methods();
2065+
int length = ik->methods()->length();
2066+
for (int i = 0; i < length; i++) {
2067+
Method* m = methods->at(i);
2068+
m->set_deprecated_for_removal();
2069+
}
2070+
}
20192071
}
20202072

20212073
#define MAX_ARGS_SIZE 255

src/hotspot/share/classfile/vmSymbols.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ class SerializeClosure;
162162
template(jdk_internal_loader_BuiltinClassLoader, "jdk/internal/loader/BuiltinClassLoader") \
163163
template(jdk_internal_loader_ClassLoaders_AppClassLoader, "jdk/internal/loader/ClassLoaders$AppClassLoader") \
164164
template(jdk_internal_loader_ClassLoaders_PlatformClassLoader, "jdk/internal/loader/ClassLoaders$PlatformClassLoader") \
165-
\
165+
template(java_lang_Deprecated, "Ljava/lang/Deprecated;") \
166+
template(since, "since") \
167+
template(for_removal, "forRemoval") \
166168
/* Java runtime version access */ \
167169
template(java_lang_VersionProps, "java/lang/VersionProps") \
168170
template(java_version_name, "java_version") \

src/hotspot/share/jfr/instrumentation/jfrResolution.cpp

Lines changed: 0 additions & 134 deletions
This file was deleted.

src/hotspot/share/jfr/jfr.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,6 @@
2323
*/
2424

2525
#include "precompiled.hpp"
26-
#include "jfr/instrumentation/jfrResolution.hpp"
2726
#include "jfr/jfr.hpp"
2827
#include "jfr/jni/jfrJavaSupport.hpp"
2928
#include "jfr/leakprofiler/leakProfiler.hpp"
@@ -33,6 +32,7 @@
3332
#include "jfr/recorder/service/jfrOptionSet.hpp"
3433
#include "jfr/recorder/service/jfrOptionSet.hpp"
3534
#include "jfr/recorder/repository/jfrRepository.hpp"
35+
#include "jfr/support/jfrResolution.hpp"
3636
#include "jfr/support/jfrThreadLocal.hpp"
3737
#include "runtime/java.hpp"
3838

@@ -67,9 +67,7 @@ void Jfr::on_create_vm_3() {
6767
}
6868

6969
void Jfr::on_unloading_classes() {
70-
if (JfrRecorder::is_created()) {
71-
JfrCheckpointManager::on_unloading_classes();
72-
}
70+
JfrCheckpointManager::on_unloading_classes();
7371
}
7472

7573
bool Jfr::is_excluded(Thread* t) {
@@ -104,6 +102,10 @@ void Jfr::on_resolution(const CallInfo& info, TRAPS) {
104102
JfrResolution::on_runtime_resolution(info, THREAD);
105103
}
106104

105+
void Jfr::on_backpatching(const Method* callee_method, JavaThread* jt) {
106+
JfrResolution::on_backpatching(callee_method, jt);
107+
}
108+
107109
#ifdef COMPILER1
108110
void Jfr::on_resolution(const GraphBuilder* builder, const ciKlass* holder, const ciMethod* target) {
109111
JfrResolution::on_c1_resolution(builder, holder, target);

src/hotspot/share/jfr/jfr.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -70,6 +70,7 @@ class Jfr : AllStatic {
7070
static void on_vm_error_report(outputStream* st);
7171
static bool on_flight_recorder_option(const JavaVMOption** option, char* delimiter);
7272
static bool on_start_flight_recording_option(const JavaVMOption** option, char* delimiter);
73+
static void on_backpatching(const Method* callee_method, JavaThread* jt);
7374
};
7475

7576
#endif // SHARE_JFR_JFR_HPP

src/hotspot/share/jfr/jni/jfrJniMethod.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "jfr/instrumentation/jfrEventClassTransformer.hpp"
4646
#include "jfr/instrumentation/jfrJvmtiAgent.hpp"
4747
#include "jfr/leakprofiler/leakProfiler.hpp"
48+
#include "jfr/support/jfrDeprecationManager.hpp"
4849
#include "jfr/support/jfrJdkJfrEvent.hpp"
4950
#include "jfr/support/jfrKlassUnloading.hpp"
5051
#include "jfr/utilities/jfrJavaLog.hpp"
@@ -159,15 +160,19 @@ NO_TRANSITION(jdouble, jfr_time_conv_factor(JNIEnv* env, jclass jvm))
159160
return (jdouble)JfrTimeConverter::nano_to_counter_multiplier();
160161
NO_TRANSITION_END
161162

162-
NO_TRANSITION(jboolean, jfr_set_cutoff(JNIEnv* env, jclass jvm, jlong event_type_id, jlong cutoff_ticks))
163-
return JfrEventSetting::set_cutoff(event_type_id, cutoff_ticks) ? JNI_TRUE : JNI_FALSE;
164-
NO_TRANSITION_END
165-
166163
NO_TRANSITION(jboolean, jfr_set_throttle(JNIEnv* env, jclass jvm, jlong event_type_id, jlong event_sample_size, jlong period_ms))
167164
JfrEventThrottler::configure(static_cast<JfrEventId>(event_type_id), event_sample_size, period_ms);
168165
return JNI_TRUE;
169166
NO_TRANSITION_END
170167

168+
NO_TRANSITION(void, jfr_set_miscellaneous(JNIEnv* env, jobject jvm, jlong event_type_id, jlong value))
169+
JfrEventSetting::set_miscellaneous(event_type_id, value);
170+
const JfrEventId typed_event_id = (JfrEventId)event_type_id;
171+
if (EventDeprecatedInvocation::eventId == typed_event_id) {
172+
JfrDeprecationManager::on_level_setting_update(value);
173+
}
174+
NO_TRANSITION_END
175+
171176
NO_TRANSITION(jboolean, jfr_should_rotate_disk(JNIEnv* env, jclass jvm))
172177
return JfrChunkRotation::should_rotate() ? JNI_TRUE : JNI_FALSE;
173178
NO_TRANSITION_END

src/hotspot/share/jfr/jni/jfrJniMethod.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ void JNICALL jfr_set_force_instrumentation(JNIEnv* env, jclass jvm, jboolean for
127127

128128
jlong JNICALL jfr_get_unloaded_event_classes_count(JNIEnv* env, jclass jvm);
129129

130-
jboolean JNICALL jfr_set_cutoff(JNIEnv* env, jclass jvm, jlong event_type_id, jlong cutoff_ticks);
131-
132130
jboolean JNICALL jfr_set_throttle(JNIEnv* env, jclass jvm, jlong event_type_id, jlong event_sample_size, jlong period_ms);
133131

132+
void JNICALL jfr_set_miscellaneous(JNIEnv* env, jobject jvm, jlong id, jlong value);
133+
134134
void JNICALL jfr_emit_old_object_samples(JNIEnv* env, jclass jvm, jlong cutoff_ticks, jboolean, jboolean);
135135

136136
jboolean JNICALL jfr_should_rotate_disk(JNIEnv* env, jclass jvm);

0 commit comments

Comments
 (0)