52578
|
1 |
/*
|
58299
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
52578
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
|
|
25 |
package org.graalvm.compiler.hotspot.amd64;
|
|
26 |
|
|
27 |
import org.graalvm.compiler.api.replacements.Snippet;
|
|
28 |
import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
|
|
29 |
import org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage;
|
|
30 |
import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
|
|
31 |
import org.graalvm.compiler.hotspot.stubs.SnippetStub;
|
|
32 |
import org.graalvm.compiler.options.OptionValues;
|
|
33 |
import org.graalvm.compiler.replacements.amd64.AMD64ArrayIndexOfNode;
|
|
34 |
|
|
35 |
public class AMD64ArrayIndexOfStub extends SnippetStub {
|
|
36 |
|
|
37 |
public AMD64ArrayIndexOfStub(ForeignCallDescriptor foreignCallDescriptor, OptionValues options, HotSpotProviders providers, HotSpotForeignCallLinkage linkage) {
|
|
38 |
super(foreignCallDescriptor.getName(), options, providers, linkage);
|
|
39 |
}
|
|
40 |
|
|
41 |
@Snippet
|
55509
|
42 |
private static int indexOfTwoConsecutiveBytes(byte[] array, int arrayLength, int fromIndex, int searchValue) {
|
|
43 |
return AMD64ArrayIndexOfNode.indexOf2ConsecutiveBytes(array, arrayLength, fromIndex, searchValue);
|
52578
|
44 |
}
|
|
45 |
|
|
46 |
@Snippet
|
55509
|
47 |
private static int indexOfTwoConsecutiveChars(char[] array, int arrayLength, int fromIndex, int searchValue) {
|
|
48 |
return AMD64ArrayIndexOfNode.indexOf2ConsecutiveChars(array, arrayLength, fromIndex, searchValue);
|
|
49 |
}
|
|
50 |
|
|
51 |
@Snippet
|
|
52 |
private static int indexOfTwoConsecutiveCharsCompact(byte[] array, int arrayLength, int fromIndex, int searchValue) {
|
|
53 |
return AMD64ArrayIndexOfNode.indexOf2ConsecutiveChars(array, arrayLength, fromIndex, searchValue);
|
52578
|
54 |
}
|
|
55 |
|
|
56 |
@Snippet
|
55509
|
57 |
private static int indexOf1Byte(byte[] array, int arrayLength, int fromIndex, byte b) {
|
|
58 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, b);
|
52578
|
59 |
}
|
|
60 |
|
|
61 |
@Snippet
|
55509
|
62 |
private static int indexOf2Bytes(byte[] array, int arrayLength, int fromIndex, byte b1, byte b2) {
|
|
63 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, b1, b2);
|
52578
|
64 |
}
|
|
65 |
|
|
66 |
@Snippet
|
55509
|
67 |
private static int indexOf3Bytes(byte[] array, int arrayLength, int fromIndex, byte b1, byte b2, byte b3) {
|
|
68 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, b1, b2, b3);
|
|
69 |
}
|
|
70 |
|
|
71 |
@Snippet
|
|
72 |
private static int indexOf4Bytes(byte[] array, int arrayLength, int fromIndex, byte b1, byte b2, byte b3, byte b4) {
|
|
73 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, b1, b2, b3, b4);
|
52578
|
74 |
}
|
|
75 |
|
|
76 |
@Snippet
|
55509
|
77 |
private static int indexOf1Char(char[] array, int arrayLength, int fromIndex, char c) {
|
|
78 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, c);
|
52578
|
79 |
}
|
|
80 |
|
|
81 |
@Snippet
|
55509
|
82 |
private static int indexOf2Chars(char[] array, int arrayLength, int fromIndex, char c1, char c2) {
|
|
83 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, c1, c2);
|
|
84 |
}
|
|
85 |
|
|
86 |
@Snippet
|
|
87 |
private static int indexOf3Chars(char[] array, int arrayLength, int fromIndex, char c1, char c2, char c3) {
|
|
88 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, c1, c2, c3);
|
|
89 |
}
|
|
90 |
|
|
91 |
@Snippet
|
|
92 |
private static int indexOf4Chars(char[] array, int arrayLength, int fromIndex, char c1, char c2, char c3, char c4) {
|
|
93 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, c1, c2, c3, c4);
|
52578
|
94 |
}
|
|
95 |
|
|
96 |
@Snippet
|
55509
|
97 |
private static int indexOf1CharCompact(byte[] array, int arrayLength, int fromIndex, char c) {
|
|
98 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, c);
|
|
99 |
}
|
|
100 |
|
|
101 |
@Snippet
|
|
102 |
private static int indexOf2CharsCompact(byte[] array, int arrayLength, int fromIndex, char c1, char c2) {
|
|
103 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, c1, c2);
|
52578
|
104 |
}
|
|
105 |
|
|
106 |
@Snippet
|
55509
|
107 |
private static int indexOf3CharsCompact(byte[] array, int arrayLength, int fromIndex, char c1, char c2, char c3) {
|
|
108 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, c1, c2, c3);
|
52578
|
109 |
}
|
|
110 |
|
|
111 |
@Snippet
|
55509
|
112 |
private static int indexOf4CharsCompact(byte[] array, int arrayLength, int fromIndex, char c1, char c2, char c3, char c4) {
|
|
113 |
return AMD64ArrayIndexOfNode.indexOf(array, arrayLength, fromIndex, c1, c2, c3, c4);
|
52578
|
114 |
}
|
|
115 |
}
|