Skip to content

Commit

Permalink
Fix incorrect resolution of merge conflicts for VectorizedHashCodeTest
Browse files Browse the repository at this point in the history
  • Loading branch information
dougxc committed Jun 5, 2024
1 parent b6f3365 commit 859ea9d
Showing 1 changed file with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package jdk.graal.compiler.hotspot.jdk23.test;

import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -40,20 +41,31 @@
@AddExports({"java.base/jdk.internal.util"})
public class VectorizedHashCodeTest extends GraalCompilerTest {

private static int getField(String name) {
try {
var arraysSupport = Class.forName("jdk.internal.util.ArraysSupport");
Field f = arraysSupport.getDeclaredField(name);
f.setAccessible(true);
return f.getInt(null);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}

@Test
public void testJDKConstantValue() {
Assert.assertEquals(ArraysSupport.T_BOOLEAN, VectorizedHashCodeInvocationPlugin.T_BOOLEAN);
Assert.assertEquals(ArraysSupport.T_CHAR, VectorizedHashCodeInvocationPlugin.T_CHAR);
Assert.assertEquals(ArraysSupport.T_BYTE, VectorizedHashCodeInvocationPlugin.T_BYTE);
Assert.assertEquals(ArraysSupport.T_SHORT, VectorizedHashCodeInvocationPlugin.T_SHORT);
Assert.assertEquals(ArraysSupport.T_INT, VectorizedHashCodeInvocationPlugin.T_INT);
Assert.assertEquals(getField("T_BOOLEAN"), VectorizedHashCodeInvocationPlugin.T_BOOLEAN);
Assert.assertEquals(getField("T_CHAR"), VectorizedHashCodeInvocationPlugin.T_CHAR);
Assert.assertEquals(getField("T_BYTE"), VectorizedHashCodeInvocationPlugin.T_BYTE);
Assert.assertEquals(getField("T_SHORT"), VectorizedHashCodeInvocationPlugin.T_SHORT);
Assert.assertEquals(getField("T_INT"), VectorizedHashCodeInvocationPlugin.T_INT);
}

// @formatter:off
private static String[] tests = {"", " ", "a", "abcdefg",
"It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only. -- Charles Dickens, Tale of Two Cities",
"C'était le meilleur des temps, c'était le pire des temps, c'était l'âge de la sagesse, c'était l'âge de la folie, c'était l'époque de la croyance, c'était l'époque de l'incrédulité, c'était la saison de la Lumière, c'était C'était la saison des Ténèbres, c'était le printemps de l'espoir, c'était l'hiver du désespoir, nous avions tout devant nous, nous n'avions rien devant nous, nous allions tous directement au Ciel, nous allions tous directement dans l'autre sens bref, la période ressemblait tellement à la période actuelle, que certaines de ses autorités les plus bruyantes ont insisté pour qu'elle soit reçue, pour le bien ou pour le mal, au degré superlatif de la comparaison seulement. -- Charles Dickens, Tale of Two Cities (in French)",
"禅道修行を志した雲水は、一般に参禅のしきたりを踏んだうえで一人の師につき、各地にある専門道場と呼ばれる養成寺院に入門し、与えられた公案に取り組むことになる。公案は、師家(老師)から雲水が悟りの境地へと進んで行くために手助けとして課す問題であり、悟りの境地に達していない人には容易に理解し難い難問だが、屁理屈や詭弁が述べられているわけではなく、頓知や謎かけとも異なる。"
"It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only. -- Charles Dickens, Tale of Two Cities",
"C'était le meilleur des temps, c'était le pire des temps, c'était l'âge de la sagesse, c'était l'âge de la folie, c'était l'époque de la croyance, c'était l'époque de l'incrédulité, c'était la saison de la Lumière, c'était C'était la saison des Ténèbres, c'était le printemps de l'espoir, c'était l'hiver du désespoir, nous avions tout devant nous, nous n'avions rien devant nous, nous allions tous directement au Ciel, nous allions tous directement dans l'autre sens bref, la période ressemblait tellement à la période actuelle, que certaines de ses autorités les plus bruyantes ont insisté pour qu'elle soit reçue, pour le bien ou pour le mal, au degré superlatif de la comparaison seulement. -- Charles Dickens, Tale of Two Cities (in French)",
"禅道修行を志した雲水は、一般に参禅のしきたりを踏んだうえで一人の師につき、各地にある専門道場と呼ばれる養成寺院に入門し、与えられた公案に取り組むことになる。公案は、師家(老師)から雲水が悟りの境地へと進んで行くために手助けとして課す問題であり、悟りの境地に達していない人には容易に理解し難い難問だが、屁理屈や詭弁が述べられているわけではなく、頓知や謎かけとも異なる。"
};
// @formatter:on

Expand Down Expand Up @@ -89,7 +101,7 @@ private void testHash(String method, Function<byte[], Object> f, Function<byte[]
}

public static int hashByteArray(byte[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_BYTE);
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
Expand All @@ -98,16 +110,16 @@ public void testHashByteArray() {
}

public static int hashByteArrayCharElement(byte[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_CHAR);
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
public void testHashByteArrayCharElement() {
testHash("hashByteArrayCharElement", a -> a, a -> a.length / 2);
}

public static int hashBooleanArray(Object array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_BOOLEAN);
public static int hashBooleanArray(byte[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
Expand All @@ -124,7 +136,7 @@ public void testHashBooleanArray() {
}

public static int hashCharArray(char[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_CHAR);
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
Expand All @@ -139,7 +151,7 @@ public void testHashCharArray() {
}

public static int hashShortArray(short[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_SHORT);
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
Expand All @@ -154,7 +166,7 @@ public void testHashShortArray() {
}

public static int hashIntArray(int[] array, int fromIndex, int length, int initialValue) {
return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_INT);
return ArraysSupport.hashCode(array, fromIndex, length, initialValue);
}

@Test
Expand Down

0 comments on commit 859ea9d

Please sign in to comment.