src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java
changeset 54122 4b1426ed1c44
parent 47216 71c04702a3d5
equal deleted inserted replaced
54121:fce463e39f72 54122:4b1426ed1c44
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
     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.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    31 import sun.jvm.hotspot.types.*;
    31 import sun.jvm.hotspot.types.*;
    32 import sun.jvm.hotspot.utilities.*;
    32 import sun.jvm.hotspot.utilities.*;
    33 
    33 
    34 public class CodeCache {
    34 public class CodeCache {
    35   private static GrowableArray<CodeHeap> heapArray;
    35   private static GrowableArray<CodeHeap> heapArray;
    36   private static AddressField scavengeRootNMethodsField;
       
    37   private static VirtualConstructor virtualConstructor;
    36   private static VirtualConstructor virtualConstructor;
    38 
    37 
    39   static {
    38   static {
    40     VM.registerVMInitializedObserver(new Observer() {
    39     VM.registerVMInitializedObserver(new Observer() {
    41         public void update(Observable o, Object data) {
    40         public void update(Observable o, Object data) {
    53     VirtualBaseConstructor heapConstructor =
    52     VirtualBaseConstructor heapConstructor =
    54         new VirtualBaseConstructor(db, codeHeapType, "sun.jvm.hotspot.memory", CodeHeap.class);
    53         new VirtualBaseConstructor(db, codeHeapType, "sun.jvm.hotspot.memory", CodeHeap.class);
    55 
    54 
    56     AddressField heapsField = type.getAddressField("_heaps");
    55     AddressField heapsField = type.getAddressField("_heaps");
    57     heapArray = GrowableArray.create(heapsField.getValue(), heapConstructor);
    56     heapArray = GrowableArray.create(heapsField.getValue(), heapConstructor);
    58 
       
    59     scavengeRootNMethodsField = type.getAddressField("_scavenge_root_nmethods");
       
    60 
    57 
    61     virtualConstructor = new VirtualConstructor(db);
    58     virtualConstructor = new VirtualConstructor(db);
    62     // Add mappings for all possible CodeBlob subclasses
    59     // Add mappings for all possible CodeBlob subclasses
    63     virtualConstructor.addMapping("BufferBlob", BufferBlob.class);
    60     virtualConstructor.addMapping("BufferBlob", BufferBlob.class);
    64     virtualConstructor.addMapping("nmethod", NMethod.class);
    61     virtualConstructor.addMapping("nmethod", NMethod.class);
    71       virtualConstructor.addMapping("ExceptionBlob", ExceptionBlob.class);
    68       virtualConstructor.addMapping("ExceptionBlob", ExceptionBlob.class);
    72       virtualConstructor.addMapping("UncommonTrapBlob", UncommonTrapBlob.class);
    69       virtualConstructor.addMapping("UncommonTrapBlob", UncommonTrapBlob.class);
    73     }
    70     }
    74   }
    71   }
    75 
    72 
    76   public NMethod scavengeRootMethods() {
       
    77     return (NMethod) VMObjectFactory.newObject(NMethod.class, scavengeRootNMethodsField.getValue());
       
    78   }
       
    79 
       
    80   public boolean contains(Address p) {
    73   public boolean contains(Address p) {
    81     for (int i = 0; i < heapArray.length(); ++i) {
    74     for (int i = 0; i < heapArray.length(); ++i) {
    82       if (heapArray.at(i).contains(p)) {
    75       if (heapArray.at(i).contains(p)) {
    83         return true;
    76         return true;
    84       }
    77       }