Skip to content

Commit 5c58d27

Browse files
Jon MasamitsustefankMikael Gerdintkrodriguez
authored andcommitted
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com> Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com> Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com> Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
1 parent 36eee7c commit 5c58d27

File tree

853 files changed

+26094
-82926
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

853 files changed

+26094
-82926
lines changed

hotspot/agent/doc/clhsdb.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ <h3>Annotated output of CLHSDB help command</h3>
3838
assert true | false <font color="red">turn on/off asserts in SA code</font>
3939
attach pid | exec core <font color="red">attach SA to a process or core</font>
4040
class name <font color="red">find a Java class from debuggee and print oop</font>
41-
classes <font color="red">print all loaded Java classes with klassOop</font>
41+
classes <font color="red">print all loaded Java classes with Klass*</font>
4242
detach <font color="red">detach SA from current target</font>
4343
dis address [ length ] <font color="red">disassemble (sparc/x86) specified number of instructions from given address</font>
44-
dumpclass { address | name } [ directory ] <font color="red">dump .class file for given klassOop or class name</font>
44+
dumpclass { address | name } [ directory ] <font color="red">dump .class file for given Klass* or class name</font>
4545
dumpheap [ file ] <font color="red">dump heap in hprof binary format</font>
4646
echo [ true | false ] <font color="red">turn on/off command echo mode</font>
4747
examine [ address/count ] | [ address,address] <font color="red">show contents of memory from given address</font>
@@ -51,15 +51,15 @@ <h3>Annotated output of CLHSDB help command</h3>
5151
help [ command ] <font color="red">print help message for all commands or just given command</font>
5252
history <font color="red">show command history. usual !command-number syntax works.</font>
5353
inspect expression <font color="red">inspect a given oop</font>
54-
jdis address <font color="red">show bytecode disassembly of a given methodOop</font>
54+
jdis address <font color="red">show bytecode disassembly of a given Method*</font>
5555
jhisto <font color="red">show Java heap histogram</font>
5656
jseval script <font color="red">evaluate a given string as JavaScript code</font>
5757
jsload file <font color="red">load and evaluate a JavaScript file</font>
5858
jstack [-v] <font color="red">show Java stack trace of all Java threads. -v is verbose mode</font>
5959
livenmethods <font color="red">show all live nmethods</font>
6060
mem address [ length ] <font color="red">show contents of memory -- also shows closest ELF/COFF symbol if found</font>
6161
pmap <font color="red">show Solaris pmap-like output</font>
62-
print expression <font color="red">print given klassOop, methodOop or arbitrary address</font>
62+
print expression <font color="red">print given Klass*, Method* or arbitrary address</font>
6363
printas type expression <font color="red">print given address as given HotSpot type. eg. print JavaThread &lt;address&gt;</font>
6464
printstatics [ type ] <font color="red">print static fields of given HotSpot type (or all types if none specified)</font>
6565
pstack [-v] <font color="red">show mixed mode stack trace for all Java, non-Java threads. -v is verbose mode</font>

hotspot/agent/src/os/bsd/ps_core.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -210,7 +210,6 @@ static map_info* core_lookup(struct ps_prochandle *ph, uintptr_t addr)
210210
// mapped. This structure gets written to a file. It is not a class,
211211
// so that the compilers don't add any compiler-private data to it.
212212

213-
// Refer to CompactingPermGenGen::n_regions in compactingPermGenGen.hpp
214213
#define NUM_SHARED_MAPS 4
215214

216215
// Refer to FileMapInfo::_current_version in filemap.hpp
@@ -234,7 +233,7 @@ struct FileMapHeader {
234233
char _read_only; // read only space?
235234
char _allow_exec; // executable code in space?
236235

237-
} _space[NUM_SHARED_MAPS]; // was _space[CompactingPermGenGen::n_regions];
236+
} _space[NUM_SHARED_MAPS];
238237

239238
// Ignore the rest of the FileMapHeader. We don't need those fields here.
240239
};

