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.replacements.amd64;
|
|
26 |
|
|
27 |
import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
|
|
28 |
|
|
29 |
public class AMD64ArrayIndexOf {
|
|
30 |
|
|
31 |
public static final ForeignCallDescriptor STUB_INDEX_OF_TWO_CONSECUTIVE_BYTES = new ForeignCallDescriptor(
|
55509
|
32 |
"indexOfTwoConsecutiveBytes", int.class, byte[].class, int.class, int.class, int.class);
|
52578
|
33 |
public static final ForeignCallDescriptor STUB_INDEX_OF_TWO_CONSECUTIVE_CHARS = new ForeignCallDescriptor(
|
55509
|
34 |
"indexOfTwoConsecutiveChars", int.class, char[].class, int.class, int.class, int.class);
|
|
35 |
public static final ForeignCallDescriptor STUB_INDEX_OF_TWO_CONSECUTIVE_CHARS_COMPACT = new ForeignCallDescriptor(
|
|
36 |
"indexOfTwoConsecutiveCharsCompact", int.class, byte[].class, int.class, int.class, int.class);
|
52578
|
37 |
public static final ForeignCallDescriptor STUB_INDEX_OF_1_BYTE = new ForeignCallDescriptor(
|
55509
|
38 |
"indexOf1Byte", int.class, byte[].class, int.class, int.class, byte.class);
|
52578
|
39 |
public static final ForeignCallDescriptor STUB_INDEX_OF_2_BYTES = new ForeignCallDescriptor(
|
55509
|
40 |
"indexOf2Bytes", int.class, byte[].class, int.class, int.class, byte.class, byte.class);
|
52578
|
41 |
public static final ForeignCallDescriptor STUB_INDEX_OF_3_BYTES = new ForeignCallDescriptor(
|
55509
|
42 |
"indexOf3Bytes", int.class, byte[].class, int.class, int.class, byte.class, byte.class, byte.class);
|
52578
|
43 |
public static final ForeignCallDescriptor STUB_INDEX_OF_4_BYTES = new ForeignCallDescriptor(
|
55509
|
44 |
"indexOf4Bytes", int.class, byte[].class, int.class, int.class, byte.class, byte.class, byte.class, byte.class);
|
52578
|
45 |
public static final ForeignCallDescriptor STUB_INDEX_OF_1_CHAR = new ForeignCallDescriptor(
|
55509
|
46 |
"indexOf1Char", int.class, char[].class, int.class, int.class, char.class);
|
52578
|
47 |
public static final ForeignCallDescriptor STUB_INDEX_OF_2_CHARS = new ForeignCallDescriptor(
|
55509
|
48 |
"indexOf2Chars", int.class, char[].class, int.class, int.class, char.class, char.class);
|
52578
|
49 |
public static final ForeignCallDescriptor STUB_INDEX_OF_3_CHARS = new ForeignCallDescriptor(
|
55509
|
50 |
"indexOf3Chars", int.class, char[].class, int.class, int.class, char.class, char.class, char.class);
|
52578
|
51 |
public static final ForeignCallDescriptor STUB_INDEX_OF_4_CHARS = new ForeignCallDescriptor(
|
55509
|
52 |
"indexOf4Chars", int.class, char[].class, int.class, int.class, char.class, char.class, char.class, char.class);
|
|
53 |
public static final ForeignCallDescriptor STUB_INDEX_OF_1_CHAR_COMPACT = new ForeignCallDescriptor(
|
|
54 |
"indexOf1CharCompact", int.class, byte[].class, int.class, int.class, char.class);
|
|
55 |
public static final ForeignCallDescriptor STUB_INDEX_OF_2_CHARS_COMPACT = new ForeignCallDescriptor(
|
|
56 |
"indexOf2CharsCompact", int.class, byte[].class, int.class, int.class, char.class, char.class);
|
|
57 |
public static final ForeignCallDescriptor STUB_INDEX_OF_3_CHARS_COMPACT = new ForeignCallDescriptor(
|
|
58 |
"indexOf3CharsCompact", int.class, byte[].class, int.class, int.class, char.class, char.class, char.class);
|
|
59 |
public static final ForeignCallDescriptor STUB_INDEX_OF_4_CHARS_COMPACT = new ForeignCallDescriptor(
|
|
60 |
"indexOf4CharsCompact", int.class, byte[].class, int.class, int.class, char.class, char.class, char.class, char.class);
|
52578
|
61 |
|
55509
|
62 |
public static int indexOfTwoConsecutiveBytes(byte[] array, int arrayLength, int fromIndex, byte b1, byte b2) {
|
52578
|
63 |
int searchValue = (Byte.toUnsignedInt(b2) << Byte.SIZE) | Byte.toUnsignedInt(b1);
|
55509
|
64 |
return AMD64ArrayIndexOfDispatchNode.indexOf2ConsecutiveBytes(STUB_INDEX_OF_TWO_CONSECUTIVE_BYTES, array, arrayLength, fromIndex, searchValue);
|
52578
|
65 |
}
|
|
66 |
|
55509
|
67 |
public static int indexOfTwoConsecutiveChars(char[] array, int arrayLength, int fromIndex, char c1, char c2) {
|
52578
|
68 |
int searchValue = (c2 << Character.SIZE) | c1;
|
55509
|
69 |
return AMD64ArrayIndexOfDispatchNode.indexOf2ConsecutiveChars(STUB_INDEX_OF_TWO_CONSECUTIVE_CHARS, array, arrayLength, fromIndex, searchValue);
|
52578
|
70 |
}
|
|
71 |
|
55509
|
72 |
public static int indexOfTwoConsecutiveChars(byte[] array, int arrayLength, int fromIndex, char c1, char c2) {
|
|
73 |
int searchValue = (c2 << Character.SIZE) | c1;
|
|
74 |
return AMD64ArrayIndexOfDispatchNode.indexOf2ConsecutiveChars(STUB_INDEX_OF_TWO_CONSECUTIVE_CHARS_COMPACT, array, arrayLength, fromIndex, searchValue);
|
52578
|
75 |
}
|
|
76 |
|
55509
|
77 |
public static int indexOf1Byte(byte[] array, int arrayLength, int fromIndex, byte b) {
|
|
78 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_1_BYTE, array, arrayLength, fromIndex, b);
|
52578
|
79 |
}
|
|
80 |
|
55509
|
81 |
public static int indexOf2Bytes(byte[] array, int arrayLength, int fromIndex, byte b1, byte b2) {
|
|
82 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_2_BYTES, array, arrayLength, fromIndex, b1, b2);
|
52578
|
83 |
}
|
|
84 |
|
55509
|
85 |
public static int indexOf3Bytes(byte[] array, int arrayLength, int fromIndex, byte b1, byte b2, byte b3) {
|
|
86 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_3_BYTES, array, arrayLength, fromIndex, b1, b2, b3);
|
52578
|
87 |
}
|
|
88 |
|
55509
|
89 |
public static int indexOf4Bytes(byte[] array, int arrayLength, int fromIndex, byte b1, byte b2, byte b3, byte b4) {
|
|
90 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_4_BYTES, array, arrayLength, fromIndex, b1, b2, b3, b4);
|
52578
|
91 |
}
|
|
92 |
|
55509
|
93 |
public static int indexOf1Char(char[] array, int arrayLength, int fromIndex, char c) {
|
|
94 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_1_CHAR, array, arrayLength, fromIndex, c);
|
|
95 |
}
|
|
96 |
|
|
97 |
public static int indexOf2Chars(char[] array, int arrayLength, int fromIndex, char c1, char c2) {
|
|
98 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_2_CHARS, array, arrayLength, fromIndex, c1, c2);
|
52578
|
99 |
}
|
|
100 |
|
55509
|
101 |
public static int indexOf3Chars(char[] array, int arrayLength, int fromIndex, char c1, char c2, char c3) {
|
|
102 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_3_CHARS, array, arrayLength, fromIndex, c1, c2, c3);
|
|
103 |
}
|
52578
|
104 |
|
55509
|
105 |
public static int indexOf4Chars(char[] array, int arrayLength, int fromIndex, char c1, char c2, char c3, char c4) {
|
|
106 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_4_CHARS, array, arrayLength, fromIndex, c1, c2, c3, c4);
|
|
107 |
}
|
52578
|
108 |
|
55509
|
109 |
public static int indexOf1Char(byte[] array, int arrayLength, int fromIndex, char c) {
|
|
110 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_1_CHAR_COMPACT, array, arrayLength, fromIndex, c);
|
|
111 |
}
|
52578
|
112 |
|
55509
|
113 |
public static int indexOf2Chars(byte[] array, int arrayLength, int fromIndex, char c1, char c2) {
|
|
114 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_2_CHARS_COMPACT, array, arrayLength, fromIndex, c1, c2);
|
|
115 |
}
|
52578
|
116 |
|
55509
|
117 |
public static int indexOf3Chars(byte[] array, int arrayLength, int fromIndex, char c1, char c2, char c3) {
|
|
118 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_3_CHARS_COMPACT, array, arrayLength, fromIndex, c1, c2, c3);
|
|
119 |
}
|
52578
|
120 |
|
55509
|
121 |
public static int indexOf4Chars(byte[] array, int arrayLength, int fromIndex, char c1, char c2, char c3, char c4) {
|
|
122 |
return AMD64ArrayIndexOfDispatchNode.indexOf(STUB_INDEX_OF_4_CHARS_COMPACT, array, arrayLength, fromIndex, c1, c2, c3, c4);
|
|
123 |
}
|
52578
|
124 |
}
|