src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java Fri Aug 17 11:56:59 2018 -0500
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java Fri Aug 17 13:20:53 2018 -0700
@@ -21,27 +21,27 @@
* questions.
*/
+
+
package jdk.tools.jaotc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
+import jdk.tools.jaotc.AOTDynamicTypeStore.AdapterLocation;
+import jdk.tools.jaotc.AOTDynamicTypeStore.AppendixLocation;
+import jdk.tools.jaotc.AOTDynamicTypeStore.Location;
import jdk.tools.jaotc.binformat.BinaryContainer;
import jdk.tools.jaotc.binformat.ReadOnlyDataContainer;
import jdk.tools.jaotc.binformat.Symbol.Binding;
import jdk.tools.jaotc.binformat.Symbol.Kind;
-
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
import jdk.vm.ci.meta.ResolvedJavaField;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
-import jdk.tools.jaotc.AOTDynamicTypeStore.AdapterLocation;
-import jdk.tools.jaotc.AOTDynamicTypeStore.AppendixLocation;
-import jdk.tools.jaotc.AOTDynamicTypeStore.Location;
-
/**
* Class encapsulating Graal-compiled output of a Java class. The compilation result of all methods
* of a class {@code className} are maintained in an array list.
@@ -74,7 +74,7 @@
this.dependentMethods = new ArrayList<>();
this.classId = classId;
this.type = type;
- this.metadataName = type.isAnonymous() ? "anon<"+ classId + ">": type.getName();
+ this.metadataName = type.isAnonymous() ? "anon<" + classId + ">" : type.getName();
this.gotIndex = binaryContainer.addTwoSlotKlassSymbol(metadataName);
this.compiledMethodsOffset = -1; // Not compiled classes do not have compiled methods.
this.dependentMethodsOffset = -1;
@@ -84,9 +84,9 @@
String name = metadataName;
Set<Location> locs = dynoStore.getDynamicClassLocationsForType(type);
if (locs == null) {
- return new String[] {name};
+ return new String[]{name};
} else {
- ArrayList<String> names = new ArrayList<String>();
+ ArrayList<String> names = new ArrayList<>();
names.add(name);
for (Location l : locs) {
HotSpotResolvedObjectType cpType = l.getHolder();
@@ -95,14 +95,14 @@
// may record types that don't make it into the final graph.
// We can safely ignore those here.
if (data == null) {
- // Not a compiled or inlined method
- continue;
+ // Not a compiled or inlined method
+ continue;
}
int cpi = l.getCpi();
- String location = "<"+ data.classId + ":" + cpi + ">";
+ String location = "<" + data.classId + ":" + cpi + ">";
if (l instanceof AdapterLocation) {
names.add("adapter" + location);
- AdapterLocation a = (AdapterLocation)l;
+ AdapterLocation a = (AdapterLocation) l;
names.add("adapter:" + a.getMethodId() + location);
} else {
assert l instanceof AppendixLocation;
@@ -319,26 +319,23 @@
/**
* Add a klass data.
*/
- synchronized static AOTKlassData addAOTKlassData(BinaryContainer binaryContainer, HotSpotResolvedObjectType type) {
- String name = type.getName();
- AOTKlassData data = klassData.get(name);
- if (data != null) {
- assert data.getType() == type : "duplicate classes for name " + name;
- } else {
+ static synchronized AOTKlassData addAOTKlassData(BinaryContainer binaryContainer, HotSpotResolvedObjectType type) {
+ AOTKlassData data = getAOTKlassData(type);
+ if (data == null) {
data = new AOTKlassData(binaryContainer, type, classesCount++);
- klassData.put(name, data);
+ klassData.put(type.getName(), data);
}
return data;
}
- private synchronized static AOTKlassData getAOTKlassData(String name) {
- return klassData.get(name);
- }
-
- synchronized static AOTKlassData getAOTKlassData(HotSpotResolvedObjectType type) {
+ static synchronized AOTKlassData getAOTKlassData(HotSpotResolvedObjectType type) {
String name = type.getName();
- AOTKlassData data = getAOTKlassData(name);
- assert data == null || data.getType() == type : "duplicate classes for name " + name;
+ AOTKlassData data = klassData.get(name);
+ if (data != null) {
+ HotSpotResolvedObjectType oldType = data.getType();
+ assert oldType == type : "duplicate classes for name " + type.getName() + ", fingerprints old: " + oldType.getFingerprint() + ", new: " + type.getFingerprint() +
+ ", klass pointers old: " + oldType.klass() + ", new: " + type.klass();
+ }
return data;
}
@@ -363,17 +360,14 @@
}
}
- synchronized static AOTKlassData addFingerprintKlassData(BinaryContainer binaryContainer, HotSpotResolvedObjectType type) {
+ static synchronized AOTKlassData addFingerprintKlassData(BinaryContainer binaryContainer, HotSpotResolvedObjectType type) {
if (type.isArray()) {
return addAOTKlassData(binaryContainer, type);
}
assert type.getFingerprint() != 0 : "no fingerprint for " + type.getName();
AOTKlassData old = getAOTKlassData(type);
if (old != null) {
- boolean assertsEnabled = false;
- // Next assignment will be executed when asserts are enabled.
- assert assertsEnabled = true;
- if (assertsEnabled) {
+ if (areAssertionsEnabled()) {
HotSpotResolvedObjectType s = type.getSuperclass();
if (s != null) {
assert getAOTKlassData(s) != null : "fingerprint for super " + s.getName() + " needed for " + type.getName();
@@ -397,6 +391,14 @@
return addAOTKlassData(binaryContainer, type);
}
+ @SuppressWarnings("all")
+ private static boolean areAssertionsEnabled() {
+ boolean assertsEnabled = false;
+ // Next assignment will be executed when asserts are enabled.
+ assert assertsEnabled = true;
+ return assertsEnabled;
+ }
+
/*
* Put methods data to contained.
*/
@@ -431,9 +433,7 @@
}
static HotSpotResolvedObjectType getType(Object ref) {
- return (ref instanceof HotSpotResolvedObjectType) ?
- (HotSpotResolvedObjectType)ref :
- ((HotSpotResolvedJavaMethod)ref).getDeclaringClass();
+ return (ref instanceof HotSpotResolvedObjectType) ? (HotSpotResolvedObjectType) ref : ((HotSpotResolvedJavaMethod) ref).getDeclaringClass();
}
static String metadataName(HotSpotResolvedObjectType type) {
@@ -448,11 +448,11 @@
static String metadataName(Object ref) {
if (ref instanceof HotSpotResolvedJavaMethod) {
- HotSpotResolvedJavaMethod m = (HotSpotResolvedJavaMethod)ref;
+ HotSpotResolvedJavaMethod m = (HotSpotResolvedJavaMethod) ref;
return metadataName(m);
} else {
assert ref instanceof HotSpotResolvedObjectType : "unexpected object type " + ref.getClass().getName();
- HotSpotResolvedObjectType type = (HotSpotResolvedObjectType)ref;
+ HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) ref;
return metadataName(type);
}
}