|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
27 | 27 | import java.util.ArrayList;
|
28 | 28 |
|
29 | 29 | import jdk.graal.compiler.core.test.GraalCompilerTest;
|
| 30 | +import jdk.graal.compiler.graph.Node; |
| 31 | +import jdk.graal.compiler.nodes.StructuredGraph; |
| 32 | +import jdk.graal.compiler.nodes.ValueNode; |
| 33 | +import jdk.graal.compiler.nodes.graphbuilderconf.GraphBuilderContext; |
| 34 | +import jdk.graal.compiler.nodes.graphbuilderconf.InlineInvokePlugin; |
30 | 35 | import jdk.graal.compiler.nodes.graphbuilderconf.InvocationPlugins;
|
| 36 | +import jdk.graal.compiler.replacements.nodes.ArrayIndexOfNode; |
31 | 37 | import jdk.graal.compiler.truffle.substitutions.TruffleInvocationPlugins;
|
| 38 | +import jdk.graal.compiler.truffle.test.strings.TStringTest; |
| 39 | +import jdk.vm.ci.meta.ResolvedJavaMethod; |
| 40 | +import org.junit.Assert; |
32 | 41 | import org.junit.Test;
|
33 | 42 | import org.junit.runner.RunWith;
|
34 | 43 | import org.junit.runners.Parameterized;
|
@@ -134,6 +143,26 @@ public static int indexOfByteArray(byte[] haystack, int fromIndex, int maxIndex,
|
134 | 143 | return ArrayUtils.indexOf(haystack, fromIndex, maxIndex, needle);
|
135 | 144 | }
|
136 | 145 |
|
| 146 | + @Override |
| 147 | + protected void checkLowTierGraph(StructuredGraph graph) { |
| 148 | + if (TStringTest.isSupportedArchitecture(getArchitecture())) { |
| 149 | + for (Node node : graph.getNodes()) { |
| 150 | + if (node instanceof ArrayIndexOfNode) { |
| 151 | + return; |
| 152 | + } |
| 153 | + } |
| 154 | + Assert.fail("intrinsic not found in graph!"); |
| 155 | + } |
| 156 | + } |
| 157 | + |
| 158 | + @Override |
| 159 | + protected InlineInvokePlugin.InlineInfo bytecodeParserShouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) { |
| 160 | + if (method.getDeclaringClass().getUnqualifiedName().equals("ArrayUtils") && !method.getName().startsWith("stub")) { |
| 161 | + return InlineInvokePlugin.InlineInfo.createStandardInlineInfo(method); |
| 162 | + } |
| 163 | + return super.bytecodeParserShouldInlineInvoke(b, method, args); |
| 164 | + } |
| 165 | + |
137 | 166 | private static byte[] toByteArray(String s) {
|
138 | 167 | byte[] ret = new byte[s.length()];
|
139 | 168 | for (int i = 0; i < s.length(); i++) {
|
|
0 commit comments