changeset 54973:6fb43030a1b4

8214363: HeapWord should not be a fake class Summary: Change HeapWord and MetaWord to be pointers to incomplete types. Reviewed-by: tschatzl, mikael, coleenp, pliden
author kbarrett
date Mon, 18 Feb 2019 16:34:46 -0500
parents bec6c8739833
children f12e86f1b0d6
files src/hotspot/share/gc/shared/genOopClosures.hpp src/hotspot/share/gc/shared/spaceDecorator.cpp src/hotspot/share/gc/shared/vmStructs_gc.hpp src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.hpp src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp src/hotspot/share/memory/memRegion.hpp src/hotspot/share/memory/metaspace.hpp src/hotspot/share/utilities/globalDefinitions.hpp
diffstat 8 files changed, 13 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/shared/genOopClosures.hpp	Mon Feb 18 09:31:07 2019 -0800
+++ b/src/hotspot/share/gc/shared/genOopClosures.hpp	Mon Feb 18 16:34:46 2019 -0500
@@ -29,7 +29,6 @@
 #include "oops/oop.hpp"
 
 class Generation;
-class HeapWord;
 class CardTableRS;
 class CardTableBarrierSet;
 class DefNewGeneration;
--- a/src/hotspot/share/gc/shared/spaceDecorator.cpp	Mon Feb 18 09:31:07 2019 -0800
+++ b/src/hotspot/share/gc/shared/spaceDecorator.cpp	Mon Feb 18 16:34:46 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -36,7 +36,7 @@
 // pattern.
 bool SpaceMangler::is_mangled(HeapWord* q) {
   // This test loses precision but is good enough
-  return badHeapWord == (max_juint & (uintptr_t) q->value());
+  return badHeapWord == (max_juint & reinterpret_cast<uintptr_t>(*q));
 }
 
 
--- a/src/hotspot/share/gc/shared/vmStructs_gc.hpp	Mon Feb 18 09:31:07 2019 -0800
+++ b/src/hotspot/share/gc/shared/vmStructs_gc.hpp	Mon Feb 18 16:34:46 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -156,8 +156,6 @@
   nonstatic_field(GenCollectedHeap,            _young_gen_spec,                               GenerationSpec*)                       \
   nonstatic_field(GenCollectedHeap,            _old_gen_spec,                                 GenerationSpec*)                       \
                                                                                                                                      \
-  nonstatic_field(HeapWord,                    i,                                             char*)                                 \
-                                                                                                                                     \
   nonstatic_field(MemRegion,                   _start,                                        HeapWord*)                             \
   nonstatic_field(MemRegion,                   _word_size,                                    size_t)                                \
                                                                                                                                      \
--- a/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.hpp	Mon Feb 18 09:31:07 2019 -0800
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.hpp	Mon Feb 18 16:34:46 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
@@ -29,8 +29,6 @@
 #include "memory/memRegion.hpp"
 #include "oops/oopsHierarchy.hpp"
 
-class HeapWord;
-
 /**
  * Encapsulate a marking bitmap with the top-at-mark-start and top-bitmaps array.
  */
--- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp	Mon Feb 18 09:31:07 2019 -0800
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp	Mon Feb 18 16:34:46 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
@@ -27,7 +27,6 @@
 #include "memory/allocation.hpp"
 #include "oops/oopsHierarchy.hpp"
 
-class HeapWord;
 class JavaThread;
 class oopDesc;
 
--- a/src/hotspot/share/memory/memRegion.hpp	Mon Feb 18 09:31:07 2019 -0800
+++ b/src/hotspot/share/memory/memRegion.hpp	Mon Feb 18 16:34:46 2019 -0500
@@ -40,8 +40,6 @@
 // create MemRegions (in CardTableBarrierSet) in heap so operator
 // new and operator new [] added for this special case.
 
-class MetaWord;
-
 class MemRegion {
   friend class VMStructs;
 private:
--- a/src/hotspot/share/memory/metaspace.hpp	Mon Feb 18 09:31:07 2019 -0800
+++ b/src/hotspot/share/memory/metaspace.hpp	Mon Feb 18 16:34:46 2019 -0500
@@ -57,7 +57,6 @@
 
 class ClassLoaderData;
 class MetaspaceTracer;
-class MetaWord;
 class Mutex;
 class outputStream;
 
--- a/src/hotspot/share/utilities/globalDefinitions.hpp	Mon Feb 18 09:31:07 2019 -0800
+++ b/src/hotspot/share/utilities/globalDefinitions.hpp	Mon Feb 18 16:34:46 2019 -0500
@@ -165,29 +165,18 @@
 // Size of a char[] needed to represent a jint as a string in decimal.
 const int jintAsStringSize = 12;
 
-// An opaque struct of heap-word width, so that HeapWord* can be a generic
-// pointer into the heap.  We require that object sizes be measured in
-// units of heap words, so that that
-//   HeapWord* hw;
+// An opaque type, so that HeapWord* can be a generic pointer into the heap.
+// We require that object sizes be measured in units of heap words (e.g.
+// pointer-sized values), so that given HeapWord* hw,
 //   hw += oop(hw)->foo();
 // works, where foo is a method (like size or scavenge) that returns the
 // object size.
-class HeapWord {
-  friend class VMStructs;
- private:
-  char* i;
-#ifndef PRODUCT
- public:
-  char* value() { return i; }
-#endif
-};
+class HeapWordImpl;             // Opaque, never defined.
+typedef HeapWordImpl* HeapWord;
 
-// Analogous opaque struct for metadata allocated from
-// metaspaces.
-class MetaWord {
- private:
-  char* i;
-};
+// Analogous opaque struct for metadata allocated from metaspaces.
+class MetaWordImpl;             // Opaque, never defined.
+typedef MetaWordImpl* MetaWord;
 
 // HeapWordSize must be 2^LogHeapWordSize.
 const int HeapWordSize        = sizeof(HeapWord);