use of jdk.vm.ci.code.VirtualObject in project graal by oracle.
the class FrameInfoVerifier method countVirtualObjects.
private static void countVirtualObjects(JavaValue[] values, BitSet visitedVirtualObjects) {
for (JavaValue value : values) {
if (value instanceof VirtualObject) {
VirtualObject virtualObject = (VirtualObject) value;
if (!visitedVirtualObjects.get(virtualObject.getId())) {
visitedVirtualObjects.set(virtualObject.getId());
countVirtualObjects(virtualObject.getValues(), visitedVirtualObjects);
}
}
}
}
use of jdk.vm.ci.code.VirtualObject in project graal by oracle.
the class JVMCIInfopointErrorTest method testUnexpectedVirtualObject.
@Test(expected = JVMCIError.class)
public void testUnexpectedVirtualObject() {
ResolvedJavaType obj = getMetaAccess().lookupJavaType(Object.class);
test((tool, state, safepoint) -> {
VirtualObject o = VirtualObject.get(obj, 0);
o.setValues(new JavaValue[0], new JavaKind[0]);
LIRFrameState newState = modifyTopFrame(state, new VirtualObject[] { o }, new JavaValue[] { o }, new JavaKind[] { JavaKind.Int }, 1, 0, 0);
safepoint.accept(newState);
});
}
use of jdk.vm.ci.code.VirtualObject 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;
}
use of jdk.vm.ci.code.VirtualObject in project graal by oracle.
the class DebugInfoBuilder method toJavaValue.
protected JavaValue toJavaValue(ValueNode value) {
try {
if (value instanceof VirtualObjectNode) {
VirtualObjectNode obj = (VirtualObjectNode) value;
EscapeObjectState state = objectStates.get(obj);
if (state == null && obj.entryCount() > 0) {
// null states occur for objects with 0 fields
throw new GraalError("no mapping found for virtual object %s", obj);
}
if (state instanceof MaterializedObjectState) {
return toJavaValue(((MaterializedObjectState) state).materializedValue());
} else {
assert obj.entryCount() == 0 || state instanceof VirtualObjectState;
VirtualObject vobject = virtualObjects.get(obj);
if (vobject == null) {
vobject = VirtualObject.get(obj.type(), virtualObjects.size());
virtualObjects.put(obj, vobject);
pendingVirtualObjects.add(obj);
}
STATE_VIRTUAL_OBJECTS.increment(debug);
return vobject;
}
} else {
// Remove proxies from constants so the constant can be directly embedded.
ValueNode unproxied = GraphUtil.unproxify(value);
if (unproxied instanceof ConstantNode) {
STATE_CONSTANTS.increment(debug);
return unproxied.asJavaConstant();
} else if (value != null) {
STATE_VARIABLES.increment(debug);
Value operand = nodeValueMap.operand(value);
if (operand instanceof ConstantValue && ((ConstantValue) operand).isJavaConstant()) {
return ((ConstantValue) operand).getJavaConstant();
} else {
assert operand instanceof Variable : operand + " for " + value;
return (JavaValue) operand;
}
} else {
// return a dummy value because real value not needed
STATE_ILLEGALS.increment(debug);
return Value.ILLEGAL;
}
}
} catch (GraalError e) {
throw e.addContext("toValue: ", value);
}
}
use of jdk.vm.ci.code.VirtualObject in project graal by oracle.
the class CompilationPrinter method debugInfoToString.
/**
* Formats given debug info as a multi line string.
*/
protected String debugInfoToString(BytecodePosition codePos, ReferenceMap refMap, IndexedValueMap liveBasePointers, RegisterSaveLayout calleeSaveInfo) {
StringBuilder sb = new StringBuilder();
if (refMap != null) {
sb.append("reference-map: ");
sb.append(refMap.toString());
sb.append("\n");
}
if (liveBasePointers != null) {
sb.append("live-base-pointers: ");
sb.append(liveBasePointers);
sb.append("\n");
}
if (calleeSaveInfo != null) {
sb.append("callee-save-info:");
for (Map.Entry<Register, Integer> e : calleeSaveInfo.registersToSlots(true).entrySet()) {
sb.append(" " + e.getKey() + " -> s" + e.getValue());
}
sb.append("\n");
}
if (codePos != null) {
BytecodePosition curCodePos = codePos;
List<VirtualObject> virtualObjects = new ArrayList<>();
do {
sb.append(MetaUtil.toLocation(curCodePos.getMethod(), curCodePos.getBCI()));
sb.append('\n');
if (curCodePos instanceof BytecodeFrame) {
BytecodeFrame frame = (BytecodeFrame) curCodePos;
if (frame.numStack > 0) {
sb.append("stack: ");
for (int i = 0; i < frame.numStack; i++) {
sb.append(valueToString(frame.getStackValue(i), virtualObjects)).append(' ');
}
sb.append("\n");
}
sb.append("locals: ");
for (int i = 0; i < frame.numLocals; i++) {
sb.append(valueToString(frame.getLocalValue(i), virtualObjects)).append(' ');
}
sb.append("\n");
if (frame.numLocks > 0) {
sb.append("locks: ");
for (int i = 0; i < frame.numLocks; ++i) {
sb.append(valueToString(frame.getLockValue(i), virtualObjects)).append(' ');
}
sb.append("\n");
}
}
curCodePos = curCodePos.getCaller();
} while (curCodePos != null);
for (int i = 0; i < virtualObjects.size(); i++) {
VirtualObject obj = virtualObjects.get(i);
sb.append(obj).append(" ").append(obj.getType().getName()).append(" ");
for (int j = 0; j < obj.getValues().length; j++) {
sb.append(valueToString(obj.getValues()[j], virtualObjects)).append(' ');
}
sb.append("\n");
}
}
return sb.toString();
}
Aggregations