OpenJDK / jdk / jdk
changeset 13728:882756847a04
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
line wrap: on
line diff
--- a/hotspot/agent/doc/clhsdb.html Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/doc/clhsdb.html Sat Sep 01 13:25:18 2012 -0400 @@ -38,10 +38,10 @@ 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> 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> 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> 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> @@ -51,7 +51,7 @@ 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> 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> 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> @@ -59,7 +59,7 @@ 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> 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 <address></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>
--- a/hotspot/agent/src/os/bsd/ps_core.c Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/os/bsd/ps_core.c Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -210,7 +210,6 @@ // 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. -// Refer to CompactingPermGenGen::n_regions in compactingPermGenGen.hpp #define NUM_SHARED_MAPS 4 // Refer to FileMapInfo::_current_version in filemap.hpp @@ -234,7 +233,7 @@ char _read_only; // read only 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. };
--- a/hotspot/agent/src/os/linux/ps_core.c Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/os/linux/ps_core.c Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -209,7 +209,6 @@ // 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. -// Refer to CompactingPermGenGen::n_regions in compactingPermGenGen.hpp #define NUM_SHARED_MAPS 4 // Refer to FileMapInfo::_current_version in filemap.hpp @@ -233,7 +232,7 @@ char _read_only; // read only 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. };
--- a/hotspot/agent/src/os/solaris/proc/saproc.cpp Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/os/solaris/proc/saproc.cpp Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -510,7 +510,6 @@ // 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. -// Refer to CompactingPermGenGen::n_regions in compactingPermGenGen.hpp const int NUM_SHARED_MAPS = 4; // Refer to FileMapInfo::_current_version in filemap.hpp @@ -531,7 +530,7 @@ bool _read_only; // read only 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. };
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -634,29 +634,57 @@ } else { String s = t.nextToken(); if (s.equals("-a")) { - HeapVisitor iterator = new DefaultHeapVisitor() { - public boolean doObj(Oop obj) { - if (obj instanceof MethodData) { - Method m = ((MethodData)obj).getMethod(); - out.println("MethodData " + obj.getHandle() + " for " + + SystemDictionary sysDict = VM.getVM().getSystemDictionary(); + sysDict.allClassesDo(new SystemDictionary.ClassVisitor() { + public void visit(Klass k) { + if (k instanceof InstanceKlass) { + 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() + "." + m.getName().asString() + - m.getSignature().asString() + "@" + m.getHandle()); - ((MethodData)obj).printDataOn(out); + m.getSignature().asString() + "@" + m.getAddress()); + mdo.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); + 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) { // Do a full dump of the nodes reachabile from root in each compiler thread. public void doit(Tokens t) { @@ -1229,7 +1257,7 @@ } }; VM.getVM().getObjectHeap().iterateRaw(iterator); - } else if (type.equals("heap") || type.equals("perm")) { + } else if (type.equals("heap")) { HeapVisitor iterator = new DefaultHeapVisitor() { public boolean doObj(Oop obj) { int index = 0; @@ -1246,11 +1274,7 @@ return false; } }; - if (type.equals("heap")) { VM.getVM().getObjectHeap().iterate(iterator); - } else { - VM.getVM().getObjectHeap().iteratePerm(iterator); - } } else if (type.equals("codecache")) { CodeCacheVisitor v = new CodeCacheVisitor() { public void prologue(Address start, Address end) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -998,7 +998,7 @@ curFrame.addressOfInterpreterFrameLocal((int) interpreterFrameMethod.getMaxLocals() + offset), "Interpreter locals area for frame with SP = " + curFrame.getSP())); } - String methodAnno = "Interpreter frame methodOop"; + String methodAnno = "Interpreter frame Method*"; if (interpreterFrameMethod == null) { methodAnno += " (BAD OOP)"; } @@ -1054,13 +1054,6 @@ } } - if (bad) { - // Try perm gen - if (heap.permGen().isIn(handle)) { - anno = "PermGen "; - bad = false; - } - } } else if (collHeap instanceof ParallelScavengeHeap) { ParallelScavengeHeap heap = (ParallelScavengeHeap) collHeap; if (heap.youngGen().isIn(handle)) { @@ -1069,9 +1062,6 @@ } else if (heap.oldGen().isIn(handle)) { anno = "PSOldGen "; bad = false; - } else if (heap.permGen().isIn(handle)) { - anno = "PSPermGen "; - bad = false; } } else { // Optimistically assume the oop isn't bad
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -50,6 +50,7 @@ private static final int C_INT8_SIZE = 1; private static final int C_INT32_SIZE = 4; private static final int C_INT64_SIZE = 8; + private static int pointerSize = UNINITIALIZED_SIZE; private static final boolean DEBUG; static { @@ -185,6 +186,9 @@ long size = entryAddr.getCIntegerAt(typeEntrySizeOffset, C_INT64_SIZE, true); createType(typeName, superclassName, isOopType, isIntegerType, isUnsigned, size); + if (pointerSize == UNINITIALIZED_SIZE && typeName.equals("void*")) { + pointerSize = (int)size; + } } entryAddr = entryAddr.addOffsetTo(typeEntryArrayStride); @@ -678,7 +682,11 @@ } } 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); return result; } @@ -731,9 +739,11 @@ "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) " + "had its size declared as " + size + " twice. Continuing."); } + } }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciArrayKlassKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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 ciArrayKlassKlass extends ciKlassKlass { - 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("ciArrayKlassKlass"); - } - - - public ciArrayKlassKlass(Address addr) { - super(addr); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciBaseObject.java Sat Sep 01 13:25:18 2012 -0400 @@ -0,0 +1,53 @@ +/* + * 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 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.*; +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 ciBaseObject extends VMObject { + 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("ciBaseObject"); + identField = new CIntField(type.getCIntegerField("_ident"), 0); + } + + private static CIntField identField; + + public ciBaseObject(Address addr) { + super(addr); + } +}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -47,8 +47,8 @@ Type type = db.lookupType("ciInstanceKlass"); initStateField = new CIntField(type.getCIntegerField("_init_state"), 0); isSharedField = new CIntField(type.getCIntegerField("_is_shared"), 0); - CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue(); - CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue(); + CLASS_STATE_LINKED = db.lookupIntConstant("InstanceKlass::linked").intValue(); + CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("InstanceKlass::fully_initialized").intValue(); } private static CIntField initStateField; @@ -63,7 +63,7 @@ public int initState() { int initState = (int)initStateField.getValue(getAddress()); if (isShared() && initState < CLASS_STATE_LINKED) { - InstanceKlass ik = (InstanceKlass)getOop(); + InstanceKlass ik = (InstanceKlass)getMetadata(); initState = ik.getInitStateAsInt(); } return initState;
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlassKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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 ciInstanceKlassKlass extends ciKlassKlass { - 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("ciInstanceKlassKlass"); - } - - - public ciInstanceKlassKlass(Address addr) { - super(addr); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciKlassKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMetadata.java Sat Sep 01 13:25:18 2012 -0400 @@ -0,0 +1,65 @@ +/* + * 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 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.*; +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 ciMetadata extends ciBaseObject { + 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("ciMetadata"); + metadataField = new MetadataField(type.getAddressField("_metadata"), 0); + } + + private static MetadataField metadataField; + + public Metadata getMetadata() { + return metadataField.getValue(getAddress()); + } + + public ciMetadata(Address addr) { + super(addr); + } + + public void printOn(PrintStream out) { + getMetadata().printValueOn(out); + } + + public String toString() { + return getMetadata().toString(); + } +}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.types.*; -public class ciMethod extends ciObject { +public class ciMethod extends ciMetadata { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -61,7 +61,7 @@ } public Method method() { - return (Method)getOop(); + return (Method)getMetadata(); } public int interpreterThrowoutCount() { @@ -75,7 +75,7 @@ public int instructionsSize() { if (instructionsSizeField == null) { // XXX - Method method = (Method)getOop(); + Method method = method(); NMethod nm = method.getNativeMethod(); if (nm != null) return (int)nm.codeEnd().minus(nm.getVerifiedEntryPoint()); return 0; @@ -84,7 +84,7 @@ } public void printShortName(PrintStream st) { - Method method = (Method)getOop(); + Method method = method(); st.printf(" %s::%s", method.getMethodHolder().getName().asString().replace('/', '.'), method.getName().asString()); }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.types.*; -public class ciMethodData extends ciObject { +public class ciMethodData extends ciMetadata { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -54,7 +54,7 @@ extraDataSizeField = new CIntField(type.getCIntegerField("_extra_data_size"), 0); dataSizeField = new CIntField(type.getCIntegerField("_data_size"), 0); stateField = new CIntField(type.getCIntegerField("_state"), 0); - sizeofMethodDataOopDesc = (int)db.lookupType("methodDataOopDesc").getSize();; + sizeofMethodDataOopDesc = (int)db.lookupType("MethodData").getSize();; } private static AddressField origField; @@ -83,7 +83,7 @@ } 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()); byte[] result = new byte[MethodData.sizeofMethodDataOopDesc]; for (int i = 0; i < MethodData.sizeofMethodDataOopDesc; i++) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciObjArrayKlassKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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 ciObjArrayKlassKlass 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("ciObjArrayKlassKlass"); - } - - - public ciObjArrayKlassKlass(Address addr) { - super(addr); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciObject.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciObject.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.types.*; -public class ciObject extends VMObject { +public class ciObject extends ciBaseObject { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -42,12 +42,10 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { Type type = db.lookupType("ciObject"); - identField = new CIntField(type.getCIntegerField("_ident"), 0); klassField = type.getAddressField("_klass"); handleField = type.getAddressField("_handle"); } - private static CIntField identField; private static AddressField klassField; private static AddressField handleField;
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciObjectFactory.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciObjectFactory.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -44,18 +44,20 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { Type type = db.lookupType("ciObjectFactory"); unloadedMethodsField = type.getAddressField("_unloaded_methods"); - ciObjectsField = type.getAddressField("_ci_objects"); + ciMetadataField = type.getAddressField("_ci_metadata"); symbolsField = type.getAddressField("_symbols"); 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); } private static AddressField unloadedMethodsField; - private static AddressField ciObjectsField; + private static AddressField ciMetadataField; private static AddressField symbolsField; private static VirtualBaseConstructor<ciObject> ciObjectConstructor; + private static VirtualBaseConstructor<ciMetadata> ciMetadataConstructor; private static VirtualBaseConstructor<ciSymbol> ciSymbolConstructor; public static ciObject get(Address addr) { @@ -64,8 +66,14 @@ return (ciObject)ciObjectConstructor.instantiateWrapperFor(addr); } - public GrowableArray<ciObject> objects() { - return GrowableArray.create(ciObjectsField.getValue(getAddress()), ciObjectConstructor); + public static ciMetadata getMetadata(Address addr) { + 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() {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciReceiverTypeData.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciReceiverTypeData.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public ciKlass receiverAt(int row) { //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)) { System.err.println(recv); }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciSymbol.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciSymbol.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.types.*; -public class ciSymbol extends VMObject { +public class ciSymbol extends ciMetadata { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -42,12 +42,10 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { Type type = db.lookupType("ciSymbol"); - identField = type.getCIntegerField("_ident"); symbolField = type.getAddressField("_symbol"); } private static AddressField symbolField; - private static CIntegerField identField; public String asUtf88() { Symbol sym = Symbol.create(symbolField.getValue(getAddress()));
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciType.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciType.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.types.*; -public class ciType extends ciObject { +public class ciType extends ciMetadata { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciTypeArrayKlassKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciVirtualCallData.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciVirtualCallData.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public ciKlass receiverAt(int row) { //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)) { System.err.println(recv); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/classfile/ClassLoaderData.java Sat Sep 01 13:25:18 2012 -0400 @@ -0,0 +1,66 @@ +/* + * 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 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.classfile; + +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 ClassLoaderData extends VMObject { + 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("ClassLoaderData"); + classLoaderField = type.getOopField("_class_loader"); + nextField = type.getAddressField("_next"); + } + + private static sun.jvm.hotspot.types.OopField classLoaderField; + private static AddressField nextField; + + public ClassLoaderData(Address 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())); + } +}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.runtime.VM; import sun.jvm.hotspot.utilities.*; +import sun.jvm.hotspot.oops.Method; public class DebugInfoReadStream extends CompressedReadStream { private NMethod code; @@ -53,6 +54,10 @@ return code.getOopAt(readInt()); } + public Method readMethod() { + return code.getMethodAt(readInt()); + } + ScopeValue readObjectValue() { int id = readInt(); if (Assert.ASSERTS_ENABLED) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ public class NMethod extends CodeBlob { 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 */ private static CIntegerField entryBCIField; /** To support simple linked-list chaining of nmethods */ @@ -50,6 +50,7 @@ private static CIntegerField origPCOffsetField; private static CIntegerField stubOffsetField; private static CIntegerField oopsOffsetField; + private static CIntegerField metadataOffsetField; private static CIntegerField scopesDataOffsetField; private static CIntegerField scopesPCsOffsetField; private static CIntegerField dependenciesOffsetField; @@ -88,7 +89,7 @@ private static void initialize(TypeDataBase db) { Type type = db.lookupType("nmethod"); - methodField = type.getOopField("_method"); + methodField = type.getAddressField("_method"); entryBCIField = type.getCIntegerField("_entry_bci"); osrLinkField = type.getAddressField("_osr_link"); scavengeRootLinkField = type.getAddressField("_scavenge_root_link"); @@ -100,6 +101,7 @@ origPCOffsetField = type.getCIntegerField("_orig_pc_offset"); stubOffsetField = type.getCIntegerField("_stub_offset"); oopsOffsetField = type.getCIntegerField("_oops_offset"); + metadataOffsetField = type.getCIntegerField("_metadata_offset"); scopesDataOffsetField = type.getCIntegerField("_scopes_data_offset"); scopesPCsOffsetField = type.getCIntegerField("_scopes_pcs_offset"); dependenciesOffsetField = type.getCIntegerField("_dependencies_offset"); @@ -126,7 +128,7 @@ } public Method getMethod() { - return (Method) VM.getVM().getObjectHeap().newOop(methodField.getValue(addr)); + return (Method)Metadata.instantiateWrapperFor(methodField.getValue(addr)); } // Type info @@ -146,7 +148,9 @@ public Address stubBegin() { return headerBegin().addOffsetTo(getStubOffset()); } public Address stubEnd() { 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 scopesDataEnd() { return headerBegin().addOffsetTo(getScopesPCsOffset()); } public Address scopesPCsBegin() { return headerBegin().addOffsetTo(getScopesPCsOffset()); } @@ -162,6 +166,7 @@ public int instsSize() { return (int) instsEnd() .minus(instsBegin()); } public int stubSize() { return (int) stubEnd() .minus(stubBegin()); } 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 scopesPCsSize() { return (int) scopesPCsEnd() .minus(scopesPCsBegin()); } public int dependenciesSize() { return (int) dependenciesEnd().minus(dependenciesBegin()); } @@ -185,12 +190,14 @@ 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 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 scopesPCsContains (Address addr) { return scopesPCsBegin() .lessThanOrEqual(addr) && scopesPCsEnd() .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 int getOopsLength() { return (int) (oopsSize() / VM.getVM().getOopSize()); } + public int getMetadataLength() { return (int) (metadataSize() / VM.getVM().getOopSize()); } /** Entry points */ public Address getEntryPoint() { return entryPointField.getValue(addr); } @@ -205,6 +212,19 @@ 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 lazy_interpreter_entry_point() for C2 @@ -412,6 +432,7 @@ private int getDeoptMhOffset() { return (int) deoptMhOffsetField .getValue(addr); } private int getStubOffset() { return (int) stubOffsetField .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 getScopesPCsOffset() { return (int) scopesPCsOffsetField .getValue(addr); } private int getDependenciesOffset() { return (int) dependenciesOffsetField.getValue(addr); }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,7 @@ DebugInfoReadStream stream = streamAt(decodeOffset); senderDecodeOffset = stream.readInt(); - method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); + method = stream.readMethod(); bci = stream.readBCI(); // Decode offsets for body and sender localsDecodeOffset = stream.readInt(); @@ -79,7 +79,7 @@ DebugInfoReadStream stream = streamAt(decodeOffset); senderDecodeOffset = stream.readInt(); - method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); + method = stream.readMethod(); bci = stream.readBCI(); // Decode offsets for body and sender localsDecodeOffset = stream.readInt();
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -56,8 +56,8 @@ } public Method method() { - OopHandle oh = methodField.getValue(getAddress()).getOopHandleAt(0); - return (Method)VM.getVM().getObjectHeap().newOop(oh); + Address oh = methodField.getValue(getAddress()).getAddressAt(0); + return (Method)Metadata.instantiateWrapperFor(oh); } public int osrBci() {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/parallelScavenge/PSPermGen.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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 -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/parallelScavenge/ParallelScavengeHeap.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/parallelScavenge/ParallelScavengeHeap.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,6 @@ Type type = db.lookupType("ParallelScavengeHeap"); youngGenField = type.getAddressField("_young_gen"); oldGenField = type.getAddressField("_old_gen"); - permGenField = type.getAddressField("_perm_gen"); } public ParallelScavengeHeap(Address addr) { @@ -55,7 +54,6 @@ // Fields private static AddressField youngGenField; private static AddressField oldGenField; - private static AddressField permGenField; // Accessors public PSYoungGen youngGen() { @@ -66,10 +64,6 @@ return (PSOldGen) VMObjectFactory.newObject(PSOldGen.class, oldGenField.getValue()); } - public PSPermGen permGen() { - return (PSPermGen) VMObjectFactory.newObject(PSPermGen.class, permGenField.getValue()); - } - public long capacity() { return youngGen().capacity() + oldGen().capacity(); } @@ -87,10 +81,6 @@ return true; } - if (permGen().isIn(a)) { - return true; - } - return false; } @@ -102,7 +92,6 @@ tty.print("ParallelScavengeHeap [ "); youngGen().printOn(tty); oldGen().printOn(tty); - permGen().printOn(tty); tty.print(" ] "); } }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeDisassembler.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeDisassembler.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -138,9 +138,9 @@ } } - Object bytecodeObj = null; + Bytecode bytecodeObj = null; try { - bytecodeObj = cstr.newInstance(new Object[] { method, new Integer(bci) }); + bytecodeObj = (Bytecode)cstr.newInstance(new Object[] { method, new Integer(bci) }); } catch (Exception exp) { if (Assert.ASSERTS_ENABLED) { Assert.that(false, "Bytecode instance of class " @@ -153,11 +153,10 @@ } try { - visitor.visit((Bytecode) bytecodeObj); + visitor.visit(bytecodeObj); } catch(ClassCastException castfail) { - if (Assert.ASSERTS_ENABLED) { - Assert.that(false, clazz.getName() + " is not derived from Bytecode!"); - } + castfail.printStackTrace(); + System.err.println(method.getAddress() + " " + bci); } }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeInvoke.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeInvoke.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -55,8 +55,7 @@ public Symbol name() { ConstantPool cp = method().getConstants(); if (isInvokedynamic()) { - int[] nt = cp.getNameAndTypeAt(indexForFieldOrMethod()); - return cp.getSymbolAt(nt[0]); + return cp.uncachedGetNameRefAt(indexForFieldOrMethod()); } return cp.getNameRefAt(index()); } @@ -65,20 +64,11 @@ public Symbol signature() { ConstantPool cp = method().getConstants(); if (isInvokedynamic()) { - int[] nt = cp.getNameAndTypeAt(indexForFieldOrMethod()); - return cp.getSymbolAt(nt[1]); + return cp.uncachedGetSignatureRefAt(indexForFieldOrMethod()); } 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() { return method().getConstants().getMethodRefAt(index()); } @@ -123,7 +113,7 @@ buf.append(Integer.toString(indexForFieldOrMethod())); if (isInvokedynamic()) { buf.append('('); - buf.append(Integer.toString(getSecondaryIndex())); + buf.append(Integer.toString(index())); buf.append(')'); } buf.append(" [Method ");
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeLoadConstant.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeLoadConstant.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -46,12 +46,11 @@ } public int poolIndex() { - int i = rawIndex(); + int index = rawIndex(); if (hasCacheIndex()) { - ConstantPoolCache cpCache = method().getConstants().getCache(); - return cpCache.getEntryAt(i).getConstantPoolIndex(); + return method().getConstants().objectToCPIndex(index); } else { - return i; + return index; } } @@ -72,8 +71,7 @@ private Oop getCachedConstant() { int i = cacheIndex(); if (i >= 0) { - ConstantPoolCache cpCache = method().getConstants().getCache(); - return cpCache.getEntryAt(i).getF1(); + throw new InternalError("invokedynamic not implemented yet"); } return null; } @@ -96,7 +94,7 @@ return (ctag.isDouble() || ctag.isLong()) ? true: false; } else { // has to be int or float or String or Klass - return (ctag.isUnresolvedString() || ctag.isString() + return (ctag.isString() || ctag.isUnresolvedKlass() || ctag.isKlass() || ctag.isMethodHandle() || ctag.isMethodType() || ctag.isInt() || ctag.isFloat())? true: false; @@ -124,9 +122,9 @@ ConstantPool cpool = method().getConstants(); int cpIndex = poolIndex(); ConstantPool.CPSlot oop = cpool.getSlotAt(cpIndex); - if (oop.isOop()) { - return (Klass) oop.getOop(); - } else if (oop.isMetaData()) { + if (oop.isResolved()) { + return oop.getKlass(); + } else if (oop.isUnresolved()) { return oop.getSymbol(); } else { throw new RuntimeException("should not reach here"); @@ -163,28 +161,21 @@ return "<float " + Float.toString(cpool.getFloatAt(cpIndex)) + "F>"; } else if (ctag.isDouble()) { 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. // We just look at the object at the corresponding index and // decide based on the oop type. - ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex); - if (obj.isMetaData()) { - Symbol sym = obj.getSymbol(); + Symbol sym = cpool.getUnresolvedStringAt(cpIndex); 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()) { // tag change from 'unresolved' to 'klass' does not happen atomically. // We just look at the object at the corresponding index and // decide based on the oop type. ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex); - if (obj.isOop()) { - Klass k = (Klass) obj.getOop(); - return "<Class " + k.getName().asString() + "@" + k.getHandle() + ">"; - } else if (obj.isMetaData()) { + if (obj.isResolved()) { + Klass k = obj.getKlass(); + return "<Class " + k.getName().asString() + "@" + k.getAddress() + ">"; + } else if (obj.isUnresolved()) { Symbol sym = obj.getSymbol(); return "<Class " + sym.asString() + ">"; } else {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeWithCPIndex.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeWithCPIndex.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -35,10 +35,17 @@ } // the constant pool index for this bytecode - public int index() { return getIndexU2(code(), false); } - - public int getSecondaryIndex() { - throw new IllegalArgumentException("must be invokedynamic"); + public int index() { + if (code() == Bytecodes._invokedynamic) { + int index = getIndexU4(); + if (ConstantPool.isInvokedynamicIndex(index)) { + return ConstantPool.decodeInvokedynamicIndex(index); + } else { + return index; + } + } else { + return getIndexU2(code(), false); + } } protected int indexForFieldOrMethod() { @@ -47,12 +54,8 @@ int cpCacheIndex = index(); if (cpCache == null) { return cpCacheIndex; - } else if (code() == Bytecodes._invokedynamic) { - int secondaryIndex = getSecondaryIndex(); - return cpCache.getMainEntryAt(secondaryIndex).getConstantPoolIndex(); } else { - // change byte-ordering and go via cache - return cpCache.getEntryAt((int) (0xFFFF & VM.getVM().getBytes().swapShort((short) cpCacheIndex))).getConstantPoolIndex(); + return cpCache.getEntryAt((int) (0xFFFF & cpCacheIndex)).getConstantPoolIndex(); } } }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeWithKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeWithKlass.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -33,15 +33,15 @@ } protected Klass getKlass() { - return method().getConstants().getKlassRefAt(index()); + return method().getConstants().getKlassAt(index()); } public Symbol getClassName() { ConstantPool.CPSlot obj = method().getConstants().getSlotAt(index()); - if (obj.isMetaData()) { + if (obj.isUnresolved()) { return obj.getSymbol(); } else { - return ((Klass)obj.getOop()).getName(); + return obj.getKlass().getName(); } }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/Bytecodes.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/Bytecodes.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -362,7 +362,7 @@ // find a bytecode, behind a breakpoint if necessary: // 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 public static boolean isDefined (int code) { return 0 <= code && code < number_of_codes && flags(code, false) != 0; } @@ -743,7 +743,7 @@ def(_invokespecial , "invokespecial" , "bJJ" , null , BasicType.getTIllegal(), -1, true ); def(_invokestatic , "invokestatic" , "bJJ" , null , BasicType.getTIllegal(), 0, 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(_newarray , "newarray" , "bc" , null , BasicType.getTObject() , 0, true ); def(_anewarray , "anewarray" , "bkk" , null , BasicType.getTObject() , 0, true ); @@ -763,6 +763,7 @@ // JVM bytecodes // 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_bgetfield , "fast_bgetfield" , "bJJ" , null , BasicType.getTInt() , 0, true , _getfield ); def(_fast_cgetfield , "fast_cgetfield" , "bJJ" , null , BasicType.getTChar() , 0, true , _getfield );
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java Sat Sep 01 13:25:18 2012 -0400 @@ -135,15 +135,15 @@ ReferenceTypeImpl other = (ReferenceTypeImpl)refType; int comp = name().compareTo(other.name()); if (comp == 0) { - Oop rf1 = ref(); - Oop rf2 = other.ref(); + Klass rf1 = ref(); + Klass rf2 = other.ref(); // optimize for typical case: refs equal and VMs equal if (rf1.equals(rf2)) { // sequenceNumbers are always positive comp = vm.sequenceNumber - ((VirtualMachineImpl)(other.virtualMachine())).sequenceNumber; } else { - comp = rf1.getHandle().minus(rf2.getHandle()) < 0? -1 : 1; + comp = rf1.getAddress().minus(rf2.getAddress()) < 0? -1 : 1; } } return comp; @@ -225,7 +225,7 @@ private boolean isThrowableBacktraceField(sun.jvm.hotspot.oops.Field fld) { // refer to JvmtiEnv::GetClassFields in jvmtiEnv.cpp. // 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()) && fld.getID().getName().equals("backtrace")) { return true; @@ -932,7 +932,7 @@ } long uniqueID() { - return vm.getAddressValue(ref()); + return vm.getAddressValue(ref().getJavaMirror()); } // new method since 1.6
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/VirtualMachineImpl.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/VirtualMachineImpl.java Sat Sep 01 13:25:18 2012 -0400 @@ -447,7 +447,7 @@ newRefType = new ClassTypeImpl(this, (InstanceKlass)kk); } } else { - throw new RuntimeException("should not reach here"); + throw new RuntimeException("should not reach here:" + kk); } typesByID.put(kk, newRefType);
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CMSPermGen.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +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 java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; - -public class CMSPermGen 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("CMSPermGen"); - genField = type.getAddressField("_gen"); - } - - public CMSPermGen(Address addr) { - super(addr); - } - - public Generation asGen() { - return GenerationFactory.newObject(genField.getValue(addr)); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CMSPermGenGen.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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"; - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -168,7 +168,7 @@ final long addressSize = vm.getAddressSize(); for (; cur.lessThan(limit);) { - Address klassOop = cur.getAddressAt(addressSize); + Address k = cur.getAddressAt(addressSize); if (FreeChunk.indicatesFreeChunk(cur)) { if (! cur.equals(regionStart)) { res.add(new MemRegion(regionStart, cur)); @@ -181,7 +181,7 @@ // note that fc.size() gives chunk size in heap words cur = cur.addOffsetTo(chunkSize * addressSize); regionStart = cur; - } else if (klassOop != null) { + } else if (k != null) { Oop obj = heap.newOop(cur.addOffsetToAsOopHandle(0)); long objectSize = obj.getObjectSize(); cur = cur.addOffsetTo(adjustObjectSizeInBytes(objectSize));
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactingPermGen.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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)); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactingPermGenGen.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/ContigPermSpace.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Dictionary.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Dictionary.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -63,10 +63,9 @@ for (int index = 0; index < tblSize; index++) { for (DictionaryEntry probe = (DictionaryEntry) bucket(index); probe != null; probe = (DictionaryEntry) probe.next()) { - Oop k = probe.klass(); - if (k.isKlass() && - heap.equal(probe.loader(), ((InstanceKlass) k).getClassLoader())) { - v.visit((Klass) k); + Klass k = probe.klass(); + if (heap.equal(probe.loader(), ((InstanceKlass) k).getClassLoader())) { + v.visit(k); } } } @@ -78,10 +77,8 @@ for (int index = 0; index < tblSize; index++) { for (DictionaryEntry probe = (DictionaryEntry) bucket(index); probe != null; probe = (DictionaryEntry) probe.next()) { - Oop k = probe.klass(); - if (k.isKlass()) { - v.visit((Klass) k, probe.loader()); - } + Klass k = probe.klass(); + v.visit(k, probe.loader()); } } }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.jvm.hotspot.memory; import java.util.*; +import sun.jvm.hotspot.classfile.ClassLoaderData; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.types.*; @@ -43,12 +44,12 @@ private static synchronized void initialize(TypeDataBase db) { Type type = db.lookupType("DictionaryEntry"); pdSetField = type.getAddressField("_pd_set"); - loaderField = type.getOopField("_loader"); + loaderDataField = type.getAddressField("_loader_data"); } // Fields private static AddressField pdSetField; - private static sun.jvm.hotspot.types.OopField loaderField; + private static AddressField loaderDataField; // Accessors @@ -59,11 +60,15 @@ } 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() { - return (Klass)VM.getVM().getObjectHeap().newOop(literalValue().addOffsetToAsOopHandle(0)); + return (Klass)Metadata.instantiateWrapperFor(literalValue()); } public DictionaryEntry(Address addr) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -90,7 +90,7 @@ } } - return permGen().isIn(a); + return false; } public long capacity() { @@ -140,7 +140,5 @@ tty.println("Invocations: " + getGen(i).invocations()); tty.println(); } - permGen().printOn(tty); - tty.println("Invocations: " + permGen().invocations()); } }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Generation.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Generation.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,6 @@ <ul> <li> OneContigSpaceCardGeneration <ul> - <li> CompactingPermGenGen <li> TenuredGeneration </ul> </ul>
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/GenerationFactory.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/GenerationFactory.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -47,8 +47,6 @@ private static synchronized void initialize(TypeDataBase db) { ctor = new VirtualConstructor(db); - ctor.addMapping("CompactingPermGenGen", CompactingPermGenGen.class); - ctor.addMapping("CMSPermGenGen", CMSPermGenGen.class); ctor.addMapping("DefNewGeneration", DefNewGeneration.class); ctor.addMapping("ParNewGeneration", ParNewGeneration.class); ctor.addMapping("TenuredGeneration", TenuredGeneration.class);
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/PermGen.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +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.*; -import sun.jvm.hotspot.runtime.*; - -/** All heaps contains a "permanent generation," containing permanent - (reflective) objects. This is like a regular generation in some - 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 { - // NEEDS_CLEANUP - public PermGen(Address addr) { - super(addr); - } - - public abstract Generation asGen(); -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/PlaceholderEntry.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/PlaceholderEntry.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.jvm.hotspot.memory; import java.util.*; +import sun.jvm.hotspot.classfile.ClassLoaderData; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.types.*; @@ -42,15 +43,19 @@ private static synchronized void initialize(TypeDataBase db) { Type type = db.lookupType("PlaceholderEntry"); - loaderField = type.getOopField("_loader"); + loaderDataField = type.getAddressField("_loader_data"); } // Field - private static sun.jvm.hotspot.types.OopField loaderField; + private static AddressField loaderDataField; // Accessor 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) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SharedHeap.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SharedHeap.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ import sun.jvm.hotspot.types.*; public abstract class SharedHeap extends CollectedHeap { - private static AddressField permGenField; private static VirtualConstructor ctor; static { @@ -46,31 +45,14 @@ private static synchronized void initialize(TypeDataBase db) { Type type = db.lookupType("SharedHeap"); - permGenField = type.getAddressField("_perm_gen"); ctor = new VirtualConstructor(db); - ctor.addMapping("CompactingPermGen", CompactingPermGen.class); - ctor.addMapping("CMSPermGen", CMSPermGen.class); - } public SharedHeap(Address 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() { return CollectedHeapName.SHARED_HEAP; } - - public Generation permGen() { - return perm().asGen(); } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java Sat Sep 01 13:25:18 2012 -0400 @@ -37,13 +37,13 @@ private static AddressField loaderConstraintTableField; private static sun.jvm.hotspot.types.OopField javaSystemLoaderField; - private static sun.jvm.hotspot.types.OopField objectKlassField; - private static sun.jvm.hotspot.types.OopField classLoaderKlassField; - private static sun.jvm.hotspot.types.OopField stringKlassField; - private static sun.jvm.hotspot.types.OopField systemKlassField; - private static sun.jvm.hotspot.types.OopField threadKlassField; - private static sun.jvm.hotspot.types.OopField threadGroupKlassField; - private static sun.jvm.hotspot.types.OopField methodHandleKlassField; + private static AddressField objectKlassField; + private static AddressField classLoaderKlassField; + private static AddressField stringKlassField; + private static AddressField systemKlassField; + private static AddressField threadKlassField; + private static AddressField threadGroupKlassField; + private static AddressField methodHandleKlassField; static { VM.registerVMInitializedObserver(new Observer() { @@ -62,13 +62,13 @@ loaderConstraintTableField = type.getAddressField("_loader_constraints"); javaSystemLoaderField = type.getOopField("_java_system_loader"); - objectKlassField = type.getOopField(WK_KLASS("Object_klass")); - classLoaderKlassField = type.getOopField(WK_KLASS("ClassLoader_klass")); - stringKlassField = type.getOopField(WK_KLASS("String_klass")); - systemKlassField = type.getOopField(WK_KLASS("System_klass")); - threadKlassField = type.getOopField(WK_KLASS("Thread_klass")); - threadGroupKlassField = type.getOopField(WK_KLASS("ThreadGroup_klass")); - methodHandleKlassField = type.getOopField(WK_KLASS("MethodHandle_klass")); + objectKlassField = type.getAddressField(WK_KLASS("Object_klass")); + classLoaderKlassField = type.getAddressField(WK_KLASS("ClassLoader_klass")); + stringKlassField = type.getAddressField(WK_KLASS("String_klass")); + systemKlassField = type.getAddressField(WK_KLASS("System_klass")); + threadKlassField = type.getAddressField(WK_KLASS("Thread_klass")); + threadGroupKlassField = type.getAddressField(WK_KLASS("ThreadGroup_klass")); + methodHandleKlassField = type.getAddressField(WK_KLASS("MethodHandle_klass")); } // This WK functions must follow the definitions in systemDictionary.hpp: @@ -104,31 +104,31 @@ // few well known classes -- not all are added here. // add more if needed. public static InstanceKlass getThreadKlass() { - return (InstanceKlass) newOop(threadKlassField.getValue()); + return (InstanceKlass)Metadata.instantiateWrapperFor(threadKlassField.getValue()); } public static InstanceKlass getThreadGroupKlass() { - return (InstanceKlass) newOop(threadGroupKlassField.getValue()); + return (InstanceKlass)Metadata.instantiateWrapperFor(threadGroupKlassField.getValue()); } public static InstanceKlass getObjectKlass() { - return (InstanceKlass) newOop(objectKlassField.getValue()); + return (InstanceKlass)Metadata.instantiateWrapperFor(objectKlassField.getValue()); } public static InstanceKlass getStringKlass() { - return (InstanceKlass) newOop(stringKlassField.getValue()); + return (InstanceKlass)Metadata.instantiateWrapperFor(stringKlassField.getValue()); } public static InstanceKlass getClassLoaderKlass() { - return (InstanceKlass) newOop(classLoaderKlassField.getValue()); + return (InstanceKlass)Metadata.instantiateWrapperFor(classLoaderKlassField.getValue()); } public static InstanceKlass getSystemKlass() { - return (InstanceKlass) newOop(systemKlassField.getValue()); + return (InstanceKlass)Metadata.instantiateWrapperFor(systemKlassField.getValue()); } public static InstanceKlass getMethodHandleKlass() { - return (InstanceKlass) newOop(methodHandleKlassField.getValue()); + return (InstanceKlass)Metadata.instantiateWrapperFor(methodHandleKlassField.getValue()); } public InstanceKlass getAbstractOwnableSynchronizerKlass() {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -42,17 +42,14 @@ private static sun.jvm.hotspot.types.OopField systemThreadGroupField; // single dimensional primitive array klasses - private static sun.jvm.hotspot.types.OopField boolArrayKlassObjField; - private static sun.jvm.hotspot.types.OopField byteArrayKlassObjField; - private static sun.jvm.hotspot.types.OopField charArrayKlassObjField; - private static sun.jvm.hotspot.types.OopField intArrayKlassObjField; - private static sun.jvm.hotspot.types.OopField shortArrayKlassObjField; - private static sun.jvm.hotspot.types.OopField longArrayKlassObjField; - private static sun.jvm.hotspot.types.OopField singleArrayKlassObjField; - private static sun.jvm.hotspot.types.OopField doubleArrayKlassObjField; - - // system obj array klass object - private static sun.jvm.hotspot.types.OopField systemObjArrayKlassObjField; + private static sun.jvm.hotspot.types.AddressField boolArrayKlassField; + private static sun.jvm.hotspot.types.AddressField byteArrayKlassField; + private static sun.jvm.hotspot.types.AddressField charArrayKlassField; + private static sun.jvm.hotspot.types.AddressField intArrayKlassField; + private static sun.jvm.hotspot.types.AddressField shortArrayKlassField; + private static sun.jvm.hotspot.types.AddressField longArrayKlassField; + private static sun.jvm.hotspot.types.AddressField singleArrayKlassField; + private static sun.jvm.hotspot.types.AddressField doubleArrayKlassField; private static AddressField narrowOopBaseField; private static CIntegerField narrowOopShiftField; @@ -78,16 +75,14 @@ mainThreadGroupField = type.getOopField("_main_thread_group"); systemThreadGroupField = type.getOopField("_system_thread_group"); - boolArrayKlassObjField = type.getOopField("_boolArrayKlassObj"); - byteArrayKlassObjField = type.getOopField("_byteArrayKlassObj"); - charArrayKlassObjField = type.getOopField("_charArrayKlassObj"); - intArrayKlassObjField = type.getOopField("_intArrayKlassObj"); - shortArrayKlassObjField = type.getOopField("_shortArrayKlassObj"); - longArrayKlassObjField = type.getOopField("_longArrayKlassObj"); - singleArrayKlassObjField = type.getOopField("_singleArrayKlassObj"); - doubleArrayKlassObjField = type.getOopField("_doubleArrayKlassObj"); - - systemObjArrayKlassObjField = type.getOopField("_systemObjArrayKlassObj"); + boolArrayKlassField = type.getAddressField("_boolArrayKlassObj"); + byteArrayKlassField = type.getAddressField("_byteArrayKlassObj"); + charArrayKlassField = type.getAddressField("_charArrayKlassObj"); + intArrayKlassField = type.getAddressField("_intArrayKlassObj"); + shortArrayKlassField = type.getAddressField("_shortArrayKlassObj"); + longArrayKlassField = type.getAddressField("_longArrayKlassObj"); + singleArrayKlassField = type.getAddressField("_singleArrayKlassObj"); + doubleArrayKlassField = type.getAddressField("_doubleArrayKlassObj"); narrowOopBaseField = type.getAddressField("_narrow_oop._base"); narrowOopShiftField = type.getCIntegerField("_narrow_oop._shift"); @@ -138,21 +133,17 @@ return newOop(systemThreadGroupField.getValue()); } - public Oop systemObjArrayKlassObj() { - return newOop(systemObjArrayKlassObjField.getValue()); - } - // 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) { - visitor.visit((Klass)newOop(boolArrayKlassObjField.getValue())); - visitor.visit((Klass)newOop(byteArrayKlassObjField.getValue())); - visitor.visit((Klass)newOop(charArrayKlassObjField.getValue())); - visitor.visit((Klass)newOop(intArrayKlassObjField.getValue())); - visitor.visit((Klass)newOop(shortArrayKlassObjField.getValue())); - visitor.visit((Klass)newOop(longArrayKlassObjField.getValue())); - visitor.visit((Klass)newOop(singleArrayKlassObjField.getValue())); - visitor.visit((Klass)newOop(doubleArrayKlassObjField.getValue())); + visitor.visit(new TypeArrayKlass(boolArrayKlassField.getValue())); + visitor.visit(new TypeArrayKlass(byteArrayKlassField.getValue())); + visitor.visit(new TypeArrayKlass(charArrayKlassField.getValue())); + visitor.visit(new TypeArrayKlass(intArrayKlassField.getValue())); + visitor.visit(new TypeArrayKlass(shortArrayKlassField.getValue())); + visitor.visit(new TypeArrayKlass(longArrayKlassField.getValue())); + visitor.visit(new TypeArrayKlass(singleArrayKlassField.getValue())); + visitor.visit(new TypeArrayKlass(doubleArrayKlassField.getValue())); } public void print() { printOn(System.out); }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/AccessFlags.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/AccessFlags.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,7 @@ public long getValue () { return flags; } // Hotspot internal flags - // methodOop flags + // Method* flags public boolean isMonitorMatching () { return (flags & JVM_ACC_MONITOR_MATCH ) != 0; } public boolean hasMonitorBytecodes () { return (flags & JVM_ACC_HAS_MONITOR_BYTECODES ) != 0; } public boolean hasLoops () { return (flags & JVM_ACC_HAS_LOOPS ) != 0; } @@ -69,13 +69,13 @@ public boolean hasJsrs () { return (flags & JVM_ACC_HAS_JSRS ) != 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 hasVanillaConstructor() { return (flags & JVM_ACC_HAS_VANILLA_CONSTRUCTOR) != 0; } public boolean hasFinalizer () { return (flags & JVM_ACC_HAS_FINALIZER ) != 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; } // field flags
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Array.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Array.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ if (headerSize != 0) { return headerSize; } - if (VM.getVM().isCompressedOopsEnabled()) { + if (VM.getVM().isCompressedHeadersEnabled()) { headerSize = typeSize; } else { headerSize = VM.getVM().alignUp(typeSize + VM.getVM().getIntSize(), @@ -80,7 +80,7 @@ if (lengthOffsetInBytes != 0) { return lengthOffsetInBytes; } - if (VM.getVM().isCompressedOopsEnabled()) { + if (VM.getVM().isCompressedHeadersEnabled()) { lengthOffsetInBytes = typeSize - VM.getVM().getIntSize(); } else { lengthOffsetInBytes = typeSize;
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayData.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayData.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -49,10 +49,6 @@ int aindex = index + arrayStartOffSet; return intAt(aindex); } - Oop arrayOopAt(int index) { - int aindex = index + arrayStartOffSet; - return oopAt(aindex); - } // Code generation support for subclasses. static int arrayElementOffset(int index) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -45,24 +45,24 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { Type type = db.lookupType("arrayKlass"); - dimension = new CIntField(type.getCIntegerField("_dimension"), Oop.getHeaderSize()); - higherDimension = new OopField(type.getOopField("_higher_dimension"), Oop.getHeaderSize()); - lowerDimension = new OopField(type.getOopField("_lower_dimension"), Oop.getHeaderSize()); - vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize()); - allocSize = new CIntField(type.getCIntegerField("_alloc_size"), Oop.getHeaderSize()); - componentMirror = new OopField(type.getOopField("_component_mirror"), Oop.getHeaderSize()); + dimension = new CIntField(type.getCIntegerField("_dimension"), 0); + higherDimension = new MetadataField(type.getAddressField("_higher_dimension"), 0); + lowerDimension = new MetadataField(type.getAddressField("_lower_dimension"), 0); + vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0); + allocSize = new CIntField(type.getCIntegerField("_alloc_size"), 0); + componentMirror = new OopField(type.getOopField("_component_mirror"), 0); javaLangCloneableName = null; javaLangObjectName = null; javaIoSerializableName = null; } - ArrayKlass(OopHandle handle, ObjectHeap heap) { - super(handle, heap); + public ArrayKlass(Address addr) { + super(addr); } private static CIntField dimension; - private static OopField higherDimension; - private static OopField lowerDimension; + private static MetadataField higherDimension; + private static MetadataField lowerDimension; private static CIntField vtableLen; private static CIntField allocSize; private static OopField componentMirror; @@ -141,19 +141,13 @@ tty.print("ArrayKlass"); } - public long getObjectSize() { - return alignObjectSize(InstanceKlass.getHeaderSize() + getVtableLen() * getHeap().getOopSize()); - } - - public void iterateFields(OopVisitor visitor, boolean doVMFields) { - super.iterateFields(visitor, doVMFields); - if (doVMFields) { + public void iterateFields(MetadataVisitor visitor) { + super.iterateFields(visitor); visitor.doCInt(dimension, true); - visitor.doOop(higherDimension, true); - visitor.doOop(lowerDimension, true); + visitor.doMetadata(higherDimension, true); + visitor.doMetadata(lowerDimension, true); visitor.doCInt(vtableLen, true); visitor.doCInt(allocSize, true); visitor.doOop(componentMirror, true); } } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayKlassKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +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.*; - -public class ArrayKlassKlass extends KlassKlass { - 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("arrayKlassKlass"); - headerSize = type.getSize() + Oop.getHeaderSize(); - } - - ArrayKlassKlass(OopHandle handle, ObjectHeap heap) { - super(handle, heap); - } - - private static long headerSize; - - public long getObjectSize() { return alignObjectSize(headerSize); } - - public void printValueOn(PrintStream tty) { - tty.print("ArrayKlassKlass"); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/BooleanField.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/BooleanField.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.jvm.hotspot.oops; import sun.jvm.hotspot.debugger.*; +import sun.jvm.hotspot.runtime.VMObject; // The class for a boolean field simply provides access to the value. public class BooleanField extends Field { @@ -41,6 +42,7 @@ } 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 { // Fix this: setJBooleanAt is missing in Address }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ByteField.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ByteField.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.jvm.hotspot.oops; import sun.jvm.hotspot.debugger.*; +import sun.jvm.hotspot.runtime.VMObject; // The class for a byte field simply provides access to the value. public class ByteField extends Field { @@ -41,6 +42,7 @@ } 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 { // Fix this: setJCharAt is missing in Address }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CIntField.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CIntField.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ package sun.jvm.hotspot.oops; +import sun.jvm.hotspot.runtime.VMObject; import sun.jvm.hotspot.debugger.*; // The class for an C int field simply provides access to the value. @@ -39,7 +40,10 @@ private boolean isUnsigned; 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) { return addr.getCIntegerAt(getOffset(), size, isUnsigned);
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CharField.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CharField.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.jvm.hotspot.oops; import sun.jvm.hotspot.debugger.*; +import sun.jvm.hotspot.runtime.VMObject; // The class for a char field simply provides access to the value. public class CharField extends Field { @@ -41,6 +42,7 @@ } 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 { // Fix this: setJCharAt is missing in Address }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CheckedExceptionElement.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CheckedExceptionElement.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -48,10 +48,10 @@ private static long offsetOfClassCPIndex; - private OopHandle handle; + private Address handle; private long offset; - public CheckedExceptionElement(OopHandle handle, long offset) { + public CheckedExceptionElement(Address handle, long offset) { this.handle = handle; this.offset = offset; }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CompiledICHolder.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CompiledICHolder.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * 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.types.*; -public class CompiledICHolder extends Oop { +public class CompiledICHolder extends VMObject { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -40,14 +40,14 @@ } private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { - Type type = db.lookupType("compiledICHolderOopDesc"); - holderMethod = new OopField(type.getOopField("_holder_method"), 0); - holderKlass = new OopField(type.getOopField("_holder_klass"), 0); + Type type = db.lookupType("CompiledICHolder"); + holderMethod = new MetadataField(type.getAddressField("_holder_method"), 0); + holderKlass = new MetadataField(type.getAddressField("_holder_klass"), 0); headerSize = type.getSize(); } - CompiledICHolder(OopHandle handle, ObjectHeap heap) { - super(handle, heap); + public CompiledICHolder(Address addr) { + super(addr); } public boolean isCompiledICHolder() { return true; } @@ -55,8 +55,8 @@ private static long headerSize; // Fields - private static OopField holderMethod; - private static OopField holderKlass; + private static MetadataField holderMethod; + private static MetadataField holderKlass; // Accessors for declared fields public Method getHolderMethod() { return (Method) holderMethod.getValue(this); } @@ -65,16 +65,4 @@ public void printValueOn(PrintStream tty) { 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); - } - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CompiledICHolderKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +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.*; - -public class CompiledICHolderKlass 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("compiledICHolderKlass"); - headerSize = type.getSize() + Oop.getHeaderSize(); - } - - CompiledICHolderKlass(OopHandle handle, ObjectHeap heap) { - super(handle, heap); - } - - private static long headerSize; - - public long getObjectSize() { return alignObjectSize(headerSize); } - - public void printValueOn(PrintStream tty) { - tty.print("CompilerICHolderKlass"); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java Sat Sep 01 13:25:18 2012 -0400 @@ -34,7 +34,7 @@ import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.utilities.*; -public class ConstMethod extends Oop { +public class ConstMethod extends VMObject { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -50,18 +50,18 @@ private static int HAS_EXCEPTION_TABLE; private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { - Type type = db.lookupType("constMethodOopDesc"); - constants = new OopField(type.getOopField("_constants"), 0); + Type type = db.lookupType("ConstMethod"); + constants = new MetadataField(type.getAddressField("_constants"), 0); constMethodSize = new CIntField(type.getCIntegerField("_constMethod_size"), 0); flags = new ByteField(type.getJByteField("_flags"), 0); // enum constants for flags - HAS_LINENUMBER_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_linenumber_table").intValue(); - HAS_CHECKED_EXCEPTIONS = db.lookupIntConstant("constMethodOopDesc::_has_checked_exceptions").intValue(); - HAS_LOCALVARIABLE_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_localvariable_table").intValue(); - HAS_EXCEPTION_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_exception_table").intValue(); + HAS_LINENUMBER_TABLE = db.lookupIntConstant("ConstMethod::_has_linenumber_table").intValue(); + HAS_CHECKED_EXCEPTIONS = db.lookupIntConstant("ConstMethod::_has_checked_exceptions").intValue(); + HAS_LOCALVARIABLE_TABLE = db.lookupIntConstant("ConstMethod::_has_localvariable_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); nameIndex = new CIntField(type.getCIntegerField("_name_index"), 0); signatureIndex = new CIntField(type.getCIntegerField("_signature_index"), 0); @@ -81,12 +81,12 @@ exceptionTableElementSize = type.getSize(); } - ConstMethod(OopHandle handle, ObjectHeap heap) { - super(handle, heap); + public ConstMethod(Address addr) { + super(addr); } // Fields - private static OopField constants; + private static MetadataField constants; private static CIntField constMethodSize; private static ByteField flags; private static CIntField codeSize; @@ -104,8 +104,8 @@ public Method getMethod() { InstanceKlass ik = (InstanceKlass)getConstants().getPoolHolder(); - ObjArray methods = ik.getMethods(); - return (Method)methods.getObjAt(getIdNum()); + MethodArray methods = ik.getMethods(); + return methods.at((int)getIdNum()); } // Accessors for declared fields @@ -157,7 +157,7 @@ /** Get a bytecode or breakpoint at the given bci */ public int getBytecodeOrBPAt(int bci) { - return getHandle().getJByteAt(bytecodeOffset + bci) & 0xFF; + return getAddress().getJByteAt(bytecodeOffset + bci) & 0xFF; } public byte getBytecodeByteArg(int bci) { @@ -215,23 +215,21 @@ for( int i=0; i < bc.length; i++ ) { long offs = bytecodeOffset + i; - bc[i] = getHandle().getJByteAt( offs ); + bc[i] = getAddress().getJByteAt( offs ); } return bc; } - public long getObjectSize() { - return getConstMethodSize() * getHeap().getOopSize(); + public long getSize() { + return getConstMethodSize(); } 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) { - super.iterateFields(visitor, doVMFields); - if (doVMFields) { - visitor.doOop(constants, true); + public void iterateFields(MetadataVisitor visitor) { + visitor.doMetadata(constants, true); visitor.doCInt(constMethodSize, true); visitor.doByte(flags, true); visitor.doCInt(codeSize, true); @@ -240,7 +238,6 @@ visitor.doCInt(genericSignatureIndex, true); visitor.doCInt(codeSize, true); } - } // Accessors @@ -266,7 +263,7 @@ // The line numbers are a short array of 2-tuples [start_pc, line_number]. // Not necessarily sorted and not necessarily one-to-one. CompressedLineNumberReadStream stream = - new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); + new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable()); while (stream.readPair()) { if (stream.bci() == bci) { // perfect match @@ -290,7 +287,7 @@ } int len = getLineNumberTableLength(); CompressedLineNumberReadStream stream = - new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); + new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable()); LineNumberTableElement[] ret = new LineNumberTableElement[len]; for (int idx = 0; idx < len; idx++) { @@ -316,7 +313,7 @@ LocalVariableTableElement[] ret = new LocalVariableTableElement[getLocalVariableTableLength()]; long offset = offsetOfLocalVariableTable(); for (int i = 0; i < ret.length; i++) { - ret[i] = new LocalVariableTableElement(getHandle(), offset); + ret[i] = new LocalVariableTableElement(getAddress(), offset); offset += localVariableTableElementSize; } return ret; @@ -333,7 +330,7 @@ ExceptionTableElement[] ret = new ExceptionTableElement[getExceptionTableLength()]; long offset = offsetOfExceptionTable(); for (int i = 0; i < ret.length; i++) { - ret[i] = new ExceptionTableElement(getHandle(), offset); + ret[i] = new ExceptionTableElement(getAddress(), offset); offset += exceptionTableElementSize; } return ret; @@ -350,7 +347,7 @@ CheckedExceptionElement[] ret = new CheckedExceptionElement[getCheckedExceptionsLength()]; long offset = offsetOfCheckedExceptions(); for (int i = 0; i < ret.length; i++) { - ret[i] = new CheckedExceptionElement(getHandle(), offset); + ret[i] = new CheckedExceptionElement(getAddress(), offset); offset += checkedExceptionElementSize; } return ret; @@ -370,14 +367,14 @@ 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() { return offsetOfCodeEnd() + (isNative() ? 2 * VM.getVM().getAddressSize() : 0); } - // Offset of last short in methodOop + // Offset of last short in Method* private long offsetOfLastU2Element() { - return getObjectSize() - 2; + return getSize() * VM.getVM().getObjectHeap().getOopSize() - 2; } private long offsetOfCheckedExceptionsLength() { @@ -386,7 +383,7 @@ private int getCheckedExceptionsLength() { if (hasCheckedExceptions()) { - return (int) getHandle().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true); + return (int) getAddress().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true); } else { return 0; } @@ -407,7 +404,7 @@ int len = 0; if (hasLineNumberTable()) { CompressedLineNumberReadStream stream = - new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); + new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable()); while (stream.readPair()) { len += 1; } @@ -417,7 +414,7 @@ private int getLocalVariableTableLength() { if (hasLocalVariableTable()) { - return (int) getHandle().getCIntegerAt(offsetOfLocalVariableTableLength(), 2, true); + return (int) getAddress().getCIntegerAt(offsetOfLocalVariableTableLength(), 2, true); } else { return 0; } @@ -450,7 +447,7 @@ private int getExceptionTableLength() { if (hasExceptionTable()) { - return (int) getHandle().getCIntegerAt(offsetOfExceptionTableLength(), 2, true); + return (int) getAddress().getCIntegerAt(offsetOfExceptionTableLength(), 2, true); } else { return 0; }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethodKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +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.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; - -// The ConstMethodKlass is the klass of a ConstMethod - -public class ConstMethodKlass 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("constMethodKlass"); - headerSize = type.getSize() + Oop.getHeaderSize(); - } - - ConstMethodKlass(OopHandle handle, ObjectHeap heap) { - super(handle, heap); - } - - private static long headerSize; - - public long getObjectSize() { return alignObjectSize(headerSize); } - - public void printValueOn(PrintStream tty) { - tty.print("ConstMethodKlass"); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -34,8 +34,7 @@ // A ConstantPool is an oop containing class constants // as described in the class file -public class ConstantPool extends Oop implements ClassConstants { - +public class ConstantPool extends Metadata implements ClassConstants { public class CPSlot { private Address ptr; @@ -46,24 +45,20 @@ this.ptr = sym.getAddress().orWithMask(1); } - public boolean isOop() { + public boolean isResolved() { return (ptr.minus(null) & 1) == 0; } - public boolean isMetaData() { + public boolean isUnresolved() { return (ptr.minus(null) & 1) == 1; } public Symbol getSymbol() { - if (isMetaData()) { + if (!isUnresolved()) throw new InternalError("not a symbol"); return Symbol.create(ptr.xorWithMask(1)); } - throw new InternalError("not a symbol"); - } - public Oop getOop() { - if (isOop()) { - return VM.getVM().getObjectHeap().newOop(ptr.addOffsetToAsOopHandle(0)); - } - throw new InternalError("not an oop"); + public Klass getKlass() { + if (!isResolved()) throw new InternalError("not klass"); + return (Klass)Metadata.instantiateWrapperFor(ptr); } } @@ -83,31 +78,35 @@ } private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { - Type type = db.lookupType("constantPoolOopDesc"); - tags = new OopField(type.getOopField("_tags"), 0); - operands = new OopField(type.getOopField("_operands"), 0); - cache = new OopField(type.getOopField("_cache"), 0); - poolHolder = new OopField(type.getOopField("_pool_holder"), 0); + Type type = db.lookupType("ConstantPool"); + tags = type.getAddressField("_tags"); + operands = type.getAddressField("_operands"); + cache = type.getAddressField("_cache"); + poolHolder = new MetadataField(type.getAddressField("_pool_holder"), 0); length = new CIntField(type.getCIntegerField("_length"), 0); + resolvedReferences = type.getAddressField("_resolved_references"); + referenceMap = type.getAddressField("_reference_map"); headerSize = type.getSize(); elementSize = 0; // fetch constants: - INDY_BSM_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_bsm_offset").intValue(); - INDY_ARGC_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_argc_offset").intValue(); - INDY_ARGV_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_argv_offset").intValue(); + INDY_BSM_OFFSET = db.lookupIntConstant("ConstantPool::_indy_bsm_offset").intValue(); + INDY_ARGC_OFFSET = db.lookupIntConstant("ConstantPool::_indy_argc_offset").intValue(); + INDY_ARGV_OFFSET = db.lookupIntConstant("ConstantPool::_indy_argv_offset").intValue(); } - ConstantPool(OopHandle handle, ObjectHeap heap) { - super(handle, heap); + public ConstantPool(Address addr) { + super(addr); } public boolean isConstantPool() { return true; } - private static OopField tags; - private static OopField operands; - private static OopField cache; - private static OopField poolHolder; + private static AddressField tags; + private static AddressField operands; + private static AddressField cache; + private static MetadataField poolHolder; private static CIntField length; // number of elements in oop + private static AddressField resolvedReferences; + private static AddressField referenceMap; private static long headerSize; private static long elementSize; @@ -116,11 +115,31 @@ private static int INDY_ARGC_OFFSET; private static int INDY_ARGV_OFFSET; - public TypeArray getTags() { return (TypeArray) tags.getValue(this); } - public TypeArray getOperands() { return (TypeArray) operands.getValue(this); } - public ConstantPoolCache getCache() { return (ConstantPoolCache) cache.getValue(this); } + public U1Array getTags() { return new U1Array(tags.getValue(getAddress())); } + public U2Array getOperands() { return new U2Array(operands.getValue(getAddress())); } + public ConstantPoolCache getCache() { + Address addr = cache.getValue(getAddress()); + return (ConstantPoolCache) VMObjectFactory.newObject(ConstantPoolCache.class, addr); + } 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() { if (elementSize !=0 ) { @@ -139,33 +158,32 @@ } 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) { - return new CPSlot(getHandle().getAddressAt(indexOffset(index))); + return new CPSlot(getAddressAtRaw(index)); } - public Oop getObjAtRaw(long index){ - return getHeap().newOop(getHandle().getOopHandleAt(indexOffset(index))); + public Address getAddressAtRaw(long index) { + return getAddress().getAddressAt(indexOffset(index)); } public Symbol getSymbolAt(long index) { - CPSlot slot = getSlotAt(index); - return slot.getSymbol(); + return Symbol.create(getAddressAtRaw(index)); } public int getIntAt(long index){ - return getHandle().getJIntAt(indexOffset(index)); + return getAddress().getJIntAt(indexOffset(index)); } public float getFloatAt(long index){ - return getHandle().getJFloatAt(indexOffset(index)); + return getAddress().getJFloatAt(indexOffset(index)); } public long getLongAt(long index) { - int oneHalf = getHandle().getJIntAt(indexOffset(index + 1)); - int otherHalf = getHandle().getJIntAt(indexOffset(index)); + int oneHalf = getAddress().getJIntAt(indexOffset(index + 1)); + int otherHalf = getAddress().getJIntAt(indexOffset(index)); // buildLongFromIntsPD accepts higher address value, lower address value // in that order. return VM.getVM().buildLongFromIntsPD(oneHalf, otherHalf); @@ -185,7 +203,7 @@ i = which; } else { // 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) { Assert.that(getTagAt(i).isFieldOrMethod(), "Corrupted constant pool"); @@ -202,7 +220,7 @@ public int[] getNameAndTypeAt(int which) { 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); if (DEBUG) { @@ -215,6 +233,10 @@ return implGetNameRefAt(which, false); } + public Symbol uncachedGetNameRefAt(int which) { + return implGetNameRefAt(which, true); + } + private Symbol implGetNameRefAt(int which, boolean uncached) { int signatureIndex = getNameRefIndexAt(implNameAndTypeRefIndexAt(which, uncached)); return getSymbolAt(signatureIndex); @@ -224,35 +246,57 @@ return implGetSignatureRefAt(which, false); } + public Symbol uncachedGetSignatureRefAt(int which) { + return implGetSignatureRefAt(which, true); + } + private Symbol implGetSignatureRefAt(int which, boolean uncached) { int signatureIndex = getSignatureRefIndexAt(implNameAndTypeRefIndexAt(which, uncached)); 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) { int i = which; if (!uncached && getCache() != null) { - if (ConstantPoolCache.isSecondaryIndex(which)) { - // Invokedynamic index. - int pool_index = getCache().getMainEntryAt(which).getConstantPoolIndex(); - pool_index = invokeDynamicNameAndTypeRefIndexAt(pool_index); - // assert(tagAt(pool_index).isNameAndType(), ""); - return pool_index; + if (isInvokedynamicIndex(which)) { + // Invokedynamic index is index into resolved_references + int poolIndex = invokedynamicCPCacheEntryAt(which).getConstantPoolIndex(); + poolIndex = invokeDynamicNameAndTypeRefIndexAt(poolIndex); + Assert.that(getTagAt(poolIndex).isNameAndType(), ""); + return poolIndex; } // change byte-ordering and go via cache i = remapInstructionOperandFromCache(which); } else { if (getTagAt(which).isInvokeDynamic()) { - int pool_index = invokeDynamicNameAndTypeRefIndexAt(which); - // assert(tag_at(pool_index).is_name_and_type(), ""); - return pool_index; + int poolIndex = invokeDynamicNameAndTypeRefIndexAt(which); + Assert.that(getTagAt(poolIndex).isNameAndType(), ""); + return poolIndex; } } // assert(tag_at(i).is_field_or_method(), "Corrupted constant pool"); // assert(!tag_at(i).is_invoke_dynamic(), "Must be handled above"); - int ref_index = getIntAt(i); - return extractHighShortFromInt(ref_index); + int refIndex = getIntAt(i); + return extractHighShortFromInt(refIndex); } private int remapInstructionOperandFromCache(int operand) { @@ -269,16 +313,29 @@ } // returns null, if not resolved. - public Klass getKlassRefAt(int which) { + public Klass getKlassAt(int which) { 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. public InstanceKlass getFieldOrMethodKlassRefAt(int which) { int refIndex = getFieldOrMethodAt(which); int klassIndex = extractLowShortFromInt(refIndex); - return (InstanceKlass) getKlassRefAt(klassIndex); + return (InstanceKlass) getKlassAt(klassIndex); } // returns null, if not resolved. @@ -371,16 +428,16 @@ Assert.that(getTagAt(i).isInvokeDynamic(), "Corrupted constant pool"); } int bsmSpec = extractLowShortFromInt(this.getIntAt(i)); - TypeArray operands = getOperands(); + U2Array operands = getOperands(); if (operands == null) return null; // safety first - int basePos = VM.getVM().buildIntFromShorts(operands.getShortAt(bsmSpec * 2 + 0), - operands.getShortAt(bsmSpec * 2 + 1)); + int basePos = VM.getVM().buildIntFromShorts(operands.at(bsmSpec * 2 + 0), + operands.at(bsmSpec * 2 + 1)); 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; short[] values = new short[endPos - basePos]; for (int j = 0; j < values.length; j++) { - values[j] = operands.getShortAt(basePos+j); + values[j] = operands.at(basePos+j); } return values; } @@ -407,25 +464,24 @@ case JVM_CONSTANT_InvokeDynamic: return "JVM_CONSTANT_InvokeDynamic"; case JVM_CONSTANT_Invalid: return "JVM_CONSTANT_Invalid"; case JVM_CONSTANT_UnresolvedClass: return "JVM_CONSTANT_UnresolvedClass"; + case JVM_CONSTANT_ClassIndex: return "JVM_CONSTANT_ClassIndex"; + case JVM_CONSTANT_StringIndex: return "JVM_CONSTANT_StringIndex"; case JVM_CONSTANT_UnresolvedClassInError: return "JVM_CONSTANT_UnresolvedClassInError"; - 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_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); } - public void iterateFields(OopVisitor visitor, boolean doVMFields) { - super.iterateFields(visitor, doVMFields); - if (doVMFields) { - visitor.doOop(tags, true); - visitor.doOop(cache, true); - visitor.doOop(poolHolder, true); + public void iterateFields(MetadataVisitor visitor) { + super.iterateFields(visitor); + visitor.doMetadata(poolHolder, true); final int length = (int) getLength(); // zero'th pool entry is always invalid. ignore it. for (int index = 1; index < length; index++) { - int ctag = (int) getTags().getByteAt((int) index); + int ctag = (int) getTags().at((int) index); switch (ctag) { case JVM_CONSTANT_ClassIndex: case JVM_CONSTANT_StringIndex: @@ -452,7 +508,6 @@ case JVM_CONSTANT_UnresolvedClassInError: case JVM_CONSTANT_UnresolvedClass: case JVM_CONSTANT_Class: - case JVM_CONSTANT_UnresolvedString: case JVM_CONSTANT_Utf8: visitor.doOop(new OopField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true); break; @@ -469,27 +524,19 @@ } } } - /* - 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 { // Map between any modified UTF-8 and it's constant pool index. Map utf8ToIndex = new HashMap(); DataOutputStream dos = new DataOutputStream(os); - TypeArray tags = getTags(); + U1Array tags = getTags(); int len = (int)getLength(); int ci = 0; // constant pool index // collect all modified UTF-8 Strings from Constant Pool for (ci = 1; ci < len; ci++) { - byte cpConstType = tags.getByteAt(ci); + int cpConstType = tags.at(ci); if(cpConstType == JVM_CONSTANT_Utf8) { Symbol sym = getSymbolAt(ci); utf8ToIndex.put(sym.asString(), new Short((short) ci)); @@ -502,7 +549,7 @@ for(ci = 1; ci < len; ci++) { - int cpConstType = (int)tags.getByteAt(ci); + int cpConstType = tags.at(ci); // write cp_info // write constant type switch(cpConstType) { @@ -548,8 +595,8 @@ case JVM_CONSTANT_Class: { dos.writeByte(cpConstType); - // Klass already resolved. ConstantPool constains klassOop. - Klass refKls = (Klass) getObjAtRaw(ci); + // Klass already resolved. ConstantPool constains Klass*. + Klass refKls = (Klass)Metadata.instantiateWrapperFor(getAddressAtRaw(ci)); String klassName = refKls.getName().asString(); Short s = (Short) utf8ToIndex.get(klassName); dos.writeShort(s.shortValue()); @@ -570,24 +617,13 @@ case JVM_CONSTANT_String: { dos.writeByte(cpConstType); - String str = OopUtilities.stringOopToString(getObjAtRaw(ci)); + String str = getUnresolvedStringAt(ci).asString(); Short s = (Short) utf8ToIndex.get(str); dos.writeShort(s.shortValue()); if (DEBUG) debugMessage("CP[" + ci + "] = string " + s); 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 case JVM_CONSTANT_Fieldref: case JVM_CONSTANT_Methodref: @@ -618,12 +654,21 @@ case JVM_CONSTANT_MethodHandle: { dos.writeByte(cpConstType); int value = getIntAt(ci); - short nameIndex = (short) extractLowShortFromInt(value); - short signatureIndex = (short) extractHighShortFromInt(value); - dos.writeShort(nameIndex); - dos.writeShort(signatureIndex); - if (DEBUG) debugMessage("CP[" + ci + "] = N&T name = " + nameIndex - + ", type = " + signatureIndex); + byte refKind = (byte) extractLowShortFromInt(value); + short memberIndex = (short) extractHighShortFromInt(value); + dos.writeByte(refKind); + dos.writeShort(memberIndex); + if (DEBUG) debugMessage("CP[" + ci + "] = MH kind = " + + 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; } @@ -634,13 +679,13 @@ short nameAndTypeIndex = (short) extractHighShortFromInt(value); dos.writeShort(bsmIndex); dos.writeShort(nameAndTypeIndex); - if (DEBUG) debugMessage("CP[" + ci + "] = indy BSM = " + bsmIndex - + ", N&T = " + nameAndTypeIndex); + if (DEBUG) debugMessage("CP[" + ci + "] = INDY bsm = " + + bsmIndex + ", N&T = " + nameAndTypeIndex); break; } default: - throw new InternalError("unknown tag: " + cpConstType); + throw new InternalError("Unknown tag: " + cpConstType); } // switch } dos.flush(); @@ -648,16 +693,11 @@ } public void printValueOn(PrintStream tty) { - Oop holder = poolHolder.getValue(this); - if (holder instanceof Klass) { - tty.print("ConstantPool for " + ((Klass)holder).getName().asString()); - } else { - tty.print("ConstantPool for partially loaded class"); - } + tty.print("ConstantPool for " + getPoolHolder().getName().asString()); } - public long getObjectSize() { - return alignObjectSize(headerSize + (getLength() * getElementSize())); + public long getSize() { + return Oop.alignObjectSize(headerSize + getLength()); } //---------------------------------------------------------------------- @@ -665,12 +705,12 @@ // 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; } 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; } }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -31,10 +31,10 @@ import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.utilities.*; -// ConstantPoolCache : A constant pool cache (constantPoolCacheOopDesc). -// See cpCacheOop.hpp for details about this class. +// ConstantPoolCache : A constant pool cache (ConstantPoolCache). +// See cpCache.hpp for details about this class. // -public class ConstantPoolCache extends Oop { +public class ConstantPoolCache extends Metadata { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -44,31 +44,33 @@ } private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { - Type type = db.lookupType("constantPoolCacheOopDesc"); - constants = new OopField(type.getOopField("_constant_pool"), 0); + Type type = db.lookupType("ConstantPoolCache"); + constants = new MetadataField(type.getAddressField("_constant_pool"), 0); baseOffset = type.getSize(); Type elType = db.lookupType("ConstantPoolCacheEntry"); elementSize = elType.getSize(); length = new CIntField(type.getCIntegerField("_length"), 0); + intSize = VM.getVM().getObjectHeap().getIntSize(); } - ConstantPoolCache(OopHandle handle, ObjectHeap heap) { - super(handle, heap); + public ConstantPoolCache(Address addr) { + super(addr); } public boolean isConstantPoolCache() { return true; } - private static OopField constants; + private static MetadataField constants; private static long baseOffset; private static long elementSize; private static CIntField length; + private static long intSize; public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } - public long getObjectSize() { - return alignObjectSize(baseOffset + getLength() * elementSize); + public long getSize() { + return Oop.alignObjectSize(baseOffset + getLength() * elementSize); } public ConstantPoolCacheEntry getEntryAt(int i) { @@ -76,41 +78,10 @@ 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) { //alignObjectSize ? - long offset = baseOffset + /*alignObjectSize*/entry * elementSize + fld* getHeap().getIntSize(); - return (int) getHandle().getCIntegerAt(offset, getHeap().getIntSize(), true ); + long offset = baseOffset + /*alignObjectSize*/entry * elementSize + fld * intSize; + return (int) getAddress().getCIntegerAt(offset, intSize, true ); } @@ -119,17 +90,15 @@ } public int getLength() { - return (int) length.getValue(this); + return (int) length.getValue(getAddress()); } - public void iterateFields(OopVisitor visitor, boolean doVMFields) { - super.iterateFields(visitor, doVMFields); - if (doVMFields) { - visitor.doOop(constants, true); + public void iterateFields(MetadataVisitor visitor) { + super.iterateFields(visitor); + visitor.doMetadata(constants, true); for (int i = 0; i < getLength(); i++) { ConstantPoolCacheEntry entry = getEntryAt(i); entry.iterateFields(visitor); } } - } };
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCacheEntry.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCacheEntry.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ private static long size; private static long baseOffset; private static CIntegerField indices; - private static sun.jvm.hotspot.types.OopField f1; + private static AddressField f1; private static CIntegerField f2; private static CIntegerField flags; @@ -54,11 +54,11 @@ size = type.getSize(); indices = type.getCIntegerField("_indices"); - f1 = type.getOopField ("_f1"); + f1 = type.getAddressField ("_f1"); f2 = type.getCIntegerField("_f2"); flags = type.getCIntegerField("_flags"); - type = db.lookupType("constantPoolCacheOopDesc"); + type = db.lookupType("ConstantPoolCache"); baseOffset = type.getSize(); } @@ -69,43 +69,32 @@ public int getConstantPoolIndex() { 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); } - public boolean isSecondaryEntry() { - return (getIndices() & 0xFFFF) == 0; + private long getIndices() { + return cp.getAddress().getCIntegerAt(indices.getOffset() + offset, indices.getSize(), indices.isUnsigned()); } - public int getMainEntryIndex() { - if (Assert.ASSERTS_ENABLED) { - Assert.that(isSecondaryEntry(), "must be a secondary CP entry"); - } - return (int) (getIndices() >>> 16); - } - - private long getIndices() { - return cp.getHandle().getCIntegerAt(indices.getOffset() + offset, indices.getSize(), indices.isUnsigned()); - } - - public Oop getF1() { - return cp.getHeap().newOop(cp.getHandle().getOopHandleAt(f1.getOffset() + offset)); + public Metadata getF1() { + return Metadata.instantiateWrapperFor(cp.getAddress().getAddressAt(f1.getOffset() + offset)); } public int getF2() { - return cp.getHandle().getJIntAt(f1.getOffset() + offset); + return cp.getAddress().getJIntAt(f1.getOffset() + offset); } 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 f2FieldName = new NamedFieldIdentifier("_f2"); 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.doInt(new IntField(f2FieldName, f2.getOffset() + offset, true), true); visitor.doInt(new IntField(flagsFieldName, flags.getOffset() + offset, true), true);
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCacheKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2000, 2008, 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 ConstantPoolCacheKlass is the klass of a ConstantPoolCache - -public class ConstantPoolCacheKlass 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("constantPoolCacheKlass"); - headerSize = type.getSize() + Oop.getHeaderSize(); - } - - ConstantPoolCacheKlass(OopHandle handle, ObjectHeap heap) { - super(handle, heap); - } - - public long getObjectSize() { return alignObjectSize(headerSize); } - - public void printValueOn(PrintStream tty) { - tty.print("ConstantPoolCacheKlass"); - } - - private static long headerSize; -} - -
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2000, 2008, 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 ConstantPoolKlass is the klass of a ConstantPool - -public class ConstantPoolKlass 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("constantPoolKlass"); - headerSize = type.getSize() + Oop.getHeaderSize(); - } - - ConstantPoolKlass(OopHandle handle, ObjectHeap heap) { - super(handle, heap); - } - - public long getObjectSize() { return alignObjectSize(headerSize); } - - public void printValueOn(PrintStream tty) { - tty.print("ConstantPoolKlass"); - } - - private static long headerSize; -} -
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/DataLayout.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/DataLayout.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -64,7 +64,7 @@ private boolean handlized; public DataLayout(MethodData d, int o) { - data = d.getHandle(); + data = d.getAddress(); offset = o; } @@ -89,15 +89,6 @@ 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) { OopHandle handle; if (handlized) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/DefaultMetadataVisitor.java Sat Sep 01 13:25:18 2012 -0400 @@ -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) {} +}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/DefaultOopVisitor.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/DefaultOopVisitor.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,7 @@ } // 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(NarrowOopField field, boolean isVMField) {} public void doByte(ByteField field, boolean isVMField) {}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/DoubleField.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/DoubleField.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.jvm.hotspot.oops; import sun.jvm.hotspot.debugger.*; +import sun.jvm.hotspot.runtime.VMObject; // The class for a double field simply provides access to the value. public class DoubleField extends Field { @@ -41,6 +42,7 @@ } 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 { // Fix this: setJDoubleAt is missing in Address }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ExceptionTableElement.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ExceptionTableElement.java Sat Sep 01 13:25:18 2012 -0400 @@ -54,10 +54,10 @@ private static long offsetOfHandlerPC; private static long offsetOfCatchTypeIndex; - private OopHandle handle; + private Address handle; private long offset; - public ExceptionTableElement(OopHandle handle, long offset) { + public ExceptionTableElement(Address handle, long offset) { this.handle = handle; this.offset = offset; } @@ -78,4 +78,3 @@ return (int) handle.getCIntegerAt(offset + offsetOfCatchTypeIndex, 2, true); } } -
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ import java.io.*; import sun.jvm.hotspot.runtime.*; +import sun.jvm.hotspot.utilities.*; // Super class for all fields in an object public class Field {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/FieldVisitor.java Sat Sep 01 13:25:18 2012 -0400 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2000, 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; + +// An OopVisitor can be used to inspect all fields within an object. +// Fields include vm fields, java fields, indexable fields. + +public interface FieldVisitor { + // 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(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); +};
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/FloatField.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/FloatField.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.jvm.hotspot.oops; import sun.jvm.hotspot.debugger.*; +import sun.jvm.hotspot.runtime.VMObject; // The class for a float field simply provides access to the value. public class FloatField extends Field { @@ -41,6 +42,7 @@ } 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 { // Fix this: setJFloatAt is missing in Address }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/GenerateOopMap.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/GenerateOopMap.java Sat Sep 01 13:25:18 2012 -0400 @@ -613,7 +613,7 @@ tty.print(" idx " + idx); /* int idx = currentBC.getIndexU2(); - constantPoolOop cp = method().constants(); + ConstantPool* cp = method().constants(); int nameAndTypeIdx = cp.name_and_type_ref_index_at(idx); int signatureIdx = cp.signature_ref_index_at(nameAndTypeIdx); Symbol* signature = cp.symbol_at(signatureIdx);
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Instance.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Instance.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ // Returns header size in bytes. public static long getHeaderSize() { - if (VM.getVM().isCompressedOopsEnabled()) { + if (VM.getVM().isCompressedHeadersEnabled()) { return typeSize - VM.getVM().getIntSize(); } else { return typeSize;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceClassLoaderKlass.java Sat Sep 01 13:25:18 2012 -0400 @@ -0,0 +1,54 @@ +/* + * 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.debugger.*; +import sun.jvm.hotspot.memory.*; +import sun.jvm.hotspot.runtime.*; +import sun.jvm.hotspot.types.*; +import sun.jvm.hotspot.utilities.*; + +// An InstanceKlass is the VM level representation of a Java class. + +public class InstanceClassLoaderKlass extends InstanceKlass { + 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 { + // Just make sure it's there for now + Type type = db.lookupType("instanceClassLoaderKlass"); + } + + public InstanceClassLoaderKlass(Address addr) { + super(addr); + } +}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Sat Sep 01 13:25:18 2012 -0400 @@ -26,6 +26,7 @@ import java.io.*; import java.util.*; +import sun.jvm.hotspot.classfile.ClassLoaderData; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.memory.*; import sun.jvm.hotspot.runtime.*; @@ -53,7 +54,6 @@ private static int FIELD_SLOTS; // ClassState constants - private static int CLASS_STATE_UNPARSABLE_BY_GC; private static int CLASS_STATE_ALLOCATED; private static int CLASS_STATE_LOADED; private static int CLASS_STATE_LINKED; @@ -62,34 +62,34 @@ private static int CLASS_STATE_INITIALIZATION_ERROR; private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { - Type type = db.lookupType("instanceKlass"); - arrayKlasses = new OopField(type.getOopField("_array_klasses"), Oop.getHeaderSize()); - methods = new OopField(type.getOopField("_methods"), Oop.getHeaderSize()); - methodOrdering = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize()); - localInterfaces = new OopField(type.getOopField("_local_interfaces"), Oop.getHeaderSize()); - transitiveInterfaces = new OopField(type.getOopField("_transitive_interfaces"), Oop.getHeaderSize()); - fields = new OopField(type.getOopField("_fields"), Oop.getHeaderSize()); - javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), Oop.getHeaderSize()); - constants = new OopField(type.getOopField("_constants"), Oop.getHeaderSize()); - classLoader = new OopField(type.getOopField("_class_loader"), Oop.getHeaderSize()); - protectionDomain = new OopField(type.getOopField("_protection_domain"), Oop.getHeaderSize()); - signers = new OopField(type.getOopField("_signers"), Oop.getHeaderSize()); + Type type = db.lookupType("InstanceKlass"); + arrayKlasses = new MetadataField(type.getAddressField("_array_klasses"), 0); + methods = type.getAddressField("_methods"); + methodOrdering = type.getAddressField("_method_ordering"); + localInterfaces = type.getAddressField("_local_interfaces"); + transitiveInterfaces = type.getAddressField("_transitive_interfaces"); + fields = type.getAddressField("_fields"); + javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), 0); + constants = new MetadataField(type.getAddressField("_constants"), 0); + classLoaderData = type.getAddressField("_class_loader_data"); + protectionDomain = new OopField(type.getOopField("_protection_domain"), 0); + signers = new OopField(type.getOopField("_signers"), 0); sourceFileName = type.getAddressField("_source_file_name"); sourceDebugExtension = type.getAddressField("_source_debug_extension"); - innerClasses = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize()); - nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize()); - staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize()); - staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), Oop.getHeaderSize()); - nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), Oop.getHeaderSize()); - isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), Oop.getHeaderSize()); - initState = new CIntField(type.getCIntegerField("_init_state"), Oop.getHeaderSize()); - vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize()); - itableLen = new CIntField(type.getCIntegerField("_itable_len"), Oop.getHeaderSize()); + innerClasses = type.getAddressField("_inner_classes"); + nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), 0); + staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), 0); + staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), 0); + nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), 0); + isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), 0); + initState = new CIntField(type.getCIntegerField("_init_state"), 0); + vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0); + itableLen = new CIntField(type.getCIntegerField("_itable_len"), 0); breakpoints = type.getAddressField("_breakpoints"); genericSignature = type.getAddressField("_generic_signature"); - majorVersion = new CIntField(type.getCIntegerField("_major_version"), Oop.getHeaderSize()); - minorVersion = new CIntField(type.getCIntegerField("_minor_version"), Oop.getHeaderSize()); - headerSize = alignObjectOffset(Oop.getHeaderSize() + type.getSize()); + majorVersion = new CIntField(type.getCIntegerField("_major_version"), 0); + minorVersion = new CIntField(type.getCIntegerField("_minor_version"), 0); + headerSize = Oop.alignObjectOffset(type.getSize()); // read field offset constants ACCESS_FLAGS_OFFSET = db.lookupIntConstant("FieldInfo::access_flags_offset").intValue(); @@ -100,18 +100,17 @@ HIGH_OFFSET = db.lookupIntConstant("FieldInfo::high_offset").intValue(); FIELD_SLOTS = db.lookupIntConstant("FieldInfo::field_slots").intValue(); // 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_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue(); - CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue(); - CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("instanceKlass::being_initialized").intValue(); - CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue(); - CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("instanceKlass::initialization_error").intValue(); + CLASS_STATE_ALLOCATED = db.lookupIntConstant("InstanceKlass::allocated").intValue(); + CLASS_STATE_LOADED = db.lookupIntConstant("InstanceKlass::loaded").intValue(); + CLASS_STATE_LINKED = db.lookupIntConstant("InstanceKlass::linked").intValue(); + CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("InstanceKlass::being_initialized").intValue(); + CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("InstanceKlass::fully_initialized").intValue(); + CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("InstanceKlass::initialization_error").intValue(); } - InstanceKlass(OopHandle handle, ObjectHeap heap) { - super(handle, heap); + public InstanceKlass(Address addr) { + super(addr); if (getJavaFieldsCount() != getAllFieldsCount()) { // Exercise the injected field logic for (int i = getJavaFieldsCount(); i < getAllFieldsCount(); i++) { @@ -121,20 +120,20 @@ } } - private static OopField arrayKlasses; - private static OopField methods; - private static OopField methodOrdering; - private static OopField localInterfaces; - private static OopField transitiveInterfaces; - private static OopField fields; + private static MetadataField arrayKlasses; + private static AddressField methods; + private static AddressField methodOrdering; + private static AddressField localInterfaces; + private static AddressField transitiveInterfaces; + private static AddressField fields; private static CIntField javaFieldsCount; - private static OopField constants; - private static OopField classLoader; + private static MetadataField constants; + private static AddressField classLoaderData; private static OopField protectionDomain; private static OopField signers; private static AddressField sourceFileName; private static AddressField sourceDebugExtension; - private static OopField innerClasses; + private static AddressField innerClasses; private static CIntField nonstaticFieldSize; private static CIntField staticFieldSize; private static CIntField staticOopFieldCount; @@ -150,7 +149,6 @@ // type safe enum for ClassState from instanceKlass.hpp 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 LOADED = new ClassState("loaded"); public static final ClassState LINKED = new ClassState("linked"); @@ -172,9 +170,7 @@ public int getInitStateAsInt() { return (int) initState.getValue(this); } public ClassState getInitState() { int state = getInitStateAsInt(); - if (state == CLASS_STATE_UNPARSABLE_BY_GC) { - return ClassState.UNPARSABLE_BY_GC; - } else if (state == CLASS_STATE_ALLOCATED) { + if (state == CLASS_STATE_ALLOCATED) { return ClassState.ALLOCATED; } else if (state == CLASS_STATE_LOADED) { return ClassState.LOADED; @@ -242,19 +238,24 @@ 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 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) { 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) { - int nameIndex = getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET); + int nameIndex = getFields().at(index * FIELD_SLOTS + NAME_INDEX_OFFSET); if (index < getJavaFieldsCount()) { return getConstants().getSymbolAt(nameIndex); } else { @@ -264,11 +265,11 @@ public short getFieldSignatureIndex(int index) { 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) { - int signatureIndex = getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET); + int signatureIndex = getFields().at(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET); if (index < getJavaFieldsCount()) { return getConstants().getSymbolAt(signatureIndex); } else { @@ -277,7 +278,7 @@ } public short getFieldGenericSignatureIndex(int index) { - int len = (int)getFields().getLength(); + int len = getFields().length(); int allFieldsCount = getAllFieldsCount(); int generic_signature_slot = allFieldsCount * FIELD_SLOTS; for (int i = 0; i < allFieldsCount; i++) { @@ -285,7 +286,7 @@ AccessFlags access = new AccessFlags(flags); if (i == index) { if (access.fieldHasGenericSignature()) { - return getFields().getShortAt(generic_signature_slot); + return getFields().at(generic_signature_slot); } else { return 0; } @@ -308,25 +309,23 @@ public short getFieldInitialValueIndex(int index) { 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) { - TypeArray fields = getFields(); - return VM.getVM().buildIntFromShorts(fields.getShortAt(index * FIELD_SLOTS + LOW_OFFSET), - fields.getShortAt(index * FIELD_SLOTS + HIGH_OFFSET)); + U2Array fields = getFields(); + return VM.getVM().buildIntFromShorts(fields.at(index * FIELD_SLOTS + LOW_OFFSET), + fields.at(index * FIELD_SLOTS + HIGH_OFFSET)); } // Accessors for declared fields public Klass getArrayKlasses() { return (Klass) arrayKlasses.getValue(this); } - public ObjArray getMethods() { return (ObjArray) methods.getValue(this); } - public TypeArray getMethodOrdering() { return (TypeArray) methodOrdering.getValue(this); } - public ObjArray getLocalInterfaces() { return (ObjArray) localInterfaces.getValue(this); } - public ObjArray getTransitiveInterfaces() { return (ObjArray) transitiveInterfaces.getValue(this); } - public TypeArray getFields() { return (TypeArray) fields.getValue(this); } + public MethodArray getMethods() { return new MethodArray(methods.getValue(getAddress())); } + public KlassArray getLocalInterfaces() { return new KlassArray(localInterfaces.getValue(getAddress())); } + public KlassArray getTransitiveInterfaces() { return new KlassArray(transitiveInterfaces.getValue(getAddress())); } public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); } public int getAllFieldsCount() { - int len = (int)getFields().getLength(); + int len = getFields().length(); int allFieldsCount = 0; for (; allFieldsCount*FIELD_SLOTS < len; allFieldsCount++) { short flags = getFieldAccessFlags(allFieldsCount); @@ -338,12 +337,12 @@ return allFieldsCount; } 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 ObjArray getSigners() { return (ObjArray) signers.getValue(this); } public Symbol getSourceFileName() { return getSymbol(sourceFileName); } - public String getSourceDebugExtension(){ return CStringUtilities.getString(sourceDebugExtension.getValue(getHandle())); } - public TypeArray getInnerClasses() { return (TypeArray) innerClasses.getValue(this); } + public String getSourceDebugExtension(){ return CStringUtilities.getString(sourceDebugExtension.getValue(getAddress())); } public long getNonstaticFieldSize() { return nonstaticFieldSize.getValue(this); } public long getStaticOopFieldCount() { return staticOopFieldCount.getValue(this); } public long getNonstaticOopMapSize() { return nonstaticOopMapSize.getValue(this); } @@ -383,8 +382,8 @@ public long computeModifierFlags() { long access = getAccessFlags(); // But check if it happens to be member class. - TypeArray innerClassList = getInnerClasses(); - int length = ( innerClassList == null)? 0 : (int) innerClassList.getLength(); + U2Array innerClassList = getInnerClasses(); + int length = (innerClassList == null)? 0 : (int) innerClassList.length(); if (length > 0) { if (Assert.ASSERTS_ENABLED) { Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0 || @@ -395,7 +394,7 @@ if (i == length - EnclosingMethodAttributeOffset.enclosing_method_attribute_size) { break; } - int ioff = innerClassList.getShortAt(i + + int ioff = innerClassList.at(i + InnerClassAttributeOffset.innerClassInnerClassInfoOffset); // 'ioff' can be zero. // refer to JVM spec. section 4.7.5. @@ -404,9 +403,9 @@ // since we are looking for the flags for our self. ConstantPool.CPSlot classInfo = getConstants().getSlotAt(ioff); Symbol name = null; - if (classInfo.isOop()) { - name = ((Klass) classInfo.getOop()).getName(); - } else if (classInfo.isMetaData()) { + if (classInfo.isResolved()) { + name = classInfo.getKlass().getName(); + } else if (classInfo.isUnresolved()) { name = classInfo.getSymbol(); } else { throw new RuntimeException("should not reach here"); @@ -414,7 +413,7 @@ if (name.equals(getName())) { // This is really a member class - access = innerClassList.getShortAt(i + + access = innerClassList.at(i + InnerClassAttributeOffset.innerClassAccessFlagsOffset); break; } @@ -440,8 +439,8 @@ } private boolean isInInnerClasses(Symbol sym, boolean includeLocals) { - TypeArray innerClassList = getInnerClasses(); - int length = ( innerClassList == null)? 0 : (int) innerClassList.getLength(); + U2Array innerClassList = getInnerClasses(); + int length = ( innerClassList == null)? 0 : (int) innerClassList.length(); if (length > 0) { if (Assert.ASSERTS_ENABLED) { Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0 || @@ -452,27 +451,19 @@ if (i == length - EnclosingMethodAttributeOffset.enclosing_method_attribute_size) { break; } - int ioff = innerClassList.getShortAt(i + + int ioff = innerClassList.at(i + InnerClassAttributeOffset.innerClassInnerClassInfoOffset); // 'ioff' can be zero. // refer to JVM spec. section 4.7.5. if (ioff != 0) { ConstantPool.CPSlot iclassInfo = getConstants().getSlotAt(ioff); - Symbol innerName = null; - if (iclassInfo.isOop()) { - innerName = ((Klass) iclassInfo.getOop()).getName(); - } else if (iclassInfo.isMetaData()) { - innerName = iclassInfo.getSymbol(); - } else { - throw new RuntimeException("should not reach here"); - } - + Symbol innerName = getConstants().getKlassNameAt(ioff); Symbol myname = getName(); - int ooff = innerClassList.getShortAt(i + + int ooff = innerClassList.at(i + InnerClassAttributeOffset.innerClassOuterClassInfoOffset); // for anonymous classes inner_name_index of InnerClasses // attribute is zero. - int innerNameIndex = innerClassList.getShortAt(i + + int innerNameIndex = innerClassList.at(i + InnerClassAttributeOffset.innerClassInnerNameOffset); // if this is not a member (anonymous, local etc.), 'ooff' will be zero // refer to JVM spec. section 4.7.5. @@ -488,9 +479,9 @@ } else { ConstantPool.CPSlot oclassInfo = getConstants().getSlotAt(ooff); Symbol outerName = null; - if (oclassInfo.isOop()) { - outerName = ((Klass) oclassInfo.getOop()).getName(); - } else if (oclassInfo.isMetaData()) { + if (oclassInfo.isResolved()) { + outerName = oclassInfo.getKlass().getName(); + } else if (oclassInfo.isUnresolved()) { outerName = oclassInfo.getSymbol(); } else { throw new RuntimeException("should not reach here"); @@ -513,10 +504,10 @@ if (Assert.ASSERTS_ENABLED) { Assert.that(k.isInterface(), "should not reach here"); } - ObjArray interfaces = getTransitiveInterfaces(); - final int len = (int) interfaces.getLength(); + KlassArray interfaces = getTransitiveInterfaces(); + final int len = interfaces.length(); 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; } @@ -533,20 +524,14 @@ tty.print("InstanceKlass for " + getName().asString()); } - public void iterateFields(OopVisitor visitor, boolean doVMFields) { - super.iterateFields(visitor, doVMFields); - if (doVMFields) { - visitor.doOop(arrayKlasses, true); - visitor.doOop(methods, true); - visitor.doOop(methodOrdering, true); - visitor.doOop(localInterfaces, true); - visitor.doOop(transitiveInterfaces, true); - visitor.doOop(fields, true); - visitor.doOop(constants, true); - visitor.doOop(classLoader, true); + public void iterateFields(MetadataVisitor visitor) { + super.iterateFields(visitor); + visitor.doMetadata(arrayKlasses, true); + // visitor.doOop(methods, true); + // visitor.doOop(localInterfaces, true); + // visitor.doOop(transitiveInterfaces, true); visitor.doOop(protectionDomain, true); visitor.doOop(signers, true); - visitor.doOop(innerClasses, true); visitor.doCInt(nonstaticFieldSize, true); visitor.doCInt(staticFieldSize, true); visitor.doCInt(staticOopFieldCount, true); @@ -556,7 +541,6 @@ visitor.doCInt(vtableLen, true); visitor.doCInt(itableLen, true); } - } /* * Visit the static fields of this InstanceKlass with the obj of @@ -628,10 +612,10 @@ /** Find field in direct superinterfaces. */ public Field findInterfaceField(Symbol name, Symbol sig) { - ObjArray interfaces = getLocalInterfaces(); - int n = (int) interfaces.getLength(); + KlassArray interfaces = getLocalInterfaces(); + int n = interfaces.length(); for (int i = 0; i < n; i++) { - InstanceKlass intf1 = (InstanceKlass) interfaces.getObjAt(i); + InstanceKlass intf1 = (InstanceKlass) interfaces.getAt(i); if (Assert.ASSERTS_ENABLED) { Assert.that(intf1.isInterface(), "just checking type"); } @@ -727,10 +711,10 @@ // transitiveInterfaces contains all interfaces implemented // by this class and its superclass chain with no duplicates. - ObjArray interfaces = getTransitiveInterfaces(); - int n = (int) interfaces.getLength(); + KlassArray interfaces = getTransitiveInterfaces(); + int n = interfaces.length(); for (int i = 0; i < n; i++) { - InstanceKlass intf1 = (InstanceKlass) interfaces.getObjAt(i); + InstanceKlass intf1 = (InstanceKlass) interfaces.getAt(i); if (Assert.ASSERTS_ENABLED) { Assert.that(intf1.isInterface(), "just checking type"); } @@ -759,20 +743,20 @@ // Contains a Method for each method declared in this class/interface // not including inherited methods. - ObjArray methods = getMethods(); - int length = (int)methods.getLength(); + MethodArray methods = getMethods(); + int length = methods.length(); Object[] tmp = new Object[length]; - TypeArray methodOrdering = getMethodOrdering(); - if (methodOrdering.getLength() != length) { + IntArray methodOrdering = getMethodOrdering(); + if (methodOrdering.length() != length) { // no ordering info present for (int index = 0; index < length; index++) { - tmp[index] = methods.getObjAt(index); + tmp[index] = methods.at(index); } } else { for (int index = 0; index < length; index++) { - int originalIndex = getMethodOrdering().getIntAt(index); - tmp[originalIndex] = methods.getObjAt(index); + int originalIndex = methodOrdering.at(index); + tmp[originalIndex] = methods.at(index); } } @@ -786,25 +770,17 @@ // Contains an InstanceKlass for each interface in this classes // 'implements' clause. - ObjArray interfaces = getLocalInterfaces(); - int length = (int) interfaces.getLength(); + KlassArray interfaces = getLocalInterfaces(); + int length = interfaces.length(); List directImplementedInterfaces = new ArrayList(length); for (int index = 0; index < length; index ++) { - directImplementedInterfaces.add(interfaces.getObjAt(index)); + directImplementedInterfaces.add(interfaces.getAt(index)); } 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) { // FIXME: in reflective system this would need to change to // actually allocate @@ -841,12 +817,28 @@ return findMethod(getMethods(), name, sig); } - /** Breakpoint support (see methods on methodOop for details) */ + /** Breakpoint support (see methods on Method* for details) */ public BreakpointInfo getBreakpoints() { - Address addr = getHandle().getAddressAt(Oop.getHeaderSize() + breakpoints.getOffset()); + Address addr = getAddress().getAddressAt(breakpoints.getOffset()); 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 // @@ -928,14 +920,14 @@ throw new RuntimeException("Illegal field type at index " + index); } - private static Method findMethod(ObjArray methods, Symbol name, Symbol signature) { - int len = (int) methods.getLength(); + private static Method findMethod(MethodArray methods, Symbol name, Symbol signature) { + int len = methods.length(); // methods are sorted, so do binary search int l = 0; int h = len - 1; while (l <= h) { int mid = (l + h) >> 1; - Method m = (Method) methods.getObjAt(mid); + Method m = methods.at(mid); int res = m.getName().fastCompare(name); if (res == 0) { // found matching name; do linear search to find matching signature @@ -944,13 +936,13 @@ // search downwards through overloaded methods int 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.getSignature().equals(signature)) return m1; } // search upwards 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.getSignature().equals(signature)) return m1; } @@ -977,10 +969,10 @@ return null; } - private static int linearSearch(ObjArray methods, Symbol name, Symbol signature) { - int len = (int) methods.getLength(); + private static int linearSearch(MethodArray methods, Symbol name, Symbol signature) { + int len = (int) methods.length(); 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)) { return index; }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlassKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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 InstanceKlassKlass is the klass of an InstanceKlass. -// There only exist one instance Universe::instanceKlassKlassObj() - -public class InstanceKlassKlass extends KlassKlass { - 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("instanceKlassKlass"); - headerSize = type.getSize() + Oop.getHeaderSize(); - } - - InstanceKlassKlass(OopHandle handle, ObjectHeap heap) { - super(handle, heap); - } - - private static long headerSize; - - public long getObjectSize() { return alignObjectSize(headerSize); } - - public void printValueOn(PrintStream tty) { - tty.print("InstanceKlassKlass"); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceMirrorKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceMirrorKlass.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -48,8 +48,8 @@ Type type = db.lookupType("instanceMirrorKlass"); } - InstanceMirrorKlass(OopHandle handle, ObjectHeap heap) { - super(handle, heap); + public InstanceMirrorKlass(Address addr) { + super(addr); } public long getObjectSize(Oop o) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceRefKlass.java Sat Sep 01 13:25:18 2012 -0400 @@ -0,0 +1,54 @@ +/* + * 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.debugger.*; +import sun.jvm.hotspot.memory.*; +import sun.jvm.hotspot.runtime.*; +import sun.jvm.hotspot.types.*; +import sun.jvm.hotspot.utilities.*; + +// An InstanceKlass is the VM level representation of a Java class. + +public class InstanceRefKlass extends InstanceKlass { + 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 { + // Just make sure it's there for now + Type type = db.lookupType("instanceRefKlass"); + } + + public InstanceRefKlass(Address addr) { + super(addr); + } +}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.jvm.hotspot.oops; import sun.jvm.hotspot.debugger.*; +import sun.jvm.hotspot.runtime.VMObject; // The class for an int field simply provides access to the value. public class IntField extends Field { @@ -46,6 +47,9 @@ } return obj.getHandle().getJIntAt(getOffset()); } + public int getValue(VMObject obj) { + return obj.getAddress().getJIntAt(getOffset()); + } public void setValue(Oop obj, int value) throws MutationException { // Fix this: setJIntAt is missing in Address }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * 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.types.*; -public class Klass extends Oop implements ClassConstants { +public class Klass extends Metadata implements ClassConstants { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -50,14 +50,14 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { Type type = db.lookupType("Klass"); - javaMirror = new OopField(type.getOopField("_java_mirror"), Oop.getHeaderSize()); - superField = new OopField(type.getOopField("_super"), Oop.getHeaderSize()); - layoutHelper = new IntField(type.getJIntField("_layout_helper"), Oop.getHeaderSize()); + javaMirror = new OopField(type.getOopField("_java_mirror"), 0); + superField = new MetadataField(type.getAddressField("_super"), 0); + layoutHelper = new IntField(type.getJIntField("_layout_helper"), 0); name = type.getAddressField("_name"); - accessFlags = new CIntField(type.getCIntegerField("_access_flags"), Oop.getHeaderSize()); - subklass = new OopField(type.getOopField("_subklass"), Oop.getHeaderSize()); - nextSibling = new OopField(type.getOopField("_next_sibling"), Oop.getHeaderSize()); - allocCount = new CIntField(type.getCIntegerField("_alloc_count"), Oop.getHeaderSize()); + accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0); + subklass = new MetadataField(type.getAddressField("_subklass"), 0); + nextSibling = new MetadataField(type.getAddressField("_next_sibling"), 0); + allocCount = new CIntField(type.getCIntegerField("_alloc_count"), 0); 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(); @@ -68,8 +68,8 @@ LH_ARRAY_TAG_OBJ_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_obj_value").intValue(); } - Klass(OopHandle handle, ObjectHeap heap) { - super(handle, heap); + public Klass(Address addr) { + super(addr); } // jvmdi support - see also class_status in VM code @@ -81,20 +81,20 @@ // Fields private static OopField javaMirror; - private static OopField superField; + private static MetadataField superField; private static IntField layoutHelper; private static AddressField name; private static CIntField accessFlags; - private static OopField subklass; - private static OopField nextSibling; + private static MetadataField subklass; + private static MetadataField nextSibling; private static CIntField allocCount; private Address getValue(AddressField field) { - return getHandle().getAddressAt(field.getOffset() + Oop.getHeaderSize()); + return addr.getAddressAt(field.getOffset()); } 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 @@ -164,19 +164,16 @@ tty.print("Klass"); } - public void iterateFields(OopVisitor visitor, boolean doVMFields) { - super.iterateFields(visitor, doVMFields); - if (doVMFields) { + public void iterateFields(MetadataVisitor visitor) { visitor.doOop(javaMirror, true); - visitor.doOop(superField, true); + visitor.doMetadata(superField, true); visitor.doInt(layoutHelper, true); // visitor.doOop(name, true); visitor.doCInt(accessFlags, true); - visitor.doOop(subklass, true); - visitor.doOop(nextSibling, true); + visitor.doMetadata(subklass, true); + visitor.doMetadata(nextSibling, true); visitor.doCInt(allocCount, true); } - } public long getObjectSize() { throw new RuntimeException("should not reach here"); @@ -191,11 +188,11 @@ public Klass arrayKlassOrNull() { return arrayKlassImpl(true); } 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) { - 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
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/KlassKlass.java Fri Aug 31 16:39:35 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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"); - } -}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/LocalVariableTableElement.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/LocalVariableTableElement.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -58,10 +58,10 @@ private static long offsetOfSignatureCPIndex; private static long offsetOfSlot; - private OopHandle handle; + private Address handle; private long offset; - public LocalVariableTableElement(OopHandle handle, long offset) { + public LocalVariableTableElement(Address handle, long offset) { this.handle = handle; this.offset = offset; }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/LongField.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/LongField.java Sat Sep 01 13:25:18 2012 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.jvm.hotspot.oops; import sun.jvm.hotspot.debugger.*; +import sun.jvm.hotspot.runtime.VMObject; // The class for a long field simply provides access to the value. public class LongField extends Field { @@ -41,6 +42,7 @@ } 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) { // Fix this: setJLongAt is missing in Address }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Metadata.java Sat Sep 01 13:25:18 2012 -0400 @@ -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); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MetadataField.java Sat Sep 01 13:25:18 2012 -0400 @@ -0,0 +1,49 @@ +/* + * 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.runtime.VMObject; +import sun.jvm.hotspot.debugger.*; + +// The class for an C int field simply provides access to the value. +public class MetadataField extends Field { + + public MetadataField(sun.jvm.hotspot.types.AddressField vmField, long startOffset) { + super(new NamedFieldIdentifier(vmField.getName()), vmField.getOffset() + startOffset, true); + } + + 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 + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MetadataVisitor.java Sat Sep 01 13:25:18 2012 -0400 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2000, 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; + +// A MetadataVisitor can be used to inspect all fields within an object. +// Fields include vm fields, java fields, indexable fields. + +public interface MetadataVisitor extends FieldVisitor { + // Called before visiting an object + public void prologue(); + + // Called after visiting an object + public void epilogue(); + + public void setObj(Metadata obj); + + // Returns the object being visited + public Metadata getObj(); +};
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java Fri Aug 31 16:39:35 2012 -0700 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java Sat Sep 01 13:25:18 2012 -0400 @@ -36,7 +36,7 @@ // A Method represents a Java method -public class Method extends Oop { +public class Method extends Metadata { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -46,9 +46,9 @@ } private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { - Type type = db.lookupType("methodOopDesc"); - constMethod = new OopField(type.getOopField("_constMethod"), 0); - methodData = new OopField(type.getOopField("_method_data"), 0); + Type type = db.lookupType("Method"); + constMethod = type.getAddressField("_constMethod"); + methodData = type.getAddressField("_method_data"); methodSize = new CIntField(type.getCIntegerField("_method_size"), 0); maxStack = new CIntField(type.getCIntegerField("_max_stack"), 0); maxLocals = new CIntField(type.getCIntegerField("_max_locals"), 0); @@ -74,15 +74,15 @@ classInitializerName = null; } - Method(OopHandle handle, ObjectHeap heap) { - super(handle, heap); + public Method(Address addr) { + super(addr); } public boolean isMethod() { return true; } // Fields - private static