From d0761c19d1ddafbcb5ea97334335462e716de250 Mon Sep 17 00:00:00 2001 From: Dean Long Date: Mon, 24 Jul 2023 20:40:08 +0000 Subject: [PATCH] 8312077: Fix signed integer overflow, final part Reviewed-by: kvn, amitkumar --- .../cpu/aarch64/stubGenerator_aarch64.cpp | 2 +- src/hotspot/cpu/arm/macroAssembler_arm.hpp | 2 +- src/hotspot/cpu/arm/stubGenerator_arm.cpp | 4 +- src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 2 +- src/hotspot/cpu/x86/macroAssembler_x86.cpp | 2 +- src/hotspot/cpu/x86/stubGenerator_x86_32.cpp | 2 +- .../x86/stubGenerator_x86_64_arraycopy.cpp | 4 +- src/hotspot/share/c1/c1_Compilation.cpp | 2 +- src/hotspot/share/c1/c1_GraphBuilder.cpp | 2 +- src/hotspot/share/c1/c1_Runtime1.cpp | 102 +++++++-------- src/hotspot/share/c1/c1_Runtime1.hpp | 36 +++--- src/hotspot/share/classfile/vmSymbols.cpp | 2 +- src/hotspot/share/code/nmethod.cpp | 104 +++++++-------- .../share/compiler/abstractCompiler.hpp | 10 +- src/hotspot/share/compiler/compileBroker.cpp | 64 +++++----- src/hotspot/share/compiler/compileBroker.hpp | 24 ++-- .../periodic/sampling/jfrThreadSampler.cpp | 6 +- src/hotspot/share/opto/c2_globals.hpp | 2 +- src/hotspot/share/opto/graphKit.cpp | 4 +- src/hotspot/share/opto/ifnode.cpp | 2 +- src/hotspot/share/opto/indexSet.cpp | 2 +- src/hotspot/share/opto/indexSet.hpp | 12 +- src/hotspot/share/opto/lcm.cpp | 2 +- src/hotspot/share/opto/matcher.cpp | 2 +- src/hotspot/share/opto/mulnode.cpp | 12 +- src/hotspot/share/opto/node.cpp | 2 +- src/hotspot/share/opto/parse1.cpp | 30 ++--- src/hotspot/share/opto/parse2.cpp | 4 +- src/hotspot/share/opto/parse3.cpp | 7 +- src/hotspot/share/runtime/sharedRuntime.cpp | 118 +++++++++--------- src/hotspot/share/runtime/sharedRuntime.hpp | 52 ++++---- 31 files changed, 313 insertions(+), 308 deletions(-) diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp index c30234aae38..c08b3c420d7 100644 --- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp @@ -83,7 +83,7 @@ class StubGenerator: public StubCodeGenerator { #ifdef PRODUCT #define inc_counter_np(counter) ((void)0) #else - void inc_counter_np_(int& counter) { + void inc_counter_np_(uint& counter) { __ lea(rscratch2, ExternalAddress((address)&counter)); __ ldrw(rscratch1, Address(rscratch2)); __ addw(rscratch1, rscratch1, 1); diff --git a/src/hotspot/cpu/arm/macroAssembler_arm.hpp b/src/hotspot/cpu/arm/macroAssembler_arm.hpp index 359ad93b91b..7a9724d201c 100644 --- a/src/hotspot/cpu/arm/macroAssembler_arm.hpp +++ b/src/hotspot/cpu/arm/macroAssembler_arm.hpp @@ -1035,7 +1035,7 @@ public: // unconditional non-atomic increment void inc_counter(address counter_addr, Register tmpreg1, Register tmpreg2); - void inc_counter(int* counter_addr, Register tmpreg1, Register tmpreg2) { + void inc_counter(uint* counter_addr, Register tmpreg1, Register tmpreg2) { inc_counter((address) counter_addr, tmpreg1, tmpreg2); } diff --git a/src/hotspot/cpu/arm/stubGenerator_arm.cpp b/src/hotspot/cpu/arm/stubGenerator_arm.cpp index fe01d5f3fa5..6e5484c98cb 100644 --- a/src/hotspot/cpu/arm/stubGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/stubGenerator_arm.cpp @@ -1962,7 +1962,7 @@ class StubGenerator: public StubCodeGenerator { } #ifndef PRODUCT - int * get_arraycopy_counter(int bytes_per_count) { + uint * get_arraycopy_counter(int bytes_per_count) { switch (bytes_per_count) { case 1: return &SharedRuntime::_jbyte_array_copy_ctr; @@ -2383,7 +2383,7 @@ class StubGenerator: public StubCodeGenerator { // Do a linear scan of the secondary super-klass chain. #ifndef PRODUCT - int* pst_counter = &SharedRuntime::_partial_subtype_ctr; + uint* pst_counter = &SharedRuntime::_partial_subtype_ctr; __ inc_counter((address) pst_counter, tmp1, tmp2); #endif diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index 811cc9575ee..98d94ccd15b 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -75,7 +75,7 @@ class StubGenerator: public StubCodeGenerator { #ifdef PRODUCT #define inc_counter_np(counter) ((void)0) #else - void inc_counter_np_(int& counter) { + void inc_counter_np_(uint& counter) { __ la(t1, ExternalAddress((address)&counter)); __ lwu(t0, Address(t1, 0)); __ addiw(t0, t0, 1); diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index 767a8618c40..709818f391e 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -4576,7 +4576,7 @@ void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass, if (!IS_A_TEMP(rdi)) { push(rdi); pushed_rdi = true; } #ifndef PRODUCT - int* pst_counter = &SharedRuntime::_partial_subtype_ctr; + uint* pst_counter = &SharedRuntime::_partial_subtype_ctr; ExternalAddress pst_counter_addr((address) pst_counter); NOT_LP64( incrementl(pst_counter_addr) ); LP64_ONLY( lea(rcx, pst_counter_addr) ); diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp index 41294a4f207..fb08c4fb167 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp @@ -90,7 +90,7 @@ class StubGenerator: public StubCodeGenerator { #ifdef PRODUCT #define inc_counter_np(counter) ((void)0) #else - void inc_counter_np_(int& counter) { + void inc_counter_np_(uint& counter) { __ incrementl(ExternalAddress((address)&counter)); } #define inc_counter_np(counter) \ diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp index 5493999cfea..80d9b4844ea 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp @@ -56,12 +56,12 @@ BLOCK_COMMENT("inc_counter " #counter); \ inc_counter_np(_masm, counter, rscratch); -static void inc_counter_np(MacroAssembler* _masm, int& counter, Register rscratch) { +static void inc_counter_np(MacroAssembler* _masm, uint& counter, Register rscratch) { __ incrementl(ExternalAddress((address)&counter), rscratch); } #if COMPILER2_OR_JVMCI -static int& get_profile_ctr(int shift) { +static uint& get_profile_ctr(int shift) { if (shift == 0) { return SharedRuntime::_jbyte_array_copy_ctr; } else if (shift == 1) { diff --git a/src/hotspot/share/c1/c1_Compilation.cpp b/src/hotspot/share/c1/c1_Compilation.cpp index 89885dede7e..ed7519febe8 100644 --- a/src/hotspot/share/c1/c1_Compilation.cpp +++ b/src/hotspot/share/c1/c1_Compilation.cpp @@ -73,7 +73,7 @@ static const char * timer_name[] = { }; static elapsedTimer timers[max_phase_timers]; -static int totalInstructionNodes = 0; +static uint totalInstructionNodes = 0; class PhaseTraceTime: public TraceTime { private: diff --git a/src/hotspot/share/c1/c1_GraphBuilder.cpp b/src/hotspot/share/c1/c1_GraphBuilder.cpp index 37f1fcbe831..a51d5e3608a 100644 --- a/src/hotspot/share/c1/c1_GraphBuilder.cpp +++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp @@ -1246,7 +1246,7 @@ void GraphBuilder::shift_op(ValueType* type, Bytecodes::Code code) { } else { // pattern: (a << s0c) >>> s0c => simplify to: a & m, with m constant assert(0 < s0c && s0c < BitsPerInt, "adjust code below to handle corner cases"); - const int m = (1 << (BitsPerInt - s0c)) - 1; + const int m = checked_cast(right_n_bits(BitsPerInt - s0c)); Value s = append(new Constant(new IntConstant(m))); ipush(append(new LogicOp(Bytecodes::_iand, l->x(), s))); } diff --git a/src/hotspot/share/c1/c1_Runtime1.cpp b/src/hotspot/share/c1/c1_Runtime1.cpp index 41a6b151b28..f815aef9bdd 100644 --- a/src/hotspot/share/c1/c1_Runtime1.cpp +++ b/src/hotspot/share/c1/c1_Runtime1.cpp @@ -116,30 +116,30 @@ const char *Runtime1::_blob_names[] = { #ifndef PRODUCT // statistics -int Runtime1::_generic_arraycopystub_cnt = 0; -int Runtime1::_arraycopy_slowcase_cnt = 0; -int Runtime1::_arraycopy_checkcast_cnt = 0; -int Runtime1::_arraycopy_checkcast_attempt_cnt = 0; -int Runtime1::_new_type_array_slowcase_cnt = 0; -int Runtime1::_new_object_array_slowcase_cnt = 0; -int Runtime1::_new_instance_slowcase_cnt = 0; -int Runtime1::_new_multi_array_slowcase_cnt = 0; -int Runtime1::_monitorenter_slowcase_cnt = 0; -int Runtime1::_monitorexit_slowcase_cnt = 0; -int Runtime1::_patch_code_slowcase_cnt = 0; -int Runtime1::_throw_range_check_exception_count = 0; -int Runtime1::_throw_index_exception_count = 0; -int Runtime1::_throw_div0_exception_count = 0; -int Runtime1::_throw_null_pointer_exception_count = 0; -int Runtime1::_throw_class_cast_exception_count = 0; -int Runtime1::_throw_incompatible_class_change_error_count = 0; -int Runtime1::_throw_count = 0; +uint Runtime1::_generic_arraycopystub_cnt = 0; +uint Runtime1::_arraycopy_slowcase_cnt = 0; +uint Runtime1::_arraycopy_checkcast_cnt = 0; +uint Runtime1::_arraycopy_checkcast_attempt_cnt = 0; +uint Runtime1::_new_type_array_slowcase_cnt = 0; +uint Runtime1::_new_object_array_slowcase_cnt = 0; +uint Runtime1::_new_instance_slowcase_cnt = 0; +uint Runtime1::_new_multi_array_slowcase_cnt = 0; +uint Runtime1::_monitorenter_slowcase_cnt = 0; +uint Runtime1::_monitorexit_slowcase_cnt = 0; +uint Runtime1::_patch_code_slowcase_cnt = 0; +uint Runtime1::_throw_range_check_exception_count = 0; +uint Runtime1::_throw_index_exception_count = 0; +uint Runtime1::_throw_div0_exception_count = 0; +uint Runtime1::_throw_null_pointer_exception_count = 0; +uint Runtime1::_throw_class_cast_exception_count = 0; +uint Runtime1::_throw_incompatible_class_change_error_count = 0; +uint Runtime1::_throw_count = 0; -static int _byte_arraycopy_stub_cnt = 0; -static int _short_arraycopy_stub_cnt = 0; -static int _int_arraycopy_stub_cnt = 0; -static int _long_arraycopy_stub_cnt = 0; -static int _oop_arraycopy_stub_cnt = 0; +static uint _byte_arraycopy_stub_cnt = 0; +static uint _short_arraycopy_stub_cnt = 0; +static uint _int_arraycopy_stub_cnt = 0; +static uint _long_arraycopy_stub_cnt = 0; +static uint _oop_arraycopy_stub_cnt = 0; address Runtime1::arraycopy_count_address(BasicType type) { switch (type) { @@ -1520,36 +1520,36 @@ JRT_END #ifndef PRODUCT void Runtime1::print_statistics() { tty->print_cr("C1 Runtime statistics:"); - tty->print_cr(" _resolve_invoke_virtual_cnt: %d", SharedRuntime::_resolve_virtual_ctr); - tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr); - tty->print_cr(" _resolve_invoke_static_cnt: %d", SharedRuntime::_resolve_static_ctr); - tty->print_cr(" _handle_wrong_method_cnt: %d", SharedRuntime::_wrong_method_ctr); - tty->print_cr(" _ic_miss_cnt: %d", SharedRuntime::_ic_miss_ctr); - tty->print_cr(" _generic_arraycopystub_cnt: %d", _generic_arraycopystub_cnt); - tty->print_cr(" _byte_arraycopy_cnt: %d", _byte_arraycopy_stub_cnt); - tty->print_cr(" _short_arraycopy_cnt: %d", _short_arraycopy_stub_cnt); - tty->print_cr(" _int_arraycopy_cnt: %d", _int_arraycopy_stub_cnt); - tty->print_cr(" _long_arraycopy_cnt: %d", _long_arraycopy_stub_cnt); - tty->print_cr(" _oop_arraycopy_cnt: %d", _oop_arraycopy_stub_cnt); - tty->print_cr(" _arraycopy_slowcase_cnt: %d", _arraycopy_slowcase_cnt); - tty->print_cr(" _arraycopy_checkcast_cnt: %d", _arraycopy_checkcast_cnt); - tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%d", _arraycopy_checkcast_attempt_cnt); + tty->print_cr(" _resolve_invoke_virtual_cnt: %u", SharedRuntime::_resolve_virtual_ctr); + tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %u", SharedRuntime::_resolve_opt_virtual_ctr); + tty->print_cr(" _resolve_invoke_static_cnt: %u", SharedRuntime::_resolve_static_ctr); + tty->print_cr(" _handle_wrong_method_cnt: %u", SharedRuntime::_wrong_method_ctr); + tty->print_cr(" _ic_miss_cnt: %u", SharedRuntime::_ic_miss_ctr); + tty->print_cr(" _generic_arraycopystub_cnt: %u", _generic_arraycopystub_cnt); + tty->print_cr(" _byte_arraycopy_cnt: %u", _byte_arraycopy_stub_cnt); + tty->print_cr(" _short_arraycopy_cnt: %u", _short_arraycopy_stub_cnt); + tty->print_cr(" _int_arraycopy_cnt: %u", _int_arraycopy_stub_cnt); + tty->print_cr(" _long_arraycopy_cnt: %u", _long_arraycopy_stub_cnt); + tty->print_cr(" _oop_arraycopy_cnt: %u", _oop_arraycopy_stub_cnt); + tty->print_cr(" _arraycopy_slowcase_cnt: %u", _arraycopy_slowcase_cnt); + tty->print_cr(" _arraycopy_checkcast_cnt: %u", _arraycopy_checkcast_cnt); + tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%u", _arraycopy_checkcast_attempt_cnt); - tty->print_cr(" _new_type_array_slowcase_cnt: %d", _new_type_array_slowcase_cnt); - tty->print_cr(" _new_object_array_slowcase_cnt: %d", _new_object_array_slowcase_cnt); - tty->print_cr(" _new_instance_slowcase_cnt: %d", _new_instance_slowcase_cnt); - tty->print_cr(" _new_multi_array_slowcase_cnt: %d", _new_multi_array_slowcase_cnt); - tty->print_cr(" _monitorenter_slowcase_cnt: %d", _monitorenter_slowcase_cnt); - tty->print_cr(" _monitorexit_slowcase_cnt: %d", _monitorexit_slowcase_cnt); - tty->print_cr(" _patch_code_slowcase_cnt: %d", _patch_code_slowcase_cnt); + tty->print_cr(" _new_type_array_slowcase_cnt: %u", _new_type_array_slowcase_cnt); + tty->print_cr(" _new_object_array_slowcase_cnt: %u", _new_object_array_slowcase_cnt); + tty->print_cr(" _new_instance_slowcase_cnt: %u", _new_instance_slowcase_cnt); + tty->print_cr(" _new_multi_array_slowcase_cnt: %u", _new_multi_array_slowcase_cnt); + tty->print_cr(" _monitorenter_slowcase_cnt: %u", _monitorenter_slowcase_cnt); + tty->print_cr(" _monitorexit_slowcase_cnt: %u", _monitorexit_slowcase_cnt); + tty->print_cr(" _patch_code_slowcase_cnt: %u", _patch_code_slowcase_cnt); - tty->print_cr(" _throw_range_check_exception_count: %d:", _throw_range_check_exception_count); - tty->print_cr(" _throw_index_exception_count: %d:", _throw_index_exception_count); - tty->print_cr(" _throw_div0_exception_count: %d:", _throw_div0_exception_count); - tty->print_cr(" _throw_null_pointer_exception_count: %d:", _throw_null_pointer_exception_count); - tty->print_cr(" _throw_class_cast_exception_count: %d:", _throw_class_cast_exception_count); - tty->print_cr(" _throw_incompatible_class_change_error_count: %d:", _throw_incompatible_class_change_error_count); - tty->print_cr(" _throw_count: %d:", _throw_count); + tty->print_cr(" _throw_range_check_exception_count: %u:", _throw_range_check_exception_count); + tty->print_cr(" _throw_index_exception_count: %u:", _throw_index_exception_count); + tty->print_cr(" _throw_div0_exception_count: %u:", _throw_div0_exception_count); + tty->print_cr(" _throw_null_pointer_exception_count: %u:", _throw_null_pointer_exception_count); + tty->print_cr(" _throw_class_cast_exception_count: %u:", _throw_class_cast_exception_count); + tty->print_cr(" _throw_incompatible_class_change_error_count: %u:", _throw_incompatible_class_change_error_count); + tty->print_cr(" _throw_count: %u:", _throw_count); SharedRuntime::print_ic_miss_histogram(); tty->cr(); diff --git a/src/hotspot/share/c1/c1_Runtime1.hpp b/src/hotspot/share/c1/c1_Runtime1.hpp index 525cfd7f92e..2e4c9f8a733 100644 --- a/src/hotspot/share/c1/c1_Runtime1.hpp +++ b/src/hotspot/share/c1/c1_Runtime1.hpp @@ -94,24 +94,24 @@ class Runtime1: public AllStatic { // statistics #ifndef PRODUCT - static int _generic_arraycopystub_cnt; - static int _arraycopy_slowcase_cnt; - static int _arraycopy_checkcast_cnt; - static int _arraycopy_checkcast_attempt_cnt; - static int _new_type_array_slowcase_cnt; - static int _new_object_array_slowcase_cnt; - static int _new_instance_slowcase_cnt; - static int _new_multi_array_slowcase_cnt; - static int _monitorenter_slowcase_cnt; - static int _monitorexit_slowcase_cnt; - static int _patch_code_slowcase_cnt; - static int _throw_range_check_exception_count; - static int _throw_index_exception_count; - static int _throw_div0_exception_count; - static int _throw_null_pointer_exception_count; - static int _throw_class_cast_exception_count; - static int _throw_incompatible_class_change_error_count; - static int _throw_count; + static uint _generic_arraycopystub_cnt; + static uint _arraycopy_slowcase_cnt; + static uint _arraycopy_checkcast_cnt; + static uint _arraycopy_checkcast_attempt_cnt; + static uint _new_type_array_slowcase_cnt; + static uint _new_object_array_slowcase_cnt; + static uint _new_instance_slowcase_cnt; + static uint _new_multi_array_slowcase_cnt; + static uint _monitorenter_slowcase_cnt; + static uint _monitorexit_slowcase_cnt; + static uint _patch_code_slowcase_cnt; + static uint _throw_range_check_exception_count; + static uint _throw_index_exception_count; + static uint _throw_div0_exception_count; + static uint _throw_null_pointer_exception_count; + static uint _throw_class_cast_exception_count; + static uint _throw_incompatible_class_change_error_count; + static uint _throw_count; #endif private: diff --git a/src/hotspot/share/classfile/vmSymbols.cpp b/src/hotspot/share/classfile/vmSymbols.cpp index 955302fa38e..36cfca83dd8 100644 --- a/src/hotspot/share/classfile/vmSymbols.cpp +++ b/src/hotspot/share/classfile/vmSymbols.cpp @@ -212,7 +212,7 @@ void vmSymbols::serialize(SerializeClosure* soc) { } #ifndef PRODUCT -static int find_sid_calls, find_sid_probes; +static uint find_sid_calls, find_sid_probes; // (Typical counts are calls=7000 and probes=17000.) #endif diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index efa6317c4f3..4bfc0440d10 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -119,23 +119,23 @@ // These variables are put into one block to reduce relocations // and make it simpler to print from the debugger. struct java_nmethod_stats_struct { - int nmethod_count; - int total_size; - int relocation_size; - int consts_size; - int insts_size; - int stub_size; - int scopes_data_size; - int scopes_pcs_size; - int dependencies_size; - int handler_table_size; - int nul_chk_table_size; + uint nmethod_count; + uint total_size; + uint relocation_size; + uint consts_size; + uint insts_size; + uint stub_size; + uint scopes_data_size; + uint scopes_pcs_size; + uint dependencies_size; + uint handler_table_size; + uint nul_chk_table_size; #if INCLUDE_JVMCI - int speculations_size; - int jvmci_data_size; + uint speculations_size; + uint jvmci_data_size; #endif - int oops_size; - int metadata_size; + uint oops_size; + uint metadata_size; void note_nmethod(nmethod* nm) { nmethod_count += 1; @@ -158,34 +158,34 @@ struct java_nmethod_stats_struct { } void print_nmethod_stats(const char* name) { if (nmethod_count == 0) return; - tty->print_cr("Statistics for %d bytecoded nmethods for %s:", nmethod_count, name); - if (total_size != 0) tty->print_cr(" total in heap = %d", total_size); + tty->print_cr("Statistics for %u bytecoded nmethods for %s:", nmethod_count, name); + if (total_size != 0) tty->print_cr(" total in heap = %u", total_size); if (nmethod_count != 0) tty->print_cr(" header = " SIZE_FORMAT, nmethod_count * sizeof(nmethod)); - if (relocation_size != 0) tty->print_cr(" relocation = %d", relocation_size); - if (consts_size != 0) tty->print_cr(" constants = %d", consts_size); - if (insts_size != 0) tty->print_cr(" main code = %d", insts_size); - if (stub_size != 0) tty->print_cr(" stub code = %d", stub_size); - if (oops_size != 0) tty->print_cr(" oops = %d", oops_size); - if (metadata_size != 0) tty->print_cr(" metadata = %d", metadata_size); - if (scopes_data_size != 0) tty->print_cr(" scopes data = %d", scopes_data_size); - if (scopes_pcs_size != 0) tty->print_cr(" scopes pcs = %d", scopes_pcs_size); - if (dependencies_size != 0) tty->print_cr(" dependencies = %d", dependencies_size); - if (handler_table_size != 0) tty->print_cr(" handler table = %d", handler_table_size); - if (nul_chk_table_size != 0) tty->print_cr(" nul chk table = %d", nul_chk_table_size); + if (relocation_size != 0) tty->print_cr(" relocation = %u", relocation_size); + if (consts_size != 0) tty->print_cr(" constants = %u", consts_size); + if (insts_size != 0) tty->print_cr(" main code = %u", insts_size); + if (stub_size != 0) tty->print_cr(" stub code = %u", stub_size); + if (oops_size != 0) tty->print_cr(" oops = %u", oops_size); + if (metadata_size != 0) tty->print_cr(" metadata = %u", metadata_size); + if (scopes_data_size != 0) tty->print_cr(" scopes data = %u", scopes_data_size); + if (scopes_pcs_size != 0) tty->print_cr(" scopes pcs = %u", scopes_pcs_size); + if (dependencies_size != 0) tty->print_cr(" dependencies = %u", dependencies_size); + if (handler_table_size != 0) tty->print_cr(" handler table = %u", handler_table_size); + if (nul_chk_table_size != 0) tty->print_cr(" nul chk table = %u", nul_chk_table_size); #if INCLUDE_JVMCI - if (speculations_size != 0) tty->print_cr(" speculations = %d", speculations_size); - if (jvmci_data_size != 0) tty->print_cr(" JVMCI data = %d", jvmci_data_size); + if (speculations_size != 0) tty->print_cr(" speculations = %u", speculations_size); + if (jvmci_data_size != 0) tty->print_cr(" JVMCI data = %u", jvmci_data_size); #endif } }; struct native_nmethod_stats_struct { - int native_nmethod_count; - int native_total_size; - int native_relocation_size; - int native_insts_size; - int native_oops_size; - int native_metadata_size; + uint native_nmethod_count; + uint native_total_size; + uint native_relocation_size; + uint native_insts_size; + uint native_oops_size; + uint native_metadata_size; void note_native_nmethod(nmethod* nm) { native_nmethod_count += 1; native_total_size += nm->size(); @@ -196,31 +196,31 @@ struct native_nmethod_stats_struct { } void print_native_nmethod_stats() { if (native_nmethod_count == 0) return; - tty->print_cr("Statistics for %d native nmethods:", native_nmethod_count); - if (native_total_size != 0) tty->print_cr(" N. total size = %d", native_total_size); - if (native_relocation_size != 0) tty->print_cr(" N. relocation = %d", native_relocation_size); - if (native_insts_size != 0) tty->print_cr(" N. main code = %d", native_insts_size); - if (native_oops_size != 0) tty->print_cr(" N. oops = %d", native_oops_size); - if (native_metadata_size != 0) tty->print_cr(" N. metadata = %d", native_metadata_size); + tty->print_cr("Statistics for %u native nmethods:", native_nmethod_count); + if (native_total_size != 0) tty->print_cr(" N. total size = %u", native_total_size); + if (native_relocation_size != 0) tty->print_cr(" N. relocation = %u", native_relocation_size); + if (native_insts_size != 0) tty->print_cr(" N. main code = %u", native_insts_size); + if (native_oops_size != 0) tty->print_cr(" N. oops = %u", native_oops_size); + if (native_metadata_size != 0) tty->print_cr(" N. metadata = %u", native_metadata_size); } }; struct pc_nmethod_stats_struct { - int pc_desc_resets; // number of resets (= number of caches) - int pc_desc_queries; // queries to nmethod::find_pc_desc - int pc_desc_approx; // number of those which have approximate true - int pc_desc_repeats; // number of _pc_descs[0] hits - int pc_desc_hits; // number of LRU cache hits - int pc_desc_tests; // total number of PcDesc examinations - int pc_desc_searches; // total number of quasi-binary search steps - int pc_desc_adds; // number of LUR cache insertions + uint pc_desc_resets; // number of resets (= number of caches) + uint pc_desc_queries; // queries to nmethod::find_pc_desc + uint pc_desc_approx; // number of those which have approximate true + uint pc_desc_repeats; // number of _pc_descs[0] hits + uint pc_desc_hits; // number of LRU cache hits + uint pc_desc_tests; // total number of PcDesc examinations + uint pc_desc_searches; // total number of quasi-binary search steps + uint pc_desc_adds; // number of LUR cache insertions void print_pc_stats() { - tty->print_cr("PcDesc Statistics: %d queries, %.2f comparisons per query", + tty->print_cr("PcDesc Statistics: %u queries, %.2f comparisons per query", pc_desc_queries, (double)(pc_desc_tests + pc_desc_searches) / pc_desc_queries); - tty->print_cr(" caches=%d queries=%d/%d, hits=%d+%d, tests=%d+%d, adds=%d", + tty->print_cr(" caches=%d queries=%u/%u, hits=%u+%u, tests=%u+%u, adds=%u", pc_desc_resets, pc_desc_queries, pc_desc_approx, pc_desc_repeats, pc_desc_hits, diff --git a/src/hotspot/share/compiler/abstractCompiler.hpp b/src/hotspot/share/compiler/abstractCompiler.hpp index 5063daefbff..724c0412db5 100644 --- a/src/hotspot/share/compiler/abstractCompiler.hpp +++ b/src/hotspot/share/compiler/abstractCompiler.hpp @@ -39,8 +39,8 @@ class CompilerStatistics { friend class VMStructs; public: elapsedTimer _time; // time spent compiling - int _bytes; // number of bytecodes compiled, including inlined bytecodes - int _count; // number of compilations + uint _bytes; // number of bytecodes compiled, including inlined bytecodes + uint _count; // number of compilations Data() : _bytes(0), _count(0) {} void update(elapsedTimer time, int bytes) { _time.add(time); @@ -55,13 +55,13 @@ class CompilerStatistics { public: Data _standard; // stats for non-OSR compilations Data _osr; // stats for OSR compilations - int _nmethods_size; // - int _nmethods_code_size; + uint _nmethods_size; // + uint _nmethods_code_size; double total_time() { return _standard._time.seconds() + _osr._time.seconds(); } double bytes_per_second() { - int bytes = _standard._bytes + _osr._bytes; + uint bytes = _standard._bytes + _osr._bytes; if (bytes == 0) { return 0.0; } diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index de8cce86578..d99233f799c 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -174,18 +174,18 @@ elapsedTimer CompileBroker::_t_standard_compilation; elapsedTimer CompileBroker::_t_invalidated_compilation; elapsedTimer CompileBroker::_t_bailedout_compilation; -int CompileBroker::_total_bailout_count = 0; -int CompileBroker::_total_invalidated_count = 0; -int CompileBroker::_total_compile_count = 0; -int CompileBroker::_total_osr_compile_count = 0; -int CompileBroker::_total_standard_compile_count = 0; -int CompileBroker::_total_compiler_stopped_count = 0; -int CompileBroker::_total_compiler_restarted_count = 0; +uint CompileBroker::_total_bailout_count = 0; +uint CompileBroker::_total_invalidated_count = 0; +uint CompileBroker::_total_compile_count = 0; +uint CompileBroker::_total_osr_compile_count = 0; +uint CompileBroker::_total_standard_compile_count = 0; +uint CompileBroker::_total_compiler_stopped_count = 0; +uint CompileBroker::_total_compiler_restarted_count = 0; -int CompileBroker::_sum_osr_bytes_compiled = 0; -int CompileBroker::_sum_standard_bytes_compiled = 0; -int CompileBroker::_sum_nmethod_size = 0; -int CompileBroker::_sum_nmethod_code_size = 0; +uint CompileBroker::_sum_osr_bytes_compiled = 0; +uint CompileBroker::_sum_standard_bytes_compiled = 0; +uint CompileBroker::_sum_nmethod_size = 0; +uint CompileBroker::_sum_nmethod_code_size = 0; jlong CompileBroker::_peak_compilation_time = 0; @@ -2599,7 +2599,7 @@ jlong CompileBroker::total_compilation_ticks() { } void CompileBroker::print_times(const char* name, CompilerStatistics* stats) { - tty->print_cr(" %s {speed: %6.3f bytes/s; standard: %6.3f s, %d bytes, %d methods; osr: %6.3f s, %d bytes, %d methods; nmethods_size: %d bytes; nmethods_code_size: %d bytes}", + tty->print_cr(" %s {speed: %6.3f bytes/s; standard: %6.3f s, %u bytes, %u methods; osr: %6.3f s, %u bytes, %u methods; nmethods_size: %u bytes; nmethods_code_size: %u bytes}", name, stats->bytes_per_second(), stats->_standard._time.seconds(), stats->_standard._bytes, stats->_standard._count, stats->_osr._time.seconds(), stats->_osr._bytes, stats->_osr._count, @@ -2642,17 +2642,17 @@ void CompileBroker::print_times(bool per_compiler, bool aggregate) { elapsedTimer osr_compilation = CompileBroker::_t_osr_compilation; elapsedTimer total_compilation = CompileBroker::_t_total_compilation; - int standard_bytes_compiled = CompileBroker::_sum_standard_bytes_compiled; - int osr_bytes_compiled = CompileBroker::_sum_osr_bytes_compiled; + uint standard_bytes_compiled = CompileBroker::_sum_standard_bytes_compiled; + uint osr_bytes_compiled = CompileBroker::_sum_osr_bytes_compiled; - int standard_compile_count = CompileBroker::_total_standard_compile_count; - int osr_compile_count = CompileBroker::_total_osr_compile_count; - int total_compile_count = CompileBroker::_total_compile_count; - int total_bailout_count = CompileBroker::_total_bailout_count; - int total_invalidated_count = CompileBroker::_total_invalidated_count; + uint standard_compile_count = CompileBroker::_total_standard_compile_count; + uint osr_compile_count = CompileBroker::_total_osr_compile_count; + uint total_compile_count = CompileBroker::_total_compile_count; + uint total_bailout_count = CompileBroker::_total_bailout_count; + uint total_invalidated_count = CompileBroker::_total_invalidated_count; - int nmethods_size = CompileBroker::_sum_nmethod_code_size; - int nmethods_code_size = CompileBroker::_sum_nmethod_size; + uint nmethods_size = CompileBroker::_sum_nmethod_code_size; + uint nmethods_code_size = CompileBroker::_sum_nmethod_size; tty->cr(); tty->print_cr("Accumulated compiler times"); @@ -2694,19 +2694,19 @@ void CompileBroker::print_times(bool per_compiler, bool aggregate) { #endif tty->cr(); - tty->print_cr(" Total compiled methods : %8d methods", total_compile_count); - tty->print_cr(" Standard compilation : %8d methods", standard_compile_count); - tty->print_cr(" On stack replacement : %8d methods", osr_compile_count); - int tcb = osr_bytes_compiled + standard_bytes_compiled; - tty->print_cr(" Total compiled bytecodes : %8d bytes", tcb); - tty->print_cr(" Standard compilation : %8d bytes", standard_bytes_compiled); - tty->print_cr(" On stack replacement : %8d bytes", osr_bytes_compiled); + tty->print_cr(" Total compiled methods : %8u methods", total_compile_count); + tty->print_cr(" Standard compilation : %8u methods", standard_compile_count); + tty->print_cr(" On stack replacement : %8u methods", osr_compile_count); + uint tcb = osr_bytes_compiled + standard_bytes_compiled; + tty->print_cr(" Total compiled bytecodes : %8u bytes", tcb); + tty->print_cr(" Standard compilation : %8u bytes", standard_bytes_compiled); + tty->print_cr(" On stack replacement : %8u bytes", osr_bytes_compiled); double tcs = total_compilation.seconds(); - int bps = tcs == 0.0 ? 0 : (int)(tcb / tcs); - tty->print_cr(" Average compilation speed : %8d bytes/s", bps); + uint bps = tcs == 0.0 ? 0 : (uint)(tcb / tcs); + tty->print_cr(" Average compilation speed : %8u bytes/s", bps); tty->cr(); - tty->print_cr(" nmethod code size : %8d bytes", nmethods_code_size); - tty->print_cr(" nmethod total size : %8d bytes", nmethods_size); + tty->print_cr(" nmethod code size : %8u bytes", nmethods_code_size); + tty->print_cr(" nmethod total size : %8u bytes", nmethods_size); } // Print general/accumulated JIT information. diff --git a/src/hotspot/share/compiler/compileBroker.hpp b/src/hotspot/share/compiler/compileBroker.hpp index e87c7f35555..e89ac326c4e 100644 --- a/src/hotspot/share/compiler/compileBroker.hpp +++ b/src/hotspot/share/compiler/compileBroker.hpp @@ -209,18 +209,18 @@ class CompileBroker: AllStatic { static elapsedTimer _t_invalidated_compilation; static elapsedTimer _t_bailedout_compilation; - static int _total_compile_count; - static int _total_bailout_count; - static int _total_invalidated_count; - static int _total_native_compile_count; - static int _total_osr_compile_count; - static int _total_standard_compile_count; - static int _total_compiler_stopped_count; - static int _total_compiler_restarted_count; - static int _sum_osr_bytes_compiled; - static int _sum_standard_bytes_compiled; - static int _sum_nmethod_size; - static int _sum_nmethod_code_size; + static uint _total_compile_count; + static uint _total_bailout_count; + static uint _total_invalidated_count; + static uint _total_native_compile_count; + static uint _total_osr_compile_count; + static uint _total_standard_compile_count; + static uint _total_compiler_stopped_count; + static uint _total_compiler_restarted_count; + static uint _sum_osr_bytes_compiled; + static uint _sum_standard_bytes_compiled; + static uint _sum_nmethod_size; + static uint _sum_nmethod_code_size; static jlong _peak_compilation_time; static CompilerStatistics _stats_per_level[]; diff --git a/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp b/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp index bda6acbc800..acf7e3a7722 100644 --- a/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp +++ b/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp @@ -554,11 +554,13 @@ void JfrThreadSampler::run() { os::naked_sleep(sleep_to_next); } - if ((next_j - sleep_to_next) <= 0) { + // Note, this code used to check (next_j - sleep_to_next) <= 0, + // but that can overflow (UB) and cause a spurious sample. + if (next_j <= sleep_to_next) { task_stacktrace(JAVA_SAMPLE, &_last_thread_java); last_java_ms = get_monotonic_ms(); } - if ((next_n - sleep_to_next) <= 0) { + if (next_n <= sleep_to_next) { task_stacktrace(NATIVE_SAMPLE, &_last_thread_native); last_native_ms = get_monotonic_ms(); } diff --git a/src/hotspot/share/opto/c2_globals.hpp b/src/hotspot/share/opto/c2_globals.hpp index ada5bc99410..8d5b749f3fb 100644 --- a/src/hotspot/share/opto/c2_globals.hpp +++ b/src/hotspot/share/opto/c2_globals.hpp @@ -96,7 +96,7 @@ \ notproduct(intx, IndexSetWatch, 0, \ "Trace all operations on this IndexSet (-1 means all, 0 none)") \ - range(-1, 0) \ + range(-1, max_intx) \ \ develop(intx, OptoNodeListSize, 4, \ "Starting allocation size of Node_List data structures") \ diff --git a/src/hotspot/share/opto/graphKit.cpp b/src/hotspot/share/opto/graphKit.cpp index dd3ab4baa0d..d9ea82c03c1 100644 --- a/src/hotspot/share/opto/graphKit.cpp +++ b/src/hotspot/share/opto/graphKit.cpp @@ -1241,8 +1241,8 @@ Node* GraphKit::array_ideal_length(AllocateArrayNode* alloc, // the incoming address with null casted away. You are allowed to use the // not-null value only if you are control dependent on the test. #ifndef PRODUCT -extern int explicit_null_checks_inserted, - explicit_null_checks_elided; +extern uint explicit_null_checks_inserted, + explicit_null_checks_elided; #endif Node* GraphKit::null_check_common(Node* value, BasicType type, // optional arguments for variations: diff --git a/src/hotspot/share/opto/ifnode.cpp b/src/hotspot/share/opto/ifnode.cpp index ef0c7208356..38713721c7c 100644 --- a/src/hotspot/share/opto/ifnode.cpp +++ b/src/hotspot/share/opto/ifnode.cpp @@ -42,7 +42,7 @@ #ifndef PRODUCT -extern int explicit_null_checks_elided; +extern uint explicit_null_checks_elided; #endif //============================================================================= diff --git a/src/hotspot/share/opto/indexSet.cpp b/src/hotspot/share/opto/indexSet.cpp index 45bc5d2e91c..e0c063145c6 100644 --- a/src/hotspot/share/opto/indexSet.cpp +++ b/src/hotspot/share/opto/indexSet.cpp @@ -47,7 +47,7 @@ julong IndexSet::_total_used_blocks = 0; julong IndexSet::_total_unused_blocks = 0; // Per set, or all sets operation tracing -int IndexSet::_serial_count = 1; +uint IndexSet::_serial_count = 1; #endif //---------------------------- IndexSet::populate_free_list() ----------------------------- diff --git a/src/hotspot/share/opto/indexSet.hpp b/src/hotspot/share/opto/indexSet.hpp index 7c1fc256cb0..b4d4237b13d 100644 --- a/src/hotspot/share/opto/indexSet.hpp +++ b/src/hotspot/share/opto/indexSet.hpp @@ -344,22 +344,22 @@ class IndexSet : public ResourceObj { // Sanity tests void verify() const; - static int _serial_count; - int _serial_number; + static uint _serial_count; + uint _serial_number; // Check to see if the serial number of the current set is the one we're tracing. // If it is, print a message. void check_watch(const char *operation, uint operand) const { if (IndexSetWatch != 0) { - if (IndexSetWatch == -1 || _serial_number == IndexSetWatch) { - tty->print_cr("IndexSet %d : %s ( %d )", _serial_number, operation, operand); + if (IndexSetWatch == -1 || (uintx)_serial_number == (uintx)IndexSetWatch) { + tty->print_cr("IndexSet %u : %s ( %d )", _serial_number, operation, operand); } } } void check_watch(const char *operation) const { if (IndexSetWatch != 0) { - if (IndexSetWatch == -1 || _serial_number == IndexSetWatch) { - tty->print_cr("IndexSet %d : %s", _serial_number, operation); + if (IndexSetWatch == -1 || (uintx)_serial_number == (uintx)IndexSetWatch) { + tty->print_cr("IndexSet %u : %s", _serial_number, operation); } } } diff --git a/src/hotspot/share/opto/lcm.cpp b/src/hotspot/share/opto/lcm.cpp index 1d85029d854..61e8946ed39 100644 --- a/src/hotspot/share/opto/lcm.cpp +++ b/src/hotspot/share/opto/lcm.cpp @@ -370,7 +370,7 @@ void PhaseCFG::implicit_null_check(Block* block, Node *proj, Node *val, int allo // ---- Found an implicit null check #ifndef PRODUCT - extern int implicit_null_checks; + extern uint implicit_null_checks; implicit_null_checks++; #endif diff --git a/src/hotspot/share/opto/matcher.cpp b/src/hotspot/share/opto/matcher.cpp index e8c62146cd2..37c9ec6ed13 100644 --- a/src/hotspot/share/opto/matcher.cpp +++ b/src/hotspot/share/opto/matcher.cpp @@ -2540,7 +2540,7 @@ void Matcher::collect_null_checks( Node *proj, Node *orig_proj ) { bool push_it = false; if( proj->Opcode() == Op_IfTrue ) { #ifndef PRODUCT - extern int all_null_checks_found; + extern uint all_null_checks_found; all_null_checks_found++; #endif if( b->_test._test == BoolTest::ne ) { diff --git a/src/hotspot/share/opto/mulnode.cpp b/src/hotspot/share/opto/mulnode.cpp index 053f33745ee..e79492a62e8 100644 --- a/src/hotspot/share/opto/mulnode.cpp +++ b/src/hotspot/share/opto/mulnode.cpp @@ -888,7 +888,7 @@ Node *LShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { // Special case C1 == C2, which just masks off low bits if (add1Con > 0 && con == add1Con) { // Convert to "(x & -(1 << C2))" - return new AndINode(add1->in(1), phase->intcon(-(1 << con))); + return new AndINode(add1->in(1), phase->intcon(java_negate(jint(1 << con)))); } else { // Wait until the right shift has been sharpened to the correct count if (add1Con > 0 && add1Con < BitsPerJavaInteger) { @@ -898,7 +898,7 @@ Node *LShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { if (con > add1Con) { // Creates "(x << (C2 - C1)) & -(1 << C2)" Node* lshift = phase->transform(new LShiftINode(add1->in(1), phase->intcon(con - add1Con))); - return new AndINode(lshift, phase->intcon(java_negate((jint)(1 << con)))); + return new AndINode(lshift, phase->intcon(java_negate(jint(1 << con)))); } else { assert(con < add1Con, "must be (%d < %d)", con, add1Con); // Creates "(x >> (C1 - C2)) & -(1 << C2)" @@ -911,7 +911,7 @@ Node *LShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { rshift = phase->transform(new URShiftINode(add1->in(1), phase->intcon(add1Con - con))); } - return new AndINode(rshift, phase->intcon(-(1 << con))); + return new AndINode(rshift, phase->intcon(java_negate(jint(1 << con)))); } } else { phase->record_for_igvn(this); @@ -1064,7 +1064,7 @@ Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Special case C1 == C2, which just masks off low bits if (add1Con > 0 && con == add1Con) { // Convert to "(x & -(1 << C2))" - return new AndLNode(add1->in(1), phase->longcon(-(CONST64(1) << con))); + return new AndLNode(add1->in(1), phase->longcon(java_negate(jlong(CONST64(1) << con)))); } else { // Wait until the right shift has been sharpened to the correct count if (add1Con > 0 && add1Con < BitsPerJavaLong) { @@ -1074,7 +1074,7 @@ Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { if (con > add1Con) { // Creates "(x << (C2 - C1)) & -(1 << C2)" Node* lshift = phase->transform(new LShiftLNode(add1->in(1), phase->intcon(con - add1Con))); - return new AndLNode(lshift, phase->longcon(-(CONST64(1) << con))); + return new AndLNode(lshift, phase->longcon(java_negate(jlong(CONST64(1) << con)))); } else { assert(con < add1Con, "must be (%d < %d)", con, add1Con); // Creates "(x >> (C1 - C2)) & -(1 << C2)" @@ -1087,7 +1087,7 @@ Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { rshift = phase->transform(new URShiftLNode(add1->in(1), phase->intcon(add1Con - con))); } - return new AndLNode(rshift, phase->longcon(-(CONST64(1) << con))); + return new AndLNode(rshift, phase->longcon(java_negate(jlong(CONST64(1) << con)))); } } else { phase->record_for_igvn(this); diff --git a/src/hotspot/share/opto/node.cpp b/src/hotspot/share/opto/node.cpp index e09aaf2acb7..527b0ba8938 100644 --- a/src/hotspot/share/opto/node.cpp +++ b/src/hotspot/share/opto/node.cpp @@ -55,7 +55,7 @@ class PhaseGVN; const uint Node::NotAMachineReg = 0xffff0000; #ifndef PRODUCT -extern int nodes_created; +extern uint nodes_created; #endif #ifdef __clang__ #pragma clang diagnostic push diff --git a/src/hotspot/share/opto/parse1.cpp b/src/hotspot/share/opto/parse1.cpp index 73ce0b28aa7..36a87cd8b0d 100644 --- a/src/hotspot/share/opto/parse1.cpp +++ b/src/hotspot/share/opto/parse1.cpp @@ -49,16 +49,16 @@ // and eventually should be encapsulated in a proper class (gri 8/18/98). #ifndef PRODUCT -int nodes_created = 0; -int methods_parsed = 0; -int methods_seen = 0; -int blocks_parsed = 0; -int blocks_seen = 0; +uint nodes_created = 0; +uint methods_parsed = 0; +uint methods_seen = 0; +uint blocks_parsed = 0; +uint blocks_seen = 0; -int explicit_null_checks_inserted = 0; -int explicit_null_checks_elided = 0; -int all_null_checks_found = 0; -int implicit_null_checks = 0; +uint explicit_null_checks_inserted = 0; +uint explicit_null_checks_elided = 0; +uint all_null_checks_found = 0; +uint implicit_null_checks = 0; bool Parse::BytecodeParseHistogram::_initialized = false; uint Parse::BytecodeParseHistogram::_bytecodes_parsed [Bytecodes::number_of_codes]; @@ -69,26 +69,26 @@ uint Parse::BytecodeParseHistogram::_new_values [Bytecodes::number_of_code //------------------------------print_statistics------------------------------- void Parse::print_statistics() { tty->print_cr("--- Compiler Statistics ---"); - tty->print("Methods seen: %d Methods parsed: %d", methods_seen, methods_parsed); - tty->print(" Nodes created: %d", nodes_created); + tty->print("Methods seen: %u Methods parsed: %u", methods_seen, methods_parsed); + tty->print(" Nodes created: %u", nodes_created); tty->cr(); if (methods_seen != methods_parsed) { tty->print_cr("Reasons for parse failures (NOT cumulative):"); } - tty->print_cr("Blocks parsed: %d Blocks seen: %d", blocks_parsed, blocks_seen); + tty->print_cr("Blocks parsed: %u Blocks seen: %u", blocks_parsed, blocks_seen); if (explicit_null_checks_inserted) { - tty->print_cr("%d original null checks - %d elided (%2d%%); optimizer leaves %d,", + tty->print_cr("%u original null checks - %u elided (%2u%%); optimizer leaves %u,", explicit_null_checks_inserted, explicit_null_checks_elided, (100*explicit_null_checks_elided)/explicit_null_checks_inserted, all_null_checks_found); } if (all_null_checks_found) { - tty->print_cr("%d made implicit (%2d%%)", implicit_null_checks, + tty->print_cr("%u made implicit (%2u%%)", implicit_null_checks, (100*implicit_null_checks)/all_null_checks_found); } if (SharedRuntime::_implicit_null_throws) { - tty->print_cr("%d implicit null exceptions at runtime", + tty->print_cr("%u implicit null exceptions at runtime", SharedRuntime::_implicit_null_throws); } diff --git a/src/hotspot/share/opto/parse2.cpp b/src/hotspot/share/opto/parse2.cpp index bb21f48f633..56fe6dc8053 100644 --- a/src/hotspot/share/opto/parse2.cpp +++ b/src/hotspot/share/opto/parse2.cpp @@ -46,8 +46,8 @@ #include "runtime/sharedRuntime.hpp" #ifndef PRODUCT -extern int explicit_null_checks_inserted, - explicit_null_checks_elided; +extern uint explicit_null_checks_inserted, + explicit_null_checks_elided; #endif //---------------------------------array_load---------------------------------- diff --git a/src/hotspot/share/opto/parse3.cpp b/src/hotspot/share/opto/parse3.cpp index 7e6b200df36..a2bf653b176 100644 --- a/src/hotspot/share/opto/parse3.cpp +++ b/src/hotspot/share/opto/parse3.cpp @@ -339,10 +339,13 @@ void Parse::do_multianewarray() { // It is often the case that the lengths are small (except the last). // If that happens, use the fast 1-d creator a constant number of times. const int expand_limit = MIN2((int)MultiArrayExpandLimit, 100); - int expand_count = 1; // count of allocations in the expansion - int expand_fanout = 1; // running total fanout + int64_t expand_count = 1; // count of allocations in the expansion + int64_t expand_fanout = 1; // running total fanout for (j = 0; j < ndimensions-1; j++) { int dim_con = find_int_con(length[j], -1); + // To prevent overflow, we use 64-bit values. Alternatively, + // we could clamp dim_con like so: + // dim_con = MIN2(dim_con, expand_limit); expand_fanout *= dim_con; expand_count += expand_fanout; // count the level-J sub-arrays if (dim_con <= 0 diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index e0cb6ba901e..b641144b5e5 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -137,13 +137,13 @@ void SharedRuntime::generate_stubs() { #ifndef PRODUCT // For statistics -int SharedRuntime::_ic_miss_ctr = 0; -int SharedRuntime::_wrong_method_ctr = 0; -int SharedRuntime::_resolve_static_ctr = 0; -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; +uint SharedRuntime::_ic_miss_ctr = 0; +uint SharedRuntime::_wrong_method_ctr = 0; +uint SharedRuntime::_resolve_static_ctr = 0; +uint SharedRuntime::_resolve_virtual_ctr = 0; +uint SharedRuntime::_resolve_opt_virtual_ctr = 0; +uint SharedRuntime::_implicit_null_throws = 0; +uint SharedRuntime::_implicit_div0_throws = 0; int64_t SharedRuntime::_nof_normal_calls = 0; int64_t SharedRuntime::_nof_inlined_calls = 0; @@ -153,28 +153,28 @@ int64_t SharedRuntime::_nof_inlined_static_calls = 0; int64_t SharedRuntime::_nof_interface_calls = 0; int64_t SharedRuntime::_nof_inlined_interface_calls = 0; -int SharedRuntime::_new_instance_ctr=0; -int SharedRuntime::_new_array_ctr=0; -int SharedRuntime::_multi2_ctr=0; -int SharedRuntime::_multi3_ctr=0; -int SharedRuntime::_multi4_ctr=0; -int SharedRuntime::_multi5_ctr=0; -int SharedRuntime::_mon_enter_stub_ctr=0; -int SharedRuntime::_mon_exit_stub_ctr=0; -int SharedRuntime::_mon_enter_ctr=0; -int SharedRuntime::_mon_exit_ctr=0; -int SharedRuntime::_partial_subtype_ctr=0; -int SharedRuntime::_jbyte_array_copy_ctr=0; -int SharedRuntime::_jshort_array_copy_ctr=0; -int SharedRuntime::_jint_array_copy_ctr=0; -int SharedRuntime::_jlong_array_copy_ctr=0; -int SharedRuntime::_oop_array_copy_ctr=0; -int SharedRuntime::_checkcast_array_copy_ctr=0; -int SharedRuntime::_unsafe_array_copy_ctr=0; -int SharedRuntime::_generic_array_copy_ctr=0; -int SharedRuntime::_slow_array_copy_ctr=0; -int SharedRuntime::_find_handler_ctr=0; -int SharedRuntime::_rethrow_ctr=0; +uint SharedRuntime::_new_instance_ctr=0; +uint SharedRuntime::_new_array_ctr=0; +uint SharedRuntime::_multi2_ctr=0; +uint SharedRuntime::_multi3_ctr=0; +uint SharedRuntime::_multi4_ctr=0; +uint SharedRuntime::_multi5_ctr=0; +uint SharedRuntime::_mon_enter_stub_ctr=0; +uint SharedRuntime::_mon_exit_stub_ctr=0; +uint SharedRuntime::_mon_enter_ctr=0; +uint SharedRuntime::_mon_exit_ctr=0; +uint SharedRuntime::_partial_subtype_ctr=0; +uint SharedRuntime::_jbyte_array_copy_ctr=0; +uint SharedRuntime::_jshort_array_copy_ctr=0; +uint SharedRuntime::_jint_array_copy_ctr=0; +uint SharedRuntime::_jlong_array_copy_ctr=0; +uint SharedRuntime::_oop_array_copy_ctr=0; +uint SharedRuntime::_checkcast_array_copy_ctr=0; +uint SharedRuntime::_unsafe_array_copy_ctr=0; +uint SharedRuntime::_generic_array_copy_ctr=0; +uint SharedRuntime::_slow_array_copy_ctr=0; +uint SharedRuntime::_find_handler_ctr=0; +uint SharedRuntime::_rethrow_ctr=0; int SharedRuntime::_ICmiss_index = 0; int SharedRuntime::_ICmiss_count[SharedRuntime::maxICmiss_count]; @@ -1419,9 +1419,9 @@ methodHandle SharedRuntime::resolve_sub_helper(bool is_virtual, bool is_optimize #ifndef PRODUCT // tracing/debugging/statistics - int *addr = (is_optimized) ? (&_resolve_opt_virtual_ctr) : - (is_virtual) ? (&_resolve_virtual_ctr) : - (&_resolve_static_ctr); + uint *addr = (is_optimized) ? (&_resolve_opt_virtual_ctr) : + (is_virtual) ? (&_resolve_virtual_ctr) : + (&_resolve_static_ctr); Atomic::inc(addr); if (TraceCallFixup) { @@ -2273,35 +2273,35 @@ void SharedRuntime::print_statistics() { 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 (_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); - if (_multi5_ctr) tty->print_cr("%5d multianewarray 5 dim", _multi5_ctr); + if (_new_instance_ctr) tty->print_cr("%5u new instance requires GC", _new_instance_ctr); + if (_new_array_ctr) tty->print_cr("%5u new array requires GC", _new_array_ctr); + if (_multi2_ctr) tty->print_cr("%5u multianewarray 2 dim", _multi2_ctr); + if (_multi3_ctr) tty->print_cr("%5u multianewarray 3 dim", _multi3_ctr); + if (_multi4_ctr) tty->print_cr("%5u multianewarray 4 dim", _multi4_ctr); + if (_multi5_ctr) tty->print_cr("%5u multianewarray 5 dim", _multi5_ctr); - tty->print_cr("%5d inline cache miss in compiled", _ic_miss_ctr); - tty->print_cr("%5d wrong method", _wrong_method_ctr); - tty->print_cr("%5d unresolved static call site", _resolve_static_ctr); - tty->print_cr("%5d unresolved virtual call site", _resolve_virtual_ctr); - tty->print_cr("%5d unresolved opt virtual call site", _resolve_opt_virtual_ctr); + tty->print_cr("%5u inline cache miss in compiled", _ic_miss_ctr); + tty->print_cr("%5u wrong method", _wrong_method_ctr); + tty->print_cr("%5u unresolved static call site", _resolve_static_ctr); + tty->print_cr("%5u unresolved virtual call site", _resolve_virtual_ctr); + tty->print_cr("%5u unresolved opt virtual call site", _resolve_opt_virtual_ctr); - if (_mon_enter_stub_ctr) tty->print_cr("%5d monitor enter stub", _mon_enter_stub_ctr); - if (_mon_exit_stub_ctr) tty->print_cr("%5d monitor exit stub", _mon_exit_stub_ctr); - if (_mon_enter_ctr) tty->print_cr("%5d monitor enter slow", _mon_enter_ctr); - if (_mon_exit_ctr) tty->print_cr("%5d monitor exit slow", _mon_exit_ctr); - if (_partial_subtype_ctr) tty->print_cr("%5d slow partial subtype", _partial_subtype_ctr); - if (_jbyte_array_copy_ctr) tty->print_cr("%5d byte array copies", _jbyte_array_copy_ctr); - if (_jshort_array_copy_ctr) tty->print_cr("%5d short array copies", _jshort_array_copy_ctr); - if (_jint_array_copy_ctr) tty->print_cr("%5d int array copies", _jint_array_copy_ctr); - if (_jlong_array_copy_ctr) tty->print_cr("%5d long array copies", _jlong_array_copy_ctr); - if (_oop_array_copy_ctr) tty->print_cr("%5d oop array copies", _oop_array_copy_ctr); - if (_checkcast_array_copy_ctr) tty->print_cr("%5d checkcast array copies", _checkcast_array_copy_ctr); - if (_unsafe_array_copy_ctr) tty->print_cr("%5d unsafe array copies", _unsafe_array_copy_ctr); - if (_generic_array_copy_ctr) tty->print_cr("%5d generic array copies", _generic_array_copy_ctr); - if (_slow_array_copy_ctr) tty->print_cr("%5d slow array copies", _slow_array_copy_ctr); - if (_find_handler_ctr) tty->print_cr("%5d find exception handler", _find_handler_ctr); - if (_rethrow_ctr) tty->print_cr("%5d rethrow handler", _rethrow_ctr); + if (_mon_enter_stub_ctr) tty->print_cr("%5u monitor enter stub", _mon_enter_stub_ctr); + if (_mon_exit_stub_ctr) tty->print_cr("%5u monitor exit stub", _mon_exit_stub_ctr); + if (_mon_enter_ctr) tty->print_cr("%5u monitor enter slow", _mon_enter_ctr); + if (_mon_exit_ctr) tty->print_cr("%5u monitor exit slow", _mon_exit_ctr); + if (_partial_subtype_ctr) tty->print_cr("%5u slow partial subtype", _partial_subtype_ctr); + if (_jbyte_array_copy_ctr) tty->print_cr("%5u byte array copies", _jbyte_array_copy_ctr); + if (_jshort_array_copy_ctr) tty->print_cr("%5u short array copies", _jshort_array_copy_ctr); + if (_jint_array_copy_ctr) tty->print_cr("%5u int array copies", _jint_array_copy_ctr); + if (_jlong_array_copy_ctr) tty->print_cr("%5u long array copies", _jlong_array_copy_ctr); + if (_oop_array_copy_ctr) tty->print_cr("%5u oop array copies", _oop_array_copy_ctr); + if (_checkcast_array_copy_ctr) tty->print_cr("%5u checkcast array copies", _checkcast_array_copy_ctr); + if (_unsafe_array_copy_ctr) tty->print_cr("%5u unsafe array copies", _unsafe_array_copy_ctr); + if (_generic_array_copy_ctr) tty->print_cr("%5u generic array copies", _generic_array_copy_ctr); + if (_slow_array_copy_ctr) tty->print_cr("%5u slow array copies", _slow_array_copy_ctr); + if (_find_handler_ctr) tty->print_cr("%5u find exception handler", _find_handler_ctr); + if (_rethrow_ctr) tty->print_cr("%5u rethrow handler", _rethrow_ctr); AdapterHandlerLibrary::print_statistics(); diff --git a/src/hotspot/share/runtime/sharedRuntime.hpp b/src/hotspot/share/runtime/sharedRuntime.hpp index 73d8c603709..b401e057e05 100644 --- a/src/hotspot/share/runtime/sharedRuntime.hpp +++ b/src/hotspot/share/runtime/sharedRuntime.hpp @@ -528,34 +528,34 @@ class SharedRuntime: AllStatic { static void trace_ic_miss(address at); public: - static int _ic_miss_ctr; // total # of IC misses - static int _wrong_method_ctr; - static int _resolve_static_ctr; - static int _resolve_virtual_ctr; - static int _resolve_opt_virtual_ctr; - static int _implicit_null_throws; - static int _implicit_div0_throws; + static uint _ic_miss_ctr; // total # of IC misses + static uint _wrong_method_ctr; + static uint _resolve_static_ctr; + static uint _resolve_virtual_ctr; + static uint _resolve_opt_virtual_ctr; + static uint _implicit_null_throws; + static uint _implicit_div0_throws; - static int _jbyte_array_copy_ctr; // Slow-path byte array copy - static int _jshort_array_copy_ctr; // Slow-path short array copy - static int _jint_array_copy_ctr; // Slow-path int array copy - static int _jlong_array_copy_ctr; // Slow-path long array copy - static int _oop_array_copy_ctr; // Slow-path oop array copy - static int _checkcast_array_copy_ctr; // Slow-path oop array copy, with cast - static int _unsafe_array_copy_ctr; // Slow-path includes alignment checks - static int _generic_array_copy_ctr; // Slow-path includes type decoding - static int _slow_array_copy_ctr; // Slow-path failed out to a method call + static uint _jbyte_array_copy_ctr; // Slow-path byte array copy + static uint _jshort_array_copy_ctr; // Slow-path short array copy + static uint _jint_array_copy_ctr; // Slow-path int array copy + static uint _jlong_array_copy_ctr; // Slow-path long array copy + static uint _oop_array_copy_ctr; // Slow-path oop array copy + static uint _checkcast_array_copy_ctr; // Slow-path oop array copy, with cast + static uint _unsafe_array_copy_ctr; // Slow-path includes alignment checks + static uint _generic_array_copy_ctr; // Slow-path includes type decoding + static uint _slow_array_copy_ctr; // Slow-path failed out to a method call - static int _new_instance_ctr; // 'new' object requires GC - static int _new_array_ctr; // 'new' array requires GC - 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 - static int _mon_exit_stub_ctr; // monitor exit stub - static int _mon_enter_ctr; // monitor enter slow - static int _mon_exit_ctr; // monitor exit slow - static int _partial_subtype_ctr; // SubRoutines::partial_subtype_check + static uint _new_instance_ctr; // 'new' object requires GC + static uint _new_array_ctr; // 'new' array requires GC + static uint _multi2_ctr, _multi3_ctr, _multi4_ctr, _multi5_ctr; + static uint _find_handler_ctr; // find exception handler + static uint _rethrow_ctr; // rethrow exception + static uint _mon_enter_stub_ctr; // monitor enter stub + static uint _mon_exit_stub_ctr; // monitor exit stub + static uint _mon_enter_ctr; // monitor enter slow + static uint _mon_exit_ctr; // monitor exit slow + static uint _partial_subtype_ctr; // SubRoutines::partial_subtype_check // Statistics code // stats for "normal" compiled calls (non-interface)