use of org.graalvm.compiler.replacements.StandardGraphBuilderPlugins.StringLatin1IndexOfCharPlugin in project graal by oracle.
the class AArch64GraphBuilderPlugins method registerStringLatin1Plugins.
private static void registerStringLatin1Plugins(InvocationPlugins plugins, Replacements replacements) {
Registration r = new Registration(plugins, "java.lang.StringLatin1", replacements);
r.setAllowOverwrite(true);
r.register(new ArrayCompareToPlugin(JavaKind.Byte, JavaKind.Byte, "compareTo", byte[].class, byte[].class));
r.register(new ArrayCompareToPlugin(JavaKind.Byte, JavaKind.Char, "compareToUTF16", byte[].class, byte[].class));
r.register(new SnippetSubstitutionInvocationPlugin<>(StringLatin1Snippets.Templates.class, "indexOf", byte[].class, int.class, byte[].class, int.class, int.class) {
@Override
public SnippetTemplate.SnippetInfo getSnippet(StringLatin1Snippets.Templates templates) {
return templates.indexOf;
}
});
r.register(new StringLatin1IndexOfCharPlugin());
}
use of org.graalvm.compiler.replacements.StandardGraphBuilderPlugins.StringLatin1IndexOfCharPlugin in project graal by oracle.
the class AMD64GraphBuilderPlugins method registerStringLatin1Plugins.
private static void registerStringLatin1Plugins(InvocationPlugins plugins, Replacements replacements) {
Registration r = new Registration(plugins, "java.lang.StringLatin1", replacements);
r.setAllowOverwrite(true);
r.register(new ArrayCompareToPlugin(JavaKind.Byte, JavaKind.Byte, "compareTo", byte[].class, byte[].class));
r.register(new ArrayCompareToPlugin(JavaKind.Byte, JavaKind.Char, "compareToUTF16", byte[].class, byte[].class));
r.register(new InvocationPlugin("inflate", byte[].class, int.class, byte[].class, int.class, int.class) {
@SuppressWarnings("try")
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode src, ValueNode srcIndex, ValueNode dest, ValueNode destIndex, ValueNode len) {
// @formatter:on
try (InvocationPluginHelper helper = new InvocationPluginHelper(b, targetMethod)) {
helper.intrinsicRangeCheck(len, Condition.LT, ConstantNode.forInt(0));
helper.intrinsicRangeCheck(srcIndex, Condition.LT, ConstantNode.forInt(0));
ValueNode srcLength = helper.length(b.nullCheckedValue(src));
helper.intrinsicRangeCheck(helper.add(srcIndex, len), Condition.GT, srcLength);
ValueNode scaledDestIndex = helper.scale(destIndex, JavaKind.Char);
helper.intrinsicRangeCheck(scaledDestIndex, Condition.LT, ConstantNode.forInt(0));
ValueNode end = helper.add(scaledDestIndex, helper.scale(len, JavaKind.Char));
ValueNode destLength = helper.length(b.nullCheckedValue(dest));
helper.intrinsicRangeCheck(end, Condition.GT, destLength);
ValueNode srcPointer = helper.arrayElementPointer(src, JavaKind.Byte, srcIndex);
ValueNode destPointer = helper.arrayElementPointer(dest, JavaKind.Byte, scaledDestIndex);
b.add(new AMD64StringLatin1InflateNode(srcPointer, destPointer, len, JavaKind.Byte));
}
return true;
}
});
r.register(new InvocationPlugin("inflate", byte[].class, int.class, char[].class, int.class, int.class) {
@SuppressWarnings("try")
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode src, ValueNode srcIndex, ValueNode dest, ValueNode destIndex, ValueNode len) {
// @formatter:on
try (InvocationPluginHelper helper = new InvocationPluginHelper(b, targetMethod)) {
helper.intrinsicRangeCheck(len, Condition.LT, ConstantNode.forInt(0));
helper.intrinsicRangeCheck(srcIndex, Condition.LT, ConstantNode.forInt(0));
ValueNode srcLength = helper.length(b.nullCheckedValue(src));
helper.intrinsicRangeCheck(helper.add(srcIndex, len), Condition.GT, srcLength);
helper.intrinsicRangeCheck(destIndex, Condition.LT, ConstantNode.forInt(0));
ValueNode end = helper.add(destIndex, len);
ValueNode destLength = helper.length(b.nullCheckedValue(dest));
helper.intrinsicRangeCheck(end, Condition.GT, destLength);
ValueNode srcPointer = helper.arrayElementPointer(src, JavaKind.Byte, srcIndex);
ValueNode destPointer = helper.arrayElementPointer(dest, JavaKind.Char, destIndex);
b.add(new AMD64StringLatin1InflateNode(srcPointer, destPointer, len, JavaKind.Char));
}
return true;
}
});
r.register(new SnippetSubstitutionInvocationPlugin<>(StringLatin1Snippets.Templates.class, "indexOf", byte[].class, int.class, byte[].class, int.class, int.class) {
@Override
public SnippetTemplate.SnippetInfo getSnippet(StringLatin1Snippets.Templates templates) {
return templates.indexOf;
}
});
r.register(new StringLatin1IndexOfCharPlugin());
}
Aggregations