hotspot/agent/src/os/linux/ps_core.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -209,7 +209,6 @@ static map_info* core_lookup(struct ps_prochandle *ph, uintptr_t addr)
209209
// mapped. This structure gets written to a file. It is not a class,
210210
// so that the compilers don't add any compiler-private data to it.
211211

212-
// Refer to CompactingPermGenGen::n_regions in compactingPermGenGen.hpp
213212
#define NUM_SHARED_MAPS 4
214213

215214
// Refer to FileMapInfo::_current_version in filemap.hpp
@@ -233,7 +232,7 @@ struct FileMapHeader {
233232
char _read_only; // read only space?
234233
char _allow_exec; // executable code in space?
235234

236-
} _space[NUM_SHARED_MAPS]; // was _space[CompactingPermGenGen::n_regions];
235+
} _space[NUM_SHARED_MAPS];
237236

238237
// Ignore the rest of the FileMapHeader. We don't need those fields here.
239238
};

hotspot/agent/src/os/solaris/proc/saproc.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -510,7 +510,6 @@ wrapper_fill_cframe_list(void *cd, const prgregset_t regs, uint_t argc,
510510
// mapped. This structure gets written to a file. It is not a class, so
511511
// that the compilers don't add any compiler-private data to it.
512512

513-
// Refer to CompactingPermGenGen::n_regions in compactingPermGenGen.hpp
514513
const int NUM_SHARED_MAPS = 4;
515514

516515
// Refer to FileMapInfo::_current_version in filemap.hpp
@@ -531,7 +530,7 @@ struct FileMapHeader {
531530
bool _read_only; // read only space?
532531
bool _allow_exec; // executable code in space?
533532

534-
} _space[NUM_SHARED_MAPS]; // was _space[CompactingPermGenGen::n_regions];
533+
} _space[NUM_SHARED_MAPS];
535534

536535
// Ignore the rest of the FileMapHeader. We don't need those fields here.
537536
};

hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -634,29 +634,57 @@ public void doit(Tokens t) {
634634
} else {
635635
String s = t.nextToken();
636636
if (s.equals("-a")) {
637-
HeapVisitor iterator = new DefaultHeapVisitor() {
638-
public boolean doObj(Oop obj) {
639-
if (obj instanceof MethodData) {
640-
Method m = ((MethodData)obj).getMethod();
641-
out.println("MethodData " + obj.getHandle() + " for " +
637+
SystemDictionary sysDict = VM.getVM().getSystemDictionary();
638+
sysDict.allClassesDo(new SystemDictionary.ClassVisitor() {
639+
public void visit(Klass k) {
640+
if (k instanceof InstanceKlass) {
641+
MethodArray methods = ((InstanceKlass)k).getMethods();
642+
for (int i = 0; i < methods.length(); i++) {
643+
Method m = methods.at(i);
644+
MethodData mdo = m.getMethodData();
645+
if (mdo != null) {
646+
out.println("MethodData " + mdo.getAddress() + " for " +
642647
"method " + m.getMethodHolder().getName().asString() + "." +
643648
m.getName().asString() +
644-
m.getSignature().asString() + "@" + m.getHandle());
645-
((MethodData)obj).printDataOn(out);
649+
m.getSignature().asString() + "@" + m.getAddress());
650+
mdo.printDataOn(out);
646651
}
647-
return false;
648652
}
649-
};
650-
VM.getVM().getObjectHeap().iteratePerm(iterator);
653+
}
654+
}
655+
}
656+
);
651657
} else {
652658
Address a = VM.getVM().getDebugger().parseAddress(s);
653-
OopHandle handle = a.addOffsetToAsOopHandle(0);
654-
MethodData mdo = (MethodData)VM.getVM().getObjectHeap().newOop(handle);
659+
MethodData mdo = (MethodData) Metadata.instantiateWrapperFor(a);
655660
mdo.printDataOn(out);
656661
}
657662
}
658663
}
659664
},
665+
new Command("printall", "printall", false) {
666+
// Print every MDO in the heap or the one referenced by expression.
667+
public void doit(Tokens t) {
668+
if (t.countTokens() != 0) {
669+
usage();
670+
} else {
671+
SystemDictionary sysDict = VM.getVM().getSystemDictionary();
672+
sysDict.allClassesDo(new SystemDictionary.ClassVisitor() {
673+
public void visit(Klass k) {
674+
if (k instanceof InstanceKlass && ((InstanceKlass)k).getConstants().getCache() != null) {
675+
MethodArray methods = ((InstanceKlass)k).getMethods();
676+
for (int i = 0; i < methods.length(); i++) {
677+
Method m = methods.at(i);
678+
HTMLGenerator gen = new HTMLGenerator(false);
679+
out.println(gen.genHTML(m));
680+
}
681+
}
682+
}
683+
}
684+
);
685+
}
686+
}
687+
},
660688
new Command("dumpideal", "dumpideal { -a | id }", false) {
661689
// Do a full dump of the nodes reachabile from root in each compiler thread.
662690
public void doit(Tokens t) {
@@ -1229,7 +1257,7 @@ public void epilogue() {
12291257
}
12301258
};
12311259
VM.getVM().getObjectHeap().iterateRaw(iterator);
1232-
} else if (type.equals("heap") || type.equals("perm")) {
1260+
} else if (type.equals("heap")) {
12331261
HeapVisitor iterator = new DefaultHeapVisitor() {
12341262
public boolean doObj(Oop obj) {
12351263
int index = 0;
@@ -1246,11 +1274,7 @@ public boolean doObj(Oop obj) {
12461274
return false;
12471275
}
12481276
};
1249-
if (type.equals("heap")) {
12501277
VM.getVM().getObjectHeap().iterate(iterator);
1251-
} else {
1252-
VM.getVM().getObjectHeap().iteratePerm(iterator);
1253-
}
12541278
} else if (type.equals("codecache")) {
12551279
CodeCacheVisitor v = new CodeCacheVisitor() {
12561280
public void prologue(Address start, Address end) {

hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -998,7 +998,7 @@ public void run() {
998998
curFrame.addressOfInterpreterFrameLocal((int) interpreterFrameMethod.getMaxLocals() + offset),
999999
"Interpreter locals area for frame with SP = " + curFrame.getSP()));
10001000
}
1001-
String methodAnno = "Interpreter frame methodOop";
1001+
String methodAnno = "Interpreter frame Method*";
10021002
if (interpreterFrameMethod == null) {
10031003
methodAnno += " (BAD OOP)";
10041004
}
@@ -1054,13 +1054,6 @@ public void addAnnotation(Address addr, OopHandle handle) {
10541054
}
10551055
}
10561056

1057-
if (bad) {
1058-
// Try perm gen
1059-
if (heap.permGen().isIn(handle)) {
1060-
anno = "PermGen ";
1061-
bad = false;
1062-
}
1063-
}
10641057
} else if (collHeap instanceof ParallelScavengeHeap) {
10651058
ParallelScavengeHeap heap = (ParallelScavengeHeap) collHeap;
10661059
if (heap.youngGen().isIn(handle)) {
@@ -1069,9 +1062,6 @@ public void addAnnotation(Address addr, OopHandle handle) {
10691062
} else if (heap.oldGen().isIn(handle)) {
10701063
anno = "PSOldGen ";
10711064
bad = false;
1072-
} else if (heap.permGen().isIn(handle)) {
1073-
anno = "PSPermGen ";
1074-
bad = false;
10751065
}
10761066
} else {
10771067
// Optimistically assume the oop isn't bad

hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -50,6 +50,7 @@ public class HotSpotTypeDataBase extends BasicTypeDataBase {
5050
private static final int C_INT8_SIZE = 1;
5151
private static final int C_INT32_SIZE = 4;
5252
private static final int C_INT64_SIZE = 8;
53+
private static int pointerSize = UNINITIALIZED_SIZE;
5354

5455
private static final boolean DEBUG;
5556
static {
@@ -185,6 +186,9 @@ private void readVMTypes() {
185186
long size = entryAddr.getCIntegerAt(typeEntrySizeOffset, C_INT64_SIZE, true);
186187

187188
createType(typeName, superclassName, isOopType, isIntegerType, isUnsigned, size);
189+
if (pointerSize == UNINITIALIZED_SIZE && typeName.equals("void*")) {
190+
pointerSize = (int)size;
191+
}
188192
}
189193

190194
entryAddr = entryAddr.addOffsetTo(typeEntryArrayStride);
@@ -678,7 +682,11 @@ private BasicPointerType recursiveCreateBasicPointerType(String typeName) {
678682
}
679683
}
680684
result = new BasicPointerType(this, typeName, targetType);
681-
result.setSize(UNINITIALIZED_SIZE);
685+
if (pointerSize == UNINITIALIZED_SIZE && !typeName.equals("void*")) {
686+
// void* must be declared early so that other pointer types can use that to set their size.
687+
throw new InternalError("void* type hasn't been seen when parsing " + typeName);
688+
}
689+
result.setSize(pointerSize);
682690
addType(result);
683691
return result;
684692
}
@@ -731,9 +739,11 @@ public void createType(String typeName, String superclassName,
731739
"had its size redefined (old was " + curType.getSize() + ", new is " + size + ").");
732740
}
733741

742+
if (!typeNameIsPointerType(typeName)) {
734743
System.err.println("Warning: the type \"" + typeName + "\" (declared in the remote VM in VMStructs::localHotSpotVMTypes) " +
735744
"had its size declared as " + size + " twice. Continuing.");
736745
}
746+
}
737747

