8314932: G1: Fix -Wconversion warnings for simple cases inside g1 folder

Reviewed-by: tschatzl, iwalulya
This commit is contained in:
Albert Mingkun Yang 2023-08-29 16:04:50 +00:00
parent 762b652912
commit e22762c010
12 changed files with 14 additions and 20 deletions

View File

@ -94,7 +94,7 @@ G1Analytics::G1Analytics(const G1Predictions* predictor) :
_recent_prev_end_times_for_all_gcs_sec.add(os::elapsedTime());
_prev_collection_pause_end_ms = os::elapsedTime() * 1000.0;
int index = MIN2(ParallelGCThreads - 1, 7u);
uint index = MIN2(ParallelGCThreads - 1, 7u);
// Start with inverse of maximum STW cost.
_concurrent_refine_rate_ms_seq.add(1/cost_per_logged_card_ms_defaults[0]);

View File

@ -46,7 +46,7 @@ inline HeapWord* G1BlockOffsetTablePart::block_start_reaching_into_card(const vo
size_t index = _bot->index_for(addr);
uint offset = _bot->offset_array(index);
u_char offset = _bot->offset_array(index);
while (offset >= BOTConstants::card_size_in_words()) {
// The excess of the offset from N_words indicates a power of Base
// to go back by.

View File

@ -32,7 +32,7 @@ void G1CardTable::g1_mark_as_young(const MemRegion& mr) {
CardValue *const first = byte_for(mr.start());
CardValue *const last = byte_after(mr.last());
memset_with_concurrent_readers(first, g1_young_gen, last - first);
memset_with_concurrent_readers(first, g1_young_gen, pointer_delta(last, first, sizeof(CardValue)));
}
#ifndef PRODUCT

View File

@ -390,8 +390,8 @@ G1ConcurrentMark::G1ConcurrentMark(G1CollectedHeap* g1h,
// _num_active_tasks set in set_non_marking_state()
// _tasks set inside the constructor
_task_queues(new G1CMTaskQueueSet((int) _max_num_tasks)),
_terminator((int) _max_num_tasks, _task_queues),
_task_queues(new G1CMTaskQueueSet(_max_num_tasks)),
_terminator(_max_num_tasks, _task_queues),
_first_overflow_barrier_sync(),
_second_overflow_barrier_sync(),
@ -540,8 +540,8 @@ void G1ConcurrentMark::set_concurrency(uint active_tasks) {
// Need to update the three data structures below according to the
// number of active threads for this phase.
_terminator.reset_for_reuse(active_tasks);
_first_overflow_barrier_sync.set_n_workers((int) active_tasks);
_second_overflow_barrier_sync.set_n_workers((int) active_tasks);
_first_overflow_barrier_sync.set_n_workers(active_tasks);
_second_overflow_barrier_sync.set_n_workers(active_tasks);
}
void G1ConcurrentMark::set_concurrency_and_phase(uint active_tasks, bool concurrent) {

View File

@ -511,7 +511,7 @@ public:
// running.
void abort_marking_threads();
void update_accum_task_vtime(int i, double vtime) {
void update_accum_task_vtime(uint i, double vtime) {
_accum_task_vtime[i] += vtime;
}

View File

@ -74,7 +74,7 @@ size_t G1CMObjArrayProcessor::process_slice(HeapWord* slice) {
objArrayOop objArray = objArrayOop(cast_to_oop(start_address));
size_t already_scanned = slice - start_address;
size_t already_scanned = pointer_delta(slice, start_address);
size_t remaining = objArray->size() - already_scanned;
return process_array_slice(objArray, slice, remaining);

View File

@ -32,7 +32,7 @@
class G1EdenRegions {
private:
int _length;
uint _length;
// Sum of used bytes from all retired eden regions.
// I.e. updated when mutator regions are retired.
volatile size_t _used_bytes;

View File

@ -26,6 +26,7 @@
#include "gc/g1/g1FreeIdSet.hpp"
#include "memory/allocation.inline.hpp"
#include "runtime/atomic.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
@ -59,7 +60,7 @@ G1FreeIdSet::~G1FreeIdSet() {
}
uint G1FreeIdSet::head_index(uintx head) const {
return head & _head_index_mask;
return checked_cast<uint>(head & _head_index_mask);
}
uintx G1FreeIdSet::make_head(uint index, uintx old_head) const {

View File

@ -100,10 +100,6 @@ size_t G1PageBasedVirtualSpace::uncommitted_size() const {
return reserved_size() - committed_size();
}
size_t G1PageBasedVirtualSpace::addr_to_page_index(char* addr) const {
return (addr - _low_boundary) / _page_size;
}
bool G1PageBasedVirtualSpace::is_area_committed(size_t start_page, size_t size_in_pages) const {
size_t end_page = start_page + size_in_pages;
return _committed.find_first_clear_bit(start_page, end_page) >= end_page;

View File

@ -84,9 +84,6 @@ class G1PageBasedVirtualSpace {
// Uncommit the given memory range.
void uncommit_internal(size_t start_page, size_t end_page);
// Returns the index of the page which contains the given address.
size_t addr_to_page_index(char* addr) const;
// Is the given page index the last page?
bool is_last_page(size_t index) const { return index == (_committed.size() - 1); }
// Is the given page index the first after last page?

View File

@ -545,7 +545,7 @@ class G1ScanHRForRegionClosure : public HeapRegionClosure {
void do_claimed_block(uint const region_idx, CardValue* const dirty_l, CardValue* const dirty_r) {
_ct->change_dirty_cards_to(dirty_l, dirty_r, _scanned_card_value);
size_t num_cards = dirty_r - dirty_l;
size_t num_cards = pointer_delta(dirty_r, dirty_l, sizeof(CardValue));
_blocks_scanned++;
HeapWord* const card_start = _ct->addr_for(dirty_l);

View File

@ -103,7 +103,7 @@ bool G1RemSetTrackingPolicy::update_before_rebuild(HeapRegion* r, size_t live_by
assert(!r->rem_set()->is_updating(), "Remembered set of region %u is updating before rebuild", r->hrm_index());
size_t live_bytes_above_tams = (r->top() - r->top_at_mark_start()) * HeapWordSize;
size_t live_bytes_above_tams = pointer_delta(r->top(), r->top_at_mark_start()) * HeapWordSize;
size_t total_live_bytes = live_bytes_below_tams + live_bytes_above_tams;
bool selected_for_rebuild = false;