use of com.oracle.svm.hosted.meta.HostedField in project graal by oracle.
the class NativeImageGenerator method printTypes.
private void printTypes() {
for (HostedType type : hUniverse.getTypes()) {
System.out.format("%8d %s ", type.getTypeID(), type.toJavaName(true));
if (type.getSuperclass() != null) {
System.out.format("extends %d %s ", type.getSuperclass().getTypeID(), type.getSuperclass().toJavaName(false));
}
if (type.getInterfaces().length > 0) {
System.out.print("implements ");
String sep = "";
for (HostedInterface interf : type.getInterfaces()) {
System.out.format("%s%d %s", sep, interf.getTypeID(), interf.toJavaName(false));
sep = ", ";
}
System.out.print(" ");
}
if (type.getWrapped().isInstantiated()) {
System.out.print("instantiated ");
}
if (type.getWrapped().isInTypeCheck()) {
System.out.print("inTypeCheck ");
}
System.out.format("assignableFrom %s ", matchesToString(type.getAssignableFromMatches()));
System.out.format("instanceOf typeID %d, # %d ", type.getInstanceOfFromTypeID(), type.getInstanceOfNumTypeIDs());
// if (type.findLeafConcreteSubtype() != null) {
// System.out.format("unique %d %s ", type.findLeafConcreteSubtype().getTypeID(),
// type.findLeafConcreteSubtype().toJavaName(false));
// }
int le = type.getHub().getLayoutEncoding();
if (LayoutEncoding.isPrimitive(le)) {
System.out.print("primitive ");
} else if (LayoutEncoding.isInterface(le)) {
System.out.print("interface ");
} else if (LayoutEncoding.isAbstract(le)) {
System.out.print("abstract ");
} else if (LayoutEncoding.isInstance(le)) {
System.out.format("instance size %d ", LayoutEncoding.getInstanceSize(le).rawValue());
} else if (LayoutEncoding.isObjectArray(le)) {
System.out.format("object array base %d shift %d scale %d ", LayoutEncoding.getArrayBaseOffset(le).rawValue(), LayoutEncoding.getArrayIndexShift(le), LayoutEncoding.getArrayIndexScale(le));
} else if (LayoutEncoding.isPrimitiveArray(le)) {
System.out.format("primitive array base %d shift %d scale %d ", LayoutEncoding.getArrayBaseOffset(le).rawValue(), LayoutEncoding.getArrayIndexShift(le), LayoutEncoding.getArrayIndexScale(le));
} else {
throw VMError.shouldNotReachHere();
}
System.out.println();
for (HostedType sub : type.getSubTypes()) {
System.out.format(" s %d %s\n", sub.getTypeID(), sub.toJavaName(false));
}
if (type.isInterface()) {
for (HostedMethod method : hUniverse.getMethods()) {
if (method.getDeclaringClass() == type) {
printMethod(method, -1);
}
}
} else if (type.isInstanceClass()) {
HostedField[] fields = type.getInstanceFields(false);
fields = Arrays.copyOf(fields, fields.length);
Arrays.sort(fields, Comparator.comparing(HostedField::toString));
for (HostedField field : fields) {
System.out.println(" f " + field.getLocation() + ": " + field.format("%T %n"));
}
HostedMethod[] vtable = type.getVTable();
for (int i = 0; i < vtable.length; i++) {
if (vtable[i] != null) {
printMethod(vtable[i], i);
}
}
for (HostedMethod method : hUniverse.getMethods()) {
if (method.getDeclaringClass() == type && !method.hasVTableIndex()) {
printMethod(method, -1);
}
}
}
}
}
use of com.oracle.svm.hosted.meta.HostedField in project graal by oracle.
the class GraalObjectReplacer method updateSubstrateDataAfterCompilation.
/**
* Updates all relevant data from universe building. Object replacement is done during analysis.
* Therefore all substrate VM related data has to be updated after building the substrate
* universe.
*/
@SuppressWarnings("try")
public void updateSubstrateDataAfterCompilation(HostedUniverse hUniverse) {
for (Map.Entry<AnalysisType, SubstrateType> entry : types.entrySet()) {
AnalysisType aType = entry.getKey();
SubstrateType sType = entry.getValue();
if (!hUniverse.contains(aType)) {
continue;
}
HostedType hType = hUniverse.lookup(aType);
DynamicHub uniqueImplementation = null;
if (hType.getUniqueConcreteImplementation() != null) {
uniqueImplementation = hType.getUniqueConcreteImplementation().getHub();
}
sType.setTypeCheckData(hType.getInstanceOfFromTypeID(), hType.getInstanceOfNumTypeIDs(), uniqueImplementation);
SubstrateField[] originalFields = sType.getInstanceFields(false);
if (originalFields != null) {
/*
* What we do here is just a reordering of the instance fields array. The fields
* array already contains all the fields, but in the order of the AnalysisType. As
* the UniverseBuilder reorders the fields, we re-construct the fields array in the
* order of the HostedType. The correct order is essential for materialization
* during deoptimization.
*/
SubstrateField[] newFields = createFields(hType);
sType.setInstanceFields(newFields);
}
}
for (Map.Entry<AnalysisField, SubstrateField> entry : fields.entrySet()) {
AnalysisField aField = entry.getKey();
SubstrateField sField = entry.getValue();
HostedField hField = hUniverse.lookup(aField);
sField.setSubstrateData(hField.getLocation(), hField.isAccessed(), hField.isWritten(), hField.getConstantValue());
}
}
use of com.oracle.svm.hosted.meta.HostedField in project graal by oracle.
the class GraalObjectReplacer method createField.
public SubstrateField createField(ResolvedJavaField original) {
AnalysisField aField;
if (original instanceof AnalysisField) {
aField = (AnalysisField) original;
} else {
aField = ((HostedField) original).wrapped;
}
SubstrateField sField = fields.get(aField);
if (sField == null) {
assert !(original instanceof HostedField) : "too late to create new field";
int modifiers = aField.getModifiers();
if (ReadableJavaField.injectFinalForRuntimeCompilation(aField.wrapped)) {
modifiers = modifiers | Modifier.FINAL;
}
sField = new SubstrateField(aMetaAccess, aField, modifiers, stringTable);
fields.put(aField, sField);
sField.setLinks(createType(aField.getType()), createType(aField.getDeclaringClass()));
/*
* Annotations are updated in every analysis iteration, but this is a starting point. It
* also ensures that all types used by annotations are created eagerly.
*/
sField.setAnnotationsEncoding(Inflation.encodeAnnotations(aMetaAccess, aField.getAnnotations(), null));
}
return sField;
}
Aggregations