use of com.oracle.svm.core.meta.SharedMethod in project graal by oracle.
the class FrameInfoVerifier method addFrame.
private FrameInfoQueryResult addFrame(FrameData data, BytecodeFrame frame, boolean isDeoptEntry, boolean needLocalValues) {
FrameInfoQueryResult result = new FrameInfoQueryResult();
if (frame.caller() != null) {
assert !isDeoptEntry : "Deoptimization entry point information for caller frames is not encoded";
result.caller = addFrame(data, frame.caller(), false, needLocalValues);
}
result.virtualObjects = data.virtualObjects;
result.encodedBci = encodeBci(frame.getBCI(), frame.duringCall, frame.rethrowException);
result.isDeoptEntry = isDeoptEntry;
result.needLocalValues = needLocalValues;
SharedMethod method = (SharedMethod) frame.getMethod();
if (customization.shouldStoreMethod()) {
result.deoptMethod = method;
objectConstants.addObject(SubstrateObjectConstant.forObject(method));
}
result.deoptMethodOffset = method.getDeoptOffsetInImage();
result.numLocals = frame.numLocals;
result.numStack = frame.numStack;
result.numLocks = frame.numLocks;
ValueInfo[] valueInfos = null;
if (needLocalValues) {
JavaValue[] values = frame.values;
int numValues = 0;
for (int i = values.length; --i >= 0; ) {
if (!ValueUtil.isIllegalJavaValue(values[i])) {
// Found the last non-illegal value, i.e., the last value we have to encode.
numValues = i + 1;
break;
}
}
valueInfos = new ValueInfo[numValues];
for (int i = 0; i < numValues; i++) {
valueInfos[i] = makeValueInfo(data, getFrameValueKind(frame, i), values[i]);
}
}
result.valueInfos = valueInfos;
ImageSingletons.lookup(Counters.class).frameCount.inc();
return result;
}
use of com.oracle.svm.core.meta.SharedMethod in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerKnownIntrinsicsPlugins.
private static void registerKnownIntrinsicsPlugins(InvocationPlugins plugins, boolean analysis) {
Registration r = new Registration(plugins, KnownIntrinsics.class);
r.register0("heapBase", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.addPush(JavaKind.Object, ReadRegisterFixedNode.forHeapBase());
return true;
}
});
r.register1("readArrayLength", Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode array) {
b.addPush(JavaKind.Int, new ArrayLengthNode(array));
return true;
}
});
r.register1("readHub", Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
ValueNode nonNullObject = b.nullCheckedValue(object);
b.addPush(JavaKind.Object, new LoadHubNode(b.getStampProvider(), nonNullObject));
return true;
}
});
r.register3("formatObject", Pointer.class, Class.class, boolean.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode memory, ValueNode hub, ValueNode rememberedSet) {
b.addPush(JavaKind.Object, new FormatObjectNode(memory, hub, rememberedSet));
return true;
}
});
r.register5("formatArray", Pointer.class, Class.class, int.class, boolean.class, boolean.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode memory, ValueNode hub, ValueNode length, ValueNode rememberedSet, ValueNode unaligned) {
b.addPush(JavaKind.Object, new FormatArrayNode(memory, hub, length, rememberedSet, unaligned));
return true;
}
});
r.register2("unsafeCast", Object.class, Class.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object, ValueNode toTypeNode) {
/*
* We need to make sure that the updated type information does not flow up, because
* it can depend on any condition before (and we do not know which condition, so we
* cannot anchor at a particular block).
*/
ResolvedJavaType toType = typeValue(b.getConstantReflection(), b, targetMethod, toTypeNode, "toType");
TypeReference toTypeRef = TypeReference.createTrustedWithoutAssumptions(toType);
b.addPush(JavaKind.Object, new FixedValueAnchorNode(object, StampFactory.object(toTypeRef)));
return true;
}
});
r.register1("nonNullPointer", Pointer.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
b.addPush(JavaKind.Object, new PiNode(object, nonZeroWord()));
return true;
}
});
r.register0("readStackPointer", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.addPush(JavaKind.Object, new ReadStackPointerNode());
return true;
}
});
r.register1("writeStackPointer", Pointer.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.add(new WriteStackPointerNode(value));
return true;
}
});
r.register0("readInstructionPointer", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.addPush(JavaKind.Object, new ReadInstructionPointerNode());
return true;
}
});
r.register0("readCallerStackPointer", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.addPush(JavaKind.Object, new ReadCallerStackPointerNode());
return true;
}
});
r.register0("readReturnAddress", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.addPush(JavaKind.Object, new ReadReturnAddressNode());
return true;
}
});
r.register3("farReturn", Object.class, Pointer.class, CodePointer.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode result, ValueNode sp, ValueNode ip) {
b.add(new FarReturnNode(result, sp, ip));
return true;
}
});
r.register0("testDeoptimize", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.add(new TestDeoptimizeNode());
return true;
}
});
r.register0("isDeoptimizationTarget", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
if (b.getGraph().method() instanceof SharedMethod) {
SharedMethod method = (SharedMethod) b.getGraph().method();
if (method.isDeoptTarget()) {
b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(true));
} else {
b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(false));
}
} else {
// In analysis the value is always true.
b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(true));
}
return true;
}
});
r.register2("convertUnknownValue", Object.class, Class.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object, ValueNode typeNode) {
ResolvedJavaType type = typeValue(b.getConstantReflection(), b, targetMethod, typeNode, "type");
TypeReference typeRef = TypeReference.createTrustedWithoutAssumptions(type);
Stamp stamp = StampFactory.object(typeRef);
if (analysis) {
b.addPush(JavaKind.Object, new ConvertUnknownValueNode(object, stamp));
} else {
b.addPush(JavaKind.Object, PiNode.create(object, stamp));
}
return true;
}
});
}
use of com.oracle.svm.core.meta.SharedMethod in project graal by oracle.
the class SubstrateAMD64Backend method newLIRGenerationResult.
@Override
public LIRGenerationResult newLIRGenerationResult(CompilationIdentifier compilationId, LIR lir, FrameMapBuilder frameMapBuilder, StructuredGraph graph, Object stub) {
SharedMethod method = (SharedMethod) graph.method();
CallingConvention callingConvention = CodeUtil.getCallingConvention(getCodeCache(), method.isEntryPoint() ? SubstrateCallingConventionType.NativeCallee : SubstrateCallingConventionType.JavaCallee, method, this);
return new SubstrateLIRGenerationResult(compilationId, lir, frameMapBuilder, callingConvention, method);
}
use of com.oracle.svm.core.meta.SharedMethod in project graal by oracle.
the class SubstrateAMD64Backend method createMoveFactory.
protected AMD64MoveFactoryBase createMoveFactory(LIRGenerationResult lirGenRes, BackupSlotProvider backupSlotProvider) {
SharedMethod method = ((SubstrateLIRGenerationResult) lirGenRes).getMethod();
SubstrateAMD64RegisterConfig registerConfig = (SubstrateAMD64RegisterConfig) lirGenRes.getRegisterConfig();
return new SubstrateAMD64MoveFactory(backupSlotProvider, method, createLirKindTool(), registerConfig);
}
use of com.oracle.svm.core.meta.SharedMethod in project graal by oracle.
the class MethodSafepointInsertionPhase method run.
@Override
protected void run(StructuredGraph graph) {
if (graph.method().getAnnotation(Uninterruptible.class) != null) {
/*
* If a method is annotated with {@link Uninterruptible}, then I do not want a test for
* a safepoint at the return.
*/
return;
}
if (graph.method().getAnnotation(CFunction.class) != null) {
/*
* If a method transfers from Java to C, then the return transition (if any) contains
* the safepoint test and one is not needed at the return of the transferring method.
*/
return;
}
if (((SharedMethod) graph.method()).isEntryPoint()) {
/*
* If a method is transferring from C to Java, then no safepoint test is needed at the
* return of the transferring method.
*/
return;
}
for (ReturnNode returnNode : graph.getNodes(ReturnNode.TYPE)) {
SafepointNode safepointNode = graph.add(new SafepointNode());
graph.addBeforeFixed(returnNode, safepointNode);
}
}
Aggregations