src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java
Index
Unified diffs
Context diffs
Sdiffs
Frames
Patch
New
Old
Previous File
Next File
hotspot Cdiff src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java
src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2016, 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.
--- 1,7 ----
/*
! * Copyright (c) 2016, 2017, 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.
*** 39,116 ****
/**
* 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.
*/
! public class AOTCompiledClass {
! public static class AOTKlassData {
! int gotIndex; // Index (offset/8) to the got in the .metaspace.got section
! int classId; // Unique ID
// Offset to compiled methods data in the .methods.offsets section.
! int compiledMethodsOffset;
// Offset to dependent methods data.
! int dependentMethodsOffset;
! long fingerprint; // Class fingerprint
private final String name;
private boolean isArray;
/**
* List of dependent compiled methods which have a reference to this class.
*/
private ArrayList<CompiledMethodInfo> dependentMethods;
! public AOTKlassData(BinaryContainer binaryContainer, String name, long fingerprint, int classId) {
this.dependentMethods = new ArrayList<>();
this.classId = classId;
this.fingerprint = fingerprint;
! this.gotIndex = binaryContainer.addTwoSlotMetaspaceSymbol(name);
this.compiledMethodsOffset = -1; // Not compiled classes do not have compiled methods.
this.dependentMethodsOffset = -1;
this.name = name;
this.isArray = name.length() > 0 && name.charAt(0) == '[';
}
! public long getFingerprint() {
return fingerprint;
}
/**
* Add a method to the list of dependent methods.
*/
! public synchronized boolean addDependentMethod(CompiledMethodInfo cm) {
return dependentMethods.add(cm);
}
/**
* Return the array list of dependent class methods.
*
* @return array list of dependent methods
*/
! public ArrayList<CompiledMethodInfo> getDependentMethods() {
return dependentMethods;
}
/**
* Returns if this class has dependent methods.
*
* @return true if dependent methods exist, false otherwise
*/
! public boolean hasDependentMethods() {
return !dependentMethods.isEmpty();
}
! public void setCompiledMethodsOffset(int offset) {
compiledMethodsOffset = offset;
}
protected void putAOTKlassData(BinaryContainer binaryContainer, ReadOnlyDataContainer container) {
int cntDepMethods = dependentMethods.size();
// Create array of dependent methods IDs. First word is count.
ReadOnlyDataContainer dependenciesContainer = binaryContainer.getKlassesDependenciesContainer();
! this.dependentMethodsOffset = binaryContainer.addMethodsCount(cntDepMethods, dependenciesContainer);
for (CompiledMethodInfo methodInfo : dependentMethods) {
dependenciesContainer.appendInt(methodInfo.getCodeId());
}
verify();
--- 39,116 ----
/**
* 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.
*/
! final class AOTCompiledClass {
! static class AOTKlassData {
! private int gotIndex; // Index (offset/8) to the got in the .metaspace.got section
! private int classId; // Unique ID
// Offset to compiled methods data in the .methods.offsets section.
! private int compiledMethodsOffset;
// Offset to dependent methods data.
! private int dependentMethodsOffset;
! private long fingerprint; // Class fingerprint
private final String name;
private boolean isArray;
/**
* List of dependent compiled methods which have a reference to this class.
*/
private ArrayList<CompiledMethodInfo> dependentMethods;
! AOTKlassData(BinaryContainer binaryContainer, String name, long fingerprint, int classId) {
this.dependentMethods = new ArrayList<>();
this.classId = classId;
this.fingerprint = fingerprint;
! this.gotIndex = binaryContainer.addTwoSlotKlassSymbol(name);
this.compiledMethodsOffset = -1; // Not compiled classes do not have compiled methods.
this.dependentMethodsOffset = -1;
this.name = name;
this.isArray = name.length() > 0 && name.charAt(0) == '[';
}
! long getFingerprint() {
return fingerprint;
}
/**
* Add a method to the list of dependent methods.
*/
! synchronized boolean addDependentMethod(CompiledMethodInfo cm) {
return dependentMethods.add(cm);
}
/**
* Return the array list of dependent class methods.
*
* @return array list of dependent methods
*/
! ArrayList<CompiledMethodInfo> getDependentMethods() {
return dependentMethods;
}
/**
* Returns if this class has dependent methods.
*
* @return true if dependent methods exist, false otherwise
*/
! boolean hasDependentMethods() {
return !dependentMethods.isEmpty();
}
! void setCompiledMethodsOffset(int offset) {
compiledMethodsOffset = offset;
}
protected void putAOTKlassData(BinaryContainer binaryContainer, ReadOnlyDataContainer container) {
int cntDepMethods = dependentMethods.size();
// Create array of dependent methods IDs. First word is count.
ReadOnlyDataContainer dependenciesContainer = binaryContainer.getKlassesDependenciesContainer();
! this.dependentMethodsOffset = BinaryContainer.addMethodsCount(cntDepMethods, dependenciesContainer);
for (CompiledMethodInfo methodInfo : dependentMethods) {
dependenciesContainer.appendInt(methodInfo.getCodeId());
}
verify();
*** 174,275 ****
* Construct an object with compiled methods. Intended to be used for code with no corresponding
* Java method name in the user application.
*
* @param compiledMethods AOT compiled methods
*/
! public AOTCompiledClass(ArrayList<CompiledMethodInfo> compiledMethods) {
this.resolvedJavaType = null;
this.compiledMethods = compiledMethods;
this.representsStubs = true;
}
/**
* Construct an object with compiled versions of the named class.
*/
! public AOTCompiledClass(ResolvedJavaType resolvedJavaType) {
this.resolvedJavaType = (HotSpotResolvedObjectType) resolvedJavaType;
this.compiledMethods = new ArrayList<>();
this.representsStubs = false;
}
/**
* @return the ResolvedJavaType of this class
*/
! public ResolvedJavaType getResolvedJavaType() {
return resolvedJavaType;
}
/**
* Get the list of methods which should be compiled.
*/
! public ArrayList<ResolvedJavaMethod> getMethods() {
ArrayList<ResolvedJavaMethod> m = methods;
methods = null; // Free - it is not used after that.
return m;
}
/**
* Get the number of all AOT classes.
*/
! public static int getClassesCount() {
return classesCount;
}
/**
* Get the number of methods which should be compiled.
*
* @return number of methods which should be compiled
*/
! public int getMethodCount() {
return methods.size();
}
/**
* Add a method to the list of methods to be compiled.
*/
! public void addMethod(ResolvedJavaMethod method) {
methods.add(method);
}
/**
* Returns if this class has methods which should be compiled.
*
* @return true if this class contains methods which should be compiled, false otherwise
*/
! public boolean hasMethods() {
return !methods.isEmpty();
}
/**
* Add a method to the list of compiled methods. This method needs to be thread-safe.
*/
! public synchronized boolean addCompiledMethod(CompiledMethodInfo cm) {
return compiledMethods.add(cm);
}
/**
* Return the array list of compiled class methods.
*
* @return array list of compiled methods
*/
! public ArrayList<CompiledMethodInfo> getCompiledMethods() {
return compiledMethods;
}
/**
* Returns if this class has successfully compiled methods.
*
* @return true if methods were compiled, false otherwise
*/
! public boolean hasCompiledMethods() {
return !compiledMethods.isEmpty();
}
/**
* Add a klass data.
*/
! public synchronized static AOTKlassData addAOTKlassData(BinaryContainer binaryContainer, HotSpotResolvedObjectType type) {
String name = type.getName();
long fingerprint = type.getFingerprint();
AOTKlassData data = klassData.get(name);
if (data != null) {
assert data.getFingerprint() == fingerprint : "incorrect fingerprint data for klass: " + name;
--- 174,275 ----
* Construct an object with compiled methods. Intended to be used for code with no corresponding
* Java method name in the user application.
*
* @param compiledMethods AOT compiled methods
*/
! AOTCompiledClass(ArrayList<CompiledMethodInfo> compiledMethods) {
this.resolvedJavaType = null;
this.compiledMethods = compiledMethods;
this.representsStubs = true;
}
/**
* Construct an object with compiled versions of the named class.
*/
! AOTCompiledClass(ResolvedJavaType resolvedJavaType) {
this.resolvedJavaType = (HotSpotResolvedObjectType) resolvedJavaType;
this.compiledMethods = new ArrayList<>();
this.representsStubs = false;
}
/**
* @return the ResolvedJavaType of this class
*/
! ResolvedJavaType getResolvedJavaType() {
return resolvedJavaType;
}
/**
* Get the list of methods which should be compiled.
*/
! ArrayList<ResolvedJavaMethod> getMethods() {
ArrayList<ResolvedJavaMethod> m = methods;
methods = null; // Free - it is not used after that.
return m;
}
/**
* Get the number of all AOT classes.
*/
! static int getClassesCount() {
return classesCount;
}
/**
* Get the number of methods which should be compiled.
*
* @return number of methods which should be compiled
*/
! int getMethodCount() {
return methods.size();
}
/**
* Add a method to the list of methods to be compiled.
*/
! void addMethod(ResolvedJavaMethod method) {
methods.add(method);
}
/**
* Returns if this class has methods which should be compiled.
*
* @return true if this class contains methods which should be compiled, false otherwise
*/
! boolean hasMethods() {
return !methods.isEmpty();
}
/**
* Add a method to the list of compiled methods. This method needs to be thread-safe.
*/
! synchronized boolean addCompiledMethod(CompiledMethodInfo cm) {
return compiledMethods.add(cm);
}
/**
* Return the array list of compiled class methods.
*
* @return array list of compiled methods
*/
! ArrayList<CompiledMethodInfo> getCompiledMethods() {
return compiledMethods;
}
/**
* Returns if this class has successfully compiled methods.
*
* @return true if methods were compiled, false otherwise
*/
! boolean hasCompiledMethods() {
return !compiledMethods.isEmpty();
}
/**
* Add a klass data.
*/
! synchronized static AOTKlassData addAOTKlassData(BinaryContainer binaryContainer, HotSpotResolvedObjectType type) {
String name = type.getName();
long fingerprint = type.getFingerprint();
AOTKlassData data = klassData.get(name);
if (data != null) {
assert data.getFingerprint() == fingerprint : "incorrect fingerprint data for klass: " + name;
*** 278,296 ****
klassData.put(name, data);
}
return data;
}
! public synchronized static AOTKlassData getAOTKlassData(String name) {
return klassData.get(name);
}
! public synchronized static AOTKlassData getAOTKlassData(HotSpotResolvedObjectType type) {
return getAOTKlassData(type.getName());
}
! public void addAOTKlassData(BinaryContainer binaryContainer) {
for (CompiledMethodInfo methodInfo : compiledMethods) {
// Record methods holder
methodInfo.addDependentKlassData(binaryContainer, resolvedJavaType);
// Record inlinee classes
ResolvedJavaMethod[] inlinees = methodInfo.getCompilationResult().getMethods();
--- 278,296 ----
klassData.put(name, data);
}
return data;
}
! synchronized static AOTKlassData getAOTKlassData(String name) {
return klassData.get(name);
}
! synchronized static AOTKlassData getAOTKlassData(HotSpotResolvedObjectType type) {
return getAOTKlassData(type.getName());
}
! void addAOTKlassData(BinaryContainer binaryContainer) {
for (CompiledMethodInfo methodInfo : compiledMethods) {
// Record methods holder
methodInfo.addDependentKlassData(binaryContainer, resolvedJavaType);
// Record inlinee classes
ResolvedJavaMethod[] inlinees = methodInfo.getCompilationResult().getMethods();
*** 307,332 ****
}
}
}
}
! public synchronized static 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;
assert assertsEnabled = true;
if (assertsEnabled) {
HotSpotResolvedObjectType s = type.getSuperclass();
if (s != null) {
! assert getAOTKlassData(s) != null : "fingerprint super " + s.getName() + " needed for " + type.getName();
}
for (HotSpotResolvedObjectType i : type.getInterfaces()) {
! assert getAOTKlassData(i) != null : "fingerprint super " + i.getName() + " needed for " + type.getName();
}
}
return old;
}
--- 307,333 ----
}
}
}
}
! synchronized static 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) {
HotSpotResolvedObjectType s = type.getSuperclass();
if (s != null) {
! assert getAOTKlassData(s) != null : "fingerprint for super " + s.getName() + " needed for " + type.getName();
}
for (HotSpotResolvedObjectType i : type.getInterfaces()) {
! assert getAOTKlassData(i) != null : "fingerprint for interface " + i.getName() + " needed for " + type.getName();
}
}
return old;
}
*** 343,356 ****
}
/*
* Put methods data to contained.
*/
! public void putMethodsData(BinaryContainer binaryContainer) {
ReadOnlyDataContainer container = binaryContainer.getMethodsOffsetsContainer();
int cntMethods = compiledMethods.size();
! int startMethods = binaryContainer.addMethodsCount(cntMethods, container);
for (CompiledMethodInfo methodInfo : compiledMethods) {
methodInfo.addMethodOffsets(binaryContainer, container);
}
String name = resolvedJavaType.getName();
AOTKlassData data = klassData.get(name);
--- 344,357 ----
}
/*
* Put methods data to contained.
*/
! void putMethodsData(BinaryContainer binaryContainer) {
ReadOnlyDataContainer container = binaryContainer.getMethodsOffsetsContainer();
int cntMethods = compiledMethods.size();
! int startMethods = BinaryContainer.addMethodsCount(cntMethods, container);
for (CompiledMethodInfo methodInfo : compiledMethods) {
methodInfo.addMethodOffsets(binaryContainer, container);
}
String name = resolvedJavaType.getName();
AOTKlassData data = klassData.get(name);
*** 359,380 ****
int cntDepMethods = data.dependentMethods.size();
assert cntDepMethods > 0 : "no dependent methods for compiled klass: " + name;
data.setCompiledMethodsOffset(startMethods);
}
! public static void putAOTKlassData(BinaryContainer binaryContainer) {
ReadOnlyDataContainer container = binaryContainer.getKlassesOffsetsContainer();
for (AOTKlassData data : klassData.values()) {
data.putAOTKlassData(binaryContainer, container);
}
}
! public boolean representsStubs() {
return representsStubs;
}
! public void clear() {
for (CompiledMethodInfo c : compiledMethods) {
c.clear();
}
this.compiledMethods = null;
this.methods = null;
--- 360,381 ----
int cntDepMethods = data.dependentMethods.size();
assert cntDepMethods > 0 : "no dependent methods for compiled klass: " + name;
data.setCompiledMethodsOffset(startMethods);
}
! static void putAOTKlassData(BinaryContainer binaryContainer) {
ReadOnlyDataContainer container = binaryContainer.getKlassesOffsetsContainer();
for (AOTKlassData data : klassData.values()) {
data.putAOTKlassData(binaryContainer, container);
}
}
! boolean representsStubs() {
return representsStubs;
}
! void clear() {
for (CompiledMethodInfo c : compiledMethods) {
c.clear();
}
this.compiledMethods = null;
this.methods = null;
src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java
Index
Unified diffs
Context diffs
Sdiffs
Frames
Patch
New
Old
Previous File
Next File