This commit is contained in:
Alejandro Murillo 2012-09-21 14:02:57 -07:00
commit 6f3e1a0593
872 changed files with 27045 additions and 83561 deletions

View File

@ -276,4 +276,5 @@ e8fb566b94667f88462164defa654203f0ab6820 jdk8-b54
09ea7e0752b306b8ae74713aeb4eb6263e1c6836 hs24-b22 09ea7e0752b306b8ae74713aeb4eb6263e1c6836 hs24-b22
af0c8a0808516317333dcf9af15567cdd52761ce jdk8-b55 af0c8a0808516317333dcf9af15567cdd52761ce jdk8-b55
6124ff4218296c91e4a72f1a76c064892d39d61b jdk8-b56 6124ff4218296c91e4a72f1a76c064892d39d61b jdk8-b56
9b076bc3ab67d42d1d02144ef8dcd6006a7fc0d6 hs25-b01
d70102c4cb73158902acaa6016f47c7bc14e0d67 jdk8-b57 d70102c4cb73158902acaa6016f47c7bc14e0d67 jdk8-b57

View File

@ -38,10 +38,10 @@ Available commands:
assert true | false <font color="red">turn on/off asserts in SA code</font> assert true | false <font color="red">turn on/off asserts in SA code</font>
attach pid | exec core <font color="red">attach SA to a process or core</font> attach pid | exec core <font color="red">attach SA to a process or core</font>
class name <font color="red">find a Java class from debuggee and print oop</font> class name <font color="red">find a Java class from debuggee and print oop</font>
classes <font color="red">print all loaded Java classes with klassOop</font> classes <font color="red">print all loaded Java classes with Klass*</font>
detach <font color="red">detach SA from current target</font> detach <font color="red">detach SA from current target</font>
dis address [ length ] <font color="red">disassemble (sparc/x86) specified number of instructions from given address</font> dis address [ length ] <font color="red">disassemble (sparc/x86) specified number of instructions from given address</font>
dumpclass { address | name } [ directory ] <font color="red">dump .class file for given klassOop or class name</font> dumpclass { address | name } [ directory ] <font color="red">dump .class file for given Klass* or class name</font>
dumpheap [ file ] <font color="red">dump heap in hprof binary format</font> dumpheap [ file ] <font color="red">dump heap in hprof binary format</font>
echo [ true | false ] <font color="red">turn on/off command echo mode</font> echo [ true | false ] <font color="red">turn on/off command echo mode</font>
examine [ address/count ] | [ address,address] <font color="red">show contents of memory from given address</font> examine [ address/count ] | [ address,address] <font color="red">show contents of memory from given address</font>
@ -51,7 +51,7 @@ Available commands:
help [ command ] <font color="red">print help message for all commands or just given command</font> help [ command ] <font color="red">print help message for all commands or just given command</font>
history <font color="red">show command history. usual !command-number syntax works.</font> history <font color="red">show command history. usual !command-number syntax works.</font>
inspect expression <font color="red">inspect a given oop</font> inspect expression <font color="red">inspect a given oop</font>
jdis address <font color="red">show bytecode disassembly of a given methodOop</font> jdis address <font color="red">show bytecode disassembly of a given Method*</font>
jhisto <font color="red">show Java heap histogram</font> jhisto <font color="red">show Java heap histogram</font>
jseval script <font color="red">evaluate a given string as JavaScript code</font> jseval script <font color="red">evaluate a given string as JavaScript code</font>
jsload file <font color="red">load and evaluate a JavaScript file</font> jsload file <font color="red">load and evaluate a JavaScript file</font>
@ -59,7 +59,7 @@ Available commands:
livenmethods <font color="red">show all live nmethods</font> livenmethods <font color="red">show all live nmethods</font>
mem address [ length ] <font color="red">show contents of memory -- also shows closest ELF/COFF symbol if found</font> mem address [ length ] <font color="red">show contents of memory -- also shows closest ELF/COFF symbol if found</font>
pmap <font color="red">show Solaris pmap-like output</font> pmap <font color="red">show Solaris pmap-like output</font>
print expression <font color="red">print given klassOop, methodOop or arbitrary address</font> print expression <font color="red">print given Klass*, Method* or arbitrary address</font>
printas type expression <font color="red">print given address as given HotSpot type. eg. print JavaThread &lt;address&gt;</font> printas type expression <font color="red">print given address as given HotSpot type. eg. print JavaThread &lt;address&gt;</font>
printstatics [ type ] <font color="red">print static fields of given HotSpot type (or all types if none specified)</font> printstatics [ type ] <font color="red">print static fields of given HotSpot type (or all types if none specified)</font>
pstack [-v] <font color="red">show mixed mode stack trace for all Java, non-Java threads. -v is verbose mode</font> pstack [-v] <font color="red">show mixed mode stack trace for all Java, non-Java threads. -v is verbose mode</font>

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -210,7 +210,6 @@ static map_info* core_lookup(struct ps_prochandle *ph, uintptr_t addr)
// mapped. This structure gets written to a file. It is not a class, // mapped. This structure gets written to a file. It is not a class,
// so that the compilers don't add any compiler-private data to it. // so that the compilers don't add any compiler-private data to it.
// Refer to CompactingPermGenGen::n_regions in compactingPermGenGen.hpp
#define NUM_SHARED_MAPS 4 #define NUM_SHARED_MAPS 4
// Refer to FileMapInfo::_current_version in filemap.hpp // Refer to FileMapInfo::_current_version in filemap.hpp
@ -234,7 +233,7 @@ struct FileMapHeader {
char _read_only; // read only space? char _read_only; // read only space?
char _allow_exec; // executable code in space? char _allow_exec; // executable code in space?
} _space[NUM_SHARED_MAPS]; // was _space[CompactingPermGenGen::n_regions]; } _space[NUM_SHARED_MAPS];
// Ignore the rest of the FileMapHeader. We don't need those fields here. // Ignore the rest of the FileMapHeader. We don't need those fields here.
}; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -209,7 +209,6 @@ static map_info* core_lookup(struct ps_prochandle *ph, uintptr_t addr)
// mapped. This structure gets written to a file. It is not a class, // mapped. This structure gets written to a file. It is not a class,
// so that the compilers don't add any compiler-private data to it. // so that the compilers don't add any compiler-private data to it.
// Refer to CompactingPermGenGen::n_regions in compactingPermGenGen.hpp
#define NUM_SHARED_MAPS 4 #define NUM_SHARED_MAPS 4
// Refer to FileMapInfo::_current_version in filemap.hpp // Refer to FileMapInfo::_current_version in filemap.hpp
@ -233,7 +232,7 @@ struct FileMapHeader {
char _read_only; // read only space? char _read_only; // read only space?
char _allow_exec; // executable code in space? char _allow_exec; // executable code in space?
} _space[NUM_SHARED_MAPS]; // was _space[CompactingPermGenGen::n_regions]; } _space[NUM_SHARED_MAPS];
// Ignore the rest of the FileMapHeader. We don't need those fields here. // Ignore the rest of the FileMapHeader. We don't need those fields here.
}; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -510,7 +510,6 @@ wrapper_fill_cframe_list(void *cd, const prgregset_t regs, uint_t argc,
// mapped. This structure gets written to a file. It is not a class, so // mapped. This structure gets written to a file. It is not a class, so
// that the compilers don't add any compiler-private data to it. // that the compilers don't add any compiler-private data to it.
// Refer to CompactingPermGenGen::n_regions in compactingPermGenGen.hpp
const int NUM_SHARED_MAPS = 4; const int NUM_SHARED_MAPS = 4;
// Refer to FileMapInfo::_current_version in filemap.hpp // Refer to FileMapInfo::_current_version in filemap.hpp
@ -531,7 +530,7 @@ struct FileMapHeader {
bool _read_only; // read only space? bool _read_only; // read only space?
bool _allow_exec; // executable code in space? bool _allow_exec; // executable code in space?
} _space[NUM_SHARED_MAPS]; // was _space[CompactingPermGenGen::n_regions]; } _space[NUM_SHARED_MAPS];
// Ignore the rest of the FileMapHeader. We don't need those fields here. // Ignore the rest of the FileMapHeader. We don't need those fields here.
}; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -634,28 +634,56 @@ public class CommandProcessor {
} else { } else {
String s = t.nextToken(); String s = t.nextToken();
if (s.equals("-a")) { if (s.equals("-a")) {
HeapVisitor iterator = new DefaultHeapVisitor() { SystemDictionary sysDict = VM.getVM().getSystemDictionary();
public boolean doObj(Oop obj) { sysDict.allClassesDo(new SystemDictionary.ClassVisitor() {
if (obj instanceof MethodData) { public void visit(Klass k) {
Method m = ((MethodData)obj).getMethod(); if (k instanceof InstanceKlass) {
out.println("MethodData " + obj.getHandle() + " for " + MethodArray methods = ((InstanceKlass)k).getMethods();
for (int i = 0; i < methods.length(); i++) {
Method m = methods.at(i);
MethodData mdo = m.getMethodData();
if (mdo != null) {
out.println("MethodData " + mdo.getAddress() + " for " +
"method " + m.getMethodHolder().getName().asString() + "." + "method " + m.getMethodHolder().getName().asString() + "." +
m.getName().asString() + m.getName().asString() +
m.getSignature().asString() + "@" + m.getHandle()); m.getSignature().asString() + "@" + m.getAddress());
((MethodData)obj).printDataOn(out);
}
return false;
}
};
VM.getVM().getObjectHeap().iteratePerm(iterator);
} else {
Address a = VM.getVM().getDebugger().parseAddress(s);
OopHandle handle = a.addOffsetToAsOopHandle(0);
MethodData mdo = (MethodData)VM.getVM().getObjectHeap().newOop(handle);
mdo.printDataOn(out); mdo.printDataOn(out);
} }
} }
} }
}
}
);
} else {
Address a = VM.getVM().getDebugger().parseAddress(s);
MethodData mdo = (MethodData) Metadata.instantiateWrapperFor(a);
mdo.printDataOn(out);
}
}
}
},
new Command("printall", "printall", false) {
// Print every MDO in the heap or the one referenced by expression.
public void doit(Tokens t) {
if (t.countTokens() != 0) {
usage();
} else {
SystemDictionary sysDict = VM.getVM().getSystemDictionary();
sysDict.allClassesDo(new SystemDictionary.ClassVisitor() {
public void visit(Klass k) {
if (k instanceof InstanceKlass && ((InstanceKlass)k).getConstants().getCache() != null) {
MethodArray methods = ((InstanceKlass)k).getMethods();
for (int i = 0; i < methods.length(); i++) {
Method m = methods.at(i);
HTMLGenerator gen = new HTMLGenerator(false);
out.println(gen.genHTML(m));
}
}
}
}
);
}
}
}, },
new Command("dumpideal", "dumpideal { -a | id }", false) { new Command("dumpideal", "dumpideal { -a | id }", false) {
// Do a full dump of the nodes reachabile from root in each compiler thread. // Do a full dump of the nodes reachabile from root in each compiler thread.
@ -1229,7 +1257,7 @@ public class CommandProcessor {
} }
}; };
VM.getVM().getObjectHeap().iterateRaw(iterator); VM.getVM().getObjectHeap().iterateRaw(iterator);
} else if (type.equals("heap") || type.equals("perm")) { } else if (type.equals("heap")) {
HeapVisitor iterator = new DefaultHeapVisitor() { HeapVisitor iterator = new DefaultHeapVisitor() {
public boolean doObj(Oop obj) { public boolean doObj(Oop obj) {
int index = 0; int index = 0;
@ -1246,11 +1274,7 @@ public class CommandProcessor {
return false; return false;
} }
}; };
if (type.equals("heap")) {
VM.getVM().getObjectHeap().iterate(iterator); VM.getVM().getObjectHeap().iterate(iterator);
} else {
VM.getVM().getObjectHeap().iteratePerm(iterator);
}
} else if (type.equals("codecache")) { } else if (type.equals("codecache")) {
CodeCacheVisitor v = new CodeCacheVisitor() { CodeCacheVisitor v = new CodeCacheVisitor() {
public void prologue(Address start, Address end) { public void prologue(Address start, Address end) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -998,7 +998,7 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener {
curFrame.addressOfInterpreterFrameLocal((int) interpreterFrameMethod.getMaxLocals() + offset), curFrame.addressOfInterpreterFrameLocal((int) interpreterFrameMethod.getMaxLocals() + offset),
"Interpreter locals area for frame with SP = " + curFrame.getSP())); "Interpreter locals area for frame with SP = " + curFrame.getSP()));
} }
String methodAnno = "Interpreter frame methodOop"; String methodAnno = "Interpreter frame Method*";
if (interpreterFrameMethod == null) { if (interpreterFrameMethod == null) {
methodAnno += " (BAD OOP)"; methodAnno += " (BAD OOP)";
} }
@ -1054,13 +1054,6 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener {
} }
} }
if (bad) {
// Try perm gen
if (heap.permGen().isIn(handle)) {
anno = "PermGen ";
bad = false;
}
}
} else if (collHeap instanceof ParallelScavengeHeap) { } else if (collHeap instanceof ParallelScavengeHeap) {
ParallelScavengeHeap heap = (ParallelScavengeHeap) collHeap; ParallelScavengeHeap heap = (ParallelScavengeHeap) collHeap;
if (heap.youngGen().isIn(handle)) { if (heap.youngGen().isIn(handle)) {
@ -1069,9 +1062,6 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener {
} else if (heap.oldGen().isIn(handle)) { } else if (heap.oldGen().isIn(handle)) {
anno = "PSOldGen "; anno = "PSOldGen ";
bad = false; bad = false;
} else if (heap.permGen().isIn(handle)) {
anno = "PSPermGen ";
bad = false;
} }
} else { } else {
// Optimistically assume the oop isn't bad // Optimistically assume the oop isn't bad

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -50,6 +50,7 @@ public class HotSpotTypeDataBase extends BasicTypeDataBase {
private static final int C_INT8_SIZE = 1; private static final int C_INT8_SIZE = 1;
private static final int C_INT32_SIZE = 4; private static final int C_INT32_SIZE = 4;
private static final int C_INT64_SIZE = 8; private static final int C_INT64_SIZE = 8;
private static int pointerSize = UNINITIALIZED_SIZE;
private static final boolean DEBUG; private static final boolean DEBUG;
static { static {
@ -185,6 +186,9 @@ public class HotSpotTypeDataBase extends BasicTypeDataBase {
long size = entryAddr.getCIntegerAt(typeEntrySizeOffset, C_INT64_SIZE, true); long size = entryAddr.getCIntegerAt(typeEntrySizeOffset, C_INT64_SIZE, true);
createType(typeName, superclassName, isOopType, isIntegerType, isUnsigned, size); createType(typeName, superclassName, isOopType, isIntegerType, isUnsigned, size);
if (pointerSize == UNINITIALIZED_SIZE && typeName.equals("void*")) {
pointerSize = (int)size;
}
} }
entryAddr = entryAddr.addOffsetTo(typeEntryArrayStride); entryAddr = entryAddr.addOffsetTo(typeEntryArrayStride);
@ -678,7 +682,11 @@ public class HotSpotTypeDataBase extends BasicTypeDataBase {
} }
} }
result = new BasicPointerType(this, typeName, targetType); result = new BasicPointerType(this, typeName, targetType);
result.setSize(UNINITIALIZED_SIZE); if (pointerSize == UNINITIALIZED_SIZE && !typeName.equals("void*")) {
// void* must be declared early so that other pointer types can use that to set their size.
throw new InternalError("void* type hasn't been seen when parsing " + typeName);
}
result.setSize(pointerSize);
addType(result); addType(result);
return result; return result;
} }
@ -731,9 +739,11 @@ public class HotSpotTypeDataBase extends BasicTypeDataBase {
"had its size redefined (old was " + curType.getSize() + ", new is " + size + ")."); "had its size redefined (old was " + curType.getSize() + ", new is " + size + ").");
} }
if (!typeNameIsPointerType(typeName)) {
System.err.println("Warning: the type \"" + typeName + "\" (declared in the remote VM in VMStructs::localHotSpotVMTypes) " + System.err.println("Warning: the type \"" + typeName + "\" (declared in the remote VM in VMStructs::localHotSpotVMTypes) " +
"had its size declared as " + size + " twice. Continuing."); "had its size declared as " + size + " twice. Continuing.");
} }
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,14 +24,14 @@
package sun.jvm.hotspot.ci; package sun.jvm.hotspot.ci;
import java.io.PrintStream; import java.io.*;
import java.util.*; import java.util.*;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
public class ciArrayKlassKlass extends ciKlassKlass { public class ciBaseObject extends VMObject {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -41,11 +41,13 @@ public class ciArrayKlassKlass extends ciKlassKlass {
} }
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("ciArrayKlassKlass"); Type type = db.lookupType("ciBaseObject");
identField = new CIntField(type.getCIntegerField("_ident"), 0);
} }
private static CIntField identField;
public ciArrayKlassKlass(Address addr) { public ciBaseObject(Address addr) {
super(addr); super(addr);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,8 +47,8 @@ public class ciInstanceKlass extends ciKlass {
Type type = db.lookupType("ciInstanceKlass"); Type type = db.lookupType("ciInstanceKlass");
initStateField = new CIntField(type.getCIntegerField("_init_state"), 0); initStateField = new CIntField(type.getCIntegerField("_init_state"), 0);
isSharedField = new CIntField(type.getCIntegerField("_is_shared"), 0); isSharedField = new CIntField(type.getCIntegerField("_is_shared"), 0);
CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue(); CLASS_STATE_LINKED = db.lookupIntConstant("InstanceKlass::linked").intValue();
CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue(); CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("InstanceKlass::fully_initialized").intValue();
} }
private static CIntField initStateField; private static CIntField initStateField;
@ -63,7 +63,7 @@ public class ciInstanceKlass extends ciKlass {
public int initState() { public int initState() {
int initState = (int)initStateField.getValue(getAddress()); int initState = (int)initStateField.getValue(getAddress());
if (isShared() && initState < CLASS_STATE_LINKED) { if (isShared() && initState < CLASS_STATE_LINKED) {
InstanceKlass ik = (InstanceKlass)getOop(); InstanceKlass ik = (InstanceKlass)getMetadata();
initState = ik.getInitStateAsInt(); initState = ik.getInitStateAsInt();
} }
return initState; return initState;

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2011, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
package sun.jvm.hotspot.ci;
import java.io.PrintStream;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*;
public class ciKlassKlass extends ciKlass {
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("ciKlassKlass");
}
public ciKlassKlass(Address addr) {
super(addr);
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,13 +24,14 @@
package sun.jvm.hotspot.ci; package sun.jvm.hotspot.ci;
import java.io.*;
import java.util.*; import java.util.*;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
public class ciInstanceKlassKlass extends ciKlassKlass { public class ciMetadata extends ciBaseObject {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -40,11 +41,25 @@ public class ciInstanceKlassKlass extends ciKlassKlass {
} }
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("ciInstanceKlassKlass"); Type type = db.lookupType("ciMetadata");
metadataField = new MetadataField(type.getAddressField("_metadata"), 0);
} }
private static MetadataField metadataField;
public ciInstanceKlassKlass(Address addr) { public Metadata getMetadata() {
return metadataField.getValue(getAddress());
}
public ciMetadata(Address addr) {
super(addr); super(addr);
} }
public void printOn(PrintStream out) {
getMetadata().printValueOn(out);
}
public String toString() {
return getMetadata().toString();
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,7 +32,7 @@ import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
public class ciMethod extends ciObject { public class ciMethod extends ciMetadata {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -61,7 +61,7 @@ public class ciMethod extends ciObject {
} }
public Method method() { public Method method() {
return (Method)getOop(); return (Method)getMetadata();
} }
public int interpreterThrowoutCount() { public int interpreterThrowoutCount() {
@ -75,7 +75,7 @@ public class ciMethod extends ciObject {
public int instructionsSize() { public int instructionsSize() {
if (instructionsSizeField == null) { if (instructionsSizeField == null) {
// XXX // XXX
Method method = (Method)getOop(); Method method = method();
NMethod nm = method.getNativeMethod(); NMethod nm = method.getNativeMethod();
if (nm != null) return (int)nm.codeEnd().minus(nm.getVerifiedEntryPoint()); if (nm != null) return (int)nm.codeEnd().minus(nm.getVerifiedEntryPoint());
return 0; return 0;
@ -84,7 +84,7 @@ public class ciMethod extends ciObject {
} }
public void printShortName(PrintStream st) { public void printShortName(PrintStream st) {
Method method = (Method)getOop(); Method method = method();
st.printf(" %s::%s", method.getMethodHolder().getName().asString().replace('/', '.'), st.printf(" %s::%s", method.getMethodHolder().getName().asString().replace('/', '.'),
method.getName().asString()); method.getName().asString());
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
public class ciMethodData extends ciObject { public class ciMethodData extends ciMetadata {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -54,7 +54,7 @@ public class ciMethodData extends ciObject {
extraDataSizeField = new CIntField(type.getCIntegerField("_extra_data_size"), 0); extraDataSizeField = new CIntField(type.getCIntegerField("_extra_data_size"), 0);
dataSizeField = new CIntField(type.getCIntegerField("_data_size"), 0); dataSizeField = new CIntField(type.getCIntegerField("_data_size"), 0);
stateField = new CIntField(type.getCIntegerField("_state"), 0); stateField = new CIntField(type.getCIntegerField("_state"), 0);
sizeofMethodDataOopDesc = (int)db.lookupType("methodDataOopDesc").getSize();; sizeofMethodDataOopDesc = (int)db.lookupType("MethodData").getSize();;
} }
private static AddressField origField; private static AddressField origField;
@ -83,7 +83,7 @@ public class ciMethodData extends ciObject {
} }
public byte[] orig() { public byte[] orig() {
// fetch the orig methodDataOopDesc data between header and dataSize // fetch the orig MethodData data between header and dataSize
Address base = getAddress().addOffsetTo(origField.getOffset()); Address base = getAddress().addOffsetTo(origField.getOffset());
byte[] result = new byte[MethodData.sizeofMethodDataOopDesc]; byte[] result = new byte[MethodData.sizeofMethodDataOopDesc];
for (int i = 0; i < MethodData.sizeofMethodDataOopDesc; i++) { for (int i = 0; i < MethodData.sizeofMethodDataOopDesc; i++) {

View File

@ -1,50 +0,0 @@
/*
* Copyright (c) 2011, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
package sun.jvm.hotspot.ci;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*;
public class ciMethodKlass extends ciKlass {
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("ciMethodKlass");
}
public ciMethodKlass(Address addr) {
super(addr);
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
public class ciObject extends VMObject { public class ciObject extends ciBaseObject {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -42,12 +42,10 @@ public class ciObject extends VMObject {
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("ciObject"); Type type = db.lookupType("ciObject");
identField = new CIntField(type.getCIntegerField("_ident"), 0);
klassField = type.getAddressField("_klass"); klassField = type.getAddressField("_klass");
handleField = type.getAddressField("_handle"); handleField = type.getAddressField("_handle");
} }
private static CIntField identField;
private static AddressField klassField; private static AddressField klassField;
private static AddressField handleField; private static AddressField handleField;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -44,18 +44,20 @@ public class ciObjectFactory extends VMObject {
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("ciObjectFactory"); Type type = db.lookupType("ciObjectFactory");
unloadedMethodsField = type.getAddressField("_unloaded_methods"); unloadedMethodsField = type.getAddressField("_unloaded_methods");
ciObjectsField = type.getAddressField("_ci_objects"); ciMetadataField = type.getAddressField("_ci_metadata");
symbolsField = type.getAddressField("_symbols"); symbolsField = type.getAddressField("_symbols");
ciObjectConstructor = new VirtualBaseConstructor<ciObject>(db, db.lookupType("ciObject"), "sun.jvm.hotspot.ci", ciObject.class); ciObjectConstructor = new VirtualBaseConstructor<ciObject>(db, db.lookupType("ciObject"), "sun.jvm.hotspot.ci", ciObject.class);
ciMetadataConstructor = new VirtualBaseConstructor<ciMetadata>(db, db.lookupType("ciMetadata"), "sun.jvm.hotspot.ci", ciMetadata.class);
ciSymbolConstructor = new VirtualBaseConstructor<ciSymbol>(db, db.lookupType("ciSymbol"), "sun.jvm.hotspot.ci", ciSymbol.class); ciSymbolConstructor = new VirtualBaseConstructor<ciSymbol>(db, db.lookupType("ciSymbol"), "sun.jvm.hotspot.ci", ciSymbol.class);
} }
private static AddressField unloadedMethodsField; private static AddressField unloadedMethodsField;
private static AddressField ciObjectsField; private static AddressField ciMetadataField;
private static AddressField symbolsField; private static AddressField symbolsField;
private static VirtualBaseConstructor<ciObject> ciObjectConstructor; private static VirtualBaseConstructor<ciObject> ciObjectConstructor;
private static VirtualBaseConstructor<ciMetadata> ciMetadataConstructor;
private static VirtualBaseConstructor<ciSymbol> ciSymbolConstructor; private static VirtualBaseConstructor<ciSymbol> ciSymbolConstructor;
public static ciObject get(Address addr) { public static ciObject get(Address addr) {
@ -64,8 +66,14 @@ public class ciObjectFactory extends VMObject {
return (ciObject)ciObjectConstructor.instantiateWrapperFor(addr); return (ciObject)ciObjectConstructor.instantiateWrapperFor(addr);
} }
public GrowableArray<ciObject> objects() { public static ciMetadata getMetadata(Address addr) {
return GrowableArray.create(ciObjectsField.getValue(getAddress()), ciObjectConstructor); if (addr == null) return null;
return (ciMetadata)ciMetadataConstructor.instantiateWrapperFor(addr);
}
public GrowableArray<ciMetadata> objects() {
return GrowableArray.create(ciMetadataField.getValue(getAddress()), ciMetadataConstructor);
} }
public GrowableArray<ciSymbol> symbols() { public GrowableArray<ciSymbol> symbols() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -42,7 +42,7 @@ public class ciReceiverTypeData extends ReceiverTypeData {
public ciKlass receiverAt(int row) { public ciKlass receiverAt(int row) {
//assert((uint)row < rowLimit(), "oob"); //assert((uint)row < rowLimit(), "oob");
ciObject recv = ciObjectFactory.get(addressAt(receiverCellIndex(row))); ciMetadata recv = ciObjectFactory.getMetadata(addressAt(receiverCellIndex(row)));
if (recv != null && !(recv instanceof ciKlass)) { if (recv != null && !(recv instanceof ciKlass)) {
System.err.println(recv); System.err.println(recv);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
public class ciSymbol extends VMObject { public class ciSymbol extends ciMetadata {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -42,12 +42,10 @@ public class ciSymbol extends VMObject {
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("ciSymbol"); Type type = db.lookupType("ciSymbol");
identField = type.getCIntegerField("_ident");
symbolField = type.getAddressField("_symbol"); symbolField = type.getAddressField("_symbol");
} }
private static AddressField symbolField; private static AddressField symbolField;
private static CIntegerField identField;
public String asUtf88() { public String asUtf88() {
Symbol sym = Symbol.create(symbolField.getValue(getAddress())); Symbol sym = Symbol.create(symbolField.getValue(getAddress()));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,7 +30,7 @@ import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
public class ciType extends ciObject { public class ciType extends ciMetadata {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2011, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
package sun.jvm.hotspot.ci;
import java.io.PrintStream;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*;
public class ciTypeArrayKlassKlass extends ciArrayKlassKlass {
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("ciTypeArrayKlassKlass");
}
public ciTypeArrayKlassKlass(Address addr) {
super(addr);
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -42,7 +42,7 @@ public class ciVirtualCallData extends VirtualCallData {
public ciKlass receiverAt(int row) { public ciKlass receiverAt(int row) {
//assert((uint)row < rowLimit(), "oob"); //assert((uint)row < rowLimit(), "oob");
ciObject recv = ciObjectFactory.get(addressAt(receiverCellIndex(row))); ciMetadata recv = ciObjectFactory.getMetadata(addressAt(receiverCellIndex(row)));
if (recv != null && !(recv instanceof ciKlass)) { if (recv != null && !(recv instanceof ciKlass)) {
System.err.println(recv); System.err.println(recv);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,7 +22,7 @@
* *
*/ */
package sun.jvm.hotspot.ci; package sun.jvm.hotspot.classfile;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.*; import java.util.*;
@ -31,7 +31,7 @@ import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
public class ciObjArrayKlassKlass extends ciArrayKlassKlass { public class ClassLoaderData extends VMObject {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -41,11 +41,26 @@ public class ciObjArrayKlassKlass extends ciArrayKlassKlass {
} }
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("ciObjArrayKlassKlass"); Type type = db.lookupType("ClassLoaderData");
classLoaderField = type.getOopField("_class_loader");
nextField = type.getAddressField("_next");
} }
private static sun.jvm.hotspot.types.OopField classLoaderField;
private static AddressField nextField;
public ciObjArrayKlassKlass(Address addr) { public ClassLoaderData(Address addr) {
super(addr); super(addr);
} }
public static ClassLoaderData instantiateWrapperFor(Address addr) {
if (addr == null) {
return null;
}
return new ClassLoaderData(addr);
}
public Oop getClassLoader() {
return VM.getVM().getObjectHeap().newOop(classLoaderField.getValue(getAddress()));
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,7 @@ import java.util.*;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.VM; import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.utilities.*; import sun.jvm.hotspot.utilities.*;
import sun.jvm.hotspot.oops.Method;
public class DebugInfoReadStream extends CompressedReadStream { public class DebugInfoReadStream extends CompressedReadStream {
private NMethod code; private NMethod code;
@ -53,6 +54,10 @@ public class DebugInfoReadStream extends CompressedReadStream {
return code.getOopAt(readInt()); return code.getOopAt(readInt());
} }
public Method readMethod() {
return code.getMethodAt(readInt());
}
ScopeValue readObjectValue() { ScopeValue readObjectValue() {
int id = readInt(); int id = readInt();
if (Assert.ASSERTS_ENABLED) { if (Assert.ASSERTS_ENABLED) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -35,7 +35,7 @@ import sun.jvm.hotspot.utilities.*;
public class NMethod extends CodeBlob { public class NMethod extends CodeBlob {
private static long pcDescSize; private static long pcDescSize;
private static sun.jvm.hotspot.types.OopField methodField; private static AddressField methodField;
/** != InvocationEntryBci if this nmethod is an on-stack replacement method */ /** != InvocationEntryBci if this nmethod is an on-stack replacement method */
private static CIntegerField entryBCIField; private static CIntegerField entryBCIField;
/** To support simple linked-list chaining of nmethods */ /** To support simple linked-list chaining of nmethods */
@ -50,6 +50,7 @@ public class NMethod extends CodeBlob {
private static CIntegerField origPCOffsetField; private static CIntegerField origPCOffsetField;
private static CIntegerField stubOffsetField; private static CIntegerField stubOffsetField;
private static CIntegerField oopsOffsetField; private static CIntegerField oopsOffsetField;
private static CIntegerField metadataOffsetField;
private static CIntegerField scopesDataOffsetField; private static CIntegerField scopesDataOffsetField;
private static CIntegerField scopesPCsOffsetField; private static CIntegerField scopesPCsOffsetField;
private static CIntegerField dependenciesOffsetField; private static CIntegerField dependenciesOffsetField;
@ -88,7 +89,7 @@ public class NMethod extends CodeBlob {
private static void initialize(TypeDataBase db) { private static void initialize(TypeDataBase db) {
Type type = db.lookupType("nmethod"); Type type = db.lookupType("nmethod");
methodField = type.getOopField("_method"); methodField = type.getAddressField("_method");
entryBCIField = type.getCIntegerField("_entry_bci"); entryBCIField = type.getCIntegerField("_entry_bci");
osrLinkField = type.getAddressField("_osr_link"); osrLinkField = type.getAddressField("_osr_link");
scavengeRootLinkField = type.getAddressField("_scavenge_root_link"); scavengeRootLinkField = type.getAddressField("_scavenge_root_link");
@ -100,6 +101,7 @@ public class NMethod extends CodeBlob {
origPCOffsetField = type.getCIntegerField("_orig_pc_offset"); origPCOffsetField = type.getCIntegerField("_orig_pc_offset");
stubOffsetField = type.getCIntegerField("_stub_offset"); stubOffsetField = type.getCIntegerField("_stub_offset");
oopsOffsetField = type.getCIntegerField("_oops_offset"); oopsOffsetField = type.getCIntegerField("_oops_offset");
metadataOffsetField = type.getCIntegerField("_metadata_offset");
scopesDataOffsetField = type.getCIntegerField("_scopes_data_offset"); scopesDataOffsetField = type.getCIntegerField("_scopes_data_offset");
scopesPCsOffsetField = type.getCIntegerField("_scopes_pcs_offset"); scopesPCsOffsetField = type.getCIntegerField("_scopes_pcs_offset");
dependenciesOffsetField = type.getCIntegerField("_dependencies_offset"); dependenciesOffsetField = type.getCIntegerField("_dependencies_offset");
@ -126,7 +128,7 @@ public class NMethod extends CodeBlob {
} }
public Method getMethod() { public Method getMethod() {
return (Method) VM.getVM().getObjectHeap().newOop(methodField.getValue(addr)); return (Method)Metadata.instantiateWrapperFor(methodField.getValue(addr));
} }
// Type info // Type info
@ -146,7 +148,9 @@ public class NMethod extends CodeBlob {
public Address stubBegin() { return headerBegin().addOffsetTo(getStubOffset()); } public Address stubBegin() { return headerBegin().addOffsetTo(getStubOffset()); }
public Address stubEnd() { return headerBegin().addOffsetTo(getOopsOffset()); } public Address stubEnd() { return headerBegin().addOffsetTo(getOopsOffset()); }
public Address oopsBegin() { return headerBegin().addOffsetTo(getOopsOffset()); } public Address oopsBegin() { return headerBegin().addOffsetTo(getOopsOffset()); }
public Address oopsEnd() { return headerBegin().addOffsetTo(getScopesDataOffset()); } public Address oopsEnd() { return headerBegin().addOffsetTo(getMetadataOffset()); }
public Address metadataBegin() { return headerBegin().addOffsetTo(getMetadataOffset()); }
public Address metadataEnd() { return headerBegin().addOffsetTo(getScopesDataOffset()); }
public Address scopesDataBegin() { return headerBegin().addOffsetTo(getScopesDataOffset()); } public Address scopesDataBegin() { return headerBegin().addOffsetTo(getScopesDataOffset()); }
public Address scopesDataEnd() { return headerBegin().addOffsetTo(getScopesPCsOffset()); } public Address scopesDataEnd() { return headerBegin().addOffsetTo(getScopesPCsOffset()); }
public Address scopesPCsBegin() { return headerBegin().addOffsetTo(getScopesPCsOffset()); } public Address scopesPCsBegin() { return headerBegin().addOffsetTo(getScopesPCsOffset()); }
@ -162,6 +166,7 @@ public class NMethod extends CodeBlob {
public int instsSize() { return (int) instsEnd() .minus(instsBegin()); } public int instsSize() { return (int) instsEnd() .minus(instsBegin()); }
public int stubSize() { return (int) stubEnd() .minus(stubBegin()); } public int stubSize() { return (int) stubEnd() .minus(stubBegin()); }
public int oopsSize() { return (int) oopsEnd() .minus(oopsBegin()); } public int oopsSize() { return (int) oopsEnd() .minus(oopsBegin()); }
public int metadataSize() { return (int) metadataEnd() .minus(metadataBegin()); }
public int scopesDataSize() { return (int) scopesDataEnd() .minus(scopesDataBegin()); } public int scopesDataSize() { return (int) scopesDataEnd() .minus(scopesDataBegin()); }
public int scopesPCsSize() { return (int) scopesPCsEnd() .minus(scopesPCsBegin()); } public int scopesPCsSize() { return (int) scopesPCsEnd() .minus(scopesPCsBegin()); }
public int dependenciesSize() { return (int) dependenciesEnd().minus(dependenciesBegin()); } public int dependenciesSize() { return (int) dependenciesEnd().minus(dependenciesBegin()); }
@ -185,12 +190,14 @@ public class NMethod extends CodeBlob {
public boolean instsContains (Address addr) { return instsBegin() .lessThanOrEqual(addr) && instsEnd() .greaterThan(addr); } public boolean instsContains (Address addr) { return instsBegin() .lessThanOrEqual(addr) && instsEnd() .greaterThan(addr); }
public boolean stubContains (Address addr) { return stubBegin() .lessThanOrEqual(addr) && stubEnd() .greaterThan(addr); } public boolean stubContains (Address addr) { return stubBegin() .lessThanOrEqual(addr) && stubEnd() .greaterThan(addr); }
public boolean oopsContains (Address addr) { return oopsBegin() .lessThanOrEqual(addr) && oopsEnd() .greaterThan(addr); } public boolean oopsContains (Address addr) { return oopsBegin() .lessThanOrEqual(addr) && oopsEnd() .greaterThan(addr); }
public boolean metadataContains (Address addr) { return metadataBegin() .lessThanOrEqual(addr) && metadataEnd() .greaterThan(addr); }
public boolean scopesDataContains (Address addr) { return scopesDataBegin() .lessThanOrEqual(addr) && scopesDataEnd() .greaterThan(addr); } public boolean scopesDataContains (Address addr) { return scopesDataBegin() .lessThanOrEqual(addr) && scopesDataEnd() .greaterThan(addr); }
public boolean scopesPCsContains (Address addr) { return scopesPCsBegin() .lessThanOrEqual(addr) && scopesPCsEnd() .greaterThan(addr); } public boolean scopesPCsContains (Address addr) { return scopesPCsBegin() .lessThanOrEqual(addr) && scopesPCsEnd() .greaterThan(addr); }
public boolean handlerTableContains(Address addr) { return handlerTableBegin().lessThanOrEqual(addr) && handlerTableEnd().greaterThan(addr); } public boolean handlerTableContains(Address addr) { return handlerTableBegin().lessThanOrEqual(addr) && handlerTableEnd().greaterThan(addr); }
public boolean nulChkTableContains (Address addr) { return nulChkTableBegin() .lessThanOrEqual(addr) && nulChkTableEnd() .greaterThan(addr); } public boolean nulChkTableContains (Address addr) { return nulChkTableBegin() .lessThanOrEqual(addr) && nulChkTableEnd() .greaterThan(addr); }
public int getOopsLength() { return (int) (oopsSize() / VM.getVM().getOopSize()); } public int getOopsLength() { return (int) (oopsSize() / VM.getVM().getOopSize()); }
public int getMetadataLength() { return (int) (metadataSize() / VM.getVM().getOopSize()); }
/** Entry points */ /** Entry points */
public Address getEntryPoint() { return entryPointField.getValue(addr); } public Address getEntryPoint() { return entryPointField.getValue(addr); }
@ -205,6 +212,19 @@ public class NMethod extends CodeBlob {
return oopsBegin().getOopHandleAt((index - 1) * VM.getVM().getOopSize()); return oopsBegin().getOopHandleAt((index - 1) * VM.getVM().getOopSize());
} }
/** Support for metadata in scopes and relocs. Note: index 0 is reserved for null. */
public Address getMetadataAt(int index) {
if (index == 0) return null;
if (Assert.ASSERTS_ENABLED) {
Assert.that(index > 0 && index <= getMetadataLength(), "must be a valid non-zero index");
}
return metadataBegin().getAddressAt((index - 1) * VM.getVM().getOopSize());
}
public Method getMethodAt(int index) {
return (Method)Metadata.instantiateWrapperFor(getMetadataAt(index));
}
// FIXME: add interpreter_entry_point() // FIXME: add interpreter_entry_point()
// FIXME: add lazy_interpreter_entry_point() for C2 // FIXME: add lazy_interpreter_entry_point() for C2
@ -412,6 +432,7 @@ public class NMethod extends CodeBlob {
private int getDeoptMhOffset() { return (int) deoptMhOffsetField .getValue(addr); } private int getDeoptMhOffset() { return (int) deoptMhOffsetField .getValue(addr); }
private int getStubOffset() { return (int) stubOffsetField .getValue(addr); } private int getStubOffset() { return (int) stubOffsetField .getValue(addr); }
private int getOopsOffset() { return (int) oopsOffsetField .getValue(addr); } private int getOopsOffset() { return (int) oopsOffsetField .getValue(addr); }
private int getMetadataOffset() { return (int) metadataOffsetField .getValue(addr); }
private int getScopesDataOffset() { return (int) scopesDataOffsetField .getValue(addr); } private int getScopesDataOffset() { return (int) scopesDataOffsetField .getValue(addr); }
private int getScopesPCsOffset() { return (int) scopesPCsOffsetField .getValue(addr); } private int getScopesPCsOffset() { return (int) scopesPCsOffsetField .getValue(addr); }
private int getDependenciesOffset() { return (int) dependenciesOffsetField.getValue(addr); } private int getDependenciesOffset() { return (int) dependenciesOffsetField.getValue(addr); }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -61,7 +61,7 @@ public class ScopeDesc {
DebugInfoReadStream stream = streamAt(decodeOffset); DebugInfoReadStream stream = streamAt(decodeOffset);
senderDecodeOffset = stream.readInt(); senderDecodeOffset = stream.readInt();
method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); method = stream.readMethod();
bci = stream.readBCI(); bci = stream.readBCI();
// Decode offsets for body and sender // Decode offsets for body and sender
localsDecodeOffset = stream.readInt(); localsDecodeOffset = stream.readInt();
@ -79,7 +79,7 @@ public class ScopeDesc {
DebugInfoReadStream stream = streamAt(decodeOffset); DebugInfoReadStream stream = streamAt(decodeOffset);
senderDecodeOffset = stream.readInt(); senderDecodeOffset = stream.readInt();
method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); method = stream.readMethod();
bci = stream.readBCI(); bci = stream.readBCI();
// Decode offsets for body and sender // Decode offsets for body and sender
localsDecodeOffset = stream.readInt(); localsDecodeOffset = stream.readInt();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -56,8 +56,8 @@ public class CompileTask extends VMObject {
} }
public Method method() { public Method method() {
OopHandle oh = methodField.getValue(getAddress()).getOopHandleAt(0); Address oh = methodField.getValue(getAddress()).getAddressAt(0);
return (Method)VM.getVM().getObjectHeap().newOop(oh); return (Method)Metadata.instantiateWrapperFor(oh);
} }
public int osrBci() { public int osrBci() {

View File

@ -1,61 +0,0 @@
/*
* Copyright (c) 2003, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.gc_implementation.parallelScavenge;
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.gc_implementation.shared.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*;
public class PSPermGen extends PSOldGen {
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static synchronized void initialize(TypeDataBase db) {
// just checking type existence
Type type = db.lookupType("PSPermGen");
}
public PSPermGen(Address addr) {
super(addr);
}
public void printOn(PrintStream tty) {
tty.print("PSPermGen [ ");
objectSpace().printOn(tty);
tty.print(" ] ");
}
// FIXME: no other stuff yet
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -45,7 +45,6 @@ public class ParallelScavengeHeap extends CollectedHeap {
Type type = db.lookupType("ParallelScavengeHeap"); Type type = db.lookupType("ParallelScavengeHeap");
youngGenField = type.getAddressField("_young_gen"); youngGenField = type.getAddressField("_young_gen");
oldGenField = type.getAddressField("_old_gen"); oldGenField = type.getAddressField("_old_gen");
permGenField = type.getAddressField("_perm_gen");
} }
public ParallelScavengeHeap(Address addr) { public ParallelScavengeHeap(Address addr) {
@ -55,7 +54,6 @@ public class ParallelScavengeHeap extends CollectedHeap {
// Fields // Fields
private static AddressField youngGenField; private static AddressField youngGenField;
private static AddressField oldGenField; private static AddressField oldGenField;
private static AddressField permGenField;
// Accessors // Accessors
public PSYoungGen youngGen() { public PSYoungGen youngGen() {
@ -66,10 +64,6 @@ public class ParallelScavengeHeap extends CollectedHeap {
return (PSOldGen) VMObjectFactory.newObject(PSOldGen.class, oldGenField.getValue()); return (PSOldGen) VMObjectFactory.newObject(PSOldGen.class, oldGenField.getValue());
} }
public PSPermGen permGen() {
return (PSPermGen) VMObjectFactory.newObject(PSPermGen.class, permGenField.getValue());
}
public long capacity() { public long capacity() {
return youngGen().capacity() + oldGen().capacity(); return youngGen().capacity() + oldGen().capacity();
} }
@ -87,10 +81,6 @@ public class ParallelScavengeHeap extends CollectedHeap {
return true; return true;
} }
if (permGen().isIn(a)) {
return true;
}
return false; return false;
} }
@ -102,7 +92,6 @@ public class ParallelScavengeHeap extends CollectedHeap {
tty.print("ParallelScavengeHeap [ "); tty.print("ParallelScavengeHeap [ ");
youngGen().printOn(tty); youngGen().printOn(tty);
oldGen().printOn(tty); oldGen().printOn(tty);
permGen().printOn(tty);
tty.print(" ] "); tty.print(" ] ");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -138,9 +138,9 @@ public class BytecodeDisassembler {
} }
} }
Object bytecodeObj = null; Bytecode bytecodeObj = null;
try { try {
bytecodeObj = cstr.newInstance(new Object[] { method, new Integer(bci) }); bytecodeObj = (Bytecode)cstr.newInstance(new Object[] { method, new Integer(bci) });
} catch (Exception exp) { } catch (Exception exp) {
if (Assert.ASSERTS_ENABLED) { if (Assert.ASSERTS_ENABLED) {
Assert.that(false, "Bytecode instance of class " Assert.that(false, "Bytecode instance of class "
@ -153,11 +153,10 @@ public class BytecodeDisassembler {
} }
try { try {
visitor.visit((Bytecode) bytecodeObj); visitor.visit(bytecodeObj);
} catch(ClassCastException castfail) { } catch(ClassCastException castfail) {
if (Assert.ASSERTS_ENABLED) { castfail.printStackTrace();
Assert.that(false, clazz.getName() + " is not derived from Bytecode!"); System.err.println(method.getAddress() + " " + bci);
}
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -55,8 +55,7 @@ public class BytecodeInvoke extends BytecodeWithCPIndex {
public Symbol name() { public Symbol name() {
ConstantPool cp = method().getConstants(); ConstantPool cp = method().getConstants();
if (isInvokedynamic()) { if (isInvokedynamic()) {
int[] nt = cp.getNameAndTypeAt(indexForFieldOrMethod()); return cp.uncachedGetNameRefAt(indexForFieldOrMethod());
return cp.getSymbolAt(nt[0]);
} }
return cp.getNameRefAt(index()); return cp.getNameRefAt(index());
} }
@ -65,20 +64,11 @@ public class BytecodeInvoke extends BytecodeWithCPIndex {
public Symbol signature() { public Symbol signature() {
ConstantPool cp = method().getConstants(); ConstantPool cp = method().getConstants();
if (isInvokedynamic()) { if (isInvokedynamic()) {
int[] nt = cp.getNameAndTypeAt(indexForFieldOrMethod()); return cp.uncachedGetSignatureRefAt(indexForFieldOrMethod());
return cp.getSymbolAt(nt[1]);
} }
return cp.getSignatureRefAt(index()); return cp.getSignatureRefAt(index());
} }
public int getSecondaryIndex() {
if (isInvokedynamic()) {
// change byte-ordering of 4-byte integer
return VM.getVM().getBytes().swapInt(javaSignedWordAt(1));
}
return super.getSecondaryIndex(); // throw an error
}
public Method getInvokedMethod() { public Method getInvokedMethod() {
return method().getConstants().getMethodRefAt(index()); return method().getConstants().getMethodRefAt(index());
} }
@ -123,7 +113,7 @@ public class BytecodeInvoke extends BytecodeWithCPIndex {
buf.append(Integer.toString(indexForFieldOrMethod())); buf.append(Integer.toString(indexForFieldOrMethod()));
if (isInvokedynamic()) { if (isInvokedynamic()) {
buf.append('('); buf.append('(');
buf.append(Integer.toString(getSecondaryIndex())); buf.append(Integer.toString(index()));
buf.append(')'); buf.append(')');
} }
buf.append(" [Method "); buf.append(" [Method ");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -46,12 +46,11 @@ public class BytecodeLoadConstant extends Bytecode {
} }
public int poolIndex() { public int poolIndex() {
int i = rawIndex(); int index = rawIndex();
if (hasCacheIndex()) { if (hasCacheIndex()) {
ConstantPoolCache cpCache = method().getConstants().getCache(); return method().getConstants().objectToCPIndex(index);
return cpCache.getEntryAt(i).getConstantPoolIndex();
} else { } else {
return i; return index;
} }
} }
@ -72,8 +71,7 @@ public class BytecodeLoadConstant extends Bytecode {
private Oop getCachedConstant() { private Oop getCachedConstant() {
int i = cacheIndex(); int i = cacheIndex();
if (i >= 0) { if (i >= 0) {
ConstantPoolCache cpCache = method().getConstants().getCache(); throw new InternalError("invokedynamic not implemented yet");
return cpCache.getEntryAt(i).getF1();
} }
return null; return null;
} }
@ -96,7 +94,7 @@ public class BytecodeLoadConstant extends Bytecode {
return (ctag.isDouble() || ctag.isLong()) ? true: false; return (ctag.isDouble() || ctag.isLong()) ? true: false;
} else { } else {
// has to be int or float or String or Klass // has to be int or float or String or Klass
return (ctag.isUnresolvedString() || ctag.isString() return (ctag.isString()
|| ctag.isUnresolvedKlass() || ctag.isKlass() || ctag.isUnresolvedKlass() || ctag.isKlass()
|| ctag.isMethodHandle() || ctag.isMethodType() || ctag.isMethodHandle() || ctag.isMethodType()
|| ctag.isInt() || ctag.isFloat())? true: false; || ctag.isInt() || ctag.isFloat())? true: false;
@ -124,9 +122,9 @@ public class BytecodeLoadConstant extends Bytecode {
ConstantPool cpool = method().getConstants(); ConstantPool cpool = method().getConstants();
int cpIndex = poolIndex(); int cpIndex = poolIndex();
ConstantPool.CPSlot oop = cpool.getSlotAt(cpIndex); ConstantPool.CPSlot oop = cpool.getSlotAt(cpIndex);
if (oop.isOop()) { if (oop.isResolved()) {
return (Klass) oop.getOop(); return oop.getKlass();
} else if (oop.isMetaData()) { } else if (oop.isUnresolved()) {
return oop.getSymbol(); return oop.getSymbol();
} else { } else {
throw new RuntimeException("should not reach here"); throw new RuntimeException("should not reach here");
@ -163,28 +161,21 @@ public class BytecodeLoadConstant extends Bytecode {
return "<float " + Float.toString(cpool.getFloatAt(cpIndex)) + "F>"; return "<float " + Float.toString(cpool.getFloatAt(cpIndex)) + "F>";
} else if (ctag.isDouble()) { } else if (ctag.isDouble()) {
return "<double " + Double.toString(cpool.getDoubleAt(cpIndex)) + "D>"; return "<double " + Double.toString(cpool.getDoubleAt(cpIndex)) + "D>";
} else if (ctag.isString() || ctag.isUnresolvedString()) { } else if (ctag.isString()) {
// tag change from 'unresolved' to 'string' does not happen atomically. // tag change from 'unresolved' to 'string' does not happen atomically.
// We just look at the object at the corresponding index and // We just look at the object at the corresponding index and
// decide based on the oop type. // decide based on the oop type.
ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex); Symbol sym = cpool.getUnresolvedStringAt(cpIndex);
if (obj.isMetaData()) {
Symbol sym = obj.getSymbol();
return "<String \"" + sym.asString() + "\">"; return "<String \"" + sym.asString() + "\">";
} else if (obj.isOop()) {
return "<String \"" + OopUtilities.stringOopToString(obj.getOop()) + "\">";
} else {
throw new RuntimeException("should not reach here");
}
} else if (ctag.isKlass() || ctag.isUnresolvedKlass()) { } else if (ctag.isKlass() || ctag.isUnresolvedKlass()) {
// tag change from 'unresolved' to 'klass' does not happen atomically. // tag change from 'unresolved' to 'klass' does not happen atomically.
// We just look at the object at the corresponding index and // We just look at the object at the corresponding index and
// decide based on the oop type. // decide based on the oop type.
ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex); ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex);
if (obj.isOop()) { if (obj.isResolved()) {
Klass k = (Klass) obj.getOop(); Klass k = obj.getKlass();
return "<Class " + k.getName().asString() + "@" + k.getHandle() + ">"; return "<Class " + k.getName().asString() + "@" + k.getAddress() + ">";
} else if (obj.isMetaData()) { } else if (obj.isUnresolved()) {
Symbol sym = obj.getSymbol(); Symbol sym = obj.getSymbol();
return "<Class " + sym.asString() + ">"; return "<Class " + sym.asString() + ">";
} else { } else {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -35,10 +35,17 @@ public abstract class BytecodeWithCPIndex extends Bytecode {
} }
// the constant pool index for this bytecode // the constant pool index for this bytecode
public int index() { return getIndexU2(code(), false); } public int index() {
if (code() == Bytecodes._invokedynamic) {
public int getSecondaryIndex() { int index = getIndexU4();
throw new IllegalArgumentException("must be invokedynamic"); if (ConstantPool.isInvokedynamicIndex(index)) {
return ConstantPool.decodeInvokedynamicIndex(index);
} else {
return index;
}
} else {
return getIndexU2(code(), false);
}
} }
protected int indexForFieldOrMethod() { protected int indexForFieldOrMethod() {
@ -47,12 +54,8 @@ public abstract class BytecodeWithCPIndex extends Bytecode {
int cpCacheIndex = index(); int cpCacheIndex = index();
if (cpCache == null) { if (cpCache == null) {
return cpCacheIndex; return cpCacheIndex;
} else if (code() == Bytecodes._invokedynamic) {
int secondaryIndex = getSecondaryIndex();
return cpCache.getMainEntryAt(secondaryIndex).getConstantPoolIndex();
} else { } else {
// change byte-ordering and go via cache return cpCache.getEntryAt((int) (0xFFFF & cpCacheIndex)).getConstantPoolIndex();
return cpCache.getEntryAt((int) (0xFFFF & VM.getVM().getBytes().swapShort((short) cpCacheIndex))).getConstantPoolIndex();
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,15 +33,15 @@ public class BytecodeWithKlass extends BytecodeWithCPIndex {
} }
protected Klass getKlass() { protected Klass getKlass() {
return method().getConstants().getKlassRefAt(index()); return method().getConstants().getKlassAt(index());
} }
public Symbol getClassName() { public Symbol getClassName() {
ConstantPool.CPSlot obj = method().getConstants().getSlotAt(index()); ConstantPool.CPSlot obj = method().getConstants().getSlotAt(index());
if (obj.isMetaData()) { if (obj.isUnresolved()) {
return obj.getSymbol(); return obj.getSymbol();
} else { } else {
return ((Klass)obj.getOop()).getName(); return obj.getKlass().getName();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -362,7 +362,7 @@ public class Bytecodes {
// find a bytecode, behind a breakpoint if necessary: // find a bytecode, behind a breakpoint if necessary:
// FIXME: not yet implementable // FIXME: not yet implementable
// static Code non_breakpoint_code_at(address bcp, methodOop method = null); // static Code non_breakpoint_code_at(address bcp, Method* method = null);
// Bytecode attributes // Bytecode attributes
public static boolean isDefined (int code) { return 0 <= code && code < number_of_codes && flags(code, false) != 0; } public static boolean isDefined (int code) { return 0 <= code && code < number_of_codes && flags(code, false) != 0; }
@ -743,7 +743,7 @@ public class Bytecodes {
def(_invokespecial , "invokespecial" , "bJJ" , null , BasicType.getTIllegal(), -1, true ); def(_invokespecial , "invokespecial" , "bJJ" , null , BasicType.getTIllegal(), -1, true );
def(_invokestatic , "invokestatic" , "bJJ" , null , BasicType.getTIllegal(), 0, true ); def(_invokestatic , "invokestatic" , "bJJ" , null , BasicType.getTIllegal(), 0, true );
def(_invokeinterface , "invokeinterface" , "bJJ__", null , BasicType.getTIllegal(), -1, true ); def(_invokeinterface , "invokeinterface" , "bJJ__", null , BasicType.getTIllegal(), -1, true );
def(_invokedynamic , "invokedynamic" , "bJJJJ", null , BasicType.getTIllegal(), -1, true ); def(_invokedynamic , "invokedynamic" , "bJJJJ", null , BasicType.getTIllegal(), 0, true );
def(_new , "new" , "bkk" , null , BasicType.getTObject() , 1, true ); def(_new , "new" , "bkk" , null , BasicType.getTObject() , 1, true );
def(_newarray , "newarray" , "bc" , null , BasicType.getTObject() , 0, true ); def(_newarray , "newarray" , "bc" , null , BasicType.getTObject() , 0, true );
def(_anewarray , "anewarray" , "bkk" , null , BasicType.getTObject() , 0, true ); def(_anewarray , "anewarray" , "bkk" , null , BasicType.getTObject() , 0, true );
@ -763,6 +763,7 @@ public class Bytecodes {
// JVM bytecodes // JVM bytecodes
// bytecode bytecode name format wide f. result tp stk traps std code // bytecode bytecode name format wide f. result tp stk traps std code
def(_fast_agetfield , "fast_agetfield" , "bJJ" , null , BasicType.getTObject() , 0, true , _getfield ); def(_fast_agetfield , "fast_agetfield" , "bJJ" , null , BasicType.getTObject() , 0, true , _getfield );
def(_fast_bgetfield , "fast_bgetfield" , "bJJ" , null , BasicType.getTInt() , 0, true , _getfield ); def(_fast_bgetfield , "fast_bgetfield" , "bJJ" , null , BasicType.getTInt() , 0, true , _getfield );
def(_fast_cgetfield , "fast_cgetfield" , "bJJ" , null , BasicType.getTChar() , 0, true , _getfield ); def(_fast_cgetfield , "fast_cgetfield" , "bJJ" , null , BasicType.getTChar() , 0, true , _getfield );

View File

@ -135,15 +135,15 @@ implements ReferenceType {
ReferenceTypeImpl other = (ReferenceTypeImpl)refType; ReferenceTypeImpl other = (ReferenceTypeImpl)refType;
int comp = name().compareTo(other.name()); int comp = name().compareTo(other.name());
if (comp == 0) { if (comp == 0) {
Oop rf1 = ref(); Klass rf1 = ref();
Oop rf2 = other.ref(); Klass rf2 = other.ref();
// optimize for typical case: refs equal and VMs equal // optimize for typical case: refs equal and VMs equal
if (rf1.equals(rf2)) { if (rf1.equals(rf2)) {
// sequenceNumbers are always positive // sequenceNumbers are always positive
comp = vm.sequenceNumber - comp = vm.sequenceNumber -
((VirtualMachineImpl)(other.virtualMachine())).sequenceNumber; ((VirtualMachineImpl)(other.virtualMachine())).sequenceNumber;
} else { } else {
comp = rf1.getHandle().minus(rf2.getHandle()) < 0? -1 : 1; comp = rf1.getAddress().minus(rf2.getAddress()) < 0? -1 : 1;
} }
} }
return comp; return comp;
@ -225,7 +225,7 @@ implements ReferenceType {
private boolean isThrowableBacktraceField(sun.jvm.hotspot.oops.Field fld) { private boolean isThrowableBacktraceField(sun.jvm.hotspot.oops.Field fld) {
// refer to JvmtiEnv::GetClassFields in jvmtiEnv.cpp. // refer to JvmtiEnv::GetClassFields in jvmtiEnv.cpp.
// We want to filter out java.lang.Throwable.backtrace (see 4446677). // We want to filter out java.lang.Throwable.backtrace (see 4446677).
// It contains some methodOops that aren't quite real Objects. // It contains some Method*s that aren't quite real Objects.
if (fld.getFieldHolder().getName().equals(vm.javaLangThrowable()) && if (fld.getFieldHolder().getName().equals(vm.javaLangThrowable()) &&
fld.getID().getName().equals("backtrace")) { fld.getID().getName().equals("backtrace")) {
return true; return true;
@ -932,7 +932,7 @@ implements ReferenceType {
} }
long uniqueID() { long uniqueID() {
return vm.getAddressValue(ref()); return vm.getAddressValue(ref().getJavaMirror());
} }
// new method since 1.6 // new method since 1.6

View File

@ -447,7 +447,7 @@ public class VirtualMachineImpl extends MirrorImpl implements PathSearchingVirtu
newRefType = new ClassTypeImpl(this, (InstanceKlass)kk); newRefType = new ClassTypeImpl(this, (InstanceKlass)kk);
} }
} else { } else {
throw new RuntimeException("should not reach here"); throw new RuntimeException("should not reach here:" + kk);
} }
typesByID.put(kk, newRefType); typesByID.put(kk, newRefType);

View File

@ -1,37 +0,0 @@
/*
* Copyright (c) 2003, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.memory;
import sun.jvm.hotspot.debugger.*;
public class CMSPermGenGen extends ConcurrentMarkSweepGeneration {
public CMSPermGenGen(Address addr) {
super(addr);
}
public String name() {
return "concurrent-mark-sweep perm gen";
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -168,7 +168,7 @@ public class CompactibleFreeListSpace extends CompactibleSpace {
final long addressSize = vm.getAddressSize(); final long addressSize = vm.getAddressSize();
for (; cur.lessThan(limit);) { for (; cur.lessThan(limit);) {
Address klassOop = cur.getAddressAt(addressSize); Address k = cur.getAddressAt(addressSize);
if (FreeChunk.indicatesFreeChunk(cur)) { if (FreeChunk.indicatesFreeChunk(cur)) {
if (! cur.equals(regionStart)) { if (! cur.equals(regionStart)) {
res.add(new MemRegion(regionStart, cur)); res.add(new MemRegion(regionStart, cur));
@ -181,7 +181,7 @@ public class CompactibleFreeListSpace extends CompactibleSpace {
// note that fc.size() gives chunk size in heap words // note that fc.size() gives chunk size in heap words
cur = cur.addOffsetTo(chunkSize * addressSize); cur = cur.addOffsetTo(chunkSize * addressSize);
regionStart = cur; regionStart = cur;
} else if (klassOop != null) { } else if (k != null) {
Oop obj = heap.newOop(cur.addOffsetToAsOopHandle(0)); Oop obj = heap.newOop(cur.addOffsetToAsOopHandle(0));
long objectSize = obj.getObjectSize(); long objectSize = obj.getObjectSize();
cur = cur.addOffsetTo(adjustObjectSizeInBytes(objectSize)); cur = cur.addOffsetTo(adjustObjectSizeInBytes(objectSize));

View File

@ -1,60 +0,0 @@
/*
* Copyright (c) 2000, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.memory;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*;
/** A PermGen implemented with a contiguous space. */
public class CompactingPermGen extends PermGen {
// The "generation" view.
private static AddressField genField;
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static synchronized void initialize(TypeDataBase db) {
Type type = db.lookupType("CompactingPermGen");
genField = type.getAddressField("_gen");
}
public CompactingPermGen(Address addr) {
super(addr);
}
public Generation asGen() {
return GenerationFactory.newObject(genField.getValue(addr));
}
}

View File

@ -1,161 +0,0 @@
/*
* Copyright (c) 2000, 2005, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.memory;
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*;
/** This is the "generation" view of a CompactingPermGen. */
public class CompactingPermGenGen extends OneContigSpaceCardGeneration {
private static AddressField unsharedBottomField;
private static AddressField unsharedEndField;
private static AddressField sharedBottomField;
private static AddressField sharedEndField;
private static AddressField readOnlyBottomField;
private static AddressField readOnlyEndField;
private static AddressField readWriteBottomField;
private static AddressField readWriteEndField;
private static AddressField roSpaceField;
private static AddressField rwSpaceField;
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static synchronized void initialize(TypeDataBase db) {
Type type = db.lookupType("CompactingPermGenGen");
unsharedBottomField = type.getAddressField("unshared_bottom");
unsharedEndField = type.getAddressField("unshared_end");
sharedBottomField = type.getAddressField("shared_bottom");
sharedEndField = type.getAddressField("shared_end");
readOnlyBottomField = type.getAddressField("readonly_bottom");
readOnlyEndField = type.getAddressField("readonly_end");
readWriteBottomField = type.getAddressField("readwrite_bottom");
readWriteEndField = type.getAddressField("readwrite_end");
roSpaceField = type.getAddressField("_ro_space");
rwSpaceField = type.getAddressField("_rw_space");
}
public boolean isSharingEnabled() {
return VM.getVM().isSharingEnabled();
}
// NEEDS_CLEANUP
public CompactingPermGenGen(Address addr) {
super(addr);
}
public OffsetTableContigSpace roSpace() {
return newOffsetTableContigSpace(roSpaceField.getValue(addr));
}
public OffsetTableContigSpace rwSpace() {
return newOffsetTableContigSpace(rwSpaceField.getValue(addr));
}
public String name() {
return "compacting permanent generation";
}
public static Address unsharedBottom() {
return unsharedBottomField.getValue();
}
public static Address unsharedEnd() {
return unsharedEndField.getValue();
}
public static Address sharedBottom() {
return sharedBottomField.getValue();
}
public static Address sharedEnd() {
return sharedEndField.getValue();
}
public static Address readOnlyBottom() {
return readOnlyBottomField.getValue();
}
public static Address readOnlyEnd() {
return readOnlyEndField.getValue();
}
public static Address readWriteBottom() {
return readWriteBottomField.getValue();
}
public static Address readWriteEnd() {
return readWriteEndField.getValue();
}
public static boolean isShared(Address p) {
return sharedBottom().lessThanOrEqual(p) && sharedEnd().greaterThan(p);
}
public static boolean isSharedReadOnly(Address p) {
return readOnlyBottom().lessThanOrEqual(p) && readOnlyEnd().greaterThan(p);
}
public static boolean isSharedReadWrite(Address p) {
return readWriteBottom().lessThanOrEqual(p) && readWriteEnd().greaterThan(p);
}
public boolean isIn(Address p) {
return unsharedBottom().lessThanOrEqual(p) && sharedEnd().greaterThan(p);
}
public void spaceIterate(SpaceClosure blk, boolean usedOnly) {
super.spaceIterate(blk, usedOnly);
if (isSharingEnabled()) {
blk.doSpace(roSpace());
blk.doSpace(rwSpace());
}
}
public void printOn(PrintStream tty) {
tty.print(" perm");
theSpace().printOn(tty);
if (isSharingEnabled()) {
tty.print(" ro space: ");
roSpace().printOn(tty);
tty.print(", rw space: ");
rwSpace().printOn(tty);
}
}
private OffsetTableContigSpace newOffsetTableContigSpace(Address addr) {
return (OffsetTableContigSpace) VMObjectFactory.newObject(
OffsetTableContigSpace.class, addr);
}
}

View File

@ -1,35 +0,0 @@
/*
* Copyright (c) 2000, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.memory;
import sun.jvm.hotspot.debugger.*;
/** No additional functionality for now */
public class ContigPermSpace extends OffsetTableContigSpace {
public ContigPermSpace(Address addr) {
super(addr);
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -63,10 +63,9 @@ public class Dictionary extends TwoOopHashtable {
for (int index = 0; index < tblSize; index++) { for (int index = 0; index < tblSize; index++) {
for (DictionaryEntry probe = (DictionaryEntry) bucket(index); probe != null; for (DictionaryEntry probe = (DictionaryEntry) bucket(index); probe != null;
probe = (DictionaryEntry) probe.next()) { probe = (DictionaryEntry) probe.next()) {
Oop k = probe.klass(); Klass k = probe.klass();
if (k.isKlass() && if (heap.equal(probe.loader(), ((InstanceKlass) k).getClassLoader())) {
heap.equal(probe.loader(), ((InstanceKlass) k).getClassLoader())) { v.visit(k);
v.visit((Klass) k);
} }
} }
} }
@ -78,10 +77,8 @@ public class Dictionary extends TwoOopHashtable {
for (int index = 0; index < tblSize; index++) { for (int index = 0; index < tblSize; index++) {
for (DictionaryEntry probe = (DictionaryEntry) bucket(index); probe != null; for (DictionaryEntry probe = (DictionaryEntry) bucket(index); probe != null;
probe = (DictionaryEntry) probe.next()) { probe = (DictionaryEntry) probe.next()) {
Oop k = probe.klass(); Klass k = probe.klass();
if (k.isKlass()) { v.visit(k, probe.loader());
v.visit((Klass) k, probe.loader());
}
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
package sun.jvm.hotspot.memory; package sun.jvm.hotspot.memory;
import java.util.*; import java.util.*;
import sun.jvm.hotspot.classfile.ClassLoaderData;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
@ -43,12 +44,12 @@ public class DictionaryEntry extends sun.jvm.hotspot.utilities.HashtableEntry {
private static synchronized void initialize(TypeDataBase db) { private static synchronized void initialize(TypeDataBase db) {
Type type = db.lookupType("DictionaryEntry"); Type type = db.lookupType("DictionaryEntry");
pdSetField = type.getAddressField("_pd_set"); pdSetField = type.getAddressField("_pd_set");
loaderField = type.getOopField("_loader"); loaderDataField = type.getAddressField("_loader_data");
} }
// Fields // Fields
private static AddressField pdSetField; private static AddressField pdSetField;
private static sun.jvm.hotspot.types.OopField loaderField; private static AddressField loaderDataField;
// Accessors // Accessors
@ -59,11 +60,15 @@ public class DictionaryEntry extends sun.jvm.hotspot.utilities.HashtableEntry {
} }
public Oop loader() { public Oop loader() {
return VM.getVM().getObjectHeap().newOop(loaderField.getValue(addr)); return loaderData().getClassLoader();
}
public ClassLoaderData loaderData() {
return ClassLoaderData.instantiateWrapperFor(loaderDataField.getValue(addr));
} }
public Klass klass() { public Klass klass() {
return (Klass)VM.getVM().getObjectHeap().newOop(literalValue().addOffsetToAsOopHandle(0)); return (Klass)Metadata.instantiateWrapperFor(literalValue());
} }
public DictionaryEntry(Address addr) { public DictionaryEntry(Address addr) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -90,7 +90,7 @@ public class GenCollectedHeap extends SharedHeap {
} }
} }
return permGen().isIn(a); return false;
} }
public long capacity() { public long capacity() {
@ -140,7 +140,5 @@ public class GenCollectedHeap extends SharedHeap {
tty.println("Invocations: " + getGen(i).invocations()); tty.println("Invocations: " + getGen(i).invocations());
tty.println(); tty.println();
} }
permGen().printOn(tty);
tty.println("Invocations: " + permGen().invocations());
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -39,7 +39,6 @@ import sun.jvm.hotspot.runtime.*;
<ul> <ul>
<li> OneContigSpaceCardGeneration <li> OneContigSpaceCardGeneration
<ul> <ul>
<li> CompactingPermGenGen
<li> TenuredGeneration <li> TenuredGeneration
</ul> </ul>
</ul> </ul>

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,8 +47,6 @@ public class GenerationFactory {
private static synchronized void initialize(TypeDataBase db) { private static synchronized void initialize(TypeDataBase db) {
ctor = new VirtualConstructor(db); ctor = new VirtualConstructor(db);
ctor.addMapping("CompactingPermGenGen", CompactingPermGenGen.class);
ctor.addMapping("CMSPermGenGen", CMSPermGenGen.class);
ctor.addMapping("DefNewGeneration", DefNewGeneration.class); ctor.addMapping("DefNewGeneration", DefNewGeneration.class);
ctor.addMapping("ParNewGeneration", ParNewGeneration.class); ctor.addMapping("ParNewGeneration", ParNewGeneration.class);
ctor.addMapping("TenuredGeneration", TenuredGeneration.class); ctor.addMapping("TenuredGeneration", TenuredGeneration.class);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
package sun.jvm.hotspot.memory; package sun.jvm.hotspot.memory;
import java.util.*; import java.util.*;
import sun.jvm.hotspot.classfile.ClassLoaderData;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
@ -42,15 +43,19 @@ public class PlaceholderEntry extends sun.jvm.hotspot.utilities.HashtableEntry {
private static synchronized void initialize(TypeDataBase db) { private static synchronized void initialize(TypeDataBase db) {
Type type = db.lookupType("PlaceholderEntry"); Type type = db.lookupType("PlaceholderEntry");
loaderField = type.getOopField("_loader"); loaderDataField = type.getAddressField("_loader_data");
} }
// Field // Field
private static sun.jvm.hotspot.types.OopField loaderField; private static AddressField loaderDataField;
// Accessor // Accessor
public Oop loader() { public Oop loader() {
return VM.getVM().getObjectHeap().newOop(loaderField.getValue(addr)); return loaderData().getClassLoader();
}
public ClassLoaderData loaderData() {
return ClassLoaderData.instantiateWrapperFor(loaderDataField.getValue(addr));
} }
public PlaceholderEntry(Address addr) { public PlaceholderEntry(Address addr) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,7 +33,6 @@ import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
public abstract class SharedHeap extends CollectedHeap { public abstract class SharedHeap extends CollectedHeap {
private static AddressField permGenField;
private static VirtualConstructor ctor; private static VirtualConstructor ctor;
static { static {
@ -46,31 +45,14 @@ public abstract class SharedHeap extends CollectedHeap {
private static synchronized void initialize(TypeDataBase db) { private static synchronized void initialize(TypeDataBase db) {
Type type = db.lookupType("SharedHeap"); Type type = db.lookupType("SharedHeap");
permGenField = type.getAddressField("_perm_gen");
ctor = new VirtualConstructor(db); ctor = new VirtualConstructor(db);
ctor.addMapping("CompactingPermGen", CompactingPermGen.class);
ctor.addMapping("CMSPermGen", CMSPermGen.class);
} }
public SharedHeap(Address addr) { public SharedHeap(Address addr) {
super(addr); super(addr);
} }
/** These functions return the "permanent" generation, in which
reflective objects are allocated and stored. Two versions, the
second of which returns the view of the perm gen as a
generation. (FIXME: this distinction is strange and seems
unnecessary, and should be cleaned up.) */
public PermGen perm() {
return (PermGen) ctor.instantiateWrapperFor(permGenField.getValue(addr));
}
public CollectedHeapName kind() { public CollectedHeapName kind() {
return CollectedHeapName.SHARED_HEAP; return CollectedHeapName.SHARED_HEAP;
} }
public Generation permGen() {
return perm().asGen();
} }
}

View File

@ -37,13 +37,13 @@ public class SystemDictionary {
private static AddressField loaderConstraintTableField; private static AddressField loaderConstraintTableField;
private static sun.jvm.hotspot.types.OopField javaSystemLoaderField; private static sun.jvm.hotspot.types.OopField javaSystemLoaderField;
private static sun.jvm.hotspot.types.OopField objectKlassField; private static AddressField objectKlassField;
private static sun.jvm.hotspot.types.OopField classLoaderKlassField; private static AddressField classLoaderKlassField;
private static sun.jvm.hotspot.types.OopField stringKlassField; private static AddressField stringKlassField;
private static sun.jvm.hotspot.types.OopField systemKlassField; private static AddressField systemKlassField;
private static sun.jvm.hotspot.types.OopField threadKlassField; private static AddressField threadKlassField;
private static sun.jvm.hotspot.types.OopField threadGroupKlassField; private static AddressField threadGroupKlassField;
private static sun.jvm.hotspot.types.OopField methodHandleKlassField; private static AddressField methodHandleKlassField;
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
@ -62,13 +62,13 @@ public class SystemDictionary {
loaderConstraintTableField = type.getAddressField("_loader_constraints"); loaderConstraintTableField = type.getAddressField("_loader_constraints");
javaSystemLoaderField = type.getOopField("_java_system_loader"); javaSystemLoaderField = type.getOopField("_java_system_loader");
objectKlassField = type.getOopField(WK_KLASS("Object_klass")); objectKlassField = type.getAddressField(WK_KLASS("Object_klass"));
classLoaderKlassField = type.getOopField(WK_KLASS("ClassLoader_klass")); classLoaderKlassField = type.getAddressField(WK_KLASS("ClassLoader_klass"));
stringKlassField = type.getOopField(WK_KLASS("String_klass")); stringKlassField = type.getAddressField(WK_KLASS("String_klass"));
systemKlassField = type.getOopField(WK_KLASS("System_klass")); systemKlassField = type.getAddressField(WK_KLASS("System_klass"));
threadKlassField = type.getOopField(WK_KLASS("Thread_klass")); threadKlassField = type.getAddressField(WK_KLASS("Thread_klass"));
threadGroupKlassField = type.getOopField(WK_KLASS("ThreadGroup_klass")); threadGroupKlassField = type.getAddressField(WK_KLASS("ThreadGroup_klass"));
methodHandleKlassField = type.getOopField(WK_KLASS("MethodHandle_klass")); methodHandleKlassField = type.getAddressField(WK_KLASS("MethodHandle_klass"));
} }
// This WK functions must follow the definitions in systemDictionary.hpp: // This WK functions must follow the definitions in systemDictionary.hpp:
@ -104,31 +104,31 @@ public class SystemDictionary {
// few well known classes -- not all are added here. // few well known classes -- not all are added here.
// add more if needed. // add more if needed.
public static InstanceKlass getThreadKlass() { public static InstanceKlass getThreadKlass() {
return (InstanceKlass) newOop(threadKlassField.getValue()); return (InstanceKlass)Metadata.instantiateWrapperFor(threadKlassField.getValue());
} }
public static InstanceKlass getThreadGroupKlass() { public static InstanceKlass getThreadGroupKlass() {
return (InstanceKlass) newOop(threadGroupKlassField.getValue()); return (InstanceKlass)Metadata.instantiateWrapperFor(threadGroupKlassField.getValue());
} }
public static InstanceKlass getObjectKlass() { public static InstanceKlass getObjectKlass() {
return (InstanceKlass) newOop(objectKlassField.getValue()); return (InstanceKlass)Metadata.instantiateWrapperFor(objectKlassField.getValue());
} }
public static InstanceKlass getStringKlass() { public static InstanceKlass getStringKlass() {
return (InstanceKlass) newOop(stringKlassField.getValue()); return (InstanceKlass)Metadata.instantiateWrapperFor(stringKlassField.getValue());
} }
public static InstanceKlass getClassLoaderKlass() { public static InstanceKlass getClassLoaderKlass() {
return (InstanceKlass) newOop(classLoaderKlassField.getValue()); return (InstanceKlass)Metadata.instantiateWrapperFor(classLoaderKlassField.getValue());
} }
public static InstanceKlass getSystemKlass() { public static InstanceKlass getSystemKlass() {
return (InstanceKlass) newOop(systemKlassField.getValue()); return (InstanceKlass)Metadata.instantiateWrapperFor(systemKlassField.getValue());
} }
public static InstanceKlass getMethodHandleKlass() { public static InstanceKlass getMethodHandleKlass() {
return (InstanceKlass) newOop(methodHandleKlassField.getValue()); return (InstanceKlass)Metadata.instantiateWrapperFor(methodHandleKlassField.getValue());
} }
public InstanceKlass getAbstractOwnableSynchronizerKlass() { public InstanceKlass getAbstractOwnableSynchronizerKlass() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -42,17 +42,14 @@ public class Universe {
private static sun.jvm.hotspot.types.OopField systemThreadGroupField; private static sun.jvm.hotspot.types.OopField systemThreadGroupField;
// single dimensional primitive array klasses // single dimensional primitive array klasses
private static sun.jvm.hotspot.types.OopField boolArrayKlassObjField; private static sun.jvm.hotspot.types.AddressField boolArrayKlassField;
private static sun.jvm.hotspot.types.OopField byteArrayKlassObjField; private static sun.jvm.hotspot.types.AddressField byteArrayKlassField;
private static sun.jvm.hotspot.types.OopField charArrayKlassObjField; private static sun.jvm.hotspot.types.AddressField charArrayKlassField;
private static sun.jvm.hotspot.types.OopField intArrayKlassObjField; private static sun.jvm.hotspot.types.AddressField intArrayKlassField;
private static sun.jvm.hotspot.types.OopField shortArrayKlassObjField; private static sun.jvm.hotspot.types.AddressField shortArrayKlassField;
private static sun.jvm.hotspot.types.OopField longArrayKlassObjField; private static sun.jvm.hotspot.types.AddressField longArrayKlassField;
private static sun.jvm.hotspot.types.OopField singleArrayKlassObjField; private static sun.jvm.hotspot.types.AddressField singleArrayKlassField;
private static sun.jvm.hotspot.types.OopField doubleArrayKlassObjField; private static sun.jvm.hotspot.types.AddressField doubleArrayKlassField;
// system obj array klass object
private static sun.jvm.hotspot.types.OopField systemObjArrayKlassObjField;
private static AddressField narrowOopBaseField; private static AddressField narrowOopBaseField;
private static CIntegerField narrowOopShiftField; private static CIntegerField narrowOopShiftField;
@ -78,16 +75,14 @@ public class Universe {
mainThreadGroupField = type.getOopField("_main_thread_group"); mainThreadGroupField = type.getOopField("_main_thread_group");
systemThreadGroupField = type.getOopField("_system_thread_group"); systemThreadGroupField = type.getOopField("_system_thread_group");
boolArrayKlassObjField = type.getOopField("_boolArrayKlassObj"); boolArrayKlassField = type.getAddressField("_boolArrayKlassObj");
byteArrayKlassObjField = type.getOopField("_byteArrayKlassObj"); byteArrayKlassField = type.getAddressField("_byteArrayKlassObj");
charArrayKlassObjField = type.getOopField("_charArrayKlassObj"); charArrayKlassField = type.getAddressField("_charArrayKlassObj");
intArrayKlassObjField = type.getOopField("_intArrayKlassObj"); intArrayKlassField = type.getAddressField("_intArrayKlassObj");
shortArrayKlassObjField = type.getOopField("_shortArrayKlassObj"); shortArrayKlassField = type.getAddressField("_shortArrayKlassObj");
longArrayKlassObjField = type.getOopField("_longArrayKlassObj"); longArrayKlassField = type.getAddressField("_longArrayKlassObj");
singleArrayKlassObjField = type.getOopField("_singleArrayKlassObj"); singleArrayKlassField = type.getAddressField("_singleArrayKlassObj");
doubleArrayKlassObjField = type.getOopField("_doubleArrayKlassObj"); doubleArrayKlassField = type.getAddressField("_doubleArrayKlassObj");
systemObjArrayKlassObjField = type.getOopField("_systemObjArrayKlassObj");
narrowOopBaseField = type.getAddressField("_narrow_oop._base"); narrowOopBaseField = type.getAddressField("_narrow_oop._base");
narrowOopShiftField = type.getCIntegerField("_narrow_oop._shift"); narrowOopShiftField = type.getCIntegerField("_narrow_oop._shift");
@ -138,21 +133,17 @@ public class Universe {
return newOop(systemThreadGroupField.getValue()); return newOop(systemThreadGroupField.getValue());
} }
public Oop systemObjArrayKlassObj() {
return newOop(systemObjArrayKlassObjField.getValue());
}
// iterate through the single dimensional primitive array klasses // iterate through the single dimensional primitive array klasses
// refer to basic_type_classes_do(void f(klassOop)) in universe.cpp // refer to basic_type_classes_do(void f(Klass*)) in universe.cpp
public void basicTypeClassesDo(SystemDictionary.ClassVisitor visitor) { public void basicTypeClassesDo(SystemDictionary.ClassVisitor visitor) {
visitor.visit((Klass)newOop(boolArrayKlassObjField.getValue())); visitor.visit(new TypeArrayKlass(boolArrayKlassField.getValue()));
visitor.visit((Klass)newOop(byteArrayKlassObjField.getValue())); visitor.visit(new TypeArrayKlass(byteArrayKlassField.getValue()));
visitor.visit((Klass)newOop(charArrayKlassObjField.getValue())); visitor.visit(new TypeArrayKlass(charArrayKlassField.getValue()));
visitor.visit((Klass)newOop(intArrayKlassObjField.getValue())); visitor.visit(new TypeArrayKlass(intArrayKlassField.getValue()));
visitor.visit((Klass)newOop(shortArrayKlassObjField.getValue())); visitor.visit(new TypeArrayKlass(shortArrayKlassField.getValue()));
visitor.visit((Klass)newOop(longArrayKlassObjField.getValue())); visitor.visit(new TypeArrayKlass(longArrayKlassField.getValue()));
visitor.visit((Klass)newOop(singleArrayKlassObjField.getValue())); visitor.visit(new TypeArrayKlass(singleArrayKlassField.getValue()));
visitor.visit((Klass)newOop(doubleArrayKlassObjField.getValue())); visitor.visit(new TypeArrayKlass(doubleArrayKlassField.getValue()));
} }
public void print() { printOn(System.out); } public void print() { printOn(System.out); }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -57,7 +57,7 @@ public class AccessFlags implements /* imports */ ClassConstants {
public long getValue () { return flags; } public long getValue () { return flags; }
// Hotspot internal flags // Hotspot internal flags
// methodOop flags // Method* flags
public boolean isMonitorMatching () { return (flags & JVM_ACC_MONITOR_MATCH ) != 0; } public boolean isMonitorMatching () { return (flags & JVM_ACC_MONITOR_MATCH ) != 0; }
public boolean hasMonitorBytecodes () { return (flags & JVM_ACC_HAS_MONITOR_BYTECODES ) != 0; } public boolean hasMonitorBytecodes () { return (flags & JVM_ACC_HAS_MONITOR_BYTECODES ) != 0; }
public boolean hasLoops () { return (flags & JVM_ACC_HAS_LOOPS ) != 0; } public boolean hasLoops () { return (flags & JVM_ACC_HAS_LOOPS ) != 0; }
@ -69,13 +69,13 @@ public class AccessFlags implements /* imports */ ClassConstants {
public boolean hasJsrs () { return (flags & JVM_ACC_HAS_JSRS ) != 0; } public boolean hasJsrs () { return (flags & JVM_ACC_HAS_JSRS ) != 0; }
public boolean isObsolete () { return (flags & JVM_ACC_IS_OBSOLETE ) != 0; } public boolean isObsolete () { return (flags & JVM_ACC_IS_OBSOLETE ) != 0; }
// klassOop flags // Klass* flags
public boolean hasMirandaMethods () { return (flags & JVM_ACC_HAS_MIRANDA_METHODS ) != 0; } public boolean hasMirandaMethods () { return (flags & JVM_ACC_HAS_MIRANDA_METHODS ) != 0; }
public boolean hasVanillaConstructor() { return (flags & JVM_ACC_HAS_VANILLA_CONSTRUCTOR) != 0; } public boolean hasVanillaConstructor() { return (flags & JVM_ACC_HAS_VANILLA_CONSTRUCTOR) != 0; }
public boolean hasFinalizer () { return (flags & JVM_ACC_HAS_FINALIZER ) != 0; } public boolean hasFinalizer () { return (flags & JVM_ACC_HAS_FINALIZER ) != 0; }
public boolean isCloneable () { return (flags & JVM_ACC_IS_CLONEABLE ) != 0; } public boolean isCloneable () { return (flags & JVM_ACC_IS_CLONEABLE ) != 0; }
// klassOop and methodOop flags // Klass* and Method* flags
public boolean hasLocalVariableTable() { return (flags & JVM_ACC_HAS_LOCAL_VARIABLE_TABLE ) != 0; } public boolean hasLocalVariableTable() { return (flags & JVM_ACC_HAS_LOCAL_VARIABLE_TABLE ) != 0; }
// field flags // field flags

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -59,7 +59,7 @@ public class Array extends Oop {
if (headerSize != 0) { if (headerSize != 0) {
return headerSize; return headerSize;
} }
if (VM.getVM().isCompressedOopsEnabled()) { if (VM.getVM().isCompressedHeadersEnabled()) {
headerSize = typeSize; headerSize = typeSize;
} else { } else {
headerSize = VM.getVM().alignUp(typeSize + VM.getVM().getIntSize(), headerSize = VM.getVM().alignUp(typeSize + VM.getVM().getIntSize(),
@ -80,7 +80,7 @@ public class Array extends Oop {
if (lengthOffsetInBytes != 0) { if (lengthOffsetInBytes != 0) {
return lengthOffsetInBytes; return lengthOffsetInBytes;
} }
if (VM.getVM().isCompressedOopsEnabled()) { if (VM.getVM().isCompressedHeadersEnabled()) {
lengthOffsetInBytes = typeSize - VM.getVM().getIntSize(); lengthOffsetInBytes = typeSize - VM.getVM().getIntSize();
} else { } else {
lengthOffsetInBytes = typeSize; lengthOffsetInBytes = typeSize;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -49,10 +49,6 @@ abstract class ArrayData extends ProfileData {
int aindex = index + arrayStartOffSet; int aindex = index + arrayStartOffSet;
return intAt(aindex); return intAt(aindex);
} }
Oop arrayOopAt(int index) {
int aindex = index + arrayStartOffSet;
return oopAt(aindex);
}
// Code generation support for subclasses. // Code generation support for subclasses.
static int arrayElementOffset(int index) { static int arrayElementOffset(int index) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -45,24 +45,24 @@ public class ArrayKlass extends Klass {
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("arrayKlass"); Type type = db.lookupType("arrayKlass");
dimension = new CIntField(type.getCIntegerField("_dimension"), Oop.getHeaderSize()); dimension = new CIntField(type.getCIntegerField("_dimension"), 0);
higherDimension = new OopField(type.getOopField("_higher_dimension"), Oop.getHeaderSize()); higherDimension = new MetadataField(type.getAddressField("_higher_dimension"), 0);
lowerDimension = new OopField(type.getOopField("_lower_dimension"), Oop.getHeaderSize()); lowerDimension = new MetadataField(type.getAddressField("_lower_dimension"), 0);
vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize()); vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0);
allocSize = new CIntField(type.getCIntegerField("_alloc_size"), Oop.getHeaderSize()); allocSize = new CIntField(type.getCIntegerField("_alloc_size"), 0);
componentMirror = new OopField(type.getOopField("_component_mirror"), Oop.getHeaderSize()); componentMirror = new OopField(type.getOopField("_component_mirror"), 0);
javaLangCloneableName = null; javaLangCloneableName = null;
javaLangObjectName = null; javaLangObjectName = null;
javaIoSerializableName = null; javaIoSerializableName = null;
} }
ArrayKlass(OopHandle handle, ObjectHeap heap) { public ArrayKlass(Address addr) {
super(handle, heap); super(addr);
} }
private static CIntField dimension; private static CIntField dimension;
private static OopField higherDimension; private static MetadataField higherDimension;
private static OopField lowerDimension; private static MetadataField lowerDimension;
private static CIntField vtableLen; private static CIntField vtableLen;
private static CIntField allocSize; private static CIntField allocSize;
private static OopField componentMirror; private static OopField componentMirror;
@ -141,19 +141,13 @@ public class ArrayKlass extends Klass {
tty.print("ArrayKlass"); tty.print("ArrayKlass");
} }
public long getObjectSize() { public void iterateFields(MetadataVisitor visitor) {
return alignObjectSize(InstanceKlass.getHeaderSize() + getVtableLen() * getHeap().getOopSize()); super.iterateFields(visitor);
}
public void iterateFields(OopVisitor visitor, boolean doVMFields) {
super.iterateFields(visitor, doVMFields);
if (doVMFields) {
visitor.doCInt(dimension, true); visitor.doCInt(dimension, true);
visitor.doOop(higherDimension, true); visitor.doMetadata(higherDimension, true);
visitor.doOop(lowerDimension, true); visitor.doMetadata(lowerDimension, true);
visitor.doCInt(vtableLen, true); visitor.doCInt(vtableLen, true);
visitor.doCInt(allocSize, true); visitor.doCInt(allocSize, true);
visitor.doOop(componentMirror, true); visitor.doOop(componentMirror, true);
} }
} }
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
package sun.jvm.hotspot.oops; package sun.jvm.hotspot.oops;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.VMObject;
// The class for a boolean field simply provides access to the value. // The class for a boolean field simply provides access to the value.
public class BooleanField extends Field { public class BooleanField extends Field {
@ -41,6 +42,7 @@ public class BooleanField extends Field {
} }
public boolean getValue(Oop obj) { return obj.getHandle().getJBooleanAt(getOffset()); } public boolean getValue(Oop obj) { return obj.getHandle().getJBooleanAt(getOffset()); }
public boolean getValue(VMObject obj) { return obj.getAddress().getJBooleanAt(getOffset()); }
public void setValue(Oop obj, boolean value) throws MutationException { public void setValue(Oop obj, boolean value) throws MutationException {
// Fix this: setJBooleanAt is missing in Address // Fix this: setJBooleanAt is missing in Address
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
package sun.jvm.hotspot.oops; package sun.jvm.hotspot.oops;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.VMObject;
// The class for a byte field simply provides access to the value. // The class for a byte field simply provides access to the value.
public class ByteField extends Field { public class ByteField extends Field {
@ -41,6 +42,7 @@ public class ByteField extends Field {
} }
public byte getValue(Oop obj) { return obj.getHandle().getJByteAt(getOffset()); } public byte getValue(Oop obj) { return obj.getHandle().getJByteAt(getOffset()); }
public byte getValue(VMObject obj) { return obj.getAddress().getJByteAt(getOffset()); }
public void setValue(Oop obj, char value) throws MutationException { public void setValue(Oop obj, char value) throws MutationException {
// Fix this: setJCharAt is missing in Address // Fix this: setJCharAt is missing in Address
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
package sun.jvm.hotspot.oops; package sun.jvm.hotspot.oops;
import sun.jvm.hotspot.runtime.VMObject;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
// The class for an C int field simply provides access to the value. // The class for an C int field simply provides access to the value.
@ -39,7 +40,10 @@ public class CIntField extends Field {
private boolean isUnsigned; private boolean isUnsigned;
public long getValue(Oop obj) { public long getValue(Oop obj) {
return obj.getHandle().getCIntegerAt(getOffset(), size, isUnsigned); return getValue(obj.getHandle());
}
public long getValue(VMObject obj) {
return getValue(obj.getAddress());
} }
public long getValue(Address addr) { public long getValue(Address addr) {
return addr.getCIntegerAt(getOffset(), size, isUnsigned); return addr.getCIntegerAt(getOffset(), size, isUnsigned);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
package sun.jvm.hotspot.oops; package sun.jvm.hotspot.oops;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.VMObject;
// The class for a char field simply provides access to the value. // The class for a char field simply provides access to the value.
public class CharField extends Field { public class CharField extends Field {
@ -41,6 +42,7 @@ public class CharField extends Field {
} }
public char getValue(Oop obj) { return obj.getHandle().getJCharAt(getOffset()); } public char getValue(Oop obj) { return obj.getHandle().getJCharAt(getOffset()); }
public char getValue(VMObject obj) { return obj.getAddress().getJCharAt(getOffset()); }
public void setValue(Oop obj, char value) throws MutationException { public void setValue(Oop obj, char value) throws MutationException {
// Fix this: setJCharAt is missing in Address // Fix this: setJCharAt is missing in Address
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -48,10 +48,10 @@ public class CheckedExceptionElement {
private static long offsetOfClassCPIndex; private static long offsetOfClassCPIndex;
private OopHandle handle; private Address handle;
private long offset; private long offset;
public CheckedExceptionElement(OopHandle handle, long offset) { public CheckedExceptionElement(Address handle, long offset) {
this.handle = handle; this.handle = handle;
this.offset = offset; this.offset = offset;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,7 +30,7 @@ import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
public class CompiledICHolder extends Oop { public class CompiledICHolder extends VMObject {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -40,14 +40,14 @@ public class CompiledICHolder extends Oop {
} }
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("compiledICHolderOopDesc"); Type type = db.lookupType("CompiledICHolder");
holderMethod = new OopField(type.getOopField("_holder_method"), 0); holderMethod = new MetadataField(type.getAddressField("_holder_method"), 0);
holderKlass = new OopField(type.getOopField("_holder_klass"), 0); holderKlass = new MetadataField(type.getAddressField("_holder_klass"), 0);
headerSize = type.getSize(); headerSize = type.getSize();
} }
CompiledICHolder(OopHandle handle, ObjectHeap heap) { public CompiledICHolder(Address addr) {
super(handle, heap); super(addr);
} }
public boolean isCompiledICHolder() { return true; } public boolean isCompiledICHolder() { return true; }
@ -55,8 +55,8 @@ public class CompiledICHolder extends Oop {
private static long headerSize; private static long headerSize;
// Fields // Fields
private static OopField holderMethod; private static MetadataField holderMethod;
private static OopField holderKlass; private static MetadataField holderKlass;
// Accessors for declared fields // Accessors for declared fields
public Method getHolderMethod() { return (Method) holderMethod.getValue(this); } public Method getHolderMethod() { return (Method) holderMethod.getValue(this); }
@ -65,16 +65,4 @@ public class CompiledICHolder extends Oop {
public void printValueOn(PrintStream tty) { public void printValueOn(PrintStream tty) {
tty.print("CompiledICHolder"); tty.print("CompiledICHolder");
} }
public long getObjectSize() {
return alignObjectSize(headerSize);
} }
void iterateFields(OopVisitor visitor, boolean doVMFields) {
super.iterateFields(visitor, doVMFields);
if (doVMFields) {
visitor.doOop(holderMethod, true);
visitor.doOop(holderKlass, true);
}
}
}

View File

@ -34,7 +34,7 @@ import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
import sun.jvm.hotspot.utilities.*; import sun.jvm.hotspot.utilities.*;
public class ConstMethod extends Oop { public class ConstMethod extends VMObject {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -50,18 +50,18 @@ public class ConstMethod extends Oop {
private static int HAS_EXCEPTION_TABLE; private static int HAS_EXCEPTION_TABLE;
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("constMethodOopDesc"); Type type = db.lookupType("ConstMethod");
constants = new OopField(type.getOopField("_constants"), 0); constants = new MetadataField(type.getAddressField("_constants"), 0);
constMethodSize = new CIntField(type.getCIntegerField("_constMethod_size"), 0); constMethodSize = new CIntField(type.getCIntegerField("_constMethod_size"), 0);
flags = new ByteField(type.getJByteField("_flags"), 0); flags = new ByteField(type.getJByteField("_flags"), 0);
// enum constants for flags // enum constants for flags
HAS_LINENUMBER_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_linenumber_table").intValue(); HAS_LINENUMBER_TABLE = db.lookupIntConstant("ConstMethod::_has_linenumber_table").intValue();
HAS_CHECKED_EXCEPTIONS = db.lookupIntConstant("constMethodOopDesc::_has_checked_exceptions").intValue(); HAS_CHECKED_EXCEPTIONS = db.lookupIntConstant("ConstMethod::_has_checked_exceptions").intValue();
HAS_LOCALVARIABLE_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_localvariable_table").intValue(); HAS_LOCALVARIABLE_TABLE = db.lookupIntConstant("ConstMethod::_has_localvariable_table").intValue();
HAS_EXCEPTION_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_exception_table").intValue(); HAS_EXCEPTION_TABLE = db.lookupIntConstant("ConstMethod::_has_exception_table").intValue();
// Size of Java bytecodes allocated immediately after constMethodOop. // Size of Java bytecodes allocated immediately after ConstMethod*.
codeSize = new CIntField(type.getCIntegerField("_code_size"), 0); codeSize = new CIntField(type.getCIntegerField("_code_size"), 0);
nameIndex = new CIntField(type.getCIntegerField("_name_index"), 0); nameIndex = new CIntField(type.getCIntegerField("_name_index"), 0);
signatureIndex = new CIntField(type.getCIntegerField("_signature_index"), 0); signatureIndex = new CIntField(type.getCIntegerField("_signature_index"), 0);
@ -81,12 +81,12 @@ public class ConstMethod extends Oop {
exceptionTableElementSize = type.getSize(); exceptionTableElementSize = type.getSize();
} }
ConstMethod(OopHandle handle, ObjectHeap heap) { public ConstMethod(Address addr) {
super(handle, heap); super(addr);
} }
// Fields // Fields
private static OopField constants; private static MetadataField constants;
private static CIntField constMethodSize; private static CIntField constMethodSize;
private static ByteField flags; private static ByteField flags;
private static CIntField codeSize; private static CIntField codeSize;
@ -104,8 +104,8 @@ public class ConstMethod extends Oop {
public Method getMethod() { public Method getMethod() {
InstanceKlass ik = (InstanceKlass)getConstants().getPoolHolder(); InstanceKlass ik = (InstanceKlass)getConstants().getPoolHolder();
ObjArray methods = ik.getMethods(); MethodArray methods = ik.getMethods();
return (Method)methods.getObjAt(getIdNum()); return methods.at((int)getIdNum());
} }
// Accessors for declared fields // Accessors for declared fields
@ -157,7 +157,7 @@ public class ConstMethod extends Oop {
/** Get a bytecode or breakpoint at the given bci */ /** Get a bytecode or breakpoint at the given bci */
public int getBytecodeOrBPAt(int bci) { public int getBytecodeOrBPAt(int bci) {
return getHandle().getJByteAt(bytecodeOffset + bci) & 0xFF; return getAddress().getJByteAt(bytecodeOffset + bci) & 0xFF;
} }
public byte getBytecodeByteArg(int bci) { public byte getBytecodeByteArg(int bci) {
@ -215,23 +215,21 @@ public class ConstMethod extends Oop {
for( int i=0; i < bc.length; i++ ) for( int i=0; i < bc.length; i++ )
{ {
long offs = bytecodeOffset + i; long offs = bytecodeOffset + i;
bc[i] = getHandle().getJByteAt( offs ); bc[i] = getAddress().getJByteAt( offs );
} }
return bc; return bc;
} }
public long getObjectSize() { public long getSize() {
return getConstMethodSize() * getHeap().getOopSize(); return getConstMethodSize();
} }
public void printValueOn(PrintStream tty) { public void printValueOn(PrintStream tty) {
tty.print("ConstMethod " + getName().asString() + getSignature().asString() + "@" + getHandle()); tty.print("ConstMethod " + getName().asString() + getSignature().asString() + "@" + getAddress());
} }
public void iterateFields(OopVisitor visitor, boolean doVMFields) { public void iterateFields(MetadataVisitor visitor) {
super.iterateFields(visitor, doVMFields); visitor.doMetadata(constants, true);
if (doVMFields) {
visitor.doOop(constants, true);
visitor.doCInt(constMethodSize, true); visitor.doCInt(constMethodSize, true);
visitor.doByte(flags, true); visitor.doByte(flags, true);
visitor.doCInt(codeSize, true); visitor.doCInt(codeSize, true);
@ -240,7 +238,6 @@ public class ConstMethod extends Oop {
visitor.doCInt(genericSignatureIndex, true); visitor.doCInt(genericSignatureIndex, true);
visitor.doCInt(codeSize, true); visitor.doCInt(codeSize, true);
} }
}
// Accessors // Accessors
@ -266,7 +263,7 @@ public class ConstMethod extends Oop {
// The line numbers are a short array of 2-tuples [start_pc, line_number]. // The line numbers are a short array of 2-tuples [start_pc, line_number].
// Not necessarily sorted and not necessarily one-to-one. // Not necessarily sorted and not necessarily one-to-one.
CompressedLineNumberReadStream stream = CompressedLineNumberReadStream stream =
new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable());
while (stream.readPair()) { while (stream.readPair()) {
if (stream.bci() == bci) { if (stream.bci() == bci) {
// perfect match // perfect match
@ -290,7 +287,7 @@ public class ConstMethod extends Oop {
} }
int len = getLineNumberTableLength(); int len = getLineNumberTableLength();
CompressedLineNumberReadStream stream = CompressedLineNumberReadStream stream =
new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable());
LineNumberTableElement[] ret = new LineNumberTableElement[len]; LineNumberTableElement[] ret = new LineNumberTableElement[len];
for (int idx = 0; idx < len; idx++) { for (int idx = 0; idx < len; idx++) {
@ -316,7 +313,7 @@ public class ConstMethod extends Oop {
LocalVariableTableElement[] ret = new LocalVariableTableElement[getLocalVariableTableLength()]; LocalVariableTableElement[] ret = new LocalVariableTableElement[getLocalVariableTableLength()];
long offset = offsetOfLocalVariableTable(); long offset = offsetOfLocalVariableTable();
for (int i = 0; i < ret.length; i++) { for (int i = 0; i < ret.length; i++) {
ret[i] = new LocalVariableTableElement(getHandle(), offset); ret[i] = new LocalVariableTableElement(getAddress(), offset);
offset += localVariableTableElementSize; offset += localVariableTableElementSize;
} }
return ret; return ret;
@ -333,7 +330,7 @@ public class ConstMethod extends Oop {
ExceptionTableElement[] ret = new ExceptionTableElement[getExceptionTableLength()]; ExceptionTableElement[] ret = new ExceptionTableElement[getExceptionTableLength()];
long offset = offsetOfExceptionTable(); long offset = offsetOfExceptionTable();
for (int i = 0; i < ret.length; i++) { for (int i = 0; i < ret.length; i++) {
ret[i] = new ExceptionTableElement(getHandle(), offset); ret[i] = new ExceptionTableElement(getAddress(), offset);
offset += exceptionTableElementSize; offset += exceptionTableElementSize;
} }
return ret; return ret;
@ -350,7 +347,7 @@ public class ConstMethod extends Oop {
CheckedExceptionElement[] ret = new CheckedExceptionElement[getCheckedExceptionsLength()]; CheckedExceptionElement[] ret = new CheckedExceptionElement[getCheckedExceptionsLength()];
long offset = offsetOfCheckedExceptions(); long offset = offsetOfCheckedExceptions();
for (int i = 0; i < ret.length; i++) { for (int i = 0; i < ret.length; i++) {
ret[i] = new CheckedExceptionElement(getHandle(), offset); ret[i] = new CheckedExceptionElement(getAddress(), offset);
offset += checkedExceptionElementSize; offset += checkedExceptionElementSize;
} }
return ret; return ret;
@ -370,14 +367,14 @@ public class ConstMethod extends Oop {
return bytecodeOffset + getCodeSize(); return bytecodeOffset + getCodeSize();
} }
// Offset of start of compressed line number table (see methodOop.hpp) // Offset of start of compressed line number table (see method.hpp)
private long offsetOfCompressedLineNumberTable() { private long offsetOfCompressedLineNumberTable() {
return offsetOfCodeEnd() + (isNative() ? 2 * VM.getVM().getAddressSize() : 0); return offsetOfCodeEnd() + (isNative() ? 2 * VM.getVM().getAddressSize() : 0);
} }
// Offset of last short in methodOop // Offset of last short in Method*
private long offsetOfLastU2Element() { private long offsetOfLastU2Element() {
return getObjectSize() - 2; return getSize() * VM.getVM().getObjectHeap().getOopSize() - 2;
} }
private long offsetOfCheckedExceptionsLength() { private long offsetOfCheckedExceptionsLength() {
@ -386,7 +383,7 @@ public class ConstMethod extends Oop {
private int getCheckedExceptionsLength() { private int getCheckedExceptionsLength() {
if (hasCheckedExceptions()) { if (hasCheckedExceptions()) {
return (int) getHandle().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true); return (int) getAddress().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true);
} else { } else {
return 0; return 0;
} }
@ -407,7 +404,7 @@ public class ConstMethod extends Oop {
int len = 0; int len = 0;
if (hasLineNumberTable()) { if (hasLineNumberTable()) {
CompressedLineNumberReadStream stream = CompressedLineNumberReadStream stream =
new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable());
while (stream.readPair()) { while (stream.readPair()) {
len += 1; len += 1;
} }
@ -417,7 +414,7 @@ public class ConstMethod extends Oop {
private int getLocalVariableTableLength() { private int getLocalVariableTableLength() {
if (hasLocalVariableTable()) { if (hasLocalVariableTable()) {
return (int) getHandle().getCIntegerAt(offsetOfLocalVariableTableLength(), 2, true); return (int) getAddress().getCIntegerAt(offsetOfLocalVariableTableLength(), 2, true);
} else { } else {
return 0; return 0;
} }
@ -450,7 +447,7 @@ public class ConstMethod extends Oop {
private int getExceptionTableLength() { private int getExceptionTableLength() {
if (hasExceptionTable()) { if (hasExceptionTable()) {
return (int) getHandle().getCIntegerAt(offsetOfExceptionTableLength(), 2, true); return (int) getAddress().getCIntegerAt(offsetOfExceptionTableLength(), 2, true);
} else { } else {
return 0; return 0;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,8 +34,7 @@ import sun.jvm.hotspot.utilities.*;
// A ConstantPool is an oop containing class constants // A ConstantPool is an oop containing class constants
// as described in the class file // as described in the class file
public class ConstantPool extends Oop implements ClassConstants { public class ConstantPool extends Metadata implements ClassConstants {
public class CPSlot { public class CPSlot {
private Address ptr; private Address ptr;
@ -46,24 +45,20 @@ public class ConstantPool extends Oop implements ClassConstants {
this.ptr = sym.getAddress().orWithMask(1); this.ptr = sym.getAddress().orWithMask(1);
} }
public boolean isOop() { public boolean isResolved() {
return (ptr.minus(null) & 1) == 0; return (ptr.minus(null) & 1) == 0;
} }
public boolean isMetaData() { public boolean isUnresolved() {
return (ptr.minus(null) & 1) == 1; return (ptr.minus(null) & 1) == 1;
} }
public Symbol getSymbol() { public Symbol getSymbol() {
if (isMetaData()) { if (!isUnresolved()) throw new InternalError("not a symbol");
return Symbol.create(ptr.xorWithMask(1)); return Symbol.create(ptr.xorWithMask(1));
} }
throw new InternalError("not a symbol"); public Klass getKlass() {
} if (!isResolved()) throw new InternalError("not klass");
public Oop getOop() { return (Klass)Metadata.instantiateWrapperFor(ptr);
if (isOop()) {
return VM.getVM().getObjectHeap().newOop(ptr.addOffsetToAsOopHandle(0));
}
throw new InternalError("not an oop");
} }
} }
@ -83,31 +78,35 @@ public class ConstantPool extends Oop implements ClassConstants {
} }
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("constantPoolOopDesc"); Type type = db.lookupType("ConstantPool");
tags = new OopField(type.getOopField("_tags"), 0); tags = type.getAddressField("_tags");
operands = new OopField(type.getOopField("_operands"), 0); operands = type.getAddressField("_operands");
cache = new OopField(type.getOopField("_cache"), 0); cache = type.getAddressField("_cache");
poolHolder = new OopField(type.getOopField("_pool_holder"), 0); poolHolder = new MetadataField(type.getAddressField("_pool_holder"), 0);
length = new CIntField(type.getCIntegerField("_length"), 0); length = new CIntField(type.getCIntegerField("_length"), 0);
resolvedReferences = type.getAddressField("_resolved_references");
referenceMap = type.getAddressField("_reference_map");
headerSize = type.getSize(); headerSize = type.getSize();
elementSize = 0; elementSize = 0;
// fetch constants: // fetch constants:
INDY_BSM_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_bsm_offset").intValue(); INDY_BSM_OFFSET = db.lookupIntConstant("ConstantPool::_indy_bsm_offset").intValue();
INDY_ARGC_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_argc_offset").intValue(); INDY_ARGC_OFFSET = db.lookupIntConstant("ConstantPool::_indy_argc_offset").intValue();
INDY_ARGV_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_argv_offset").intValue(); INDY_ARGV_OFFSET = db.lookupIntConstant("ConstantPool::_indy_argv_offset").intValue();
} }
ConstantPool(OopHandle handle, ObjectHeap heap) { public ConstantPool(Address addr) {
super(handle, heap); super(addr);
} }
public boolean isConstantPool() { return true; } public boolean isConstantPool() { return true; }
private static OopField tags; private static AddressField tags;
private static OopField operands; private static AddressField operands;
private static OopField cache; private static AddressField cache;
private static OopField poolHolder; private static MetadataField poolHolder;
private static CIntField length; // number of elements in oop private static CIntField length; // number of elements in oop
private static AddressField resolvedReferences;
private static AddressField referenceMap;
private static long headerSize; private static long headerSize;
private static long elementSize; private static long elementSize;
@ -116,11 +115,31 @@ public class ConstantPool extends Oop implements ClassConstants {
private static int INDY_ARGC_OFFSET; private static int INDY_ARGC_OFFSET;
private static int INDY_ARGV_OFFSET; private static int INDY_ARGV_OFFSET;
public TypeArray getTags() { return (TypeArray) tags.getValue(this); } public U1Array getTags() { return new U1Array(tags.getValue(getAddress())); }
public TypeArray getOperands() { return (TypeArray) operands.getValue(this); } public U2Array getOperands() { return new U2Array(operands.getValue(getAddress())); }
public ConstantPoolCache getCache() { return (ConstantPoolCache) cache.getValue(this); } public ConstantPoolCache getCache() {
Address addr = cache.getValue(getAddress());
return (ConstantPoolCache) VMObjectFactory.newObject(ConstantPoolCache.class, addr);
}
public Klass getPoolHolder() { return (Klass) poolHolder.getValue(this); } public Klass getPoolHolder() { return (Klass) poolHolder.getValue(this); }
public int getLength() { return (int)length.getValue(this); } public int getLength() { return (int)length.getValue(getAddress()); }
public Oop getResolvedReferences() {
Address handle = resolvedReferences.getValue(getAddress());
if (handle != null) {
// Load through the handle
OopHandle refs = handle.getOopHandleAt(0);
return VM.getVM().getObjectHeap().newOop(refs);
}
return null;
}
public U2Array referenceMap() {
return new U2Array(referenceMap.getValue(getAddress()));
}
public int objectToCPIndex(int index) {
return referenceMap().at(index);
}
private long getElementSize() { private long getElementSize() {
if (elementSize !=0 ) { if (elementSize !=0 ) {
@ -139,33 +158,32 @@ public class ConstantPool extends Oop implements ClassConstants {
} }
public ConstantTag getTagAt(long index) { public ConstantTag getTagAt(long index) {
return new ConstantTag(getTags().getByteAt((int) index)); return new ConstantTag((byte)getTags().at((int) index));
} }
public CPSlot getSlotAt(long index) { public CPSlot getSlotAt(long index) {
return new CPSlot(getHandle().getAddressAt(indexOffset(index))); return new CPSlot(getAddressAtRaw(index));
} }
public Oop getObjAtRaw(long index){ public Address getAddressAtRaw(long index) {
return getHeap().newOop(getHandle().getOopHandleAt(indexOffset(index))); return getAddress().getAddressAt(indexOffset(index));
} }
public Symbol getSymbolAt(long index) { public Symbol getSymbolAt(long index) {
CPSlot slot = getSlotAt(index); return Symbol.create(getAddressAtRaw(index));
return slot.getSymbol();
} }
public int getIntAt(long index){ public int getIntAt(long index){
return getHandle().getJIntAt(indexOffset(index)); return getAddress().getJIntAt(indexOffset(index));
} }
public float getFloatAt(long index){ public float getFloatAt(long index){
return getHandle().getJFloatAt(indexOffset(index)); return getAddress().getJFloatAt(indexOffset(index));
} }
public long getLongAt(long index) { public long getLongAt(long index) {
int oneHalf = getHandle().getJIntAt(indexOffset(index + 1)); int oneHalf = getAddress().getJIntAt(indexOffset(index + 1));
int otherHalf = getHandle().getJIntAt(indexOffset(index)); int otherHalf = getAddress().getJIntAt(indexOffset(index));
// buildLongFromIntsPD accepts higher address value, lower address value // buildLongFromIntsPD accepts higher address value, lower address value
// in that order. // in that order.
return VM.getVM().buildLongFromIntsPD(oneHalf, otherHalf); return VM.getVM().buildLongFromIntsPD(oneHalf, otherHalf);
@ -185,7 +203,7 @@ public class ConstantPool extends Oop implements ClassConstants {
i = which; i = which;
} else { } else {
// change byte-ordering and go via cache // change byte-ordering and go via cache
i = cache.getEntryAt(0xFFFF & VM.getVM().getBytes().swapShort((short) which)).getConstantPoolIndex(); i = cache.getEntryAt(0xFFFF & which).getConstantPoolIndex();
} }
if (Assert.ASSERTS_ENABLED) { if (Assert.ASSERTS_ENABLED) {
Assert.that(getTagAt(i).isFieldOrMethod(), "Corrupted constant pool"); Assert.that(getTagAt(i).isFieldOrMethod(), "Corrupted constant pool");
@ -202,7 +220,7 @@ public class ConstantPool extends Oop implements ClassConstants {
public int[] getNameAndTypeAt(int which) { public int[] getNameAndTypeAt(int which) {
if (Assert.ASSERTS_ENABLED) { if (Assert.ASSERTS_ENABLED) {
Assert.that(getTagAt(which).isNameAndType(), "Corrupted constant pool"); Assert.that(getTagAt(which).isNameAndType(), "Corrupted constant pool: " + which + " " + getTagAt(which));
} }
int i = getIntAt(which); int i = getIntAt(which);
if (DEBUG) { if (DEBUG) {
@ -215,6 +233,10 @@ public class ConstantPool extends Oop implements ClassConstants {
return implGetNameRefAt(which, false); return implGetNameRefAt(which, false);
} }
public Symbol uncachedGetNameRefAt(int which) {
return implGetNameRefAt(which, true);
}
private Symbol implGetNameRefAt(int which, boolean uncached) { private Symbol implGetNameRefAt(int which, boolean uncached) {
int signatureIndex = getNameRefIndexAt(implNameAndTypeRefIndexAt(which, uncached)); int signatureIndex = getNameRefIndexAt(implNameAndTypeRefIndexAt(which, uncached));
return getSymbolAt(signatureIndex); return getSymbolAt(signatureIndex);
@ -224,35 +246,57 @@ public class ConstantPool extends Oop implements ClassConstants {
return implGetSignatureRefAt(which, false); return implGetSignatureRefAt(which, false);
} }
public Symbol uncachedGetSignatureRefAt(int which) {
return implGetSignatureRefAt(which, true);
}
private Symbol implGetSignatureRefAt(int which, boolean uncached) { private Symbol implGetSignatureRefAt(int which, boolean uncached) {
int signatureIndex = getSignatureRefIndexAt(implNameAndTypeRefIndexAt(which, uncached)); int signatureIndex = getSignatureRefIndexAt(implNameAndTypeRefIndexAt(which, uncached));
return getSymbolAt(signatureIndex); return getSymbolAt(signatureIndex);
} }
public static boolean isInvokedynamicIndex(int i) { return (i < 0); }
public static int decodeInvokedynamicIndex(int i) { Assert.that(isInvokedynamicIndex(i), ""); return ~i; }
// The invokedynamic points at the object index. The object map points at
// the cpCache index and the cpCache entry points at the original constant
// pool index.
public int invokedynamicCPCacheIndex(int index) {
Assert.that(isInvokedynamicIndex(index), "should be a invokedynamic index");
int rawIndex = decodeInvokedynamicIndex(index);
return referenceMap().at(rawIndex);
}
ConstantPoolCacheEntry invokedynamicCPCacheEntryAt(int index) {
// decode index that invokedynamic points to.
int cpCacheIndex = invokedynamicCPCacheIndex(index);
return getCache().getEntryAt(cpCacheIndex);
}
private int implNameAndTypeRefIndexAt(int which, boolean uncached) { private int implNameAndTypeRefIndexAt(int which, boolean uncached) {
int i = which; int i = which;
if (!uncached && getCache() != null) { if (!uncached && getCache() != null) {
if (ConstantPoolCache.isSecondaryIndex(which)) { if (isInvokedynamicIndex(which)) {
// Invokedynamic index. // Invokedynamic index is index into resolved_references
int pool_index = getCache().getMainEntryAt(which).getConstantPoolIndex(); int poolIndex = invokedynamicCPCacheEntryAt(which).getConstantPoolIndex();
pool_index = invokeDynamicNameAndTypeRefIndexAt(pool_index); poolIndex = invokeDynamicNameAndTypeRefIndexAt(poolIndex);
// assert(tagAt(pool_index).isNameAndType(), ""); Assert.that(getTagAt(poolIndex).isNameAndType(), "");
return pool_index; return poolIndex;
} }
// change byte-ordering and go via cache // change byte-ordering and go via cache
i = remapInstructionOperandFromCache(which); i = remapInstructionOperandFromCache(which);
} else { } else {
if (getTagAt(which).isInvokeDynamic()) { if (getTagAt(which).isInvokeDynamic()) {
int pool_index = invokeDynamicNameAndTypeRefIndexAt(which); int poolIndex = invokeDynamicNameAndTypeRefIndexAt(which);
// assert(tag_at(pool_index).is_name_and_type(), ""); Assert.that(getTagAt(poolIndex).isNameAndType(), "");
return pool_index; return poolIndex;
} }
} }
// assert(tag_at(i).is_field_or_method(), "Corrupted constant pool"); // assert(tag_at(i).is_field_or_method(), "Corrupted constant pool");
// assert(!tag_at(i).is_invoke_dynamic(), "Must be handled above"); // assert(!tag_at(i).is_invoke_dynamic(), "Must be handled above");
int ref_index = getIntAt(i); int refIndex = getIntAt(i);
return extractHighShortFromInt(ref_index); return extractHighShortFromInt(refIndex);
} }
private int remapInstructionOperandFromCache(int operand) { private int remapInstructionOperandFromCache(int operand) {
@ -269,16 +313,29 @@ public class ConstantPool extends Oop implements ClassConstants {
} }
// returns null, if not resolved. // returns null, if not resolved.
public Klass getKlassRefAt(int which) { public Klass getKlassAt(int which) {
if( ! getTagAt(which).isKlass()) return null; if( ! getTagAt(which).isKlass()) return null;
return (Klass) getObjAtRaw(which); return (Klass)Metadata.instantiateWrapperFor(getAddressAtRaw(which));
}
public Symbol getKlassNameAt(int which) {
CPSlot entry = getSlotAt(which);
if (entry.isResolved()) {
return entry.getKlass().getName();
} else {
return entry.getSymbol();
}
}
public Symbol getUnresolvedStringAt(int which) {
return getSymbolAt(which);
} }
// returns null, if not resolved. // returns null, if not resolved.
public InstanceKlass getFieldOrMethodKlassRefAt(int which) { public InstanceKlass getFieldOrMethodKlassRefAt(int which) {
int refIndex = getFieldOrMethodAt(which); int refIndex = getFieldOrMethodAt(which);
int klassIndex = extractLowShortFromInt(refIndex); int klassIndex = extractLowShortFromInt(refIndex);
return (InstanceKlass) getKlassRefAt(klassIndex); return (InstanceKlass) getKlassAt(klassIndex);
} }
// returns null, if not resolved. // returns null, if not resolved.
@ -371,16 +428,16 @@ public class ConstantPool extends Oop implements ClassConstants {
Assert.that(getTagAt(i).isInvokeDynamic(), "Corrupted constant pool"); Assert.that(getTagAt(i).isInvokeDynamic(), "Corrupted constant pool");
} }
int bsmSpec = extractLowShortFromInt(this.getIntAt(i)); int bsmSpec = extractLowShortFromInt(this.getIntAt(i));
TypeArray operands = getOperands(); U2Array operands = getOperands();
if (operands == null) return null; // safety first if (operands == null) return null; // safety first
int basePos = VM.getVM().buildIntFromShorts(operands.getShortAt(bsmSpec * 2 + 0), int basePos = VM.getVM().buildIntFromShorts(operands.at(bsmSpec * 2 + 0),
operands.getShortAt(bsmSpec * 2 + 1)); operands.at(bsmSpec * 2 + 1));
int argv = basePos + INDY_ARGV_OFFSET; int argv = basePos + INDY_ARGV_OFFSET;
int argc = operands.getShortAt(basePos + INDY_ARGC_OFFSET); int argc = operands.at(basePos + INDY_ARGC_OFFSET);
int endPos = argv + argc; int endPos = argv + argc;
short[] values = new short[endPos - basePos]; short[] values = new short[endPos - basePos];
for (int j = 0; j < values.length; j++) { for (int j = 0; j < values.length; j++) {
values[j] = operands.getShortAt(basePos+j); values[j] = operands.at(basePos+j);
} }
return values; return values;
} }
@ -407,25 +464,24 @@ public class ConstantPool extends Oop implements ClassConstants {
case JVM_CONSTANT_InvokeDynamic: return "JVM_CONSTANT_InvokeDynamic"; case JVM_CONSTANT_InvokeDynamic: return "JVM_CONSTANT_InvokeDynamic";
case JVM_CONSTANT_Invalid: return "JVM_CONSTANT_Invalid"; case JVM_CONSTANT_Invalid: return "JVM_CONSTANT_Invalid";
case JVM_CONSTANT_UnresolvedClass: return "JVM_CONSTANT_UnresolvedClass"; case JVM_CONSTANT_UnresolvedClass: return "JVM_CONSTANT_UnresolvedClass";
case JVM_CONSTANT_UnresolvedClassInError: return "JVM_CONSTANT_UnresolvedClassInError";
case JVM_CONSTANT_ClassIndex: return "JVM_CONSTANT_ClassIndex"; case JVM_CONSTANT_ClassIndex: return "JVM_CONSTANT_ClassIndex";
case JVM_CONSTANT_UnresolvedString: return "JVM_CONSTANT_UnresolvedString";
case JVM_CONSTANT_StringIndex: return "JVM_CONSTANT_StringIndex"; case JVM_CONSTANT_StringIndex: return "JVM_CONSTANT_StringIndex";
case JVM_CONSTANT_UnresolvedClassInError: return "JVM_CONSTANT_UnresolvedClassInError";
case JVM_CONSTANT_MethodHandleInError:return "JVM_CONSTANT_MethodHandleInError";
case JVM_CONSTANT_MethodTypeInError: return "JVM_CONSTANT_MethodTypeInError";
case JVM_CONSTANT_Object: return "JVM_CONSTANT_Object";
} }
throw new InternalError("Unknown tag: " + tag); throw new InternalError("Unknown tag: " + tag);
} }
public void iterateFields(OopVisitor visitor, boolean doVMFields) { public void iterateFields(MetadataVisitor visitor) {
super.iterateFields(visitor, doVMFields); super.iterateFields(visitor);
if (doVMFields) { visitor.doMetadata(poolHolder, true);
visitor.doOop(tags, true);
visitor.doOop(cache, true);
visitor.doOop(poolHolder, true);
final int length = (int) getLength(); final int length = (int) getLength();
// zero'th pool entry is always invalid. ignore it. // zero'th pool entry is always invalid. ignore it.
for (int index = 1; index < length; index++) { for (int index = 1; index < length; index++) {
int ctag = (int) getTags().getByteAt((int) index); int ctag = (int) getTags().at((int) index);
switch (ctag) { switch (ctag) {
case JVM_CONSTANT_ClassIndex: case JVM_CONSTANT_ClassIndex:
case JVM_CONSTANT_StringIndex: case JVM_CONSTANT_StringIndex:
@ -452,7 +508,6 @@ public class ConstantPool extends Oop implements ClassConstants {
case JVM_CONSTANT_UnresolvedClassInError: case JVM_CONSTANT_UnresolvedClassInError:
case JVM_CONSTANT_UnresolvedClass: case JVM_CONSTANT_UnresolvedClass:
case JVM_CONSTANT_Class: case JVM_CONSTANT_Class:
case JVM_CONSTANT_UnresolvedString:
case JVM_CONSTANT_Utf8: case JVM_CONSTANT_Utf8:
visitor.doOop(new OopField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true); visitor.doOop(new OopField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true);
break; break;
@ -469,27 +524,19 @@ public class ConstantPool extends Oop implements ClassConstants {
} }
} }
} }
/*
int length = getLength();
for (int index = 0; index < length; index++) {
long offset = baseOffset + (index + typeDataBase.getOopSize());
visitor.doOop(new IndexableField(index, offset, false), getObjAt(index));
}
*/
}
public void writeBytes(OutputStream os) throws IOException { public void writeBytes(OutputStream os) throws IOException {
// Map between any modified UTF-8 and it's constant pool index. // Map between any modified UTF-8 and it's constant pool index.
Map utf8ToIndex = new HashMap(); Map utf8ToIndex = new HashMap();
DataOutputStream dos = new DataOutputStream(os); DataOutputStream dos = new DataOutputStream(os);
TypeArray tags = getTags(); U1Array tags = getTags();
int len = (int)getLength(); int len = (int)getLength();
int ci = 0; // constant pool index int ci = 0; // constant pool index
// collect all modified UTF-8 Strings from Constant Pool // collect all modified UTF-8 Strings from Constant Pool
for (ci = 1; ci < len; ci++) { for (ci = 1; ci < len; ci++) {
byte cpConstType = tags.getByteAt(ci); int cpConstType = tags.at(ci);
if(cpConstType == JVM_CONSTANT_Utf8) { if(cpConstType == JVM_CONSTANT_Utf8) {
Symbol sym = getSymbolAt(ci); Symbol sym = getSymbolAt(ci);
utf8ToIndex.put(sym.asString(), new Short((short) ci)); utf8ToIndex.put(sym.asString(), new Short((short) ci));
@ -502,7 +549,7 @@ public class ConstantPool extends Oop implements ClassConstants {
for(ci = 1; ci < len; ci++) { for(ci = 1; ci < len; ci++) {
int cpConstType = (int)tags.getByteAt(ci); int cpConstType = tags.at(ci);
// write cp_info // write cp_info
// write constant type // write constant type
switch(cpConstType) { switch(cpConstType) {
@ -548,8 +595,8 @@ public class ConstantPool extends Oop implements ClassConstants {
case JVM_CONSTANT_Class: { case JVM_CONSTANT_Class: {
dos.writeByte(cpConstType); dos.writeByte(cpConstType);
// Klass already resolved. ConstantPool constains klassOop. // Klass already resolved. ConstantPool constains Klass*.
Klass refKls = (Klass) getObjAtRaw(ci); Klass refKls = (Klass)Metadata.instantiateWrapperFor(getAddressAtRaw(ci));
String klassName = refKls.getName().asString(); String klassName = refKls.getName().asString();
Short s = (Short) utf8ToIndex.get(klassName); Short s = (Short) utf8ToIndex.get(klassName);
dos.writeShort(s.shortValue()); dos.writeShort(s.shortValue());
@ -570,24 +617,13 @@ public class ConstantPool extends Oop implements ClassConstants {
case JVM_CONSTANT_String: { case JVM_CONSTANT_String: {
dos.writeByte(cpConstType); dos.writeByte(cpConstType);
String str = OopUtilities.stringOopToString(getObjAtRaw(ci)); String str = getUnresolvedStringAt(ci).asString();
Short s = (Short) utf8ToIndex.get(str); Short s = (Short) utf8ToIndex.get(str);
dos.writeShort(s.shortValue()); dos.writeShort(s.shortValue());
if (DEBUG) debugMessage("CP[" + ci + "] = string " + s); if (DEBUG) debugMessage("CP[" + ci + "] = string " + s);
break; break;
} }
// case JVM_CONSTANT_StringIndex:
case JVM_CONSTANT_UnresolvedString: {
dos.writeByte(JVM_CONSTANT_String);
String val = getSymbolAt(ci).asString();
Short s = (Short) utf8ToIndex.get(val);
dos.writeShort(s.shortValue());
if (DEBUG) debugMessage("CP[" + ci + "] = string " + s);
break;
}
// all external, internal method/field references // all external, internal method/field references
case JVM_CONSTANT_Fieldref: case JVM_CONSTANT_Fieldref:
case JVM_CONSTANT_Methodref: case JVM_CONSTANT_Methodref:
@ -618,12 +654,21 @@ public class ConstantPool extends Oop implements ClassConstants {
case JVM_CONSTANT_MethodHandle: { case JVM_CONSTANT_MethodHandle: {
dos.writeByte(cpConstType); dos.writeByte(cpConstType);
int value = getIntAt(ci); int value = getIntAt(ci);
short nameIndex = (short) extractLowShortFromInt(value); byte refKind = (byte) extractLowShortFromInt(value);
short signatureIndex = (short) extractHighShortFromInt(value); short memberIndex = (short) extractHighShortFromInt(value);
dos.writeShort(nameIndex); dos.writeByte(refKind);
dos.writeShort(signatureIndex); dos.writeShort(memberIndex);
if (DEBUG) debugMessage("CP[" + ci + "] = N&T name = " + nameIndex if (DEBUG) debugMessage("CP[" + ci + "] = MH kind = " +
+ ", type = " + signatureIndex); refKind + ", mem = " + memberIndex);
break;
}
case JVM_CONSTANT_MethodType: {
dos.writeByte(cpConstType);
int value = getIntAt(ci);
short refIndex = (short) value;
dos.writeShort(refIndex);
if (DEBUG) debugMessage("CP[" + ci + "] = MT index = " + refIndex);
break; break;
} }
@ -634,13 +679,13 @@ public class ConstantPool extends Oop implements ClassConstants {
short nameAndTypeIndex = (short) extractHighShortFromInt(value); short nameAndTypeIndex = (short) extractHighShortFromInt(value);
dos.writeShort(bsmIndex); dos.writeShort(bsmIndex);
dos.writeShort(nameAndTypeIndex); dos.writeShort(nameAndTypeIndex);
if (DEBUG) debugMessage("CP[" + ci + "] = indy BSM = " + bsmIndex if (DEBUG) debugMessage("CP[" + ci + "] = INDY bsm = " +
+ ", N&T = " + nameAndTypeIndex); bsmIndex + ", N&T = " + nameAndTypeIndex);
break; break;
} }
default: default:
throw new InternalError("unknown tag: " + cpConstType); throw new InternalError("Unknown tag: " + cpConstType);
} // switch } // switch
} }
dos.flush(); dos.flush();
@ -648,16 +693,11 @@ public class ConstantPool extends Oop implements ClassConstants {
} }
public void printValueOn(PrintStream tty) { public void printValueOn(PrintStream tty) {
Oop holder = poolHolder.getValue(this); tty.print("ConstantPool for " + getPoolHolder().getName().asString());
if (holder instanceof Klass) {
tty.print("ConstantPool for " + ((Klass)holder).getName().asString());
} else {
tty.print("ConstantPool for partially loaded class");
}
} }
public long getObjectSize() { public long getSize() {
return alignObjectSize(headerSize + (getLength() * getElementSize())); return Oop.alignObjectSize(headerSize + getLength());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -665,12 +705,12 @@ public class ConstantPool extends Oop implements ClassConstants {
// //
private static int extractHighShortFromInt(int val) { private static int extractHighShortFromInt(int val) {
// must stay in sync with constantPoolOopDesc::name_and_type_at_put, method_at_put, etc. // must stay in sync with ConstantPool::name_and_type_at_put, method_at_put, etc.
return (val >> 16) & 0xFFFF; return (val >> 16) & 0xFFFF;
} }
private static int extractLowShortFromInt(int val) { private static int extractLowShortFromInt(int val) {
// must stay in sync with constantPoolOopDesc::name_and_type_at_put, method_at_put, etc. // must stay in sync with ConstantPool::name_and_type_at_put, method_at_put, etc.
return val & 0xFFFF; return val & 0xFFFF;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,10 +31,10 @@ import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
import sun.jvm.hotspot.utilities.*; import sun.jvm.hotspot.utilities.*;
// ConstantPoolCache : A constant pool cache (constantPoolCacheOopDesc). // ConstantPoolCache : A constant pool cache (ConstantPoolCache).
// See cpCacheOop.hpp for details about this class. // See cpCache.hpp for details about this class.
// //
public class ConstantPoolCache extends Oop { public class ConstantPoolCache extends Metadata {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -44,31 +44,33 @@ public class ConstantPoolCache extends Oop {
} }
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("constantPoolCacheOopDesc"); Type type = db.lookupType("ConstantPoolCache");
constants = new OopField(type.getOopField("_constant_pool"), 0); constants = new MetadataField(type.getAddressField("_constant_pool"), 0);
baseOffset = type.getSize(); baseOffset = type.getSize();
Type elType = db.lookupType("ConstantPoolCacheEntry"); Type elType = db.lookupType("ConstantPoolCacheEntry");
elementSize = elType.getSize(); elementSize = elType.getSize();
length = new CIntField(type.getCIntegerField("_length"), 0); length = new CIntField(type.getCIntegerField("_length"), 0);
intSize = VM.getVM().getObjectHeap().getIntSize();
} }
ConstantPoolCache(OopHandle handle, ObjectHeap heap) { public ConstantPoolCache(Address addr) {
super(handle, heap); super(addr);
} }
public boolean isConstantPoolCache() { return true; } public boolean isConstantPoolCache() { return true; }
private static OopField constants; private static MetadataField constants;
private static long baseOffset; private static long baseOffset;
private static long elementSize; private static long elementSize;
private static CIntField length; private static CIntField length;
private static long intSize;
public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); }
public long getObjectSize() { public long getSize() {
return alignObjectSize(baseOffset + getLength() * elementSize); return Oop.alignObjectSize(baseOffset + getLength() * elementSize);
} }
public ConstantPoolCacheEntry getEntryAt(int i) { public ConstantPoolCacheEntry getEntryAt(int i) {
@ -76,41 +78,10 @@ public class ConstantPoolCache extends Oop {
return new ConstantPoolCacheEntry(this, i); return new ConstantPoolCacheEntry(this, i);
} }
public static boolean isSecondaryIndex(int i) { return (i < 0); }
public static int decodeSecondaryIndex(int i) { return isSecondaryIndex(i) ? ~i : i; }
public static int encodeSecondaryIndex(int i) { return !isSecondaryIndex(i) ? ~i : i; }
// secondary entries hold invokedynamic call site bindings
public ConstantPoolCacheEntry getSecondaryEntryAt(int i) {
int rawIndex = i;
if (isSecondaryIndex(i)) {
rawIndex = decodeSecondaryIndex(i);
}
ConstantPoolCacheEntry e = getEntryAt(rawIndex);
if (Assert.ASSERTS_ENABLED) {
Assert.that(e.isSecondaryEntry(), "must be a secondary entry:" + rawIndex);
}
return e;
}
public ConstantPoolCacheEntry getMainEntryAt(int i) {
int primaryIndex = i;
if (isSecondaryIndex(i)) {
// run through an extra level of indirection:
int rawIndex = decodeSecondaryIndex(i);
primaryIndex = getEntryAt(rawIndex).getMainEntryIndex();
}
ConstantPoolCacheEntry e = getEntryAt(primaryIndex);
if (Assert.ASSERTS_ENABLED) {
Assert.that(!e.isSecondaryEntry(), "must not be a secondary entry:" + primaryIndex);
}
return e;
}
public int getIntAt(int entry, int fld) { public int getIntAt(int entry, int fld) {
//alignObjectSize ? //alignObjectSize ?
long offset = baseOffset + /*alignObjectSize*/entry * elementSize + fld* getHeap().getIntSize(); long offset = baseOffset + /*alignObjectSize*/entry * elementSize + fld * intSize;
return (int) getHandle().getCIntegerAt(offset, getHeap().getIntSize(), true ); return (int) getAddress().getCIntegerAt(offset, intSize, true );
} }
@ -119,17 +90,15 @@ public class ConstantPoolCache extends Oop {
} }
public int getLength() { public int getLength() {
return (int) length.getValue(this); return (int) length.getValue(getAddress());
} }
public void iterateFields(OopVisitor visitor, boolean doVMFields) { public void iterateFields(MetadataVisitor visitor) {
super.iterateFields(visitor, doVMFields); super.iterateFields(visitor);
if (doVMFields) { visitor.doMetadata(constants, true);
visitor.doOop(constants, true);
for (int i = 0; i < getLength(); i++) { for (int i = 0; i < getLength(); i++) {
ConstantPoolCacheEntry entry = getEntryAt(i); ConstantPoolCacheEntry entry = getEntryAt(i);
entry.iterateFields(visitor); entry.iterateFields(visitor);
} }
} }
}
}; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,7 +34,7 @@ public class ConstantPoolCacheEntry {
private static long size; private static long size;
private static long baseOffset; private static long baseOffset;
private static CIntegerField indices; private static CIntegerField indices;
private static sun.jvm.hotspot.types.OopField f1; private static AddressField f1;
private static CIntegerField f2; private static CIntegerField f2;
private static CIntegerField flags; private static CIntegerField flags;
@ -54,11 +54,11 @@ public class ConstantPoolCacheEntry {
size = type.getSize(); size = type.getSize();
indices = type.getCIntegerField("_indices"); indices = type.getCIntegerField("_indices");
f1 = type.getOopField ("_f1"); f1 = type.getAddressField ("_f1");
f2 = type.getCIntegerField("_f2"); f2 = type.getCIntegerField("_f2");
flags = type.getCIntegerField("_flags"); flags = type.getCIntegerField("_flags");
type = db.lookupType("constantPoolCacheOopDesc"); type = db.lookupType("ConstantPoolCache");
baseOffset = type.getSize(); baseOffset = type.getSize();
} }
@ -69,43 +69,32 @@ public class ConstantPoolCacheEntry {
public int getConstantPoolIndex() { public int getConstantPoolIndex() {
if (Assert.ASSERTS_ENABLED) { if (Assert.ASSERTS_ENABLED) {
Assert.that(!isSecondaryEntry(), "must not be a secondary CP entry"); Assert.that((getIndices() & 0xFFFF) != 0, "must be main entry");
} }
return (int) (getIndices() & 0xFFFF); return (int) (getIndices() & 0xFFFF);
} }
public boolean isSecondaryEntry() {
return (getIndices() & 0xFFFF) == 0;
}
public int getMainEntryIndex() {
if (Assert.ASSERTS_ENABLED) {
Assert.that(isSecondaryEntry(), "must be a secondary CP entry");
}
return (int) (getIndices() >>> 16);
}
private long getIndices() { private long getIndices() {
return cp.getHandle().getCIntegerAt(indices.getOffset() + offset, indices.getSize(), indices.isUnsigned()); return cp.getAddress().getCIntegerAt(indices.getOffset() + offset, indices.getSize(), indices.isUnsigned());
} }
public Oop getF1() { public Metadata getF1() {
return cp.getHeap().newOop(cp.getHandle().getOopHandleAt(f1.getOffset() + offset)); return Metadata.instantiateWrapperFor(cp.getAddress().getAddressAt(f1.getOffset() + offset));
} }
public int getF2() { public int getF2() {
return cp.getHandle().getJIntAt(f1.getOffset() + offset); return cp.getAddress().getJIntAt(f1.getOffset() + offset);
} }
public int getFlags() { public int getFlags() {
return cp.getHandle().getJIntAt(flags.getOffset() + offset); return cp.getAddress().getJIntAt(flags.getOffset() + offset);
} }
static NamedFieldIdentifier f1FieldName = new NamedFieldIdentifier("_f1"); static NamedFieldIdentifier f1FieldName = new NamedFieldIdentifier("_f1");
static NamedFieldIdentifier f2FieldName = new NamedFieldIdentifier("_f2"); static NamedFieldIdentifier f2FieldName = new NamedFieldIdentifier("_f2");
static NamedFieldIdentifier flagsFieldName = new NamedFieldIdentifier("_flags"); static NamedFieldIdentifier flagsFieldName = new NamedFieldIdentifier("_flags");
public void iterateFields(OopVisitor visitor) { public void iterateFields(MetadataVisitor visitor) {
visitor.doOop(new OopField(f1FieldName, f1.getOffset() + offset, true), true); visitor.doOop(new OopField(f1FieldName, f1.getOffset() + offset, true), true);
visitor.doInt(new IntField(f2FieldName, f2.getOffset() + offset, true), true); visitor.doInt(new IntField(f2FieldName, f2.getOffset() + offset, true), true);
visitor.doInt(new IntField(flagsFieldName, flags.getOffset() + offset, true), true); visitor.doInt(new IntField(flagsFieldName, flags.getOffset() + offset, true), true);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -64,7 +64,7 @@ public class DataLayout {
private boolean handlized; private boolean handlized;
public DataLayout(MethodData d, int o) { public DataLayout(MethodData d, int o) {
data = d.getHandle(); data = d.getAddress();
offset = o; offset = o;
} }
@ -89,15 +89,6 @@ public class DataLayout {
return (int)data.getCIntegerAt(offset + cellOffset(index), MethodData.cellSize, false); return (int)data.getCIntegerAt(offset + cellOffset(index), MethodData.cellSize, false);
} }
Oop oopAt(int index) {
OopHandle handle;
if (handlized) {
throw new InternalError("unsupported");
}
handle = data.getOopHandleAt(offset + cellOffset(index));
return VM.getVM().getObjectHeap().newOop(handle);
}
public Address addressAt(int index) { public Address addressAt(int index) {
OopHandle handle; OopHandle handle;
if (handlized) { if (handlized) {

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.oops;
import sun.jvm.hotspot.debugger.Address;
/** A DefaultMetadataVisitor implements basic no-op MetadataVisitor
functionality except that the setObj() and getObj() methods are
implemented properly. */
abstract public class DefaultMetadataVisitor implements MetadataVisitor {
private Metadata obj;
public void prologue() {}
// Called after visiting an object
public void epilogue() {}
public void setObj(Metadata obj) {
this.obj = obj;
}
public Metadata getObj() {
return obj;
}
// Callback methods for each field type in an object
abstract public void doMetadata(MetadataField field, boolean isVMField);
public void doOop(OopField field, boolean isVMField) {}
public void doOop(NarrowOopField field, boolean isVMField) {}
public void doByte(ByteField field, boolean isVMField) {}
public void doChar(CharField field, boolean isVMField) {}
public void doBoolean(BooleanField field, boolean isVMField) {}
public void doShort(ShortField field, boolean isVMField) {}
public void doInt(IntField field, boolean isVMField) {}
public void doLong(LongField field, boolean isVMField) {}
public void doFloat(FloatField field, boolean isVMField) {}
public void doDouble(DoubleField field, boolean isVMField) {}
public void doCInt(CIntField field, boolean isVMField) {}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -45,6 +45,7 @@ public class DefaultOopVisitor implements OopVisitor {
} }
// Callback methods for each field type in an object // Callback methods for each field type in an object
public void doMetadata(MetadataField field, boolean isVMField) {}
public void doOop(OopField field, boolean isVMField) {} public void doOop(OopField field, boolean isVMField) {}
public void doOop(NarrowOopField field, boolean isVMField) {} public void doOop(NarrowOopField field, boolean isVMField) {}
public void doByte(ByteField field, boolean isVMField) {} public void doByte(ByteField field, boolean isVMField) {}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
package sun.jvm.hotspot.oops; package sun.jvm.hotspot.oops;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.VMObject;
// The class for a double field simply provides access to the value. // The class for a double field simply provides access to the value.
public class DoubleField extends Field { public class DoubleField extends Field {
@ -41,6 +42,7 @@ public class DoubleField extends Field {
} }
public double getValue(Oop obj) { return obj.getHandle().getJDoubleAt(getOffset()); } public double getValue(Oop obj) { return obj.getHandle().getJDoubleAt(getOffset()); }
public double getValue(VMObject obj) { return obj.getAddress().getJDoubleAt(getOffset()); }
public void setValue(Oop obj, double value) throws MutationException { public void setValue(Oop obj, double value) throws MutationException {
// Fix this: setJDoubleAt is missing in Address // Fix this: setJDoubleAt is missing in Address
} }

View File

@ -54,10 +54,10 @@ public class ExceptionTableElement {
private static long offsetOfHandlerPC; private static long offsetOfHandlerPC;
private static long offsetOfCatchTypeIndex; private static long offsetOfCatchTypeIndex;
private OopHandle handle; private Address handle;
private long offset; private long offset;
public ExceptionTableElement(OopHandle handle, long offset) { public ExceptionTableElement(Address handle, long offset) {
this.handle = handle; this.handle = handle;
this.offset = offset; this.offset = offset;
} }
@ -78,4 +78,3 @@ public class ExceptionTableElement {
return (int) handle.getCIntegerAt(offset + offsetOfCatchTypeIndex, 2, true); return (int) handle.getCIntegerAt(offset + offsetOfCatchTypeIndex, 2, true);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,7 @@ package sun.jvm.hotspot.oops;
import java.io.*; import java.io.*;
import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.utilities.*;
// Super class for all fields in an object // Super class for all fields in an object
public class Field { public class Field {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,35 +24,21 @@
package sun.jvm.hotspot.oops; package sun.jvm.hotspot.oops;
import java.io.*; // An OopVisitor can be used to inspect all fields within an object.
import java.util.*; // Fields include vm fields, java fields, indexable fields.
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*;
public class TypeArrayKlassKlass extends ArrayKlassKlass { public interface FieldVisitor {
static { // Callback methods for each field type in an object
VM.registerVMInitializedObserver(new Observer() { public void doMetadata(MetadataField field, boolean isVMField);
public void update(Observable o, Object data) { public void doOop(OopField field, boolean isVMField);
initialize(VM.getVM().getTypeDataBase()); public void doOop(NarrowOopField field, boolean isVMField);
} public void doByte(ByteField field, boolean isVMField);
}); public void doChar(CharField field, boolean isVMField);
} public void doBoolean(BooleanField field, boolean isVMField);
public void doShort(ShortField field, boolean isVMField);
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { public void doInt(IntField field, boolean isVMField);
Type type = db.lookupType("typeArrayKlassKlass"); public void doLong(LongField field, boolean isVMField);
headerSize = type.getSize() + Oop.getHeaderSize(); public void doFloat(FloatField field, boolean isVMField);
} public void doDouble(DoubleField field, boolean isVMField);
public void doCInt(CIntField field, boolean isVMField);
public TypeArrayKlassKlass(OopHandle handle, ObjectHeap heap) {
super(handle, heap);
}
private static long headerSize;
public long getObjectSize() { return alignObjectSize(headerSize); }
public void printValueOn(PrintStream tty) {
tty.print("TypeArrayKlassKlass");
}
}; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
package sun.jvm.hotspot.oops; package sun.jvm.hotspot.oops;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.VMObject;
// The class for a float field simply provides access to the value. // The class for a float field simply provides access to the value.
public class FloatField extends Field { public class FloatField extends Field {
@ -41,6 +42,7 @@ public class FloatField extends Field {
} }
public float getValue(Oop obj) { return obj.getHandle().getJFloatAt(getOffset()); } public float getValue(Oop obj) { return obj.getHandle().getJFloatAt(getOffset()); }
public float getValue(VMObject obj) { return obj.getAddress().getJFloatAt(getOffset()); }
public void setValue(Oop obj, float value) throws MutationException { public void setValue(Oop obj, float value) throws MutationException {
// Fix this: setJFloatAt is missing in Address // Fix this: setJFloatAt is missing in Address
} }

View File

@ -613,7 +613,7 @@ public class GenerateOopMap {
tty.print(" idx " + idx); tty.print(" idx " + idx);
/* /*
int idx = currentBC.getIndexU2(); int idx = currentBC.getIndexU2();
constantPoolOop cp = method().constants(); ConstantPool* cp = method().constants();
int nameAndTypeIdx = cp.name_and_type_ref_index_at(idx); int nameAndTypeIdx = cp.name_and_type_ref_index_at(idx);
int signatureIdx = cp.signature_ref_index_at(nameAndTypeIdx); int signatureIdx = cp.signature_ref_index_at(nameAndTypeIdx);
Symbol* signature = cp.symbol_at(signatureIdx); Symbol* signature = cp.symbol_at(signatureIdx);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -53,7 +53,7 @@ public class Instance extends Oop {
// Returns header size in bytes. // Returns header size in bytes.
public static long getHeaderSize() { public static long getHeaderSize() {
if (VM.getVM().isCompressedOopsEnabled()) { if (VM.getVM().isCompressedHeadersEnabled()) {
return typeSize - VM.getVM().getIntSize(); return typeSize - VM.getVM().getIntSize();
} else { } else {
return typeSize; return typeSize;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,10 +27,14 @@ package sun.jvm.hotspot.oops;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
import sun.jvm.hotspot.utilities.*;
public class ArrayKlassKlass extends KlassKlass { // An InstanceKlass is the VM level representation of a Java class.
public class InstanceClassLoaderKlass extends InstanceKlass {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -40,19 +44,11 @@ public class ArrayKlassKlass extends KlassKlass {
} }
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("arrayKlassKlass"); // Just make sure it's there for now
headerSize = type.getSize() + Oop.getHeaderSize(); Type type = db.lookupType("InstanceClassLoaderKlass");
} }
ArrayKlassKlass(OopHandle handle, ObjectHeap heap) { public InstanceClassLoaderKlass(Address addr) {
super(handle, heap); super(addr);
}
private static long headerSize;
public long getObjectSize() { return alignObjectSize(headerSize); }
public void printValueOn(PrintStream tty) {
tty.print("ArrayKlassKlass");
} }
} }

View File

@ -26,6 +26,7 @@ package sun.jvm.hotspot.oops;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import sun.jvm.hotspot.classfile.ClassLoaderData;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.memory.*; import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.runtime.*;
@ -53,7 +54,6 @@ public class InstanceKlass extends Klass {
private static int FIELD_SLOTS; private static int FIELD_SLOTS;
// ClassState constants // ClassState constants
private static int CLASS_STATE_UNPARSABLE_BY_GC;
private static int CLASS_STATE_ALLOCATED; private static int CLASS_STATE_ALLOCATED;
private static int CLASS_STATE_LOADED; private static int CLASS_STATE_LOADED;
private static int CLASS_STATE_LINKED; private static int CLASS_STATE_LINKED;
@ -62,34 +62,34 @@ public class InstanceKlass extends Klass {
private static int CLASS_STATE_INITIALIZATION_ERROR; private static int CLASS_STATE_INITIALIZATION_ERROR;
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("instanceKlass"); Type type = db.lookupType("InstanceKlass");
arrayKlasses = new OopField(type.getOopField("_array_klasses"), Oop.getHeaderSize()); arrayKlasses = new MetadataField(type.getAddressField("_array_klasses"), 0);
methods = new OopField(type.getOopField("_methods"), Oop.getHeaderSize()); methods = type.getAddressField("_methods");
methodOrdering = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize()); methodOrdering = type.getAddressField("_method_ordering");
localInterfaces = new OopField(type.getOopField("_local_interfaces"), Oop.getHeaderSize()); localInterfaces = type.getAddressField("_local_interfaces");
transitiveInterfaces = new OopField(type.getOopField("_transitive_interfaces"), Oop.getHeaderSize()); transitiveInterfaces = type.getAddressField("_transitive_interfaces");
fields = new OopField(type.getOopField("_fields"), Oop.getHeaderSize()); fields = type.getAddressField("_fields");
javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), Oop.getHeaderSize()); javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), 0);
constants = new OopField(type.getOopField("_constants"), Oop.getHeaderSize()); constants = new MetadataField(type.getAddressField("_constants"), 0);
classLoader = new OopField(type.getOopField("_class_loader"), Oop.getHeaderSize()); classLoaderData = type.getAddressField("_class_loader_data");
protectionDomain = new OopField(type.getOopField("_protection_domain"), Oop.getHeaderSize()); protectionDomain = new OopField(type.getOopField("_protection_domain"), 0);
signers = new OopField(type.getOopField("_signers"), Oop.getHeaderSize()); signers = new OopField(type.getOopField("_signers"), 0);
sourceFileName = type.getAddressField("_source_file_name"); sourceFileName = type.getAddressField("_source_file_name");
sourceDebugExtension = type.getAddressField("_source_debug_extension"); sourceDebugExtension = type.getAddressField("_source_debug_extension");
innerClasses = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize()); innerClasses = type.getAddressField("_inner_classes");
nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize()); nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), 0);
staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize()); staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), 0);
staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), Oop.getHeaderSize()); staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), 0);
nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), Oop.getHeaderSize()); nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), 0);
isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), Oop.getHeaderSize()); isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), 0);
initState = new CIntField(type.getCIntegerField("_init_state"), Oop.getHeaderSize()); initState = new CIntField(type.getCIntegerField("_init_state"), 0);
vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize()); vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0);
itableLen = new CIntField(type.getCIntegerField("_itable_len"), Oop.getHeaderSize()); itableLen = new CIntField(type.getCIntegerField("_itable_len"), 0);
breakpoints = type.getAddressField("_breakpoints"); breakpoints = type.getAddressField("_breakpoints");
genericSignature = type.getAddressField("_generic_signature"); genericSignature = type.getAddressField("_generic_signature");
majorVersion = new CIntField(type.getCIntegerField("_major_version"), Oop.getHeaderSize()); majorVersion = new CIntField(type.getCIntegerField("_major_version"), 0);
minorVersion = new CIntField(type.getCIntegerField("_minor_version"), Oop.getHeaderSize()); minorVersion = new CIntField(type.getCIntegerField("_minor_version"), 0);
headerSize = alignObjectOffset(Oop.getHeaderSize() + type.getSize()); headerSize = Oop.alignObjectOffset(type.getSize());
// read field offset constants // read field offset constants
ACCESS_FLAGS_OFFSET = db.lookupIntConstant("FieldInfo::access_flags_offset").intValue(); ACCESS_FLAGS_OFFSET = db.lookupIntConstant("FieldInfo::access_flags_offset").intValue();
@ -100,18 +100,17 @@ public class InstanceKlass extends Klass {
HIGH_OFFSET = db.lookupIntConstant("FieldInfo::high_offset").intValue(); HIGH_OFFSET = db.lookupIntConstant("FieldInfo::high_offset").intValue();
FIELD_SLOTS = db.lookupIntConstant("FieldInfo::field_slots").intValue(); FIELD_SLOTS = db.lookupIntConstant("FieldInfo::field_slots").intValue();
// read ClassState constants // read ClassState constants
CLASS_STATE_UNPARSABLE_BY_GC = db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue(); CLASS_STATE_ALLOCATED = db.lookupIntConstant("InstanceKlass::allocated").intValue();
CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue(); CLASS_STATE_LOADED = db.lookupIntConstant("InstanceKlass::loaded").intValue();
CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue(); CLASS_STATE_LINKED = db.lookupIntConstant("InstanceKlass::linked").intValue();
CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue(); CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("InstanceKlass::being_initialized").intValue();
CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("instanceKlass::being_initialized").intValue(); CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("InstanceKlass::fully_initialized").intValue();
CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue(); CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("InstanceKlass::initialization_error").intValue();
CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("instanceKlass::initialization_error").intValue();
} }
InstanceKlass(OopHandle handle, ObjectHeap heap) { public InstanceKlass(Address addr) {
super(handle, heap); super(addr);
if (getJavaFieldsCount() != getAllFieldsCount()) { if (getJavaFieldsCount() != getAllFieldsCount()) {
// Exercise the injected field logic // Exercise the injected field logic
for (int i = getJavaFieldsCount(); i < getAllFieldsCount(); i++) { for (int i = getJavaFieldsCount(); i < getAllFieldsCount(); i++) {
@ -121,20 +120,20 @@ public class InstanceKlass extends Klass {
} }
} }
private static OopField arrayKlasses; private static MetadataField arrayKlasses;
private static OopField methods; private static AddressField methods;
private static OopField methodOrdering; private static AddressField methodOrdering;
private static OopField localInterfaces; private static AddressField localInterfaces;
private static OopField transitiveInterfaces; private static AddressField transitiveInterfaces;
private static OopField fields; private static AddressField fields;
private static CIntField javaFieldsCount; private static CIntField javaFieldsCount;
private static OopField constants; private static MetadataField constants;
private static OopField classLoader; private static AddressField classLoaderData;
private static OopField protectionDomain; private static OopField protectionDomain;
private static OopField signers; private static OopField signers;
private static AddressField sourceFileName; private static AddressField sourceFileName;
private static AddressField sourceDebugExtension; private static AddressField sourceDebugExtension;
private static OopField innerClasses; private static AddressField innerClasses;
private static CIntField nonstaticFieldSize; private static CIntField nonstaticFieldSize;
private static CIntField staticFieldSize; private static CIntField staticFieldSize;
private static CIntField staticOopFieldCount; private static CIntField staticOopFieldCount;
@ -150,7 +149,6 @@ public class InstanceKlass extends Klass {
// type safe enum for ClassState from instanceKlass.hpp // type safe enum for ClassState from instanceKlass.hpp
public static class ClassState { public static class ClassState {
public static final ClassState UNPARSABLE_BY_GC = new ClassState("unparsable_by_gc");
public static final ClassState ALLOCATED = new ClassState("allocated"); public static final ClassState ALLOCATED = new ClassState("allocated");
public static final ClassState LOADED = new ClassState("loaded"); public static final ClassState LOADED = new ClassState("loaded");
public static final ClassState LINKED = new ClassState("linked"); public static final ClassState LINKED = new ClassState("linked");
@ -172,9 +170,7 @@ public class InstanceKlass extends Klass {
public int getInitStateAsInt() { return (int) initState.getValue(this); } public int getInitStateAsInt() { return (int) initState.getValue(this); }
public ClassState getInitState() { public ClassState getInitState() {
int state = getInitStateAsInt(); int state = getInitStateAsInt();
if (state == CLASS_STATE_UNPARSABLE_BY_GC) { if (state == CLASS_STATE_ALLOCATED) {
return ClassState.UNPARSABLE_BY_GC;
} else if (state == CLASS_STATE_ALLOCATED) {
return ClassState.ALLOCATED; return ClassState.ALLOCATED;
} else if (state == CLASS_STATE_LOADED) { } else if (state == CLASS_STATE_LOADED) {
return ClassState.LOADED; return ClassState.LOADED;
@ -242,19 +238,24 @@ public class InstanceKlass extends Klass {
return getSizeHelper() * VM.getVM().getAddressSize(); return getSizeHelper() * VM.getVM().getAddressSize();
} }
public long getSize() {
return Oop.alignObjectSize(getHeaderSize() + Oop.alignObjectOffset(getVtableLen()) +
Oop.alignObjectOffset(getItableLen()) + Oop.alignObjectOffset(getNonstaticOopMapSize()));
}
public static long getHeaderSize() { return headerSize; } public static long getHeaderSize() { return headerSize; }
public short getFieldAccessFlags(int index) { public short getFieldAccessFlags(int index) {
return getFields().getShortAt(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET); return getFields().at(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET);
} }
public short getFieldNameIndex(int index) { public short getFieldNameIndex(int index) {
if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;"); if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;");
return getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET); return getFields().at(index * FIELD_SLOTS + NAME_INDEX_OFFSET);
} }
public Symbol getFieldName(int index) { public Symbol getFieldName(int index) {
int nameIndex = getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET); int nameIndex = getFields().at(index * FIELD_SLOTS + NAME_INDEX_OFFSET);
if (index < getJavaFieldsCount()) { if (index < getJavaFieldsCount()) {
return getConstants().getSymbolAt(nameIndex); return getConstants().getSymbolAt(nameIndex);
} else { } else {
@ -264,11 +265,11 @@ public class InstanceKlass extends Klass {
public short getFieldSignatureIndex(int index) { public short getFieldSignatureIndex(int index) {
if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;"); if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;");
return getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET); return getFields().at(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET);
} }
public Symbol getFieldSignature(int index) { public Symbol getFieldSignature(int index) {
int signatureIndex = getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET); int signatureIndex = getFields().at(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET);
if (index < getJavaFieldsCount()) { if (index < getJavaFieldsCount()) {
return getConstants().getSymbolAt(signatureIndex); return getConstants().getSymbolAt(signatureIndex);
} else { } else {
@ -277,7 +278,7 @@ public class InstanceKlass extends Klass {
} }
public short getFieldGenericSignatureIndex(int index) { public short getFieldGenericSignatureIndex(int index) {
int len = (int)getFields().getLength(); int len = getFields().length();
int allFieldsCount = getAllFieldsCount(); int allFieldsCount = getAllFieldsCount();
int generic_signature_slot = allFieldsCount * FIELD_SLOTS; int generic_signature_slot = allFieldsCount * FIELD_SLOTS;
for (int i = 0; i < allFieldsCount; i++) { for (int i = 0; i < allFieldsCount; i++) {
@ -285,7 +286,7 @@ public class InstanceKlass extends Klass {
AccessFlags access = new AccessFlags(flags); AccessFlags access = new AccessFlags(flags);
if (i == index) { if (i == index) {
if (access.fieldHasGenericSignature()) { if (access.fieldHasGenericSignature()) {
return getFields().getShortAt(generic_signature_slot); return getFields().at(generic_signature_slot);
} else { } else {
return 0; return 0;
} }
@ -308,25 +309,23 @@ public class InstanceKlass extends Klass {
public short getFieldInitialValueIndex(int index) { public short getFieldInitialValueIndex(int index) {
if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;"); if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;");
return getFields().getShortAt(index * FIELD_SLOTS + INITVAL_INDEX_OFFSET); return getFields().at(index * FIELD_SLOTS + INITVAL_INDEX_OFFSET);
} }
public int getFieldOffset(int index) { public int getFieldOffset(int index) {
TypeArray fields = getFields(); U2Array fields = getFields();
return VM.getVM().buildIntFromShorts(fields.getShortAt(index * FIELD_SLOTS + LOW_OFFSET), return VM.getVM().buildIntFromShorts(fields.at(index * FIELD_SLOTS + LOW_OFFSET),
fields.getShortAt(index * FIELD_SLOTS + HIGH_OFFSET)); fields.at(index * FIELD_SLOTS + HIGH_OFFSET));
} }
// Accessors for declared fields // Accessors for declared fields
public Klass getArrayKlasses() { return (Klass) arrayKlasses.getValue(this); } public Klass getArrayKlasses() { return (Klass) arrayKlasses.getValue(this); }
public ObjArray getMethods() { return (ObjArray) methods.getValue(this); } public MethodArray getMethods() { return new MethodArray(methods.getValue(getAddress())); }
public TypeArray getMethodOrdering() { return (TypeArray) methodOrdering.getValue(this); } public KlassArray getLocalInterfaces() { return new KlassArray(localInterfaces.getValue(getAddress())); }
public ObjArray getLocalInterfaces() { return (ObjArray) localInterfaces.getValue(this); } public KlassArray getTransitiveInterfaces() { return new KlassArray(transitiveInterfaces.getValue(getAddress())); }
public ObjArray getTransitiveInterfaces() { return (ObjArray) transitiveInterfaces.getValue(this); }
public TypeArray getFields() { return (TypeArray) fields.getValue(this); }
public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); } public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); }
public int getAllFieldsCount() { public int getAllFieldsCount() {
int len = (int)getFields().getLength(); int len = getFields().length();
int allFieldsCount = 0; int allFieldsCount = 0;
for (; allFieldsCount*FIELD_SLOTS < len; allFieldsCount++) { for (; allFieldsCount*FIELD_SLOTS < len; allFieldsCount++) {
short flags = getFieldAccessFlags(allFieldsCount); short flags = getFieldAccessFlags(allFieldsCount);
@ -338,12 +337,12 @@ public class InstanceKlass extends Klass {
return allFieldsCount; return allFieldsCount;
} }
public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); }
public Oop getClassLoader() { return classLoader.getValue(this); } public ClassLoaderData getClassLoaderData() { return ClassLoaderData.instantiateWrapperFor(classLoaderData.getValue(getAddress())); }
public Oop getClassLoader() { return getClassLoaderData().getClassLoader(); }
public Oop getProtectionDomain() { return protectionDomain.getValue(this); } public Oop getProtectionDomain() { return protectionDomain.getValue(this); }
public ObjArray getSigners() { return (ObjArray) signers.getValue(this); } public ObjArray getSigners() { return (ObjArray) signers.getValue(this); }
public Symbol getSourceFileName() { return getSymbol(sourceFileName); } public Symbol getSourceFileName() { return getSymbol(sourceFileName); }
public String getSourceDebugExtension(){ return CStringUtilities.getString(sourceDebugExtension.getValue(getHandle())); } public String getSourceDebugExtension(){ return CStringUtilities.getString(sourceDebugExtension.getValue(getAddress())); }
public TypeArray getInnerClasses() { return (TypeArray) innerClasses.getValue(this); }
public long getNonstaticFieldSize() { return nonstaticFieldSize.getValue(this); } public long getNonstaticFieldSize() { return nonstaticFieldSize.getValue(this); }
public long getStaticOopFieldCount() { return staticOopFieldCount.getValue(this); } public long getStaticOopFieldCount() { return staticOopFieldCount.getValue(this); }
public long getNonstaticOopMapSize() { return nonstaticOopMapSize.getValue(this); } public long getNonstaticOopMapSize() { return nonstaticOopMapSize.getValue(this); }
@ -383,8 +382,8 @@ public class InstanceKlass extends Klass {
public long computeModifierFlags() { public long computeModifierFlags() {
long access = getAccessFlags(); long access = getAccessFlags();
// But check if it happens to be member class. // But check if it happens to be member class.
TypeArray innerClassList = getInnerClasses(); U2Array innerClassList = getInnerClasses();
int length = ( innerClassList == null)? 0 : (int) innerClassList.getLength(); int length = (innerClassList == null)? 0 : (int) innerClassList.length();
if (length > 0) { if (length > 0) {
if (Assert.ASSERTS_ENABLED) { if (Assert.ASSERTS_ENABLED) {
Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0 || Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0 ||
@ -395,7 +394,7 @@ public class InstanceKlass extends Klass {
if (i == length - EnclosingMethodAttributeOffset.enclosing_method_attribute_size) { if (i == length - EnclosingMethodAttributeOffset.enclosing_method_attribute_size) {
break; break;
} }
int ioff = innerClassList.getShortAt(i + int ioff = innerClassList.at(i +
InnerClassAttributeOffset.innerClassInnerClassInfoOffset); InnerClassAttributeOffset.innerClassInnerClassInfoOffset);
// 'ioff' can be zero. // 'ioff' can be zero.
// refer to JVM spec. section 4.7.5. // refer to JVM spec. section 4.7.5.
@ -404,9 +403,9 @@ public class InstanceKlass extends Klass {
// since we are looking for the flags for our self. // since we are looking for the flags for our self.
ConstantPool.CPSlot classInfo = getConstants().getSlotAt(ioff); ConstantPool.CPSlot classInfo = getConstants().getSlotAt(ioff);
Symbol name = null; Symbol name = null;
if (classInfo.isOop()) { if (classInfo.isResolved()) {
name = ((Klass) classInfo.getOop()).getName(); name = classInfo.getKlass().getName();
} else if (classInfo.isMetaData()) { } else if (classInfo.isUnresolved()) {
name = classInfo.getSymbol(); name = classInfo.getSymbol();
} else { } else {
throw new RuntimeException("should not reach here"); throw new RuntimeException("should not reach here");
@ -414,7 +413,7 @@ public class InstanceKlass extends Klass {
if (name.equals(getName())) { if (name.equals(getName())) {
// This is really a member class // This is really a member class
access = innerClassList.getShortAt(i + access = innerClassList.at(i +
InnerClassAttributeOffset.innerClassAccessFlagsOffset); InnerClassAttributeOffset.innerClassAccessFlagsOffset);
break; break;
} }
@ -440,8 +439,8 @@ public class InstanceKlass extends Klass {
} }
private boolean isInInnerClasses(Symbol sym, boolean includeLocals) { private boolean isInInnerClasses(Symbol sym, boolean includeLocals) {
TypeArray innerClassList = getInnerClasses(); U2Array innerClassList = getInnerClasses();
int length = ( innerClassList == null)? 0 : (int) innerClassList.getLength(); int length = ( innerClassList == null)? 0 : (int) innerClassList.length();
if (length > 0) { if (length > 0) {
if (Assert.ASSERTS_ENABLED) { if (Assert.ASSERTS_ENABLED) {
Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0 || Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0 ||
@ -452,27 +451,19 @@ public class InstanceKlass extends Klass {
if (i == length - EnclosingMethodAttributeOffset.enclosing_method_attribute_size) { if (i == length - EnclosingMethodAttributeOffset.enclosing_method_attribute_size) {
break; break;
} }
int ioff = innerClassList.getShortAt(i + int ioff = innerClassList.at(i +
InnerClassAttributeOffset.innerClassInnerClassInfoOffset); InnerClassAttributeOffset.innerClassInnerClassInfoOffset);
// 'ioff' can be zero. // 'ioff' can be zero.
// refer to JVM spec. section 4.7.5. // refer to JVM spec. section 4.7.5.
if (ioff != 0) { if (ioff != 0) {
ConstantPool.CPSlot iclassInfo = getConstants().getSlotAt(ioff); ConstantPool.CPSlot iclassInfo = getConstants().getSlotAt(ioff);
Symbol innerName = null; Symbol innerName = getConstants().getKlassNameAt(ioff);
if (iclassInfo.isOop()) {
innerName = ((Klass) iclassInfo.getOop()).getName();
} else if (iclassInfo.isMetaData()) {
innerName = iclassInfo.getSymbol();
} else {
throw new RuntimeException("should not reach here");
}
Symbol myname = getName(); Symbol myname = getName();
int ooff = innerClassList.getShortAt(i + int ooff = innerClassList.at(i +
InnerClassAttributeOffset.innerClassOuterClassInfoOffset); InnerClassAttributeOffset.innerClassOuterClassInfoOffset);
// for anonymous classes inner_name_index of InnerClasses // for anonymous classes inner_name_index of InnerClasses
// attribute is zero. // attribute is zero.
int innerNameIndex = innerClassList.getShortAt(i + int innerNameIndex = innerClassList.at(i +
InnerClassAttributeOffset.innerClassInnerNameOffset); InnerClassAttributeOffset.innerClassInnerNameOffset);
// if this is not a member (anonymous, local etc.), 'ooff' will be zero // if this is not a member (anonymous, local etc.), 'ooff' will be zero
// refer to JVM spec. section 4.7.5. // refer to JVM spec. section 4.7.5.
@ -488,9 +479,9 @@ public class InstanceKlass extends Klass {
} else { } else {
ConstantPool.CPSlot oclassInfo = getConstants().getSlotAt(ooff); ConstantPool.CPSlot oclassInfo = getConstants().getSlotAt(ooff);
Symbol outerName = null; Symbol outerName = null;
if (oclassInfo.isOop()) { if (oclassInfo.isResolved()) {
outerName = ((Klass) oclassInfo.getOop()).getName(); outerName = oclassInfo.getKlass().getName();
} else if (oclassInfo.isMetaData()) { } else if (oclassInfo.isUnresolved()) {
outerName = oclassInfo.getSymbol(); outerName = oclassInfo.getSymbol();
} else { } else {
throw new RuntimeException("should not reach here"); throw new RuntimeException("should not reach here");
@ -513,10 +504,10 @@ public class InstanceKlass extends Klass {
if (Assert.ASSERTS_ENABLED) { if (Assert.ASSERTS_ENABLED) {
Assert.that(k.isInterface(), "should not reach here"); Assert.that(k.isInterface(), "should not reach here");
} }
ObjArray interfaces = getTransitiveInterfaces(); KlassArray interfaces = getTransitiveInterfaces();
final int len = (int) interfaces.getLength(); final int len = interfaces.length();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
if (interfaces.getObjAt(i).equals(k)) return true; if (interfaces.getAt(i).equals(k)) return true;
} }
return false; return false;
} }
@ -533,20 +524,14 @@ public class InstanceKlass extends Klass {
tty.print("InstanceKlass for " + getName().asString()); tty.print("InstanceKlass for " + getName().asString());
} }
public void iterateFields(OopVisitor visitor, boolean doVMFields) { public void iterateFields(MetadataVisitor visitor) {
super.iterateFields(visitor, doVMFields); super.iterateFields(visitor);
if (doVMFields) { visitor.doMetadata(arrayKlasses, true);
visitor.doOop(arrayKlasses, true); // visitor.doOop(methods, true);
visitor.doOop(methods, true); // visitor.doOop(localInterfaces, true);
visitor.doOop(methodOrdering, true); // visitor.doOop(transitiveInterfaces, true);
visitor.doOop(localInterfaces, true);
visitor.doOop(transitiveInterfaces, true);
visitor.doOop(fields, true);
visitor.doOop(constants, true);
visitor.doOop(classLoader, true);
visitor.doOop(protectionDomain, true); visitor.doOop(protectionDomain, true);
visitor.doOop(signers, true); visitor.doOop(signers, true);
visitor.doOop(innerClasses, true);
visitor.doCInt(nonstaticFieldSize, true); visitor.doCInt(nonstaticFieldSize, true);
visitor.doCInt(staticFieldSize, true); visitor.doCInt(staticFieldSize, true);
visitor.doCInt(staticOopFieldCount, true); visitor.doCInt(staticOopFieldCount, true);
@ -556,7 +541,6 @@ public class InstanceKlass extends Klass {
visitor.doCInt(vtableLen, true); visitor.doCInt(vtableLen, true);
visitor.doCInt(itableLen, true); visitor.doCInt(itableLen, true);
} }
}
/* /*
* Visit the static fields of this InstanceKlass with the obj of * Visit the static fields of this InstanceKlass with the obj of
@ -628,10 +612,10 @@ public class InstanceKlass extends Klass {
/** Find field in direct superinterfaces. */ /** Find field in direct superinterfaces. */
public Field findInterfaceField(Symbol name, Symbol sig) { public Field findInterfaceField(Symbol name, Symbol sig) {
ObjArray interfaces = getLocalInterfaces(); KlassArray interfaces = getLocalInterfaces();
int n = (int) interfaces.getLength(); int n = interfaces.length();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
InstanceKlass intf1 = (InstanceKlass) interfaces.getObjAt(i); InstanceKlass intf1 = (InstanceKlass) interfaces.getAt(i);
if (Assert.ASSERTS_ENABLED) { if (Assert.ASSERTS_ENABLED) {
Assert.that(intf1.isInterface(), "just checking type"); Assert.that(intf1.isInterface(), "just checking type");
} }
@ -727,10 +711,10 @@ public class InstanceKlass extends Klass {
// transitiveInterfaces contains all interfaces implemented // transitiveInterfaces contains all interfaces implemented
// by this class and its superclass chain with no duplicates. // by this class and its superclass chain with no duplicates.
ObjArray interfaces = getTransitiveInterfaces(); KlassArray interfaces = getTransitiveInterfaces();
int n = (int) interfaces.getLength(); int n = interfaces.length();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
InstanceKlass intf1 = (InstanceKlass) interfaces.getObjAt(i); InstanceKlass intf1 = (InstanceKlass) interfaces.getAt(i);
if (Assert.ASSERTS_ENABLED) { if (Assert.ASSERTS_ENABLED) {
Assert.that(intf1.isInterface(), "just checking type"); Assert.that(intf1.isInterface(), "just checking type");
} }
@ -759,20 +743,20 @@ public class InstanceKlass extends Klass {
// Contains a Method for each method declared in this class/interface // Contains a Method for each method declared in this class/interface
// not including inherited methods. // not including inherited methods.
ObjArray methods = getMethods(); MethodArray methods = getMethods();
int length = (int)methods.getLength(); int length = methods.length();
Object[] tmp = new Object[length]; Object[] tmp = new Object[length];
TypeArray methodOrdering = getMethodOrdering(); IntArray methodOrdering = getMethodOrdering();
if (methodOrdering.getLength() != length) { if (methodOrdering.length() != length) {
// no ordering info present // no ordering info present
for (int index = 0; index < length; index++) { for (int index = 0; index < length; index++) {
tmp[index] = methods.getObjAt(index); tmp[index] = methods.at(index);
} }
} else { } else {
for (int index = 0; index < length; index++) { for (int index = 0; index < length; index++) {
int originalIndex = getMethodOrdering().getIntAt(index); int originalIndex = methodOrdering.at(index);
tmp[originalIndex] = methods.getObjAt(index); tmp[originalIndex] = methods.at(index);
} }
} }
@ -786,25 +770,17 @@ public class InstanceKlass extends Klass {
// Contains an InstanceKlass for each interface in this classes // Contains an InstanceKlass for each interface in this classes
// 'implements' clause. // 'implements' clause.
ObjArray interfaces = getLocalInterfaces(); KlassArray interfaces = getLocalInterfaces();
int length = (int) interfaces.getLength(); int length = interfaces.length();
List directImplementedInterfaces = new ArrayList(length); List directImplementedInterfaces = new ArrayList(length);
for (int index = 0; index < length; index ++) { for (int index = 0; index < length; index ++) {
directImplementedInterfaces.add(interfaces.getObjAt(index)); directImplementedInterfaces.add(interfaces.getAt(index));
} }
return directImplementedInterfaces; return directImplementedInterfaces;
} }
public long getObjectSize() {
long bodySize = alignObjectOffset(getVtableLen() * getHeap().getOopSize())
+ alignObjectOffset(getItableLen() * getHeap().getOopSize())
+ (getNonstaticOopMapSize()) * getHeap().getOopSize();
return alignObjectSize(headerSize + bodySize);
}
public Klass arrayKlassImpl(boolean orNull, int n) { public Klass arrayKlassImpl(boolean orNull, int n) {
// FIXME: in reflective system this would need to change to // FIXME: in reflective system this would need to change to
// actually allocate // actually allocate
@ -841,12 +817,28 @@ public class InstanceKlass extends Klass {
return findMethod(getMethods(), name, sig); return findMethod(getMethods(), name, sig);
} }
/** Breakpoint support (see methods on methodOop for details) */ /** Breakpoint support (see methods on Method* for details) */
public BreakpointInfo getBreakpoints() { public BreakpointInfo getBreakpoints() {
Address addr = getHandle().getAddressAt(Oop.getHeaderSize() + breakpoints.getOffset()); Address addr = getAddress().getAddressAt(breakpoints.getOffset());
return (BreakpointInfo) VMObjectFactory.newObject(BreakpointInfo.class, addr); return (BreakpointInfo) VMObjectFactory.newObject(BreakpointInfo.class, addr);
} }
public IntArray getMethodOrdering() {
Address addr = getAddress().getAddressAt(methodOrdering.getOffset());
return (IntArray) VMObjectFactory.newObject(IntArray.class, addr);
}
public U2Array getFields() {
Address addr = getAddress().getAddressAt(fields.getOffset());
return (U2Array) VMObjectFactory.newObject(U2Array.class, addr);
}
public U2Array getInnerClasses() {
Address addr = getAddress().getAddressAt(innerClasses.getOffset());
return (U2Array) VMObjectFactory.newObject(U2Array.class, addr);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Internals only below this point // Internals only below this point
// //
@ -928,14 +920,14 @@ public class InstanceKlass extends Klass {
throw new RuntimeException("Illegal field type at index " + index); throw new RuntimeException("Illegal field type at index " + index);
} }
private static Method findMethod(ObjArray methods, Symbol name, Symbol signature) { private static Method findMethod(MethodArray methods, Symbol name, Symbol signature) {
int len = (int) methods.getLength(); int len = methods.length();
// methods are sorted, so do binary search // methods are sorted, so do binary search
int l = 0; int l = 0;
int h = len - 1; int h = len - 1;
while (l <= h) { while (l <= h) {
int mid = (l + h) >> 1; int mid = (l + h) >> 1;
Method m = (Method) methods.getObjAt(mid); Method m = methods.at(mid);
int res = m.getName().fastCompare(name); int res = m.getName().fastCompare(name);
if (res == 0) { if (res == 0) {
// found matching name; do linear search to find matching signature // found matching name; do linear search to find matching signature
@ -944,13 +936,13 @@ public class InstanceKlass extends Klass {
// search downwards through overloaded methods // search downwards through overloaded methods
int i; int i;
for (i = mid - 1; i >= l; i--) { for (i = mid - 1; i >= l; i--) {
Method m1 = (Method) methods.getObjAt(i); Method m1 = methods.at(i);
if (!m1.getName().equals(name)) break; if (!m1.getName().equals(name)) break;
if (m1.getSignature().equals(signature)) return m1; if (m1.getSignature().equals(signature)) return m1;
} }
// search upwards // search upwards
for (i = mid + 1; i <= h; i++) { for (i = mid + 1; i <= h; i++) {
Method m1 = (Method) methods.getObjAt(i); Method m1 = methods.at(i);
if (!m1.getName().equals(name)) break; if (!m1.getName().equals(name)) break;
if (m1.getSignature().equals(signature)) return m1; if (m1.getSignature().equals(signature)) return m1;
} }
@ -977,10 +969,10 @@ public class InstanceKlass extends Klass {
return null; return null;
} }
private static int linearSearch(ObjArray methods, Symbol name, Symbol signature) { private static int linearSearch(MethodArray methods, Symbol name, Symbol signature) {
int len = (int) methods.getLength(); int len = (int) methods.length();
for (int index = 0; index < len; index++) { for (int index = 0; index < len; index++) {
Method m = (Method) methods.getObjAt(index); Method m = methods.at(index);
if (m.getSignature().equals(signature) && m.getName().equals(name)) { if (m.getSignature().equals(signature) && m.getName().equals(name)) {
return index; return index;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -45,11 +45,11 @@ public class InstanceMirrorKlass extends InstanceKlass {
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
// Just make sure it's there for now // Just make sure it's there for now
Type type = db.lookupType("instanceMirrorKlass"); Type type = db.lookupType("InstanceMirrorKlass");
} }
InstanceMirrorKlass(OopHandle handle, ObjectHeap heap) { public InstanceMirrorKlass(Address addr) {
super(handle, heap); super(addr);
} }
public long getObjectSize(Oop o) { public long getObjectSize(Oop o) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,10 +27,14 @@ package sun.jvm.hotspot.oops;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
import sun.jvm.hotspot.utilities.*;
public class CompiledICHolderKlass extends Klass { // An InstanceKlass is the VM level representation of a Java class.
public class InstanceRefKlass extends InstanceKlass {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -40,19 +44,11 @@ public class CompiledICHolderKlass extends Klass {
} }
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("compiledICHolderKlass"); // Just make sure it's there for now
headerSize = type.getSize() + Oop.getHeaderSize(); Type type = db.lookupType("InstanceRefKlass");
} }
CompiledICHolderKlass(OopHandle handle, ObjectHeap heap) { public InstanceRefKlass(Address addr) {
super(handle, heap); super(addr);
}
private static long headerSize;
public long getObjectSize() { return alignObjectSize(headerSize); }
public void printValueOn(PrintStream tty) {
tty.print("CompilerICHolderKlass");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
package sun.jvm.hotspot.oops; package sun.jvm.hotspot.oops;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.VMObject;
// The class for an int field simply provides access to the value. // The class for an int field simply provides access to the value.
public class IntField extends Field { public class IntField extends Field {
@ -46,6 +47,9 @@ public class IntField extends Field {
} }
return obj.getHandle().getJIntAt(getOffset()); return obj.getHandle().getJIntAt(getOffset());
} }
public int getValue(VMObject obj) {
return obj.getAddress().getJIntAt(getOffset());
}
public void setValue(Oop obj, int value) throws MutationException { public void setValue(Oop obj, int value) throws MutationException {
// Fix this: setJIntAt is missing in Address // Fix this: setJIntAt is missing in Address
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,7 +30,7 @@ import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
public class Klass extends Oop implements ClassConstants { public class Klass extends Metadata implements ClassConstants {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -50,14 +50,14 @@ public class Klass extends Oop implements ClassConstants {
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("Klass"); Type type = db.lookupType("Klass");
javaMirror = new OopField(type.getOopField("_java_mirror"), Oop.getHeaderSize()); javaMirror = new OopField(type.getOopField("_java_mirror"), 0);
superField = new OopField(type.getOopField("_super"), Oop.getHeaderSize()); superField = new MetadataField(type.getAddressField("_super"), 0);
layoutHelper = new IntField(type.getJIntField("_layout_helper"), Oop.getHeaderSize()); layoutHelper = new IntField(type.getJIntField("_layout_helper"), 0);
name = type.getAddressField("_name"); name = type.getAddressField("_name");
accessFlags = new CIntField(type.getCIntegerField("_access_flags"), Oop.getHeaderSize()); accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0);
subklass = new OopField(type.getOopField("_subklass"), Oop.getHeaderSize()); subklass = new MetadataField(type.getAddressField("_subklass"), 0);
nextSibling = new OopField(type.getOopField("_next_sibling"), Oop.getHeaderSize()); nextSibling = new MetadataField(type.getAddressField("_next_sibling"), 0);
allocCount = new CIntField(type.getCIntegerField("_alloc_count"), Oop.getHeaderSize()); allocCount = new CIntField(type.getCIntegerField("_alloc_count"), 0);
LH_INSTANCE_SLOW_PATH_BIT = db.lookupIntConstant("Klass::_lh_instance_slow_path_bit").intValue(); LH_INSTANCE_SLOW_PATH_BIT = db.lookupIntConstant("Klass::_lh_instance_slow_path_bit").intValue();
LH_LOG2_ELEMENT_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_log2_element_size_shift").intValue(); LH_LOG2_ELEMENT_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_log2_element_size_shift").intValue();
@ -68,8 +68,8 @@ public class Klass extends Oop implements ClassConstants {
LH_ARRAY_TAG_OBJ_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_obj_value").intValue(); LH_ARRAY_TAG_OBJ_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_obj_value").intValue();
} }
Klass(OopHandle handle, ObjectHeap heap) { public Klass(Address addr) {
super(handle, heap); super(addr);
} }
// jvmdi support - see also class_status in VM code // jvmdi support - see also class_status in VM code
@ -81,20 +81,20 @@ public class Klass extends Oop implements ClassConstants {
// Fields // Fields
private static OopField javaMirror; private static OopField javaMirror;
private static OopField superField; private static MetadataField superField;
private static IntField layoutHelper; private static IntField layoutHelper;
private static AddressField name; private static AddressField name;
private static CIntField accessFlags; private static CIntField accessFlags;
private static OopField subklass; private static MetadataField subklass;
private static OopField nextSibling; private static MetadataField nextSibling;
private static CIntField allocCount; private static CIntField allocCount;
private Address getValue(AddressField field) { private Address getValue(AddressField field) {
return getHandle().getAddressAt(field.getOffset() + Oop.getHeaderSize()); return addr.getAddressAt(field.getOffset());
} }
protected Symbol getSymbol(AddressField field) { protected Symbol getSymbol(AddressField field) {
return Symbol.create(getHandle().getAddressAt(field.getOffset() + Oop.getHeaderSize())); return Symbol.create(addr.getAddressAt(field.getOffset()));
} }
// Accessors for declared fields // Accessors for declared fields
@ -164,19 +164,16 @@ public class Klass extends Oop implements ClassConstants {
tty.print("Klass"); tty.print("Klass");
} }
public void iterateFields(OopVisitor visitor, boolean doVMFields) { public void iterateFields(MetadataVisitor visitor) {
super.iterateFields(visitor, doVMFields);
if (doVMFields) {
visitor.doOop(javaMirror, true); visitor.doOop(javaMirror, true);
visitor.doOop(superField, true); visitor.doMetadata(superField, true);
visitor.doInt(layoutHelper, true); visitor.doInt(layoutHelper, true);
// visitor.doOop(name, true); // visitor.doOop(name, true);
visitor.doCInt(accessFlags, true); visitor.doCInt(accessFlags, true);
visitor.doOop(subklass, true); visitor.doMetadata(subklass, true);
visitor.doOop(nextSibling, true); visitor.doMetadata(nextSibling, true);
visitor.doCInt(allocCount, true); visitor.doCInt(allocCount, true);
} }
}
public long getObjectSize() { public long getObjectSize() {
throw new RuntimeException("should not reach here"); throw new RuntimeException("should not reach here");
@ -191,11 +188,11 @@ public class Klass extends Oop implements ClassConstants {
public Klass arrayKlassOrNull() { return arrayKlassImpl(true); } public Klass arrayKlassOrNull() { return arrayKlassImpl(true); }
public Klass arrayKlassImpl(boolean orNull, int rank) { public Klass arrayKlassImpl(boolean orNull, int rank) {
throw new RuntimeException("array_klass should be dispatched to instanceKlass, objArrayKlass or typeArrayKlass"); throw new RuntimeException("array_klass should be dispatched to InstanceKlass, objArrayKlass or typeArrayKlass");
} }
public Klass arrayKlassImpl(boolean orNull) { public Klass arrayKlassImpl(boolean orNull) {
throw new RuntimeException("array_klass should be dispatched to instanceKlass, objArrayKlass or typeArrayKlass"); throw new RuntimeException("array_klass should be dispatched to InstanceKlass, objArrayKlass or typeArrayKlass");
} }
// This returns the name in the form java/lang/String which isn't really a signature // This returns the name in the form java/lang/String which isn't really a signature

View File

@ -1,61 +0,0 @@
/*
* Copyright (c) 2000, 2001, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.oops;
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*;
// A KlassKlass serves as the fix point of the klass chain.
// The klass of KlassKlass is itself.
public class KlassKlass extends Klass {
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("klassKlass");
headerSize = type.getSize() + Oop.getHeaderSize();
}
KlassKlass(OopHandle handle, ObjectHeap heap) {
super(handle, heap);
}
private static long headerSize;
public long getObjectSize() { return alignObjectSize(headerSize); }
public void printValueOn(PrintStream tty) {
tty.print("KlassKlass");
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -58,10 +58,10 @@ public class LocalVariableTableElement {
private static long offsetOfSignatureCPIndex; private static long offsetOfSignatureCPIndex;
private static long offsetOfSlot; private static long offsetOfSlot;
private OopHandle handle; private Address handle;
private long offset; private long offset;
public LocalVariableTableElement(OopHandle handle, long offset) { public LocalVariableTableElement(Address handle, long offset) {
this.handle = handle; this.handle = handle;
this.offset = offset; this.offset = offset;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
package sun.jvm.hotspot.oops; package sun.jvm.hotspot.oops;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.VMObject;
// The class for a long field simply provides access to the value. // The class for a long field simply provides access to the value.
public class LongField extends Field { public class LongField extends Field {
@ -41,6 +42,7 @@ public class LongField extends Field {
} }
public long getValue(Oop obj) { return obj.getHandle().getJLongAt(getOffset()); } public long getValue(Oop obj) { return obj.getHandle().getJLongAt(getOffset()); }
public long getValue(VMObject obj) { return obj.getAddress().getJLongAt(getOffset()); }
public void setValue(Oop obj, long value) { public void setValue(Oop obj, long value) {
// Fix this: setJLongAt is missing in Address // Fix this: setJLongAt is missing in Address
} }

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.oops;
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.utilities.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*;
abstract public class Metadata extends VMObject {
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
public Metadata(Address addr) {
super(addr);
}
private static VirtualBaseConstructor<Metadata> metadataConstructor;
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
metadataConstructor = new VirtualBaseConstructor<Metadata>(db, db.lookupType("Metadata"), null, null);
// Define an explicit mapping since the C++ and Java type names don't match.
metadataConstructor.addMapping("Metadata", Metadata.class);
metadataConstructor.addMapping("Klass", Klass.class);
metadataConstructor.addMapping("InstanceKlass", InstanceKlass.class);
metadataConstructor.addMapping("InstanceMirrorKlass", InstanceMirrorKlass.class);
metadataConstructor.addMapping("InstanceRefKlass", InstanceRefKlass.class);
metadataConstructor.addMapping("InstanceClassLoaderKlass", InstanceClassLoaderKlass.class);
metadataConstructor.addMapping("typeArrayKlass", TypeArrayKlass.class);
metadataConstructor.addMapping("objArrayKlass", ObjArrayKlass.class);
metadataConstructor.addMapping("Method", Method.class);
metadataConstructor.addMapping("MethodData", MethodData.class);
metadataConstructor.addMapping("ConstMethod", ConstMethod.class);
metadataConstructor.addMapping("ConstantPool", ConstantPool.class);
metadataConstructor.addMapping("ConstantPoolCache", ConstantPoolCache.class);
}
public static Metadata instantiateWrapperFor(Address addr) {
return metadataConstructor.instantiateWrapperFor(addr);
}
public void iterate(MetadataVisitor visitor) {
visitor.setObj(this);
visitor.prologue();
iterateFields(visitor);
visitor.epilogue();
}
void iterateFields(MetadataVisitor visitor) {
}
abstract public void printValueOn(PrintStream tty);
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,21 +22,28 @@
* *
*/ */
package sun.jvm.hotspot.memory; package sun.jvm.hotspot.oops;
import sun.jvm.hotspot.runtime.VMObject;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
/** All heaps contains a "permanent generation," containing permanent // The class for an C int field simply provides access to the value.
(reflective) objects. This is like a regular generation in some public class MetadataField extends Field {
ways, but unlike one in others, and so is split apart. (FIXME:
this distinction is confusing and seems unnecessary.) */
public abstract class PermGen extends VMObject { public MetadataField(sun.jvm.hotspot.types.AddressField vmField, long startOffset) {
// NEEDS_CLEANUP super(new NamedFieldIdentifier(vmField.getName()), vmField.getOffset() + startOffset, true);
public PermGen(Address addr) {
super(addr);
} }
public abstract Generation asGen(); public Metadata getValue(Oop obj) {
return getValue(obj.getHandle());
}
public Metadata getValue(VMObject obj) {
return getValue(obj.getAddress());
}
public Metadata getValue(Address addr) {
return Metadata.instantiateWrapperFor(addr.getAddressAt(getOffset()));
}
public void setValue(Oop obj, long value) throws MutationException {
// Fix this: set* missing in Address
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,19 +22,20 @@
* *
*/ */
#include "precompiled.hpp" package sun.jvm.hotspot.oops;
#include "ci/ciMethodKlass.hpp"
#include "ci/ciUtilities.hpp"
// ciMethodKlass // A MetadataVisitor can be used to inspect all fields within an object.
// // Fields include vm fields, java fields, indexable fields.
// This class represents a klassOop in the HotSpot virtual machine
// whose Klass part is a methodKlass.
// ------------------------------------------------------------------ public interface MetadataVisitor extends FieldVisitor {
// ciMethodKlass::instance // Called before visiting an object
// public void prologue();
// Return the distinguished instance of this class
ciMethodKlass* ciMethodKlass::make() { // Called after visiting an object
return CURRENT_ENV->_method_klass_instance; public void epilogue();
}
public void setObj(Metadata obj);
// Returns the object being visited
public Metadata getObj();
};

View File

@ -36,7 +36,7 @@ import sun.jvm.hotspot.utilities.*;
// A Method represents a Java method // A Method represents a Java method
public class Method extends Oop { public class Method extends Metadata {
static { static {
VM.registerVMInitializedObserver(new Observer() { VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) { public void update(Observable o, Object data) {
@ -46,9 +46,9 @@ public class Method extends Oop {
} }
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("methodOopDesc"); Type type = db.lookupType("Method");
constMethod = new OopField(type.getOopField("_constMethod"), 0); constMethod = type.getAddressField("_constMethod");
methodData = new OopField(type.getOopField("_method_data"), 0); methodData = type.getAddressField("_method_data");
methodSize = new CIntField(type.getCIntegerField("_method_size"), 0); methodSize = new CIntField(type.getCIntegerField("_method_size"), 0);
maxStack = new CIntField(type.getCIntegerField("_max_stack"), 0); maxStack = new CIntField(type.getCIntegerField("_max_stack"), 0);
maxLocals = new CIntField(type.getCIntegerField("_max_locals"), 0); maxLocals = new CIntField(type.getCIntegerField("_max_locals"), 0);
@ -74,15 +74,15 @@ public class Method extends Oop {
classInitializerName = null; classInitializerName = null;
} }
Method(OopHandle handle, ObjectHeap heap) { public Method(Address addr) {
super(handle, heap); super(addr);
} }
public boolean isMethod() { return true; } public boolean isMethod() { return true; }
// Fields // Fields
private static OopField constMethod; private static AddressField constMethod;
private static OopField methodData; private static AddressField methodData;
private static CIntField methodSize; private static CIntField methodSize;
private static CIntField maxStack; private static CIntField maxStack;
private static CIntField maxLocals; private static CIntField maxLocals;
@ -122,11 +122,17 @@ public class Method extends Oop {
*/ */
// Accessors for declared fields // Accessors for declared fields
public ConstMethod getConstMethod() { return (ConstMethod) constMethod.getValue(this); } public ConstMethod getConstMethod() {
Address addr = constMethod.getValue(getAddress());
return (ConstMethod) VMObjectFactory.newObject(ConstMethod.class, addr);
}
public ConstantPool getConstants() { public ConstantPool getConstants() {
return getConstMethod().getConstants(); return getConstMethod().getConstants();
} }
public MethodData getMethodData() { return (MethodData) methodData.getValue(this); } public MethodData getMethodData() {
Address addr = methodData.getValue(getAddress());
return (MethodData) VMObjectFactory.newObject(MethodData.class, addr);
}
/** WARNING: this is in words, not useful in this system; use getObjectSize() instead */ /** WARNING: this is in words, not useful in this system; use getObjectSize() instead */
public long getMethodSize() { return methodSize.getValue(this); } public long getMethodSize() { return methodSize.getValue(this); }
public long getMaxStack() { return maxStack.getValue(this); } public long getMaxStack() { return maxStack.getValue(this); }
@ -153,7 +159,7 @@ public class Method extends Oop {
// get associated compiled native method, if available, else return null. // get associated compiled native method, if available, else return null.
public NMethod getNativeMethod() { public NMethod getNativeMethod() {
Address addr = code.getValue(getHandle()); Address addr = code.getValue(getAddress());
return (NMethod) VMObjectFactory.newObject(NMethod.class, addr); return (NMethod) VMObjectFactory.newObject(NMethod.class, addr);
} }
@ -268,25 +274,21 @@ public class Method extends Oop {
return entry; return entry;
} }
public long getObjectSize() { public long getSize() {
return getMethodSize() * getHeap().getOopSize(); return getMethodSize();
} }
public void printValueOn(PrintStream tty) { public void printValueOn(PrintStream tty) {
tty.print("Method " + getName().asString() + getSignature().asString() + "@" + getHandle()); tty.print("Method " + getName().asString() + getSignature().asString() + "@" + getAddress());
} }
public void iterateFields(OopVisitor visitor, boolean doVMFields) { public void iterateFields(MetadataVisitor visitor) {
super.iterateFields(visitor, doVMFields);
if (doVMFields) {
visitor.doOop(constMethod, true);
visitor.doCInt(methodSize, true); visitor.doCInt(methodSize, true);
visitor.doCInt(maxStack, true); visitor.doCInt(maxStack, true);
visitor.doCInt(maxLocals, true); visitor.doCInt(maxLocals, true);
visitor.doCInt(sizeOfParameters, true); visitor.doCInt(sizeOfParameters, true);
visitor.doCInt(accessFlags, true); visitor.doCInt(accessFlags, true);
} }
}
public boolean hasLineNumberTable() { public boolean hasLineNumberTable() {
return getConstMethod().hasLineNumberTable(); return getConstMethod().hasLineNumberTable();
@ -357,10 +359,10 @@ public class Method extends Oop {
return buf.toString().replace('/', '.'); return buf.toString().replace('/', '.');
} }
public int interpreterThrowoutCount() { public int interpreterThrowoutCount() {
return (int) interpreterThrowoutCountField.getValue(getHandle()); return (int) interpreterThrowoutCountField.getValue(this);
} }
public int interpreterInvocationCount() { public int interpreterInvocationCount() {
return (int) interpreterInvocationCountField.getValue(getHandle()); return (int) interpreterInvocationCountField.getValue(this);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,7 +33,7 @@ import sun.jvm.hotspot.utilities.*;
// A MethodData provides interpreter profiling information // A MethodData provides interpreter profiling information
public class MethodData extends Oop { public class MethodData extends Metadata {
static int TypeProfileWidth = 2; static int TypeProfileWidth = 2;
static int BciProfileWidth = 2; static int BciProfileWidth = 2;
static int CompileThreshold; static int CompileThreshold;
@ -129,11 +129,11 @@ public class MethodData extends Oop {
} }
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("methodDataOopDesc"); Type type = db.lookupType("MethodData");
baseOffset = type.getSize(); baseOffset = type.getSize();
size = new CIntField(type.getCIntegerField("_size"), 0); size = new CIntField(type.getCIntegerField("_size"), 0);
method = new OopField(type.getOopField("_method"), 0); method = new MetadataField(type.getAddressField("_method"), 0);
VM.Flag[] flags = VM.getVM().getCommandLineFlags(); VM.Flag[] flags = VM.getVM().getCommandLineFlags();
for (int f = 0; f < flags.length; f++) { for (int f = 0; f < flags.length; f++) {
@ -188,25 +188,21 @@ public class MethodData extends Oop {
} }
} }
MethodData(OopHandle handle, ObjectHeap heap) { public MethodData(Address addr) {
super(handle, heap); super(addr);
} }
public boolean isMethodData() { return true; } public boolean isMethodData() { return true; }
private static long baseOffset; private static long baseOffset;
private static CIntField size; private static CIntField size;
private static OopField method; private static MetadataField method;
private static CIntField dataSize; private static CIntField dataSize;
private static AddressField data; private static AddressField data;
public static int sizeofMethodDataOopDesc; public static int sizeofMethodDataOopDesc;
public static int cellSize; public static int cellSize;
public long getObjectSize() {
return alignObjectSize(size.getValue(this));
}
public Method getMethod() { public Method getMethod() {
return (Method) method.getValue(this); return (Method) method.getValue(this);
} }
@ -216,19 +212,17 @@ public class MethodData extends Oop {
tty.print("MethodData for " + m.getName().asString() + m.getSignature().asString()); tty.print("MethodData for " + m.getName().asString() + m.getSignature().asString());
} }
public void iterateFields(OopVisitor visitor, boolean doVMFields) { public void iterateFields(MetadataVisitor visitor) {
super.iterateFields(visitor, doVMFields); super.iterateFields(visitor);
if (doVMFields) { visitor.doMetadata(method, true);
visitor.doOop(method, true);
visitor.doCInt(size, true); visitor.doCInt(size, true);
} }
}
int dataSize() { int dataSize() {
if (dataSize == null) { if (dataSize == null) {
return 0; return 0;
} else { } else {
return (int)dataSize.getValue(this); return (int)dataSize.getValue(getAddress());
} }
} }
@ -298,13 +292,13 @@ public class MethodData extends Oop {
} }
public byte[] orig() { public byte[] orig() {
// fetch the orig methodDataOopDesc data between header and dataSize // fetch the orig MethodData data between header and dataSize
return fetchDataAt(this.getHandle(), 0, sizeofMethodDataOopDesc); return fetchDataAt(getAddress(), 0, sizeofMethodDataOopDesc);
} }
public long[] data() { public long[] data() {
// Read the data as an array of intptr_t elements // Read the data as an array of intptr_t elements
OopHandle base = getHandle(); Address base = getAddress();
long offset = data.getOffset(); long offset = data.getOffset();
int elements = dataSize() / cellSize; int elements = dataSize() / cellSize;
long[] result = new long[elements]; long[] result = new long[elements];

View File

@ -1,60 +0,0 @@
/*
* Copyright (c) 2000, 2001, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.oops;
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*;
// The MethodDataKlass is the klass of a MethodData oop
public class MethodDataKlass extends Klass {
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("methodDataKlass");
headerSize = type.getSize() + Oop.getHeaderSize();
}
MethodDataKlass(OopHandle handle, ObjectHeap heap) {
super(handle, heap);
}
private static long headerSize;
public long getObjectSize() { return alignObjectSize(headerSize); }
public void printValueOn(PrintStream tty) {
tty.print("MethodDataKlass");
}
}

View File

@ -1,60 +0,0 @@
/*
* Copyright (c) 2000, 2001, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.oops;
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*;
// The MethodKlass is the klass of a Method
public class MethodKlass extends Klass {
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("methodKlass");
headerSize = type.getSize() + Oop.getHeaderSize();
}
MethodKlass(OopHandle handle, ObjectHeap heap) {
super(handle, heap);
}
private static long headerSize;
public long getObjectSize() { return alignObjectSize(headerSize); }
public void printValueOn(PrintStream tty) {
tty.print("MethodKlass");
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -44,16 +44,16 @@ public class ObjArrayKlass extends ArrayKlass {
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("objArrayKlass"); Type type = db.lookupType("objArrayKlass");
elementKlass = new OopField(type.getOopField("_element_klass"), Oop.getHeaderSize()); elementKlass = new MetadataField(type.getAddressField("_element_klass"), 0);
bottomKlass = new OopField(type.getOopField("_bottom_klass"), Oop.getHeaderSize()); bottomKlass = new MetadataField(type.getAddressField("_bottom_klass"), 0);
} }
ObjArrayKlass(OopHandle handle, ObjectHeap heap) { public ObjArrayKlass(Address addr) {
super(handle, heap); super(addr);
} }
private static OopField elementKlass; private static MetadataField elementKlass;
private static OopField bottomKlass; private static MetadataField bottomKlass;
public Klass getElementKlass() { return (Klass) elementKlass.getValue(this); } public Klass getElementKlass() { return (Klass) elementKlass.getValue(this); }
public Klass getBottomKlass() { return (Klass) bottomKlass.getValue(this); } public Klass getBottomKlass() { return (Klass) bottomKlass.getValue(this); }
@ -71,12 +71,10 @@ public class ObjArrayKlass extends ArrayKlass {
return arrayFlags; return arrayFlags;
} }
public void iterateFields(OopVisitor visitor, boolean doVMFields) { public void iterateFields(MetadataVisitor visitor) {
super.iterateFields(visitor, doVMFields); super.iterateFields(visitor);
if (doVMFields) { visitor.doMetadata(elementKlass, true);
visitor.doOop(elementKlass, true); visitor.doMetadata(bottomKlass, true);
visitor.doOop(bottomKlass, true);
}
} }
public Klass arrayKlassImpl(boolean orNull, int n) { public Klass arrayKlassImpl(boolean orNull, int n) {

View File

@ -1,61 +0,0 @@
/*
* Copyright (c) 2000, 2001, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.oops;
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*;
// An ObjArrayKlassKlass is klass for ObjArrayKlass'
// We only have one
public class ObjArrayKlassKlass extends ArrayKlassKlass {
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("objArrayKlassKlass");
headerSize = type.getSize() + Oop.getHeaderSize();
}
ObjArrayKlassKlass(OopHandle handle, ObjectHeap heap) {
super(handle, heap);
}
private static long headerSize;
public long getObjectSize() { return alignObjectSize(headerSize); }
public void printValueOn(PrintStream tty) {
tty.print("ObjArrayKlassKlass");
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -48,35 +48,15 @@ public class ObjectHeap {
DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null; DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null;
} }
private OopHandle methodKlassHandle; private Address boolArrayKlassHandle;
private OopHandle constMethodKlassHandle; private Address byteArrayKlassHandle;
private OopHandle methodDataKlassHandle; private Address charArrayKlassHandle;
private OopHandle constantPoolKlassHandle; private Address intArrayKlassHandle;
private OopHandle constantPoolCacheKlassHandle; private Address shortArrayKlassHandle;
private OopHandle klassKlassHandle; private Address longArrayKlassHandle;
private OopHandle instanceKlassKlassHandle; private Address singleArrayKlassHandle;
private OopHandle typeArrayKlassKlassHandle; private Address doubleArrayKlassHandle;
private OopHandle objArrayKlassKlassHandle;
private OopHandle boolArrayKlassHandle;
private OopHandle byteArrayKlassHandle;
private OopHandle charArrayKlassHandle;
private OopHandle intArrayKlassHandle;
private OopHandle shortArrayKlassHandle;
private OopHandle longArrayKlassHandle;
private OopHandle singleArrayKlassHandle;
private OopHandle doubleArrayKlassHandle;
private OopHandle arrayKlassKlassHandle;
private OopHandle compiledICHolderKlassHandle;
private MethodKlass methodKlassObj;
private ConstMethodKlass constMethodKlassObj;
private MethodDataKlass methodDataKlassObj;
private ConstantPoolKlass constantPoolKlassObj;
private ConstantPoolCacheKlass constantPoolCacheKlassObj;
private KlassKlass klassKlassObj;
private InstanceKlassKlass instanceKlassKlassObj;
private TypeArrayKlassKlass typeArrayKlassKlassObj;
private ObjArrayKlassKlass objArrayKlassKlassObj;
private TypeArrayKlass boolArrayKlassObj; private TypeArrayKlass boolArrayKlassObj;
private TypeArrayKlass byteArrayKlassObj; private TypeArrayKlass byteArrayKlassObj;
private TypeArrayKlass charArrayKlassObj; private TypeArrayKlass charArrayKlassObj;
@ -85,71 +65,34 @@ public class ObjectHeap {
private TypeArrayKlass longArrayKlassObj; private TypeArrayKlass longArrayKlassObj;
private TypeArrayKlass singleArrayKlassObj; private TypeArrayKlass singleArrayKlassObj;
private TypeArrayKlass doubleArrayKlassObj; private TypeArrayKlass doubleArrayKlassObj;
private ArrayKlassKlass arrayKlassKlassObj;
private CompiledICHolderKlass compiledICHolderKlassObj;
public void initialize(TypeDataBase db) throws WrongTypeException { public void initialize(TypeDataBase db) throws WrongTypeException {
// Lookup the roots in the object hierarchy. // Lookup the roots in the object hierarchy.
Type universeType = db.lookupType("Universe"); Type universeType = db.lookupType("Universe");
methodKlassHandle = universeType.getOopField("_methodKlassObj").getValue(); boolArrayKlassHandle = universeType.getAddressField("_boolArrayKlassObj").getValue();
methodKlassObj = new MethodKlass(methodKlassHandle, this); boolArrayKlassObj = new TypeArrayKlass(boolArrayKlassHandle);
constMethodKlassHandle = universeType.getOopField("_constMethodKlassObj").getValue(); byteArrayKlassHandle = universeType.getAddressField("_byteArrayKlassObj").getValue();
constMethodKlassObj = new ConstMethodKlass(constMethodKlassHandle, this); byteArrayKlassObj = new TypeArrayKlass(byteArrayKlassHandle);
constantPoolKlassHandle = universeType.getOopField("_constantPoolKlassObj").getValue(); charArrayKlassHandle = universeType.getAddressField("_charArrayKlassObj").getValue();
constantPoolKlassObj = new ConstantPoolKlass(constantPoolKlassHandle, this); charArrayKlassObj = new TypeArrayKlass(charArrayKlassHandle);
constantPoolCacheKlassHandle = universeType.getOopField("_constantPoolCacheKlassObj").getValue(); intArrayKlassHandle = universeType.getAddressField("_intArrayKlassObj").getValue();
constantPoolCacheKlassObj = new ConstantPoolCacheKlass(constantPoolCacheKlassHandle, this); intArrayKlassObj = new TypeArrayKlass(intArrayKlassHandle);
klassKlassHandle = universeType.getOopField("_klassKlassObj").getValue(); shortArrayKlassHandle = universeType.getAddressField("_shortArrayKlassObj").getValue();
klassKlassObj = new KlassKlass(klassKlassHandle, this); shortArrayKlassObj = new TypeArrayKlass(shortArrayKlassHandle);
arrayKlassKlassHandle = universeType.getOopField("_arrayKlassKlassObj").getValue(); longArrayKlassHandle = universeType.getAddressField("_longArrayKlassObj").getValue();
arrayKlassKlassObj = new ArrayKlassKlass(arrayKlassKlassHandle, this); longArrayKlassObj = new TypeArrayKlass(longArrayKlassHandle);
instanceKlassKlassHandle = universeType.getOopField("_instanceKlassKlassObj").getValue(); singleArrayKlassHandle = universeType.getAddressField("_singleArrayKlassObj").getValue();
instanceKlassKlassObj = new InstanceKlassKlass(instanceKlassKlassHandle, this); singleArrayKlassObj = new TypeArrayKlass(singleArrayKlassHandle);
typeArrayKlassKlassHandle = universeType.getOopField("_typeArrayKlassKlassObj").getValue(); doubleArrayKlassHandle = universeType.getAddressField("_doubleArrayKlassObj").getValue();
typeArrayKlassKlassObj = new TypeArrayKlassKlass(typeArrayKlassKlassHandle, this); doubleArrayKlassObj = new TypeArrayKlass(doubleArrayKlassHandle);
objArrayKlassKlassHandle = universeType.getOopField("_objArrayKlassKlassObj").getValue();
objArrayKlassKlassObj = new ObjArrayKlassKlass(objArrayKlassKlassHandle, this);
boolArrayKlassHandle = universeType.getOopField("_boolArrayKlassObj").getValue();
boolArrayKlassObj = new TypeArrayKlass(boolArrayKlassHandle, this);
byteArrayKlassHandle = universeType.getOopField("_byteArrayKlassObj").getValue();
byteArrayKlassObj = new TypeArrayKlass(byteArrayKlassHandle, this);
charArrayKlassHandle = universeType.getOopField("_charArrayKlassObj").getValue();
charArrayKlassObj = new TypeArrayKlass(charArrayKlassHandle, this);
intArrayKlassHandle = universeType.getOopField("_intArrayKlassObj").getValue();
intArrayKlassObj = new TypeArrayKlass(intArrayKlassHandle, this);
shortArrayKlassHandle = universeType.getOopField("_shortArrayKlassObj").getValue();
shortArrayKlassObj = new TypeArrayKlass(shortArrayKlassHandle, this);
longArrayKlassHandle = universeType.getOopField("_longArrayKlassObj").getValue();
longArrayKlassObj = new TypeArrayKlass(longArrayKlassHandle, this);
singleArrayKlassHandle = universeType.getOopField("_singleArrayKlassObj").getValue();
singleArrayKlassObj = new TypeArrayKlass(singleArrayKlassHandle, this);
doubleArrayKlassHandle = universeType.getOopField("_doubleArrayKlassObj").getValue();
doubleArrayKlassObj = new TypeArrayKlass(doubleArrayKlassHandle, this);
if (!VM.getVM().isCore()) {
methodDataKlassHandle = universeType.getOopField("_methodDataKlassObj").getValue();
methodDataKlassObj = new MethodDataKlass(methodDataKlassHandle, this);
compiledICHolderKlassHandle = universeType.getOopField("_compiledICHolderKlassObj").getValue();
compiledICHolderKlassObj= new CompiledICHolderKlass(compiledICHolderKlassHandle ,this);
}
} }
public ObjectHeap(TypeDataBase db) throws WrongTypeException { public ObjectHeap(TypeDataBase db) throws WrongTypeException {
@ -195,16 +138,6 @@ public class ObjectHeap {
public long getDoubleSize() { return doubleSize; } public long getDoubleSize() { return doubleSize; }
// Accessors for well-known system classes (from Universe) // Accessors for well-known system classes (from Universe)
public MethodKlass getMethodKlassObj() { return methodKlassObj; }
public ConstMethodKlass getConstMethodKlassObj() { return constMethodKlassObj; }
public MethodDataKlass getMethodDataKlassObj() { return methodDataKlassObj; }
public ConstantPoolKlass getConstantPoolKlassObj() { return constantPoolKlassObj; }
public ConstantPoolCacheKlass getConstantPoolCacheKlassObj() { return constantPoolCacheKlassObj; }
public KlassKlass getKlassKlassObj() { return klassKlassObj; }
public ArrayKlassKlass getArrayKlassKlassObj() { return arrayKlassKlassObj; }
public InstanceKlassKlass getInstanceKlassKlassObj() { return instanceKlassKlassObj; }
public ObjArrayKlassKlass getObjArrayKlassKlassObj() { return objArrayKlassKlassObj; }
public TypeArrayKlassKlass getTypeArrayKlassKlassObj() { return typeArrayKlassKlassObj; }
public TypeArrayKlass getBoolArrayKlassObj() { return boolArrayKlassObj; } public TypeArrayKlass getBoolArrayKlassObj() { return boolArrayKlassObj; }
public TypeArrayKlass getByteArrayKlassObj() { return byteArrayKlassObj; } public TypeArrayKlass getByteArrayKlassObj() { return byteArrayKlassObj; }
public TypeArrayKlass getCharArrayKlassObj() { return charArrayKlassObj; } public TypeArrayKlass getCharArrayKlassObj() { return charArrayKlassObj; }
@ -213,12 +146,6 @@ public class ObjectHeap {
public TypeArrayKlass getLongArrayKlassObj() { return longArrayKlassObj; } public TypeArrayKlass getLongArrayKlassObj() { return longArrayKlassObj; }
public TypeArrayKlass getSingleArrayKlassObj() { return singleArrayKlassObj; } public TypeArrayKlass getSingleArrayKlassObj() { return singleArrayKlassObj; }
public TypeArrayKlass getDoubleArrayKlassObj() { return doubleArrayKlassObj; } public TypeArrayKlass getDoubleArrayKlassObj() { return doubleArrayKlassObj; }
public CompiledICHolderKlass getCompiledICHolderKlassObj() {
if (Assert.ASSERTS_ENABLED) {
Assert.that(!VM.getVM().isCore(), "must not be called for core build");
}
return compiledICHolderKlassObj;
}
/** Takes a BasicType and returns the corresponding primitive array /** Takes a BasicType and returns the corresponding primitive array
klass */ klass */
@ -301,23 +228,14 @@ public class ObjectHeap {
visitor.epilogue(); visitor.epilogue();
} }
// Iterates through only the perm generation for the purpose of public boolean isValidMethod(Address handle) {
// finding static fields for liveness analysis try {
public void iteratePerm(HeapVisitor visitor) { Method m = (Method)Metadata.instantiateWrapperFor(handle);
CollectedHeap heap = VM.getVM().getUniverse().heap();
List liveRegions = new ArrayList();
addPermGenLiveRegions(liveRegions, heap);
sortLiveRegions(liveRegions);
iterateLiveRegions(liveRegions, visitor, null);
}
public boolean isValidMethod(OopHandle handle) {
OopHandle klass = Oop.getKlassForOopHandle(handle);
if (klass != null && klass.equals(methodKlassHandle)) {
return true; return true;
} } catch (Exception e) {
return false; return false;
} }
}
// Creates an instance from the Oop hierarchy based based on the handle // Creates an instance from the Oop hierarchy based based on the handle
public Oop newOop(OopHandle handle) { public Oop newOop(OopHandle handle) {
@ -329,60 +247,12 @@ public class ObjectHeap {
// Handle the null reference // Handle the null reference
if (handle == null) return null; if (handle == null) return null;
// First check if handle is one of the root objects
if (handle.equals(methodKlassHandle)) return getMethodKlassObj();
if (handle.equals(constMethodKlassHandle)) return getConstMethodKlassObj();
if (handle.equals(constantPoolKlassHandle)) return getConstantPoolKlassObj();
if (handle.equals(constantPoolCacheKlassHandle)) return getConstantPoolCacheKlassObj();
if (handle.equals(instanceKlassKlassHandle)) return getInstanceKlassKlassObj();
if (handle.equals(objArrayKlassKlassHandle)) return getObjArrayKlassKlassObj();
if (handle.equals(klassKlassHandle)) return getKlassKlassObj();
if (handle.equals(arrayKlassKlassHandle)) return getArrayKlassKlassObj();
if (handle.equals(typeArrayKlassKlassHandle)) return getTypeArrayKlassKlassObj();
if (handle.equals(boolArrayKlassHandle)) return getBoolArrayKlassObj();
if (handle.equals(byteArrayKlassHandle)) return getByteArrayKlassObj();
if (handle.equals(charArrayKlassHandle)) return getCharArrayKlassObj();
if (handle.equals(intArrayKlassHandle)) return getIntArrayKlassObj();
if (handle.equals(shortArrayKlassHandle)) return getShortArrayKlassObj();
if (handle.equals(longArrayKlassHandle)) return getLongArrayKlassObj();
if (handle.equals(singleArrayKlassHandle)) return getSingleArrayKlassObj();
if (handle.equals(doubleArrayKlassHandle)) return getDoubleArrayKlassObj();
if (!VM.getVM().isCore()) {
if (handle.equals(compiledICHolderKlassHandle)) return getCompiledICHolderKlassObj();
if (handle.equals(methodDataKlassHandle)) return getMethodDataKlassObj();
}
// Then check if obj.klass() is one of the root objects // Then check if obj.klass() is one of the root objects
OopHandle klass = Oop.getKlassForOopHandle(handle); Klass klass = Oop.getKlassForOopHandle(handle);
if (klass != null) { if (klass != null) {
if (klass.equals(methodKlassHandle)) return new Method(handle, this); if (klass instanceof TypeArrayKlass) return new TypeArray(handle, this);
if (klass.equals(constMethodKlassHandle)) return new ConstMethod(handle, this); if (klass instanceof ObjArrayKlass) return new ObjArray(handle, this);
if (klass.equals(constantPoolKlassHandle)) return new ConstantPool(handle, this); if (klass instanceof InstanceKlass) return new Instance(handle, this);
if (klass.equals(constantPoolCacheKlassHandle)) return new ConstantPoolCache(handle, this);
if (!VM.getVM().isCore()) {
if (klass.equals(compiledICHolderKlassHandle)) return new CompiledICHolder(handle, this);
if (klass.equals(methodDataKlassHandle)) return new MethodData(handle, this);
}
if (klass.equals(instanceKlassKlassHandle)) {
InstanceKlass ik = new InstanceKlass(handle, this);
if (ik.getName().asString().equals("java/lang/Class")) {
// We would normally do this using the vtable style
// lookup but since it's not used for these currently
// it's simpler to just check for the name.
return new InstanceMirrorKlass(handle, this);
}
return ik;
}
if (klass.equals(objArrayKlassKlassHandle)) return new ObjArrayKlass(handle, this);
if (klass.equals(typeArrayKlassKlassHandle)) return new TypeArrayKlass(handle, this);
// Lastly check if obj.klass().klass() is on of the root objects
OopHandle klassKlass = Oop.getKlassForOopHandle(klass);
if (klassKlass != null) {
if (klassKlass.equals(instanceKlassKlassHandle)) return new Instance(handle, this);
if (klassKlass.equals(objArrayKlassKlassHandle)) return new ObjArray(handle, this);
if (klassKlass.equals(typeArrayKlassKlassHandle)) return new TypeArray(handle, this);
}
} }
if (DEBUG) { if (DEBUG) {
@ -434,21 +304,15 @@ public class ObjectHeap {
visitor.prologue(totalSize); visitor.prologue(totalSize);
CompactibleFreeListSpace cmsSpaceOld = null; CompactibleFreeListSpace cmsSpaceOld = null;
CompactibleFreeListSpace cmsSpacePerm = null;
CollectedHeap heap = VM.getVM().getUniverse().heap(); CollectedHeap heap = VM.getVM().getUniverse().heap();
if (heap instanceof GenCollectedHeap) { if (heap instanceof GenCollectedHeap) {
GenCollectedHeap genHeap = (GenCollectedHeap) heap; GenCollectedHeap genHeap = (GenCollectedHeap) heap;
Generation genOld = genHeap.getGen(1); Generation genOld = genHeap.getGen(1);
Generation genPerm = genHeap.permGen();
if (genOld instanceof ConcurrentMarkSweepGeneration) { if (genOld instanceof ConcurrentMarkSweepGeneration) {
ConcurrentMarkSweepGeneration concGen = (ConcurrentMarkSweepGeneration)genOld; ConcurrentMarkSweepGeneration concGen = (ConcurrentMarkSweepGeneration)genOld;
cmsSpaceOld = concGen.cmsSpace(); cmsSpaceOld = concGen.cmsSpace();
} }
if (genPerm instanceof ConcurrentMarkSweepGeneration) {
ConcurrentMarkSweepGeneration concGen = (ConcurrentMarkSweepGeneration)genPerm;
cmsSpacePerm = concGen.cmsSpace();
}
} }
for (int i = 0; i < liveRegions.size(); i += 2) { for (int i = 0; i < liveRegions.size(); i += 2) {
@ -476,8 +340,6 @@ public class ObjectHeap {
if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle) ){ if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle) ){
size = cmsSpaceOld.collector().blockSizeUsingPrintezisBits(handle); size = cmsSpaceOld.collector().blockSizeUsingPrintezisBits(handle);
} else if ((cmsSpacePerm != null) && cmsSpacePerm.contains(handle) ){
size = cmsSpacePerm.collector().blockSizeUsingPrintezisBits(handle);
} }
if (size <= 0) { if (size <= 0) {
@ -494,8 +356,7 @@ public class ObjectHeap {
break; break;
} }
} }
if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle) || if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle)) {
(cmsSpacePerm != null) && cmsSpacePerm.contains(handle) ) {
handle = handle.addOffsetToAsOopHandle(CompactibleFreeListSpace.adjustObjectSizeInBytes(obj.getObjectSize()) ); handle = handle.addOffsetToAsOopHandle(CompactibleFreeListSpace.adjustObjectSizeInBytes(obj.getObjectSize()) );
} else { } else {
handle = handle.addOffsetToAsOopHandle(obj.getObjectSize()); handle = handle.addOffsetToAsOopHandle(obj.getObjectSize());
@ -513,32 +374,6 @@ public class ObjectHeap {
visitor.epilogue(); visitor.epilogue();
} }
private void addPermGenLiveRegions(List output, CollectedHeap heap) {
LiveRegionsCollector lrc = new LiveRegionsCollector(output);
if (heap instanceof SharedHeap) {
if (Assert.ASSERTS_ENABLED) {
Assert.that(heap instanceof GenCollectedHeap ||
heap instanceof G1CollectedHeap,
"Expecting GenCollectedHeap or G1CollectedHeap, " +
"but got " + heap.getClass().getName());
}
// Handles both GenCollectedHeap and G1CollectedHeap
SharedHeap sharedHeap = (SharedHeap) heap;
Generation gen = sharedHeap.permGen();
gen.spaceIterate(lrc, true);
} else if (heap instanceof ParallelScavengeHeap) {
ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
PSPermGen permGen = psh.permGen();
addLiveRegions(permGen.objectSpace().getLiveRegions(), output);
} else {
if (Assert.ASSERTS_ENABLED) {
Assert.that(false,
"Expecting SharedHeap or ParallelScavengeHeap, " +
"but got " + heap.getClass().getName());
}
}
}
private void addLiveRegions(List input, List output) { private void addLiveRegions(List input, List output) {
for (Iterator itr = input.iterator(); itr.hasNext();) { for (Iterator itr = input.iterator(); itr.hasNext();) {
MemRegion reg = (MemRegion) itr.next(); MemRegion reg = (MemRegion) itr.next();
@ -608,9 +443,6 @@ public class ObjectHeap {
} }
} }
// handle perm generation
addPermGenLiveRegions(liveRegions, heap);
// If UseTLAB is enabled, snip out regions associated with TLABs' // If UseTLAB is enabled, snip out regions associated with TLABs'
// dead regions. Note that TLABs can be present in any generation. // dead regions. Note that TLABs can be present in any generation.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -84,10 +84,6 @@ public class ObjectHistogramElement {
return tak.getElementTypeName() + "[]"; return tak.getElementTypeName() + "[]";
} else if (k instanceof ObjArrayKlass) { } else if (k instanceof ObjArrayKlass) {
ObjArrayKlass oak = (ObjArrayKlass) ak; ObjArrayKlass oak = (ObjArrayKlass) ak;
// See whether it's a "system objArray"
if (oak.equals(VM.getVM().getUniverse().systemObjArrayKlassObj())) {
return "* System ObjArray";
}
Klass bottom = oak.getBottomKlass(); Klass bottom = oak.getBottomKlass();
int dim = (int) oak.getDimension(); int dim = (int) oak.getDimension();
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,7 +30,6 @@ import sun.jvm.hotspot.utilities.*;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
import sun.jvm.hotspot.memory.CompactingPermGenGen;
// Oop represents the superclass for all types of // Oop represents the superclass for all types of
// objects in the HotSpot object heap. // objects in the HotSpot object heap.
@ -47,8 +46,11 @@ public class Oop {
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("oopDesc"); Type type = db.lookupType("oopDesc");
mark = new CIntField(type.getCIntegerField("_mark"), 0); mark = new CIntField(type.getCIntegerField("_mark"), 0);
klass = new OopField(type.getOopField("_metadata._klass"), 0); klass = new MetadataField(type.getAddressField("_metadata._klass"), 0);
compressedKlass = new NarrowOopField(type.getOopField("_metadata._compressed_klass"), 0); if (VM.getVM().isCompressedHeadersEnabled()) {
// compressedKlass = new CIntField(type.getCIntegerField("_metadata._compressed_klass"), 0);
throw new InternalError("unimplemented");
}
headerSize = type.getSize(); headerSize = type.getSize();
} }
@ -71,28 +73,16 @@ public class Oop {
public static long getHeaderSize() { return headerSize; } // Header size in bytes. public static long getHeaderSize() { return headerSize; } // Header size in bytes.
private static CIntField mark; private static CIntField mark;
private static OopField klass; private static MetadataField klass;
private static NarrowOopField compressedKlass; private static CIntField compressedKlass;
public boolean isShared() {
return CompactingPermGenGen.isShared(handle);
}
public boolean isSharedReadOnly() {
return CompactingPermGenGen.isSharedReadOnly(handle);
}
public boolean isSharedReadWrite() {
return CompactingPermGenGen.isSharedReadWrite(handle);
}
// Accessors for declared fields // Accessors for declared fields
public Mark getMark() { return new Mark(getHandle()); } public Mark getMark() { return new Mark(getHandle()); }
public Klass getKlass() { public Klass getKlass() {
if (VM.getVM().isCompressedOopsEnabled()) { if (VM.getVM().isCompressedHeadersEnabled()) {
return (Klass) compressedKlass.getValue(this); throw new InternalError("unimplemented");
} else { } else {
return (Klass) klass.getValue(this); return (Klass)klass.getValue(getHandle());
} }
} }
@ -113,14 +103,7 @@ public class Oop {
public boolean isArray() { return false; } public boolean isArray() { return false; }
public boolean isObjArray() { return false; } public boolean isObjArray() { return false; }
public boolean isTypeArray() { return false; } public boolean isTypeArray() { return false; }
public boolean isSymbol() { return false; }
public boolean isKlass() { return false; }
public boolean isThread() { return false; } public boolean isThread() { return false; }
public boolean isMethod() { return false; }
public boolean isMethodData() { return false; }
public boolean isConstantPool() { return false; }
public boolean isConstantPoolCache() { return false; }
public boolean isCompiledICHolder() { return false; }
// Align the object size. // Align the object size.
public static long alignObjectSize(long size) { public static long alignObjectSize(long size) {
@ -167,10 +150,10 @@ public class Oop {
void iterateFields(OopVisitor visitor, boolean doVMFields) { void iterateFields(OopVisitor visitor, boolean doVMFields) {
if (doVMFields) { if (doVMFields) {
visitor.doCInt(mark, true); visitor.doCInt(mark, true);
if (VM.getVM().isCompressedOopsEnabled()) { if (VM.getVM().isCompressedHeadersEnabled()) {
visitor.doOop(compressedKlass, true); throw new InternalError("unimplemented");
} else { } else {
visitor.doOop(klass, true); visitor.doMetadata(klass, true);
} }
} }
} }
@ -223,14 +206,14 @@ public class Oop {
public boolean verify() { return true;} public boolean verify() { return true;}
// Package-private routine to speed up ObjectHeap.newOop // Package-private routine to speed up ObjectHeap.newOop
static OopHandle getKlassForOopHandle(OopHandle handle) { static Klass getKlassForOopHandle(OopHandle handle) {
if (handle == null) { if (handle == null) {
return null; return null;
} }
if (VM.getVM().isCompressedOopsEnabled()) { if (VM.getVM().isCompressedHeadersEnabled()) {
return handle.getCompOopHandleAt(compressedKlass.getOffset()); throw new InternalError("Unimplemented");
} else { } else {
return handle.getOopHandleAt(klass.getOffset()); return (Klass)Metadata.instantiateWrapperFor(handle.getAddressAt(klass.getOffset()));
} }
} }
}; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,8 @@
package sun.jvm.hotspot.oops; package sun.jvm.hotspot.oops;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObject;
// The class for an oop field simply provides access to the value. // The class for an oop field simply provides access to the value.
public class OopField extends Field { public class OopField extends Field {
@ -55,6 +57,15 @@ public class OopField extends Field {
return obj.getHandle().getOopHandleAt(getOffset()); return obj.getHandle().getOopHandleAt(getOffset());
} }
public Oop getValue(VMObject obj) {
return VM.getVM().getObjectHeap().newOop(getValueAsOopHandle(obj));
}
/** Debugging support */
public OopHandle getValueAsOopHandle(VMObject obj) {
return obj.getAddress().getOopHandleAt(getOffset());
}
public void setValue(Oop obj) throws MutationException { public void setValue(Oop obj) throws MutationException {
// Fix this: setOopAt is missing in Address // Fix this: setOopAt is missing in Address
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -52,6 +52,12 @@ public class OopPrinter implements OopVisitor {
field.printOn(tty); field.printOn(tty);
} }
public void doMetadata(MetadataField field, boolean isVMField) {
printField(field);
field.getValue(getObj()).printValueOn(tty);
tty.println();
}
public void doOop(OopField field, boolean isVMField) { public void doOop(OopField field, boolean isVMField) {
printField(field); printField(field);
Oop.printOopValueOn(field.getValue(getObj()), tty); Oop.printOopValueOn(field.getValue(getObj()), tty);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,7 +27,7 @@ package sun.jvm.hotspot.oops;
// An OopVisitor can be used to inspect all fields within an object. // An OopVisitor can be used to inspect all fields within an object.
// Fields include vm fields, java fields, indexable fields. // Fields include vm fields, java fields, indexable fields.
public interface OopVisitor { public interface OopVisitor extends FieldVisitor {
// Called before visiting an object // Called before visiting an object
public void prologue(); public void prologue();
@ -38,17 +38,4 @@ public interface OopVisitor {
// Returns the object being visited // Returns the object being visited
public Oop getObj(); public Oop getObj();
// Callback methods for each field type in an object
public void doOop(OopField field, boolean isVMField);
public void doOop(NarrowOopField field, boolean isVMField);
public void doByte(ByteField field, boolean isVMField);
public void doChar(CharField field, boolean isVMField);
public void doBoolean(BooleanField field, boolean isVMField);
public void doShort(ShortField field, boolean isVMField);
public void doInt(IntField field, boolean isVMField);
public void doLong(LongField field, boolean isVMField);
public void doFloat(FloatField field, boolean isVMField);
public void doDouble(DoubleField field, boolean isVMField);
public void doCInt(CIntField field, boolean isVMField);
}; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -61,10 +61,6 @@ public abstract class ProfileData {
int uintAt(int index) { int uintAt(int index) {
return (int)intptrAt(index); return (int)intptrAt(index);
} }
Oop oopAt(int index) {
return data().oopAt(index);
}
public Address addressAt(int index) { public Address addressAt(int index) {
return data().addressAt(index); return data().addressAt(index);
} }

Some files were not shown because too many files have changed in this diff Show More