738748
}
739749

hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciArrayKlassKlass.java renamed to hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciBaseObject.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,14 @@
2424

2525
package sun.jvm.hotspot.ci;
2626

27-
import java.io.PrintStream;
27+
import java.io.*;
2828
import java.util.*;
2929
import sun.jvm.hotspot.debugger.*;
3030
import sun.jvm.hotspot.runtime.*;
3131
import sun.jvm.hotspot.oops.*;
3232
import sun.jvm.hotspot.types.*;
3333

34-
public class ciArrayKlassKlass extends ciKlassKlass {
34+
public class ciBaseObject extends VMObject {
3535
static {
3636
VM.registerVMInitializedObserver(new Observer() {
3737
public void update(Observable o, Object data) {
@@ -41,11 +41,13 @@ public void update(Observable o, Object data) {
4141
}
4242

4343
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
44-
Type type = db.lookupType("ciArrayKlassKlass");
44+
Type type = db.lookupType("ciBaseObject");
45+
identField = new CIntField(type.getCIntegerField("_ident"), 0);
4546
}
4647

48+
private static CIntField identField;
4749

48-
public ciArrayKlassKlass(Address addr) {
50+
public ciBaseObject(Address addr) {
4951
super(addr);
5052
}
5153
}

hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -47,8 +47,8 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc
4747
Type type = db.lookupType("ciInstanceKlass");
4848
initStateField = new CIntField(type.getCIntegerField("_init_state"), 0);
4949
isSharedField = new CIntField(type.getCIntegerField("_is_shared"), 0);
50-
CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue();
51-
CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue();
50+
CLASS_STATE_LINKED = db.lookupIntConstant("InstanceKlass::linked").intValue();
51+
CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("InstanceKlass::fully_initialized").intValue();
5252
}
5353

5454
private static CIntField initStateField;
@@ -63,7 +63,7 @@ public ciInstanceKlass(Address addr) {
6363
public int initState() {
6464
int initState = (int)initStateField.getValue(getAddress());
6565
if (isShared() && initState < CLASS_STATE_LINKED) {
66-
InstanceKlass ik = (InstanceKlass)getOop();
66+
InstanceKlass ik = (InstanceKlass)getMetadata();
6767
initState = ik.getInitStateAsInt();
6868
}
6969
return initState;

0 commit comments

Comments
 (0)