Skip to content
Permalink
Browse files
8267657: Add missing PrintC1Statistics before incrementing counters
Reviewed-by: iveresov
  • Loading branch information
Yi Yang committed Jun 22, 2021
1 parent 1f0ea7c commit 2e639dd34a4342de6e1b9470448d66ef89c4bd52
@@ -361,8 +361,10 @@ void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
ce->add_call_info_here(info());

#ifndef PRODUCT
__ lea(rscratch2, ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
__ incrementw(Address(rscratch2));
if (PrintC1Statistics) {
__ lea(rscratch2, ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
__ incrementw(Address(rscratch2));
}
#endif

__ b(_continuation);
@@ -491,12 +491,14 @@ void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
ce->verify_oop_map(info());

#ifndef PRODUCT
const address counter = (address)&Runtime1::_arraycopy_slowcase_cnt;
const Register tmp = R3, tmp2 = R4;
int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
__ lwz(tmp2, simm16_offs, tmp);
__ addi(tmp2, tmp2, 1);
__ stw(tmp2, simm16_offs, tmp);
if (PrintC1Statistics) {
const address counter = (address)&Runtime1::_arraycopy_slowcase_cnt;
const Register tmp = R3, tmp2 = R4;
int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
__ lwz(tmp2, simm16_offs, tmp);
__ addi(tmp2, tmp2, 1);
__ stw(tmp2, simm16_offs, tmp);
}
#endif

__ b(_continuation);
@@ -454,8 +454,10 @@ void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
ce->verify_oop_map(info());

#ifndef PRODUCT
__ load_const_optimized(Z_R1_scratch, (address)&Runtime1::_arraycopy_slowcase_cnt);
__ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch);
if (PrintC1Statistics) {
__ load_const_optimized(Z_R1_scratch, (address)&Runtime1::_arraycopy_slowcase_cnt);
__ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch);
}
#endif

__ branch_optimized(Assembler::bcondAlways, _continuation);
@@ -543,7 +543,9 @@ void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
ce->add_call_info_here(info());

#ifndef PRODUCT
__ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
if (PrintC1Statistics) {
__ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
}
#endif

