mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 10:34:38 +02:00
8216041: [Event Request] - Deoptimization
Reviewed-by: iignatyev, vlivanov, egahlin
This commit is contained in:
parent
fec6f8a1e4
commit
6864634fb1
11 changed files with 270 additions and 5 deletions
|
@ -56,9 +56,9 @@
|
|||
#include "runtime/fieldDescriptor.hpp"
|
||||
#include "runtime/fieldDescriptor.inline.hpp"
|
||||
#include "runtime/frame.inline.hpp"
|
||||
#include "runtime/jniHandles.inline.hpp"
|
||||
#include "runtime/handles.inline.hpp"
|
||||
#include "runtime/interfaceSupport.inline.hpp"
|
||||
#include "runtime/jniHandles.inline.hpp"
|
||||
#include "runtime/safepointVerifiers.hpp"
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "runtime/signature.hpp"
|
||||
|
@ -69,9 +69,13 @@
|
|||
#include "runtime/vframeArray.hpp"
|
||||
#include "runtime/vframe_hp.hpp"
|
||||
#include "utilities/events.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
#include "utilities/preserveException.hpp"
|
||||
#include "utilities/xmlstream.hpp"
|
||||
|
||||
#if INCLUDE_JFR
|
||||
#include "jfr/jfrEvents.hpp"
|
||||
#include "jfr/metadata/jfrSerializer.hpp"
|
||||
#endif
|
||||
|
||||
bool DeoptimizationMarker::_is_active = false;
|
||||
|
||||
|
@ -1652,6 +1656,69 @@ void Deoptimization::load_class_by_index(const constantPoolHandle& constant_pool
|
|||
}
|
||||
}
|
||||
|
||||
#if INCLUDE_JFR
|
||||
|
||||
class DeoptReasonSerializer : public JfrSerializer {
|
||||
public:
|
||||
void serialize(JfrCheckpointWriter& writer) {
|
||||
writer.write_count((u4)(Deoptimization::Reason_LIMIT + 1)); // + Reason::many (-1)
|
||||
for (int i = -1; i < Deoptimization::Reason_LIMIT; ++i) {
|
||||
writer.write_key((u8)i);
|
||||
writer.write(Deoptimization::trap_reason_name(i));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class DeoptActionSerializer : public JfrSerializer {
|
||||
public:
|
||||
void serialize(JfrCheckpointWriter& writer) {
|
||||
static const u4 nof_actions = Deoptimization::Action_LIMIT;
|
||||
writer.write_count(nof_actions);
|
||||
for (u4 i = 0; i < Deoptimization::Action_LIMIT; ++i) {
|
||||
writer.write_key(i);
|
||||
writer.write(Deoptimization::trap_action_name((int)i));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static void register_serializers() {
|
||||
static int critical_section = 0;
|
||||
if (1 == critical_section || Atomic::cmpxchg(&critical_section, 0, 1) == 1) {
|
||||
return;
|
||||
}
|
||||
JfrSerializer::register_serializer(TYPE_DEOPTIMIZATIONREASON, true, new DeoptReasonSerializer());
|
||||
JfrSerializer::register_serializer(TYPE_DEOPTIMIZATIONACTION, true, new DeoptActionSerializer());
|
||||
}
|
||||
|
||||
static void post_deoptimization_event(CompiledMethod* nm,
|
||||
const Method* method,
|
||||
int trap_bci,
|
||||
int instruction,
|
||||
Deoptimization::DeoptReason reason,
|
||||
Deoptimization::DeoptAction action) {
|
||||
assert(nm != NULL, "invariant");
|
||||
assert(method != NULL, "invariant");
|
||||
if (EventDeoptimization::is_enabled()) {
|
||||
static bool serializers_registered = false;
|
||||
if (!serializers_registered) {
|
||||
register_serializers();
|
||||
serializers_registered = true;
|
||||
}
|
||||
EventDeoptimization event;
|
||||
event.set_compileId(nm->compile_id());
|
||||
event.set_compiler(nm->compiler_type());
|
||||
event.set_method(method);
|
||||
event.set_lineNumber(method->line_number_from_bci(trap_bci));
|
||||
event.set_bci(trap_bci);
|
||||
event.set_instruction(instruction);
|
||||
event.set_reason(reason);
|
||||
event.set_action(action);
|
||||
event.commit();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INCLUDE_JFR
|
||||
|
||||
JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint trap_request)) {
|
||||
HandleMark hm;
|
||||
|
||||
|
@ -1746,6 +1813,8 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint tra
|
|||
MethodData* trap_mdo =
|
||||
get_method_data(thread, profiled_method, create_if_missing);
|
||||
|
||||
JFR_ONLY(post_deoptimization_event(nm, trap_method(), trap_bci, trap_bc, reason, action);)
|
||||
|
||||
// Log a message
|
||||
Events::log_deopt_message(thread, "Uncommon trap: reason=%s action=%s pc=" INTPTR_FORMAT " method=%s @ %d %s",
|
||||
trap_reason_name(reason), trap_action_name(action), p2i(fr.pc()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue