< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZBarrier.java

Print this page
rev 48259 : SA for GC - patch 2

@@ -24,22 +24,37 @@
 
 package sun.jvm.hotspot.gc.z;
 
 import sun.jvm.hotspot.debugger.Address;
 import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.types.TypeDataBase;
+import sun.jvm.hotspot.types.WrongTypeException;
 
 class ZBarrier {
+
+    private static int ZGlobalPhase;
+    private static int ZPhaseRelocate;
+
+    static {
+        VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase()));
+    }
+
+    private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+        ZGlobalPhase = db.lookupIntConstant("ZGlobalPhase").intValue();
+        ZPhaseRelocate = db.lookupIntConstant("ZPhaseRelocate").intValue();
+    }
+
     private static boolean is_weak_good_or_null_fast_path(Address addr) {
         return ZAddress.is_weak_good_or_null(addr);
     }
 
     private static Address weak_load_barrier_on_oop_slow_path(Address addr) {
         return ZAddress.is_weak_good(addr) ? ZAddress.good(addr) : relocate_or_remap(addr);
     }
 
     private static boolean during_relocate() {
-        return ZGlobals.ZGlobalPhase() == ZGlobals.ZPhaseRelocate;
+        return ZGlobalPhase == ZPhaseRelocate;
     }
 
     private static Address relocate(Address addr) {
         ZHeap heap = zheap();
         if (heap.is_relocating(addr)) {
< prev index next >