use of com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo in project graal by oracle.
the class CollectingObjectReferenceVisitor method verifyVirtualObject.
private void verifyVirtualObject(CompilationResult compilation, VirtualObject expectedObject, ValueInfo[] actualObject, FrameInfoQueryResult actualFrame, BitSet visitedVirtualObjects) {
if (visitedVirtualObjects.get(expectedObject.getId())) {
return;
}
visitedVirtualObjects.set(expectedObject.getId());
ObjectLayout objectLayout = ConfigurationValues.getObjectLayout();
SharedType expectedType = (SharedType) expectedObject.getType();
if (expectedType.isArray()) {
JavaKind kind = expectedType.getComponentType().getJavaKind();
int expectedLength = 0;
for (int i = 0; i < expectedObject.getValues().length; i++) {
JavaValue expectedValue = expectedObject.getValues()[i];
UnsignedWord expectedOffset = WordFactory.unsigned(objectLayout.getArrayElementOffset(expectedType.getComponentType().getJavaKind(), expectedLength));
ValueInfo actualValue = findActualArrayElement(actualObject, expectedOffset);
verifyValue(compilation, expectedValue, actualValue, actualFrame, visitedVirtualObjects);
JavaKind valueKind = expectedObject.getSlotKind(i);
if (objectLayout.sizeInBytes(kind) == 4 && objectLayout.sizeInBytes(valueKind) == 8) {
/*
* Truffle uses arrays in a non-standard way: it declares an int[] array and
* uses it to also store long and double values. These values span two array
* elements - so we have to add 2 to the length.
*/
expectedLength += 2;
} else {
expectedLength++;
}
}
int actualLength = actualObject[1].value.asInt();
assert expectedLength == actualLength;
} else {
SharedField[] expectedFields = (SharedField[]) expectedType.getInstanceFields(true);
int fieldIdx = 0;
int valueIdx = 0;
while (valueIdx < expectedObject.getValues().length) {
SharedField expectedField = expectedFields[fieldIdx];
fieldIdx += 1;
JavaValue expectedValue = expectedObject.getValues()[valueIdx];
JavaKind valueKind = expectedObject.getSlotKind(valueIdx);
valueIdx += 1;
JavaKind kind = expectedField.getStorageKind();
if (objectLayout.sizeInBytes(kind) == 4 && objectLayout.sizeInBytes(valueKind) == 8) {
/*
* Truffle uses fields in a non-standard way: it declares a couple of
* (consecutive) int fields, and uses them to also store long and double values.
* These values span two fields - so we have to ignore a field.
*/
fieldIdx++;
}
UnsignedWord expectedOffset = WordFactory.unsigned(expectedField.getLocation());
ValueInfo actualValue = findActualField(actualObject, expectedOffset);
verifyValue(compilation, expectedValue, actualValue, actualFrame, visitedVirtualObjects);
}
}
}
use of com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo in project graal by oracle.
the class CollectingObjectReferenceVisitor method findActualValue.
private static ValueInfo findActualValue(ValueInfo[] actualObject, UnsignedWord expectedOffset, ObjectLayout objectLayout, UnsignedWord startOffset, int startIdx) {
UnsignedWord curOffset = startOffset;
int curIdx = startIdx;
while (curOffset.notEqual(expectedOffset)) {
ValueInfo value = actualObject[curIdx];
curOffset = curOffset.add(objectLayout.sizeInBytes(value.getKind(), value.isCompressedReference));
curIdx++;
}
assert curOffset.equal(expectedOffset);
return actualObject[curIdx];
}
use of com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo in project graal by oracle.
the class FrameInfoDecoder method decodeValues.
private static ValueInfo[] decodeValues(ValueInfoAllocator valueInfoAllocator, int numValues, TypeReader readBuffer, Object[] frameInfoObjectConstants) {
ValueInfo[] valueInfos = valueInfoAllocator.newValueInfoArray(numValues);
for (int i = 0; i < numValues; i++) {
ValueInfo valueInfo = valueInfoAllocator.newValueInfo();
if (valueInfos != null) {
valueInfos[i] = valueInfo;
}
int flags = readBuffer.getU1();
ValueType valueType = extractType(flags);
if (valueInfo != null) {
valueInfo.type = valueType;
valueInfo.kind = extractKind(flags);
valueInfo.isCompressedReference = extractIsCompressedReference(flags);
}
if (valueType.hasData) {
long valueInfoData = readBuffer.getSV();
if (valueInfo != null) {
valueInfo.data = valueInfoData;
}
}
valueInfoAllocator.decodeConstant(valueInfo, frameInfoObjectConstants);
}
return valueInfos;
}
use of com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo in project graal by oracle.
the class FrameInfoVerifier method addDebugInfo.
protected FrameData addDebugInfo(ResolvedJavaMethod method, Infopoint infopoint, int totalFrameSize) {
final boolean shouldIncludeMethod = customization.shouldInclude(method, infopoint);
final boolean encodeSourceReferences = FrameInfoDecoder.encodeSourceReferences();
if (!shouldIncludeMethod && !encodeSourceReferences) {
return null;
}
final DebugInfo debugInfo = infopoint.debugInfo;
final FrameData data = new FrameData();
data.debugInfo = debugInfo;
data.totalFrameSize = totalFrameSize;
data.virtualObjects = new ValueInfo[countVirtualObjects(debugInfo)][];
data.frame = addFrame(data, debugInfo.frame(), customization.isDeoptEntry(method, infopoint), shouldIncludeMethod);
final boolean encodeDebugNames = shouldIncludeMethod && FrameInfoDecoder.encodeDebugNames();
if (encodeDebugNames || FrameInfoDecoder.encodeSourceReferences()) {
BytecodeFrame bytecodeFrame = data.debugInfo.frame();
for (FrameInfoQueryResult resultFrame = data.frame; bytecodeFrame != null; resultFrame = resultFrame.caller) {
customization.fillDebugNames(bytecodeFrame, resultFrame, encodeDebugNames && shouldIncludeMethod);
bytecodeFrame = bytecodeFrame.caller();
}
for (FrameInfoQueryResult cur = data.frame; cur != null; cur = cur.caller) {
sourceClassNames.addObject(cur.sourceClassName);
sourceMethodNames.addObject(cur.sourceMethodName);
sourceFileNames.addObject(cur.sourceFileName);
if (encodeDebugNames) {
for (ValueInfo valueInfo : cur.valueInfos) {
if (valueInfo.name == null) {
valueInfo.name = "";
}
names.addObject(valueInfo.name);
}
}
}
}
allDebugInfos.add(data);
return data;
}
use of com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo in project graal by oracle.
the class FrameInfoVerifier method makeValueInfo.
private ValueInfo makeValueInfo(FrameData data, JavaKind kind, JavaValue value) {
ValueInfo result = new ValueInfo();
result.kind = kind;
if (ValueUtil.isIllegalJavaValue(value)) {
result.type = ValueType.Illegal;
assert result.kind == JavaKind.Illegal;
} else if (value instanceof StackSlot) {
StackSlot stackSlot = (StackSlot) value;
result.type = ValueType.StackSlot;
result.data = stackSlot.getOffset(data.totalFrameSize);
result.isCompressedReference = isCompressedReference(stackSlot);
ImageSingletons.lookup(Counters.class).stackValueCount.inc();
} else if (value instanceof JavaConstant) {
JavaConstant constant = (JavaConstant) value;
result.value = constant;
if (constant.isDefaultForKind()) {
result.type = ValueType.DefaultConstant;
} else {
result.type = ValueType.Constant;
if (constant.getJavaKind() == JavaKind.Object) {
/*
* Collect all Object constants, which will be stored in a separate Object[]
* array so that the GC can visit them.
*/
objectConstants.addObject(constant);
}
}
ImageSingletons.lookup(Counters.class).constantValueCount.inc();
} else if (ValueUtil.isVirtualObject(value)) {
VirtualObject virtualObject = (VirtualObject) value;
result.type = ValueType.VirtualObject;
result.data = virtualObject.getId();
makeVirtualObject(data, virtualObject);
} else {
throw shouldNotReachHere();
}
return result;
}
Aggregations