Skip to content

Commit 2e639dd

Browse files
committedJun 22, 2021
8267657: Add missing PrintC1Statistics before incrementing counters
Reviewed-by: iveresov
1 parent 1f0ea7c commit 2e639dd

File tree

7 files changed

+90
-35
lines changed

7 files changed

+90
-35
lines changed
 

‎src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,10 @@ void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
361361
ce->add_call_info_here(info());
362362

363363
#ifndef PRODUCT
364-
__ lea(rscratch2, ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
365-
__ incrementw(Address(rscratch2));
364+
if (PrintC1Statistics) {
365+
__ lea(rscratch2, ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
366+
__ incrementw(Address(rscratch2));
367+
}
366368
#endif
367369

368370
__ b(_continuation);

‎src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -491,12 +491,14 @@ void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
491491
ce->verify_oop_map(info());
492492

493493
#ifndef PRODUCT
494-
const address counter = (address)&Runtime1::_arraycopy_slowcase_cnt;
495-
const Register tmp = R3, tmp2 = R4;
496-
int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
497-
__ lwz(tmp2, simm16_offs, tmp);
498-
__ addi(tmp2, tmp2, 1);
499-
__ stw(tmp2, simm16_offs, tmp);
494+
if (PrintC1Statistics) {
495+
const address counter = (address)&Runtime1::_arraycopy_slowcase_cnt;
496+
const Register tmp = R3, tmp2 = R4;
497+
int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
498+
__ lwz(tmp2, simm16_offs, tmp);
499+
__ addi(tmp2, tmp2, 1);
500+
__ stw(tmp2, simm16_offs, tmp);
501+
}
500502
#endif
501503

502504
__ b(_continuation);

‎src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,10 @@ void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
454454
ce->verify_oop_map(info());
455455

456456
#ifndef PRODUCT
457-
__ load_const_optimized(Z_R1_scratch, (address)&Runtime1::_arraycopy_slowcase_cnt);
458-
__ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch);
457+
if (PrintC1Statistics) {
458+
__ load_const_optimized(Z_R1_scratch, (address)&Runtime1::_arraycopy_slowcase_cnt);
459+
__ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch);
460+
}
459461
#endif
460462

461463
__ branch_optimized(Assembler::bcondAlways, _continuation);

‎src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,9 @@ void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
543543
ce->add_call_info_here(info());
544544

545545
#ifndef PRODUCT
546-
__ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
546+
if (PrintC1Statistics) {
547+
__ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
548+
}
547549
#endif
548550

549551
__ jmp(_continuation);

‎src/hotspot/share/c1/c1_Runtime1.cpp

+70-17
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,11 @@ const char* Runtime1::name_for_address(address entry) {
348348

349349

350350
JRT_ENTRY(void, Runtime1::new_instance(JavaThread* current, Klass* klass))
351-
NOT_PRODUCT(_new_instance_slowcase_cnt++;)
352-
351+
#ifndef PRODUCT
352+
if (PrintC1Statistics) {
353+
_new_instance_slowcase_cnt++;
354+
}
355+
#endif
353356
assert(klass->is_klass(), "not a class");
354357
Handle holder(current, klass->klass_holder()); // keep the klass alive
355358
InstanceKlass* h = InstanceKlass::cast(klass);
@@ -363,7 +366,11 @@ JRT_END
363366

364367

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

382389

383390
JRT_ENTRY(void, Runtime1::new_object_array(JavaThread* current, Klass* array_klass, jint length))
384-
NOT_PRODUCT(_new_object_array_slowcase_cnt++;)
385-
391+
#ifndef PRODUCT
392+
if (PrintC1Statistics) {
393+
_new_object_array_slowcase_cnt++;
394+
}
395+
#endif
386396
// Note: no handle for klass needed since they are not used
387397
// anymore after new_objArray() and no GC can happen before.
388398
// (This may have to change if this code changes!)
@@ -400,8 +410,11 @@ JRT_END
400410

401411

402412
JRT_ENTRY(void, Runtime1::new_multi_array(JavaThread* current, Klass* klass, int rank, jint* dims))
403-
NOT_PRODUCT(_new_multi_array_slowcase_cnt++;)
404-
413+
#ifndef PRODUCT
414+
if (PrintC1Statistics) {
415+
_new_multi_array_slowcase_cnt++;
416+
}
417+
#endif
405418
assert(klass->is_klass(), "not a class");
406419
assert(rank >= 1, "rank must be nonzero");
407420
Handle holder(current, klass->klass_holder()); // keep the klass alive
@@ -653,7 +666,11 @@ address Runtime1::exception_handler_for_pc(JavaThread* current) {
653666

654667

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

664681

665682
JRT_ENTRY(void, Runtime1::throw_index_exception(JavaThread* current, int index))
666-
NOT_PRODUCT(_throw_index_exception_count++;)
683+
#ifndef PRODUCT
684+
if (PrintC1Statistics) {
685+
_throw_index_exception_count++;
686+
}
687+
#endif
667688
char message[16];
668689
sprintf(message, "%d", index);
669690
SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IndexOutOfBoundsException(), message);
670691
JRT_END
671692

672693

673694
JRT_ENTRY(void, Runtime1::throw_div0_exception(JavaThread* current))
674-
NOT_PRODUCT(_throw_div0_exception_count++;)
695+
#ifndef PRODUCT
696+
if (PrintC1Statistics) {
697+
_throw_div0_exception_count++;
698+
}
699+
#endif
675700
SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ArithmeticException(), "/ by zero");
676701
JRT_END
677702

