Skip to content
Permalink
Browse files
8263721: Unify oop casting
Reviewed-by: kbarrett, coleenp
  • Loading branch information
stefank committed Mar 24, 2021
1 parent 329697b commit a79f09569754f33b5d8b32a599ba74724d64c14f
Show file tree
Hide file tree
Showing 90 changed files with 248 additions and 249 deletions.
@@ -178,7 +178,7 @@ int MacroAssembler::patch_oop(address insn_addr, address o) {
// instruction.
if (Instruction_aarch64::extract(insn, 31, 21) == 0b11010010101) {
// Move narrow OOP
uint32_t n = CompressedOops::narrow_oop_value((oop)o);
uint32_t n = CompressedOops::narrow_oop_value(cast_to_oop(o));
Instruction_aarch64::patch(insn_addr, 20, 5, n >> 16);
Instruction_aarch64::patch(insn_addr+4, 20, 5, n & 0xffff);
instructions = 2;
@@ -58,7 +58,7 @@ void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
assert(type() == relocInfo::oop_type || type() == relocInfo::metadata_type,
"how to encode else?");
narrowOop no = (type() == relocInfo::oop_type) ?
CompressedOops::encode((oop)x) :
CompressedOops::encode(cast_to_oop(x)) :
// Type punning compressed klass pointer as narrowOop.
CompressedOops::narrow_oop_cast(CompressedKlassPointers::encode((Klass*)x));
nativeMovConstReg_at(addr())->set_narrow_oop(no, code());
@@ -297,7 +297,7 @@ BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result)
switch (type) {
case T_OBJECT:
case T_ARRAY: {
*oop_result = (oop) (void*) ijava_state()->oop_tmp;
*oop_result = cast_to_oop((void*) ijava_state()->oop_tmp);
break;
}
// We use std/stfd to store the values.
@@ -429,7 +429,7 @@ address NativeMovConstReg::set_data_plain(intptr_t src, CodeBlob *cb) {
}
// cOops
else if (MacroAssembler::is_load_narrow_oop(loc)) {
MacroAssembler::patch_load_narrow_oop(loc, (oop) (void*) x);
MacroAssembler::patch_load_narrow_oop(loc, cast_to_oop((void*) x));
ICache::invalidate_range(loc, MacroAssembler::load_narrow_oop_size());
next_address = next_instruction_address();
}
@@ -441,7 +441,7 @@ address NativeMovConstReg::set_data_plain(intptr_t src, CodeBlob *cb) {
}
// cOops
else if (MacroAssembler::is_compare_immediate_narrow_oop(loc)) {
MacroAssembler::patch_compare_immediate_narrow_oop(loc, (oop) (void*) x);
MacroAssembler::patch_compare_immediate_narrow_oop(loc, cast_to_oop((void*) x));
ICache::invalidate_range(loc, MacroAssembler::compare_immediate_narrow_oop_size());
next_address = next_instruction_address();
}
@@ -52,7 +52,7 @@ void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
address disp = Assembler::locate_operand(addr(), which);
// both compressed oops and compressed classes look the same
if (CompressedOops::is_in((void*)x)) {
uint32_t encoded = CompressedOops::narrow_oop_value((oop)x);
uint32_t encoded = CompressedOops::narrow_oop_value(cast_to_oop(x));
if (verify_only) {
guarantee(*(uint32_t*) disp == encoded, "instructions must match");
} else {
@@ -808,7 +808,7 @@ InterpreterFrame *InterpreterFrame::build(Method* const method, TRAPS) {
if (method->is_static())
object = method->constants()->pool_holder()->java_mirror();
else
object = (oop) (void*)locals[0];
object = cast_to_oop((void*)locals[0]);
monitor->set_obj(object);
}

@@ -1473,7 +1473,7 @@ objArrayOop java_lang_Class::signers(oop java_class) {
}
void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
assert(_signers_offset != 0, "must be set");
java_class->obj_field_put(_signers_offset, (oop)signers);
java_class->obj_field_put(_signers_offset, signers);
}

oop java_lang_Class::class_data(oop java_class) {
@@ -40,7 +40,7 @@ void java_lang_String::set_value_raw(oop string, typeArrayOop buffer) {
}

void java_lang_String::set_value(oop string, typeArrayOop buffer) {
string->obj_field_put(_value_offset, (oop)buffer);
string->obj_field_put(_value_offset, buffer);
}

bool java_lang_String::hash_is_set(oop java_string) {
@@ -486,10 +486,10 @@ class Dependencies: public ResourceObj {
bool is_oop() const { return _is_oop; }
bool is_metadata() const { return !_is_oop; }
bool is_klass() const { return is_metadata() && metadata_value()->is_klass(); }
bool is_method() const { return is_metadata() && metadata_value()->is_method(); }
bool is_method() const { return is_metadata() && metadata_value()->is_method(); }

oop oop_value() const { assert(_is_oop && _valid, "must be"); return (oop) _value; }
Metadata* metadata_value() const { assert(!_is_oop && _valid, "must be"); return (Metadata*) _value; }
oop oop_value() const { assert(_is_oop && _valid, "must be"); return cast_to_oop(_value); }
Metadata* metadata_value() const { assert(!_is_oop && _valid, "must be"); return (Metadata*) _value; }
};

static void print_dependency(DepType dept,
@@ -1026,7 +1026,7 @@ inline void nmethod::initialize_immediate_oop(oop* dest, jobject handle) {
if (handle == NULL ||
// As a special case, IC oops are initialized to 1 or -1.
handle == (jobject) Universe::non_oop_word()) {
(*dest) = (oop) handle;
(*dest) = cast_to_oop(handle);
} else {
(*dest) = JNIHandles::resolve_non_null(handle);
}
@@ -2721,7 +2721,7 @@ void nmethod::print_recorded_oops() {
for (int i = 0; i < n; i++) {
oop o = oop_at(i);
tty->print("#%*d: " INTPTR_FORMAT " ", log_n, i, p2i(o));
if (o == (oop)Universe::non_oop_word()) {
if ((void*)o == Universe::non_oop_word()) {
tty->print("non-oop word");
} else if (o == NULL) {
tty->print("NULL-oop");
@@ -278,7 +278,7 @@ void Relocation::set_value(address x) {
void Relocation::const_set_data_value(address x) {
#ifdef _LP64
if (format() == relocInfo::narrow_oop_in_const) {
*(narrowOop*)addr() = CompressedOops::encode((oop) x);
*(narrowOop*)addr() = CompressedOops::encode(cast_to_oop(x));
} else {
#endif
*(address*)addr() = x;
@@ -290,7 +290,7 @@ void Relocation::const_set_data_value(address x) {
void Relocation::const_verify_data_value(address x) {
#ifdef _LP64
if (format() == relocInfo::narrow_oop_in_const) {
guarantee(*(narrowOop*)addr() == CompressedOops::encode((oop) x), "must agree");
guarantee(*(narrowOop*)addr() == CompressedOops::encode(cast_to_oop(x)), "must agree");
} else {
#endif
guarantee(*(address*)addr() == x, "must agree");
@@ -720,7 +720,7 @@ void DerivedPointerTable::add(oop *derived_loc, oop *base_loc) {
);
}
// Set derived oop location to point to base.
*derived_loc = (oop)base_loc;
*derived_loc = cast_to_oop(base_loc);
Entry* entry = new Entry(derived_loc, offset);
Entry::_list->push(*entry);
}
@@ -737,7 +737,7 @@ void DerivedPointerTable::update_pointers() {
oop base = **(oop**)derived_loc;
assert(Universe::heap()->is_in_or_null(base), "must be an oop");

*derived_loc = (oop)(cast_from_oop<address>(base) + offset);
*derived_loc = cast_to_oop(cast_from_oop<address>(base) + offset);
assert(value_of_loc(derived_loc) - value_of_loc(&base) == offset, "sanity check");

if (TraceDerivedPointers) {
@@ -227,7 +227,7 @@ HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_slow(HeapWord
while (next_boundary < addr) {
while (n <= next_boundary) {
q = n;
oop obj = oop(q);
oop obj = cast_to_oop(q);
if (obj->klass_or_null_acquire() == NULL) return q;
n += block_size(q);
}
@@ -142,7 +142,7 @@ inline HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_const(
if (addr >= _hr->top()) return _hr->top();
while (n <= addr) {
q = n;
oop obj = oop(q);
oop obj = cast_to_oop(q);
if (obj->klass_or_null_acquire() == NULL) {
return q;
}
@@ -155,7 +155,7 @@ inline HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_const(

inline HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr(HeapWord* q,
const void* addr) {
if (oop(q)->klass_or_null_acquire() == NULL) {
if (cast_to_oop(q)->klass_or_null_acquire() == NULL) {
return q;
}
HeapWord* n = q + block_size(q);
@@ -3514,7 +3514,7 @@ class G1PrepareEvacuationTask : public AbstractGangTask {
bool humongous_region_is_candidate(HeapRegion* region) const {
assert(region->is_starts_humongous(), "Must start a humongous object");

oop obj = oop(region->bottom());
oop obj = cast_to_oop(region->bottom());

// Dead objects cannot be eager reclaim candidates. Due to class
// unloading it is unsafe to query their classes so we return early.
@@ -4357,7 +4357,7 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure {

G1CollectedHeap* g1h = G1CollectedHeap::heap();

oop obj = (oop)r->bottom();
oop obj = cast_to_oop(r->bottom());
G1CMBitMap* next_bitmap = g1h->concurrent_mark()->next_mark_bitmap();

// The following checks whether the humongous object is live are sufficient.
@@ -81,7 +81,7 @@ bool G1CMBitMapClosure::do_addr(HeapWord* const addr) {
// We move that task's local finger along.
_task->move_finger_to(addr);

_task->scan_task_entry(G1TaskQueueEntry::from_oop(oop(addr)));
_task->scan_task_entry(G1TaskQueueEntry::from_oop(cast_to_oop(addr)));
// we only partially drain the local queue and global stack
_task->drain_local_queue(true);
_task->drain_global_stack(true);
@@ -485,7 +485,7 @@ void G1ConcurrentMark::clear_statistics(HeapRegion* r) {
uint const region_idx = r->hrm_index();
if (r->is_humongous()) {
assert(r->is_starts_humongous(), "Got humongous continues region here");
uint const size_in_regions = (uint)_g1h->humongous_obj_size_in_regions(oop(r->humongous_start_region()->bottom())->size());
uint const size_in_regions = (uint)_g1h->humongous_obj_size_in_regions(cast_to_oop(r->humongous_start_region()->bottom())->size());
for (uint j = region_idx; j < (region_idx + size_in_regions); j++) {
clear_statistics_in_region(j);
}
@@ -853,7 +853,7 @@ void G1ConcurrentMark::scan_root_region(const MemRegion* region, uint worker_id)
const HeapWord* end = region->end();
while (curr < end) {
Prefetch::read(curr, interval);
oop obj = oop(curr);
oop obj = cast_to_oop(curr);
int size = obj->oop_iterate_size(&cl);
assert(size == obj->size(), "sanity");
curr += size;
@@ -1004,7 +1004,7 @@ class G1UpdateRemSetTrackingBeforeRebuildTask : public AbstractGangTask {
// note end of marking.
void distribute_marked_bytes(HeapRegion* hr, size_t marked_words) {
uint const region_idx = hr->hrm_index();
size_t const obj_size_in_words = (size_t)oop(hr->bottom())->size();
size_t const obj_size_in_words = (size_t)cast_to_oop(hr->bottom())->size();
uint const num_regions_in_humongous = (uint)G1CollectedHeap::humongous_obj_size_in_regions(obj_size_in_words);

// "Distributing" zero words means that we only note end of marking for these
@@ -1719,7 +1719,7 @@ class G1CMSATBBufferClosure : public SATBBufferClosure {
// circumspect about treating the argument as an object.
void do_entry(void* entry) const {
_task->increment_refs_reached();
oop const obj = static_cast<oop>(entry);
oop const obj = cast_to_oop(entry);
_task->make_reference_grey(obj);
}

@@ -2638,7 +2638,7 @@ void G1CMTask::do_marking_step(double time_target_ms,
// the object. It is easy to avoid this. We move the finger by
// enough to point to the next possible object header.
assert(_finger < _region_limit, "invariant");
HeapWord* const new_finger = _finger + ((oop)_finger)->size();
HeapWord* const new_finger = _finger + cast_to_oop(_finger)->size();
// Check if bitmap iteration was aborted while scanning the last object
if (new_finger >= _region_limit) {
giveup_current_region();
@@ -72,7 +72,7 @@ class G1TaskQueueEntry {

oop obj() const {
assert(!is_array_slice(), "Trying to read array slice " PTR_FORMAT " as oop", p2i(_holder));
return (oop)_holder;
return cast_to_oop(_holder);
}

HeapWord* slice() const {
@@ -45,7 +45,7 @@ inline bool G1CMBitMap::iterate(G1CMBitMapClosure* cl, MemRegion mr) {
if (!cl->do_addr(addr)) {
return false;
}
size_t const obj_size = (size_t)((oop)addr)->size();
size_t const obj_size = (size_t)cast_to_oop(addr)->size();
offset = _bm.get_next_one_offset(offset + (obj_size >> _shifter), end_offset);
}
return true;
@@ -61,13 +61,13 @@ size_t G1CMObjArrayProcessor::process_slice(HeapWord* slice) {
r->humongous_start_region()->bottom() :
g1h->block_start(slice);

assert(oop(start_address)->is_objArray(), "Address " PTR_FORMAT " does not refer to an object array ", p2i(start_address));
assert(cast_to_oop(start_address)->is_objArray(), "Address " PTR_FORMAT " does not refer to an object array ", p2i(start_address));
assert(start_address < slice,
"Object start address " PTR_FORMAT " must be smaller than decoded address " PTR_FORMAT,
p2i(start_address),
p2i(slice));

objArrayOop objArray = objArrayOop(start_address);
objArrayOop objArray = objArrayOop(cast_to_oop(start_address));

size_t already_scanned = slice - start_address;
size_t remaining = objArray->size() - already_scanned;
@@ -172,7 +172,7 @@ class RemoveSelfForwardPtrObjClosure: public ObjectClosure {
if (gap_size >= CollectedHeap::min_fill_size()) {
CollectedHeap::fill_with_objects(start, gap_size);

HeapWord* end_first_obj = start + ((oop)start)->size();
HeapWord* end_first_obj = start + cast_to_oop(start)->size();
_hr->cross_threshold(start, end_first_obj);
// Fill_with_objects() may have created multiple (i.e. two)
// objects, as the max_fill_size() is half a region.
@@ -181,7 +181,7 @@ class RemoveSelfForwardPtrObjClosure: public ObjectClosure {
if (end_first_obj != end) {
_hr->cross_threshold(end_first_obj, end);
#ifdef ASSERT
size_t size_second_obj = ((oop)end_first_obj)->size();
size_t size_second_obj = cast_to_oop(end_first_obj)->size();
HeapWord* end_of_second_obj = end_first_obj + size_second_obj;
assert(end == end_of_second_obj,
"More than two objects were used to fill the area from " PTR_FORMAT " to " PTR_FORMAT ", "
@@ -65,7 +65,7 @@ class G1AdjustRegionClosure : public HeapRegionClosure {
if (r->is_humongous()) {
// Special handling for humongous regions to get somewhat better
// work distribution.
oop obj = oop(r->humongous_start_region()->bottom());
oop obj = cast_to_oop(r->humongous_start_region()->bottom());
obj->oop_iterate(&cl, MemRegion(r->bottom(), r->top()));
} else if (!r->is_closed_archive() && !r->is_free()) {
// Closed archive regions never change references and only contain
@@ -44,7 +44,7 @@ class G1ResetPinnedClosure : public HeapRegionClosure {
if (!r->is_pinned()) {
return false;
}
assert(!r->is_starts_humongous() || _bitmap->is_marked((oop)r->bottom()),
assert(!r->is_starts_humongous() || _bitmap->is_marked(cast_to_oop(r->bottom())),
"must be, otherwise reclaimed earlier");
r->reset_pinned_after_full_gc();
return false;
@@ -63,8 +63,8 @@ size_t G1FullGCCompactTask::G1CompactRegionClosure::apply(oop obj) {
HeapWord* obj_addr = cast_from_oop<HeapWord*>(obj);
assert(obj_addr != destination, "everything in this pass should be moving");
Copy::aligned_conjoint_words(obj_addr, destination, size);
oop(destination)->init_mark();
assert(oop(destination)->klass() != NULL, "should have a class");
cast_to_oop(destination)->init_mark();
assert(cast_to_oop(destination)->klass() != NULL, "should have a class");

return size;
}
@@ -103,7 +103,7 @@ void G1FullGCCompactionPoint::forward(oop object, size_t size) {

// Store a forwarding pointer if the object should be moved.
if (cast_from_oop<HeapWord*>(object) != _compaction_top) {
object->forward_to(oop(_compaction_top));
object->forward_to(cast_to_oop(_compaction_top));
} else {
if (object->forwardee() != NULL) {
// Object should not move but mark-word is used so it looks like the
@@ -45,7 +45,7 @@ bool G1FullGCPrepareTask::G1CalculatePointersClosure::do_heap_region(HeapRegion*
// prepare them for compaction. The adjust pointers phase will skip
// work for them.
if (hr->is_humongous()) {
oop obj = oop(hr->humongous_start_region()->bottom());
oop obj = cast_to_oop(hr->humongous_start_region()->bottom());
if (!_bitmap->is_marked(obj)) {
free_humongous_region(hr);
}
@@ -233,7 +233,7 @@ void G1ParCopyClosure<barrier, should_mark>::do_oop_work(T* p) {
oop forwardee;
markWord m = obj->mark();
if (m.is_marked()) {
forwardee = (oop) m.decode_pointer();
forwardee = cast_to_oop(m.decode_pointer());
} else {
forwardee = _par_scan_state->copy_to_survivor_space(state, obj, m);
}
@@ -203,7 +203,7 @@ void G1ParScanThreadState::do_oop_evac(T* p) {

markWord m = obj->mark();
if (m.is_marked()) {
obj = (oop) m.decode_pointer();
obj = cast_to_oop(m.decode_pointer());
} else {
obj = do_copy_to_survivor_space(region_attr, obj, m);
}
@@ -473,7 +473,7 @@ oop G1ParScanThreadState::do_copy_to_survivor_space(G1HeapRegionAttr const regio
// We're going to allocate linearly, so might as well prefetch ahead.
Prefetch::write(obj_ptr, PrefetchCopyIntervalInBytes);

const oop obj = oop(obj_ptr);
const oop obj = cast_to_oop(obj_ptr);
const oop forward_ptr = old->forward_to_atomic(obj, old_mark, memory_order_relaxed);
if (forward_ptr == NULL) {
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(old), obj_ptr, word_sz);

0 comments on commit a79f095

Please sign in to comment.