src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/cms/AdaptiveFreeList.java
branchaefimov-dns-client-branch
changeset 59099 fcdb8e7ead8f
parent 58984 15e026239a6c
parent 59075 355f4f42dda5
child 59100 b92aac38b046
equal deleted inserted replaced
58984:15e026239a6c 59099:fcdb8e7ead8f
     1 /*
       
     2  * @(#)AdaptiveFreeList.java
       
     3  *
       
     4  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
       
     5  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     6  *
       
     7  * This code is free software; you can redistribute it and/or modify it
       
     8  * under the terms of the GNU General Public License version 2 only, as
       
     9  * published by the Free Software Foundation.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  *
       
    25  */
       
    26 
       
    27 package sun.jvm.hotspot.gc.cms;
       
    28 
       
    29 import java.util.Observable;
       
    30 import java.util.Observer;
       
    31 
       
    32 import sun.jvm.hotspot.debugger.Address;
       
    33 import sun.jvm.hotspot.runtime.VM;
       
    34 import sun.jvm.hotspot.runtime.VMObject;
       
    35 import sun.jvm.hotspot.types.CIntegerField;
       
    36 import sun.jvm.hotspot.types.Type;
       
    37 import sun.jvm.hotspot.types.TypeDataBase;
       
    38 
       
    39 public class AdaptiveFreeList extends VMObject {
       
    40   static {
       
    41     VM.registerVMInitializedObserver(new Observer() {
       
    42       public void update(Observable o, Object data) {
       
    43         initialize(VM.getVM().getTypeDataBase());
       
    44       }
       
    45     });
       
    46   }
       
    47 
       
    48   private static synchronized void initialize(TypeDataBase db) {
       
    49     Type type = db.lookupType("AdaptiveFreeList<FreeChunk>");
       
    50     sizeField = type.getCIntegerField("_size");
       
    51     countField = type.getCIntegerField("_count");
       
    52     headerSize = type.getSize();
       
    53   }
       
    54 
       
    55   // Fields
       
    56   private static CIntegerField sizeField;
       
    57   private static CIntegerField countField;
       
    58   private static long          headerSize;
       
    59 
       
    60   //Constructor
       
    61   public AdaptiveFreeList(Address address) {
       
    62     super(address);
       
    63   }
       
    64 
       
    65   // Accessors
       
    66   public long size() {
       
    67     return sizeField.getValue(addr);
       
    68   }
       
    69 
       
    70   public long count() {
       
    71     return  countField.getValue(addr);
       
    72   }
       
    73 
       
    74   public static long sizeOf() {
       
    75     return headerSize;
       
    76   }
       
    77 }