678703

679704
JRT_ENTRY(void, Runtime1::throw_null_pointer_exception(JavaThread* current))
680-
NOT_PRODUCT(_throw_null_pointer_exception_count++;)
705+
#ifndef PRODUCT
706+
if (PrintC1Statistics) {
707+
_throw_null_pointer_exception_count++;
708+
}
709+
#endif
681710
SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_NullPointerException());
682711
JRT_END
683712

684713

685714
JRT_ENTRY(void, Runtime1::throw_class_cast_exception(JavaThread* current, oopDesc* object))
686-
NOT_PRODUCT(_throw_class_cast_exception_count++;)
715+
#ifndef PRODUCT
716+
if (PrintC1Statistics) {
717+
_throw_class_cast_exception_count++;
718+
}
719+
#endif
687720
ResourceMark rm(current);
688721
char* message = SharedRuntime::generate_class_cast_message(current, object->klass());
689722
SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ClassCastException(), message);
690723
JRT_END
691724

692725

693726
JRT_ENTRY(void, Runtime1::throw_incompatible_class_change_error(JavaThread* current))
694-
NOT_PRODUCT(_throw_incompatible_class_change_error_count++;)
727+
#ifndef PRODUCT
728+
if (PrintC1Statistics) {
729+
_throw_incompatible_class_change_error_count++;
730+
}
731+
#endif
695732
ResourceMark rm(current);
696733
SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IncompatibleClassChangeError());
697734
JRT_END
698735

699736

700737
JRT_BLOCK_ENTRY(void, Runtime1::monitorenter(JavaThread* current, oopDesc* obj, BasicObjectLock* lock))
701-
NOT_PRODUCT(_monitorenter_slowcase_cnt++;)
738+
#ifndef PRODUCT
739+
if (PrintC1Statistics) {
740+
_monitorenter_slowcase_cnt++;
741+
}
742+
#endif
702743
if (!UseFastLocking) {
703744
lock->set_obj(obj);
704745
}
@@ -708,7 +749,11 @@ JRT_END
708749

709750

710751
JRT_LEAF(void, Runtime1::monitorexit(JavaThread* current, BasicObjectLock* lock))
711-
NOT_PRODUCT(_monitorexit_slowcase_cnt++;)
752+
#ifndef PRODUCT
753+
if (PrintC1Statistics) {
754+
_monitorexit_slowcase_cnt++;
755+
}
756+
#endif
712757
assert(current->last_Java_sp(), "last_Java_sp must be set");
713758
oop obj = lock->obj();
714759
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
860905
// patch only naturally aligned words, as single, full-word writes.
861906

862907
JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_id ))
863-
NOT_PRODUCT(_patch_code_slowcase_cnt++;)
908+
#ifndef PRODUCT
909+
if (PrintC1Statistics) {
910+
_patch_code_slowcase_cnt++;
911+
}
912+
#endif
864913

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

12571306
void Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_id) {
1258-
NOT_PRODUCT(_patch_code_slowcase_cnt++);
1307+
#ifndef PRODUCT
1308+
if (PrintC1Statistics) {
1309+
_patch_code_slowcase_cnt++;
1310+
}
1311+
#endif
12591312

12601313
// Enable WXWrite: the function is called by c1 stub as a runtime function
12611314
// (see another implementation above).

‎src/hotspot/share/runtime/sharedRuntime.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ int SharedRuntime::_resolve_virtual_ctr = 0;
141141
int SharedRuntime::_resolve_opt_virtual_ctr = 0;
142142
int SharedRuntime::_implicit_null_throws = 0;
143143
int SharedRuntime::_implicit_div0_throws = 0;
144-
int SharedRuntime::_throw_null_ctr = 0;
145144

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

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

2161-
if (_throw_null_ctr) tty->print_cr("%5d implicit null throw", _throw_null_ctr);
2162-
21632159
SharedRuntime::print_ic_miss_histogram();
21642160

21652161
// Dump the JRT_ENTRY counters
21662162
if (_new_instance_ctr) tty->print_cr("%5d new instance requires GC", _new_instance_ctr);
21672163
if (_new_array_ctr) tty->print_cr("%5d new array requires GC", _new_array_ctr);
2168-
if (_multi1_ctr) tty->print_cr("%5d multianewarray 1 dim", _multi1_ctr);
21692164
if (_multi2_ctr) tty->print_cr("%5d multianewarray 2 dim", _multi2_ctr);
21702165
if (_multi3_ctr) tty->print_cr("%5d multianewarray 3 dim", _multi3_ctr);
21712166
if (_multi4_ctr) tty->print_cr("%5d multianewarray 4 dim", _multi4_ctr);

‎src/hotspot/share/runtime/sharedRuntime.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,6 @@ class SharedRuntime: AllStatic {
534534
static void trace_ic_miss(address at);
535535

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

556555
static int _new_instance_ctr; // 'new' object requires GC
557556
static int _new_array_ctr; // 'new' array requires GC
558-
static int _multi1_ctr, _multi2_ctr, _multi3_ctr, _multi4_ctr, _multi5_ctr;
557+
static int _multi2_ctr, _multi3_ctr, _multi4_ctr, _multi5_ctr;
559558
static int _find_handler_ctr; // find exception handler
560559
static int _rethrow_ctr; // rethrow exception
561560
static int _mon_enter_stub_ctr; // monitor enter stub

0 commit comments

Comments
 (0)
Please sign in to comment.