Skip to content

Commit

Permalink
4718400: Many quantities are held as signed that should be unsigned
Browse files Browse the repository at this point in the history
Reviewed-by: coleenp, rbackman, dholmes
  • Loading branch information
stefank committed Oct 27, 2021
1 parent 168081e commit 93be099
Show file tree
Hide file tree
Showing 52 changed files with 95 additions and 110 deletions.
8 changes: 4 additions & 4 deletions src/hotspot/share/cds/heapShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void HeapShared::copy_open_objects(GrowableArray<MemRegion>* open_regions) {
// Copy _pending_archive_roots into an objArray
void HeapShared::copy_roots() {
int length = _pending_roots != NULL ? _pending_roots->length() : 0;
int size = objArrayOopDesc::object_size(length);
size_t size = objArrayOopDesc::object_size(length);
Klass* k = Universe::objectArrayKlassObj(); // already relocated to point to archived klass
HeapWord* mem = G1CollectedHeap::heap()->archive_mem_allocate(size);

Expand All @@ -448,7 +448,7 @@ void HeapShared::copy_roots() {
for (int i = 0; i < length; i++) {
roots()->obj_at_put(i, _pending_roots->at(i));
}
log_info(cds)("archived obj roots[%d] = %d words, klass = %p, obj = %p", length, size, k, mem);
log_info(cds)("archived obj roots[%d] = " SIZE_FORMAT " words, klass = %p, obj = %p", length, size, k, mem);
}

void HeapShared::init_narrow_oop_decoding(address base, int shift) {
Expand Down Expand Up @@ -912,7 +912,7 @@ class WalkOopAndArchiveClosure: public BasicOopIterateClosure {

if (!_record_klasses_only && log_is_enabled(Debug, cds, heap)) {
ResourceMark rm;
log_debug(cds, heap)("(%d) %s[" SIZE_FORMAT "] ==> " PTR_FORMAT " size %d %s", _level,
log_debug(cds, heap)("(%d) %s[" SIZE_FORMAT "] ==> " PTR_FORMAT " size " SIZE_FORMAT " %s", _level,
_orig_referencing_obj->klass()->external_name(), field_delta,
p2i(obj), obj->size() * HeapWordSize, obj->klass()->external_name());
LogTarget(Trace, cds, heap) log;
Expand Down Expand Up @@ -1023,7 +1023,7 @@ oop HeapShared::archive_reachable_objects_from(int level,
ResourceMark rm;
log_error(cds, heap)(
"Cannot archive the sub-graph referenced from %s object ("
PTR_FORMAT ") size %d, skipped.",
PTR_FORMAT ") size " SIZE_FORMAT ", skipped.",
orig_obj->klass()->external_name(), p2i(orig_obj), orig_obj->size() * HeapWordSize);
if (level == 1) {
// Don't archive a subgraph root that's too big. For archives static fields, that's OK
Expand Down
7 changes: 4 additions & 3 deletions src/hotspot/share/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,10 +1377,11 @@ void java_lang_Class::fixup_module_field(Klass* k, Handle module) {
java_lang_Class::set_module(k->java_mirror(), module());
}

void java_lang_Class::set_oop_size(HeapWord* java_class, int size) {
void java_lang_Class::set_oop_size(HeapWord* java_class, size_t size) {
assert(_oop_size_offset != 0, "must be set");
assert(size > 0, "Oop size must be greater than zero, not %d", size);
*(int*)(((char*)java_class) + _oop_size_offset) = size;
assert(size > 0, "Oop size must be greater than zero, not " SIZE_FORMAT, size);
assert(size <= INT_MAX, "Lossy conversion: " SIZE_FORMAT, size);
*(int*)(((char*)java_class) + _oop_size_offset) = (int)size;
}

int java_lang_Class::static_oop_field_count(oop java_class) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/javaClasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ class java_lang_Class : AllStatic {
static oop source_file(oop java_class);
static void set_source_file(oop java_class, oop source_file);

static int oop_size(oop java_class);
static void set_oop_size(HeapWord* java_class, int size);
static size_t oop_size(oop java_class);
static void set_oop_size(HeapWord* java_class, size_t size);
static int static_oop_field_count(oop java_class);
static void set_static_oop_field_count(oop java_class, int size);

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/javaClasses.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ inline bool java_lang_Class::is_primitive(oop java_class) {
return is_primitive;
}

inline int java_lang_Class::oop_size(oop java_class) {
inline size_t java_lang_Class::oop_size(oop java_class) {
assert(_oop_size_offset != 0, "must be set");
int size = java_class->int_field(_oop_size_offset);
assert(size > 0, "Oop size must be greater than zero, not %d", size);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ void G1ConcurrentMark::scan_root_region(const MemRegion* region, uint worker_id)
while (curr < end) {
Prefetch::read(curr, interval);
oop obj = cast_to_oop(curr);
int size = obj->oop_iterate_size(&cl);
size_t size = obj->oop_iterate_size(&cl);
assert(size == obj->size(), "sanity");
curr += size;
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inline bool G1CMBitMap::iterate(G1CMBitMapClosure* cl, MemRegion mr) {
if (!cl->do_addr(addr)) {
return false;
}
size_t const obj_size = (size_t)cast_to_oop(addr)->size();
size_t const obj_size = cast_to_oop(addr)->size();
offset = _bm.get_next_one_offset(offset + (obj_size >> _shifter), end_offset);
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ size_t G1CMObjArrayProcessor::process_array_slice(objArrayOop obj, HeapWord* sta
}

size_t G1CMObjArrayProcessor::process_obj(oop obj) {
assert(should_be_sliced(obj), "Must be an array object %d and large " SIZE_FORMAT, obj->is_objArray(), (size_t)obj->size());
assert(should_be_sliced(obj), "Must be an array object %d and large " SIZE_FORMAT, obj->is_objArray(), obj->size());

return process_array_slice(objArrayOop(obj), cast_from_oop<HeapWord*>(obj), (size_t)objArrayOop(obj)->size());
return process_array_slice(objArrayOop(obj), cast_from_oop<HeapWord*>(obj), objArrayOop(obj)->size());
}

size_t G1CMObjArrayProcessor::process_slice(HeapWord* slice) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "runtime/globals.hpp"

inline bool G1CMObjArrayProcessor::should_be_sliced(oop obj) {
return obj->is_objArray() && ((size_t)((objArrayOop)obj)->size()) >= 2 * ObjArrayMarkingStride;
return obj->is_objArray() && ((objArrayOop)obj)->size() >= 2 * ObjArrayMarkingStride;
}

#endif // SHARE_GC_G1_G1CONCURRENTMARKOBJARRAYPROCESSOR_INLINE_HPP
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1RegionMarkStatsCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ G1RegionMarkStatsCache::~G1RegionMarkStatsCache() {

void G1RegionMarkStatsCache::add_live_words(oop obj) {
uint region_index = G1CollectedHeap::heap()->addr_to_region(cast_from_oop<HeapWord*>(obj));
add_live_words(region_index, (size_t) obj->size());
add_live_words(region_index, obj->size());
}

// Evict all remaining statistics, returning cache hits and misses.
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1YoungCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ class G1PrepareEvacuationTask : public WorkerTask {
}
log_debug(gc, humongous)("Humongous region %u (object size " SIZE_FORMAT " @ " PTR_FORMAT ") remset " SIZE_FORMAT " code roots " SIZE_FORMAT " marked %d reclaim candidate %d type array %d",
index,
(size_t)cast_to_oop(hr->bottom())->size() * HeapWordSize,
cast_to_oop(hr->bottom())->size() * HeapWordSize,
p2i(hr->bottom()),
hr->rem_set()->occupied(),
hr->rem_set()->strong_code_roots_list_length(),
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure {

log_debug(gc, humongous)("Reclaimed humongous region %u (object size " SIZE_FORMAT " @ " PTR_FORMAT ")",
region_idx,
(size_t)obj->size() * HeapWordSize,
obj->size() * HeapWordSize,
p2i(r->bottom())
);

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/heapRegion.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ HeapWord* HeapRegion::do_oops_on_memregion_in_humongous(MemRegion mr,
// If obj is not an objArray and mr contains the start of the
// obj, then this could be an imprecise mark, and we need to
// process the entire object.
int size = obj->oop_iterate_size(cl);
size_t size = obj->oop_iterate_size(cl);
// We have scanned to the end of the object, but since there can be no objects
// after this humongous object in the region, we can return the end of the
// region if it is greater.
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/parallel/parMarkBitMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ParMarkBitMap: public CHeapObj<mtGC>

// Atomically mark an object as live.
bool mark_obj(HeapWord* addr, size_t size);
inline bool mark_obj(oop obj, int size);
inline bool mark_obj(oop obj, size_t size);

// Return whether the specified begin or end bit is set.
inline bool is_obj_beg(idx_t bit) const;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/parallel/parMarkBitMap.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ inline ParMarkBitMap::IterationStatus ParMarkBitMap::iterate(ParMarkBitMapClosur
addr_to_bit(dead_range_end));
}

inline bool ParMarkBitMap::mark_obj(oop obj, int size) {
return mark_obj(cast_from_oop<HeapWord*>(obj), (size_t)size);
inline bool ParMarkBitMap::mark_obj(oop obj, size_t size) {
return mark_obj(cast_from_oop<HeapWord*>(obj), size);
}

inline ParMarkBitMap::idx_t ParMarkBitMap::addr_to_bit(HeapWord* addr) const {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/parallel/psClosure.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PSAdjustWeakRootsClosure final: public OopClosure {
oop new_obj = o->forwardee();
if (log_develop_is_enabled(Trace, gc, scavenge)) {
ResourceMark rm; // required by internal_name()
log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (" SIZE_FORMAT ")}",
"forwarding",
new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size());
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ inline void PSParallelCompact::check_new_location(HeapWord* old_addr, HeapWord*
#endif // ASSERT

inline bool PSParallelCompact::mark_obj(oop obj) {
const int obj_size = obj->size();
const size_t obj_size = obj->size();
if (mark_bitmap()->mark_obj(obj, obj_size)) {
_summary_data.add_obj(obj, obj_size);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/serial/defNewGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ void DefNewGeneration::restore_preserved_marks() {
}

void DefNewGeneration::handle_promotion_failure(oop old) {
log_debug(gc, promotion)("Promotion failure size = %d) ", old->size());
log_debug(gc, promotion)("Promotion failure size = " SIZE_FORMAT ") ", old->size());

_promotion_failed = true;
_promotion_failed_info.register_copy_failure(old->size());
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/serial/markSweep.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class MarkSweep : AllStatic {
static void adjust_marks(); // Adjust the pointers in the preserved marks table
static void restore_marks(); // Restore the marks that we saved in preserve_mark

static int adjust_pointers(oop obj);
static size_t adjust_pointers(oop obj);

static void follow_stack(); // Empty marking stack.

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/serial/markSweep.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ inline void AdjustPointerClosure::do_oop(oop* p) { do_oop_work(p); }
inline void AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_work(p); }


inline int MarkSweep::adjust_pointers(oop obj) {
inline size_t MarkSweep::adjust_pointers(oop obj) {
return obj->oop_iterate_size(&MarkSweep::adjust_pointer_closure);
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/cardTableBarrierSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void CardTableBarrierSet::flush_deferred_card_mark_barrier(JavaThread* thread) {
assert(!_card_table->is_in_young(old_obj),
"Else should have been filtered in on_slowpath_allocation_exit()");
assert(oopDesc::is_oop(old_obj, true), "Not an oop");
assert(deferred.word_size() == (size_t)(old_obj->size()),
assert(deferred.word_size() == old_obj->size(),
"Mismatch: multiple objects?");
}
write_region(deferred);
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/shared/collectedHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ class CollectedHeap : public CHeapObj<mtInternal> {
void set_gc_cause(GCCause::Cause v);
GCCause::Cause gc_cause() { return _gc_cause; }

oop obj_allocate(Klass* klass, int size, TRAPS);
virtual oop array_allocate(Klass* klass, int size, int length, bool do_zero, TRAPS);
oop class_allocate(Klass* klass, int size, TRAPS);
oop obj_allocate(Klass* klass, size_t size, TRAPS);
virtual oop array_allocate(Klass* klass, size_t size, int length, bool do_zero, TRAPS);
oop class_allocate(Klass* klass, size_t size, TRAPS);

// Utilities for turning raw memory into filler objects.
//
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/shared/collectedHeap.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
#include "oops/oop.inline.hpp"
#include "utilities/align.hpp"

inline oop CollectedHeap::obj_allocate(Klass* klass, int size, TRAPS) {
inline oop CollectedHeap::obj_allocate(Klass* klass, size_t size, TRAPS) {
ObjAllocator allocator(klass, size, THREAD);
return allocator.allocate();
}

inline oop CollectedHeap::array_allocate(Klass* klass, int size, int length, bool do_zero, TRAPS) {
inline oop CollectedHeap::array_allocate(Klass* klass, size_t size, int length, bool do_zero, TRAPS) {
ObjArrayAllocator allocator(klass, size, length, do_zero, THREAD);
return allocator.allocate();
}

inline oop CollectedHeap::class_allocate(Klass* klass, int size, TRAPS) {
inline oop CollectedHeap::class_allocate(Klass* klass, size_t size, TRAPS) {
ClassAllocator allocator(klass, size, THREAD);
return allocator.allocate();
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/genCollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ oop GenCollectedHeap::handle_failed_promotion(Generation* old_gen,
oop obj,
size_t obj_size) {
guarantee(old_gen == _old_gen, "We only get here with an old generation");
assert(obj_size == (size_t)obj->size(), "bad obj_size passed in");
assert(obj_size == obj->size(), "bad obj_size passed in");
HeapWord* result = NULL;

result = old_gen->expand_and_allocate(obj_size, false);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/generation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bool Generation::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const

// Ignores "ref" and calls allocate().
oop Generation::promote(oop obj, size_t obj_size) {
assert(obj_size == (size_t)obj->size(), "bad obj_size passed in");
assert(obj_size == obj->size(), "bad obj_size passed in");

#ifndef PRODUCT
if (GenCollectedHeap::heap()->promotion_should_fail()) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/memAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,6 @@ oop ClassAllocator::initialize(HeapWord* mem) const {
// concurrent GC.
assert(_word_size > 0, "oop_size must be positive.");
mem_clear(mem);
java_lang_Class::set_oop_size(mem, (int)_word_size);
java_lang_Class::set_oop_size(mem, _word_size);
return finish(mem);
}
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ HeapWord* ContiguousSpaceDCTOC::get_actual_top(HeapWord* top,
// Otherwise, it is possible that the object starting on the dirty
// card spans the entire card, and that the store happened on a
// later card. Figure out where the object ends.
assert(_sp->block_size(top_obj) == (size_t) cast_to_oop(top_obj)->size(),
assert(_sp->block_size(top_obj) == cast_to_oop(top_obj)->size(),
"Block size and object size mismatch");
top = top_obj + cast_to_oop(top_obj)->size();
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/space.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class DeadSpacer : StackObj {
oop obj = cast_to_oop(dead_start);
obj->set_mark(obj->mark().set_marked());

assert(dead_length == (size_t)obj->size(), "bad filler object size");
assert(dead_length == obj->size(), "bad filler object size");
log_develop_trace(gc, compaction)("Inserting object to dead space: " PTR_FORMAT ", " PTR_FORMAT ", " SIZE_FORMAT "b",
p2i(dead_start), p2i(dead_end), dead_length * HeapWordSize);

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ class ShenandoahCompactObjectsClosure : public ObjectClosure {

void do_object(oop p) {
assert(_heap->complete_marking_context()->is_marked(p), "must be marked");
size_t size = (size_t)p->size();
size_t size = p->size();
if (p->is_forwarded()) {
HeapWord* compact_from = cast_from_oop<HeapWord*>(p);
HeapWord* compact_to = cast_from_oop<HeapWord*>(p->forwardee());
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ inline void ShenandoahHeap::marked_object_iterate(ShenandoahHeapRegion* region,
oop obj = cast_to_oop(cs);
assert(oopDesc::is_oop(obj), "sanity");
assert(ctx->is_marked(obj), "object expected to be marked");
int size = obj->size();
size_t size = obj->size();
cl->do_object(obj);
cs += size;
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/z/zCollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ HeapWord* ZCollectedHeap::allocate_new_tlab(size_t min_size, size_t requested_si
return (HeapWord*)addr;
}

oop ZCollectedHeap::array_allocate(Klass* klass, int size, int length, bool do_zero, TRAPS) {
oop ZCollectedHeap::array_allocate(Klass* klass, size_t size, int length, bool do_zero, TRAPS) {
if (!do_zero) {
return CollectedHeap::array_allocate(klass, size, length, false /* do_zero */, THREAD);
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/z/zCollectedHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ZCollectedHeap : public CollectedHeap {

virtual uint32_t hash_oop(oop obj) const;

virtual oop array_allocate(Klass* klass, int size, int length, bool do_zero, TRAPS);
virtual oop array_allocate(Klass* klass, size_t size, int length, bool do_zero, TRAPS);
virtual HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
virtual MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
size_t size,
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp