use of com.oracle.svm.core.classinitialization.EnsureClassInitializedNode in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerUnsafePlugins.
private static void registerUnsafePlugins(MetaAccessProvider metaAccess, Registration r, SnippetReflectionProvider snippetReflection, ParsingReason reason, boolean isSunMiscUnsafe) {
r.register(new RequiredInvocationPlugin("staticFieldOffset", Receiver.class, Field.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode fieldNode) {
if (fieldNode.isConstant()) {
Field targetField = snippetReflection.asObject(Field.class, fieldNode.asJavaConstant());
return processFieldOffset(b, targetField, reason, metaAccess, isSunMiscUnsafe);
}
return false;
}
});
r.register(new RequiredInvocationPlugin("staticFieldBase", Receiver.class, Field.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode fieldNode) {
if (fieldNode.isConstant()) {
Field targetField = snippetReflection.asObject(Field.class, fieldNode.asJavaConstant());
return processStaticFieldBase(b, targetField, isSunMiscUnsafe);
}
return false;
}
});
r.register(new RequiredInvocationPlugin("objectFieldOffset", Receiver.class, Field.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode fieldNode) {
if (fieldNode.isConstant()) {
Field targetField = snippetReflection.asObject(Field.class, fieldNode.asJavaConstant());
return processFieldOffset(b, targetField, reason, metaAccess, isSunMiscUnsafe);
}
return false;
}
});
r.register(new RequiredInvocationPlugin("allocateInstance", Receiver.class, Class.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode clazz) {
/* Emits a null-check for the otherwise unused receiver. */
unsafe.get();
/*
* The allocated class must be null-checked already before the class initialization
* check.
*/
ValueNode clazzNonNull = b.nullCheckedValue(clazz, DeoptimizationAction.None);
b.add(new EnsureClassInitializedNode(clazzNonNull));
DynamicNewInstanceNode.createAndPush(b, clazzNonNull);
return true;
}
});
}
use of com.oracle.svm.core.classinitialization.EnsureClassInitializedNode in project graal by oracle.
the class HostedGraphKit method emitEnsureInitializedCall.
public void emitEnsureInitializedCall(ResolvedJavaType type) {
if (EnsureClassInitializedNode.needsRuntimeInitialization(graph.method().getDeclaringClass(), type)) {
ValueNode hub = createConstant(getConstantReflection().asJavaClass(type), JavaKind.Object);
appendWithUnwind(new EnsureClassInitializedNode(hub));
}
}
use of com.oracle.svm.core.classinitialization.EnsureClassInitializedNode in project graal by oracle.
the class SubstrateClassInitializationPlugin method emitEnsureClassInitialized.
private static void emitEnsureClassInitialized(GraphBuilderContext builder, JavaConstant hubConstant, FrameState frameState) {
ValueNode hub = ConstantNode.forConstant(hubConstant, builder.getMetaAccess(), builder.getGraph());
EnsureClassInitializedNode node = new EnsureClassInitializedNode(hub, frameState);
builder.add(node);
}
Aggregations