__ jmp(_continuation);
@@ -348,8 +348,11 @@ const char* Runtime1::name_for_address(address entry) {


JRT_ENTRY(void, Runtime1::new_instance(JavaThread* current, Klass* klass))
NOT_PRODUCT(_new_instance_slowcase_cnt++;)

#ifndef PRODUCT
if (PrintC1Statistics) {
_new_instance_slowcase_cnt++;
}
#endif
assert(klass->is_klass(), "not a class");
Handle holder(current, klass->klass_holder()); // keep the klass alive
InstanceKlass* h = InstanceKlass::cast(klass);
@@ -363,7 +366,11 @@ JRT_END


JRT_ENTRY(void, Runtime1::new_type_array(JavaThread* current, Klass* klass, jint length))
NOT_PRODUCT(_new_type_array_slowcase_cnt++;)
#ifndef PRODUCT
if (PrintC1Statistics) {
_new_type_array_slowcase_cnt++;
}
#endif
// Note: no handle for klass needed since they are not used
// anymore after new_typeArray() and no GC can happen before.
// (This may have to change if this code changes!)
@@ -381,8 +388,11 @@ JRT_END


JRT_ENTRY(void, Runtime1::new_object_array(JavaThread* current, Klass* array_klass, jint length))
NOT_PRODUCT(_new_object_array_slowcase_cnt++;)

#ifndef PRODUCT
if (PrintC1Statistics) {
_new_object_array_slowcase_cnt++;
}
#endif
// Note: no handle for klass needed since they are not used
// anymore after new_objArray() and no GC can happen before.
// (This may have to change if this code changes!)
@@ -400,8 +410,11 @@ JRT_END


JRT_ENTRY(void, Runtime1::new_multi_array(JavaThread* current, Klass* klass, int rank, jint* dims))
NOT_PRODUCT(_new_multi_array_slowcase_cnt++;)

#ifndef PRODUCT
if (PrintC1Statistics) {
_new_multi_array_slowcase_cnt++;
}
#endif
assert(klass->is_klass(), "not a class");
assert(rank >= 1, "rank must be nonzero");
Handle holder(current, klass->klass_holder()); // keep the klass alive
@@ -653,7 +666,11 @@ address Runtime1::exception_handler_for_pc(JavaThread* current) {


JRT_ENTRY(void, Runtime1::throw_range_check_exception(JavaThread* current, int index, arrayOopDesc* a))
NOT_PRODUCT(_throw_range_check_exception_count++;)
#ifndef PRODUCT
if (PrintC1Statistics) {
_throw_range_check_exception_count++;
}
#endif
const int len = 35;
assert(len < strlen("Index %d out of bounds for length %d"), "Must allocate more space for message.");
char message[2 * jintAsStringSize + len];
@@ -663,42 +680,66 @@ JRT_END


JRT_ENTRY(void, Runtime1::throw_index_exception(JavaThread* current, int index))
NOT_PRODUCT(_throw_index_exception_count++;)
#ifndef PRODUCT
if (PrintC1Statistics) {
_throw_index_exception_count++;
}
#endif
char message[16];
sprintf(message, "%d", index);
SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IndexOutOfBoundsException(), message);
JRT_END


JRT_ENTRY(void, Runtime1::throw_div0_exception(JavaThread* current))
NOT_PRODUCT(_throw_div0_exception_count++;)
#ifndef PRODUCT
if (PrintC1Statistics) {
_throw_div0_exception_count++;
}
#endif
SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ArithmeticException(), "/ by zero");
JRT_END


JRT_ENTRY(void, Runtime1::throw_null_pointer_exception(JavaThread* current))
NOT_PRODUCT(_throw_null_pointer_exception_count++;)
#ifndef PRODUCT
if (PrintC1Statistics) {
_throw_null_pointer_exception_count++;
}
#endif
SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_NullPointerException());
JRT_END


JRT_ENTRY(void, Runtime1::throw_class_cast_exception(JavaThread* current, oopDesc* object))
NOT_PRODUCT(_throw_class_cast_exception_count++;)
#ifndef PRODUCT
if (PrintC1Statistics) {
_throw_class_cast_exception_count++;
}
#endif
ResourceMark rm(current);
char* message = SharedRuntime::generate_class_cast_message(current, object->klass());
SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ClassCastException(), message);
JRT_END


JRT_ENTRY(void, Runtime1::throw_incompatible_class_change_error(JavaThread* current))
NOT_PRODUCT(_throw_incompatible_class_change_error_count++;)
#ifndef PRODUCT
if (PrintC1Statistics) {
_throw_incompatible_class_change_error_count++;
}
#endif
ResourceMark rm(current);
SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IncompatibleClassChangeError());
JRT_END


JRT_BLOCK_ENTRY(void, Runtime1::monitorenter(JavaThread* current, oopDesc* obj, BasicObjectLock* lock))
NOT_PRODUCT(_monitorenter_slowcase_cnt++;)
#ifndef PRODUCT
if (PrintC1Statistics) {
_monitorenter_slowcase_cnt++;
}
#endif
if (!UseFastLocking) {
lock->set_obj(obj);
}
@@ -708,7 +749,11 @@ JRT_END


JRT_LEAF(void, Runtime1::monitorexit(JavaThread* current, BasicObjectLock* lock))
NOT_PRODUCT(_monitorexit_slowcase_cnt++;)
#ifndef PRODUCT
if (PrintC1Statistics) {
_monitorexit_slowcase_cnt++;
}
#endif
assert(current->last_Java_sp(), "last_Java_sp must be set");
oop obj = lock->obj();
assert(oopDesc::is_oop(obj), "must be NULL or an object");
@@ -860,7 +905,11 @@ static Klass* resolve_field_return_klass(const methodHandle& caller, int bci, TR
// patch only naturally aligned words, as single, full-word writes.

JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_id ))
NOT_PRODUCT(_patch_code_slowcase_cnt++;)
#ifndef PRODUCT
if (PrintC1Statistics) {
_patch_code_slowcase_cnt++;
}
#endif

