aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Stefan Karlsson <stefank@openjdk.org> 2021-03-24 10:28:38 +0000
committerGravatar Stefan Karlsson <stefank@openjdk.org> 2021-03-24 10:28:38 +0000
commita79f09569754f33b5d8b32a599ba74724d64c14f (patch)
treee1a8da58ae20b3ab8114b626c24f328a60ae7258
parent329697b02ee66b5bb767634dbf3ba19f6624c8d3 (diff)
downloadjdk-a79f09569754f33b5d8b32a599ba74724d64c14f.tar.gz
jdk-a79f09569754f33b5d8b32a599ba74724d64c14f.zip
8263721: Unify oop casting
Reviewed-by: kbarrett, coleenp
-rw-r--r--src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp2
-rw-r--r--src/hotspot/cpu/ppc/relocInfo_ppc.cpp2
-rw-r--r--src/hotspot/cpu/s390/frame_s390.cpp2
-rw-r--r--src/hotspot/cpu/s390/nativeInst_s390.cpp4
-rw-r--r--src/hotspot/cpu/x86/relocInfo_x86.cpp2
-rw-r--r--src/hotspot/cpu/zero/zeroInterpreter_zero.cpp2
-rw-r--r--src/hotspot/share/classfile/javaClasses.cpp2
-rw-r--r--src/hotspot/share/classfile/javaClasses.inline.hpp2
-rw-r--r--src/hotspot/share/code/dependencies.hpp6
-rw-r--r--src/hotspot/share/code/nmethod.cpp4
-rw-r--r--src/hotspot/share/code/relocInfo.cpp4
-rw-r--r--src/hotspot/share/compiler/oopMap.cpp4
-rw-r--r--src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp2
-rw-r--r--src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp4
-rw-r--r--src/hotspot/share/gc/g1/g1CollectedHeap.cpp4
-rw-r--r--src/hotspot/share/gc/g1/g1ConcurrentMark.cpp12
-rw-r--r--src/hotspot/share/gc/g1/g1ConcurrentMark.hpp2
-rw-r--r--src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp2
-rw-r--r--src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.cpp4
-rw-r--r--src/hotspot/share/gc/g1/g1EvacFailure.cpp4
-rw-r--r--src/hotspot/share/gc/g1/g1FullGCAdjustTask.cpp2
-rw-r--r--src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp6
-rw-r--r--src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp2
-rw-r--r--src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp2
-rw-r--r--src/hotspot/share/gc/g1/g1OopClosures.inline.hpp2
-rw-r--r--src/hotspot/share/gc/g1/g1ParScanThreadState.cpp4
-rw-r--r--src/hotspot/share/gc/g1/g1RemSet.cpp8
-rw-r--r--src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp4
-rw-r--r--src/hotspot/share/gc/g1/g1SATBMarkQueueSet.cpp4
-rw-r--r--src/hotspot/share/gc/g1/heapRegion.cpp8
-rw-r--r--src/hotspot/share/gc/g1/heapRegion.inline.hpp10
-rw-r--r--src/hotspot/share/gc/parallel/mutableSpace.cpp10
-rw-r--r--src/hotspot/share/gc/parallel/objectStartArray.inline.hpp2
-rw-r--r--src/hotspot/share/gc/parallel/parMarkBitMap.cpp4
-rw-r--r--src/hotspot/share/gc/parallel/psCardTable.cpp10
-rw-r--r--src/hotspot/share/gc/parallel/psOldGen.cpp6
-rw-r--r--src/hotspot/share/gc/parallel/psParallelCompact.cpp14
-rw-r--r--src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp2
-rw-r--r--src/hotspot/share/gc/parallel/psPromotionLAB.cpp2
-rw-r--r--src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp12
-rw-r--r--src/hotspot/share/gc/parallel/psScavenge.cpp2
-rw-r--r--src/hotspot/share/gc/serial/defNewGeneration.cpp2
-rw-r--r--src/hotspot/share/gc/serial/markSweep.inline.hpp2
-rw-r--r--src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp2
-rw-r--r--src/hotspot/share/gc/shared/blockOffsetTable.cpp2
-rw-r--r--src/hotspot/share/gc/shared/cardTableBarrierSet.cpp2
-rw-r--r--src/hotspot/share/gc/shared/cardTableRS.cpp4
-rw-r--r--src/hotspot/share/gc/shared/genCollectedHeap.cpp2
-rw-r--r--src/hotspot/share/gc/shared/generation.cpp2
-rw-r--r--src/hotspot/share/gc/shared/locationPrinter.inline.hpp4
-rw-r--r--src/hotspot/share/gc/shared/memAllocator.cpp2
-rw-r--r--src/hotspot/share/gc/shared/space.cpp54
-rw-r--r--src/hotspot/share/gc/shared/space.inline.hpp36
-rw-r--r--src/hotspot/share/gc/shared/taskqueue.hpp2
-rw-r--r--src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp2
-rw-r--r--src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp14
-rw-r--r--src/hotspot/share/gc/shenandoah/shenandoahForwarding.hpp4
-rw-r--r--src/hotspot/share/gc/shenandoah/shenandoahForwarding.inline.hpp14
-rw-r--r--src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp14
-rw-r--r--src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp2
-rw-r--r--src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp10
-rw-r--r--src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp10
-rw-r--r--src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp14
-rw-r--r--src/hotspot/share/gc/z/zObjArrayAllocator.cpp2
-rw-r--r--src/hotspot/share/interpreter/interpreterRuntime.cpp2
-rw-r--r--src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp14
-rw-r--r--src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp2
-rw-r--r--src/hotspot/share/jvmci/jvmciRuntime.cpp6
-rw-r--r--src/hotspot/share/memory/filemap.cpp2
-rw-r--r--src/hotspot/share/memory/heapShared.cpp6
-rw-r--r--src/hotspot/share/memory/heapShared.inline.hpp2
-rw-r--r--src/hotspot/share/oops/compressedOops.inline.hpp2
-rw-r--r--src/hotspot/share/oops/constantPool.cpp4
-rw-r--r--src/hotspot/share/oops/instanceKlass.cpp2
-rw-r--r--src/hotspot/share/oops/oop.cpp4
-rw-r--r--src/hotspot/share/oops/oop.inline.hpp6
-rw-r--r--src/hotspot/share/oops/oopsHierarchy.hpp23
-rw-r--r--src/hotspot/share/prims/jvm.cpp2
-rw-r--r--src/hotspot/share/prims/jvmtiEnv.cpp2
-rw-r--r--src/hotspot/share/prims/jvmtiExport.cpp2
-rw-r--r--src/hotspot/share/prims/vectorSupport.cpp2
-rw-r--r--src/hotspot/share/runtime/deoptimization.cpp4
-rw-r--r--src/hotspot/share/runtime/objectMonitor.cpp2
-rw-r--r--src/hotspot/share/runtime/reflection.cpp4
-rw-r--r--src/hotspot/share/runtime/vframe.cpp4
-rw-r--r--src/hotspot/share/runtime/vframeArray.cpp4
-rw-r--r--src/hotspot/share/runtime/vframe_hp.cpp2
-rw-r--r--src/hotspot/share/services/diagnosticCommand.cpp2
-rw-r--r--src/hotspot/share/utilities/debug.cpp2
-rw-r--r--test/hotspot/gtest/oops/test_typeArrayOop.cpp2
90 files changed, 248 insertions, 249 deletions
diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
index c577d6ada84..dc355b0d4f4 100644
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
@@ -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;
diff --git a/src/hotspot/cpu/ppc/relocInfo_ppc.cpp b/src/hotspot/cpu/ppc/relocInfo_ppc.cpp
index f940a7e0fb8..71ced03459f 100644
--- a/src/hotspot/cpu/ppc/relocInfo_ppc.cpp
+++ b/src/hotspot/cpu/ppc/relocInfo_ppc.cpp
@@ -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());
diff --git a/src/hotspot/cpu/s390/frame_s390.cpp b/src/hotspot/cpu/s390/frame_s390.cpp
index 3f232c2ef21..94f109b5721 100644
--- a/src/hotspot/cpu/s390/frame_s390.cpp
+++ b/src/hotspot/cpu/s390/frame_s390.cpp
@@ -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.
diff --git a/src/hotspot/cpu/s390/nativeInst_s390.cpp b/src/hotspot/cpu/s390/nativeInst_s390.cpp
index 62697e03bf9..79fb7b61c57 100644
--- a/src/hotspot/cpu/s390/nativeInst_s390.cpp
+++ b/src/hotspot/cpu/s390/nativeInst_s390.cpp
@@ -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();
}
diff --git a/src/hotspot/cpu/x86/relocInfo_x86.cpp b/src/hotspot/cpu/x86/relocInfo_x86.cpp
index 794bfb7bf3e..d7a9e667237 100644
--- a/src/hotspot/cpu/x86/relocInfo_x86.cpp
+++ b/src/hotspot/cpu/x86/relocInfo_x86.cpp
@@ -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 {
diff --git a/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp b/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp
index 9300338051b..50901798f6c 100644
--- a/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp
+++ b/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp
@@ -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);
}
diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp
index e66939ab819..ca3b73c199d 100644
--- a/src/hotspot/share/classfile/javaClasses.cpp
+++ b/src/hotspot/share/classfile/javaClasses.cpp
@@ -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) {
diff --git a/src/hotspot/share/classfile/javaClasses.inline.hpp b/src/hotspot/share/classfile/javaClasses.inline.hpp
index 5cf6c0dc937..9917626d010 100644
--- a/src/hotspot/share/classfile/javaClasses.inline.hpp
+++ b/src/hotspot/share/classfile/javaClasses.inline.hpp
@@ -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) {
diff --git a/src/hotspot/share/code/dependencies.hpp b/src/hotspot/share/code/dependencies.hpp
index 55bbc11502a..1a8c5022014 100644
--- a/src/hotspot/share/code/dependencies.hpp
+++ b/src/hotspot/share/code/dependencies.hpp
@@ -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,
diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp
index c13455efae1..c6c4a3c6031 100644
--- a/src/hotspot/share/code/nmethod.cpp
+++ b/src/hotspot/share/code/nmethod.cpp
@@ -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");
diff --git a/src/hotspot/share/code/relocInfo.cpp b/src/hotspot/share/code/relocInfo.cpp
index 39c14d739ef..6f15e502810 100644
--- a/src/hotspot/share/code/relocInfo.cpp
+++ b/src/hotspot/share/code/relocInfo.cpp
@@ -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");
diff --git a/src/hotspot/share/compiler/oopMap.cpp b/src/hotspot/share/compiler/oopMap.cpp
index 4a7b9540b73..45141743528 100644
--- a/src/hotspot/share/compiler/oopMap.cpp
+++ b/src/hotspot/share/compiler/oopMap.cpp
@@ -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) {
diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp
index 277c9e38228..30843eb5d20 100644
--- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp
+++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp
@@ -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);
}
diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp
index 4941641c688..f88319eccb3 100644
--- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp
+++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp
@@ -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);
diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
index bb27fd6eb83..282f6428d11 100644
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
@@ -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.
diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
index 270a89b7a55..2c35ae70702 100644
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
@@ -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 @@ private:
// 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();
diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp
index 0c5b59131de..26728c4a16c 100644
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp
@@ -72,7 +72,7 @@ public:
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 {
diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp b/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp
index 851a8fb909a..d45f3b0263a 100644
--- a/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp
@@ -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;
diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.cpp
index a318481ce8b..81f377d2b68 100644
--- a/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.cpp
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.cpp
@@ -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;
diff --git a/src/hotspot/share/gc/g1/g1EvacFailure.cpp b/src/hotspot/share/gc/g1/g1EvacFailure.cpp
index 1a018269419..9b8fd794456 100644
--- a/src/hotspot/share/gc/g1/g1EvacFailure.cpp
+++ b/src/hotspot/share/gc/g1/g1EvacFailure.cpp
@@ -172,7 +172,7 @@ public:
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 @@ public:
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 ", "
diff --git a/src/hotspot/share/gc/g1/g1FullGCAdjustTask.cpp b/src/hotspot/share/gc/g1/g1FullGCAdjustTask.cpp
index 80dd4288b20..87205049926 100644
--- a/src/hotspot/share/gc/g1/g1FullGCAdjustTask.cpp
+++ b/src/hotspot/share/gc/g1/g1FullGCAdjustTask.cpp
@@ -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
diff --git a/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp b/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
index 8a0a5c4c0eb..4ce2c995f6c 100644
--- a/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
+++ b/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
@@ -44,7 +44,7 @@ public:
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;
}
diff --git a/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp b/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp
index c70f1f02f00..499ae94c12b 100644
--- a/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp
+++ b/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp
@@ -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
diff --git a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
index 7b072fc49d4..b85e116b57c 100644
--- a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
+++ b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
@@ -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);
}
diff --git a/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp b/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp
index 78fdf820707..e1790bdf657 100644
--- a/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp
+++ b/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp
@@ -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);
}
diff --git a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp
index ce1eb33a543..6744ab49ac4 100644
--- a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp
+++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp
@@ -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);
diff --git a/src/hotspot/share/gc/g1/g1RemSet.cpp b/src/hotspot/share/gc/g1/g1RemSet.cpp
index a737da25cea..48af1fa65a2 100644
--- a/src/hotspot/share/gc/g1/g1RemSet.cpp
+++ b/src/hotspot/share/gc/g1/g1RemSet.cpp
@@ -1693,8 +1693,8 @@ class G1RebuildRemSetTask: public AbstractGangTask {
// Step to the next live object within the MemRegion if needed.
if (is_live(_current)) {
// Non-objArrays were scanned by the previous part of that region.
- if (_current < mr.start() && !oop(_current)->is_objArray()) {
- _current += oop(_current)->size();
+ if (_current < mr.start() && !cast_to_oop(_current)->is_objArray()) {
+ _current += cast_to_oop(_current)->size();
// We might have positioned _current on a non-live object. Reposition to the next
// live one if needed.
move_if_below_tams();
@@ -1715,7 +1715,7 @@ class G1RebuildRemSetTask: public AbstractGangTask {
}
oop next() const {
- oop result = oop(_current);
+ oop result = cast_to_oop(_current);
assert(is_live(_current),
"Object " PTR_FORMAT " must be live TAMS " PTR_FORMAT " below %d mr " PTR_FORMAT " " PTR_FORMAT " outside %d",
p2i(_current), p2i(_tams), _tams > _current, p2i(_mr.start()), p2i(_mr.end()), _mr.contains(result));
@@ -1739,7 +1739,7 @@ class G1RebuildRemSetTask: public AbstractGangTask {
size_t marked_words = 0;
if (hr->is_humongous()) {
- oop const humongous_obj = oop(hr->humongous_start_region()->bottom());
+ oop const humongous_obj = cast_to_oop(hr->humongous_start_region()->bottom());
if (is_humongous_live(humongous_obj, bitmap, top_at_mark_start, top_at_rebuild_start)) {
// We need to scan both [bottom, TAMS) and [TAMS, top_at_rebuild_start);
// however in case of humongous objects it is sufficient to scan the encompassing
diff --git a/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp b/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp
index 20d43de49fe..661a9bd059c 100644
--- a/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp
+++ b/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp
@@ -93,7 +93,7 @@ bool G1RemSetTrackingPolicy::update_humongous_before_rebuild(HeapRegion* r, bool
// For humongous regions, to be of interest for rebuilding the remembered set the following must apply:
// - We always try to update the remembered sets of humongous regions containing
// type arrays as they might have been reset after full gc.
- if (is_live && oop(r->humongous_start_region()->bottom())->is_typeArray() && !r->rem_set()->is_tracked()) {
+ if (is_live && cast_to_oop(r->humongous_start_region()->bottom())->is_typeArray() && !r->rem_set()->is_tracked()) {
r->rem_set()->set_state_updating();
selected_for_rebuild = true;
}
@@ -152,7 +152,7 @@ void G1RemSetTrackingPolicy::update_after_rebuild(HeapRegion* r) {
// cycle as e.g. remembered set entries will always be added.
if (r->is_starts_humongous() && !g1h->is_potential_eager_reclaim_candidate(r)) {
// Handle HC regions with the HS region.
- uint const size_in_regions = (uint)g1h->humongous_obj_size_in_regions(oop(r->bottom())->size());
+ uint const size_in_regions = (uint)g1h->humongous_obj_size_in_regions(cast_to_oop(r->bottom())->size());
uint const region_idx = r->hrm_index();
for (uint j = region_idx; j < (region_idx + size_in_regions); j++) {
HeapRegion* const cur = g1h->region_at(j);
diff --git a/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.cpp b/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.cpp
index 15fbfb5c91a..bc6957cd356 100644
--- a/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.cpp
+++ b/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.cpp
@@ -91,14 +91,14 @@ static inline bool requires_marking(const void* entry, G1CollectedHeap* g1h) {
return false;
}
- assert(oopDesc::is_oop(oop(entry), true /* ignore mark word */),
+ assert(oopDesc::is_oop(cast_to_oop(entry), true /* ignore mark word */),
"Invalid oop in SATB buffer: " PTR_FORMAT, p2i(entry));
return true;
}
static inline bool discard_entry(const void* entry, G1CollectedHeap* g1h) {
- return !requires_marking(entry, g1h) || g1h->is_marked_next((oop)entry);
+ return !requires_marking(entry, g1h) || g1h->is_marked_next(cast_to_oop(entry));
}
// Workaround for not yet having std::bind.
diff --git a/src/hotspot/share/gc/g1/heapRegion.cpp b/src/hotspot/share/gc/g1/heapRegion.cpp
index eb51ac8acac..7f96e981d86 100644
--- a/src/hotspot/share/gc/g1/heapRegion.cpp
+++ b/src/hotspot/share/gc/g1/heapRegion.cpp
@@ -666,7 +666,7 @@ void HeapRegion::verify(VerifyOption vo,
bool is_region_humongous = is_humongous();
size_t object_num = 0;
while (p < top()) {
- oop obj = oop(p);
+ oop obj = cast_to_oop(p);
size_t obj_size = block_size(p);
object_num += 1;
@@ -726,7 +726,7 @@ void HeapRegion::verify(VerifyOption vo,
}
if (is_region_humongous) {
- oop obj = oop(this->humongous_start_region()->bottom());
+ oop obj = cast_to_oop(this->humongous_start_region()->bottom());
if (cast_from_oop<HeapWord*>(obj) > bottom() || cast_from_oop<HeapWord*>(obj) + obj->size() < bottom()) {
log_error(gc, verify)("this humongous region is not part of its' humongous object " PTR_FORMAT, p2i(obj));
*failures = true;
@@ -811,7 +811,7 @@ void HeapRegion::verify_rem_set(VerifyOption vo, bool* failures) const {
HeapWord* prev_p = NULL;
VerifyRemSetClosure vr_cl(g1h, vo);
while (p < top()) {
- oop obj = oop(p);
+ oop obj = cast_to_oop(p);
size_t obj_size = block_size(p);
if (!g1h->is_obj_dead_cond(obj, this, vo)) {
@@ -873,7 +873,7 @@ void HeapRegion::object_iterate(ObjectClosure* blk) {
HeapWord* p = bottom();
while (p < top()) {
if (block_is_obj(p)) {
- blk->do_object(oop(p));
+ blk->do_object(cast_to_oop(p));
}
p += block_size(p);
}
diff --git a/src/hotspot/share/gc/g1/heapRegion.inline.hpp b/src/hotspot/share/gc/g1/heapRegion.inline.hpp
index d58895b434c..8eb3c4fb9f2 100644
--- a/src/hotspot/share/gc/g1/heapRegion.inline.hpp
+++ b/src/hotspot/share/gc/g1/heapRegion.inline.hpp
@@ -142,7 +142,7 @@ inline bool HeapRegion::block_is_obj(const HeapWord* p) const {
return (p == humongous_start_region()->bottom());
}
if (ClassUnloadingWithConcurrentMark) {
- return !g1h->is_obj_dead(oop(p), this);
+ return !g1h->is_obj_dead(cast_to_oop(p), this);
}
return p < top();
}
@@ -175,7 +175,7 @@ inline size_t HeapRegion::block_size(const HeapWord *addr) const {
}
if (block_is_obj(addr)) {
- return oop(addr)->size();
+ return cast_to_oop(addr)->size();
}
return block_size_using_bitmap(addr, G1CollectedHeap::heap()->concurrent_mark()->prev_mark_bitmap());
@@ -236,7 +236,7 @@ inline void HeapRegion::apply_to_marked_objects(G1CMBitMap* bitmap, ApplyToMarke
// some extra work done by get_next_marked_addr for
// the case where next_addr is marked.
if (bitmap->is_marked(next_addr)) {
- oop current = oop(next_addr);
+ oop current = cast_to_oop(next_addr);
next_addr += closure->apply(current);
} else {
next_addr = bitmap->get_next_marked_addr(next_addr, limit);
@@ -288,7 +288,7 @@ HeapWord* HeapRegion::do_oops_on_memregion_in_humongous(MemRegion mr,
G1CollectedHeap* g1h) {
assert(is_humongous(), "precondition");
HeapRegion* sr = humongous_start_region();
- oop obj = oop(sr->bottom());
+ oop obj = cast_to_oop(sr->bottom());
// If concurrent and klass_or_null is NULL, then space has been
// allocated but the object has not yet been published by setting
@@ -368,7 +368,7 @@ HeapWord* HeapRegion::oops_on_memregion_seq_iterate_careful(MemRegion mr,
const G1CMBitMap* const bitmap = g1h->concurrent_mark()->prev_mark_bitmap();
while (true) {
- oop obj = oop(cur);
+ oop obj = cast_to_oop(cur);
assert(oopDesc::is_oop(obj, true), "Not an oop at " PTR_FORMAT, p2i(cur));
assert(obj->klass_or_null() != NULL,
"Unparsable heap at " PTR_FORMAT, p2i(cur));
diff --git a/src/hotspot/share/gc/parallel/mutableSpace.cpp b/src/hotspot/share/gc/parallel/mutableSpace.cpp
index defb1ffd04e..363e115d10d 100644
--- a/src/hotspot/share/gc/parallel/mutableSpace.cpp
+++ b/src/hotspot/share/gc/parallel/mutableSpace.cpp
@@ -229,15 +229,15 @@ void MutableSpace::oop_iterate(OopIterateClosure* cl) {
HeapWord* t = top();
// Could call objects iterate, but this is easier.
while (obj_addr < t) {
- obj_addr += oop(obj_addr)->oop_iterate_size(cl);
+ obj_addr += cast_to_oop(obj_addr)->oop_iterate_size(cl);
}
}
void MutableSpace::object_iterate(ObjectClosure* cl) {
HeapWord* p = bottom();
while (p < top()) {
- cl->do_object(oop(p));
- p += oop(p)->size();
+ cl->do_object(cast_to_oop(p));
+ p += cast_to_oop(p)->size();
}
}
@@ -259,9 +259,9 @@ void MutableSpace::verify() {
HeapWord* t = top();
HeapWord* prev_p = NULL;
while (p < t) {
- oopDesc::verify(oop(p));
+ oopDesc::verify(cast_to_oop(p));
prev_p = p;
- p += oop(p)->size();
+ p += cast_to_oop(p)->size();
}
guarantee(p == top(), "end of last object must match end of space");
}
diff --git a/src/hotspot/share/gc/parallel/objectStartArray.inline.hpp b/src/hotspot/share/gc/parallel/objectStartArray.inline.hpp
index 6af0fed77e1..75650a6e1cf 100644
--- a/src/hotspot/share/gc/parallel/objectStartArray.inline.hpp
+++ b/src/hotspot/share/gc/parallel/objectStartArray.inline.hpp
@@ -42,7 +42,7 @@ HeapWord* ObjectStartArray::object_start(HeapWord* addr) const {
HeapWord* next = scroll_forward;
while (next <= addr) {
scroll_forward = next;
- next += oop(next)->size();
+ next += cast_to_oop(next)->size();
}
assert(scroll_forward <= addr, "wrong order for current and arg");
assert(addr <= next, "wrong order for arg and next");
diff --git a/src/hotspot/share/gc/parallel/parMarkBitMap.cpp b/src/hotspot/share/gc/parallel/parMarkBitMap.cpp
index d08762b2ca1..97d1e23b75e 100644
--- a/src/hotspot/share/gc/parallel/parMarkBitMap.cpp
+++ b/src/hotspot/share/gc/parallel/parMarkBitMap.cpp
@@ -146,14 +146,14 @@ ParMarkBitMap::live_words_in_range_use_cache(ParCompactionManager* cm, HeapWord*
// The cached value is for an object that is to the left (lower address) of the current
// end_obj. Calculate back from that cached value.
if (pointer_delta(end_obj, beg_addr) > pointer_delta(last_obj, end_obj)) {
- last_ret = last_ret - live_words_in_range_helper(end_obj, (oop)last_obj);
+ last_ret = last_ret - live_words_in_range_helper(end_obj, cast_to_oop(last_obj));
} else {
last_ret = live_words_in_range_helper(beg_addr, end_oop);
}
last_obj = end_obj;
}
- update_live_words_in_range_cache(cm, last_beg, (oop)last_obj, last_ret);
+ update_live_words_in_range_cache(cm, last_beg, cast_to_oop(last_obj), last_ret);
return last_ret;
}
diff --git a/src/hotspot/share/gc/parallel/psCardTable.cpp b/src/hotspot/share/gc/parallel/psCardTable.cpp
index 9ad29779ed7..ec186aec83f 100644
--- a/src/hotspot/share/gc/parallel/psCardTable.cpp
+++ b/src/hotspot/share/gc/parallel/psCardTable.cpp
@@ -213,7 +213,7 @@ void PSCardTable::scavenge_contents_parallel(ObjectStartArray* start_array,
HeapWord* first_object = start_array->object_start(slice_start);
debug_only(oop* first_object_within_slice = (oop*) first_object;)
if (first_object < slice_start) {
- last_scanned = (oop*)(first_object + oop(first_object)->size());
+ last_scanned = (oop*)(first_object + cast_to_oop(first_object)->size());
debug_only(first_object_within_slice = last_scanned;)
worker_start_card = byte_for(last_scanned);
}
@@ -222,7 +222,7 @@ void PSCardTable::scavenge_contents_parallel(ObjectStartArray* start_array,
if (slice_end < (HeapWord*)sp_top) {
// The subtraction is important! An object may start precisely at slice_end.
HeapWord* last_object = start_array->object_start(slice_end - 1);
- slice_end = last_object + oop(last_object)->size();
+ slice_end = last_object + cast_to_oop(last_object)->size();
// worker_end_card is exclusive, so bump it one past the end of last_object's
// covered span.
worker_end_card = byte_for(slice_end) + 1;
@@ -260,7 +260,7 @@ void PSCardTable::scavenge_contents_parallel(ObjectStartArray* start_array,
// prevents the redundant object scan, but it does not prevent newly
// marked cards from being cleaned.
HeapWord* last_object_in_dirty_region = start_array->object_start(addr_for(current_card)-1);
- size_t size_of_last_object = oop(last_object_in_dirty_region)->size();
+ size_t size_of_last_object = cast_to_oop(last_object_in_dirty_region)->size();
HeapWord* end_of_last_object = last_object_in_dirty_region + size_of_last_object;
CardValue* ending_card_of_last_object = byte_for(end_of_last_object);
assert(ending_card_of_last_object <= worker_end_card, "ending_card_of_last_object is greater than worker_end_card");
@@ -316,7 +316,7 @@ void PSCardTable::scavenge_contents_parallel(ObjectStartArray* start_array,
if (interval != 0) {
while (p < to) {
Prefetch::write(p, interval);
- oop m = oop(p);
+ oop m = cast_to_oop(p);
assert(oopDesc::is_oop_or_null(m), "Expected an oop or NULL for header field at " PTR_FORMAT, p2i(m));
pm->push_contents(m);
p += m->size();
@@ -324,7 +324,7 @@ void PSCardTable::scavenge_contents_parallel(ObjectStartArray* start_array,
pm->drain_stacks_cond_depth();
} else {
while (p < to) {
- oop m = oop(p);
+ oop m = cast_to_oop(p);
assert(oopDesc::is_oop_or_null(m), "Expected an oop or NULL for header field at " PTR_FORMAT, p2i(m));
pm->push_contents(m);
p += m->size();
diff --git a/src/hotspot/share/gc/parallel/psOldGen.cpp b/src/hotspot/share/gc/parallel/psOldGen.cpp
index 44c7901571a..a8b871f2011 100644
--- a/src/hotspot/share/gc/parallel/psOldGen.cpp
+++ b/src/hotspot/share/gc/parallel/psOldGen.cpp
@@ -167,14 +167,14 @@ void PSOldGen::object_iterate_block(ObjectClosure* cl, size_t block_index) {
// Get object starting at or reaching into this block.
HeapWord* start = start_array()->object_start(begin);
if (start < begin) {
- start += oop(start)->size();
+ start += cast_to_oop(start)->size();
}
assert(start >= begin,
"Object address" PTR_FORMAT " must be larger or equal to block address at " PTR_FORMAT,
p2i(start), p2i(begin));
// Iterate all objects until the end.
- for (HeapWord* p = start; p < end; p += oop(p)->size()) {
- cl->do_object(oop(p));
+ for (HeapWord* p = start; p < end; p += cast_to_oop(p)->size()) {
+ cl->do_object(cast_to_oop(p));
}
}
diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp
index 0acee8a8ecb..e4f1d108f81 100644
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp
@@ -549,7 +549,7 @@ void ParallelCompactData::add_obj(HeapWord* addr, size_t len)
const size_t beg_ofs = region_offset(addr);
_region_data[beg_region].add_live_obj(RegionSize - beg_ofs);
- Klass* klass = ((oop)addr)->klass();
+ Klass* klass = cast_to_oop(addr)->klass();
// Middle regions--completely spanned by this object.
for (size_t region = beg_region + 1; region < end_region; ++region) {
_region_data[region].set_partial_obj_size(RegionSize);
@@ -817,7 +817,7 @@ HeapWord* ParallelCompactData::calc_new_pointer(HeapWord* addr, ParCompactionMan
const size_t block_offset = addr_to_block_ptr(addr)->offset();
const ParMarkBitMap* bitmap = PSParallelCompact::mark_bitmap();
- const size_t live = bitmap->live_words_in_range(cm, search_start, oop(addr));
+ const size_t live = bitmap->live_words_in_range(cm, search_start, cast_to_oop(addr));
result += block_offset + live;
DEBUG_ONLY(PSParallelCompact::check_new_location(addr, result));
return result;
@@ -2674,7 +2674,7 @@ void PSParallelCompact::verify_complete(SpaceId space_id) {
inline void UpdateOnlyClosure::do_addr(HeapWord* addr) {
_start_array->allocate_block(addr);
- compaction_manager()->update_contents(oop(addr));
+ compaction_manager()->update_contents(cast_to_oop(addr));
}
// Update interior oops in the ranges of regions [beg_region, end_region).
@@ -2777,8 +2777,8 @@ void PSParallelCompact::update_deferred_objects(ParCompactionManager* cm,
if (start_array != NULL) {
start_array->allocate_block(addr);
}
- cm->update_contents(oop(addr));
- assert(oopDesc::is_oop_or_null(oop(addr)), "Expected an oop or NULL at " PTR_FORMAT, p2i(oop(addr)));
+ cm->update_contents(cast_to_oop(addr));
+ assert(oopDesc::is_oop_or_null(cast_to_oop(addr)), "Expected an oop or NULL at " PTR_FORMAT, p2i(cast_to_oop(addr)));
}
}
}
@@ -3298,7 +3298,7 @@ MoveAndUpdateClosure::do_addr(HeapWord* addr, size_t words) {
Copy::aligned_conjoint_words(source(), copy_destination(), words);
}
- oop moved_oop = (oop) copy_destination();
+ oop moved_oop = cast_to_oop(copy_destination());
compaction_manager()->update_contents(moved_oop);
assert(oopDesc::is_oop_or_null(moved_oop), "Expected an oop or NULL at " PTR_FORMAT, p2i(moved_oop));
@@ -3356,7 +3356,7 @@ FillClosure::do_addr(HeapWord* addr, size_t size) {
HeapWord* const end = addr + size;
do {
_start_array->allocate_block(addr);
- addr += oop(addr)->size();
+ addr += cast_to_oop(addr)->size();
} while (addr < end);
return ParMarkBitMap::incomplete;
}
diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp b/src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp
index 7d2678e3f4c..3bc193dd061 100644
--- a/src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp
@@ -112,7 +112,7 @@ inline void PSParallelCompact::adjust_pointer(T* p, ParCompactionManager* cm) {
oop obj = CompressedOops::decode_not_null(heap_oop);
assert(ParallelScavengeHeap::heap()->is_in(obj), "should be in heap");
- oop new_obj = (oop)summary_data().calc_new_pointer(obj, cm);
+ oop new_obj = cast_to_oop(summary_data().calc_new_pointer(obj, cm));
assert(new_obj != NULL, "non-null address for live objects");
// Is it actually relocated at all?
if (new_obj != obj) {
diff --git a/src/hotspot/share/gc/parallel/psPromotionLAB.cpp b/src/hotspot/share/gc/parallel/psPromotionLAB.cpp
index f119084cd1c..53fac0e98a5 100644
--- a/src/hotspot/share/gc/parallel/psPromotionLAB.cpp
+++ b/src/hotspot/share/gc/parallel/psPromotionLAB.cpp
@@ -82,7 +82,7 @@ void PSPromotionLAB::flush() {
// PLAB's never allocate the last aligned_header_size
// so they can always fill with an array.
HeapWord* tlab_end = end() + filler_header_size;
- typeArrayOop filler_oop = (typeArrayOop) top();
+ typeArrayOop filler_oop = (typeArrayOop) cast_to_oop(top());
filler_oop->set_mark(markWord::prototype());
filler_oop->set_klass(Universe::intArrayKlassObj());
const size_t array_length =
diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
index ca6897f76f0..fd5438badb0 100644
--- a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
+++ b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
@@ -153,12 +153,12 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
if (!promote_immediately) {
// Try allocating obj in to-space (unless too old)
if (age < PSScavenge::tenuring_threshold()) {
- new_obj = (oop) _young_lab.allocate(new_obj_size);
+ new_obj = cast_to_oop(_young_lab.allocate(new_obj_size));
if (new_obj == NULL && !_young_gen_is_full) {
// Do we allocate directly, or flush and refill?
if (new_obj_size > (YoungPLABSize / 2)) {
// Allocate this object directly
- new_obj = (oop)young_space()->cas_allocate(new_obj_size);
+ new_obj = cast_to_oop(young_space()->cas_allocate(new_obj_size));
promotion_trace_event(new_obj, o, new_obj_size, age, false, NULL);
} else {
// Flush and fill
@@ -168,7 +168,7 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
if (lab_base != NULL) {
_young_lab.initialize(MemRegion(lab_base, YoungPLABSize));
// Try the young lab allocation again.
- new_obj = (oop) _young_lab.allocate(new_obj_size);
+ new_obj = cast_to_oop(_young_lab.allocate(new_obj_size));
promotion_trace_event(new_obj, o, new_obj_size, age, false, &_young_lab);
} else {
_young_gen_is_full = true;
@@ -186,7 +186,7 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
}
#endif // #ifndef PRODUCT
- new_obj = (oop) _old_lab.allocate(new_obj_size);
+ new_obj = cast_to_oop(_old_lab.allocate(new_obj_size));
new_obj_is_tenured = true;
if (new_obj == NULL) {
@@ -194,7 +194,7 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
// Do we allocate directly, or flush and refill?
if (new_obj_size > (OldPLABSize / 2)) {
// Allocate this object directly
- new_obj = (oop)old_gen()->allocate(new_obj_size);
+ new_obj = cast_to_oop(old_gen()->allocate(new_obj_size));
promotion_trace_event(new_obj, o, new_obj_size, age, true, NULL);
} else {
// Flush and fill
@@ -211,7 +211,7 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
#endif
_old_lab.initialize(MemRegion(lab_base, OldPLABSize));
// Try the old lab allocation again.
- new_obj = (oop) _old_lab.allocate(new_obj_size);
+ new_obj = cast_to_oop(_old_lab.allocate(new_obj_size));
promotion_trace_event(new_obj, o, new_obj_size, age, true, &_old_lab);
}
}
diff --git a/src/hotspot/share/gc/parallel/psScavenge.cpp b/src/hotspot/share/gc/parallel/psScavenge.cpp
index 61af24c6c4b..e0b7529efac 100644
--- a/src/hotspot/share/gc/parallel/psScavenge.cpp
+++ b/src/hotspot/share/gc/parallel/psScavenge.cpp
@@ -791,7 +791,7 @@ bool PSScavenge::should_attempt_scavenge() {
void PSScavenge::set_young_generation_boundary(HeapWord* v) {
_young_generation_boundary = v;
if (UseCompressedOops) {
- _young_generation_boundary_compressed = (uintptr_t)CompressedOops::encode((oop)v);
+ _young_generation_boundary_compressed = (uintptr_t)CompressedOops::encode(cast_to_oop(v));
}
}
diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp
index b606e7080cf..271d0d764b5 100644
--- a/src/hotspot/share/gc/serial/defNewGeneration.cpp
+++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp
@@ -705,7 +705,7 @@ oop DefNewGeneration::copy_to_survivor_space(oop old) {
// Try allocating obj in to-space (unless too old)
if (old->age() < tenuring_threshold()) {
- obj = (oop) to()->allocate(s);
+ obj = cast_to_oop(to()->allocate(s));
}
// Otherwise try allocating obj tenured
diff --git a/src/hotspot/share/gc/serial/markSweep.inline.hpp b/src/hotspot/share/gc/serial/markSweep.inline.hpp
index 4b3875f754c..5a2c6a607c4 100644
--- a/src/hotspot/share/gc/serial/markSweep.inline.hpp
+++ b/src/hotspot/share/gc/serial/markSweep.inline.hpp
@@ -79,7 +79,7 @@ template <class T> inline void MarkSweep::adjust_pointer(T* p) {
oop obj = CompressedOops::decode_not_null(heap_oop);
assert(Universe::heap()->is_in(obj), "should be in heap");
- oop new_obj = oop(obj->mark().decode_pointer());
+ oop new_obj = cast_to_oop(obj->mark().decode_pointer());
assert(new_obj != NULL || // is forwarding ptr?
obj->mark() == markWord::prototype() || // not gc marked?
diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp b/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp
index 03bb92750e6..02ebd79c703 100644
--- a/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp
+++ b/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp
@@ -42,7 +42,7 @@ HeapWord* TenuredGeneration::par_allocate(size_t word_size,
size_t TenuredGeneration::block_size(const HeapWord* addr) const {
if (addr < _the_space->top()) {
- return oop(addr)->size();
+ return cast_to_oop(addr)->size();
} else {
assert(addr == _the_space->top(), "non-block head arg to block_size");
return _the_space->end() - _the_space->top();
diff --git a/src/hotspot/share/gc/shared/blockOffsetTable.cpp b/src/hotspot/share/gc/shared/blockOffsetTable.cpp
index c3039f5c20b..bea66b65d40 100644
--- a/src/hotspot/share/gc/shared/blockOffsetTable.cpp
+++ b/src/hotspot/share/gc/shared/blockOffsetTable.cpp
@@ -340,7 +340,7 @@ void BlockOffsetArray::verify() const {
HeapWord* start = block_start(p);
// First check if the start is an allocated block and only
// then if it is a valid object.
- oop o = oop(start);
+ oop o = cast_to_oop(start);
assert(!Universe::is_fully_initialized() ||
_sp->is_free_block(start) ||
oopDesc::is_oop_or_null(o), "Bad object was found");
diff --git a/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp b/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp
index 225fca264bd..8e44274a7f0 100644
--- a/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp
+++ b/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp
@@ -164,7 +164,7 @@ void CardTableBarrierSet::flush_deferred_card_mark_barrier(JavaThread* thread) {
assert(_defer_initial_card_mark, "Otherwise should be empty");
{
// Verify that the storage points to a parsable object in heap
- DEBUG_ONLY(oop old_obj = oop(deferred.start());)
+ DEBUG_ONLY(oop old_obj = cast_to_oop(deferred.start());)
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");
diff --git a/src/hotspot/share/gc/shared/cardTableRS.cpp b/src/hotspot/share/gc/shared/cardTableRS.cpp
index 3dc15fb23a1..076f7137c99 100644
--- a/src/hotspot/share/gc/shared/cardTableRS.cpp
+++ b/src/hotspot/share/gc/shared/cardTableRS.cpp
@@ -245,7 +245,7 @@ void CardTableRS::verify_space(Space* s, HeapWord* gen_boundary) {
HeapWord* start_block = boundary_block; // Until proven otherwise.
if (boundary_block < boundary) {
if (s->block_is_obj(boundary_block) && s->obj_is_alive(boundary_block)) {
- oop boundary_obj = oop(boundary_block);
+ oop boundary_obj = cast_to_oop(boundary_block);
if (!boundary_obj->is_objArray() &&
!boundary_obj->is_typeArray()) {
guarantee(cur_entry > byte_for(used.start()),
@@ -263,7 +263,7 @@ void CardTableRS::verify_space(Space* s, HeapWord* gen_boundary) {
VerifyCleanCardClosure verify_blk(gen_boundary, begin, end);
for (HeapWord* cur = start_block; cur < end; cur += s->block_size(cur)) {
if (s->block_is_obj(cur) && s->obj_is_alive(cur)) {
- oop(cur)->oop_iterate(&verify_blk, mr);
+ cast_to_oop(cur)->oop_iterate(&verify_blk, mr);
}
}
}
diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
index 743e8882624..b6328967dcd 100644
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
@@ -1298,5 +1298,5 @@ oop GenCollectedHeap::handle_failed_promotion(Generation* old_gen,
if (result != NULL) {
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(obj), result, obj_size);
}
- return oop(result);
+ return cast_to_oop(result);
}
diff --git a/src/hotspot/share/gc/shared/generation.cpp b/src/hotspot/share/gc/shared/generation.cpp
index c41da47d641..4c4e7a24e6e 100644
--- a/src/hotspot/share/gc/shared/generation.cpp
+++ b/src/hotspot/share/gc/shared/generation.cpp
@@ -167,7 +167,7 @@ oop Generation::promote(oop obj, size_t obj_size) {
HeapWord* result = allocate(obj_size, false);
if (result != NULL) {
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(obj), result, obj_size);
- return oop(result);
+ return cast_to_oop(result);
} else {
GenCollectedHeap* gch = GenCollectedHeap::heap();
return gch->handle_failed_promotion(this, obj, obj_size);
diff --git a/src/hotspot/share/gc/shared/locationPrinter.inline.hpp b/src/hotspot/share/gc/shared/locationPrinter.inline.hpp
index 343687ae0f0..9d78af9ab0f 100644
--- a/src/hotspot/share/gc/shared/locationPrinter.inline.hpp
+++ b/src/hotspot/share/gc/shared/locationPrinter.inline.hpp
@@ -33,7 +33,7 @@ template <typename CollectedHeapT>
oop BlockLocationPrinter<CollectedHeapT>::base_oop_or_null(void* addr) {
if (is_valid_obj(addr)) {
// We were just given an oop directly.
- return oop(addr);
+ return cast_to_oop(addr);
}
// Try to find addr using block_start.
@@ -42,7 +42,7 @@ oop BlockLocationPrinter<CollectedHeapT>::base_oop_or_null(void* addr) {
if (!is_valid_obj(p)) {
return NULL;
}
- return oop(p);
+ return cast_to_oop(p);
}
return NULL;
diff --git a/src/hotspot/share/gc/shared/memAllocator.cpp b/src/hotspot/share/gc/shared/memAllocator.cpp
index 73c77a43d6f..15fcbc435f1 100644
--- a/src/hotspot/share/gc/shared/memAllocator.cpp
+++ b/src/hotspot/share/gc/shared/memAllocator.cpp
@@ -393,7 +393,7 @@ oop MemAllocator::finish(HeapWord* mem) const {
// object zeroing are visible before setting the klass non-NULL, for
// concurrent collectors.
oopDesc::release_set_klass(mem, _klass);
- return oop(mem);
+ return cast_to_oop(mem);
}
oop ObjAllocator::initialize(HeapWord* mem) const {
diff --git a/src/hotspot/share/gc/shared/space.cpp b/src/hotspot/share/gc/shared/space.cpp
index 516e789b3ff..3b36398625f 100644
--- a/src/hotspot/share/gc/shared/space.cpp
+++ b/src/hotspot/share/gc/shared/space.cpp
@@ -52,7 +52,7 @@ HeapWord* DirtyCardToOopClosure::get_actual_top(HeapWord* top,
if (top_obj != NULL) {
if (_sp->block_is_obj(top_obj)) {
if (_precision == CardTable::ObjHeadPreciseArray) {
- if (oop(top_obj)->is_objArray() || oop(top_obj)->is_typeArray()) {
+ if (cast_to_oop(top_obj)->is_objArray() || cast_to_oop(top_obj)->is_typeArray()) {
// An arrayOop is starting on the dirty card - since we do exact
// store checks for objArrays we are done.
} else {
@@ -63,7 +63,7 @@ HeapWord* DirtyCardToOopClosure::get_actual_top(HeapWord* top,
// the iteration is being done. That space (e.g. CMS) may have
// specific requirements on object sizes which will
// be reflected in the block_size() method.
- top = top_obj + oop(top_obj)->size();
+ top = top_obj + cast_to_oop(top_obj)->size();
}
}
} else {
@@ -94,8 +94,8 @@ void DirtyCardToOopClosure::walk_mem_region(MemRegion mr,
// "adjust the object size" (for instance pad it up to its
// block alignment or minimum block size restrictions. XXX
if (_sp->block_is_obj(bottom) &&
- !_sp->obj_allocated_since_save_marks(oop(bottom))) {
- oop(bottom)->oop_iterate(_cl, mr);
+ !_sp->obj_allocated_since_save_marks(cast_to_oop(bottom))) {
+ cast_to_oop(bottom)->oop_iterate(_cl, mr);
}
}
}
@@ -171,16 +171,16 @@ HeapWord* ContiguousSpaceDCTOC::get_actual_top(HeapWord* top,
HeapWord* top_obj) {
if (top_obj != NULL && top_obj < (_sp->toContiguousSpace())->top()) {
if (_precision == CardTable::ObjHeadPreciseArray) {
- if (oop(top_obj)->is_objArray() || oop(top_obj)->is_typeArray()) {
+ if (cast_to_oop(top_obj)->is_objArray() || cast_to_oop(top_obj)->is_typeArray()) {
// An arrayOop is starting on the dirty card - since we do exact
// store checks for objArrays we are done.
} else {
// 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) oop(top_obj)->size(),
+ assert(_sp->block_size(top_obj) == (size_t) cast_to_oop(top_obj)->size(),
"Block size and object size mismatch");
- top = top_obj + oop(top_obj)->size();
+ top = top_obj + cast_to_oop(top_obj)->size();
}
}
} else {
@@ -218,18 +218,18 @@ void ContiguousSpaceDCTOC::walk_mem_region_with_cl(MemRegion mr, \
HeapWord* bottom, \
HeapWord* top, \
ClosureType* cl) { \
- bottom += oop(bottom)->oop_iterate_size(cl, mr); \
+ bottom += cast_to_oop(bottom)->oop_iterate_size(cl, mr); \
if (bottom < top) { \
- HeapWord* next_obj = bottom + oop(bottom)->size(); \
+ HeapWord* next_obj = bottom + cast_to_oop(bottom)->size(); \
while (next_obj < top) { \
/* Bottom lies entirely below top, so we can call the */ \
/* non-memRegion version of oop_iterate below. */ \
- oop(bottom)->oop_iterate(cl); \
+ cast_to_oop(bottom)->oop_iterate(cl); \
bottom = next_obj; \
- next_obj = bottom + oop(bottom)->size(); \
+ next_obj = bottom + cast_to_oop(bottom)->size(); \
} \
/* Last object. */ \
- oop(bottom)->oop_iterate(cl, mr); \
+ cast_to_oop(bottom)->oop_iterate(cl, mr); \
} \
}
@@ -372,7 +372,7 @@ HeapWord* CompactibleSpace::forward(oop q, size_t size,
// store the forwarding pointer into the mark word
if (cast_from_oop<HeapWord*>(q) != compact_top) {
- q->forward_to(oop(compact_top));
+ q->forward_to(cast_to_oop(compact_top));
assert(q->is_gc_marked(), "encoding the pointer should preserve the mark");
} else {
// if the object isn't moving we can just set the mark to the default
@@ -446,9 +446,9 @@ void ContiguousSpace::verify() const {
HeapWord* t = top();
HeapWord* prev_p = NULL;
while (p < t) {
- oopDesc::verify(oop(p));
+ oopDesc::verify(cast_to_oop(p));
prev_p = p;
- p += oop(p)->size();
+ p += cast_to_oop(p)->size();
}
guarantee(p == top(), "end of last object must match end of space");
if (top() != end()) {
@@ -474,7 +474,7 @@ void ContiguousSpace::oop_iterate(OopIterateClosure* blk) {
HeapWord* t = top();
// Could call objects iterate, but this is easier.
while (obj_addr < t) {
- obj_addr += oop(obj_addr)->oop_iterate_size(blk);
+ obj_addr += cast_to_oop(obj_addr)->oop_iterate_size(blk);
}
}
@@ -485,8 +485,8 @@ void ContiguousSpace::object_iterate(ObjectClosure* blk) {
void ContiguousSpace::object_iterate_from(HeapWord* mark, ObjectClosure* blk) {
while (mark < top()) {
- blk->do_object(oop(mark));
- mark += oop(mark)->size();
+ blk->do_object(cast_to_oop(mark));
+ mark += cast_to_oop(mark)->size();
}
}
@@ -502,9 +502,9 @@ HeapWord* ContiguousSpace::block_start_const(const void* p) const {
HeapWord* cur = last;
while (cur <= p) {
last = cur;
- cur += oop(cur)->size();
+ cur += cast_to_oop(cur)->size();
}
- assert(oopDesc::is_oop(oop(last)), PTR_FORMAT " should be an object start", p2i(last));
+ assert(oopDesc::is_oop(cast_to_oop(last)), PTR_FORMAT " should be an object start", p2i(last));
return last;
}
}
@@ -517,12 +517,12 @@ size_t ContiguousSpace::block_size(const HeapWord* p) const {
assert(p <= current_top,
"p > current top - p: " PTR_FORMAT ", current top: " PTR_FORMAT,
p2i(p), p2i(current_top));
- assert(p == current_top || oopDesc::is_oop(oop(p)),
+ assert(p == current_top || oopDesc::is_oop(cast_to_oop(p)),
"p (" PTR_FORMAT ") is not a block start - "
"current_top: " PTR_FORMAT ", is_oop: %s",
- p2i(p), p2i(current_top), BOOL_TO_STR(oopDesc::is_oop(oop(p))));
+ p2i(p), p2i(current_top), BOOL_TO_STR(oopDesc::is_oop(cast_to_oop(p))));
if (p < current_top) {
- return oop(p)->size();
+ return cast_to_oop(p)->size();
} else {
assert(p == current_top, "just checking");
return pointer_delta(end(), (HeapWord*) p);
@@ -592,7 +592,7 @@ void ContiguousSpace::allocate_temporary_filler(int factor) {
if (size >= align_object_size(array_header_size)) {
size_t length = (size - array_header_size) * (HeapWordSize / sizeof(jint));
// allocate uninitialized int array
- typeArrayOop t = (typeArrayOop) allocate(size);
+ typeArrayOop t = (typeArrayOop) cast_to_oop(allocate(size));
assert(t != NULL, "allocation should succeed");
t->set_mark(markWord::prototype());
t->set_klass(Universe::intArrayKlassObj());
@@ -600,7 +600,7 @@ void ContiguousSpace::allocate_temporary_filler(int factor) {
} else {
assert(size == CollectedHeap::min_fill_size(),
"size for smallest fake object doesn't match");
- instanceOop obj = (instanceOop) allocate(size);
+ instanceOop obj = (instanceOop) cast_to_oop(allocate(size));
obj->set_mark(markWord::prototype());
obj->set_klass_gap(0);
obj->set_klass(vmClasses::Object_klass());
@@ -639,7 +639,7 @@ void OffsetTableContigSpace::verify() const {
}
while (p < top()) {
- size_t size = oop(p)->size();
+ size_t size = cast_to_oop(p)->size();
// For a sampling of objects in the space, find it using the
// block offset table.
if (blocks == BLOCK_SAMPLE_INTERVAL) {
@@ -651,7 +651,7 @@ void OffsetTableContigSpace::verify() const {
}
if (objs == OBJ_SAMPLE_INTERVAL) {
- oopDesc::verify(oop(p));
+ oopDesc::verify(cast_to_oop(p));
objs = 0;
} else {
objs++;
diff --git a/src/hotspot/share/gc/shared/space.inline.hpp b/src/hotspot/share/gc/shared/space.inline.hpp
index e7d9e025ec9..e5ea0db5e46 100644
--- a/src/hotspot/share/gc/shared/space.inline.hpp
+++ b/src/hotspot/share/gc/shared/space.inline.hpp
@@ -76,7 +76,7 @@ OffsetTableContigSpace::block_start_const(const void* p) const {
}
size_t CompactibleSpace::obj_size(const HeapWord* addr) const {
- return oop(addr)->size();
+ return cast_to_oop(addr)->size();
}
#if INCLUDE_SERIALGC
@@ -116,7 +116,7 @@ public:
if (_allowed_deadspace_words >= dead_length) {
_allowed_deadspace_words -= dead_length;
CollectedHeap::fill_with_object(dead_start, dead_length);
- oop obj = oop(dead_start);
+ 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");
@@ -163,11 +163,11 @@ inline void CompactibleSpace::scan_and_forward(SpaceType* space, CompactPoint* c
HeapWord* scan_limit = space->scan_limit();
while (cur_obj < scan_limit) {
- if (space->scanned_block_is_obj(cur_obj) && oop(cur_obj)->is_gc_marked()) {
+ if (space->scanned_block_is_obj(cur_obj) && cast_to_oop(cur_obj)->is_gc_marked()) {
// prefetch beyond cur_obj
Prefetch::write(cur_obj, interval);
size_t size = space->scanned_block_size(cur_obj);
- compact_top = cp->space->forward(oop(cur_obj), size, cp, compact_top);
+ compact_top = cp->space->forward(cast_to_oop(cur_obj), size, cp, compact_top);
cur_obj += size;
end_of_live = cur_obj;
} else {
@@ -177,12 +177,12 @@ inline void CompactibleSpace::scan_and_forward(SpaceType* space, CompactPoint* c
// prefetch beyond end
Prefetch::write(end, interval);
end += space->scanned_block_size(end);
- } while (end < scan_limit && (!space->scanned_block_is_obj(end) || !oop(end)->is_gc_marked()));
+ } while (end < scan_limit && (!space->scanned_block_is_obj(end) || !cast_to_oop(end)->is_gc_marked()));
// see if we might want to pretend this object is alive so that
// we don't have to compact quite as often.
if (cur_obj == compact_top && dead_spacer.insert_deadspace(cur_obj, end)) {
- oop obj = oop(cur_obj);
+ oop obj = cast_to_oop(cur_obj);
compact_top = cp->space->forward(obj, obj->size(), cp, compact_top);
end_of_live = end;
} else {
@@ -230,10 +230,10 @@ inline void CompactibleSpace::scan_and_adjust_pointers(SpaceType* space) {
debug_only(HeapWord* prev_obj = NULL);
while (cur_obj < end_of_live) {
Prefetch::write(cur_obj, interval);
- if (cur_obj < first_dead || oop(cur_obj)->is_gc_marked()) {
+ if (cur_obj < first_dead || cast_to_oop(cur_obj)->is_gc_marked()) {
// cur_obj is alive
// point all the oops to the new location
- size_t size = MarkSweep::adjust_pointers(oop(cur_obj));
+ size_t size = MarkSweep::adjust_pointers(cast_to_oop(cur_obj));
size = space->adjust_obj_size(size);
debug_only(prev_obj = cur_obj);
cur_obj += size;
@@ -253,7 +253,7 @@ template <class SpaceType>
inline void CompactibleSpace::verify_up_to_first_dead(SpaceType* space) {
HeapWord* cur_obj = space->bottom();
- if (cur_obj < space->_end_of_live && space->_first_dead > cur_obj && !oop(cur_obj)->is_gc_marked()) {
+ if (cur_obj < space->_end_of_live && space->_first_dead > cur_obj && !cast_to_oop(cur_obj)->is_gc_marked()) {
// we have a chunk of the space which hasn't moved and we've reinitialized
// the mark word during the previous pass, so we can't use is_gc_marked for
// the traversal.
@@ -261,7 +261,7 @@ inline void CompactibleSpace::verify_up_to_first_dead(SpaceType* space) {
while (cur_obj < space->_first_dead) {
size_t size = space->obj_size(cur_obj);
- assert(!oop(cur_obj)->is_gc_marked(), "should be unmarked (special dense prefix handling)");
+ assert(!cast_to_oop(cur_obj)->is_gc_marked(), "should be unmarked (special dense prefix handling)");
prev_obj = cur_obj;
cur_obj += size;
}
@@ -298,7 +298,7 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space) {
HeapWord* const end_of_live = space->_end_of_live;
assert(space->_first_dead <= end_of_live, "Invariant. _first_dead: " PTR_FORMAT " <= end_of_live: " PTR_FORMAT, p2i(space->_first_dead), p2i(end_of_live));
- if (space->_first_dead == end_of_live && (bottom == end_of_live || !oop(bottom)->is_gc_marked())) {
+ if (space->_first_dead == end_of_live && (bottom == end_of_live || !cast_to_oop(bottom)->is_gc_marked())) {
// Nothing to compact. The space is either empty or all live object should be left in place.
clear_empty_region(space);
return;
@@ -309,7 +309,7 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space) {
assert(bottom < end_of_live, "bottom: " PTR_FORMAT " should be < end_of_live: " PTR_FORMAT, p2i(bottom), p2i(end_of_live));
HeapWord* cur_obj = bottom;
- if (space->_first_dead > cur_obj && !oop(cur_obj)->is_gc_marked()) {
+ if (space->_first_dead > cur_obj && !cast_to_oop(cur_obj)->is_gc_marked()) {
// All object before _first_dead can be skipped. They should not be moved.
// A pointer to the first live object is stored at the memory location for _first_dead.
cur_obj = *(HeapWord**)(space->_first_dead);
@@ -317,7 +317,7 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space) {
debug_only(HeapWord* prev_obj = NULL);
while (cur_obj < end_of_live) {
- if (!oop(cur_obj)->is_gc_marked()) {
+ if (!cast_to_oop(cur_obj)->is_gc_marked()) {
debug_only(prev_obj = cur_obj);
// The first word of the dead object contains a pointer to the next live object or end of space.
cur_obj = *(HeapWord**)cur_obj;
@@ -328,7 +328,7 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space) {
// size and destination
size_t size = space->obj_size(cur_obj);
- HeapWord* compaction_top = cast_from_oop<HeapWord*>(oop(cur_obj)->forwardee());
+ HeapWord* compaction_top = cast_from_oop<HeapWord*>(cast_to_oop(cur_obj)->forwardee());
// prefetch beyond compaction_top
Prefetch::write(compaction_top, copy_interval);
@@ -336,8 +336,8 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space) {
// copy object and reinit its mark
assert(cur_obj != compaction_top, "everything in this pass should be moving");
Copy::aligned_conjoint_words(cur_obj, compaction_top, size);
- oop(compaction_top)->init_mark();
- assert(oop(compaction_top)->klass() != NULL, "should have a class");
+ cast_to_oop(compaction_top)->init_mark();
+ assert(cast_to_oop(compaction_top)->klass() != NULL, "should have a class");
debug_only(prev_obj = cur_obj);
cur_obj += size;
@@ -350,7 +350,7 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space) {
#endif // INCLUDE_SERIALGC
size_t ContiguousSpace::scanned_block_size(const HeapWord* addr) const {
- return oop(addr)->size();
+ return cast_to_oop(addr)->size();
}
template <typename OopClosureType>
@@ -365,7 +365,7 @@ void ContiguousSpace::oop_since_save_marks_iterate(OopClosureType* blk) {
while (p < t) {
Prefetch::write(p, interval);
debug_only(HeapWord* prev = p);
- oop m = oop(p);
+ oop m = cast_to_oop(p);
p += m->oop_iterate_size(blk);
}
} while (t < top());
diff --git a/src/hotspot/share/gc/shared/taskqueue.hpp b/src/hotspot/share/gc/shared/taskqueue.hpp
index c7e120d7074..718d0929a4e 100644
--- a/src/hotspot/share/gc/shared/taskqueue.hpp
+++ b/src/hotspot/share/gc/shared/taskqueue.hpp
@@ -614,7 +614,7 @@ public:
}
PartialArrayScanTask to_partial_array_task() const {
- return PartialArrayScanTask(oop(decode(PartialArrayTag)));
+ return PartialArrayScanTask(cast_to_oop(decode(PartialArrayTag)));
}
};
diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp
index 66e7bca9ce6..b6929cf65f7 100644
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp
@@ -119,7 +119,7 @@ void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collec
// Reclaim humongous regions here, and count them as the immediate garbage
#ifdef ASSERT
bool reg_live = region->has_live();
- bool bm_live = ctx->is_marked(oop(region->bottom()));
+ bool bm_live = ctx->is_marked(cast_to_oop(region->bottom()));
assert(reg_live == bm_live,
"Humongous liveness and marks should agree. Region live: %s; Bitmap live: %s; Region Live Words: " SIZE_FORMAT,
BOOL_TO_STR(reg_live), BOOL_TO_STR(bm_live), region->get_live_data_words());
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp b/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp
index 27c1f988833..898db1a8df9 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp
@@ -139,7 +139,7 @@ void ShenandoahAsserts::print_failure(SafeLevel level, oop obj, void* interior_l
msg.append("\n");
if (level >= _safe_oop) {
- oop fwd = (oop) ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
+ oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
msg.append("Forwardee:\n");
if (obj != fwd) {
if (level >= _safe_oop_fwd) {
@@ -154,8 +154,8 @@ void ShenandoahAsserts::print_failure(SafeLevel level, oop obj, void* interior_l
}
if (level >= _safe_oop_fwd) {
- oop fwd = (oop) ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
- oop fwd2 = (oop) ShenandoahForwarding::get_forwardee_raw_unchecked(fwd);
+ oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
+ oop fwd2 = ShenandoahForwarding::get_forwardee_raw_unchecked(fwd);
if (fwd != fwd2) {
msg.append("Second forwardee:\n");
print_obj_safe(msg, fwd2);
@@ -210,7 +210,7 @@ void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char*
file,line);
}
- oop fwd = oop(ShenandoahForwarding::get_forwardee_raw_unchecked(obj));
+ oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
if (obj != fwd) {
// When Full GC moves the objects, we cannot trust fwdptrs. If we got here, it means something
@@ -243,7 +243,7 @@ void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char*
}
// Step 4. Check for multiple forwardings
- oop fwd2 = oop(ShenandoahForwarding::get_forwardee_raw_unchecked(fwd));
+ oop fwd2 = ShenandoahForwarding::get_forwardee_raw_unchecked(fwd);
if (fwd != fwd2) {
print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
"Multiple forwardings",
@@ -285,7 +285,7 @@ void ShenandoahAsserts::assert_in_correct_region(void* interior_loc, oop obj, co
void ShenandoahAsserts::assert_forwarded(void* interior_loc, oop obj, const char* file, int line) {
assert_correct(interior_loc, obj, file, line);
- oop fwd = oop(ShenandoahForwarding::get_forwardee_raw_unchecked(obj));
+ oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
if (obj == fwd) {
print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_forwarded failed",
@@ -296,7 +296,7 @@ void ShenandoahAsserts::assert_forwarded(void* interior_loc, oop obj, const char
void ShenandoahAsserts::assert_not_forwarded(void* interior_loc, oop obj, const char* file, int line) {
assert_correct(interior_loc, obj, file, line);
- oop fwd = oop(ShenandoahForwarding::get_forwardee_raw_unchecked(obj));
+ oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
if (obj != fwd) {
print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_not_forwarded failed",
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahForwarding.hpp b/src/hotspot/share/gc/shenandoah/shenandoahForwarding.hpp
index 80a51c63e69..95152017a69 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahForwarding.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahForwarding.hpp
@@ -40,12 +40,12 @@ public:
/* Returns the raw value from forwardee slot.
*/
- static inline HeapWord* get_forwardee_raw(oop obj);
+ static inline oop get_forwardee_raw(oop obj);
/* Returns the raw value from forwardee slot without any checks.
* Used for quick verification.
*/
- static inline HeapWord* get_forwardee_raw_unchecked(oop obj);
+ static inline oop get_forwardee_raw_unchecked(oop obj);
/**
* Returns true if the object is forwarded, false otherwise.
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahForwarding.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahForwarding.inline.hpp
index e271dfb1f2f..7020d7a4b99 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahForwarding.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahForwarding.inline.hpp
@@ -30,12 +30,12 @@
#include "oops/markWord.inline.hpp"
#include "runtime/thread.hpp"
-inline HeapWord* ShenandoahForwarding::get_forwardee_raw(oop obj) {
+inline oop ShenandoahForwarding::get_forwardee_raw(oop obj) {
shenandoah_assert_in_heap(NULL, obj);
return get_forwardee_raw_unchecked(obj);
}
-inline HeapWord* ShenandoahForwarding::get_forwardee_raw_unchecked(oop obj) {
+inline oop ShenandoahForwarding::get_forwardee_raw_unchecked(oop obj) {
// JVMTI and JFR code use mark words for marking objects for their needs.
// On this path, we can encounter the "marked" object, but with NULL
// fwdptr. That object is still not forwarded, and we need to return
@@ -44,10 +44,10 @@ inline HeapWord* ShenandoahForwarding::get_forwardee_raw_unchecked(oop obj) {
if (mark.is_marked()) {
HeapWord* fwdptr = (HeapWord*) mark.clear_lock_bits().to_pointer();
if (fwdptr != NULL) {
- return fwdptr;
+ return cast_to_oop(fwdptr);
}
}
- return cast_from_oop<HeapWord*>(obj);
+ return obj;
}
inline oop ShenandoahForwarding::get_forwardee_mutator(oop obj) {
@@ -67,7 +67,7 @@ inline oop ShenandoahForwarding::get_forwardee_mutator(oop obj) {
inline oop ShenandoahForwarding::get_forwardee(oop obj) {
shenandoah_assert_correct(NULL, obj);
- return oop(get_forwardee_raw_unchecked(obj));
+ return get_forwardee_raw_unchecked(obj);
}
inline bool ShenandoahForwarding::is_forwarded(oop obj) {
@@ -77,7 +77,7 @@ inline bool ShenandoahForwarding::is_forwarded(oop obj) {
inline oop ShenandoahForwarding::try_update_forwardee(oop obj, oop update) {
markWord old_mark = obj->mark();
if (old_mark.is_marked()) {
- return oop(old_mark.clear_lock_bits().to_pointer());
+ return cast_to_oop(old_mark.clear_lock_bits().to_pointer());
}
markWord new_mark = markWord::encode_pointer_as_mark(update);
@@ -85,7 +85,7 @@ inline oop ShenandoahForwarding::try_update_forwardee(oop obj, oop update) {
if (prev_mark == old_mark) {
return update;
} else {
- return oop(prev_mark.clear_lock_bits().to_pointer());
+ return cast_to_oop(prev_mark.clear_lock_bits().to_pointer());
}
}
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp
index 5769c120994..244fbbc756a 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp
@@ -360,7 +360,7 @@ public:
assert(_compact_point + obj_size <= _to_region->end(), "must fit");
shenandoah_assert_not_forwarded(NULL, p);
_preserved_marks->push_if_necessary(p, p->mark());
- p->forward_to(oop(_compact_point));
+ p->forward_to(cast_to_oop(_compact_point));
_compact_point += obj_size;
}
};
@@ -459,7 +459,7 @@ void ShenandoahFullGC::calculate_target_humongous_objects() {
if (r->is_humongous_start() && r->is_stw_move_allowed()) {
// From-region candidate: movable humongous region
- oop old_obj = oop(r->bottom());
+ oop old_obj = cast_to_oop(r->bottom());
size_t words_size = old_obj->size();
size_t num_regions = ShenandoahHeapRegion::required_regions(words_size * HeapWordSize);
@@ -468,7 +468,7 @@ void ShenandoahFullGC::calculate_target_humongous_objects() {
if (start >= to_begin && start != r->index()) {
// Fits into current window, and the move is non-trivial. Record the move then, and continue scan.
_preserved_marks->get(0)->push_if_necessary(old_obj, old_obj->mark());
- old_obj->forward_to(oop(heap->get_region(start)->bottom()));
+ old_obj->forward_to(cast_to_oop(heap->get_region(start)->bottom()));
to_end = start;
continue;
}
@@ -516,7 +516,7 @@ public:
void heap_region_do(ShenandoahHeapRegion* r) {
if (r->is_humongous_start()) {
- oop humongous_obj = oop(r->bottom());
+ oop humongous_obj = cast_to_oop(r->bottom());
if (!_ctx->is_marked(humongous_obj)) {
assert(!r->has_live(),
"Region " SIZE_FORMAT " is not marked, should not have live", r->index());
@@ -841,7 +841,7 @@ public:
HeapWord* compact_from = cast_from_oop<HeapWord*>(p);
HeapWord* compact_to = cast_from_oop<HeapWord*>(p->forwardee());
Copy::aligned_conjoint_words(compact_from, compact_to, size);
- oop new_obj = oop(compact_to);
+ oop new_obj = cast_to_oop(compact_to);
new_obj->init_mark();
}
}
@@ -938,7 +938,7 @@ void ShenandoahFullGC::compact_humongous_objects() {
for (size_t c = heap->num_regions(); c > 0; c--) {
ShenandoahHeapRegion* r = heap->get_region(c - 1);
if (r->is_humongous_start()) {
- oop old_obj = oop(r->bottom());
+ oop old_obj = cast_to_oop(r->bottom());
if (!old_obj->is_forwarded()) {
// No need to move the object, it stays at the same slot
continue;
@@ -957,7 +957,7 @@ void ShenandoahFullGC::compact_humongous_objects() {
heap->get_region(new_start)->bottom(),
words_size);
- oop new_obj = oop(heap->get_region(new_start)->bottom());
+ oop new_obj = cast_to_oop(heap->get_region(new_start)->bottom());
new_obj->init_mark();
{
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
index 2b892c276ce..df69f630c82 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
@@ -1034,7 +1034,7 @@ void ShenandoahHeap::print_heap_regions_on(outputStream* st) const {
void ShenandoahHeap::trash_humongous_region_at(ShenandoahHeapRegion* start) {
assert(start->is_humongous_start(), "reclaim regions starting with the first one");
- oop humongous_obj = oop(start->bottom());
+ oop humongous_obj = cast_to_oop(start->bottom());
size_t size = humongous_obj->size();
size_t required_regions = ShenandoahHeapRegion::required_regions(size * HeapWordSize);
size_t index = start->index() + required_regions - 1;
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp
index 8d116005804..4e83b9fc971 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp
@@ -251,7 +251,7 @@ inline oop ShenandoahHeap::evacuate_object(oop p, Thread* thread) {
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(p), copy, size);
// Try to install the new forwarding pointer.
- oop copy_val = oop(copy);
+ oop copy_val = cast_to_oop(copy);
oop result = ShenandoahForwarding::try_update_forwardee(p, copy_val);
if (result == copy_val) {
// Successfully evacuated. Our copy is now the public one!
@@ -281,7 +281,7 @@ inline oop ShenandoahHeap::evacuate_object(oop p, Thread* thread) {
}
inline bool ShenandoahHeap::requires_marking(const void* entry) const {
- oop obj = oop(entry);
+ oop obj = cast_to_oop(entry);
return !_marking_context->is_marked_strong(obj);
}
@@ -400,7 +400,7 @@ inline void ShenandoahHeap::marked_object_iterate(ShenandoahHeapRegion* region,
for (int c = 0; c < avail; c++) {
assert (slots[c] < tams, "only objects below TAMS here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(slots[c]), p2i(tams));
assert (slots[c] < limit, "only objects below limit here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(slots[c]), p2i(limit));
- oop obj = oop(slots[c]);
+ oop obj = cast_to_oop(slots[c]);
assert(oopDesc::is_oop(obj), "sanity");
assert(ctx->is_marked(obj), "object expected to be marked");
cl->do_object(obj);
@@ -410,7 +410,7 @@ inline void ShenandoahHeap::marked_object_iterate(ShenandoahHeapRegion* region,
while (cb < limit_bitmap) {
assert (cb < tams, "only objects below TAMS here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cb), p2i(tams));
assert (cb < limit, "only objects below limit here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cb), p2i(limit));
- oop obj = oop(cb);
+ oop obj = cast_to_oop(cb);
assert(oopDesc::is_oop(obj), "sanity");
assert(ctx->is_marked(obj), "object expected to be marked");
cl->do_object(obj);
@@ -428,7 +428,7 @@ inline void ShenandoahHeap::marked_object_iterate(ShenandoahHeapRegion* region,
while (cs < limit) {
assert (cs >= tams, "only objects past TAMS here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(tams));
assert (cs < limit, "only objects below limit here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(limit));
- oop obj = oop(cs);
+ 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();
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp
index 6adc450e46c..d5d411c9379 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp
@@ -392,7 +392,7 @@ void ShenandoahHeapRegion::oop_iterate_objects(OopIterateClosure* blk) {
HeapWord* t = top();
// Could call objects iterate, but this is easier.
while (obj_addr < t) {
- oop obj = oop(obj_addr);
+ oop obj = cast_to_oop(obj_addr);
obj_addr += obj->oop_iterate_size(blk);
}
}
@@ -402,7 +402,7 @@ void ShenandoahHeapRegion::oop_iterate_humongous(OopIterateClosure* blk) {
// Find head.
ShenandoahHeapRegion* r = humongous_start_region();
assert(r->is_humongous_start(), "need humongous head here");
- oop obj = oop(r->bottom());
+ oop obj = cast_to_oop(r->bottom());
obj->oop_iterate(blk, MemRegion(bottom(), top()));
}
@@ -448,9 +448,9 @@ HeapWord* ShenandoahHeapRegion::block_start(const void* p) const {
HeapWord* cur = last;
while (cur <= p) {
last = cur;
- cur += oop(cur)->size();
+ cur += cast_to_oop(cur)->size();
}
- shenandoah_assert_correct(NULL, oop(last));
+ shenandoah_assert_correct(NULL, cast_to_oop(last));
return last;
}
}
@@ -460,7 +460,7 @@ size_t ShenandoahHeapRegion::block_size(const HeapWord* p) const {
"p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")",
p2i(p), p2i(bottom()), p2i(end()));
if (p < top()) {
- return oop(p)->size();
+ return cast_to_oop(p)->size();
} else {
assert(p == top(), "just checking");
return pointer_delta(end(), (HeapWord*) p);
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp
index e309cdebe07..4748688b2da 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp
@@ -171,7 +171,7 @@ private:
}
}
- oop fwd = (oop) ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
+ oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
ShenandoahHeapRegion* fwd_reg = NULL;
@@ -204,7 +204,7 @@ private:
check(ShenandoahAsserts::_safe_oop, obj, (fwd_addr + fwd->size()) <= fwd_reg->top(),
"Forwardee end should be within the region");
- oop fwd2 = (oop) ShenandoahForwarding::get_forwardee_raw_unchecked(fwd);
+ oop fwd2 = ShenandoahForwarding::get_forwardee_raw_unchecked(fwd);
check(ShenandoahAsserts::_safe_oop, obj, (fwd == fwd2),
"Double forwarding");
} else {
@@ -536,7 +536,7 @@ public:
virtual void work_humongous(ShenandoahHeapRegion *r, ShenandoahVerifierStack& stack, ShenandoahVerifyOopClosure& cl) {
size_t processed = 0;
HeapWord* obj = r->bottom();
- if (_heap->complete_marking_context()->is_marked((oop)obj)) {
+ if (_heap->complete_marking_context()->is_marked(cast_to_oop(obj))) {
verify_and_follow(obj, stack, cl, &processed);
}
Atomic::add(&_processed, processed, memory_order_relaxed);
@@ -568,7 +568,7 @@ public:
while (addr < limit) {
verify_and_follow(addr, stack, cl, &processed);
- addr += oop(addr)->size();
+ addr += cast_to_oop(addr)->size();
}
}
@@ -579,7 +579,7 @@ public:
if (!_bitmap->par_mark(addr)) return;
// Verify the object itself:
- oop obj = oop(addr);
+ oop obj = cast_to_oop(addr);
cl.verify_oop_standalone(obj);
// Verify everything reachable from that object too, hopefully realizing
@@ -918,7 +918,7 @@ private:
T o = RawAccess<>::oop_load(p);
if (!CompressedOops::is_null(o)) {
oop obj = CompressedOops::decode_not_null(o);
- oop fwd = (oop) ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
+ oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
if (obj != fwd) {
ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, NULL,
"Verify Roots", "Should not be forwarded", __FILE__, __LINE__);
@@ -950,7 +950,7 @@ private:
"Verify Roots In To-Space", "Should not be in collection set", __FILE__, __LINE__);
}
- oop fwd = (oop) ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
+ oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
if (obj != fwd) {
ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, NULL,
"Verify Roots In To-Space", "Should not be forwarded", __FILE__, __LINE__);
diff --git a/src/hotspot/share/gc/z/zObjArrayAllocator.cpp b/src/hotspot/share/gc/z/zObjArrayAllocator.cpp
index 32c16fd959e..2e30bd8c694 100644
--- a/src/hotspot/share/gc/z/zObjArrayAllocator.cpp
+++ b/src/hotspot/share/gc/z/zObjArrayAllocator.cpp
@@ -61,5 +61,5 @@ oop ZObjArrayAllocator::finish(HeapWord* mem) const {
ZThreadLocalData::clear_invisible_root(_thread);
- return oop(mem);
+ return cast_to_oop(mem);
}
diff --git a/src/hotspot/share/interpreter/interpreterRuntime.cpp b/src/hotspot/share/interpreter/interpreterRuntime.cpp
index cbec6124221..2ff8552c71d 100644
--- a/src/hotspot/share/interpreter/interpreterRuntime.cpp
+++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp
@@ -1498,7 +1498,7 @@ JRT_ENTRY(void, InterpreterRuntime::member_name_arg_or_null(JavaThread* thread,
Symbol* mname = cpool->name_ref_at(cp_index);
if (MethodHandles::has_member_arg(cname, mname)) {
- oop member_name_oop = (oop) member_name;
+ oop member_name_oop = cast_to_oop(member_name);
if (java_lang_invoke_DirectMethodHandle::is_instance(member_name_oop)) {
// FIXME: remove after j.l.i.InvokerBytecodeGenerator code shape is updated.
member_name_oop = java_lang_invoke_DirectMethodHandle::member(member_name_oop);
diff --git a/src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp b/src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp
index 21eb67ea172..e10a86361b9 100644
--- a/src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp
+++ b/src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp
@@ -1605,9 +1605,9 @@ run:
count_addr = (int *)JvmtiExport::get_field_access_count_addr();
if ( *count_addr > 0 ) {
if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) {
- obj = (oop)NULL;
+ obj = NULL;
} else {
- obj = (oop) STACK_OBJECT(-1);
+ obj = STACK_OBJECT(-1);
VERIFY_OOP(obj);
}
CALL_VM(InterpreterRuntime::post_field_access(THREAD,
@@ -1623,7 +1623,7 @@ run:
obj = k->java_mirror();
MORE_STACK(1); // Assume single slot push
} else {
- obj = (oop) STACK_OBJECT(-1);
+ obj = STACK_OBJECT(-1);
CHECK_NULL(obj);
}
@@ -1729,13 +1729,13 @@ run:
count_addr = (int *)JvmtiExport::get_field_modification_count_addr();
if ( *count_addr > 0 ) {
if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) {
- obj = (oop)NULL;
+ obj = NULL;
}
else {
if (cache->is_long() || cache->is_double()) {
- obj = (oop) STACK_OBJECT(-3);
+ obj = STACK_OBJECT(-3);
} else {
- obj = (oop) STACK_OBJECT(-2);
+ obj = STACK_OBJECT(-2);
}
VERIFY_OOP(obj);
}
@@ -1764,7 +1764,7 @@ run:
obj = k->java_mirror();
} else {
--count;
- obj = (oop) STACK_OBJECT(count);
+ obj = STACK_OBJECT(count);
CHECK_NULL(obj);
}
diff --git a/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp b/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp
index 9074dbf862c..5443069a656 100644
--- a/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp
+++ b/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp
@@ -235,7 +235,7 @@ void ObjectSampler::add(HeapWord* obj, size_t allocated, traceid thread_id, Java
}
sample->set_span(allocated);
- sample->set_object((oop)obj);
+ sample->set_object(cast_to_oop(obj));
sample->set_allocated(allocated);
sample->set_allocation_time(JfrTicks::now());
sample->set_heap_used_at_last_gc(Universe::heap()->used_at_last_gc());
diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp
index 2209f219223..5e1ce0f475a 100644
--- a/src/hotspot/share/jvmci/jvmciRuntime.cpp
+++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp
@@ -487,7 +487,7 @@ class ArgumentPusher : public SignatureIterator {
Handle next_object() {
guarantee(!_pushed, "one argument");
_pushed = true;
- return Handle(Thread::current(), (oop) (address) _argument);
+ return Handle(Thread::current(), cast_to_oop(_argument));
}
public:
@@ -536,7 +536,7 @@ JRT_ENTRY(jlong, JVMCIRuntime::invoke_static_method_one_arg(JavaThread* thread,
if (return_type == T_VOID) {
return 0;
} else if (return_type == T_OBJECT || return_type == T_ARRAY) {
- thread->set_vm_result((oop) result.get_jobject());
+ thread->set_vm_result(result.get_oop());
return 0;
} else {
jvalue *value = (jvalue *) result.get_value_addr();
@@ -656,7 +656,7 @@ static void decipher(jlong v, bool ignoreZero) {
return;
}
if (Universe::heap()->is_in(p)) {
- oop obj = oop(p);
+ oop obj = cast_to_oop(p);
obj->print_value_on(tty);
return;
}
diff --git a/src/hotspot/share/memory/filemap.cpp b/src/hotspot/share/memory/filemap.cpp
index ae238ad9d42..2c520909ef0 100644
--- a/src/hotspot/share/memory/filemap.cpp
+++ b/src/hotspot/share/memory/filemap.cpp
@@ -1310,7 +1310,7 @@ void FileMapInfo::write_region(int region, char* base, size_t size,
} else if (HeapShared::is_heap_region(region)) {
assert(!DynamicDumpSharedSpaces, "must be");
requested_base = base;
- mapping_offset = (size_t)CompressedOops::encode_not_null((oop)base);
+ mapping_offset = (size_t)CompressedOops::encode_not_null(cast_to_oop(base));
assert(mapping_offset == (size_t)(uint32_t)mapping_offset, "must be 32-bit only");
} else {
char* requested_SharedBaseAddress = (char*)MetaspaceShared::requested_base_address();
diff --git a/src/hotspot/share/memory/heapShared.cpp b/src/hotspot/share/memory/heapShared.cpp
index 8191f6d8a9f..a701c314dd0 100644
--- a/src/hotspot/share/memory/heapShared.cpp
+++ b/src/hotspot/share/memory/heapShared.cpp
@@ -263,7 +263,7 @@ oop HeapShared::archive_heap_object(oop obj) {
return NULL;
}
- oop archived_oop = (oop)G1CollectedHeap::heap()->archive_mem_allocate(len);
+ oop archived_oop = cast_to_oop(G1CollectedHeap::heap()->archive_mem_allocate(len));
if (archived_oop != NULL) {
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(obj), cast_from_oop<HeapWord*>(archived_oop), len);
// Reinitialize markword to remove age/marking/locking/etc.
@@ -424,7 +424,7 @@ void HeapShared::copy_roots() {
arrayOopDesc::set_length(mem, length);
}
- _roots = OopHandle(Universe::vm_global(), (oop)mem);
+ _roots = OopHandle(Universe::vm_global(), cast_to_oop(mem));
for (int i = 0; i < length; i++) {
roots()->obj_at_put(i, _pending_roots->at(i));
}
@@ -1395,7 +1395,7 @@ ResourceBitMap HeapShared::calculate_oopmap(MemRegion region) {
int num_objs = 0;
while (p < end) {
- oop o = (oop)p;
+ oop o = cast_to_oop(p);
o->oop_iterate(&finder);
p += o->size();
if (DumpSharedSpaces) {
diff --git a/src/hotspot/share/memory/heapShared.inline.hpp b/src/hotspot/share/memory/heapShared.inline.hpp
index a022fcfb4bc..c6fc737c971 100644
--- a/src/hotspot/share/memory/heapShared.inline.hpp
+++ b/src/hotspot/share/memory/heapShared.inline.hpp
@@ -38,7 +38,7 @@ bool HeapShared::is_archived_object(oop p) {
inline oop HeapShared::decode_from_archive(narrowOop v) {
assert(!CompressedOops::is_null(v), "narrow oop value can never be zero");
- oop result = (oop)(void*)((uintptr_t)_narrow_oop_base + ((uintptr_t)v << _narrow_oop_shift));
+ oop result = cast_to_oop((uintptr_t)_narrow_oop_base + ((uintptr_t)v << _narrow_oop_shift));
assert(is_object_aligned(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
return result;
}
diff --git a/src/hotspot/share/oops/compressedOops.inline.hpp b/src/hotspot/share/oops/compressedOops.inline.hpp
index 597c3e96bbd..0843d7c936b 100644
--- a/src/hotspot/share/oops/compressedOops.inline.hpp
+++ b/src/hotspot/share/oops/compressedOops.inline.hpp
@@ -47,7 +47,7 @@ inline oop CompressedOops::decode_raw_not_null(narrowOop v) {
}
inline oop CompressedOops::decode_raw(narrowOop v) {
- return (oop)(void*)((uintptr_t)base() + ((uintptr_t)v << shift()));
+ return cast_to_oop((uintptr_t)base() + ((uintptr_t)v << shift()));
}
inline oop CompressedOops::decode_not_null(narrowOop v) {
diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp
index 4af03c6b54c..c140cfb19cd 100644
--- a/src/hotspot/share/oops/constantPool.cpp
+++ b/src/hotspot/share/oops/constantPool.cpp
@@ -197,7 +197,7 @@ void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data,
// Create Java array for holding resolved strings, methodHandles,
// methodTypes, invokedynamic and invokehandle appendix objects, etc.
objArrayOop stom = oopFactory::new_objArray(vmClasses::Object_klass(), map_length, CHECK);
- Handle refs_handle (THREAD, (oop)stom); // must handleize.
+ Handle refs_handle (THREAD, stom); // must handleize.
set_resolved_references(loader_data->add_handle(refs_handle));
}
}
@@ -382,7 +382,7 @@ void ConstantPool::restore_unshareable_info(TRAPS) {
int map_length = resolved_reference_length();
if (map_length > 0) {
objArrayOop stom = oopFactory::new_objArray(vmClasses::Object_klass(), map_length, CHECK);
- Handle refs_handle(THREAD, (oop)stom); // must handleize.
+ Handle refs_handle(THREAD, stom); // must handleize.
set_resolved_references(loader_data->add_handle(refs_handle));
}
}
diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp
index 9bc2abdefc6..7ad5985b114 100644
--- a/src/hotspot/share/oops/instanceKlass.cpp
+++ b/src/hotspot/share/oops/instanceKlass.cpp
@@ -787,7 +787,7 @@ oop InstanceKlass::init_lock() const {
oop lock = java_lang_Class::init_lock(java_mirror());
// Prevent reordering with any access of initialization state
OrderAccess::loadload();
- assert((oop)lock != NULL || !is_not_initialized(), // initialized or in_error state
+ assert(lock != NULL || !is_not_initialized(), // initialized or in_error state
"only fully initialized state can have a null lock");
return lock;
}
diff --git a/src/hotspot/share/oops/oop.cpp b/src/hotspot/share/oops/oop.cpp
index 88af956b21e..bbb4decdfbb 100644
--- a/src/hotspot/share/oops/oop.cpp
+++ b/src/hotspot/share/oops/oop.cpp
@@ -38,7 +38,7 @@
#include "utilities/macros.hpp"
void oopDesc::print_on(outputStream* st) const {
- klass()->oop_print_on(oop(this), st);
+ klass()->oop_print_on(const_cast<oopDesc*>(this), st);
}
void oopDesc::print_address_on(outputStream* st) const {
@@ -68,7 +68,7 @@ char* oopDesc::print_value_string() {
}
void oopDesc::print_value_on(outputStream* st) const {
- oop obj = oop(this);
+ oop obj = const_cast<oopDesc*>(this);
if (java_lang_String::is_instance(obj)) {
java_lang_String::print(obj, st);
print_address_on(st);
diff --git a/src/hotspot/share/oops/oop.inline.hpp b/src/hotspot/share/oops/oop.inline.hpp
index 0ca29f42848..b6921bed4fc 100644
--- a/src/hotspot/share/oops/oop.inline.hpp
+++ b/src/hotspot/share/oops/oop.inline.hpp
@@ -294,7 +294,7 @@ oop oopDesc::forward_to_atomic(oop p, markWord compare, atomic_memory_order orde
if (old_mark == compare) {
return NULL;
} else {
- return (oop)old_mark.decode_pointer();
+ return cast_to_oop(old_mark.decode_pointer());
}
}
@@ -302,14 +302,14 @@ oop oopDesc::forward_to_atomic(oop p, markWord compare, atomic_memory_order orde
// The forwardee is used when copying during scavenge and mark-sweep.
// It does need to clear the low two locking- and GC-related bits.
oop oopDesc::forwardee() const {
- return (oop) mark().decode_pointer();
+ return cast_to_oop(mark().decode_pointer());
}
// Note that the forwardee is not the same thing as the displaced_mark.
// The forwardee is used when copying during scavenge and mark-sweep.
// It does need to clear the low two locking- and GC-related bits.
oop oopDesc::forwardee_acquire() const {
- return (oop) Atomic::load_acquire(&_mark).decode_pointer();
+ return cast_to_oop(Atomic::load_acquire(&_mark).decode_pointer());
}
// The following method needs to be MT safe.
diff --git a/src/hotspot/share/oops/oopsHierarchy.hpp b/src/hotspot/share/oops/oopsHierarchy.hpp
index 12662c67613..5249f671a34 100644
--- a/src/hotspot/share/oops/oopsHierarchy.hpp
+++ b/src/hotspot/share/oops/oopsHierarchy.hpp
@@ -86,9 +86,9 @@ class oop {
}
public:
- oop() : _o(NULL) { register_if_checking(); }
- oop(const oop& o) : _o(o._o) { register_if_checking(); }
- oop(const void* p) : _o((oopDesc*)p) { register_if_checking(); }
+ oop() : _o(nullptr) { register_if_checking(); }
+ oop(const oop& o) : _o(o._o) { register_if_checking(); }
+ oop(oopDesc* o) : _o(o) { register_if_checking(); }
~oop() {
if (CheckUnhandledOops) unregister_oop();
}
@@ -98,11 +98,12 @@ public:
operator oopDesc* () const { return _o; }
bool operator==(const oop& o) const { return _o == o._o; }
- bool operator==(void *p) const { return _o == p; }
bool operator!=(const oop& o) const { return _o != o._o; }
- bool operator!=(void *p) const { return _o != p; }
- oop& operator=(const oop& o) { _o = o._o; return *this; }
+ bool operator==(nullptr_t) const { return _o == nullptr; }
+ bool operator!=(nullptr_t) const { return _o != nullptr; }
+
+ oop& operator=(const oop& o) { _o = o._o; return *this; }
};
template<>
@@ -148,13 +149,11 @@ DEF_OOP(typeArray);
#endif // CHECK_UNHANDLED_OOPS
-// For CHECK_UNHANDLED_OOPS, it is ambiguous C++ behavior to have the oop
-// structure contain explicit user defined conversions of both numerical
-// and pointer type. Define inline methods to provide the numerical conversions.
-template <class T> inline oop cast_to_oop(T value) {
- return (oop)(CHECK_UNHANDLED_OOPS_ONLY((void *))(value));
+// Cast functions to convert to and from oops.
+template <typename T> inline oop cast_to_oop(T value) {
+ return (oopDesc*)value;
}
-template <class T> inline T cast_from_oop(oop o) {
+template <typename T> inline T cast_from_oop(oop o) {
return (T)(CHECK_UNHANDLED_OOPS_ONLY((oopDesc*))o);
}
diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp
index 2d4e4fb492f..1b7b065c22e 100644
--- a/src/hotspot/share/prims/jvm.cpp
+++ b/src/hotspot/share/prims/jvm.cpp
@@ -600,7 +600,7 @@ JVM_ENTRY(void, JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms))
Handle obj(THREAD, JNIHandles::resolve_non_null(handle));
JavaThreadInObjectWaitState jtiows(thread, ms != 0);
if (JvmtiExport::should_post_monitor_wait()) {
- JvmtiExport::post_monitor_wait(thread, (oop)obj(), ms);
+ JvmtiExport::post_monitor_wait(thread, obj(), ms);
// The current thread already owns the monitor and it has not yet
// been added to the wait queue so the current thread cannot be
diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp
index 129de1aedf5..86b697c03f9 100644
--- a/src/hotspot/share/prims/jvmtiEnv.cpp
+++ b/src/hotspot/share/prims/jvmtiEnv.cpp
@@ -1446,7 +1446,7 @@ JvmtiEnv::GetThreadGroupInfo(jthreadGroup group, jvmtiThreadGroupInfo* info_ptr)
jvmtiError
JvmtiEnv::GetThreadGroupChildren(jthreadGroup group, jint* thread_count_ptr, jthread** threads_ptr, jint* group_count_ptr, jthreadGroup** groups_ptr) {
JavaThread* current_thread = JavaThread::current();
- oop group_obj = (oop) JNIHandles::resolve_external_guard(group);
+ oop group_obj = JNIHandles::resolve_external_guard(group);
NULL_CHECK(group_obj, JVMTI_ERROR_INVALID_THREAD_GROUP);
Handle *thread_objs = NULL;
diff --git a/src/hotspot/share/prims/jvmtiExport.cpp b/src/hotspot/share/prims/jvmtiExport.cpp
index eca6c573888..e7dba71a8b6 100644
--- a/src/hotspot/share/prims/jvmtiExport.cpp
+++ b/src/hotspot/share/prims/jvmtiExport.cpp
@@ -2047,7 +2047,7 @@ void JvmtiExport::post_raw_field_modification(JavaThread *thread, Method* method
// convert oop to JNI handle.
if (sig_type == JVM_SIGNATURE_CLASS) {
handle_created = true;
- value->l = (jobject)JNIHandles::make_local(thread, (oop)value->l);
+ value->l = (jobject)JNIHandles::make_local(thread, cast_to_oop(value->l));
}
post_field_modification(thread, method, location, field_klass, object, field, sig_type, value);
diff --git a/src/hotspot/share/prims/vectorSupport.cpp b/src/hotspot/share/prims/vectorSupport.cpp
index 8be642dc72c..0b949e2da77 100644
--- a/src/hotspot/share/prims/vectorSupport.cpp
+++ b/src/hotspot/share/prims/vectorSupport.cpp
@@ -173,7 +173,7 @@ Handle VectorSupport::allocate_vector_payload(InstanceKlass* ik, frame* fr, Regi
assert(payload->is_object(), "expected 'object' value for scalar-replaced boxed vector but got: %s", ss.as_string());
#endif
}
- return Handle(THREAD, (oop)nullptr);
+ return Handle(THREAD, nullptr);
}
instanceOop VectorSupport::allocate_vector(InstanceKlass* ik, frame* fr, RegisterMap* reg_map, ObjectValue* ov, TRAPS) {
diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp
index 8ac41bd5af6..1d37a7efaa2 100644
--- a/src/hotspot/share/runtime/deoptimization.cpp
+++ b/src/hotspot/share/runtime/deoptimization.cpp
@@ -271,7 +271,7 @@ static void restore_eliminated_locks(JavaThread* thread, GrowableArray<compiledV
}
if (exec_mode == Deoptimization::Unpack_none) {
ObjectMonitor* monitor = deoptee_thread->current_waiting_monitor();
- if (monitor != NULL && (oop)monitor->object() == mi->owner()) {
+ if (monitor != NULL && monitor->object() == mi->owner()) {
tty->print_cr(" object <" INTPTR_FORMAT "> DEFERRED relocking after wait", p2i(mi->owner()));
continue;
}
@@ -1467,7 +1467,7 @@ bool Deoptimization::relock_objects(JavaThread* thread, GrowableArray<MonitorInf
if (mark.has_monitor()) {
// defer relocking if the deoptee thread is currently waiting for obj
ObjectMonitor* waiting_monitor = deoptee_thread->current_waiting_monitor();
- if (waiting_monitor != NULL && (oop)waiting_monitor->object() == obj()) {
+ if (waiting_monitor != NULL && waiting_monitor->object() == obj()) {
assert(fr.is_deoptimized_frame(), "frame must be scheduled for deoptimization");
mon_info->lock()->set_displaced_header(markWord::unused_mark());
JvmtiDeferredUpdates::inc_relock_count_after_wait(deoptee_thread);
diff --git a/src/hotspot/share/runtime/objectMonitor.cpp b/src/hotspot/share/runtime/objectMonitor.cpp
index 619d0bc5f55..001f1c63435 100644
--- a/src/hotspot/share/runtime/objectMonitor.cpp
+++ b/src/hotspot/share/runtime/objectMonitor.cpp
@@ -69,7 +69,7 @@
char* bytes = NULL; \
int len = 0; \
jlong jtid = SharedRuntime::get_java_tid(thread); \
- Symbol* klassname = ((oop)obj)->klass()->name(); \
+ Symbol* klassname = obj->klass()->name(); \
if (klassname != NULL) { \
bytes = (char*)klassname->bytes(); \
len = klassname->utf8_length(); \
diff --git a/src/hotspot/share/runtime/reflection.cpp b/src/hotspot/share/runtime/reflection.cpp
index c093446974f..9f0abe3861f 100644
--- a/src/hotspot/share/runtime/reflection.cpp
+++ b/src/hotspot/share/runtime/reflection.cpp
@@ -100,7 +100,7 @@ oop Reflection::box(jvalue* value, BasicType type, TRAPS) {
}
if (is_reference_type(type)) {
// regular objects are not boxed
- return (oop) value->l;
+ return cast_to_oop(value->l);
}
oop result = java_lang_boxing_object::create(type, value, CHECK_NULL);
if (result == NULL) {
@@ -274,7 +274,7 @@ void Reflection::array_set(jvalue* value, arrayOop a, int index, BasicType value
}
if (a->is_objArray()) {
if (value_type == T_OBJECT) {
- oop obj = (oop) value->l;
+ oop obj = cast_to_oop(value->l);
if (obj != NULL) {
Klass* element_klass = ObjArrayKlass::cast(a->klass())->element_klass();
if (!obj->is_a(element_klass)) {
diff --git a/src/hotspot/share/runtime/vframe.cpp b/src/hotspot/share/runtime/vframe.cpp
index b50c18c944f..d66895a71a3 100644
--- a/src/hotspot/share/runtime/vframe.cpp
+++ b/src/hotspot/share/runtime/vframe.cpp
@@ -146,8 +146,8 @@ GrowableArray<MonitorInfo*>* javaVFrame::locked_monitors() {
if (waiting_monitor == NULL) {
pending_monitor = thread()->current_pending_monitor();
}
- oop pending_obj = (pending_monitor != NULL ? (oop) pending_monitor->object() : (oop) NULL);
- oop waiting_obj = (waiting_monitor != NULL ? (oop) waiting_monitor->object() : (oop) NULL);
+ oop pending_obj = (pending_monitor != NULL ? pending_monitor->object() : (oop) NULL);
+ oop waiting_obj = (waiting_monitor != NULL ? waiting_monitor->object() : (oop) NULL);
for (int index = (mons->length()-1); index >= 0; index--) {
MonitorInfo* monitor = mons->at(index);
diff --git a/src/hotspot/share/runtime/vframeArray.cpp b/src/hotspot/share/runtime/vframeArray.cpp
index 1d73ec6ea3d..618e11c4258 100644
--- a/src/hotspot/share/runtime/vframeArray.cpp
+++ b/src/hotspot/share/runtime/vframeArray.cpp
@@ -351,7 +351,7 @@ void vframeArrayElement::unpack_on_stack(int caller_actual_parameters,
#ifndef PRODUCT
if (PrintDeoptimizationDetails) {
tty->print("Reconstructed expression %d (OBJECT): ", i);
- oop o = (oop)(address)(*addr);
+ oop o = cast_to_oop((address)(*addr));
if (o == NULL) {
tty->print_cr("NULL");
} else {
@@ -389,7 +389,7 @@ void vframeArrayElement::unpack_on_stack(int caller_actual_parameters,
#ifndef PRODUCT
if (PrintDeoptimizationDetails) {
tty->print("Reconstructed local %d (OBJECT): ", i);
- oop o = (oop)(address)(*addr);
+ oop o = cast_to_oop((address)(*addr));
if (o == NULL) {
tty->print_cr("NULL");
} else {
diff --git a/src/hotspot/share/runtime/vframe_hp.cpp b/src/hotspot/share/runtime/vframe_hp.cpp
index cc96123f504..cdb72ab4f7a 100644
--- a/src/hotspot/share/runtime/vframe_hp.cpp
+++ b/src/hotspot/share/runtime/vframe_hp.cpp
@@ -459,7 +459,7 @@ void jvmtiDeferredLocalVariableSet::update_value(StackValueCollection* locals, B
break;
case T_OBJECT:
{
- Handle obj(Thread::current(), (oop)value.l);
+ Handle obj(Thread::current(), cast_to_oop(value.l));
locals->set_obj_at(index, obj);
}
break;
diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp
index c797baf0ddd..a3b0d485e88 100644
--- a/src/hotspot/share/services/diagnosticCommand.cpp
+++ b/src/hotspot/share/services/diagnosticCommand.cpp
@@ -870,7 +870,7 @@ void JMXStatusDCmd::execute(DCmdSource source, TRAPS) {
JavaCalls::call_static(&result, k, vmSymbols::getAgentStatus_name(), vmSymbols::void_string_signature(), CHECK);
jvalue* jv = (jvalue*) result.get_value_addr();
- oop str = (oop) jv->l;
+ oop str = cast_to_oop(jv->l);
if (str != NULL) {
char* out = java_lang_String::as_utf8_string(str);
if (out) {
diff --git a/src/hotspot/share/utilities/debug.cpp b/src/hotspot/share/utilities/debug.cpp
index 25762fa43f1..8caba6d448d 100644
--- a/src/hotspot/share/utilities/debug.cpp
+++ b/src/hotspot/share/utilities/debug.cpp
@@ -482,7 +482,7 @@ extern "C" void pp(void* p) {
Command c("pp");
FlagSetting fl(DisplayVMOutput, true);
if (Universe::heap()->is_in(p)) {
- oop obj = oop(p);
+ oop obj = cast_to_oop(p);
obj->print();
} else {
tty->print(PTR_FORMAT, p2i(p));
diff --git a/test/hotspot/gtest/oops/test_typeArrayOop.cpp b/test/hotspot/gtest/oops/test_typeArrayOop.cpp
index 0b57be309b7..2d9c8cfd990 100644
--- a/test/hotspot/gtest/oops/test_typeArrayOop.cpp
+++ b/test/hotspot/gtest/oops/test_typeArrayOop.cpp
@@ -35,7 +35,7 @@ TEST_VM(typeArrayOopDesc, bool_at_put) {
char* addr = align_up(mem, 16);
- typeArrayOop o = (typeArrayOop) addr;
+ typeArrayOop o = (typeArrayOop) cast_to_oop(addr);
o->set_klass(Universe::boolArrayKlassObj());
o->set_length(10);