diff --git a/src/hotspot/share/code/stubs.cpp b/src/hotspot/share/code/stubs.cpp index 55e0207c87d..a1d79de7964 100644 --- a/src/hotspot/share/code/stubs.cpp +++ b/src/hotspot/share/code/stubs.cpp @@ -67,7 +67,7 @@ StubQueue::StubQueue(StubInterface* stub_interface, int buffer_size, Mutex* lock, const char* name) : _mutex(lock) { intptr_t size = align_up(buffer_size, 2*BytesPerWord); - BufferBlob* blob = BufferBlob::create(name, size); + BufferBlob* blob = BufferBlob::create(name, checked_cast(size)); if( blob == nullptr) { vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for %s", name); } diff --git a/src/hotspot/share/code/stubs.hpp b/src/hotspot/share/code/stubs.hpp index bf5b7b8eb12..7b8ee922101 100644 --- a/src/hotspot/share/code/stubs.hpp +++ b/src/hotspot/share/code/stubs.hpp @@ -155,7 +155,7 @@ class StubQueue: public CHeapObj { void check_index(int i) const { assert(0 <= i && i < _buffer_limit && i % stub_alignment() == 0, "illegal index"); } bool is_contiguous() const { return _queue_begin <= _queue_end; } - int index_of(Stub* s) const { int i = (address)s - _stub_buffer; check_index(i); return i; } + int index_of(Stub* s) const { int i = (int)((address)s - _stub_buffer); check_index(i); return i; } Stub* stub_at(int i) const { check_index(i); return (Stub*)(_stub_buffer + i); } Stub* current_stub() const { return stub_at(_queue_end); } diff --git a/src/hotspot/share/interpreter/bytecodeHistogram.cpp b/src/hotspot/share/interpreter/bytecodeHistogram.cpp index 31fe4dacb5d..9b023f1a662 100644 --- a/src/hotspot/share/interpreter/bytecodeHistogram.cpp +++ b/src/hotspot/share/interpreter/bytecodeHistogram.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -130,14 +130,14 @@ void BytecodeHistogram::print(float cutoff) { while (i-- > 0) { HistoEntry* e = profile->at(i); int abs = e->count(); - float rel = abs * 100.0F / tot; + float rel = (float)abs * 100.0F / (float)tot; if (cutoff <= rel) { tty->print_cr("%10d %7.2f%% %02x %s", abs, rel, e->index(), name_for(e->index())); abs_sum += abs; } } tty->print_cr("----------------------------------------------------------------------"); - float rel_sum = abs_sum * 100.0F / tot; + float rel_sum = (float)abs_sum * 100.0F / (float)tot; tty->print_cr("%10d %7.2f%% (cutoff = %.2f%%)", abs_sum, rel_sum, cutoff); tty->cr(); } @@ -172,7 +172,7 @@ void BytecodePairHistogram::print(float cutoff) { while (i-- > 0) { HistoEntry* e = profile->at(i); int abs = e->count(); - float rel = abs * 100.0F / tot; + float rel = (float)abs * 100.0F / (float)tot; if (cutoff <= rel) { int c1 = e->index() % number_of_codes; int c2 = e->index() / number_of_codes; @@ -181,7 +181,7 @@ void BytecodePairHistogram::print(float cutoff) { } } tty->print_cr("----------------------------------------------------------------------"); - float rel_sum = abs_sum * 100.0F / tot; + float rel_sum = (float)abs_sum * 100.0F / (float)tot; tty->print_cr("%10d %6.3f%% (cutoff = %.3f%%)", abs_sum, rel_sum, cutoff); tty->cr(); } diff --git a/src/hotspot/share/interpreter/bytecodeTracer.cpp b/src/hotspot/share/interpreter/bytecodeTracer.cpp index 333c1e9488e..7df787800a5 100644 --- a/src/hotspot/share/interpreter/bytecodeTracer.cpp +++ b/src/hotspot/share/interpreter/bytecodeTracer.cpp @@ -118,7 +118,7 @@ class BytecodePrinter { code = Bytecodes::code_at(method(), bcp); } _code = code; - int bci = bcp - method->code_base(); + int bci = (int)(bcp - method->code_base()); st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id()); if (Verbose) { st->print("%8d %4d " INTPTR_FORMAT " " INTPTR_FORMAT " %s", @@ -147,7 +147,7 @@ class BytecodePrinter { code = Bytecodes::code_at(method(), bcp+1); } _code = code; - int bci = bcp - method->code_base(); + int bci = (int)(bcp - method->code_base()); // Print bytecode index and name if (ClassPrinter::has_mode(_flags, ClassPrinter::PRINT_BYTECODE_ADDR)) { st->print(INTPTR_FORMAT " ", p2i(bcp)); diff --git a/src/hotspot/share/interpreter/bytecodeUtils.cpp b/src/hotspot/share/interpreter/bytecodeUtils.cpp index 49bc25e57fe..97b8441365f 100644 --- a/src/hotspot/share/interpreter/bytecodeUtils.cpp +++ b/src/hotspot/share/interpreter/bytecodeUtils.cpp @@ -353,7 +353,7 @@ static void print_local_var(outputStream *os, unsigned int bci, Method* method, StackSlotAnalysisData::StackSlotAnalysisData(BasicType type) : _bci(INVALID), _type(type) {} -StackSlotAnalysisData::StackSlotAnalysisData(int bci, BasicType type) : _bci(bci), _type(type) { +StackSlotAnalysisData::StackSlotAnalysisData(int bci, BasicType type) : _bci((u2)bci), _type(type) { assert(bci >= 0, "BCI must be >= 0"); assert(bci < 65536, "BCI must be < 65536"); } @@ -1081,7 +1081,7 @@ int ExceptionMessageBuilder::do_instruction(int bci) { } // If we have more than one branch target, process these too. - for (int64_t i = 0; i < dests.length(); ++i) { + for (int i = 0; i < dests.length(); ++i) { if (_stacks->at(dests.at(i)) == nullptr) { _added_one = true; } diff --git a/src/hotspot/share/interpreter/bytecodes.cpp b/src/hotspot/share/interpreter/bytecodes.cpp index 5db3ab5fe6b..8d29a2caf48 100644 --- a/src/hotspot/share/interpreter/bytecodes.cpp +++ b/src/hotspot/share/interpreter/bytecodes.cpp @@ -385,9 +385,9 @@ int Bytecodes::special_length_at(Bytecodes::Code code, address bcp, address end) if (end != nullptr && aligned_bcp + 3*jintSize >= end) { return -1; // don't read past end of code buffer } - jlong lo = (jint)Bytes::get_Java_u4(aligned_bcp + 1*jintSize); - jlong hi = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize); - jlong len = (aligned_bcp - bcp) + (3 + hi - lo + 1)*jintSize; + int lo = Bytes::get_Java_u4(aligned_bcp + 1*jintSize); + int hi = Bytes::get_Java_u4(aligned_bcp + 2*jintSize); + int len = (int)(aligned_bcp - bcp) + (3 + hi - lo + 1)*jintSize; // only return len if it can be represented as a positive int; // return -1 otherwise return (len > 0 && len == (int)len) ? len : -1; @@ -400,8 +400,8 @@ int Bytecodes::special_length_at(Bytecodes::Code code, address bcp, address end) if (end != nullptr && aligned_bcp + 2*jintSize >= end) { return -1; // don't read past end of code buffer } - jlong npairs = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize); - jlong len = (aligned_bcp - bcp) + (2 + 2*npairs)*jintSize; + int npairs = Bytes::get_Java_u4(aligned_bcp + jintSize); + int len = (int)(aligned_bcp - bcp) + (2 + 2*npairs)*jintSize; // only return len if it can be represented as a positive int; // return -1 otherwise return (len > 0 && len == (int)len) ? len : -1; @@ -439,7 +439,7 @@ void Bytecodes::def_flags(Code code, const char* format, const char* wide_format int len = (format != nullptr ? (int) strlen(format) : 0); int wlen = (wide_format != nullptr ? (int) strlen(wide_format) : 0); #endif - int bc_flags = 0; + jchar bc_flags = 0; if (can_trap) bc_flags |= _bc_can_trap; if (java_code != code) bc_flags |= _bc_can_rewrite; _flags[(u1)code+0*(1<available_space() - 2*K; + int codelet_size = AbstractInterpreter::code()->available_space() - (int)(2*K); // Guarantee there's a little bit of code space left. guarantee(codelet_size > 0 && (size_t)codelet_size > 2*K, diff --git a/src/hotspot/share/interpreter/invocationCounter.cpp b/src/hotspot/share/interpreter/invocationCounter.cpp index 965369dc167..d1165d29ac9 100644 --- a/src/hotspot/share/interpreter/invocationCounter.cpp +++ b/src/hotspot/share/interpreter/invocationCounter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,7 +65,7 @@ void InvocationCounter::decay() { void InvocationCounter::print() { uint counter = raw_counter(); - tty->print_cr("invocation count: up = %d, limit = %d, carry = %s", + tty->print_cr("invocation count: up = %d, limit = " INTX_FORMAT ", carry = %s", extract_count(counter), limit(), extract_carry(counter) ? "true" : "false"); } diff --git a/src/hotspot/share/interpreter/invocationCounter.hpp b/src/hotspot/share/interpreter/invocationCounter.hpp index 3732ed28d48..5ae6fb91b15 100644 --- a/src/hotspot/share/interpreter/invocationCounter.hpp +++ b/src/hotspot/share/interpreter/invocationCounter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ class InvocationCounter { // Accessors bool carry() const { return (_counter & carry_mask) != 0; } uint count() const { return _counter >> number_of_noncount_bits; } - uint limit() const { return CompileThreshold; } + intx limit() const { return CompileThreshold; } uint raw_counter() const { return _counter; } void print(); diff --git a/src/hotspot/share/interpreter/oopMapCache.cpp b/src/hotspot/share/interpreter/oopMapCache.cpp index 5b125d9e2bd..2ce6ce7ca7a 100644 --- a/src/hotspot/share/interpreter/oopMapCache.cpp +++ b/src/hotspot/share/interpreter/oopMapCache.cpp @@ -334,7 +334,7 @@ void OopMapCacheEntry::fill(const methodHandle& method, int bci) { // Flush entry to deallocate an existing entry flush(); set_method(method()); - set_bci(bci); + set_bci(checked_cast(bci)); // bci is always u2 if (method->is_native()) { // Native method activations have oops only among the parameters and one // extra oop following the parameters (the mirror for static native methods). diff --git a/src/hotspot/share/interpreter/oopMapCache.hpp b/src/hotspot/share/interpreter/oopMapCache.hpp index 0e7548763b9..d66ca23feb8 100644 --- a/src/hotspot/share/interpreter/oopMapCache.hpp +++ b/src/hotspot/share/interpreter/oopMapCache.hpp @@ -102,8 +102,8 @@ class InterpreterOopMap: ResourceObj { // access methods Method* method() const { return _method; } void set_method(Method* v) { _method = v; } - int bci() const { return _bci; } - void set_bci(int v) { _bci = v; } + unsigned short bci() const { return _bci; } + void set_bci(unsigned short v) { _bci = v; } int mask_size() const { return _mask_size; } void set_mask_size(int v) { _mask_size = v; } // Test bit mask size and return either the in-line bit mask or allocated diff --git a/src/hotspot/share/interpreter/rewriter.cpp b/src/hotspot/share/interpreter/rewriter.cpp index 7bd346f0c91..6db1a64c94b 100644 --- a/src/hotspot/share/interpreter/rewriter.cpp +++ b/src/hotspot/share/interpreter/rewriter.cpp @@ -181,13 +181,13 @@ void Rewriter::rewrite_member_reference(address bcp, int offset, bool reverse) { if (!reverse) { int cp_index = Bytes::get_Java_u2(p); int cache_index = cp_entry_to_cp_cache(cp_index); - Bytes::put_native_u2(p, cache_index); + Bytes::put_native_u2(p, (u2)cache_index); if (!_method_handle_invokers.is_empty()) maybe_rewrite_invokehandle(p - 1, cp_index, cache_index, reverse); } else { int cache_index = Bytes::get_native_u2(p); int pool_index = cp_cache_entry_pool_index(cache_index); - Bytes::put_Java_u2(p, pool_index); + Bytes::put_Java_u2(p, (u2)pool_index); if (!_method_handle_invokers.is_empty()) maybe_rewrite_invokehandle(p - 1, pool_index, cache_index, reverse); } @@ -206,7 +206,7 @@ void Rewriter::rewrite_invokespecial(address bcp, int offset, bool reverse, bool if (cache_index != (int)(jushort) cache_index) { *invokespecial_error = true; } - Bytes::put_native_u2(p, cache_index); + Bytes::put_native_u2(p, (u2)cache_index); } else { rewrite_member_reference(bcp, offset, reverse); } @@ -295,7 +295,7 @@ void Rewriter::rewrite_invokedynamic(address bcp, int offset, bool reverse) { assert(_pool->tag_at(cp_index).is_invoke_dynamic(), "wrong index"); // zero out 4 bytes Bytes::put_Java_u4(p, 0); - Bytes::put_Java_u2(p, cp_index); + Bytes::put_Java_u2(p, (u2)cp_index); } } @@ -319,7 +319,7 @@ void Rewriter::maybe_rewrite_ldc(address bcp, int offset, bool is_wide, if (is_wide) { (*bcp) = Bytecodes::_fast_aldc_w; assert(ref_index == (u2)ref_index, "index overflow"); - Bytes::put_native_u2(p, ref_index); + Bytes::put_native_u2(p, (u2)ref_index); } else { (*bcp) = Bytecodes::_fast_aldc; assert(ref_index == (u1)ref_index, "index overflow"); @@ -336,7 +336,7 @@ void Rewriter::maybe_rewrite_ldc(address bcp, int offset, bool is_wide, if (is_wide) { (*bcp) = Bytecodes::_ldc_w; assert(pool_index == (u2)pool_index, "index overflow"); - Bytes::put_Java_u2(p, pool_index); + Bytes::put_Java_u2(p, (u2)pool_index); } else { (*bcp) = Bytecodes::_ldc; assert(pool_index == (u1)pool_index, "index overflow"); diff --git a/src/hotspot/share/interpreter/templateInterpreter.hpp b/src/hotspot/share/interpreter/templateInterpreter.hpp index 87fa4efebef..9d3c5545fa0 100644 --- a/src/hotspot/share/interpreter/templateInterpreter.hpp +++ b/src/hotspot/share/interpreter/templateInterpreter.hpp @@ -76,7 +76,7 @@ class DispatchTable { void set_entry(int i, EntryPoint& entry); // set entry point for a given bytecode i address* table_for(TosState state) { return _table[state]; } address* table_for() { return table_for((TosState)0); } - int distance_from(address *table) { return table - table_for(); } + int distance_from(address *table) { return (int)(table - table_for()); } int distance_from(TosState state) { return distance_from(table_for(state)); } // Comparison diff --git a/src/hotspot/share/interpreter/templateTable.cpp b/src/hotspot/share/interpreter/templateTable.cpp index 827d89a858e..28e42ca1e02 100644 --- a/src/hotspot/share/interpreter/templateTable.cpp +++ b/src/hotspot/share/interpreter/templateTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,8 +48,8 @@ void Template::initialize(int flags, TosState tos_in, TosState tos_out, generato Bytecodes::Code Template::bytecode() const { - int i = this - TemplateTable::_template_table; - if (i < 0 || i >= Bytecodes::number_of_codes) i = this - TemplateTable::_template_table_wide; + int i = (int)(this - TemplateTable::_template_table); + if (i < 0 || i >= Bytecodes::number_of_codes) i = (int)(this - TemplateTable::_template_table_wide); return Bytecodes::cast(i); } diff --git a/src/hotspot/share/oops/markWord.hpp b/src/hotspot/share/oops/markWord.hpp index d7dc61d8024..7a21dccc5dd 100644 --- a/src/hotspot/share/oops/markWord.hpp +++ b/src/hotspot/share/oops/markWord.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -231,7 +231,7 @@ class markWord { markWord set_marked() { return markWord((value() & ~lock_mask_in_place) | marked_value); } markWord set_unmarked() { return markWord((value() & ~lock_mask_in_place) | unlocked_value); } - uint age() const { return mask_bits(value() >> age_shift, age_mask); } + uint age() const { return (uint) mask_bits(value() >> age_shift, age_mask); } markWord set_age(uint v) const { assert((v & ~age_mask) == 0, "shouldn't overflow age field"); return markWord((value() & ~age_mask_in_place) | ((v & age_mask) << age_shift)); diff --git a/src/hotspot/share/oops/stackChunkOop.inline.hpp b/src/hotspot/share/oops/stackChunkOop.inline.hpp index 1d5bb7ffa81..39d7dea2d76 100644 --- a/src/hotspot/share/oops/stackChunkOop.inline.hpp +++ b/src/hotspot/share/oops/stackChunkOop.inline.hpp @@ -123,7 +123,7 @@ inline int stackChunkOopDesc::to_offset(intptr_t* p) const { assert(is_in_chunk(p) || (p >= start_address() && (p - start_address()) <= stack_size() + frame::metadata_words), "p: " PTR_FORMAT " start: " PTR_FORMAT " end: " PTR_FORMAT, p2i(p), p2i(start_address()), p2i(bottom_address())); - return p - start_address(); + return (int)(p - start_address()); } inline intptr_t* stackChunkOopDesc::from_offset(int offset) const { diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 64dd10edab3..9216dd80502 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -715,7 +715,7 @@ void basic_types_init(); // cannot define here; uses assert // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java -enum BasicType { +enum BasicType : u1 { // The values T_BOOLEAN..T_LONG (4..11) are derived from the JVMS. T_BOOLEAN = JVM_T_BOOLEAN, T_CHAR = JVM_T_CHAR,