ResourceMark rm(current);
RegisterMap reg_map(current, false);
@@ -1255,7 +1304,11 @@ JRT_END
#else // DEOPTIMIZE_WHEN_PATCHING

void Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_id) {
NOT_PRODUCT(_patch_code_slowcase_cnt++);
#ifndef PRODUCT
if (PrintC1Statistics) {
_patch_code_slowcase_cnt++;
}
#endif

// Enable WXWrite: the function is called by c1 stub as a runtime function
// (see another implementation above).
@@ -141,7 +141,6 @@ int SharedRuntime::_resolve_virtual_ctr = 0;
int SharedRuntime::_resolve_opt_virtual_ctr = 0;
int SharedRuntime::_implicit_null_throws = 0;
int SharedRuntime::_implicit_div0_throws = 0;
int SharedRuntime::_throw_null_ctr = 0;

int64_t SharedRuntime::_nof_normal_calls = 0;
int64_t SharedRuntime::_nof_optimized_calls = 0;
@@ -156,7 +155,6 @@ int64_t SharedRuntime::_nof_megamorphic_interface_calls = 0;

int SharedRuntime::_new_instance_ctr=0;
int SharedRuntime::_new_array_ctr=0;
int SharedRuntime::_multi1_ctr=0;
int SharedRuntime::_multi2_ctr=0;
int SharedRuntime::_multi3_ctr=0;
int SharedRuntime::_multi4_ctr=0;
@@ -2158,14 +2156,11 @@ void SharedRuntime::print_statistics() {
ttyLocker ttyl;
if (xtty != NULL) xtty->head("statistics type='SharedRuntime'");

if (_throw_null_ctr) tty->print_cr("%5d implicit null throw", _throw_null_ctr);

SharedRuntime::print_ic_miss_histogram();

// Dump the JRT_ENTRY counters
if (_new_instance_ctr) tty->print_cr("%5d new instance requires GC", _new_instance_ctr);
if (_new_array_ctr) tty->print_cr("%5d new array requires GC", _new_array_ctr);
if (_multi1_ctr) tty->print_cr("%5d multianewarray 1 dim", _multi1_ctr);
if (_multi2_ctr) tty->print_cr("%5d multianewarray 2 dim", _multi2_ctr);
if (_multi3_ctr) tty->print_cr("%5d multianewarray 3 dim", _multi3_ctr);
if (_multi4_ctr) tty->print_cr("%5d multianewarray 4 dim", _multi4_ctr);
@@ -534,7 +534,6 @@ class SharedRuntime: AllStatic {
static void trace_ic_miss(address at);

public:
static int _throw_null_ctr; // throwing a null-pointer exception
static int _ic_miss_ctr; // total # of IC misses
static int _wrong_method_ctr;
static int _resolve_static_ctr;
@@ -555,7 +554,7 @@ class SharedRuntime: AllStatic {

static int _new_instance_ctr; // 'new' object requires GC
static int _new_array_ctr; // 'new' array requires GC
static int _multi1_ctr, _multi2_ctr, _multi3_ctr, _multi4_ctr, _multi5_ctr;
static int _multi2_ctr, _multi3_ctr, _multi4_ctr, _multi5_ctr;
static int _find_handler_ctr; // find exception handler
static int _rethrow_ctr; // rethrow exception
static int _mon_enter_stub_ctr; // monitor enter stub

1 comment on commit 2e639dd

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 2e639dd Jun 22, 2021

Please sign in to comment.