< prev index next >

src/share/vm/gc_implementation/shenandoah/shenandoahSharedVariables.hpp

Print this page
rev 10690 : [backport] Cleanup header files and forward declarations
rev 10715 : [backport] Cleanup up superfluous newlines
rev 10772 : [backport] Update copyrights
   1 /*
   2  * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHSHAREDFLAG_HPP
  25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHSHAREDFLAG_HPP
  26 
  27 #include "memory/allocation.hpp"

  28 
  29 typedef jbyte ShenandoahSharedValue;
  30 
  31 typedef struct ShenandoahSharedFlag {
  32   enum {
  33     UNSET = 0,
  34     SET = 1,
  35   };
  36 
  37   char _pad_0[128];
  38   volatile ShenandoahSharedValue value;
  39   char _pad_1[128];
  40 
  41   ShenandoahSharedFlag() {
  42     // Needed for cooperation with generated code.
  43     STATIC_ASSERT(sizeof(ShenandoahSharedValue) == 1);
  44 
  45     unset();
  46   }
  47 


 180 
 181   ShenandoahSharedValue raw_value() {
 182     return value;
 183   }
 184 
 185 private:
 186   volatile ShenandoahSharedValue* operator&() {
 187     fatal("Use addr_of() instead");
 188     return NULL;
 189   }
 190 
 191   bool operator==(ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 192   bool operator!=(ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 193   bool operator> (ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 194   bool operator>=(ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 195   bool operator< (ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 196   bool operator<=(ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 197 
 198 } ShenandoahSharedBitmap;
 199 
 200 
 201 template<class T>
 202 struct ShenandoahSharedEnumFlag {
 203   char _pad_0[128];
 204   volatile ShenandoahSharedValue value;
 205   char _pad_1[128];
 206 
 207   ShenandoahSharedEnumFlag() {
 208     value = 0;
 209   }
 210 
 211   void set(T v) {
 212     assert (v >= 0, "sanity");
 213     assert (v < (sizeof(ShenandoahSharedValue) * CHAR_MAX), "sanity");
 214     OrderAccess::release_store_fence(&value, (ShenandoahSharedValue)v);
 215   }
 216 
 217   T get() const {
 218     return (T)OrderAccess::load_acquire((volatile ShenandoahSharedValue*) &value);
 219   }
 220 


 225   }
 226 
 227   volatile ShenandoahSharedValue* addr_of() {
 228     return &value;
 229   }
 230 
 231 private:
 232   volatile T* operator&() {
 233     fatal("Use addr_of() instead");
 234     return NULL;
 235   }
 236 
 237   bool operator==(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 238   bool operator!=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 239   bool operator> (ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 240   bool operator>=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 241   bool operator< (ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 242   bool operator<=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 243 
 244 };
 245 
 246 
 247 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHSHAREDFLAG_HPP
   1 /*
   2  * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHSHAREDFLAG_HPP
  25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHSHAREDFLAG_HPP
  26 
  27 #include "memory/allocation.hpp"
  28 #include "runtime/orderAccess.hpp"
  29 
  30 typedef jbyte ShenandoahSharedValue;
  31 
  32 typedef struct ShenandoahSharedFlag {
  33   enum {
  34     UNSET = 0,
  35     SET = 1,
  36   };
  37 
  38   char _pad_0[128];
  39   volatile ShenandoahSharedValue value;
  40   char _pad_1[128];
  41 
  42   ShenandoahSharedFlag() {
  43     // Needed for cooperation with generated code.
  44     STATIC_ASSERT(sizeof(ShenandoahSharedValue) == 1);
  45 
  46     unset();
  47   }
  48 


 181 
 182   ShenandoahSharedValue raw_value() {
 183     return value;
 184   }
 185 
 186 private:
 187   volatile ShenandoahSharedValue* operator&() {
 188     fatal("Use addr_of() instead");
 189     return NULL;
 190   }
 191 
 192   bool operator==(ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 193   bool operator!=(ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 194   bool operator> (ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 195   bool operator>=(ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 196   bool operator< (ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 197   bool operator<=(ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
 198 
 199 } ShenandoahSharedBitmap;
 200 

 201 template<class T>
 202 struct ShenandoahSharedEnumFlag {
 203   char _pad_0[128];
 204   volatile ShenandoahSharedValue value;
 205   char _pad_1[128];
 206 
 207   ShenandoahSharedEnumFlag() {
 208     value = 0;
 209   }
 210 
 211   void set(T v) {
 212     assert (v >= 0, "sanity");
 213     assert (v < (sizeof(ShenandoahSharedValue) * CHAR_MAX), "sanity");
 214     OrderAccess::release_store_fence(&value, (ShenandoahSharedValue)v);
 215   }
 216 
 217   T get() const {
 218     return (T)OrderAccess::load_acquire((volatile ShenandoahSharedValue*) &value);
 219   }
 220 


 225   }
 226 
 227   volatile ShenandoahSharedValue* addr_of() {
 228     return &value;
 229   }
 230 
 231 private:
 232   volatile T* operator&() {
 233     fatal("Use addr_of() instead");
 234     return NULL;
 235   }
 236 
 237   bool operator==(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 238   bool operator!=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 239   bool operator> (ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 240   bool operator>=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 241   bool operator< (ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 242   bool operator<=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 243 
 244 };

 245 
 246 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHSHAREDFLAG_HPP
< prev index next >