Skip to content

Commit

Permalink
8312077: Fix signed integer overflow, final part
Browse files Browse the repository at this point in the history
Reviewed-by: kvn, amitkumar
  • Loading branch information
dean-long committed Jul 24, 2023
1 parent 2bdfa83 commit d0761c1
Show file tree
Hide file tree
Showing 31 changed files with 321 additions and 316 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/arm/macroAssembler_arm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ class MacroAssembler: public Assembler {

// 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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/arm/stubGenerator_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/macroAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) );
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/stubGenerator_x86_32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_GraphBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(right_n_bits(BitsPerInt - s0c));
Value s = append(new Constant(new IntConstant(m)));
ipush(append(new LogicOp(Bytecodes::_iand, l->x(), s)));
}
Expand Down
108 changes: 54 additions & 54 deletions src/hotspot/share/c1/c1_Runtime1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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;
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 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) {
Expand Down Expand Up @@ -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(" _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(" _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(" _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: %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: %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();
Expand Down
36 changes: 18 additions & 18 deletions src/hotspot/share/c1/c1_Runtime1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/vmSymbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

1 comment on commit d0761c1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.