Skip to content

Commit

Permalink
Changes requested by veresov
Browse files Browse the repository at this point in the history
  • Loading branch information
RealLucy committed Mar 3, 2021
1 parent e8af119 commit 5c27640
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/hotspot/cpu/x86/vtableStubs_x86_32.cpp
Expand Up @@ -156,7 +156,6 @@ VtableStub* VtableStubs::create_itable_stub(int itable_index) {
if (s == NULL) {
return NULL;
}

// Count unused bytes in instruction sequences of variable size.
// We add them to the computed buffer size in order to avoid
// overflow in subsequently generated stubs.
Expand Down
29 changes: 9 additions & 20 deletions src/hotspot/share/oops/method.cpp
Expand Up @@ -508,28 +508,17 @@ void Method::print_invocation_count() {
}
tty->cr();

// Internal counting is based on signed int counters. They tend to
// overflow with longer-running workloads on fast machines. To shift
// the overflow limit, we interpret the return value as unsigned int.
// This is ok because counters are unsigned by nature, and it gives us
// another factor of 2 before the counter values become meaningless.
// Print a "overflow" notification to create awareness.
const char* addMsg;
unsigned int maxInt = (1U<<31) - 1;
unsigned int iic = (unsigned int)interpreter_invocation_count();
addMsg = (iic > maxInt) ? "counter in overflow" : "";
tty->print_cr (" interpreter_invocation_count: " UINT32_FORMAT_W(11) " %s", iic, addMsg);
unsigned int ic = (unsigned int)invocation_count();
addMsg = (ic > maxInt) ? "counter in overflow" : "";
tty->print_cr (" invocation_counter: " UINT32_FORMAT_W(11) " %s", ic, addMsg);
unsigned int bec = (unsigned int)backedge_count();
addMsg = (bec > maxInt) ? "counter in overflow" : "";
tty->print_cr (" backedge_counter: " UINT32_FORMAT_W(11) " %s", bec, addMsg);
// Counting based on signed int counters tends to overflow with
// longer-running workloads on fast machines. The counters under
// consideration here, however, are limited in range by counting
// logic. See InvocationCounter:count_limit for example.
// No "overflow precautions" need to be implemented here.
tty->print_cr (" interpreter_invocation_count: " INT32_FORMAT_W(11), interpreter_invocation_count());
tty->print_cr (" invocation_counter: " INT32_FORMAT_W(11), invocation_count());
tty->print_cr (" backedge_counter: " INT32_FORMAT_W(11), backedge_count());

if (method_data() != NULL) {
unsigned int dcc = (unsigned int)method_data()->decompile_count();
addMsg = (dcc > maxInt) ? "counter in overflow" : "";
tty->print_cr (" decompile_count: " UINT32_FORMAT_W(11)" %s", dcc, addMsg);
tty->print_cr (" decompile_count: " UINT32_FORMAT_W(11), method_data()->decompile_count());
}

#ifndef PRODUCT
Expand Down
9 changes: 6 additions & 3 deletions src/hotspot/share/runtime/java.cpp
Expand Up @@ -96,8 +96,11 @@
GrowableArray<Method*>* collected_profiled_methods;

int compare_methods(Method** a, Method** b) {
return (int32_t)(((uint32_t)(*b)->invocation_count() + (*b)->compiled_invocation_count())
- ((uint32_t)(*a)->invocation_count() + (*a)->compiled_invocation_count()));
// compiled_invocation_count() returns int64_t, forcing the entire expression
// to be evaluated as int64_t. Overflow is not an issue.
int64_t diff = (((*b)->invocation_count() + (*b)->compiled_invocation_count())
- ((*a)->invocation_count() + (*a)->compiled_invocation_count()));
return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
}

void collect_profiled_methods(Method* m) {
Expand Down Expand Up @@ -149,7 +152,7 @@ void print_method_profiling_data() {
GrowableArray<Method*>* collected_invoked_methods;

void collect_invoked_methods(Method* m) {
if ((uint32_t)m->invocation_count() + m->compiled_invocation_count() >= 1) {
if (m->invocation_count() + m->compiled_invocation_count() >= 1) {
collected_invoked_methods->push(m);
}
}
Expand Down

0 comments on commit 5c27640

Please sign in to comment.