< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot.code;
  26 
  27 import java.util.*;
  28 import sun.jvm.hotspot.debugger.*;
  29 import sun.jvm.hotspot.memory.*;
  30 import sun.jvm.hotspot.runtime.*;
  31 import sun.jvm.hotspot.types.*;
  32 import sun.jvm.hotspot.utilities.*;
  33 
  34 public class CodeCache {
  35   private static GrowableArray<CodeHeap> heapArray;
  36   private static AddressField scavengeRootNMethodsField;
  37   private static VirtualConstructor virtualConstructor;
  38 
  39   static {
  40     VM.registerVMInitializedObserver(new Observer() {
  41         public void update(Observable o, Object data) {
  42           initialize(VM.getVM().getTypeDataBase());
  43         }
  44       });
  45   }
  46 
  47   private static synchronized void initialize(TypeDataBase db) {
  48     Type type = db.lookupType("CodeCache");
  49 
  50     // Get array of CodeHeaps
  51     // Note: CodeHeap may be subclassed with optional private heap mechanisms.
  52     Type codeHeapType = db.lookupType("CodeHeap");
  53     VirtualBaseConstructor heapConstructor =
  54         new VirtualBaseConstructor(db, codeHeapType, "sun.jvm.hotspot.memory", CodeHeap.class);
  55 
  56     AddressField heapsField = type.getAddressField("_heaps");
  57     heapArray = GrowableArray.create(heapsField.getValue(), heapConstructor);
  58 
  59     scavengeRootNMethodsField = type.getAddressField("_scavenge_root_nmethods");
  60 
  61     virtualConstructor = new VirtualConstructor(db);
  62     // Add mappings for all possible CodeBlob subclasses
  63     virtualConstructor.addMapping("BufferBlob", BufferBlob.class);
  64     virtualConstructor.addMapping("nmethod", NMethod.class);
  65     virtualConstructor.addMapping("RuntimeStub", RuntimeStub.class);
  66     virtualConstructor.addMapping("AdapterBlob", AdapterBlob.class);
  67     virtualConstructor.addMapping("MethodHandlesAdapterBlob", MethodHandlesAdapterBlob.class);
  68     virtualConstructor.addMapping("SafepointBlob", SafepointBlob.class);
  69     virtualConstructor.addMapping("DeoptimizationBlob", DeoptimizationBlob.class);
  70     if (VM.getVM().isServerCompiler()) {
  71       virtualConstructor.addMapping("ExceptionBlob", ExceptionBlob.class);
  72       virtualConstructor.addMapping("UncommonTrapBlob", UncommonTrapBlob.class);
  73     }
  74   }
  75 
  76   public NMethod scavengeRootMethods() {
  77     return (NMethod) VMObjectFactory.newObject(NMethod.class, scavengeRootNMethodsField.getValue());
  78   }
  79 
  80   public boolean contains(Address p) {
  81     for (int i = 0; i < heapArray.length(); ++i) {
  82       if (heapArray.at(i).contains(p)) {
  83         return true;
  84       }
  85     }
  86     return false;
  87   }
  88 
  89   /** When VM.getVM().isDebugging() returns true, this behaves like
  90       findBlobUnsafe */
  91   public CodeBlob findBlob(Address start) {
  92     CodeBlob result = findBlobUnsafe(start);
  93     if (result == null) return null;
  94     if (VM.getVM().isDebugging()) {
  95       return result;
  96     }
  97     // We could potientially look up non_entrant methods


   1 /*
   2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot.code;
  26 
  27 import java.util.*;
  28 import sun.jvm.hotspot.debugger.*;
  29 import sun.jvm.hotspot.memory.*;
  30 import sun.jvm.hotspot.runtime.*;
  31 import sun.jvm.hotspot.types.*;
  32 import sun.jvm.hotspot.utilities.*;
  33 
  34 public class CodeCache {
  35   private static GrowableArray<CodeHeap> heapArray;

  36   private static VirtualConstructor virtualConstructor;
  37 
  38   static {
  39     VM.registerVMInitializedObserver(new Observer() {
  40         public void update(Observable o, Object data) {
  41           initialize(VM.getVM().getTypeDataBase());
  42         }
  43       });
  44   }
  45 
  46   private static synchronized void initialize(TypeDataBase db) {
  47     Type type = db.lookupType("CodeCache");
  48 
  49     // Get array of CodeHeaps
  50     // Note: CodeHeap may be subclassed with optional private heap mechanisms.
  51     Type codeHeapType = db.lookupType("CodeHeap");
  52     VirtualBaseConstructor heapConstructor =
  53         new VirtualBaseConstructor(db, codeHeapType, "sun.jvm.hotspot.memory", CodeHeap.class);
  54 
  55     AddressField heapsField = type.getAddressField("_heaps");
  56     heapArray = GrowableArray.create(heapsField.getValue(), heapConstructor);
  57 


  58     virtualConstructor = new VirtualConstructor(db);
  59     // Add mappings for all possible CodeBlob subclasses
  60     virtualConstructor.addMapping("BufferBlob", BufferBlob.class);
  61     virtualConstructor.addMapping("nmethod", NMethod.class);
  62     virtualConstructor.addMapping("RuntimeStub", RuntimeStub.class);
  63     virtualConstructor.addMapping("AdapterBlob", AdapterBlob.class);
  64     virtualConstructor.addMapping("MethodHandlesAdapterBlob", MethodHandlesAdapterBlob.class);
  65     virtualConstructor.addMapping("SafepointBlob", SafepointBlob.class);
  66     virtualConstructor.addMapping("DeoptimizationBlob", DeoptimizationBlob.class);
  67     if (VM.getVM().isServerCompiler()) {
  68       virtualConstructor.addMapping("ExceptionBlob", ExceptionBlob.class);
  69       virtualConstructor.addMapping("UncommonTrapBlob", UncommonTrapBlob.class);
  70     }




  71   }
  72 
  73   public boolean contains(Address p) {
  74     for (int i = 0; i < heapArray.length(); ++i) {
  75       if (heapArray.at(i).contains(p)) {
  76         return true;
  77       }
  78     }
  79     return false;
  80   }
  81 
  82   /** When VM.getVM().isDebugging() returns true, this behaves like
  83       findBlobUnsafe */
  84   public CodeBlob findBlob(Address start) {
  85     CodeBlob result = findBlobUnsafe(start);
  86     if (result == null) return null;
  87     if (VM.getVM().isDebugging()) {
  88       return result;
  89     }
  90     // We could potientially look up non_entrant methods


< prev index next >