Skip to content

Commit e8268d9

Browse files
committed
8309210: Extend VM Operations hs_err logging
Reviewed-by: dholmes, stuefe, eosterlund, sjohanss
1 parent 7dbdad5 commit e8268d9

File tree

4 files changed

+49
-7
lines changed

4 files changed

+49
-7
lines changed

src/hotspot/share/gc/z/zGeneration.cpp

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,20 @@ const char* ZGeneration::phase_to_string() const {
398398

399399
class VM_ZOperation : public VM_Operation {
400400
private:
401-
const uint _gc_id;
402-
bool _success;
401+
const uint _gc_id;
402+
const GCCause::Cause _gc_cause;
403+
bool _success;
403404

404405
public:
405-
VM_ZOperation()
406+
VM_ZOperation(GCCause::Cause gc_cause)
406407
: _gc_id(GCId::current()),
408+
_gc_cause(gc_cause),
407409
_success(false) {}
408410

411+
virtual const char* cause() const {
412+
return GCCause::to_string(_gc_cause);
413+
}
414+
409415
virtual bool block_jni_critical() const {
410416
// Blocking JNI critical regions is needed in operations where we change
411417
// the bad mask or move objects. Changing the bad mask will invalidate all
@@ -558,6 +564,9 @@ void ZGenerationYoung::collect(ZYoungType type, ConcurrentGCTimer* timer) {
558564

559565
class VM_ZMarkStartYoungAndOld : public VM_ZOperation {
560566
public:
567+
VM_ZMarkStartYoungAndOld()
568+
: VM_ZOperation(ZDriver::major()->gc_cause()) {}
569+
561570
virtual VMOp_Type type() const {
562571
return VMOp_ZMarkStartYoungAndOld;
563572
}
@@ -578,7 +587,22 @@ class VM_ZMarkStartYoungAndOld : public VM_ZOperation {
578587
}
579588
};
580589

581-
class VM_ZMarkStartYoung : public VM_ZOperation {
590+
class VM_ZYoungOperation : public VM_ZOperation {
591+
private:
592+
static ZDriver* driver() {
593+
if (ZGeneration::young()->type() == ZYoungType::minor) {
594+
return ZDriver::minor();
595+
} else {
596+
return ZDriver::major();
597+
}
598+
}
599+
600+
public:
601+
VM_ZYoungOperation()
602+
: VM_ZOperation(driver()->gc_cause()) {}
603+
};
604+
605+
class VM_ZMarkStartYoung : public VM_ZYoungOperation {
582606
public:
583607
virtual VMOp_Type type() const {
584608
return VMOp_ZMarkStartYoung;
@@ -626,7 +650,7 @@ void ZGenerationYoung::concurrent_mark() {
626650
mark_follow();
627651
}
628652

629-
class VM_ZMarkEndYoung : public VM_ZOperation {
653+
class VM_ZMarkEndYoung : public VM_ZYoungOperation {
630654
public:
631655
virtual VMOp_Type type() const {
632656
return VMOp_ZMarkEndYoung;
@@ -785,7 +809,8 @@ void ZGenerationYoung::concurrent_select_relocation_set() {
785809
select_relocation_set(_id, promote_all);
786810
}
787811

788-
class VM_ZRelocateStartYoung : public VM_ZOperation {
812+
class VM_ZRelocateStartYoung : public VM_ZYoungOperation {
813+
789814
public:
790815
virtual VMOp_Type type() const {
791816
return VMOp_ZRelocateStartYoung;
@@ -1047,6 +1072,9 @@ void ZGenerationOld::concurrent_mark() {
10471072

10481073
class VM_ZMarkEndOld : public VM_ZOperation {
10491074
public:
1075+
VM_ZMarkEndOld()
1076+
: VM_ZOperation(ZDriver::major()->gc_cause()) {}
1077+
10501078
virtual VMOp_Type type() const {
10511079
return VMOp_ZMarkEndOld;
10521080
}
@@ -1125,6 +1153,9 @@ void ZGenerationOld::concurrent_select_relocation_set() {
11251153

11261154
class VM_ZRelocateStartOld : public VM_ZOperation {
11271155
public:
1156+
VM_ZRelocateStartOld()
1157+
: VM_ZOperation(ZDriver::major()->gc_cause()) {}
1158+
11281159
virtual VMOp_Type type() const {
11291160
return VMOp_ZRelocateStartOld;
11301161
}

src/hotspot/share/runtime/handshake.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ class VM_HandshakeAllThreads: public VM_Operation {
238238
public:
239239
VM_HandshakeAllThreads(HandshakeOperation* op) : _op(op) {}
240240

241+
const char* cause() const { return _op->name(); }
242+
241243
bool evaluate_at_safepoint() const { return false; }
242244

243245
void doit() {

src/hotspot/share/runtime/vmOperation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ class VM_Operation : public StackObj {
174174
assert(type >= 0 && type < VMOp_Terminating, "invalid VM operation type");
175175
return _names[type];
176176
}
177+
// Extra information about what triggered this operation.
178+
virtual const char* cause() const { return nullptr; }
177179
#ifndef PRODUCT
178180
void print_on(outputStream* st) const { print_on_error(st); }
179181
#endif

src/hotspot/share/runtime/vmThread.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,14 @@ void VMThread::inner_execute(VM_Operation* op) {
407407
_cur_vm_operation = op;
408408

409409
HandleMark hm(VMThread::vm_thread());
410-
EventMarkVMOperation em("Executing %sVM operation: %s", prev_vm_operation != nullptr ? "nested " : "", op->name());
410+
411+
const char* const cause = op->cause();
412+
EventMarkVMOperation em("Executing %sVM operation: %s%s%s%s",
413+
prev_vm_operation != nullptr ? "nested " : "",
414+
op->name(),
415+
cause != nullptr ? " (" : "",
416+
cause != nullptr ? cause : "",
417+
cause != nullptr ? ")" : "");
411418

412419
log_debug(vmthread)("Evaluating %s %s VM operation: %s",
413420
prev_vm_operation != nullptr ? "nested" : "",

0 commit comments

Comments
 (0)