< prev index next >
agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -33,11 +33,12 @@
import sun.jvm.hotspot.types.*;
import sun.jvm.hotspot.utilities.*;
public class GenCollectedHeap extends SharedHeap {
private static CIntegerField nGensField;
- private static long gensOffset;
+ private static AddressField youngGenField;
+ private static AddressField oldGenField;
private static AddressField genSpecsField;
private static GenerationFactory genFactory;
static {
@@ -50,11 +51,12 @@
private static synchronized void initialize(TypeDataBase db) {
Type type = db.lookupType("GenCollectedHeap");
nGensField = type.getCIntegerField("_n_gens");
- gensOffset = type.getField("_gens").getOffset();
+ youngGenField = type.getAddressField("_young_gen");
+ oldGenField = type.getAddressField("_old_gen");
genSpecsField = type.getAddressField("_gen_specs");
genFactory = new GenerationFactory();
}
@@ -66,22 +68,23 @@
return (int) nGensField.getValue(addr);
}
public Generation getGen(int i) {
if (Assert.ASSERTS_ENABLED) {
- Assert.that((i >= 0) && (i < nGens()), "Index " + i +
- " out of range (should be between 0 and " + nGens() + ")");
+ Assert.that((i == 0) || (i == 1), "Index " + i +
+ " out of range (should be 0 or 1)");
}
- if ((i < 0) || (i >= nGens())) {
+ switch (i) {
+ case 0:
+ return genFactory.newObject(youngGenField.getAddress());
+ case 1:
+ return genFactory.newObject(oldGenField.getAddress());
+ default:
+ // no generation for i, and assertions disabled.
return null;
}
-
- Address genAddr = addr.getAddressAt(gensOffset +
- (i * VM.getVM().getAddressSize()));
- return genFactory.newObject(addr.getAddressAt(gensOffset +
- (i * VM.getVM().getAddressSize())));
}
public boolean isIn(Address a) {
for (int i = 0; i < nGens(); i++) {
Generation gen = getGen(i);
< prev index next >