src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/cms/AdaptiveFreeList.java
author stefank
Tue, 19 Feb 2019 10:03:41 +0100
changeset 53814 eff915f3d3f2
parent 47216 71c04702a3d5
permissions -rw-r--r--
8219003: SA: Refactor live regions iteration in preparation for JDK-8218922 Reviewed-by: eosterlund, ysuenaga
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
     1
/*
22886
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
     2
 * @(#)AdaptiveFreeList.java
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
     3
 *
30769
df60209aac9d 8080581: Align SA with new GC directory structure
pliden
parents: 22886
diff changeset
     4
 * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
     5
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
     6
 *
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
     7
 * This code is free software; you can redistribute it and/or modify it
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
     8
 * under the terms of the GNU General Public License version 2 only, as
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
     9
 * published by the Free Software Foundation.
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    10
 *
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    15
 * accompanied this code).
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    16
 *
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    20
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    23
 * questions.
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    24
 *
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    25
 */
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    26
30769
df60209aac9d 8080581: Align SA with new GC directory structure
pliden
parents: 22886
diff changeset
    27
package sun.jvm.hotspot.gc.cms;
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    28
22886
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    29
import java.util.Observable;
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    30
import java.util.Observer;
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    31
22886
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    32
import sun.jvm.hotspot.debugger.Address;
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    33
import sun.jvm.hotspot.runtime.VM;
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    34
import sun.jvm.hotspot.runtime.VMObject;
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    35
import sun.jvm.hotspot.types.CIntegerField;
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    36
import sun.jvm.hotspot.types.Type;
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    37
import sun.jvm.hotspot.types.TypeDataBase;
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    38
22886
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    39
public class AdaptiveFreeList extends VMObject {
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    40
  static {
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    41
    VM.registerVMInitializedObserver(new Observer() {
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    42
      public void update(Observable o, Object data) {
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    43
        initialize(VM.getVM().getTypeDataBase());
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    44
      }
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    45
    });
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    46
  }
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    47
22886
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    48
  private static synchronized void initialize(TypeDataBase db) {
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    49
    Type type = db.lookupType("AdaptiveFreeList<FreeChunk>");
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    50
    sizeField = type.getCIntegerField("_size");
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    51
    countField = type.getCIntegerField("_count");
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    52
    headerSize = type.getSize();
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    53
  }
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    54
22886
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    55
  // Fields
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    56
  private static CIntegerField sizeField;
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    57
  private static CIntegerField countField;
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    58
  private static long          headerSize;
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    59
22886
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    60
  //Constructor
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    61
  public AdaptiveFreeList(Address address) {
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    62
    super(address);
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    63
  }
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    64
22886
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    65
  // Accessors
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    66
  public long size() {
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    67
    return sizeField.getValue(addr);
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    68
  }
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    69
22886
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    70
  public long count() {
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    71
    return  countField.getValue(addr);
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    72
  }
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    73
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    74
  public static long sizeOf() {
e8b17e1f03ac 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
sjohanss
parents: 15431
diff changeset
    75
    return headerSize;
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    76
  }
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
diff changeset
    77
}