8221984: ZGC: Clean up ZOop
authorpliden
Wed, 10 Apr 2019 12:45:32 +0200
changeset 54488 25199b48f34f
parent 54487 4fa1fd8bc21e
child 54489 a84fefde0543
8221984: ZGC: Clean up ZOop Reviewed-by: stefank, eosterlund
src/hotspot/share/gc/z/zBarrier.cpp
src/hotspot/share/gc/z/zBarrier.inline.hpp
src/hotspot/share/gc/z/zHeap.inline.hpp
src/hotspot/share/gc/z/zLiveMap.inline.hpp
src/hotspot/share/gc/z/zMark.cpp
src/hotspot/share/gc/z/zOop.hpp
src/hotspot/share/gc/z/zOop.inline.hpp
src/hotspot/share/gc/z/zOopClosures.cpp
src/hotspot/share/gc/z/zUtils.inline.hpp
--- a/src/hotspot/share/gc/z/zBarrier.cpp	Tue Apr 09 12:47:34 2019 +0200
+++ b/src/hotspot/share/gc/z/zBarrier.cpp	Wed Apr 10 12:45:32 2019 +0200
@@ -123,7 +123,7 @@
 }
 
 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);
 }
--- a/src/hotspot/share/gc/z/zBarrier.inline.hpp	Tue Apr 09 12:47:34 2019 +0200
+++ b/src/hotspot/share/gc/z/zBarrier.inline.hpp	Wed Apr 10 12:45:32 2019 +0200
@@ -37,7 +37,7 @@
 retry:
   // Fast path
   if (fast_path(addr)) {
-    return ZOop::to_oop(addr);
+    return ZOop::from_address(addr);
   }
 
   // Slow path
@@ -56,7 +56,7 @@
     }
   }
 
-  return ZOop::to_oop(good_addr);
+  return ZOop::from_address(good_addr);
 }
 
 template <ZBarrierFastPath fast_path, ZBarrierSlowPath slow_path>
@@ -67,7 +67,7 @@
   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 @@
     }
   }
 
-  return ZOop::to_oop(good_addr);
+  return ZOop::from_address(good_addr);
 }
 
 template <ZBarrierFastPath fast_path, ZBarrierSlowPath slow_path>
@@ -117,7 +117,7 @@
   // 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) {
--- a/src/hotspot/share/gc/z/zHeap.inline.hpp	Tue Apr 09 12:47:34 2019 +0200
+++ b/src/hotspot/share/gc/z/zHeap.inline.hpp	Wed Apr 10 12:45:32 2019 +0200
@@ -135,7 +135,7 @@
 }
 
 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
--- a/src/hotspot/share/gc/z/zLiveMap.inline.hpp	Tue Apr 09 12:47:34 2019 +0200
+++ b/src/hotspot/share/gc/z/zLiveMap.inline.hpp	Wed Apr 10 12:45:32 2019 +0200
@@ -144,7 +144,7 @@
     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);
--- a/src/hotspot/share/gc/z/zMark.cpp	Tue Apr 09 12:47:34 2019 +0200
+++ b/src/hotspot/share/gc/z/zMark.cpp	Wed Apr 10 12:45:32 2019 +0200
@@ -200,7 +200,7 @@
 }
 
 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 @@
   }
 
   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);
   }
 }
 
--- a/src/hotspot/share/gc/z/zOop.hpp	Tue Apr 09 12:47:34 2019 +0200
+++ b/src/hotspot/share/gc/z/zOop.hpp	Wed Apr 10 12:45:32 2019 +0200
@@ -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
--- a/src/hotspot/share/gc/z/zOop.inline.hpp	Tue Apr 09 12:47:34 2019 +0200
+++ b/src/hotspot/share/gc/z/zOop.inline.hpp	Wed Apr 10 12:45:32 2019 +0200
@@ -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
--- a/src/hotspot/share/gc/z/zOopClosures.cpp	Tue Apr 09 12:47:34 2019 +0200
+++ b/src/hotspot/share/gc/z/zOopClosures.cpp	Wed Apr 10 12:45:32 2019 +0200
@@ -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 @@
 
   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));
   }
 }
 
--- a/src/hotspot/share/gc/z/zUtils.inline.hpp	Tue Apr 09 12:47:34 2019 +0200
+++ b/src/hotspot/share/gc/z/zUtils.inline.hpp	Wed Apr 10 12:45:32 2019 +0200
@@ -57,7 +57,7 @@
 }
 
 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) {