8221984: ZGC: Clean up ZOop

Reviewed-by: stefank, eosterlund
This commit is contained in:
Per Lidén 2019-04-10 12:45:32 +02:00
parent 91c90755b5
commit 3a2343d9e6
9 changed files with 24 additions and 41 deletions

View File

@ -123,7 +123,7 @@ uintptr_t ZBarrier::load_barrier_on_oop_slow_path(uintptr_t addr) {
}
void ZBarrier::load_barrier_on_oop_fields(oop o) {
assert(ZOop::is_good(o), "Should be good");
assert(ZAddress::is_good(ZOop::to_address(o)), "Should be good");
ZLoadBarrierOopClosure cl;
o->oop_iterate(&cl);
}

View File

@ -37,7 +37,7 @@ inline oop ZBarrier::barrier(volatile oop* p, oop o) {
retry:
// Fast path
if (fast_path(addr)) {
return ZOop::to_oop(addr);
return ZOop::from_address(addr);
}
// Slow path
@ -56,7 +56,7 @@ retry:
}
}
return ZOop::to_oop(good_addr);
return ZOop::from_address(good_addr);
}
template <ZBarrierFastPath fast_path, ZBarrierSlowPath slow_path>
@ -67,7 +67,7 @@ inline oop ZBarrier::weak_barrier(volatile oop* p, oop o) {
if (fast_path(addr)) {
// Return the good address instead of the weak good address
// to ensure that the currently active heap view is used.
return ZOop::to_oop(ZAddress::good_or_null(addr));
return ZOop::from_address(ZAddress::good_or_null(addr));
}
// Slow path
@ -95,7 +95,7 @@ inline oop ZBarrier::weak_barrier(volatile oop* p, oop o) {
}
}
return ZOop::to_oop(good_addr);
return ZOop::from_address(good_addr);
}
template <ZBarrierFastPath fast_path, ZBarrierSlowPath slow_path>
@ -117,7 +117,7 @@ inline void ZBarrier::root_barrier(oop* p, oop o) {
// to heal the same root if it is aligned, since they would always heal
// the root in the same way and it does not matter in which order it
// happens. For misaligned oops, there needs to be mutual exclusion.
*p = ZOop::to_oop(good_addr);
*p = ZOop::from_address(good_addr);
}
inline bool ZBarrier::is_null_fast_path(uintptr_t addr) {

View File

@ -135,7 +135,7 @@ inline void ZHeap::check_out_of_memory() {
}
inline bool ZHeap::is_oop(oop object) const {
return ZOop::is_good(object);
return ZAddress::is_good(ZOop::to_address(object));
}
#endif // SHARE_GC_Z_ZHEAP_INLINE_HPP

View File

@ -144,7 +144,7 @@ inline void ZLiveMap::iterate_segment(ObjectClosure* cl, BitMap::idx_t segment,
const uintptr_t addr = page_start + ((index / 2) << page_object_alignment_shift);
// Apply closure
cl->do_object(ZOop::to_oop(addr));
cl->do_object(ZOop::from_address(addr));
// Find next bit after this object
const size_t size = ZUtils::object_size(addr);

View File

@ -200,7 +200,7 @@ void ZMark::finish_work() {
}
bool ZMark::is_array(uintptr_t addr) const {
return ZOop::to_oop(addr)->is_objArray();
return ZOop::from_address(addr)->is_objArray();
}
void ZMark::push_partial_array(uintptr_t addr, size_t size, bool finalizable) {
@ -347,9 +347,9 @@ void ZMark::mark_and_follow(ZMarkCache* cache, ZMarkStackEntry entry) {
}
if (is_array(addr)) {
follow_array_object(objArrayOop(ZOop::to_oop(addr)), finalizable);
follow_array_object(objArrayOop(ZOop::from_address(addr)), finalizable);
} else {
follow_object(ZOop::to_oop(addr), finalizable);
follow_object(ZOop::from_address(addr), finalizable);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,13 +29,8 @@
class ZOop : public AllStatic {
public:
static oop to_oop(uintptr_t value);
static oop from_address(uintptr_t addr);
static uintptr_t to_address(oop o);
static bool is_good(oop o);
static bool is_finalizable_good(oop o);
static oop good(oop);
};
#endif // SHARE_GC_Z_ZOOP_HPP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,28 +24,14 @@
#ifndef SHARE_GC_Z_ZOOP_INLINE_HPP
#define SHARE_GC_Z_ZOOP_INLINE_HPP
#include "gc/z/zAddress.inline.hpp"
#include "gc/z/zOop.hpp"
#include "oops/oopsHierarchy.hpp"
inline oop ZOop::to_oop(uintptr_t value) {
return cast_to_oop(value);
inline oop ZOop::from_address(uintptr_t addr) {
return cast_to_oop(addr);
}
inline uintptr_t ZOop::to_address(oop o) {
return cast_from_oop<uintptr_t>(o);
}
inline bool ZOop::is_good(oop o) {
return ZAddress::is_good(to_address(o));
}
inline bool ZOop::is_finalizable_good(oop o) {
return ZAddress::is_finalizable_good(to_address(o));
}
inline oop ZOop::good(oop o) {
return to_oop(ZAddress::good(to_address(o)));
}
#endif // SHARE_GC_Z_ZOOP_INLINE_HPP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -39,12 +39,14 @@ void ZVerifyOopClosure::do_oop(oop* p) {
const oop o = RawAccess<>::oop_load(p);
if (o != NULL) {
guarantee(ZOop::is_good(o) || ZOop::is_finalizable_good(o),
const uintptr_t addr = ZOop::to_address(o);
const uintptr_t good_addr = ZAddress::good(addr);
guarantee(ZAddress::is_good(addr) || ZAddress::is_finalizable_good(addr),
"Bad oop " PTR_FORMAT " found at " PTR_FORMAT ", expected " PTR_FORMAT,
p2i(o), p2i(p), p2i(ZOop::good(o)));
guarantee(oopDesc::is_oop(ZOop::good(o)),
addr, p2i(p), good_addr);
guarantee(oopDesc::is_oop(ZOop::from_address(good_addr)),
"Bad object " PTR_FORMAT " found at " PTR_FORMAT,
p2i(o), p2i(p));
addr, p2i(p));
}
}

View File

@ -57,7 +57,7 @@ inline size_t ZUtils::words_to_bytes(size_t size_in_words) {
}
inline size_t ZUtils::object_size(uintptr_t addr) {
return words_to_bytes(ZOop::to_oop(addr)->size());
return words_to_bytes(ZOop::from_address(addr)->size());
}
inline void ZUtils::object_copy(uintptr_t from, uintptr_t to, size_t size) {