src/hotspot/share/gc/z/zHeap.inline.hpp
changeset 54162 f344a0c6e19e
parent 50582 6464882498b5
child 54163 790679f86a51
--- a/src/hotspot/share/gc/z/zHeap.inline.hpp	Mon Mar 18 11:50:39 2019 +0100
+++ b/src/hotspot/share/gc/z/zHeap.inline.hpp	Mon Mar 18 11:50:39 2019 +0100
@@ -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
@@ -25,6 +25,8 @@
 #define SHARE_GC_Z_ZHEAP_INLINE_HPP
 
 #include "gc/z/zAddress.inline.hpp"
+#include "gc/z/zForwarding.inline.hpp"
+#include "gc/z/zForwardingTable.inline.hpp"
 #include "gc/z/zHeap.hpp"
 #include "gc/z/zMark.inline.hpp"
 #include "gc/z/zOop.inline.hpp"
@@ -42,8 +44,8 @@
   return &_reference_processor;
 }
 
-inline bool ZHeap::is_relocating(uintptr_t addr) const {
-  return _pagetable.is_relocating(addr);
+inline ZForwarding* ZHeap::forwarding(uintptr_t addr) {
+  return _forwarding_table.get(addr);
 }
 
 inline bool ZHeap::is_object_live(uintptr_t addr) const {
@@ -89,6 +91,40 @@
   _object_allocator.undo_alloc_object_for_relocation(page, addr, size);
 }
 
+inline uintptr_t ZHeap::relocate_object(uintptr_t addr) {
+  assert(ZGlobalPhase == ZPhaseRelocate, "Relocate not allowed");
+
+  ZForwarding* const forwarding = _forwarding_table.get(addr);
+  if (forwarding == NULL) {
+    // Not forwarding
+    return ZAddress::good(addr);
+  }
+
+  // Relocate object
+  const bool retained = forwarding->inc_refcount();
+  const uintptr_t new_addr = _relocate.relocate_object(forwarding, addr);
+  if (retained && forwarding->dec_refcount()) {
+    ZPage* const page = _pagetable.get(addr);
+    free_page(page, true /* reclaimed */);
+  }
+
+  return new_addr;
+}
+
+inline uintptr_t ZHeap::remap_object(uintptr_t addr) {
+  assert(ZGlobalPhase == ZPhaseMark ||
+         ZGlobalPhase == ZPhaseMarkCompleted, "Forward not allowed");
+
+  ZForwarding* const forwarding = _forwarding_table.get(addr);
+  if (forwarding == NULL) {
+    // Not forwarding
+    return ZAddress::good(addr);
+  }
+
+  // Forward object
+  return _relocate.forward_object(forwarding, addr);
+}
+
 inline bool ZHeap::is_alloc_stalled() const {
   return _page_allocator.is_alloc_stalled();
 }