diff --git a/make/src/classes/build/tools/jfr/GenerateJfrFiles.java b/make/src/classes/build/tools/jfr/GenerateJfrFiles.java index dbaa8db7f65..a3b17cf8c3f 100644 --- a/make/src/classes/build/tools/jfr/GenerateJfrFiles.java +++ b/make/src/classes/build/tools/jfr/GenerateJfrFiles.java @@ -174,6 +174,7 @@ public class GenerateJfrFiles { boolean cutoff; boolean throttle; boolean experimental; + boolean internal; long id; boolean isEvent; boolean isRelation; @@ -197,6 +198,7 @@ public class GenerateJfrFiles { pos.writeBoolean(cutoff); pos.writeBoolean(throttle); pos.writeBoolean(experimental); + pos.writeBoolean(internal); pos.writeLong(id); pos.writeBoolean(isEvent); pos.writeBoolean(isRelation); @@ -487,6 +489,7 @@ public class GenerateJfrFiles { currentType.description = getString(attributes, "description"); currentType.category = getString(attributes, "category"); currentType.experimental = getBoolean(attributes, "experimental", false); + currentType.internal = getBoolean(attributes, "internal", false); currentType.thread = getBoolean(attributes, "thread", false); currentType.stackTrace = getBoolean(attributes, "stackTrace", false); currentType.startTime = getBoolean(attributes, "startTime", true); @@ -863,6 +866,9 @@ public class GenerateJfrFiles { private static void printWriteData(Printer out, TypeElement type) { out.write(" template "); out.write(" void writeData(Writer& w) {"); + if (type.isEvent && type.internal) { + out.write(" JfrEventSetting::unhide_internal_types();"); + } if (("_thread_in_native").equals(type.commitState)) { out.write(" // explicit epoch synchronization check"); out.write(" JfrEpochSynchronization sync;"); diff --git a/src/hotspot/share/jfr/jni/jfrUpcalls.cpp b/src/hotspot/share/jfr/jni/jfrUpcalls.cpp index e8b846d6021..2040a34a6fa 100644 --- a/src/hotspot/share/jfr/jni/jfrUpcalls.cpp +++ b/src/hotspot/share/jfr/jni/jfrUpcalls.cpp @@ -32,6 +32,7 @@ #include "jfr/support/jfrJdkJfrEvent.hpp" #include "logging/log.hpp" #include "memory/oopFactory.hpp" +#include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" #include "oops/typeArrayKlass.hpp" #include "oops/typeArrayOop.inline.hpp" @@ -45,6 +46,8 @@ static Symbol* on_retransform_method_sym = NULL; static Symbol* on_retransform_signature_sym = NULL; static Symbol* bytes_for_eager_instrumentation_sym = NULL; static Symbol* bytes_for_eager_instrumentation_sig_sym = NULL; +static Symbol* unhide_internal_types_sym = NULL; +static Symbol* unhide_internal_types_sig_sym = NULL; static bool initialize(TRAPS) { static bool initialized = false; @@ -55,7 +58,9 @@ static bool initialize(TRAPS) { on_retransform_signature_sym = SymbolTable::new_permanent_symbol("(JZLjava/lang/Class;[B)[B"); bytes_for_eager_instrumentation_sym = SymbolTable::new_permanent_symbol("bytesForEagerInstrumentation"); bytes_for_eager_instrumentation_sig_sym = SymbolTable::new_permanent_symbol("(JZLjava/lang/Class;[B)[B"); - initialized = bytes_for_eager_instrumentation_sig_sym != NULL; + unhide_internal_types_sym = SymbolTable::new_permanent_symbol("unhideInternalTypes"); + unhide_internal_types_sig_sym = SymbolTable::new_permanent_symbol("()V"); + initialized = unhide_internal_types_sig_sym != NULL; } return initialized; } @@ -82,7 +87,8 @@ static const typeArrayOop invoke(jlong trace_id, args.push_oop(old_byte_array); JfrJavaSupport::call_static(&args, THREAD); if (HAS_PENDING_EXCEPTION) { - log_error(jfr, system)("JfrUpcall failed"); + ResourceMark rm(THREAD); + log_error(jfr, system)("JfrUpcall failed for %s", method_sym->as_C_string()); return NULL; } // The result should be a [B @@ -179,3 +185,19 @@ void JfrUpcalls::new_bytes_eager_instrumentation(jlong trace_id, *new_class_data_len = new_bytes_length; *new_class_data = new_bytes; } + +bool JfrUpcalls::unhide_internal_types(TRAPS) { + DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD)); + JavaValue result(T_VOID); + const Klass* klass = SystemDictionary::resolve_or_fail(jvm_upcalls_class_sym, true, CHECK_false); + assert(klass != NULL, "invariant"); + JfrJavaArguments args(&result, klass, unhide_internal_types_sym, unhide_internal_types_sig_sym); + JfrJavaSupport::call_static(&args, THREAD); + if (HAS_PENDING_EXCEPTION) { + CLEAR_PENDING_EXCEPTION; + ResourceMark rm(THREAD); + log_error(jfr, system)("JfrUpcall failed for %s", unhide_internal_types_sym->as_C_string()); + return false; + } + return true; +} diff --git a/src/hotspot/share/jfr/jni/jfrUpcalls.hpp b/src/hotspot/share/jfr/jni/jfrUpcalls.hpp index 0bfe7074b4c..cefda39bf6b 100644 --- a/src/hotspot/share/jfr/jni/jfrUpcalls.hpp +++ b/src/hotspot/share/jfr/jni/jfrUpcalls.hpp @@ -53,6 +53,8 @@ class JfrUpcalls : AllStatic { jint* new_class_data_len, unsigned char** new_class_data, TRAPS); + + static bool unhide_internal_types(TRAPS); }; #endif // SHARE_JFR_JNI_JFRUPCALLS_HPP diff --git a/src/hotspot/share/jfr/metadata/metadata.xml b/src/hotspot/share/jfr/metadata/metadata.xml index 2cc8cc10bea..0b17b5da715 100644 --- a/src/hotspot/share/jfr/metadata/metadata.xml +++ b/src/hotspot/share/jfr/metadata/metadata.xml @@ -26,6 +26,55 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -1034,11 +1083,6 @@ - - - - - diff --git a/src/hotspot/share/jfr/metadata/metadata.xsd b/src/hotspot/share/jfr/metadata/metadata.xsd index 017307e3847..95aa2b94e8c 100644 --- a/src/hotspot/share/jfr/metadata/metadata.xsd +++ b/src/hotspot/share/jfr/metadata/metadata.xsd @@ -1,4 +1,4 @@ - +