diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/VerifyWordFactoryUsage.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/VerifyWordFactoryUsage.java index 5a141f51d836..e43350e662d8 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/VerifyWordFactoryUsage.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/VerifyWordFactoryUsage.java @@ -28,11 +28,13 @@ import jdk.graal.compiler.nodes.java.MethodCallTargetNode; import jdk.graal.compiler.nodes.spi.CoreProviders; import jdk.graal.compiler.phases.VerifyPhase; -import jdk.vm.ci.meta.MetaUtil; +import jdk.graal.compiler.word.Word; +import jdk.vm.ci.meta.ResolvedJavaType; +import org.graalvm.word.WordFactory; /** - * Ensures that Graal compiler code uses {@link jdk.graal.compiler.word.WordFactory} instead of - * {@link org.graalvm.word.WordFactory} to create word values. + * Ensures that Graal compiler code uses factory methods in {@link Word} instead of + * {@link WordFactory} to create word values. */ public class VerifyWordFactoryUsage extends VerifyPhase { @@ -44,14 +46,14 @@ public boolean checkContract() { @Override protected void verify(StructuredGraph graph, CoreProviders context) { - String badWordFactory = MetaUtil.toInternalName(org.graalvm.word.WordFactory.class.getName()); - + ResolvedJavaType wordFactory = context.getMetaAccess().lookupJavaType(WordFactory.class); for (MethodCallTargetNode t : graph.getNodes(MethodCallTargetNode.TYPE)) { - if (t.targetMethod().getDeclaringClass().getName().equals(badWordFactory)) { - throw new VerificationError("accessing %s in %s is prohibited - use %s instead", - badWordFactory, + if (t.targetMethod().getDeclaringClass().equals(wordFactory)) { + throw new VerificationError("accessing %s in %s is prohibited - use %s.%s instead", + wordFactory.toJavaName(), graph.method().format("%H.%n(%p)"), - jdk.graal.compiler.word.WordFactory.class.getName()); + Word.class.getName(), + graph.method().format("%n(%p)")); } } diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/ObjectAccessTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/ObjectAccessTest.java index 99dca966a077..bfd9a7c20c28 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/ObjectAccessTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/ObjectAccessTest.java @@ -37,9 +37,9 @@ import jdk.graal.compiler.nodes.extended.JavaWriteNode; import jdk.graal.compiler.nodes.memory.address.OffsetAddressNode; import jdk.graal.compiler.word.ObjectAccess; +import jdk.graal.compiler.word.Word; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import org.junit.Assert; import org.junit.Test; @@ -152,7 +152,7 @@ public static byte readByte1(Object o, int offset) { @Snippet public static byte readByte2(Object o, int offset) { - return ObjectAccess.readByte(o, WordFactory.signed(offset), ID); + return ObjectAccess.readByte(o, Word.signed(offset), ID); } @Snippet @@ -167,7 +167,7 @@ public static void writeByte1(Object o, int offset, byte value) { @Snippet public static void writeByte2(Object o, int offset, byte value) { - ObjectAccess.writeByte(o, WordFactory.signed(offset), value, ID); + ObjectAccess.writeByte(o, Word.signed(offset), value, ID); } @Snippet @@ -182,7 +182,7 @@ public static char readChar1(Object o, int offset) { @Snippet public static char readChar2(Object o, int offset) { - return ObjectAccess.readChar(o, WordFactory.signed(offset), ID); + return ObjectAccess.readChar(o, Word.signed(offset), ID); } @Snippet @@ -197,7 +197,7 @@ public static void writeChar1(Object o, int offset, char value) { @Snippet public static void writeChar2(Object o, int offset, char value) { - ObjectAccess.writeChar(o, WordFactory.signed(offset), value, ID); + ObjectAccess.writeChar(o, Word.signed(offset), value, ID); } @Snippet @@ -212,7 +212,7 @@ public static short readShort1(Object o, int offset) { @Snippet public static short readShort2(Object o, int offset) { - return ObjectAccess.readShort(o, WordFactory.signed(offset), ID); + return ObjectAccess.readShort(o, Word.signed(offset), ID); } @Snippet @@ -227,7 +227,7 @@ public static void writeShort1(Object o, int offset, short value) { @Snippet public static void writeShort2(Object o, int offset, short value) { - ObjectAccess.writeShort(o, WordFactory.signed(offset), value, ID); + ObjectAccess.writeShort(o, Word.signed(offset), value, ID); } @Snippet @@ -242,7 +242,7 @@ public static int readInt1(Object o, int offset) { @Snippet public static int readInt2(Object o, int offset) { - return ObjectAccess.readInt(o, WordFactory.signed(offset), ID); + return ObjectAccess.readInt(o, Word.signed(offset), ID); } @Snippet @@ -257,7 +257,7 @@ public static void writeInt1(Object o, int offset, int value) { @Snippet public static void writeInt2(Object o, int offset, int value) { - ObjectAccess.writeInt(o, WordFactory.signed(offset), value, ID); + ObjectAccess.writeInt(o, Word.signed(offset), value, ID); } @Snippet @@ -272,7 +272,7 @@ public static long readLong1(Object o, int offset) { @Snippet public static long readLong2(Object o, int offset) { - return ObjectAccess.readLong(o, WordFactory.signed(offset), ID); + return ObjectAccess.readLong(o, Word.signed(offset), ID); } @Snippet @@ -287,7 +287,7 @@ public static void writeLong1(Object o, int offset, long value) { @Snippet public static void writeLong2(Object o, int offset, long value) { - ObjectAccess.writeLong(o, WordFactory.signed(offset), value, ID); + ObjectAccess.writeLong(o, Word.signed(offset), value, ID); } @Snippet @@ -302,7 +302,7 @@ public static float readFloat1(Object o, int offset) { @Snippet public static float readFloat2(Object o, int offset) { - return ObjectAccess.readFloat(o, WordFactory.signed(offset), ID); + return ObjectAccess.readFloat(o, Word.signed(offset), ID); } @Snippet @@ -317,7 +317,7 @@ public static void writeFloat1(Object o, int offset, float value) { @Snippet public static void writeFloat2(Object o, int offset, float value) { - ObjectAccess.writeFloat(o, WordFactory.signed(offset), value, ID); + ObjectAccess.writeFloat(o, Word.signed(offset), value, ID); } @Snippet @@ -332,7 +332,7 @@ public static double readDouble1(Object o, int offset) { @Snippet public static double readDouble2(Object o, int offset) { - return ObjectAccess.readDouble(o, WordFactory.signed(offset), ID); + return ObjectAccess.readDouble(o, Word.signed(offset), ID); } @Snippet @@ -347,7 +347,7 @@ public static void writeDouble1(Object o, int offset, double value) { @Snippet public static void writeDouble2(Object o, int offset, double value) { - ObjectAccess.writeDouble(o, WordFactory.signed(offset), value, ID); + ObjectAccess.writeDouble(o, Word.signed(offset), value, ID); } @Snippet @@ -362,7 +362,7 @@ public static Object readObject1(Object o, int offset) { @Snippet public static Object readObject2(Object o, int offset) { - return ObjectAccess.readObject(o, WordFactory.signed(offset), ID); + return ObjectAccess.readObject(o, Word.signed(offset), ID); } @Snippet @@ -377,7 +377,7 @@ public static void writeObject1(Object o, int offset, Object value) { @Snippet public static void writeObject2(Object o, int offset, Object value) { - ObjectAccess.writeObject(o, WordFactory.signed(offset), value, ID); + ObjectAccess.writeObject(o, Word.signed(offset), value, ID); } @Snippet diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/PointerTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/PointerTest.java index 6682b94ca286..57fbf7b94ce6 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/PointerTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/PointerTest.java @@ -42,7 +42,6 @@ import jdk.graal.compiler.word.WordCastNode; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import org.junit.Assert; import org.junit.Test; @@ -172,7 +171,7 @@ public static byte readByte1(Object o, int offset) { @Snippet public static byte readByte2(Object o, int offset) { - return Word.objectToTrackedPointer(o).readByte(WordFactory.signed(offset), ID); + return Word.objectToTrackedPointer(o).readByte(Word.signed(offset), ID); } @Snippet @@ -187,7 +186,7 @@ public static void writeByte1(Object o, int offset, byte value) { @Snippet public static void writeByte2(Object o, int offset, byte value) { - Word.objectToTrackedPointer(o).writeByte(WordFactory.signed(offset), value, ID); + Word.objectToTrackedPointer(o).writeByte(Word.signed(offset), value, ID); } @Snippet @@ -202,7 +201,7 @@ public static char readChar1(Object o, int offset) { @Snippet public static char readChar2(Object o, int offset) { - return Word.objectToTrackedPointer(o).readChar(WordFactory.signed(offset), ID); + return Word.objectToTrackedPointer(o).readChar(Word.signed(offset), ID); } @Snippet @@ -217,7 +216,7 @@ public static void writeChar1(Object o, int offset, char value) { @Snippet public static void writeChar2(Object o, int offset, char value) { - Word.objectToTrackedPointer(o).writeChar(WordFactory.signed(offset), value, ID); + Word.objectToTrackedPointer(o).writeChar(Word.signed(offset), value, ID); } @Snippet @@ -232,7 +231,7 @@ public static short readShort1(Object o, int offset) { @Snippet public static short readShort2(Object o, int offset) { - return Word.objectToTrackedPointer(o).readShort(WordFactory.signed(offset), ID); + return Word.objectToTrackedPointer(o).readShort(Word.signed(offset), ID); } @Snippet @@ -247,7 +246,7 @@ public static void writeShort1(Object o, int offset, short value) { @Snippet public static void writeShort2(Object o, int offset, short value) { - Word.objectToTrackedPointer(o).writeShort(WordFactory.signed(offset), value, ID); + Word.objectToTrackedPointer(o).writeShort(Word.signed(offset), value, ID); } @Snippet @@ -262,7 +261,7 @@ public static int readInt1(Object o, int offset) { @Snippet public static int readInt2(Object o, int offset) { - return Word.objectToTrackedPointer(o).readInt(WordFactory.signed(offset), ID); + return Word.objectToTrackedPointer(o).readInt(Word.signed(offset), ID); } @Snippet @@ -277,7 +276,7 @@ public static void writeInt1(Object o, int offset, int value) { @Snippet public static void writeInt2(Object o, int offset, int value) { - Word.objectToTrackedPointer(o).writeInt(WordFactory.signed(offset), value, ID); + Word.objectToTrackedPointer(o).writeInt(Word.signed(offset), value, ID); } @Snippet @@ -292,7 +291,7 @@ public static long readLong1(Object o, int offset) { @Snippet public static long readLong2(Object o, int offset) { - return Word.objectToTrackedPointer(o).readLong(WordFactory.signed(offset), ID); + return Word.objectToTrackedPointer(o).readLong(Word.signed(offset), ID); } @Snippet @@ -307,7 +306,7 @@ public static void writeLong1(Object o, int offset, long value) { @Snippet public static void writeLong2(Object o, int offset, long value) { - Word.objectToTrackedPointer(o).writeLong(WordFactory.signed(offset), value, ID); + Word.objectToTrackedPointer(o).writeLong(Word.signed(offset), value, ID); } @Snippet @@ -322,7 +321,7 @@ public static float readFloat1(Object o, int offset) { @Snippet public static float readFloat2(Object o, int offset) { - return Word.objectToTrackedPointer(o).readFloat(WordFactory.signed(offset), ID); + return Word.objectToTrackedPointer(o).readFloat(Word.signed(offset), ID); } @Snippet @@ -337,7 +336,7 @@ public static void writeFloat1(Object o, int offset, float value) { @Snippet public static void writeFloat2(Object o, int offset, float value) { - Word.objectToTrackedPointer(o).writeFloat(WordFactory.signed(offset), value, ID); + Word.objectToTrackedPointer(o).writeFloat(Word.signed(offset), value, ID); } @Snippet @@ -352,7 +351,7 @@ public static double readDouble1(Object o, int offset) { @Snippet public static double readDouble2(Object o, int offset) { - return Word.objectToTrackedPointer(o).readDouble(WordFactory.signed(offset), ID); + return Word.objectToTrackedPointer(o).readDouble(Word.signed(offset), ID); } @Snippet @@ -367,7 +366,7 @@ public static void writeDouble1(Object o, int offset, double value) { @Snippet public static void writeDouble2(Object o, int offset, double value) { - Word.objectToTrackedPointer(o).writeDouble(WordFactory.signed(offset), value, ID); + Word.objectToTrackedPointer(o).writeDouble(Word.signed(offset), value, ID); } @Snippet @@ -382,7 +381,7 @@ public static Object readObject1(Object o, int offset) { @Snippet public static Object readObject2(Object o, int offset) { - return Word.objectToTrackedPointer(o).readObject(WordFactory.signed(offset), ID); + return Word.objectToTrackedPointer(o).readObject(Word.signed(offset), ID); } @Snippet @@ -397,7 +396,7 @@ public static void writeObject1(Object o, int offset, Object value) { @Snippet public static void writeObject2(Object o, int offset, Object value) { - Word.objectToTrackedPointer(o).writeObject(WordFactory.signed(offset), value, ID); + Word.objectToTrackedPointer(o).writeObject(Word.signed(offset), value, ID); } @Snippet diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/WordTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/WordTest.java index cf881957d570..e6ce78c8ab2b 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/WordTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/WordTest.java @@ -34,7 +34,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import org.junit.Test; /** @@ -119,7 +118,7 @@ public void testCast() { @Snippet public static long cast(long input) { - WordBase base = WordFactory.signed(input); + WordBase base = Word.signed(input); UnsignedWord unsigned = (UnsignedWord) base; Pointer pointer = (Pointer) unsigned; Word word = (Word) pointer; @@ -128,111 +127,111 @@ public static long cast(long input) { @Snippet public static long unsignedLong(long word) { - return WordFactory.unsigned(word).rawValue(); + return Word.unsigned(word).rawValue(); } @Snippet public static long unsignedInt(int word) { - return WordFactory.unsigned(word).rawValue(); + return Word.unsigned(word).rawValue(); } @Snippet public static long signedLong(long word) { - return WordFactory.signed(word).rawValue(); + return Word.signed(word).rawValue(); } @Snippet public static long signedInt(int word) { - return WordFactory.signed(word).rawValue(); + return Word.signed(word).rawValue(); } @Snippet public static long unsignedPlusInt(long word, int addend) { - return WordFactory.unsigned(word).add(addend).rawValue(); + return Word.unsigned(word).add(addend).rawValue(); } @Snippet public static long unsignedMinusInt(long word, int addend) { - return WordFactory.unsigned(word).subtract(addend).rawValue(); + return Word.unsigned(word).subtract(addend).rawValue(); } @Snippet public static long unsignedPlusLong(long word, long addend) { - return WordFactory.unsigned(word).add(WordFactory.unsigned(addend)).rawValue(); + return Word.unsigned(word).add(Word.unsigned(addend)).rawValue(); } @Snippet public static long unsignedMinusLong(long word, long addend) { - return WordFactory.unsigned(word).subtract(WordFactory.unsigned(addend)).rawValue(); + return Word.unsigned(word).subtract(Word.unsigned(addend)).rawValue(); } @Snippet public static long signedPlusInt(long word, int addend) { - return WordFactory.signed(word).add(addend).rawValue(); + return Word.signed(word).add(addend).rawValue(); } @Snippet public static long signedMinusInt(long word, int addend) { - return WordFactory.signed(word).subtract(addend).rawValue(); + return Word.signed(word).subtract(addend).rawValue(); } @Snippet public static long signedPlusLong(long word, long addend) { - return WordFactory.signed(word).add(WordFactory.signed(addend)).rawValue(); + return Word.signed(word).add(Word.signed(addend)).rawValue(); } @Snippet public static long signedMinusLong(long word, long addend) { - return WordFactory.signed(word).subtract(WordFactory.signed(addend)).rawValue(); + return Word.signed(word).subtract(Word.signed(addend)).rawValue(); } @Snippet public static long signedNot(long word) { - return WordFactory.signed(word).not().rawValue(); + return Word.signed(word).not().rawValue(); } @Snippet public static long unsignedNot(long word) { - return WordFactory.unsigned(word).not().rawValue(); + return Word.unsigned(word).not().rawValue(); } @Snippet public static boolean aboveOrEqual(long word1, long word2) { - return WordFactory.unsigned(word1).aboveOrEqual(WordFactory.unsigned(word2)); + return Word.unsigned(word1).aboveOrEqual(Word.unsigned(word2)); } @Snippet public static boolean above(long word1, long word2) { - return WordFactory.unsigned(word1).aboveThan(WordFactory.unsigned(word2)); + return Word.unsigned(word1).aboveThan(Word.unsigned(word2)); } @Snippet public static boolean belowOrEqual(long word1, long word2) { - return WordFactory.unsigned(word1).belowOrEqual(WordFactory.unsigned(word2)); + return Word.unsigned(word1).belowOrEqual(Word.unsigned(word2)); } @Snippet public static boolean below(long word1, long word2) { - return WordFactory.unsigned(word1).belowThan(WordFactory.unsigned(word2)); + return Word.unsigned(word1).belowThan(Word.unsigned(word2)); } @Snippet public static long andInt(long word, int addend) { - return WordFactory.unsigned(word).and(addend).rawValue(); + return Word.unsigned(word).and(addend).rawValue(); } @Snippet public static long orInt(long word, int addend) { - return WordFactory.unsigned(word).or(addend).rawValue(); + return Word.unsigned(word).or(addend).rawValue(); } @Snippet public static long andLong(long word, long addend) { - return WordFactory.unsigned(word).and(WordFactory.unsigned(addend)).rawValue(); + return Word.unsigned(word).and(Word.unsigned(addend)).rawValue(); } @Snippet public static long orLong(long word, long addend) { - return WordFactory.unsigned(word).or(WordFactory.unsigned(addend)).rawValue(); + return Word.unsigned(word).or(Word.unsigned(addend)).rawValue(); } } diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/test/WordTests.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/test/WordTests.java index 39c0614ca9e2..e467d054ed41 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/test/WordTests.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/test/WordTests.java @@ -29,9 +29,11 @@ import static jdk.graal.compiler.core.common.calc.UnsignedMath.belowOrEqual; import static jdk.graal.compiler.core.common.calc.UnsignedMath.belowThan; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; +import org.graalvm.word.WordFactory; import org.junit.Assert; import org.junit.Test; @@ -40,8 +42,7 @@ import java.util.stream.Stream; /** - * Tests word operations on boxed values produced by {@link org.graalvm.word.WordFactory} and - * {@link jdk.graal.compiler.word.WordFactory}. + * Tests word operations on boxed values produced by {@link WordFactory} and {@link Word}. */ public class WordTests { @@ -62,15 +63,15 @@ public class WordTests { }; static SignedWord graalSigned(long val) { - return jdk.graal.compiler.word.WordFactory.signed(val); + return Word.signed(val); } static UnsignedWord graalUnsigned(long val) { - return jdk.graal.compiler.word.WordFactory.unsigned(val); + return Word.unsigned(val); } static Pointer graalPointer(long val) { - return jdk.graal.compiler.word.WordFactory.pointer(val); + return Word.pointer(val); } static List signedWords = Stream.concat( diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/DigestBaseSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/DigestBaseSnippets.java index bea0692c10ad..1070fc8dbb12 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/DigestBaseSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/DigestBaseSnippets.java @@ -44,7 +44,6 @@ import jdk.graal.compiler.replacements.nodes.FallbackInvokeWithExceptionNode; import jdk.graal.compiler.word.Word; import org.graalvm.word.LocationIdentity; -import jdk.graal.compiler.word.WordFactory; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.ResolvedJavaType; @@ -73,32 +72,32 @@ static int implCompressMultiBlock0(Object receiver, byte[] buf, int ofs, int lim @Snippet.ConstantParameter ResolvedJavaType sha3type) { Object realReceiver = PiNode.piCast(receiver, receiverType, false, true, SnippetAnchorNode.anchor()); - Word bufAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(buf, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Byte) + ofs)); + Word bufAddr = Word.unsigned(ComputeObjectAddressNode.get(buf, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Byte) + ofs)); if (useMD5Intrinsics(INJECTED_VMCONFIG) && doInstanceof(md5type, realReceiver)) { Object md5obj = PiNode.piCast(realReceiver, md5type, false, true, SnippetAnchorNode.anchor()); Object state = RawLoadNode.load(md5obj, HotSpotReplacementsUtil.getFieldOffset(md5type, "state"), JavaKind.Object, LocationIdentity.any()); - Word stateAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(state, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Int))); + Word stateAddr = Word.unsigned(ComputeObjectAddressNode.get(state, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Int))); return HotSpotBackend.md5ImplCompressMBStub(bufAddr, stateAddr, ofs, limit); } else if (useSHA1Intrinsics(INJECTED_VMCONFIG) && doInstanceof(sha1type, realReceiver)) { Object sha1obj = PiNode.piCast(realReceiver, sha1type, false, true, SnippetAnchorNode.anchor()); Object state = RawLoadNode.load(sha1obj, HotSpotReplacementsUtil.getFieldOffset(sha1type, "state"), JavaKind.Object, LocationIdentity.any()); - Word stateAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(state, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Int))); + Word stateAddr = Word.unsigned(ComputeObjectAddressNode.get(state, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Int))); return HotSpotBackend.shaImplCompressMBStub(bufAddr, stateAddr, ofs, limit); } else if (useSHA256Intrinsics(INJECTED_VMCONFIG) && doInstanceof(sha256type, realReceiver)) { Object sha256obj = PiNode.piCast(realReceiver, sha256type, false, true, SnippetAnchorNode.anchor()); Object state = RawLoadNode.load(sha256obj, HotSpotReplacementsUtil.getFieldOffset(sha256type, "state"), JavaKind.Object, LocationIdentity.any()); - Word stateAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(state, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Int))); + Word stateAddr = Word.unsigned(ComputeObjectAddressNode.get(state, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Int))); return HotSpotBackend.sha2ImplCompressMBStub(bufAddr, stateAddr, ofs, limit); } else if (useSHA512Intrinsics(INJECTED_VMCONFIG) && doInstanceof(sha512type, realReceiver)) { Object sha512obj = PiNode.piCast(realReceiver, sha512type, false, true, SnippetAnchorNode.anchor()); Object state = RawLoadNode.load(sha512obj, HotSpotReplacementsUtil.getFieldOffset(sha512type, "state"), JavaKind.Object, LocationIdentity.any()); - Word stateAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(state, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Long))); + Word stateAddr = Word.unsigned(ComputeObjectAddressNode.get(state, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Long))); return HotSpotBackend.sha5ImplCompressMBStub(bufAddr, stateAddr, ofs, limit); } else if (useSHA3Intrinsics(INJECTED_VMCONFIG) && doInstanceof(sha3type, realReceiver)) { Object sha3obj = PiNode.piCast(realReceiver, sha3type, false, true, SnippetAnchorNode.anchor()); int blockSize = RawLoadNode.loadInt(sha3obj, HotSpotReplacementsUtil.getFieldOffset(sha3type, "blockSize"), JavaKind.Int, LocationIdentity.any()); Object state = RawLoadNode.load(sha3obj, HotSpotReplacementsUtil.getFieldOffset(sha3type, "state"), JavaKind.Object, LocationIdentity.any()); - Word stateAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(state, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Long))); + Word stateAddr = Word.unsigned(ComputeObjectAddressNode.get(state, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Long))); return HotSpotBackend.sha3ImplCompressMBStub(bufAddr, stateAddr, blockSize, ofs, limit); } else { return FallbackInvokeWithExceptionNode.fallbackFunctionCallInt(); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotAllocationSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotAllocationSnippets.java index 05433d348bfb..a900f600f056 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotAllocationSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotAllocationSnippets.java @@ -70,7 +70,6 @@ import static jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.api.replacements.Fold.InjectedParameter; @@ -148,7 +147,7 @@ protected Object allocateInstance(KlassPointer hub, @ConstantParameter boolean emitMemoryBarrier, @ConstantParameter HotSpotAllocationProfilingData profilingData, @ConstantParameter boolean withException) { - Object result = allocateInstanceImpl(hub.asWord(), WordFactory.unsigned(size), forceSlowPath, fillContents, emitMemoryBarrier, true, profilingData, withException); + Object result = allocateInstanceImpl(hub.asWord(), Word.unsigned(size), forceSlowPath, fillContents, emitMemoryBarrier, true, profilingData, withException); return piCastToSnippetReplaceeStamp(result); } @@ -193,7 +192,7 @@ public Object allocateInstanceDynamic(@NonNullParameter Class type, * FIXME(je,ds): we should actually pass typeContext instead of "" but late binding * of parameters is not yet supported by the GraphBuilderPlugin system. */ - UnsignedWord size = WordFactory.unsigned(layoutHelper); + UnsignedWord size = Word.unsigned(layoutHelper); return allocateInstanceImpl(nonNullHub.asWord(), size, false, fillContents, emitMemoryBarrier, false, profilingData, withException); } } @@ -286,9 +285,9 @@ protected Object newmultiarray(KlassPointer hub, @ConstantParameter int rank, @C private void verifyHeap() { Word tlabInfo = getTLABInfo(); Word topValue = readTlabTop(tlabInfo); - if (!topValue.equal(WordFactory.zero())) { + if (!topValue.equal(Word.zero())) { Word topValueContents = topValue.readWord(0, MARK_WORD_LOCATION); - if (topValueContents.equal(WordFactory.zero())) { + if (topValueContents.equal(Word.zero())) { AssertionSnippets.vmMessageC(VM_MESSAGE_C, true, cstring("overzeroing of TLAB detected"), 0L, 0L, 0L); } } @@ -430,7 +429,7 @@ protected final int getMinimalBulkZeroingSize() { @Override public final void initializeObjectHeader(Word memory, Word hub, boolean isArray) { KlassPointer klassPtr = KlassPointer.fromWord(hub); - Word markWord = WordFactory.signed(HotSpotReplacementsUtil.defaultPrototypeMarkWord(INJECTED_VMCONFIG)); + Word markWord = Word.signed(HotSpotReplacementsUtil.defaultPrototypeMarkWord(INJECTED_VMCONFIG)); HotSpotReplacementsUtil.initializeObjectHeader(memory, markWord, klassPtr); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotG1WriteBarrierSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotG1WriteBarrierSnippets.java index 74c3f420f5f8..1e2ff3c4d3ea 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotG1WriteBarrierSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotG1WriteBarrierSnippets.java @@ -31,7 +31,6 @@ import static jdk.graal.compiler.hotspot.meta.HotSpotForeignCallsProviderImpl.NO_LOCATIONS; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import jdk.graal.compiler.core.common.CompressEncoding; import jdk.graal.compiler.core.common.spi.ForeignCallDescriptor; @@ -125,7 +124,7 @@ protected byte youngCardValue() { @Override protected Word cardTableAddress(Pointer oop) { - Word cardTable = WordFactory.unsigned(HotSpotReplacementsUtil.cardTableStart(INJECTED_VMCONFIG)); + Word cardTable = Word.unsigned(HotSpotReplacementsUtil.cardTableStart(INJECTED_VMCONFIG)); int cardTableShift = HotSpotReplacementsUtil.cardTableShift(INJECTED_VMCONFIG); return cardTable.add(oop.unsignedShiftRight(cardTableShift)); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotHashCodeSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotHashCodeSnippets.java index a189bd20eb7f..53244374f8fe 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotHashCodeSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotHashCodeSnippets.java @@ -40,8 +40,6 @@ import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.FAST_PATH_PROBABILITY; import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.probability; -import jdk.graal.compiler.word.WordFactory; - import jdk.graal.compiler.lir.SyncPort; import jdk.graal.compiler.replacements.IdentityHashCodeSnippets; import jdk.graal.compiler.word.Word; @@ -76,10 +74,10 @@ protected int computeIdentityHashCode(final Object x) { // unlocked, i.e., lock bits equals to 0b01. // // See src/hotspot/share/oops/markWord.hpp for more details. - final Word lockBits = mark.and(WordFactory.unsigned(markWordLockMaskInPlace(INJECTED_VMCONFIG))); + final Word lockBits = mark.and(Word.unsigned(markWordLockMaskInPlace(INJECTED_VMCONFIG))); if (useObjectMonitorTable(INJECTED_VMCONFIG) || probability(FAST_PATH_PROBABILITY, - useLightweightLocking(INJECTED_VMCONFIG) ? lockBits.notEqual(WordFactory.unsigned(monitorValue(INJECTED_VMCONFIG))) - : lockBits.equal(WordFactory.unsigned(unlockedValue(INJECTED_VMCONFIG))))) { + useLightweightLocking(INJECTED_VMCONFIG) ? lockBits.notEqual(Word.unsigned(monitorValue(INJECTED_VMCONFIG))) + : lockBits.equal(Word.unsigned(unlockedValue(INJECTED_VMCONFIG))))) { // `& markWord::hash_mask' is essential with -XX:+UseCompactObjectHeaders, because bit // 42 might be set. int hash = (int) mark.unsignedShiftRight(markWordHashCodeShift(INJECTED_VMCONFIG)).and((int) markWordHashMark(INJECTED_VMCONFIG)).rawValue(); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotReplacementsUtil.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotReplacementsUtil.java index 98dc008ab121..6da8224bc695 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotReplacementsUtil.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotReplacementsUtil.java @@ -32,7 +32,6 @@ import java.lang.ref.Reference; import org.graalvm.word.LocationIdentity; -import jdk.graal.compiler.word.WordFactory; import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.api.replacements.Fold.InjectedParameter; @@ -525,7 +524,7 @@ static CompressEncoding klassEncoding(@InjectedParameter GraalHotSpotVMConfig co public static void initializeObjectHeader(Word memory, Word markWord, KlassPointer hub) { if (useCompactObjectHeaders(INJECTED_VMCONFIG)) { - Word compressedHub = WordFactory.unsigned(compress(Compress, hub, klassEncoding(INJECTED_VMCONFIG)).asInt()); + Word compressedHub = Word.unsigned(compress(Compress, hub, klassEncoding(INJECTED_VMCONFIG)).asInt()); Word hubInPlace = compressedHub.shiftLeft(markWordKlassShift(INJECTED_VMCONFIG)); Word newMarkWord = markWord.or(hubInPlace); memory.writeWord(markOffset(INJECTED_VMCONFIG), newMarkWord, MARK_WORD_LOCATION); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotSerialWriteBarrierSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotSerialWriteBarrierSnippets.java index 0b9937de800f..d192cd0ff5d7 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotSerialWriteBarrierSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotSerialWriteBarrierSnippets.java @@ -26,8 +26,6 @@ import static jdk.graal.compiler.hotspot.GraalHotSpotVMConfig.INJECTED_VMCONFIG; -import jdk.graal.compiler.word.WordFactory; - import jdk.graal.compiler.hotspot.meta.HotSpotProviders; import jdk.graal.compiler.nodes.gc.SerialArrayRangeWriteBarrierNode; import jdk.graal.compiler.nodes.gc.SerialWriteBarrierNode; @@ -47,7 +45,7 @@ public HotSpotSerialWriteBarrierSnippets() { @Override public Word cardTableAddress() { - return WordFactory.unsigned(HotSpotReplacementsUtil.cardTableStart(INJECTED_VMCONFIG)); + return Word.unsigned(HotSpotReplacementsUtil.cardTableStart(INJECTED_VMCONFIG)); } @Override diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/LoadExceptionObjectSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/LoadExceptionObjectSnippets.java index 1b5e898efd9c..152cc0152039 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/LoadExceptionObjectSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/LoadExceptionObjectSnippets.java @@ -35,8 +35,6 @@ import static jdk.graal.compiler.nodes.PiNode.piCastToSnippetReplaceeStamp; import static jdk.graal.compiler.replacements.SnippetTemplate.DEFAULT_REPLACER; -import jdk.graal.compiler.word.WordFactory; - import jdk.graal.compiler.api.replacements.Snippet; import jdk.graal.compiler.api.replacements.Snippet.ConstantParameter; import jdk.graal.compiler.core.common.type.Stamp; @@ -74,7 +72,7 @@ public static Object loadException(@ConstantParameter Register threadRegister) { Word thread = registerAsWord(threadRegister); Object exception = readExceptionOop(thread); writeExceptionOop(thread, null); - writeExceptionPc(thread, WordFactory.zero()); + writeExceptionPc(thread, Word.zero()); return piCastToSnippetReplaceeStamp(exception); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/MonitorSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/MonitorSnippets.java index 6e944c9d97cc..3405485e374d 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/MonitorSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/MonitorSnippets.java @@ -94,9 +94,9 @@ import static jdk.graal.compiler.replacements.SnippetTemplate.DEFAULT_REPLACER; import static jdk.graal.compiler.replacements.nodes.CStringConstant.cstring; import static org.graalvm.word.LocationIdentity.any; -import static jdk.graal.compiler.word.WordFactory.nullPointer; -import static jdk.graal.compiler.word.WordFactory.unsigned; -import static jdk.graal.compiler.word.WordFactory.zero; +import static jdk.graal.compiler.word.Word.nullPointer; +import static jdk.graal.compiler.word.Word.unsigned; +import static jdk.graal.compiler.word.Word.zero; import java.util.List; import java.util.Objects; @@ -104,7 +104,6 @@ import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.api.replacements.Snippet; @@ -358,7 +357,7 @@ private static boolean tryStackLocking(Object object, Word lock, Word mark, Word if (probability(SLOW_PATH_PROBABILITY, mark.and(monitorValue(INJECTED_VMCONFIG)).notEqual(0))) { // Inflated case // Set the lock slot's displaced mark to unused. Any non-0 value suffices. - lock.writeWord(lockMetadataOffset(INJECTED_VMCONFIG), WordFactory.unsigned(unusedMark(INJECTED_VMCONFIG)), BASICLOCK_METADATA_LOCATION); + lock.writeWord(lockMetadataOffset(INJECTED_VMCONFIG), Word.unsigned(unusedMark(INJECTED_VMCONFIG)), BASICLOCK_METADATA_LOCATION); return tryEnterInflated(object, lock, mark, thread, trace, counters); } @@ -419,11 +418,11 @@ private static boolean tryStackLocking(Object object, Word lock, Word mark, Word // @formatter:on @SuppressWarnings("unused") private static boolean tryLightweightLocking(Object object, Word lock, Word mark, Word thread, boolean trace, Counters counters, Register stackPointerRegister) { - writeMonitorCache(lock, WordFactory.nullPointer()); + writeMonitorCache(lock, Word.nullPointer()); // Prefetch top // We assume `lockStackTop' is always positive and use `WordFactory.unsigned' to skip a sign // extension. - Word lockStackTop = WordFactory.unsigned(thread.readInt(javaThreadLockStackTopOffset(INJECTED_VMCONFIG), JAVA_THREAD_LOCK_STACK_TOP_LOCATION)); + Word lockStackTop = Word.unsigned(thread.readInt(javaThreadLockStackTopOffset(INJECTED_VMCONFIG), JAVA_THREAD_LOCK_STACK_TOP_LOCATION)); if (probability(SLOW_PATH_PROBABILITY, mark.and(monitorValue(INJECTED_VMCONFIG)).notEqual(0))) { // Inflated case @@ -444,7 +443,7 @@ private static boolean tryLightweightLocking(Object object, Word lock, Word mark if (probability(FAST_PATH_PROBABILITY, tryLightweightLockingHelper(object, objectPointer, mark, thread, trace, counters, lockStackTop))) { if (useObjectMonitorTable(INJECTED_VMCONFIG)) { // Need to reload top, clobbered by CAS. - lockStackTop = WordFactory.unsigned(thread.readInt(javaThreadLockStackTopOffset(INJECTED_VMCONFIG), JAVA_THREAD_LOCK_STACK_TOP_LOCATION)); + lockStackTop = Word.unsigned(thread.readInt(javaThreadLockStackTopOffset(INJECTED_VMCONFIG), JAVA_THREAD_LOCK_STACK_TOP_LOCATION)); } // Push object to lock-stack. // Here we don't re-read LockStack::_top as it is thread-local data. @@ -549,7 +548,7 @@ private static boolean tryStackUnlocking(Object object, Word thread, Word lock, // @formatter:on private static boolean tryLightweightUnlocking(Object object, Word thread, Word lock, boolean trace, Counters counters) { // Load top - Word lockStackTop = WordFactory.unsigned(thread.readInt(javaThreadLockStackTopOffset(INJECTED_VMCONFIG), JAVA_THREAD_LOCK_STACK_TOP_LOCATION)); + Word lockStackTop = Word.unsigned(thread.readInt(javaThreadLockStackTopOffset(INJECTED_VMCONFIG), JAVA_THREAD_LOCK_STACK_TOP_LOCATION)); Word newLockStackTop = lockStackTop.add(-wordSize()); // Prefetch mark @@ -572,7 +571,7 @@ private static boolean tryLightweightUnlocking(Object object, Word thread, Word // Pop lock-stack. if (isCAssertEnabled(INJECTED_VMCONFIG)) { - thread.writeWord(newLockStackTop, WordFactory.zero(), JAVA_THREAD_LOCK_STACK_LOCATION); + thread.writeWord(newLockStackTop, Word.zero(), JAVA_THREAD_LOCK_STACK_LOCATION); } thread.writeInt(javaThreadLockStackTopOffset(INJECTED_VMCONFIG), (int) newLockStackTop.rawValue(), JAVA_THREAD_LOCK_STACK_TOP_LOCATION); @@ -586,7 +585,7 @@ private static boolean tryLightweightUnlocking(Object object, Word thread, Word // We elide the monitor check, let the CAS fail instead. // Try to unlock. Transition lock bits 0b00 => 0b01 - Word markLocked = mark.and(WordFactory.unsigned(~markWordLockMaskInPlace(INJECTED_VMCONFIG))); + Word markLocked = mark.and(Word.unsigned(~markWordLockMaskInPlace(INJECTED_VMCONFIG))); Word markUnlocked = mark.or(unlockedValue(INJECTED_VMCONFIG)); if (probability(FAST_PATH_PROBABILITY, objectPointer.logicCompareAndSwapWord(markOffset(INJECTED_VMCONFIG), markLocked, markUnlocked, MARK_WORD_LOCATION))) { traceObject(trace, "-lock{lightweight:cas}", object, false); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/UnsafeSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/UnsafeSnippets.java index f60eef582614..618e4c903f37 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/UnsafeSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/UnsafeSnippets.java @@ -28,7 +28,6 @@ import static jdk.graal.compiler.replacements.SnippetTemplate.DEFAULT_REPLACER; import org.graalvm.word.LocationIdentity; -import jdk.graal.compiler.word.WordFactory; import jdk.graal.compiler.api.replacements.Snippet; import jdk.graal.compiler.hotspot.HotSpotBackend; @@ -50,9 +49,9 @@ public class UnsafeSnippets implements Snippets { @SuppressWarnings("unused") @Snippet static void copyMemory(Object receiver, Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes) { - Word srcAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(srcBase, srcOffset)); - Word dstAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(destBase, destOffset)); - Word size = WordFactory.signed(bytes); + Word srcAddr = Word.unsigned(ComputeObjectAddressNode.get(srcBase, srcOffset)); + Word dstAddr = Word.unsigned(ComputeObjectAddressNode.get(destBase, destOffset)); + Word size = Word.signed(bytes); Word javaThread = CurrentJavaThreadNode.get(); int offset = HotSpotReplacementsUtil.doingUnsafeAccessOffset(INJECTED_VMCONFIG); LocationIdentity any = LocationIdentity.any(); @@ -67,8 +66,8 @@ static void copyMemory(Object receiver, Object srcBase, long srcOffset, Object d @SuppressWarnings("unused") @Snippet static void setMemory(Object receiver, Object objBase, long objOffset, long bytes, byte value) { - Word objAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(objBase, objOffset)); - Word size = WordFactory.signed(bytes); + Word objAddr = Word.unsigned(ComputeObjectAddressNode.get(objBase, objOffset)); + Word size = Word.signed(bytes); Word javaThread = CurrentJavaThreadNode.get(); int offset = HotSpotReplacementsUtil.doingUnsafeAccessOffset(INJECTED_VMCONFIG); LocationIdentity any = LocationIdentity.any(); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/arraycopy/HotSpotArraycopySnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/arraycopy/HotSpotArraycopySnippets.java index 40e6387adc77..12161ee4b3a3 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/arraycopy/HotSpotArraycopySnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/arraycopy/HotSpotArraycopySnippets.java @@ -39,7 +39,6 @@ import jdk.graal.compiler.replacements.arraycopy.ArrayCopySnippets; import jdk.graal.compiler.word.Word; import org.graalvm.word.LocationIdentity; -import jdk.graal.compiler.word.WordFactory; import jdk.vm.ci.meta.JavaKind; @@ -53,7 +52,7 @@ public boolean hubsEqual(Object nonNullSrc, Object nonNullDest) { } Word getSuperCheckOffset(KlassPointer destElemKlass) { - return WordFactory.signed(destElemKlass.readInt(HotSpotReplacementsUtil.superCheckOffsetOffset(INJECTED_VMCONFIG), HotSpotReplacementsUtil.KLASS_SUPER_CHECK_OFFSET_LOCATION)); + return Word.signed(destElemKlass.readInt(HotSpotReplacementsUtil.superCheckOffsetOffset(INJECTED_VMCONFIG), HotSpotReplacementsUtil.KLASS_SUPER_CHECK_OFFSET_LOCATION)); } @Override diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/CreateExceptionStub.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/CreateExceptionStub.java index 03e7b0c4850d..3173f5825d64 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/CreateExceptionStub.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/CreateExceptionStub.java @@ -29,8 +29,6 @@ import static jdk.vm.ci.hotspot.HotSpotCallingConventionType.NativeCall; import static org.graalvm.word.LocationIdentity.any; -import jdk.graal.compiler.word.WordFactory; - import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.core.common.spi.ForeignCallDescriptor; import jdk.graal.compiler.graph.Node.ConstantNodeParameter; @@ -86,7 +84,7 @@ private static Word classAsCString(Class cls) { } protected static Object createException(Register threadRegister, Class exception) { - Word message = WordFactory.zero(); + Word message = Word.zero(); return createException(threadRegister, exception, message); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/ExceptionHandlerStub.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/ExceptionHandlerStub.java index 6e2990657aba..a063887d86ec 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/ExceptionHandlerStub.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/ExceptionHandlerStub.java @@ -33,8 +33,6 @@ import static jdk.graal.compiler.hotspot.stubs.StubUtil.printf; import static org.graalvm.word.LocationIdentity.any; -import jdk.graal.compiler.word.WordFactory; - import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.api.replacements.Fold.InjectedParameter; import jdk.graal.compiler.api.replacements.Snippet; @@ -120,7 +118,7 @@ static void checkNoExceptionInThread(Word thread, boolean enabled) { // This thread-local is only cleared in DEBUG builds of the VM // (see OptoRuntime::generate_exception_blob) Word currentExceptionPc = HotSpotReplacementsUtil.readExceptionPc(thread); - if (currentExceptionPc.notEqual(WordFactory.zero())) { + if (currentExceptionPc.notEqual(Word.zero())) { fatal("exception PC in thread must be zero, not %p", currentExceptionPc.rawValue()); } } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/ForeignCallSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/ForeignCallSnippets.java index 158dd883744e..8787bedc509a 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/ForeignCallSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/ForeignCallSnippets.java @@ -29,7 +29,6 @@ import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.api.replacements.Fold.InjectedParameter; @@ -85,15 +84,15 @@ public static void handlePendingException(Word thread, boolean shouldClearExcept @Snippet(allowMissingProbabilities = true) public static Object verifyObject(Object object) { if (HotSpotReplacementsUtil.verifyOops(GraalHotSpotVMConfig.INJECTED_VMCONFIG)) { - Word verifyOopCounter = WordFactory.unsigned(HotSpotReplacementsUtil.verifyOopCounterAddress(GraalHotSpotVMConfig.INJECTED_VMCONFIG)); + Word verifyOopCounter = Word.unsigned(HotSpotReplacementsUtil.verifyOopCounterAddress(GraalHotSpotVMConfig.INJECTED_VMCONFIG)); verifyOopCounter.writeInt(0, verifyOopCounter.readInt(0) + 1); Pointer oop = Word.objectToTrackedPointer(object); if (object != null) { GuardingNode anchorNode = SnippetAnchorNode.anchor(); // make sure object is 'reasonable' - if (!oop.and(WordFactory.unsigned(HotSpotReplacementsUtil.verifyOopMask(GraalHotSpotVMConfig.INJECTED_VMCONFIG))).equal( - WordFactory.unsigned(HotSpotReplacementsUtil.verifyOopBits(GraalHotSpotVMConfig.INJECTED_VMCONFIG)))) { + if (!oop.and(Word.unsigned(HotSpotReplacementsUtil.verifyOopMask(GraalHotSpotVMConfig.INJECTED_VMCONFIG))).equal( + Word.unsigned(HotSpotReplacementsUtil.verifyOopBits(GraalHotSpotVMConfig.INJECTED_VMCONFIG)))) { fatal("oop not in heap: %p", oop.rawValue()); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/LookUpSecondarySupersTableStub.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/LookUpSecondarySupersTableStub.java index 4291474d294b..2dea7c6a620c 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/LookUpSecondarySupersTableStub.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/LookUpSecondarySupersTableStub.java @@ -32,8 +32,6 @@ import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.NOT_LIKELY_PROBABILITY; import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.probability; -import jdk.graal.compiler.word.WordFactory; - import jdk.graal.compiler.api.replacements.Snippet; import jdk.graal.compiler.core.common.spi.ForeignCallDescriptor; import jdk.graal.compiler.graph.Node.ConstantNodeParameter; @@ -105,7 +103,7 @@ private static boolean lookupSecondarySupersTableSlowPath(KlassPointer t, Word s } public static KlassPointer loadSecondarySupersElement(Word metaspaceArray, long index) { - return KlassPointer.fromWord(metaspaceArray.readWord(WordFactory.signed(HotSpotReplacementsUtil.metaspaceArrayBaseOffset(INJECTED_VMCONFIG) + index * HotSpotReplacementsUtil.wordSize()), + return KlassPointer.fromWord(metaspaceArray.readWord(Word.signed(HotSpotReplacementsUtil.metaspaceArrayBaseOffset(INJECTED_VMCONFIG) + index * HotSpotReplacementsUtil.wordSize()), HotSpotReplacementsUtil.SECONDARY_SUPERS_ELEMENT_LOCATION)); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/StubUtil.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/StubUtil.java index 1d1ced2c89cf..c2d4a0663b1e 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/StubUtil.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/stubs/StubUtil.java @@ -45,7 +45,6 @@ import jdk.graal.compiler.hotspot.replacements.Log; import jdk.graal.compiler.word.Word; import org.graalvm.word.LocationIdentity; -import jdk.graal.compiler.word.WordFactory; //JaCoCo Exclude @@ -159,7 +158,7 @@ public static void printf(String format, long v1, long v2, long v3) { * Analyzes a given value and prints information about it to the log stream. */ public static void decipher(long value) { - vmMessageC(VM_MESSAGE_C, false, WordFactory.zero(), value, 0L, 0L); + vmMessageC(VM_MESSAGE_C, false, Word.zero(), value, 0L, 0L); } /** diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/AllocationSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/AllocationSnippets.java index d7409c7b889e..7c942f9fff61 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/AllocationSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/AllocationSnippets.java @@ -33,7 +33,6 @@ import org.graalvm.word.LocationIdentity; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import jdk.graal.compiler.nodes.PrefetchAllocateNode; import jdk.graal.compiler.nodes.extended.MembarNode; @@ -121,7 +120,7 @@ protected Object newMultiArrayImpl(Word hub, int rank, boolean withException, in protected UnsignedWord arrayAllocationSize(int length, int arrayBaseOffset, int log2ElementSize) { int alignment = objectAlignment(); - return WordFactory.unsigned(arrayAllocationSize(length, arrayBaseOffset, log2ElementSize, alignment)); + return Word.unsigned(arrayAllocationSize(length, arrayBaseOffset, log2ElementSize, alignment)); } public static long arrayAllocationSize(int length, int arrayBaseOffset, int log2ElementSize, int alignment) { @@ -173,7 +172,7 @@ private void fillMemory(long value, boolean supportsOptimizedFilling, AllocationSnippetCounters snippetCounters) { ReplacementsUtil.dynamicAssert(endOffset.and(0x7).equal(0), "unaligned object size"); - UnsignedWord offset = WordFactory.unsigned(startOffset); + UnsignedWord offset = Word.unsigned(startOffset); if (probability(SLOW_PATH_PROBABILITY, offset.and(0x7).notEqual(0))) { memory.writeInt(offset, (int) value, LocationIdentity.init()); offset = offset.add(4); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/BigIntegerSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/BigIntegerSnippets.java index 5295b79e2893..9281fb0f2362 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/BigIntegerSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/BigIntegerSnippets.java @@ -30,7 +30,6 @@ import jdk.graal.compiler.phases.util.Providers; import jdk.graal.compiler.replacements.nodes.BigIntegerMultiplyToLenNode; import jdk.graal.compiler.word.Word; -import jdk.graal.compiler.word.WordFactory; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.MetaAccessProvider; @@ -67,6 +66,6 @@ public static int[] implMultiplyToLen(int[] x, int xlen, int[] y, int ylen, int[ } private static Word arrayStart(int[] a) { - return WordFactory.unsigned(ComputeObjectAddressNode.get(a, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Int))); + return Word.unsigned(ComputeObjectAddressNode.get(a, ReplacementsUtil.getArrayBaseOffset(INJECTED_METAACCESS, JavaKind.Int))); } } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/gc/G1WriteBarrierSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/gc/G1WriteBarrierSnippets.java index 9b6350690389..e516ec612c07 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/gc/G1WriteBarrierSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/gc/G1WriteBarrierSnippets.java @@ -31,7 +31,6 @@ import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import jdk.graal.compiler.api.directives.GraalDirectives; import jdk.graal.compiler.api.replacements.Snippet; @@ -127,7 +126,7 @@ private void satbBarrier(Address address, Object object, Object expectedObject, boolean trace = isTracingActive(traceStartCycle); int gcCycle = 0; if (trace) { - Pointer gcTotalCollectionsAddress = WordFactory.pointer(gcTotalCollectionsAddress()); + Pointer gcTotalCollectionsAddress = Word.pointer(gcTotalCollectionsAddress()); gcCycle = gcTotalCollectionsAddress.readInt(0, LocationIdentity.any()); log(trace, "[%d] G1-Pre Thread %p Object %p\n", gcCycle, thread.rawValue(), Word.objectToTrackedPointer(object).rawValue()); log(trace, "[%d] G1-Pre Thread %p Expected Object %p\n", gcCycle, thread.rawValue(), Word.objectToTrackedPointer(expectedObject).rawValue()); @@ -195,7 +194,7 @@ public void g1PostWriteBarrier(Address address, Object object, Object value, @Co boolean trace = isTracingActive(traceStartCycle); int gcCycle = 0; if (trace) { - Pointer gcTotalCollectionsAddress = WordFactory.pointer(gcTotalCollectionsAddress()); + Pointer gcTotalCollectionsAddress = Word.pointer(gcTotalCollectionsAddress()); gcCycle = gcTotalCollectionsAddress.readInt(0, LocationIdentity.any()); log(trace, "[%d] G1-Post Thread: %p Object: %p\n", gcCycle, thread.rawValue(), Word.objectToTrackedPointer(object).rawValue()); log(trace, "[%d] G1-Post Thread: %p Field: %p\n", gcCycle, thread.rawValue(), oop.rawValue()); @@ -223,7 +222,7 @@ public void g1PostWriteBarrier(Address address, Object object, Object value, @Co MembarNode.memoryBarrier(MembarNode.FenceKind.STORE_LOAD, GC_CARD_LOCATION); byte cardByteReload = cardAddress.readByte(0, GC_CARD_LOCATION); if (probability(NOT_FREQUENT_PROBABILITY, cardByteReload != dirtyCardValue())) { - log(trace, "[%d] G1-Post Thread: %p Card: %p \n", gcCycle, thread.rawValue(), WordFactory.unsigned((int) cardByte).rawValue()); + log(trace, "[%d] G1-Post Thread: %p Card: %p \n", gcCycle, thread.rawValue(), Word.unsigned((int) cardByte).rawValue()); cardAddress.writeByte(0, dirtyCardValue(), GC_CARD_LOCATION); counters.g1ExecutedPostWriteBarrierCounter.inc(); @@ -263,16 +262,16 @@ public void g1ArrayRangePreWriteBarrier(Address address, long length, @ConstantP Word start = getPointerToFirstArrayElement(address, length, elementStride); for (int i = 0; GraalDirectives.injectIterationCount(10, i < length); i++) { - Word arrElemPtr = start.add(WordFactory.unsigned(i * scale)); + Word arrElemPtr = start.add(Word.unsigned(i * scale)); Object previousObject = arrElemPtr.readObject(0, BarrierType.NONE, LocationIdentity.any()); verifyOop(previousObject); if (probability(FREQUENT_PROBABILITY, previousObject != null)) { if (probability(FREQUENT_PROBABILITY, indexValue != 0)) { indexValue = indexValue - wordSize(); - Word logAddress = bufferAddress.add(WordFactory.unsigned(indexValue)); + Word logAddress = bufferAddress.add(Word.unsigned(indexValue)); // Log the object to be marked and update the SATB's buffer next index. logAddress.writeWord(0, Word.objectToTrackedPointer(previousObject), SATB_QUEUE_LOG_LOCATION); - indexAddress.writeWord(0, WordFactory.unsigned(indexValue), SATB_QUEUE_INDEX_LOCATION); + indexAddress.writeWord(0, Word.unsigned(indexValue), SATB_QUEUE_INDEX_LOCATION); } else { g1PreBarrierStub(previousObject); } @@ -307,11 +306,11 @@ public void g1ArrayRangePostWriteBarrier(Address address, long length, @Constant // initialize a new one and add the card entry. if (probability(FREQUENT_PROBABILITY, indexValue != 0)) { indexValue = indexValue - wordSize(); - Word logAddress = bufferAddress.add(WordFactory.unsigned(indexValue)); + Word logAddress = bufferAddress.add(Word.unsigned(indexValue)); // Log the object to be scanned as well as update // the card queue's next index. logAddress.writeWord(0, cur, CARD_QUEUE_LOG_LOCATION); - indexAddress.writeWord(0, WordFactory.unsigned(indexValue), CARD_QUEUE_INDEX_LOCATION); + indexAddress.writeWord(0, Word.unsigned(indexValue), CARD_QUEUE_INDEX_LOCATION); } else { g1PostBarrierStub(cur); } @@ -366,7 +365,7 @@ public void g1ArrayRangePostWriteBarrier(Address address, long length, @Constant protected abstract ForeignCallDescriptor printfCallDescriptor(); protected boolean isTracingActive(int traceStartCycle) { - return traceStartCycle > 0 && ((Pointer) WordFactory.pointer(gcTotalCollectionsAddress())).readInt(0) > traceStartCycle; + return traceStartCycle > 0 && ((Pointer) Word.pointer(gcTotalCollectionsAddress())).readInt(0) > traceStartCycle; } private void log(boolean enabled, String format, long value1, long value2, long value3) { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/gc/WriteBarrierSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/gc/WriteBarrierSnippets.java index dddbcffd9225..a227e09e48b4 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/gc/WriteBarrierSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/gc/WriteBarrierSnippets.java @@ -35,7 +35,6 @@ import jdk.graal.compiler.replacements.nodes.AssertionNode; import jdk.graal.compiler.word.Word; import org.graalvm.word.LocationIdentity; -import jdk.graal.compiler.word.WordFactory; public abstract class WriteBarrierSnippets { public static final LocationIdentity GC_CARD_LOCATION = NamedLocationIdentity.mutable("GC-Card"); @@ -53,7 +52,7 @@ protected static Word getPointerToFirstArrayElement(Address address, long length // the address points to the place after the last array element result = result + elementStride * length; } - return WordFactory.unsigned(result); + return Word.unsigned(result); } protected static Word getPointerToLastArrayElement(Address address, long length, int elementStride) { @@ -64,6 +63,6 @@ protected static Word getPointerToLastArrayElement(Address address, long length, } else { result = result + (length - 1) * elementStride; } - return WordFactory.unsigned(result); + return Word.unsigned(result); } } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/word/Word.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/word/Word.java index ee3fb36c7db8..0436883335e7 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/word/Word.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/word/Word.java @@ -32,6 +32,7 @@ import org.graalvm.word.ComparableWord; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; +import org.graalvm.word.PointerBase; import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; @@ -56,11 +57,79 @@ import jdk.graal.compiler.nodes.calc.XorNode; import jdk.graal.compiler.nodes.memory.address.AddressNode.Address; import jdk.internal.misc.Unsafe; - +import org.graalvm.word.WordFactory; +import org.graalvm.word.impl.WordFactoryOpcode; +import org.graalvm.word.impl.WordFactoryOperation; + +/** + * This is the compiler-specific implementation and extension of the word types declared in + * {@code org.graalvm.word}. It includes factory methods to create boxed word values that should be + * used instead of the methods with the same signature in {@link WordFactory}. + */ public abstract class Word implements SignedWord, UnsignedWord, Pointer { private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + /** + * @see org.graalvm.word.WordFactory#zero() + */ + @WordFactoryOperation(opcode = WordFactoryOpcode.ZERO) + public static T zero() { + return box(0L); + } + + /** + * @see org.graalvm.word.WordFactory#nullPointer() + */ + @WordFactoryOperation(opcode = WordFactoryOpcode.ZERO) + public static T nullPointer() { + return box(0L); + } + + /** + * In an execution environment where this method returns a boxed value (e.g. not in Native + * Image), the returned value supports all of the {@link Pointer} memory access operations + * (i.e., read, write, compare-and-swap etc.) through use of {@link Unsafe}. + * + * @see org.graalvm.word.WordFactory#pointer(long) + */ + @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_UNSIGNED) + public static T pointer(long val) { + return box(val); + } + + /** + * @see org.graalvm.word.WordFactory#unsigned(int) + */ + @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_UNSIGNED) + public static T unsigned(int val) { + return box(val & 0xffffffffL); + } + + /** + * @see org.graalvm.word.WordFactory#unsigned(long) + */ + @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_UNSIGNED) + public static T unsigned(long val) { + return box(val); + } + + /** + * @see org.graalvm.word.WordFactory#signed(int) + */ + @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_SIGNED) + public static T signed(int val) { + return box(val); + } + + /** + * @see org.graalvm.word.WordFactory#signed(long) + */ + @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_SIGNED) + public static T signed(long val) { + return box(val); + } + /** * Links a method to a canonical operation represented by an {@link Opcode} val. */ @@ -442,13 +511,13 @@ public Word not() { @Override @Operation(opcode = Opcode.IS_NULL) public boolean isNull() { - return equal(WordFactory.zero()); + return equal(zero()); } @Override @Operation(opcode = Opcode.IS_NON_NULL) public boolean isNonNull() { - return notEqual(WordFactory.zero()); + return notEqual(zero()); } @Override @@ -648,49 +717,49 @@ public boolean aboveOrEqual(Word val) { @Override @Operation(opcode = Opcode.READ_POINTER) public byte readByte(WordBase offset, LocationIdentity locationIdentity) { - return UNSAFE.getByte(add((Word) offset).unbox()); + return UNSAFE.getByte(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public char readChar(WordBase offset, LocationIdentity locationIdentity) { - return UNSAFE.getChar(add((Word) offset).unbox()); + return UNSAFE.getChar(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public short readShort(WordBase offset, LocationIdentity locationIdentity) { - return UNSAFE.getShort(add((Word) offset).unbox()); + return UNSAFE.getShort(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public int readInt(WordBase offset, LocationIdentity locationIdentity) { - return UNSAFE.getInt(add((Word) offset).unbox()); + return UNSAFE.getInt(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public long readLong(WordBase offset, LocationIdentity locationIdentity) { - return UNSAFE.getLong(add((Word) offset).unbox()); + return UNSAFE.getLong(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public float readFloat(WordBase offset, LocationIdentity locationIdentity) { - return UNSAFE.getFloat(add((Word) offset).unbox()); + return UNSAFE.getFloat(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public double readDouble(WordBase offset, LocationIdentity locationIdentity) { - return UNSAFE.getDouble(add((Word) offset).unbox()); + return UNSAFE.getDouble(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public T readWord(WordBase offset, LocationIdentity locationIdentity) { - return box(UNSAFE.getAddress(add((Word) offset).unbox())); + return box(UNSAFE.getAddress(add(cast(offset)).unbox())); } @Override @@ -700,55 +769,55 @@ public T readWord(WordBase offset, LocationIdentity locatio @Override @Operation(opcode = Opcode.READ_POINTER) public byte readByte(int offset, LocationIdentity locationIdentity) { - return readByte(WordFactory.signed(offset), locationIdentity); + return readByte(signed(offset), locationIdentity); } @Override @Operation(opcode = Opcode.READ_POINTER) public char readChar(int offset, LocationIdentity locationIdentity) { - return readChar(WordFactory.signed(offset), locationIdentity); + return readChar(signed(offset), locationIdentity); } @Override @Operation(opcode = Opcode.READ_POINTER) public short readShort(int offset, LocationIdentity locationIdentity) { - return readShort(WordFactory.signed(offset), locationIdentity); + return readShort(signed(offset), locationIdentity); } @Override @Operation(opcode = Opcode.READ_POINTER) public int readInt(int offset, LocationIdentity locationIdentity) { - return readInt(WordFactory.signed(offset), locationIdentity); + return readInt(signed(offset), locationIdentity); } @Override @Operation(opcode = Opcode.READ_POINTER) public long readLong(int offset, LocationIdentity locationIdentity) { - return readLong(WordFactory.signed(offset), locationIdentity); + return readLong(signed(offset), locationIdentity); } @Override @Operation(opcode = Opcode.READ_POINTER) public float readFloat(int offset, LocationIdentity locationIdentity) { - return readFloat(WordFactory.signed(offset), locationIdentity); + return readFloat(signed(offset), locationIdentity); } @Override @Operation(opcode = Opcode.READ_POINTER) public double readDouble(int offset, LocationIdentity locationIdentity) { - return readDouble(WordFactory.signed(offset), locationIdentity); + return readDouble(signed(offset), locationIdentity); } @Override @Operation(opcode = Opcode.READ_POINTER) public T readWord(int offset, LocationIdentity locationIdentity) { - return readWord(WordFactory.signed(offset), locationIdentity); + return readWord(signed(offset), locationIdentity); } @Override @Operation(opcode = Opcode.READ_POINTER) public Object readObject(int offset, LocationIdentity locationIdentity) { - return readObject(WordFactory.signed(offset), locationIdentity); + return readObject(signed(offset), locationIdentity); } @Override @@ -758,55 +827,55 @@ public Object readObject(int offset, LocationIdentity locationIdentity) { @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeByte(WordBase offset, byte val, LocationIdentity locationIdentity) { - UNSAFE.putByte(add((Word) offset).unbox(), val); + UNSAFE.putByte(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeChar(WordBase offset, char val, LocationIdentity locationIdentity) { - UNSAFE.putChar(add((Word) offset).unbox(), val); + UNSAFE.putChar(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeShort(WordBase offset, short val, LocationIdentity locationIdentity) { - UNSAFE.putShort(add((Word) offset).unbox(), val); + UNSAFE.putShort(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeInt(WordBase offset, int val, LocationIdentity locationIdentity) { - UNSAFE.putInt(add((Word) offset).unbox(), val); + UNSAFE.putInt(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeLong(WordBase offset, long val, LocationIdentity locationIdentity) { - UNSAFE.putLong(add((Word) offset).unbox(), val); + UNSAFE.putLong(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeFloat(WordBase offset, float val, LocationIdentity locationIdentity) { - UNSAFE.putFloat(add((Word) offset).unbox(), val); + UNSAFE.putFloat(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeDouble(WordBase offset, double val, LocationIdentity locationIdentity) { - UNSAFE.putDouble(add((Word) offset).unbox(), val); + UNSAFE.putDouble(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeWord(WordBase offset, WordBase val, LocationIdentity locationIdentity) { - UNSAFE.putAddress(add((Word) offset).unbox(), (cast(val)).unbox()); + UNSAFE.putAddress(add(cast(offset)).unbox(), (cast(val)).unbox()); } @Override @Operation(opcode = Opcode.INITIALIZE) public void initializeLong(WordBase offset, long val, LocationIdentity locationIdentity) { - UNSAFE.putLong(add((Word) offset).unbox(), val); + UNSAFE.putLong(add(cast(offset)).unbox(), val); } @Override @@ -816,109 +885,109 @@ public void initializeLong(WordBase offset, long val, LocationIdentity locationI @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeByte(int offset, byte val, LocationIdentity locationIdentity) { - writeByte(WordFactory.signed(offset), val, locationIdentity); + writeByte(signed(offset), val, locationIdentity); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeChar(int offset, char val, LocationIdentity locationIdentity) { - writeChar(WordFactory.signed(offset), val, locationIdentity); + writeChar(signed(offset), val, locationIdentity); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeShort(int offset, short val, LocationIdentity locationIdentity) { - writeShort(WordFactory.signed(offset), val, locationIdentity); + writeShort(signed(offset), val, locationIdentity); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeInt(int offset, int val, LocationIdentity locationIdentity) { - writeInt(WordFactory.signed(offset), val, locationIdentity); + writeInt(signed(offset), val, locationIdentity); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeLong(int offset, long val, LocationIdentity locationIdentity) { - writeLong(WordFactory.signed(offset), val, locationIdentity); + writeLong(signed(offset), val, locationIdentity); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeFloat(int offset, float val, LocationIdentity locationIdentity) { - writeFloat(WordFactory.signed(offset), val, locationIdentity); + writeFloat(signed(offset), val, locationIdentity); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeDouble(int offset, double val, LocationIdentity locationIdentity) { - writeDouble(WordFactory.signed(offset), val, locationIdentity); + writeDouble(signed(offset), val, locationIdentity); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeWord(int offset, WordBase val, LocationIdentity locationIdentity) { - writeWord(WordFactory.signed(offset), val, locationIdentity); + writeWord(signed(offset), val, locationIdentity); } @Override @Operation(opcode = Opcode.INITIALIZE) public void initializeLong(int offset, long val, LocationIdentity locationIdentity) { - initializeLong(WordFactory.signed(offset), val, locationIdentity); + initializeLong(signed(offset), val, locationIdentity); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeObject(int offset, Object val, LocationIdentity locationIdentity) { - writeObject(WordFactory.signed(offset), val, locationIdentity); + writeObject(signed(offset), val, locationIdentity); } @Override @Operation(opcode = Opcode.READ_POINTER) public byte readByte(WordBase offset) { - return UNSAFE.getByte(add((Word) offset).unbox()); + return UNSAFE.getByte(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public char readChar(WordBase offset) { - return UNSAFE.getChar(add((Word) offset).unbox()); + return UNSAFE.getChar(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public short readShort(WordBase offset) { - return UNSAFE.getShort(add((Word) offset).unbox()); + return UNSAFE.getShort(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public int readInt(WordBase offset) { - return UNSAFE.getInt(add((Word) offset).unbox()); + return UNSAFE.getInt(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public long readLong(WordBase offset) { - return UNSAFE.getLong(add((Word) offset).unbox()); + return UNSAFE.getLong(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public float readFloat(WordBase offset) { - return UNSAFE.getFloat(add((Word) offset).unbox()); + return UNSAFE.getFloat(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public double readDouble(WordBase offset) { - return UNSAFE.getDouble(add((Word) offset).unbox()); + return UNSAFE.getDouble(add(cast(offset)).unbox()); } @Override @Operation(opcode = Opcode.READ_POINTER) public T readWord(WordBase offset) { - return box(UNSAFE.getAddress(add((Word) offset).unbox())); + return box(UNSAFE.getAddress(add(cast(offset)).unbox())); } @Override @@ -934,107 +1003,107 @@ public T readWord(WordBase offset) { @Override @Operation(opcode = Opcode.READ_POINTER) public byte readByte(int offset) { - return readByte(WordFactory.signed(offset)); + return readByte(signed(offset)); } @Override @Operation(opcode = Opcode.READ_POINTER) public char readChar(int offset) { - return readChar(WordFactory.signed(offset)); + return readChar(signed(offset)); } @Override @Operation(opcode = Opcode.READ_POINTER) public short readShort(int offset) { - return readShort(WordFactory.signed(offset)); + return readShort(signed(offset)); } @Override @Operation(opcode = Opcode.READ_POINTER) public int readInt(int offset) { - return readInt(WordFactory.signed(offset)); + return readInt(signed(offset)); } @Override @Operation(opcode = Opcode.READ_POINTER) public long readLong(int offset) { - return readLong(WordFactory.signed(offset)); + return readLong(signed(offset)); } @Override @Operation(opcode = Opcode.READ_POINTER) public float readFloat(int offset) { - return readFloat(WordFactory.signed(offset)); + return readFloat(signed(offset)); } @Override @Operation(opcode = Opcode.READ_POINTER) public double readDouble(int offset) { - return readDouble(WordFactory.signed(offset)); + return readDouble(signed(offset)); } @Override @Operation(opcode = Opcode.READ_POINTER) public T readWord(int offset) { - return readWord(WordFactory.signed(offset)); + return readWord(signed(offset)); } @Override @Operation(opcode = Opcode.READ_POINTER) public Object readObject(int offset) { - return readObject(WordFactory.signed(offset)); + return readObject(signed(offset)); } @Operation(opcode = Opcode.READ_HEAP) public Object readObject(int offset, BarrierType barrierType) { - return readObject(WordFactory.signed(offset), barrierType); + return readObject(signed(offset), barrierType); } @Operation(opcode = Opcode.READ_HEAP) public Object readObject(int offset, BarrierType barrierType, LocationIdentity locationIdentity) { - return readObject(WordFactory.signed(offset), barrierType, locationIdentity); + return readObject(signed(offset), barrierType, locationIdentity); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeByte(WordBase offset, byte val) { - UNSAFE.putByte(add((Word) offset).unbox(), val); + UNSAFE.putByte(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeChar(WordBase offset, char val) { - UNSAFE.putChar(add((Word) offset).unbox(), val); + UNSAFE.putChar(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeShort(WordBase offset, short val) { - UNSAFE.putShort(add((Word) offset).unbox(), val); + UNSAFE.putShort(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeInt(WordBase offset, int val) { - UNSAFE.putInt(add((Word) offset).unbox(), val); + UNSAFE.putInt(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeLong(WordBase offset, long val) { - UNSAFE.putLong(add((Word) offset).unbox(), val); + UNSAFE.putLong(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeFloat(WordBase offset, float val) { - UNSAFE.putFloat(add((Word) offset).unbox(), val); + UNSAFE.putFloat(add(cast(offset)).unbox(), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeDouble(WordBase offset, double val) { - UNSAFE.putDouble(add((Word) offset).unbox(), val); + UNSAFE.putDouble(add(cast(offset)).unbox(), val); } @Override @@ -1056,13 +1125,13 @@ public void writeDouble(WordBase offset, double val) { @Override @Operation(opcode = Opcode.CAS_POINTER) public boolean logicCompareAndSwapInt(WordBase offset, int expectedValue, int newValue, LocationIdentity locationIdentity) { - return UNSAFE.compareAndSetInt(this.toObject(), ((Word) offset).unbox(), expectedValue, newValue); + return UNSAFE.compareAndSetInt(this.toObject(), (cast(offset)).unbox(), expectedValue, newValue); } @Override @Operation(opcode = Opcode.CAS_POINTER) public boolean logicCompareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity) { - return UNSAFE.compareAndSetLong(this.toObject(), ((Word) offset).unbox(), expectedValue, newValue); + return UNSAFE.compareAndSetLong(this.toObject(), (cast(offset)).unbox(), expectedValue, newValue); } @Override @@ -1072,13 +1141,13 @@ public boolean logicCompareAndSwapLong(WordBase offset, long expectedValue, long @Override @Operation(opcode = Opcode.CAS_POINTER) public boolean logicCompareAndSwapObject(WordBase offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity) { - return UNSAFE.compareAndSetReference(this.toObject(), ((Word) offset).unbox(), expectedValue, newValue); + return UNSAFE.compareAndSetReference(this.toObject(), (cast(offset)).unbox(), expectedValue, newValue); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeWord(WordBase offset, WordBase val) { - UNSAFE.putAddress(add((Word) offset).unbox(), (cast(val)).unbox()); + UNSAFE.putAddress(add(cast(offset)).unbox(), (cast(val)).unbox()); } @Override @@ -1088,55 +1157,55 @@ public void writeWord(WordBase offset, WordBase val) { @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeByte(int offset, byte val) { - writeByte(WordFactory.signed(offset), val); + writeByte(signed(offset), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeChar(int offset, char val) { - writeChar(WordFactory.signed(offset), val); + writeChar(signed(offset), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeShort(int offset, short val) { - writeShort(WordFactory.signed(offset), val); + writeShort(signed(offset), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeInt(int offset, int val) { - writeInt(WordFactory.signed(offset), val); + writeInt(signed(offset), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeLong(int offset, long val) { - writeLong(WordFactory.signed(offset), val); + writeLong(signed(offset), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeFloat(int offset, float val) { - writeFloat(WordFactory.signed(offset), val); + writeFloat(signed(offset), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeDouble(int offset, double val) { - writeDouble(WordFactory.signed(offset), val); + writeDouble(signed(offset), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeWord(int offset, WordBase val) { - writeWord(WordFactory.signed(offset), val); + writeWord(signed(offset), val); } @Override @Operation(opcode = Opcode.WRITE_POINTER) public void writeObject(int offset, Object val) { - writeObject(WordFactory.signed(offset), val); + writeObject(signed(offset), val); } @Override @@ -1146,49 +1215,49 @@ public void writeObject(int offset, Object val) { @Override @Operation(opcode = Opcode.CAS_POINTER) public int compareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity) { - return compareAndSwapInt(WordFactory.signed(offset), expectedValue, newValue, locationIdentity); + return compareAndSwapInt(signed(offset), expectedValue, newValue, locationIdentity); } @Override @Operation(opcode = Opcode.CAS_POINTER) public long compareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity) { - return compareAndSwapLong(WordFactory.signed(offset), expectedValue, newValue, locationIdentity); + return compareAndSwapLong(signed(offset), expectedValue, newValue, locationIdentity); } @Override @Operation(opcode = Opcode.CAS_POINTER) public T compareAndSwapWord(int offset, T expectedValue, T newValue, LocationIdentity locationIdentity) { - return compareAndSwapWord(WordFactory.signed(offset), expectedValue, newValue, locationIdentity); + return compareAndSwapWord(signed(offset), expectedValue, newValue, locationIdentity); } @Override @Operation(opcode = Opcode.CAS_POINTER) public Object compareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity) { - return compareAndSwapObject(WordFactory.signed(offset), expectedValue, newValue, locationIdentity); + return compareAndSwapObject(signed(offset), expectedValue, newValue, locationIdentity); } @Override @Operation(opcode = Opcode.CAS_POINTER) public boolean logicCompareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity) { - return logicCompareAndSwapInt(WordFactory.signed(offset), expectedValue, newValue, locationIdentity); + return logicCompareAndSwapInt(signed(offset), expectedValue, newValue, locationIdentity); } @Override @Operation(opcode = Opcode.CAS_POINTER) public boolean logicCompareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity) { - return logicCompareAndSwapLong(WordFactory.signed(offset), expectedValue, newValue, locationIdentity); + return logicCompareAndSwapLong(signed(offset), expectedValue, newValue, locationIdentity); } @Override @Operation(opcode = Opcode.CAS_POINTER) public boolean logicCompareAndSwapWord(int offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity) { - return logicCompareAndSwapWord(WordFactory.signed(offset), expectedValue, newValue, locationIdentity); + return logicCompareAndSwapWord(signed(offset), expectedValue, newValue, locationIdentity); } @Override @Operation(opcode = Opcode.CAS_POINTER) public boolean logicCompareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity) { - return logicCompareAndSwapObject(WordFactory.signed(offset), expectedValue, newValue, locationIdentity); + return logicCompareAndSwapObject(signed(offset), expectedValue, newValue, locationIdentity); } /** diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/word/WordFactory.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/word/WordFactory.java deleted file mode 100644 index c42bc504cef4..000000000000 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/word/WordFactory.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package jdk.graal.compiler.word; - -import org.graalvm.word.PointerBase; -import org.graalvm.word.SignedWord; -import org.graalvm.word.UnsignedWord; -import org.graalvm.word.WordBase; -import org.graalvm.word.impl.WordFactoryOpcode; -import org.graalvm.word.impl.WordFactoryOperation; - -/** - * Provides factory methods to create boxed {@link WordBase} objects specific to the class loader - * loading this class. This avoids type confusion caused by using - * {@link org.graalvm.word.WordFactory} which can lead word objects specific to one class loader - * (e.g. the libgraal class loader) into code expecting word objects loaded by another class loader - * (e.g. the native image class loader). - */ -public final class WordFactory { - - private WordFactory() { - } - - @SuppressWarnings("unchecked") - private static T box(long val) { - return (T) HostedWord.boxLong(val); - } - - /** - * @see org.graalvm.word.WordFactory#zero() - */ - @WordFactoryOperation(opcode = WordFactoryOpcode.ZERO) - public static T zero() { - return box(0L); - } - - /** - * @see org.graalvm.word.WordFactory#nullPointer() - */ - @WordFactoryOperation(opcode = WordFactoryOpcode.ZERO) - public static T nullPointer() { - return box(0L); - } - - /** - * @see org.graalvm.word.WordFactory#pointer(long) - */ - @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_UNSIGNED) - public static T pointer(long val) { - return box(val); - } - - /** - * @see org.graalvm.word.WordFactory#unsigned(int) - */ - @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_UNSIGNED) - public static T unsigned(int val) { - return box(val & 0xffffffffL); - } - - /** - * @see org.graalvm.word.WordFactory#unsigned(long) - */ - @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_UNSIGNED) - public static T unsigned(long val) { - return box(val); - } - - /** - * @see org.graalvm.word.WordFactory#signed(int) - */ - @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_SIGNED) - public static T signed(int val) { - return box(val); - } - - /** - * @see org.graalvm.word.WordFactory#signed(long) - */ - @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_SIGNED) - public static T signed(long val) { - return box(val); - } -} diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/word/WordTypes.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/word/WordTypes.java index 2f3baa0ce78f..6e9e4676b336 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/word/WordTypes.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/word/WordTypes.java @@ -28,12 +28,10 @@ import jdk.graal.compiler.core.common.type.AbstractObjectStamp; import jdk.graal.compiler.core.common.type.Stamp; import jdk.graal.compiler.core.common.type.StampFactory; -import jdk.graal.compiler.debug.GraalError; import jdk.graal.compiler.graph.Node; import jdk.graal.compiler.nodes.StructuredGraph; import jdk.graal.compiler.nodes.ValueNode; import jdk.graal.compiler.nodes.type.StampTool; -import org.graalvm.nativeimage.ImageInfo; import org.graalvm.word.WordBase; import jdk.vm.ci.meta.JavaKind; @@ -43,8 +41,6 @@ import jdk.vm.ci.meta.ResolvedJavaType; import org.graalvm.word.impl.WordFactoryOperation; -import java.util.List; - /** * Encapsulates information for Java types representing raw words (as opposed to Objects). */ @@ -54,18 +50,12 @@ public class WordTypes { * Resolved type for {@link WordBase}. */ private final ResolvedJavaType wordBaseType; - private final Class wordBaseClass; /** * Resolved type for {@link Word}. */ private final ResolvedJavaType wordImplType; - /** - * Resolved type for {@link WordFactory}. - */ - private final List wordFactoryTypes; - /** * Resolved type for {@link ObjectAccess}. */ @@ -81,11 +71,7 @@ public class WordTypes { public WordTypes(MetaAccessProvider metaAccess, JavaKind wordKind) { this.wordKind = wordKind; this.wordBaseType = metaAccess.lookupJavaType(WordBase.class); - this.wordBaseClass = WordBase.class; this.wordImplType = metaAccess.lookupJavaType(Word.class); - this.wordFactoryTypes = List.of( - metaAccess.lookupJavaType(org.graalvm.word.WordFactory.class), - metaAccess.lookupJavaType(WordFactory.class)); this.objectAccessType = metaAccess.lookupJavaType(ObjectAccess.class); this.barrieredAccessType = metaAccess.lookupJavaType(BarrieredAccess.class); @@ -96,14 +82,8 @@ public WordTypes(MetaAccessProvider metaAccess, JavaKind wordKind) { * Determines if a given method denotes a word operation. */ public boolean isWordOperation(ResolvedJavaMethod targetMethod) { - final boolean isWordFactory = wordFactoryTypes.contains(targetMethod.getDeclaringClass()); - if (isWordFactory) { - return !targetMethod.isConstructor(); - } - if (ImageInfo.inImageBuildtimeCode()) { - // Can only retrieve annotations at libgraal build time - GraalError.guarantee(targetMethod.getAnnotation(WordFactoryOperation.class) == null, - "%s.wordFactoryTypes should include %s", WordTypes.class.getName(), targetMethod.getDeclaringClass().getName()); + if (targetMethod.getAnnotation(WordFactoryOperation.class) != null) { + return true; } final boolean isObjectAccess = objectAccessType.equals(targetMethod.getDeclaringClass()); @@ -149,7 +129,7 @@ public boolean isWord(JavaType type) { } public boolean isWord(Class clazz) { - return wordBaseClass.isAssignableFrom(clazz); + return WordBase.class.isAssignableFrom(clazz); } /** diff --git a/sdk/src/org.graalvm.word/src/org/graalvm/word/Word.java b/sdk/src/org.graalvm.word/src/org/graalvm/word/Word.java index 48778892e26c..d62e9b74fd6c 100644 --- a/sdk/src/org.graalvm.word/src/org/graalvm/word/Word.java +++ b/sdk/src/org.graalvm.word/src/org/graalvm/word/Word.java @@ -40,30 +40,619 @@ */ package org.graalvm.word; +import static java.lang.Long.compareUnsigned; + /** - * Unifies the {@link SignedWord}, {@link UnsignedWord} and {@link Pointer} interfaces so that - * methods with the same signature but different return types (e.g. - * {@link UnsignedWord#shiftLeft(UnsignedWord)} and {@link SignedWord#shiftLeft(UnsignedWord)}) are - * overridden by a common method that merges the return types. This a requirement for creating a - * proxy type in {@link WordFactory#box(long)}. + * A box for words that supports all operations except memory accesses (see + * {@link WordFactory#pointer(long)}). */ -interface Word extends SignedWord, UnsignedWord, Pointer { +final class Word implements SignedWord, UnsignedWord, Pointer { + + private final long rawValue; + + Word(long val) { + this.rawValue = val; + } + + @SuppressWarnings("unchecked") + static T box(long val) { + return (T) new Word(val); + } + + @Override + public native Object toObject(); + + @Override + public native T toObject(Class clazz, boolean nonNull); + + @Override + public native Object toObjectNonNull(); + + @Override + public native byte readByte(WordBase offset, LocationIdentity locationIdentity); + + @Override + public native char readChar(WordBase offset, LocationIdentity locationIdentity); + + @Override + public native short readShort(WordBase offset, LocationIdentity locationIdentity); + + @Override + public native int readInt(WordBase offset, LocationIdentity locationIdentity); + + @Override + public native long readLong(WordBase offset, LocationIdentity locationIdentity); + + @Override + public native float readFloat(WordBase offset, LocationIdentity locationIdentity); + + @Override + public native double readDouble(WordBase offset, LocationIdentity locationIdentity); + + @Override + public native T readWord(WordBase offset, LocationIdentity locationIdentity); + + @Override + public native Object readObject(WordBase offset, LocationIdentity locationIdentity); + + @Override + public native byte readByte(int offset, LocationIdentity locationIdentity); + + @Override + public native char readChar(int offset, LocationIdentity locationIdentity); + + @Override + public native short readShort(int offset, LocationIdentity locationIdentity); + + @Override + public native int readInt(int offset, LocationIdentity locationIdentity); + + @Override + public native long readLong(int offset, LocationIdentity locationIdentity); + + @Override + public native float readFloat(int offset, LocationIdentity locationIdentity); + + @Override + public native double readDouble(int offset, LocationIdentity locationIdentity); + + @Override + public native T readWord(int offset, LocationIdentity locationIdentity); + + @Override + public native Object readObject(int offset, LocationIdentity locationIdentity); + + @Override + public native T readWordVolatile(int offset, LocationIdentity locationIdentity); + + @Override + public native void writeByte(WordBase offset, byte val, LocationIdentity locationIdentity); + + @Override + public native void writeChar(WordBase offset, char val, LocationIdentity locationIdentity); + + @Override + public native void writeShort(WordBase offset, short val, LocationIdentity locationIdentity); + + @Override + public native void writeInt(WordBase offset, int val, LocationIdentity locationIdentity); + + @Override + public native void writeLong(WordBase offset, long val, LocationIdentity locationIdentity); + + @Override + public native void writeFloat(WordBase offset, float val, LocationIdentity locationIdentity); + + @Override + public native void writeDouble(WordBase offset, double val, LocationIdentity locationIdentity); + + @Override + public native void writeWord(WordBase offset, WordBase val, LocationIdentity locationIdentity); + + @Override + public void initializeLong(WordBase offset, long val, LocationIdentity locationIdentity) { + + } + + @Override + public native void writeObject(WordBase offset, Object val, LocationIdentity locationIdentity); + + @Override + public native void writeByte(int offset, byte val, LocationIdentity locationIdentity); + + @Override + public native void writeChar(int offset, char val, LocationIdentity locationIdentity); + + @Override + public native void writeShort(int offset, short val, LocationIdentity locationIdentity); + + @Override + public native void writeInt(int offset, int val, LocationIdentity locationIdentity); + + @Override + public native void writeLong(int offset, long val, LocationIdentity locationIdentity); + + @Override + public native void writeFloat(int offset, float val, LocationIdentity locationIdentity); + + @Override + public native void writeDouble(int offset, double val, LocationIdentity locationIdentity); + + @Override + public native void writeWord(int offset, WordBase val, LocationIdentity locationIdentity); + + @Override + public void initializeLong(int offset, long val, LocationIdentity locationIdentity) { + + } + + @Override + public native void writeObject(int offset, Object val, LocationIdentity locationIdentity); + + @Override + public native byte readByte(WordBase offset); + + @Override + public native char readChar(WordBase offset); + + @Override + public native short readShort(WordBase offset); + + @Override + public native int readInt(WordBase offset); + + @Override + public native long readLong(WordBase offset); + + @Override + public native float readFloat(WordBase offset); + + @Override + public native double readDouble(WordBase offset); + + @Override + public native T readWord(WordBase offset); + + @Override + public native Object readObject(WordBase offset); + + @Override + public native byte readByte(int offset); + + @Override + public native char readChar(int offset); + + @Override + public native short readShort(int offset); + + @Override + public native int readInt(int offset); + + @Override + public native long readLong(int offset); + + @Override + public native float readFloat(int offset); + + @Override + public native double readDouble(int offset); + + @Override + public native T readWord(int offset); + + @Override + public native Object readObject(int offset); + + @Override + public native void writeByte(WordBase offset, byte val); + + @Override + public native void writeChar(WordBase offset, char val); + + @Override + public native void writeShort(WordBase offset, short val); + + @Override + public native void writeInt(WordBase offset, int val); + + @Override + public native void writeLong(WordBase offset, long val); + + @Override + public native void writeFloat(WordBase offset, float val); + + @Override + public native void writeDouble(WordBase offset, double val); + + @Override + public native void writeWord(WordBase offset, WordBase val); + + @Override + public native void writeObject(WordBase offset, Object val); + + @Override + public native int compareAndSwapInt(WordBase offset, int expectedValue, int newValue, LocationIdentity locationIdentity); + + @Override + public native long compareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity); + + @Override + public native T compareAndSwapWord(WordBase offset, T expectedValue, T newValue, LocationIdentity locationIdentity); + + @Override + public native Object compareAndSwapObject(WordBase offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity); + + @Override + public boolean logicCompareAndSwapInt(WordBase offset, int expectedValue, int newValue, LocationIdentity locationIdentity) { + return false; + } + + @Override + public boolean logicCompareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity) { + return false; + } + + @Override + public boolean logicCompareAndSwapWord(WordBase offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity) { + return false; + } + + @Override + public boolean logicCompareAndSwapObject(WordBase offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity) { + return false; + } + + @Override + public native void writeByte(int offset, byte val); + + @Override + public native void writeChar(int offset, char val); + + @Override + public native void writeShort(int offset, short val); + + @Override + public native void writeInt(int offset, int val); + + @Override + public native void writeLong(int offset, long val); + + @Override + public native void writeFloat(int offset, float val); + + @Override + public native void writeDouble(int offset, double val); + + @Override + public native void writeWord(int offset, WordBase val); + + @Override + public native void writeObject(int offset, Object val); + + @Override + public native void writeWordVolatile(int offset, WordBase val); + + @Override + public native int compareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity); + + @Override + public native long compareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity); + + @Override + public native T compareAndSwapWord(int offset, T expectedValue, T newValue, LocationIdentity locationIdentity); + + @Override + public native Object compareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity); + + @Override + public native boolean logicCompareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity); + + @Override + public native boolean logicCompareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity); + + @Override + public native boolean logicCompareAndSwapWord(int offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity); + + @Override + public native boolean logicCompareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity); + + @Override + public Pointer add(UnsignedWord val) { + return box(this.rawValue + val.rawValue()); + } + + @Override + public Pointer subtract(UnsignedWord val) { + return box(this.rawValue - val.rawValue()); + } + + @Override + public UnsignedWord multiply(UnsignedWord val) { + return box(this.rawValue * val.rawValue()); + } + + @Override + public UnsignedWord unsignedDivide(UnsignedWord val) { + return box(Long.divideUnsigned(this.rawValue, val.rawValue())); + } + + @Override + public UnsignedWord unsignedRemainder(UnsignedWord val) { + return box(Long.remainderUnsigned(this.rawValue, val.rawValue())); + } + + @Override + public Pointer and(UnsignedWord val) { + return box(this.rawValue & val.rawValue()); + } + + @Override + public Pointer or(UnsignedWord val) { + return box(this.rawValue | val.rawValue()); + } + + @Override + public UnsignedWord xor(UnsignedWord val) { + return box(this.rawValue ^ val.rawValue()); + } + + @Override + public boolean isNull() { + return this.rawValue == 0; + } + + @Override + public boolean isNonNull() { + return this.rawValue != 0; + } + + @Override + public SignedWord add(SignedWord val) { + return box(this.rawValue + val.rawValue()); + } + + @Override + public SignedWord subtract(SignedWord val) { + return box(this.rawValue - val.rawValue()); + } + + @Override + public SignedWord multiply(SignedWord val) { + return box(this.rawValue * val.rawValue()); + } + + @Override + public SignedWord signedDivide(SignedWord val) { + return box(this.rawValue / val.rawValue()); + } + + @Override + public SignedWord signedRemainder(SignedWord val) { + return box(this.rawValue % val.rawValue()); + } + + @Override + public Word shiftLeft(UnsignedWord n) { + return box(this.rawValue << n.rawValue()); + } + + @Override + public UnsignedWord unsignedShiftRight(UnsignedWord n) { + return box(this.rawValue >>> n.rawValue()); + } + + @Override + public SignedWord signedShiftRight(UnsignedWord n) { + return box(this.rawValue >> n.rawValue()); + } + + @Override + public SignedWord and(SignedWord val) { + return box(this.rawValue & val.rawValue()); + } + + @Override + public SignedWord or(SignedWord val) { + return box(this.rawValue | val.rawValue()); + } + + @Override + public SignedWord xor(SignedWord val) { + return box(this.rawValue ^ val.rawValue()); + } + + @Override + public Word not() { + return box(~this.rawValue); + } + + @Override + public boolean equal(UnsignedWord val) { + return this.rawValue == val.rawValue(); + } + + @Override + public boolean notEqual(UnsignedWord val) { + return this.rawValue != val.rawValue(); + } + + @Override + public boolean belowThan(UnsignedWord val) { + return compareUnsigned(this.rawValue, val.rawValue()) < 0; + } + + @Override + public boolean belowOrEqual(UnsignedWord val) { + return compareUnsigned(this.rawValue, val.rawValue()) <= 0; + } + + @Override + public boolean aboveThan(UnsignedWord val) { + return compareUnsigned(this.rawValue, val.rawValue()) > 0; + } + + @Override + public boolean aboveOrEqual(UnsignedWord val) { + return compareUnsigned(this.rawValue, val.rawValue()) >= 0; + } + + @Override + public boolean equal(SignedWord val) { + return this.rawValue == val.rawValue(); + } + + @Override + public boolean notEqual(SignedWord val) { + return this.rawValue != val.rawValue(); + } + + @Override + public boolean lessThan(SignedWord val) { + return this.rawValue < val.rawValue(); + } + + @Override + public boolean lessOrEqual(SignedWord val) { + return this.rawValue <= val.rawValue(); + } + + @Override + public boolean greaterThan(SignedWord val) { + return this.rawValue > val.rawValue(); + } + + @Override + public boolean greaterOrEqual(SignedWord val) { + return this.rawValue >= val.rawValue(); + } + + @Override + public Word add(int val) { + return box(this.rawValue + val); + } + + @Override + public Word subtract(int val) { + return box(this.rawValue - val); + } + + @Override + public Word multiply(int val) { + return box(this.rawValue * val); + } + + @Override + public UnsignedWord unsignedDivide(int val) { + return box(Long.divideUnsigned(this.rawValue, val)); + } + + @Override + public UnsignedWord unsignedRemainder(int val) { + return box(Long.remainderUnsigned(this.rawValue, val)); + } + + @Override + public SignedWord signedDivide(int val) { + return box(this.rawValue / val); + } + + @Override + public SignedWord signedRemainder(int val) { + return box(this.rawValue % val); + } + + @Override + public Word shiftLeft(int n) { + return box(this.rawValue << n); + } + + @Override + public UnsignedWord unsignedShiftRight(int n) { + return box(this.rawValue >>> n); + } + + @Override + public SignedWord signedShiftRight(int n) { + return box(this.rawValue >> n); + } + + @Override + public Word and(int val) { + return box(this.rawValue & val); + } + + @Override + public Word or(int val) { + return box(this.rawValue | val); + } + + @Override + public Word xor(int val) { + return box(this.rawValue ^ val); + } + + @Override + public boolean equal(int val) { + return this.rawValue == 0; + } + + @Override + public boolean notEqual(int val) { + return this.rawValue != 0; + } + + @Override + public boolean belowThan(int val) { + return compareUnsigned(this.rawValue, val) < 0; + } + + @Override + public boolean belowOrEqual(int val) { + return compareUnsigned(this.rawValue, val) <= 0; + } - Word add(int p1); + @Override + public boolean aboveThan(int val) { + return compareUnsigned(this.rawValue, val) > 0; + } - Word shiftLeft(int p1); + @Override + public boolean aboveOrEqual(int val) { + return compareUnsigned(this.rawValue, val) >= 0; + } - Word shiftLeft(UnsignedWord p1); + @Override + public boolean lessThan(int val) { + return this.rawValue < val; + } - Word multiply(int p1); + @Override + public boolean lessOrEqual(int val) { + return this.rawValue <= val; + } - Word or(int p1); + @Override + public boolean greaterThan(int val) { + return this.rawValue > val; + } - Word and(int p1); + @Override + public boolean greaterOrEqual(int val) { + return this.rawValue >= val; + } - Word not(); + @Override + public boolean equal(ComparableWord val) { + return this.rawValue == val.rawValue(); + } - Word subtract(int p1); + @Override + public boolean notEqual(ComparableWord val) { + return this.rawValue != val.rawValue(); + } - Word xor(int p1); + @Override + public long rawValue() { + return rawValue; + } } diff --git a/sdk/src/org.graalvm.word/src/org/graalvm/word/WordFactory.java b/sdk/src/org.graalvm.word/src/org/graalvm/word/WordFactory.java index a0772f091f00..73c55ae20e34 100644 --- a/sdk/src/org.graalvm.word/src/org/graalvm/word/WordFactory.java +++ b/sdk/src/org.graalvm.word/src/org/graalvm/word/WordFactory.java @@ -40,13 +40,9 @@ */ package org.graalvm.word; -import static java.lang.Long.compareUnsigned; - import org.graalvm.word.impl.WordFactoryOpcode; import org.graalvm.word.impl.WordFactoryOperation; -import java.lang.reflect.Proxy; - /** * Provides factory method to create machine-word-sized values. * @@ -67,7 +63,7 @@ private WordFactory() { */ @WordFactoryOperation(opcode = WordFactoryOpcode.ZERO) public static T zero() { - return box(0L); + return Word.box(0L); } /** @@ -80,7 +76,7 @@ public static T zero() { */ @WordFactoryOperation(opcode = WordFactoryOpcode.ZERO) public static T nullPointer() { - return box(0L); + return Word.box(0L); } /** @@ -94,7 +90,7 @@ public static T nullPointer() { */ @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_UNSIGNED) public static T unsigned(long val) { - return box(val); + return Word.box(val); } /** @@ -102,8 +98,9 @@ public static T unsigned(long val) { * treated as an unsigned 64-bit value (in contrast to the semantics of a Java long). * * In an execution environment where this method returns a boxed value (e.g. not in Native - * Image), the returned value will throw {@link UnsupportedOperationException} if any of the - * {@link Pointer} memory access operations are invoked on it. + * Image), the returned value will throw {@link UnsatisfiedLinkError} if any of the + * {@link Pointer} memory access operations (i.e., read, write, compare-and-swap etc.) are + * invoked on it. * * @param val a 64 bit unsigned value * @return the value cast to PointerBase @@ -112,7 +109,7 @@ public static T unsigned(long val) { */ @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_UNSIGNED) public static T pointer(long val) { - return box(val); + return Word.box(val); } /** @@ -126,7 +123,7 @@ public static T pointer(long val) { */ @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_UNSIGNED) public static T unsigned(int val) { - return box(val & 0xffffffffL); + return Word.box(val & 0xffffffffL); } /** @@ -140,7 +137,7 @@ public static T unsigned(int val) { */ @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_SIGNED) public static T signed(long val) { - return box(val); + return Word.box(val); } /** @@ -154,70 +151,7 @@ public static T signed(long val) { */ @WordFactoryOperation(opcode = WordFactoryOpcode.FROM_SIGNED) public static T signed(int val) { - return box(val); + return Word.box(val); } - /** - * Creates a box for {@code val} that all word operations except memory access operations (see - * {@link #pointer(long)}). - */ - @SuppressWarnings("unchecked") - static T box(long val) { - Class[] interfaces = {Word.class}; - return (T) Proxy.newProxyInstance(WordFactory.class.getClassLoader(), interfaces, (proxy, method, args) -> { - switch (method.getName()) { - case "toString": { - return Word.class.getName() + "<" + val + ">"; - } - case "equals": { - if (args[0] instanceof WordBase) { - WordBase thatWord = (WordBase) args[0]; - return val == thatWord.rawValue(); - } - return false; - } - // @formatter:off - case "aboveOrEqual": return compareUnsigned(val, unbox(args[0])) >= 0; - case "aboveThan": return compareUnsigned(val, unbox(args[0])) > 0; - case "add": return box(val + unbox(args[0])); - case "and": return box(val & unbox(args[0])); - case "belowOrEqual": return compareUnsigned(val, unbox(args[0])) <= 0; - case "belowThan": return compareUnsigned(val, unbox(args[0])) < 0; - case "equal": return val == unbox(args[0]); - case "greaterOrEqual": return val >= unbox(args[0]); - case "greaterThan": return val > unbox(args[0]); - case "hashCode": return Long.hashCode(val); - case "isNonNull": return val != 0; - case "isNull": return val == 0; - case "lessOrEqual": return val <= unbox(args[0]); - case "lessThan": return val < unbox(args[0]); - case "multiply": return box(val * unbox(args[0])); - case "not": return box(~val); - case "notEqual": return val != unbox(args[0]); - case "or": return box(val | unbox(args[0])); - case "rawValue": return val; - case "shiftLeft": return box(val << unbox(args[0])); - case "signedDivide": return box(val / unbox(args[0])); - case "signedRemainder": return box(val % unbox(args[0])); - case "signedShiftRight": return box(val >> unbox(args[0])); - case "subtract": return box(val - unbox(args[0])); - case "unsignedDivide": return box(Long.divideUnsigned(val, unbox(args[0]))); - case "unsignedRemainder": return box(Long.remainderUnsigned(val, unbox(args[0]))); - case "unsignedShiftRight": return box(val >>> unbox(args[0])); - case "xor": return box(val ^ unbox(args[0])); - // @formatter:on - } - throw new UnsupportedOperationException("operation `" + method.getName() + "` not supported"); - }); - } - - static long unbox(Object arg) { - if (arg instanceof WordBase) { - return ((WordBase) arg).rawValue(); - } - if (arg instanceof Number) { - return ((Number) arg).longValue(); - } - throw new IllegalArgumentException(); - } } diff --git a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/ForeignFunctionsRuntime.java b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/ForeignFunctionsRuntime.java index bb1a72ce2505..ed66d9578d8a 100644 --- a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/ForeignFunctionsRuntime.java +++ b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/ForeignFunctionsRuntime.java @@ -32,6 +32,7 @@ import java.util.Map; import java.util.function.BiConsumer; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicMap; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; @@ -40,7 +41,6 @@ import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.FunctionPointerHolder; import com.oracle.svm.core.OS; @@ -145,7 +145,7 @@ void patchForDirectUpcall(long trampolineAddress, DirectMethodHandleDesc desc) { return; } - Pointer trampolinePointer = WordFactory.pointer(trampolineAddress); + Pointer trampolinePointer = Word.pointer(trampolineAddress); Pointer trampolineSetBase = TrampolineSet.getAllocationBase(trampolinePointer); TrampolineSet trampolineSet = trampolines.get(trampolineSetBase.rawValue()); if (trampolineSet == null) { @@ -174,7 +174,7 @@ public void setUsingSpecializedUpcallListener(BiConsumer 0L) { - maxHeap = WordFactory.unsigned(optionMax); + maxHeap = Word.unsigned(optionMax); } else { maxHeap = PhysicalMemory.size().unsignedDivide(100).multiply(HeapParameters.getMaximumHeapSizePercent()); } @@ -336,7 +336,7 @@ protected SizeParameters computeSizeParameters(SizeParameters existing) { UnsignedWord maxYoung; long optionMaxYoung = SubstrateGCOptions.MaxNewSize.getValue(); if (optionMaxYoung > 0L) { - maxYoung = WordFactory.unsigned(optionMaxYoung); + maxYoung = Word.unsigned(optionMaxYoung); } else if (SerialAndEpsilonGCOptions.MaximumYoungGenerationSizePercent.hasBeenSet()) { maxYoung = maxHeap.unsignedDivide(100).multiply(HeapParameters.getMaximumYoungGenerationSizePercent()); } else { @@ -349,10 +349,10 @@ protected SizeParameters computeSizeParameters(SizeParameters existing) { VMError.guarantee(maxOld.aboveOrEqual(minSpaceSize()) && maxHeap.belowOrEqual(addressSpaceSize) && (maxHeap.belowOrEqual(unadjustedMaxHeap) || unadjustedMaxHeap.belowThan(minAllSpaces))); - UnsignedWord minHeap = WordFactory.zero(); + UnsignedWord minHeap = Word.zero(); long optionMin = SubstrateGCOptions.MinHeapSize.getValue(); if (optionMin > 0L) { - minHeap = WordFactory.unsigned(optionMin); + minHeap = Word.unsigned(optionMin); } minHeap = UnsignedUtils.clamp(alignUp(minHeap), minAllSpaces, maxHeap); @@ -366,7 +366,7 @@ protected SizeParameters computeSizeParameters(SizeParameters existing) { initialYoung = initialHeap.unsignedDivide(initialNewRatio + 1); initialYoung = UnsignedUtils.clamp(alignUp(initialYoung), minYoungSpaces, maxYoung); } - UnsignedWord initialSurvivor = WordFactory.zero(); + UnsignedWord initialSurvivor = Word.zero(); if (HeapParameters.getMaxSurvivorSpaces() > 0) { /* * In HotSpot, this is the reserved capacity of each of the survivor From and To spaces, @@ -427,7 +427,7 @@ private SizeParameters(UnsignedWord maxHeapSize, UnsignedWord maxYoungSize, Unsi @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) UnsignedWord maxSurvivorSize() { if (HeapParameters.getMaxSurvivorSpaces() == 0) { - return WordFactory.zero(); + return Word.zero(); } UnsignedWord size = maxYoungSize.unsignedDivide(MIN_SURVIVOR_RATIO); return minSpaceSize(alignDown(size)); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AbstractMemoryPoolMXBean.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AbstractMemoryPoolMXBean.java index f282660945ec..8392cffda696 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AbstractMemoryPoolMXBean.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AbstractMemoryPoolMXBean.java @@ -33,10 +33,10 @@ import javax.management.ObjectName; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.heap.AbstractMXBean; import com.oracle.svm.core.jdk.UninterruptibleUtils; @@ -45,7 +45,7 @@ public abstract class AbstractMemoryPoolMXBean extends AbstractMXBean implements MemoryPoolMXBean { - protected static final UnsignedWord UNDEFINED = WordFactory.unsigned(UNDEFINED_MEMORY_USAGE); + protected static final UnsignedWord UNDEFINED = Word.unsigned(UNDEFINED_MEMORY_USAGE); private final String name; private final String[] managerNames; @@ -157,7 +157,7 @@ public long getCollectionUsageThresholdCount() { @Override public void resetPeakUsage() { - peakUsage.set(WordFactory.zero()); + peakUsage.set(Word.zero()); } void updatePeakUsage(UnsignedWord value) { diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java index eb3822c1df9f..576d94b7f8ee 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java @@ -26,8 +26,8 @@ import static com.oracle.svm.core.genscavenge.CollectionPolicy.shouldCollectYoungGenSeparately; +import jdk.graal.compiler.word.Word; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.heap.GCCause; @@ -134,7 +134,7 @@ class AdaptiveCollectionPolicy extends AbstractCollectionPolicy { private long minorCount; private long latestMinorMutatorIntervalNanos; private boolean youngGenPolicyIsReady; - private UnsignedWord youngGenSizeIncrementSupplement = WordFactory.unsigned(YOUNG_GENERATION_SIZE_SUPPLEMENT); + private UnsignedWord youngGenSizeIncrementSupplement = Word.unsigned(YOUNG_GENERATION_SIZE_SUPPLEMENT); private long youngGenChangeForMinorThroughput; private int minorCountSinceMajorCollection; @@ -145,7 +145,7 @@ class AdaptiveCollectionPolicy extends AbstractCollectionPolicy { private final AdaptiveWeightedAverage avgOldLive = new AdaptiveWeightedAverage(ADAPTIVE_SIZE_POLICY_WEIGHT); private final ReciprocalLeastSquareFit majorCostEstimator = new ReciprocalLeastSquareFit(ADAPTIVE_SIZE_COST_ESTIMATORS_HISTORY_LENGTH); private long majorCount; - private UnsignedWord oldGenSizeIncrementSupplement = WordFactory.unsigned(TENURED_GENERATION_SIZE_SUPPLEMENT); + private UnsignedWord oldGenSizeIncrementSupplement = Word.unsigned(TENURED_GENERATION_SIZE_SUPPLEMENT); private long latestMajorMutatorIntervalNanos; private boolean oldSizeExceededInPreviousCollection; private long oldGenChangeForMajorThroughput; @@ -323,7 +323,7 @@ private static UnsignedWord scaleDown(UnsignedWord change, UnsignedWord part, Un } private static UnsignedWord edenDecrement(UnsignedWord curEden) { - return spaceIncrement(curEden, WordFactory.unsigned(YOUNG_GENERATION_SIZE_INCREMENT)) + return spaceIncrement(curEden, Word.unsigned(YOUNG_GENERATION_SIZE_INCREMENT)) .unsignedDivide(ADAPTIVE_SIZE_DECREMENT_SCALE_FACTOR); } @@ -512,7 +512,7 @@ private static UnsignedWord promoDecrement(UnsignedWord curPromo) { } private static UnsignedWord promoIncrement(UnsignedWord curPromo) { - return spaceIncrement(curPromo, WordFactory.unsigned(TENURED_GENERATION_SIZE_INCREMENT)); + return spaceIncrement(curPromo, Word.unsigned(TENURED_GENERATION_SIZE_INCREMENT)); } private UnsignedWord promoIncrementWithSupplementAlignedUp(UnsignedWord curPromo) { diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AddressRangeCommittedMemoryProvider.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AddressRangeCommittedMemoryProvider.java index 62f13ffa9a39..d9542a7f1480 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AddressRangeCommittedMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AddressRangeCommittedMemoryProvider.java @@ -28,10 +28,10 @@ import static com.oracle.svm.core.util.PointerUtils.roundDown; import static com.oracle.svm.core.util.PointerUtils.roundUp; import static com.oracle.svm.core.util.VMError.guarantee; -import static jdk.graal.compiler.word.WordFactory.unsigned; -import static jdk.graal.compiler.word.WordFactory.nullPointer; +import static jdk.graal.compiler.word.Word.unsigned; +import static jdk.graal.compiler.word.Word.nullPointer; -import jdk.graal.compiler.word.WordFactory; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Isolate; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -145,15 +145,15 @@ public AddressRangeCommittedMemoryProvider() { @Uninterruptible(reason = "Still being initialized.") public int initialize(WordPointer heapBasePointer, IsolateArguments arguments) { UnsignedWord addressSpaceSize = ReferenceAccess.singleton().getAddressSpaceSize(); - UnsignedWord reserved = WordFactory.unsigned(IsolateArgumentAccess.readLong(arguments, IsolateArgumentParser.getOptionIndex(SubstrateGCOptions.ReservedAddressSpaceSize))); + UnsignedWord reserved = Word.unsigned(IsolateArgumentAccess.readLong(arguments, IsolateArgumentParser.getOptionIndex(SubstrateGCOptions.ReservedAddressSpaceSize))); if (reserved.equal(0)) { /* * By default, always reserve at least 32 GB of address space. If a large maximum heap * size was specified, then reserve 2x of that maximum heap size (assuming that the max. * address space size is large enough for that). */ - UnsignedWord maxHeapSize = WordFactory.unsigned(IsolateArgumentAccess.readLong(arguments, IsolateArgumentParser.getOptionIndex(SubstrateGCOptions.MaxHeapSize))).multiply(2); - reserved = UnsignedUtils.clamp(maxHeapSize, WordFactory.unsigned(MIN_RESERVED_ADDRESS_SPACE_SIZE), addressSpaceSize); + UnsignedWord maxHeapSize = Word.unsigned(IsolateArgumentAccess.readLong(arguments, IsolateArgumentParser.getOptionIndex(SubstrateGCOptions.MaxHeapSize))).multiply(2); + reserved = UnsignedUtils.clamp(maxHeapSize, Word.unsigned(MIN_RESERVED_ADDRESS_SPACE_SIZE), addressSpaceSize); } UnsignedWord alignment = unsigned(Heap.getHeap().getPreferredAddressSpaceAlignment()); @@ -650,7 +650,7 @@ protected void freeInHeapAddressSpace(Pointer start, UnsignedWord nbytes) { removeFromUnusedList(unusedNext); freeNode(unusedNext); - unusedNext = WordFactory.nullPointer(); + unusedNext = Word.nullPointer(); } } else if (adjacentSuccessor) { /* Add the freed memory to the successor node. */ diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AlignedHeapChunk.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AlignedHeapChunk.java index 5f9bb23f068c..8b0da4008afd 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AlignedHeapChunk.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AlignedHeapChunk.java @@ -28,7 +28,6 @@ import org.graalvm.nativeimage.c.struct.RawStructure; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -94,7 +93,7 @@ public static void initialize(AlignedHeader chunk, UnsignedWord chunkSize) { public static void reset(AlignedHeader chunk) { long alignedChunkSize = SerialAndEpsilonGCOptions.AlignedHeapChunkSize.getValue(); assert HeapChunk.getEndOffset(chunk).rawValue() == alignedChunkSize; - initialize(chunk, WordFactory.unsigned(alignedChunkSize)); + initialize(chunk, Word.unsigned(alignedChunkSize)); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -113,7 +112,7 @@ public static boolean isEmpty(AlignedHeader that) { /** Allocate uninitialized memory within this AlignedHeapChunk. */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) static Pointer allocateMemory(AlignedHeader that, UnsignedWord size) { - Pointer result = WordFactory.nullPointer(); + Pointer result = Word.nullPointer(); UnsignedWord available = HeapChunk.availableObjectMemory(that); if (size.belowOrEqual(available)) { result = HeapChunk.getTopPointer(that); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/BasicCollectionPolicies.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/BasicCollectionPolicies.java index 3816daa0e4af..ea442a7a91e9 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/BasicCollectionPolicies.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/BasicCollectionPolicies.java @@ -26,10 +26,10 @@ import static com.oracle.svm.core.genscavenge.CollectionPolicy.shouldCollectYoungGenSeparately; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateGCOptions; import com.oracle.svm.core.Uninterruptible; @@ -54,7 +54,7 @@ private BasicCollectionPolicies() { public abstract static class BasicPolicy implements CollectionPolicy { protected static UnsignedWord m(long bytes) { assert 0 <= bytes; - return WordFactory.unsigned(bytes).multiply(1024).multiply(1024); + return Word.unsigned(bytes).multiply(1024).multiply(1024); } @Override @@ -98,7 +98,7 @@ public UnsignedWord getMaximumEdenSize() { public final UnsignedWord getMaximumHeapSize() { long runtimeValue = SubstrateGCOptions.MaxHeapSize.getValue(); if (runtimeValue != 0L) { - return WordFactory.unsigned(runtimeValue); + return Word.unsigned(runtimeValue); } /* @@ -117,7 +117,7 @@ public final UnsignedWord getMaximumHeapSize() { public final UnsignedWord getMaximumYoungGenerationSize() { long runtimeValue = SubstrateGCOptions.MaxNewSize.getValue(); if (runtimeValue != 0L) { - return WordFactory.unsigned(runtimeValue); + return Word.unsigned(runtimeValue); } /* If no value is set, use a fraction of the maximum heap size. */ @@ -135,7 +135,7 @@ public final UnsignedWord getMinimumHeapSize() { long runtimeValue = SubstrateGCOptions.MinHeapSize.getValue(); if (runtimeValue != 0L) { /* If `-Xms` has been parsed from the command line, use that value. */ - return WordFactory.unsigned(runtimeValue); + return Word.unsigned(runtimeValue); } /* A default value chosen to delay the first full collection. */ @@ -155,13 +155,13 @@ public UnsignedWord getInitialSurvivorSize() { @Override public UnsignedWord getMaximumSurvivorSize() { - return WordFactory.zero(); + return Word.zero(); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public UnsignedWord getSurvivorSpacesCapacity() { - return WordFactory.zero(); + return Word.zero(); } @Override @@ -179,7 +179,7 @@ public UnsignedWord getOldGenerationCapacity() { UnsignedWord heapCapacity = getCurrentHeapCapacity(); UnsignedWord youngCapacity = getYoungGenerationCapacity(); if (youngCapacity.aboveThan(heapCapacity)) { - return WordFactory.zero(); // should never happen unless options change in between + return Word.zero(); // should never happen unless options change in between } return heapCapacity.subtract(youngCapacity); } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ChunkedImageHeapAllocator.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ChunkedImageHeapAllocator.java index 1418ef16d588..67a7313b3050 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ChunkedImageHeapAllocator.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ChunkedImageHeapAllocator.java @@ -28,8 +28,8 @@ import java.util.List; import jdk.graal.compiler.core.common.NumUtil; +import jdk.graal.compiler.word.Word; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.image.ImageHeap; @@ -195,7 +195,7 @@ public void alignBetweenChunks(int multiple) { public long allocateUnalignedChunkForObject(ImageHeapObject obj, boolean writable) { assert currentAlignedChunk == null; - UnsignedWord objSize = WordFactory.unsigned(obj.getSize()); + UnsignedWord objSize = Word.unsigned(obj.getSize()); long chunkSize = UnalignedHeapChunk.getChunkSizeForObject(objSize).rawValue(); long chunkBegin = allocateRaw(chunkSize); unalignedChunks.add(new UnalignedChunk(chunkBegin, chunkSize, writable)); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ChunksAccounting.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ChunksAccounting.java index 4e33713f9a32..8bb78a79e413 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ChunksAccounting.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ChunksAccounting.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.genscavenge; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; @@ -57,7 +57,7 @@ final class ChunksAccounting { public void reset() { alignedCount = 0L; unalignedCount = 0L; - unalignedChunkBytes = WordFactory.zero(); + unalignedChunkBytes = Word.zero(); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -71,7 +71,7 @@ public long getAlignedChunkCount() { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public UnsignedWord getAlignedChunkBytes() { - return WordFactory.unsigned(alignedCount).multiply(HeapParameters.getAlignedHeapChunkSize()); + return Word.unsigned(alignedCount).multiply(HeapParameters.getAlignedHeapChunkSize()); } public long getUnalignedChunkCount() { diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/CollectionPolicy.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/CollectionPolicy.java index 4ccb21356cb4..6db2f15e3ea1 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/CollectionPolicy.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/CollectionPolicy.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.genscavenge; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; @@ -38,7 +38,7 @@ /** The interface for a garbage collection policy. All sizes are in bytes. */ public interface CollectionPolicy { - UnsignedWord UNDEFINED = WordFactory.unsigned(-1); + UnsignedWord UNDEFINED = Word.unsigned(-1); @Platforms(Platform.HOSTED_ONLY.class) static String getInitialPolicyName() { diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GCAccounting.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GCAccounting.java index 0141451cc72e..dd4df8380d3d 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GCAccounting.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GCAccounting.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.genscavenge; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -47,24 +47,24 @@ public final class GCAccounting { private long incrementalCollectionTotalNanos = 0; private long completeCollectionCount = 0; private long completeCollectionTotalNanos = 0; - private UnsignedWord totalCollectedChunkBytes = WordFactory.zero(); - private UnsignedWord totalAllocatedChunkBytes = WordFactory.zero(); - private UnsignedWord lastIncrementalCollectionPromotedChunkBytes = WordFactory.zero(); + private UnsignedWord totalCollectedChunkBytes = Word.zero(); + private UnsignedWord totalAllocatedChunkBytes = Word.zero(); + private UnsignedWord lastIncrementalCollectionPromotedChunkBytes = Word.zero(); private boolean lastIncrementalCollectionOverflowedSurvivors = false; /* Before and after measures. */ - private UnsignedWord youngChunkBytesBefore = WordFactory.zero(); - private UnsignedWord oldChunkBytesBefore = WordFactory.zero(); - private UnsignedWord oldChunkBytesAfter = WordFactory.zero(); + private UnsignedWord youngChunkBytesBefore = Word.zero(); + private UnsignedWord oldChunkBytesBefore = Word.zero(); + private UnsignedWord oldChunkBytesAfter = Word.zero(); /* * Bytes allocated in Objects, as opposed to bytes of chunks. These are only maintained if * -R:+PrintGCSummary because they are expensive. */ - private UnsignedWord totalCollectedObjectBytes = WordFactory.zero(); - private UnsignedWord youngObjectBytesBefore = WordFactory.zero(); - private UnsignedWord oldObjectBytesBefore = WordFactory.zero(); - private UnsignedWord allocatedObjectBytes = WordFactory.zero(); + private UnsignedWord totalCollectedObjectBytes = Word.zero(); + private UnsignedWord youngObjectBytesBefore = Word.zero(); + private UnsignedWord oldObjectBytesBefore = Word.zero(); + private UnsignedWord allocatedObjectBytes = Word.zero(); @Platforms(Platform.HOSTED_ONLY.class) GCAccounting() { diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GCImpl.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GCImpl.java index 1754465b1228..a15dddabfee6 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GCImpl.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GCImpl.java @@ -31,6 +31,7 @@ import java.lang.ref.Reference; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; @@ -41,7 +42,6 @@ import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Isolates; @@ -126,7 +126,7 @@ public final class GCImpl implements GC { private final CollectionPolicy policy; private boolean completeCollection = false; - private UnsignedWord collectionEpoch = WordFactory.zero(); + private UnsignedWord collectionEpoch = Word.zero(); private long lastWholeHeapExaminedNanos = -1; @Platforms(Platform.HOSTED_ONLY.class) @@ -191,7 +191,7 @@ boolean collectWithoutAllocating(GCCause cause, boolean forceFullGC) { int size = SizeOf.get(CollectionVMOperationData.class); CollectionVMOperationData data = StackValue.get(size); - UnmanagedMemoryUtil.fill((Pointer) data, WordFactory.unsigned(size), (byte) 0); + UnmanagedMemoryUtil.fill((Pointer) data, Word.unsigned(size), (byte) 0); data.setCauseId(cause.getId()); data.setRequestingEpoch(getCollectionEpoch()); data.setCompleteCollectionCount(GCImpl.getAccounting().getCompleteCollectionCount()); @@ -858,7 +858,7 @@ private static void walkStack(IsolateThread thread, JavaStackWalk walk, ObjectRe * passing (re-use of deopt slot). */ long varStackSize = DeoptimizationSlotPacking.decodeVariableFrameSizeFromDeoptSlot(sp.readLong(0)); - Pointer actualSP = sp.add(WordFactory.unsigned(varStackSize)); + Pointer actualSP = sp.add(Word.unsigned(varStackSize)); InterpreterSupport.walkInterpreterLeaveStubFrame(visitor, actualSP, sp); } else { @@ -1310,11 +1310,11 @@ public void add(UnalignedHeader chunks) { void release(boolean keepAllAlignedChunks) { if (firstAligned.isNonNull()) { HeapImpl.getChunkProvider().consumeAlignedChunks(firstAligned, keepAllAlignedChunks); - firstAligned = WordFactory.nullPointer(); + firstAligned = Word.nullPointer(); } if (firstUnaligned.isNonNull()) { HeapChunkProvider.consumeUnalignedChunks(firstUnaligned); - firstUnaligned = WordFactory.nullPointer(); + firstUnaligned = Word.nullPointer(); } } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GenScavengeMemoryPoolMXBeans.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GenScavengeMemoryPoolMXBeans.java index e9a55af1c63e..de5ed9b23d26 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GenScavengeMemoryPoolMXBeans.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GenScavengeMemoryPoolMXBeans.java @@ -27,11 +27,11 @@ import java.lang.management.MemoryUsage; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.util.VMError; @@ -122,7 +122,7 @@ public MemoryUsage getPeakUsage() { @Override public MemoryUsage getCollectionUsage() { - return memoryUsage(WordFactory.zero()); + return memoryUsage(Word.zero()); } private static UnsignedWord getCurrentUsage() { @@ -241,7 +241,7 @@ public MemoryUsage getPeakUsage() { @Override public MemoryUsage getCollectionUsage() { - return memoryUsage(WordFactory.zero()); + return memoryUsage(Word.zero()); } } } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GreyObjectsWalker.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GreyObjectsWalker.java index fcb32db4726e..760c0093fec3 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GreyObjectsWalker.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GreyObjectsWalker.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.genscavenge; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.NeverInline; @@ -62,7 +62,7 @@ void setScanStart(Space s) { space = s; AlignedHeapChunk.AlignedHeader aChunk = s.getLastAlignedHeapChunk(); alignedHeapChunk = aChunk; - alignedTop = (aChunk.isNonNull() ? HeapChunk.getTopPointer(aChunk) : WordFactory.nullPointer()); + alignedTop = (aChunk.isNonNull() ? HeapChunk.getTopPointer(aChunk) : Word.nullPointer()); unalignedHeapChunk = s.getLastUnalignedHeapChunk(); } @@ -91,7 +91,7 @@ private void walkAlignedGreyObjects() { if (alignedHeapChunk.isNull() && alignedTop.isNull()) { /* If the snapshot is empty, then I have to walk from the beginning of the Space. */ aChunk = space.getFirstAlignedHeapChunk(); - aStart = (aChunk.isNonNull() ? AlignedHeapChunk.getObjectsStart(aChunk) : WordFactory.nullPointer()); + aStart = (aChunk.isNonNull() ? AlignedHeapChunk.getObjectsStart(aChunk) : Word.nullPointer()); } else { /* Otherwise walk Objects that arrived after the snapshot. */ aChunk = alignedHeapChunk; @@ -107,7 +107,7 @@ private void walkAlignedGreyObjects() { throw VMError.shouldNotReachHereAtRuntime(); } aChunk = HeapChunk.getNext(aChunk); - aStart = (aChunk.isNonNull() ? AlignedHeapChunk.getObjectsStart(aChunk) : WordFactory.nullPointer()); + aStart = (aChunk.isNonNull() ? AlignedHeapChunk.getObjectsStart(aChunk) : Word.nullPointer()); } while (aChunk.isNonNull()); /* Move the scan point. */ diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapChunk.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapChunk.java index 3aab49183db8..ab6b889ef5b6 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapChunk.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapChunk.java @@ -35,7 +35,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.NeverInline; @@ -174,8 +173,8 @@ public static void initialize(Header chunk, Pointer objectsStart, UnsignedWor HeapChunk.setEndOffset(chunk, endOffset); HeapChunk.setTopPointer(chunk, objectsStart); HeapChunk.setSpace(chunk, null); - HeapChunk.setNext(chunk, WordFactory.nullPointer()); - HeapChunk.setPrevious(chunk, WordFactory.nullPointer()); + HeapChunk.setNext(chunk, Word.nullPointer()); + HeapChunk.setPrevious(chunk, Word.nullPointer()); /* * The epoch is obviously not random, but cheap to use, and we cannot use a random number @@ -272,8 +271,8 @@ public static void setIdentityHashSalt(Header that, UnsignedWord value) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @SuppressWarnings("unchecked") private static T pointerFromOffset(Header that, ComparableWord offset) { - T pointer = WordFactory.nullPointer(); - if (offset.notEqual(WordFactory.zero())) { + T pointer = Word.nullPointer(); + if (offset.notEqual(Word.zero())) { pointer = (T) ((SignedWord) that).add((SignedWord) offset); } return pointer; @@ -286,7 +285,7 @@ private static T pointerFromOffset(Header that, Compa */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static SignedWord offsetFromPointer(Header that, PointerBase pointer) { - SignedWord offset = WordFactory.zero(); + SignedWord offset = Word.zero(); if (pointer.isNonNull()) { offset = ((SignedWord) pointer).subtract((SignedWord) that); } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapChunkProvider.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapChunkProvider.java index 9391506defe6..c242551a780e 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapChunkProvider.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapChunkProvider.java @@ -24,12 +24,12 @@ */ package com.oracle.svm.core.genscavenge; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.FrameAccess; import com.oracle.svm.core.Uninterruptible; @@ -107,7 +107,7 @@ AlignedHeader produceAlignedChunk() { void freeExcessAlignedChunks() { assert VMOperation.isGCInProgress(); - consumeAlignedChunks(WordFactory.nullPointer(), false); + consumeAlignedChunks(Word.nullPointer(), false); } /** @@ -118,14 +118,14 @@ void consumeAlignedChunks(AlignedHeader firstChunk, boolean keepAll) { assert VMOperation.isGCInProgress(); assert firstChunk.isNull() || HeapChunk.getPrevious(firstChunk).isNull() : "prev must be null"; - UnsignedWord maxChunksToKeep = WordFactory.zero(); - UnsignedWord unusedChunksToFree = WordFactory.zero(); + UnsignedWord maxChunksToKeep = Word.zero(); + UnsignedWord unusedChunksToFree = Word.zero(); if (keepAll) { maxChunksToKeep = UnsignedUtils.MAX_VALUE; } else { UnsignedWord freeListBytes = getBytesInUnusedChunks(); UnsignedWord reserveBytes = GCImpl.getPolicy().getMaximumFreeAlignedChunksSize(); - UnsignedWord maxHeapFree = WordFactory.unsigned(SerialGCOptions.MaxHeapFree.getValue()); + UnsignedWord maxHeapFree = Word.unsigned(SerialGCOptions.MaxHeapFree.getValue()); if (maxHeapFree.aboveThan(0)) { reserveBytes = UnsignedUtils.min(reserveBytes, maxHeapFree); } @@ -178,7 +178,7 @@ private void pushUnusedAlignedChunk(AlignedHeader chunk) { HeapChunk.setNext(chunk, unusedAlignedChunks.get()); unusedAlignedChunks.set(chunk); - numUnusedAlignedChunks.addAndGet(WordFactory.unsigned(1)); + numUnusedAlignedChunks.addAndGet(Word.unsigned(1)); } /** @@ -194,9 +194,9 @@ private void pushUnusedAlignedChunk(AlignedHeader chunk) { private AlignedHeader popUnusedAlignedChunk() { AlignedHeader result = popUnusedAlignedChunkUninterruptibly(); if (result.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } else { - numUnusedAlignedChunks.subtractAndGet(WordFactory.unsigned(1)); + numUnusedAlignedChunks.subtractAndGet(Word.unsigned(1)); return result; } } @@ -206,11 +206,11 @@ private AlignedHeader popUnusedAlignedChunkUninterruptibly() { while (true) { AlignedHeader result = unusedAlignedChunks.get(); if (result.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } else { AlignedHeader next = HeapChunk.getNext(result); if (unusedAlignedChunks.compareAndSet(result, next)) { - HeapChunk.setNext(result, WordFactory.nullPointer()); + HeapChunk.setNext(result, Word.nullPointer()); return result; } } @@ -224,7 +224,7 @@ private void freeUnusedAlignedChunksAtSafepoint(UnsignedWord count) { } AlignedHeader chunk = unusedAlignedChunks.get(); - UnsignedWord released = WordFactory.zero(); + UnsignedWord released = Word.zero(); while (chunk.isNonNull() && released.belowThan(count)) { AlignedHeader next = HeapChunk.getNext(chunk); freeAlignedChunk(chunk); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapImpl.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapImpl.java index a4c4893d11f7..eb38e7dc100d 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapImpl.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapImpl.java @@ -35,7 +35,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.MemoryWalker; @@ -854,7 +853,7 @@ private static Descriptor getTlabUnsafe(IsolateThread thread) { public boolean verifyImageHeapMapping() { for (ImageHeapInfo info : HeapImpl.getImageHeapInfos()) { /* Read & write some data at the beginning and end of each writable chunk. */ - writeToEachChunk(info.getFirstWritableAlignedChunk(), WordFactory.nullPointer()); + writeToEachChunk(info.getFirstWritableAlignedChunk(), Word.nullPointer()); writeToEachChunk(info.getFirstWritableUnalignedChunk(), info.getLastWritableUnalignedChunk()); } return true; @@ -975,7 +974,7 @@ protected void operate() { */ UnsignedWord size = LayoutEncoding.getArrayAllocationSize(hubOfDynamicHub.getLayoutEncoding(), vTableSlots); - Pointer memory = WordFactory.nullPointer(); + Pointer memory = Word.nullPointer(); if (getHeapImpl().lastDynamicHubChunk.isNonNull()) { /* * GR-57355: move this fast-path out of vmOp. Needs some locking (it's not diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapParameters.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapParameters.java index 0379e32efd41..52a9e376aa74 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapParameters.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapParameters.java @@ -27,7 +27,6 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateGCOptions; import com.oracle.svm.core.SubstrateUtil; @@ -108,7 +107,7 @@ public static void setMaximumHeapFree(UnsignedWord bytes) { } public static UnsignedWord getMaximumHeapFree() { - return WordFactory.unsigned(SerialGCOptions.MaxHeapFree.getValue()); + return Word.unsigned(SerialGCOptions.MaxHeapFree.getValue()); } public static int getHeapChunkHeaderPadding() { @@ -129,7 +128,7 @@ static int getMaximumHeapSizePercent() { @Fold public static UnsignedWord getAlignedHeapChunkSize() { - return WordFactory.unsigned(SerialAndEpsilonGCOptions.AlignedHeapChunkSize.getValue()); + return Word.unsigned(SerialAndEpsilonGCOptions.AlignedHeapChunkSize.getValue()); } @Fold @@ -144,7 +143,7 @@ public static UnsignedWord getMinUnalignedChunkSize() { @Fold public static UnsignedWord getLargeArrayThreshold() { - return WordFactory.unsigned(SerialAndEpsilonGCOptions.LargeArrayThreshold.getValue()); + return Word.unsigned(SerialAndEpsilonGCOptions.LargeArrayThreshold.getValue()); } /* @@ -169,10 +168,10 @@ public static boolean getZapConsumedHeapChunks() { /** Unused but still committed Java heap memory. */ private static final int UNUSED_JAVA_HEAP = 0xdeadbeef; - private static final UnsignedWord producedHeapChunkZapInt = WordFactory.unsigned(UNINITIALIZED_JAVA_HEAP); + private static final UnsignedWord producedHeapChunkZapInt = Word.unsigned(UNINITIALIZED_JAVA_HEAP); private static final UnsignedWord producedHeapChunkZapWord = producedHeapChunkZapInt.shiftLeft(32).or(producedHeapChunkZapInt); - private static final UnsignedWord consumedHeapChunkZapInt = WordFactory.unsigned(UNUSED_JAVA_HEAP); + private static final UnsignedWord consumedHeapChunkZapInt = Word.unsigned(UNUSED_JAVA_HEAP); private static final UnsignedWord consumedHeapChunkZapWord = consumedHeapChunkZapInt.shiftLeft(32).or(consumedHeapChunkZapInt); public static final class TestingBackDoor { diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapVerifier.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapVerifier.java index c87e561fb5b9..0d1e7cbae8c9 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapVerifier.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapVerifier.java @@ -30,7 +30,6 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader; @@ -157,7 +156,7 @@ static boolean verifySpace(Space space) { private static boolean verifyChunkList(Space space, String kind, HeapChunk.Header firstChunk, HeapChunk.Header lastChunk) { boolean result = true; HeapChunk.Header current = firstChunk; - HeapChunk.Header previous = WordFactory.nullPointer(); + HeapChunk.Header previous = Word.nullPointer(); while (current.isNonNull()) { HeapChunk.Header previousOfCurrent = HeapChunk.getPrevious(current); if (previousOfCurrent.notEqual(previous)) { @@ -193,7 +192,7 @@ private static boolean verifyAlignedChunks(Space space, AlignedHeader firstAlign success = false; } - OBJECT_VERIFIER.initialize(aChunk, WordFactory.nullPointer()); + OBJECT_VERIFIER.initialize(aChunk, Word.nullPointer()); AlignedHeapChunk.walkObjects(aChunk, OBJECT_VERIFIER); aChunk = HeapChunk.getNext(aChunk); success &= OBJECT_VERIFIER.result; @@ -202,7 +201,7 @@ private static boolean verifyAlignedChunks(Space space, AlignedHeader firstAlign } private static boolean verifyUnalignedChunks(Space space, UnalignedHeader firstUnalignedHeapChunk) { - return verifyUnalignedChunks(space, firstUnalignedHeapChunk, WordFactory.nullPointer()); + return verifyUnalignedChunks(space, firstUnalignedHeapChunk, Word.nullPointer()); } private static boolean verifyUnalignedChunks(Space space, UnalignedHeader firstUnalignedHeapChunk, UnalignedHeader lastUnalignedHeapChunk) { @@ -216,7 +215,7 @@ private static boolean verifyUnalignedChunks(Space space, UnalignedHeader firstU success = false; } - OBJECT_VERIFIER.initialize(WordFactory.nullPointer(), uChunk); + OBJECT_VERIFIER.initialize(Word.nullPointer(), uChunk); UnalignedHeapChunk.walkObjects(uChunk, OBJECT_VERIFIER); success &= OBJECT_VERIFIER.result; diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ImageHeapInfo.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ImageHeapInfo.java index 40e9318e4cf4..5eab14eef0db 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ImageHeapInfo.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ImageHeapInfo.java @@ -28,7 +28,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.BuildPhaseProvider.AfterHeapLayout; import com.oracle.svm.core.Uninterruptible; @@ -210,7 +209,7 @@ public UnalignedHeader getLastWritableUnalignedChunk() { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static Pointer getObjectEnd(Object obj) { if (obj == null) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } return LayoutEncoding.getImageHeapObjectEnd(obj); } @@ -219,9 +218,9 @@ private static Pointer getObjectEnd(Object obj) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static > T asImageHeapChunk(long offsetInImageHeap) { if (offsetInImageHeap < 0) { - return (T) WordFactory.nullPointer(); + return (T) Word.nullPointer(); } - UnsignedWord offset = WordFactory.unsigned(offsetInImageHeap); + UnsignedWord offset = Word.unsigned(offsetInImageHeap); return (T) KnownIntrinsics.heapBase().add(offset); } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ImageHeapWalker.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ImageHeapWalker.java index f878ae2fe681..68fd58ea2638 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ImageHeapWalker.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ImageHeapWalker.java @@ -28,7 +28,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.MemoryWalker; @@ -153,7 +152,7 @@ abstract class MemoryWalkerAccessBase implements MemoryWalker.NativeImageHeapReg public UnsignedWord getSize(ImageHeapInfo info) { Pointer firstStart = Word.objectToUntrackedPointer(getFirstObject(info)); if (firstStart.isNull()) { // no objects - return WordFactory.zero(); + return Word.zero(); } Pointer lastEnd = LayoutEncoding.getImageHeapObjectEnd(getLastObject(info)); return lastEnd.subtract(firstStart); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/LibGraalCollectionPolicy.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/LibGraalCollectionPolicy.java index 14a2ad769878..5eb5f30ec59e 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/LibGraalCollectionPolicy.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/LibGraalCollectionPolicy.java @@ -25,8 +25,8 @@ package com.oracle.svm.core.genscavenge; import jdk.graal.compiler.options.Option; +import jdk.graal.compiler.word.Word; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.heap.GCCause; import com.oracle.svm.core.option.RuntimeOptionKey; @@ -52,15 +52,15 @@ public static final class Options { public static final RuntimeOptionKey ExpectedEdenSize = new RuntimeOptionKey<>(32L * 1024L * 1024L); } - protected static final UnsignedWord INITIAL_HEAP_SIZE = WordFactory.unsigned(64L * 1024L * 1024L); - protected static final UnsignedWord FULL_GC_BONUS = WordFactory.unsigned(2L * 1024L * 1024L); + protected static final UnsignedWord INITIAL_HEAP_SIZE = Word.unsigned(64L * 1024L * 1024L); + protected static final UnsignedWord FULL_GC_BONUS = Word.unsigned(2L * 1024L * 1024L); /** * See class javadoc for rationale behind this 16G limit. */ - protected static final UnsignedWord MAXIMUM_HEAP_SIZE = WordFactory.unsigned(16L * 1024L * 1024L * 1024L); + protected static final UnsignedWord MAXIMUM_HEAP_SIZE = Word.unsigned(16L * 1024L * 1024L * 1024L); - private UnsignedWord sizeBefore = WordFactory.zero(); + private UnsignedWord sizeBefore = Word.zero(); private GCCause lastGCCause = null; /** @@ -83,7 +83,7 @@ public boolean shouldCollectOnHint(boolean fullGC) { */ edenUsedBytes = edenUsedBytes.add(FULL_GC_BONUS); } - return edenUsedBytes.aboveOrEqual(WordFactory.unsigned(Options.ExpectedEdenSize.getValue())) || + return edenUsedBytes.aboveOrEqual(Word.unsigned(Options.ExpectedEdenSize.getValue())) || (UnsignedUtils.toDouble(edenUsedBytes) / UnsignedUtils.toDouble(edenSize) >= Options.UsedEdenProportionThreshold.getValue()); } @@ -110,7 +110,7 @@ public void onCollectionBegin(boolean completeCollection, long requestingNanoTim @Override public void onCollectionEnd(boolean completeCollection, GCCause cause) { super.onCollectionEnd(completeCollection, cause); - sizeBefore = WordFactory.zero(); + sizeBefore = Word.zero(); lastGCCause = cause; } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ObjectHeaderImpl.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ObjectHeaderImpl.java index 5cf054fbfb2c..ceb77f8944e9 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ObjectHeaderImpl.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ObjectHeaderImpl.java @@ -29,7 +29,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.SubstrateOptions; @@ -62,9 +61,9 @@ * {@link Heap#isInImageHeap}. */ public final class ObjectHeaderImpl extends ObjectHeader { - private static final UnsignedWord UNALIGNED_BIT = WordFactory.unsigned(0b00001); - private static final UnsignedWord REMSET_OR_MARKED1_BIT = WordFactory.unsigned(0b00010); - private static final UnsignedWord FORWARDED_OR_MARKED2_BIT = WordFactory.unsigned(0b00100); + private static final UnsignedWord UNALIGNED_BIT = Word.unsigned(0b00001); + private static final UnsignedWord REMSET_OR_MARKED1_BIT = Word.unsigned(0b00010); + private static final UnsignedWord FORWARDED_OR_MARKED2_BIT = Word.unsigned(0b00100); private static final UnsignedWord MARKED_BITS = REMSET_OR_MARKED1_BIT.or(FORWARDED_OR_MARKED2_BIT); /** @@ -72,12 +71,12 @@ public final class ObjectHeaderImpl extends ObjectHeader { * initialized to {@link #IDHASH_STATE_UNASSIGNED}. */ private static final int IDHASH_STATE_SHIFT = 3; - private static final UnsignedWord IDHASH_STATE_BITS = WordFactory.unsigned(0b11000); + private static final UnsignedWord IDHASH_STATE_BITS = Word.unsigned(0b11000); @SuppressWarnings("unused") // - private static final UnsignedWord IDHASH_STATE_UNASSIGNED = WordFactory.unsigned(0b00); - private static final UnsignedWord IDHASH_STATE_FROM_ADDRESS = WordFactory.unsigned(0b01); - private static final UnsignedWord IDHASH_STATE_IN_FIELD = WordFactory.unsigned(0b10); + private static final UnsignedWord IDHASH_STATE_UNASSIGNED = Word.unsigned(0b00); + private static final UnsignedWord IDHASH_STATE_FROM_ADDRESS = Word.unsigned(0b01); + private static final UnsignedWord IDHASH_STATE_IN_FIELD = Word.unsigned(0b10); private final int numAlignmentBits; private final int numReservedBits; @@ -141,7 +140,7 @@ protected void initializeObjectHeader(Pointer objectPointer, Word encodedHub, bo ObjectLayout ol = ConfigurationValues.getObjectLayout(); boolean isIdentityHashFieldInObjectHeader = ol.isIdentityHashFieldInObjectHeader() || ol.isIdentityHashFieldAtTypeSpecificOffset() && isArrayLike; if (getReferenceSize() == Integer.BYTES) { - dynamicAssert(encodedHub.and(WordFactory.unsigned(0xFFFFFFFF00000000L)).isNull(), "hub can only use 32 bits"); + dynamicAssert(encodedHub.and(Word.unsigned(0xFFFFFFFF00000000L)).isNull(), "hub can only use 32 bits"); if (isIdentityHashFieldInObjectHeader) { /* Use a single 64-bit write to initialize the hub and the identity hashcode. */ dynamicAssert(ol.getObjectHeaderIdentityHashOffset() == getHubOffset() + 4, "assumed layout to optimize initializing write"); @@ -279,7 +278,7 @@ public Word encodeAsObjectHeader(DynamicHub hub, boolean rememberedSet, boolean /** Clear the object header bits from a header. */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) UnsignedWord clearBits(UnsignedWord header) { - UnsignedWord mask = WordFactory.unsigned(reservedBitsMask); + UnsignedWord mask = Word.unsigned(reservedBitsMask); return header.and(mask.not()); } @@ -444,7 +443,7 @@ private UnsignedWord getForwardHeader(Object copy) { if (hasShift()) { // Compression with a shift uses all bits of a reference, so store the forwarding // pointer in the location following the hub pointer. - result = compressedCopy.shiftLeft(32).or(WordFactory.unsigned(0x00000000e0e0e0e0L)); + result = compressedCopy.shiftLeft(32).or(Word.unsigned(0x00000000e0e0e0e0L)); } else { result = compressedCopy; } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ProportionateSpacesPolicy.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ProportionateSpacesPolicy.java index cddaf924bec4..beebfea4d001 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ProportionateSpacesPolicy.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ProportionateSpacesPolicy.java @@ -26,8 +26,8 @@ import static com.oracle.svm.core.genscavenge.CollectionPolicy.shouldCollectYoungGenSeparately; +import jdk.graal.compiler.word.Word; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.heap.GCCause; @@ -107,7 +107,7 @@ private void adjustDesiredTenuringThreshold() { // DefNewGeneration::adjust_desi // AgeTable::compute_tenuring_threshold YoungGeneration youngGen = HeapImpl.getHeapImpl().getYoungGeneration(); - UnsignedWord total = WordFactory.zero(); + UnsignedWord total = Word.zero(); int i; for (i = 0; i < HeapParameters.getMaxSurvivorSpaces(); i++) { Space space = youngGen.getSurvivorFromSpaceAt(0); @@ -146,7 +146,7 @@ private void computeNewOldGenSize(boolean resizeOnlyForPromotions) { // TenuredG } UnsignedWord maxShrinkBytes = oldSize.subtract(minimumDesiredCapacity); - UnsignedWord shrinkBytes = WordFactory.zero(); + UnsignedWord shrinkBytes = Word.zero(); if (MAX_HEAP_FREE_RATIO < 100) { double maximumFreePercentage = MAX_HEAP_FREE_RATIO / 100.0; double minimumUsedPercentage = 1 - maximumFreePercentage; @@ -198,7 +198,7 @@ private void computeNewYoungGenSize() { // DefNewGeneration::compute_new_size // DefNewGeneration::compute_space_boundaries, DefNewGeneration::compute_survivor_size survivorSize = minSpaceSize(alignDown(desiredNewSize.unsignedDivide(SURVIVOR_RATIO))); - UnsignedWord desiredEdenSize = WordFactory.zero(); + UnsignedWord desiredEdenSize = Word.zero(); if (desiredNewSize.aboveThan(survivorSize.multiply(2))) { desiredEdenSize = desiredNewSize.subtract(survivorSize.multiply(2)); } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ReferenceObjectProcessing.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ReferenceObjectProcessing.java index 3b05e632d8c7..bb103917e1e8 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ReferenceObjectProcessing.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ReferenceObjectProcessing.java @@ -31,9 +31,9 @@ import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -131,7 +131,7 @@ private static void discover(Object obj, ObjectReferenceVisitor refVisitor) { if (timestamp == 0) { // created or last accessed before the clock was initialized timestamp = initialSoftRefClock; } - UnsignedWord elapsed = WordFactory.unsigned(clock - timestamp); + UnsignedWord elapsed = Word.unsigned(clock - timestamp); if (elapsed.belowThan(maxSoftRefAccessIntervalMs)) { // Important: we need to pass the reference object as holder so that the remembered // set can be updated accordingly! diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/RuntimeImageHeapChunkWriter.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/RuntimeImageHeapChunkWriter.java index 0d430145769e..5880aa00d186 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/RuntimeImageHeapChunkWriter.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/RuntimeImageHeapChunkWriter.java @@ -29,7 +29,6 @@ import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.genscavenge.remset.RememberedSet; import com.oracle.svm.core.identityhashcode.IdentityHashCodeSupport; @@ -44,8 +43,8 @@ public class RuntimeImageHeapChunkWriter implements ImageHeapChunkWriter { RuntimeImageHeapChunkWriter(ByteBuffer buffer, long layoutToBufferOffsetAddend) { DirectBuffer direct = (DirectBuffer) buffer; // required from caller - this.heapBegin = WordFactory.pointer(direct.address()); - this.layoutToBufferOffsetAddend = WordFactory.signed(layoutToBufferOffsetAddend); + this.heapBegin = Word.pointer(direct.address()); + this.layoutToBufferOffsetAddend = Word.signed(layoutToBufferOffsetAddend); } private Pointer getChunkPointerInBuffer(int chunkPosition) { @@ -55,23 +54,23 @@ private Pointer getChunkPointerInBuffer(int chunkPosition) { @Override public void initializeAlignedChunk(int chunkPosition, long topOffset, long endOffset, long offsetToPreviousChunk, long offsetToNextChunk) { AlignedHeapChunk.AlignedHeader header = (AlignedHeapChunk.AlignedHeader) getChunkPointerInBuffer(chunkPosition); - header.setTopOffset(WordFactory.unsigned(topOffset)); - header.setEndOffset(WordFactory.unsigned(endOffset)); + header.setTopOffset(Word.unsigned(topOffset)); + header.setEndOffset(Word.unsigned(endOffset)); header.setSpace(null); - header.setOffsetToPreviousChunk(WordFactory.unsigned(offsetToPreviousChunk)); - header.setOffsetToNextChunk(WordFactory.unsigned(offsetToNextChunk)); - header.setIdentityHashSalt(WordFactory.zero(), IdentityHashCodeSupport.IDENTITY_HASHCODE_SALT_LOCATION); + header.setOffsetToPreviousChunk(Word.unsigned(offsetToPreviousChunk)); + header.setOffsetToNextChunk(Word.unsigned(offsetToNextChunk)); + header.setIdentityHashSalt(Word.zero(), IdentityHashCodeSupport.IDENTITY_HASHCODE_SALT_LOCATION); } @Override public void initializeUnalignedChunk(int chunkPosition, long topOffset, long endOffset, long offsetToPreviousChunk, long offsetToNextChunk) { UnalignedHeapChunk.UnalignedHeader header = (UnalignedHeapChunk.UnalignedHeader) getChunkPointerInBuffer(chunkPosition); - header.setTopOffset(WordFactory.unsigned(topOffset)); - header.setEndOffset(WordFactory.unsigned(endOffset)); + header.setTopOffset(Word.unsigned(topOffset)); + header.setEndOffset(Word.unsigned(endOffset)); header.setSpace(null); - header.setOffsetToPreviousChunk(WordFactory.unsigned(offsetToPreviousChunk)); - header.setOffsetToNextChunk(WordFactory.unsigned(offsetToNextChunk)); - header.setIdentityHashSalt(WordFactory.zero(), IdentityHashCodeSupport.IDENTITY_HASHCODE_SALT_LOCATION); + header.setOffsetToPreviousChunk(Word.unsigned(offsetToPreviousChunk)); + header.setOffsetToNextChunk(Word.unsigned(offsetToNextChunk)); + header.setIdentityHashSalt(Word.zero(), IdentityHashCodeSupport.IDENTITY_HASHCODE_SALT_LOCATION); } @Override diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/Space.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/Space.java index 2f35ca80da3e..233f4030b3b0 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/Space.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/Space.java @@ -33,7 +33,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -214,7 +213,7 @@ public void logChunks(Log log) { @AlwaysInline("GC performance") @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private Pointer allocateMemory(UnsignedWord objectSize) { - Pointer result = WordFactory.nullPointer(); + Pointer result = Word.nullPointer(); /* Fast-path: try allocating in the last chunk. */ AlignedHeapChunk.AlignedHeader oldChunk = getLastAlignedHeapChunk(); if (oldChunk.isNonNull()) { @@ -233,7 +232,7 @@ private Pointer allocateInNewChunk(UnsignedWord objectSize) { if (newChunk.isNonNull()) { return AlignedHeapChunk.allocateMemory(newChunk, objectSize); } - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -241,10 +240,10 @@ public void releaseChunks(ChunkReleaser chunkReleaser) { chunkReleaser.add(firstAlignedHeapChunk); chunkReleaser.add(firstUnalignedHeapChunk); - firstAlignedHeapChunk = WordFactory.nullPointer(); - lastAlignedHeapChunk = WordFactory.nullPointer(); - firstUnalignedHeapChunk = WordFactory.nullPointer(); - lastUnalignedHeapChunk = WordFactory.nullPointer(); + firstAlignedHeapChunk = Word.nullPointer(); + lastAlignedHeapChunk = Word.nullPointer(); + firstUnalignedHeapChunk = Word.nullPointer(); + lastUnalignedHeapChunk = Word.nullPointer(); accounting.reset(); } @@ -264,7 +263,7 @@ private void appendAlignedHeapChunkUninterruptibly(AlignedHeapChunk.AlignedHeade AlignedHeapChunk.AlignedHeader oldLast = getLastAlignedHeapChunk(); HeapChunk.setSpace(aChunk, this); HeapChunk.setPrevious(aChunk, oldLast); - HeapChunk.setNext(aChunk, WordFactory.nullPointer()); + HeapChunk.setNext(aChunk, Word.nullPointer()); if (oldLast.isNonNull()) { HeapChunk.setNext(oldLast, aChunk); } @@ -295,8 +294,8 @@ private void extractAlignedHeapChunkUninterruptibly(AlignedHeapChunk.AlignedHead } else { setLastAlignedHeapChunk(chunkPrev); } - HeapChunk.setNext(aChunk, WordFactory.nullPointer()); - HeapChunk.setPrevious(aChunk, WordFactory.nullPointer()); + HeapChunk.setNext(aChunk, Word.nullPointer()); + HeapChunk.setPrevious(aChunk, Word.nullPointer()); HeapChunk.setSpace(aChunk, null); } @@ -316,7 +315,7 @@ private void appendUnalignedHeapChunkUninterruptibly(UnalignedHeapChunk.Unaligne UnalignedHeapChunk.UnalignedHeader oldLast = getLastUnalignedHeapChunk(); HeapChunk.setSpace(uChunk, this); HeapChunk.setPrevious(uChunk, oldLast); - HeapChunk.setNext(uChunk, WordFactory.nullPointer()); + HeapChunk.setNext(uChunk, Word.nullPointer()); if (oldLast.isNonNull()) { HeapChunk.setNext(oldLast, uChunk); } @@ -348,8 +347,8 @@ private void extractUnalignedHeapChunkUninterruptibly(UnalignedHeapChunk.Unalign setLastUnalignedHeapChunk(chunkPrev); } /* Reset the fields that the result chunk keeps for Space. */ - HeapChunk.setNext(uChunk, WordFactory.nullPointer()); - HeapChunk.setPrevious(uChunk, WordFactory.nullPointer()); + HeapChunk.setNext(uChunk, Word.nullPointer()); + HeapChunk.setPrevious(uChunk, Word.nullPointer()); HeapChunk.setSpace(uChunk, null); } @@ -577,7 +576,7 @@ UnsignedWord computeObjectBytes() { } private UnsignedWord computeAlignedObjectBytes() { - UnsignedWord result = WordFactory.zero(); + UnsignedWord result = Word.zero(); AlignedHeapChunk.AlignedHeader aChunk = getFirstAlignedHeapChunk(); while (aChunk.isNonNull()) { UnsignedWord allocatedBytes = HeapChunk.getTopOffset(aChunk).subtract(AlignedHeapChunk.getObjectsStartOffset()); @@ -588,7 +587,7 @@ private UnsignedWord computeAlignedObjectBytes() { } private UnsignedWord computeUnalignedObjectBytes() { - UnsignedWord result = WordFactory.zero(); + UnsignedWord result = Word.zero(); UnalignedHeapChunk.UnalignedHeader uChunk = getFirstUnalignedHeapChunk(); while (uChunk.isNonNull()) { UnsignedWord allocatedBytes = HeapChunk.getTopOffset(uChunk).subtract(UnalignedHeapChunk.getObjectStartOffset()); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ThreadLocalAllocation.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ThreadLocalAllocation.java index d609f1f8bf4b..c725b3e80395 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ThreadLocalAllocation.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ThreadLocalAllocation.java @@ -40,7 +40,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateGCOptions; import com.oracle.svm.core.Uninterruptible; @@ -436,7 +435,7 @@ private static UnsignedWord availableTlabMemory(Descriptor allocator) { assert top.belowOrEqual(end); if (top.isNull() || end.isNull()) { - return WordFactory.unsigned(0); + return Word.unsigned(0); } return end.subtract(top); } @@ -444,7 +443,7 @@ private static UnsignedWord availableTlabMemory(Descriptor allocator) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static void guaranteeZeroed(Pointer memory, UnsignedWord size) { int wordSize = ConfigurationValues.getTarget().wordSize; - VMError.guarantee(UnsignedUtils.isAMultiple(size, WordFactory.unsigned(wordSize))); + VMError.guarantee(UnsignedUtils.isAMultiple(size, Word.unsigned(wordSize))); Pointer pos = memory; Pointer end = memory.add(size); @@ -494,20 +493,20 @@ private static void retireTlabToEden(IsolateThread thread) { Descriptor tlab = retireCurrentAllocationChunk(thread); AlignedHeader alignedChunk = tlab.getAlignedChunk(); UnalignedHeader unalignedChunk = tlab.getUnalignedChunk(); - tlab.setAlignedChunk(WordFactory.nullPointer()); - tlab.setUnalignedChunk(WordFactory.nullPointer()); + tlab.setAlignedChunk(Word.nullPointer()); + tlab.setUnalignedChunk(Word.nullPointer()); Space eden = HeapImpl.getHeapImpl().getYoungGeneration().getEden(); while (alignedChunk.isNonNull()) { AlignedHeader next = HeapChunk.getNext(alignedChunk); - HeapChunk.setNext(alignedChunk, WordFactory.nullPointer()); + HeapChunk.setNext(alignedChunk, Word.nullPointer()); eden.appendAlignedHeapChunk(alignedChunk); alignedChunk = next; } while (unalignedChunk.isNonNull()) { UnalignedHeader next = HeapChunk.getNext(unalignedChunk); - HeapChunk.setNext(unalignedChunk, WordFactory.nullPointer()); + HeapChunk.setNext(unalignedChunk, Word.nullPointer()); eden.appendUnalignedHeapChunk(unalignedChunk); unalignedChunk = next; } @@ -524,7 +523,7 @@ private static void registerNewAllocationChunk(Descriptor tlab, AlignedHeader ne tlab.setAllocationTop(HeapChunk.getTopPointer(newChunk), TLAB_TOP_IDENTITY); tlab.setAllocationEnd(HeapChunk.getEndPointer(newChunk), TLAB_END_IDENTITY); - HeapChunk.setTopPointer(newChunk, WordFactory.nullPointer()); + HeapChunk.setTopPointer(newChunk, Word.nullPointer()); } @Uninterruptible(reason = "Modifies and returns TLAB", callerMustBe = true) @@ -543,8 +542,8 @@ private static Descriptor retireCurrentAllocationChunk(IsolateThread thread) { * and only set in the top aligned chunk when it is retired. */ HeapChunk.setTopPointer(alignedChunk, allocationTop); - tlab.setAllocationTop(WordFactory.nullPointer(), TLAB_TOP_IDENTITY); - tlab.setAllocationEnd(WordFactory.nullPointer(), TLAB_END_IDENTITY); + tlab.setAllocationTop(Word.nullPointer(), TLAB_TOP_IDENTITY); + tlab.setAllocationEnd(Word.nullPointer(), TLAB_END_IDENTITY); UnsignedWord usedTlabSize = HeapChunk.getTopPointer(alignedChunk).subtract(AlignedHeapChunk.getObjectsStart(alignedChunk)); allocatedBytes.set(thread, allocatedBytes.get(thread).add(usedTlabSize)); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UnalignedHeapChunk.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UnalignedHeapChunk.java index 924962e23171..e0825c0f56d5 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UnalignedHeapChunk.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UnalignedHeapChunk.java @@ -27,7 +27,6 @@ import org.graalvm.nativeimage.c.struct.RawStructure; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -104,7 +103,7 @@ public static Pointer getObjectEnd(UnalignedHeader that) { static UnsignedWord getChunkSizeForObject(UnsignedWord objectSize) { UnsignedWord objectStart = getObjectStartOffset(); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(objectStart.add(objectSize), alignment); } @@ -112,7 +111,7 @@ static UnsignedWord getChunkSizeForObject(UnsignedWord objectSize) { @Uninterruptible(reason = "Returns uninitialized memory.", callerMustBe = true) public static Pointer allocateMemory(UnalignedHeader that, UnsignedWord size) { UnsignedWord available = HeapChunk.availableObjectMemory(that); - Pointer result = WordFactory.nullPointer(); + Pointer result = Word.nullPointer(); if (size.belowOrEqual(available)) { result = HeapChunk.getTopPointer(that); Pointer newTop = result.add(size); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/YoungGeneration.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/YoungGeneration.java index c05ca0118da2..f70b053e279f 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/YoungGeneration.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/YoungGeneration.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.genscavenge; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -193,7 +193,7 @@ UnsignedWord getChunkBytes() { */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) UnsignedWord getSurvivorChunkBytes() { - UnsignedWord chunkBytes = WordFactory.zero(); + UnsignedWord chunkBytes = Word.zero(); for (int i = 0; i < maxSurvivorSpaces; i++) { chunkBytes = chunkBytes.add(getSurvivorChunkBytes(i)); } @@ -216,7 +216,7 @@ UnsignedWord getAlignedChunkBytes() { * This value is only updated during a GC, be careful: see {@link #getChunkBytes}. */ UnsignedWord getSurvivorAlignedChunkBytes() { - UnsignedWord chunkBytes = WordFactory.zero(); + UnsignedWord chunkBytes = Word.zero(); for (int i = 0; i < maxSurvivorSpaces; i++) { chunkBytes = chunkBytes.add(this.survivorFromSpaces[i].getAlignedChunkBytes()); chunkBytes = chunkBytes.add(this.survivorToSpaces[i].getAlignedChunkBytes()); @@ -229,7 +229,7 @@ UnsignedWord computeObjectBytes() { } UnsignedWord computeSurvivorObjectBytes() { - UnsignedWord usedObjectBytes = WordFactory.zero(); + UnsignedWord usedObjectBytes = Word.zero(); for (int i = 0; i < maxSurvivorSpaces; i++) { usedObjectBytes = usedObjectBytes.add(survivorFromSpaces[i].computeObjectBytes()); usedObjectBytes = usedObjectBytes.add(survivorToSpaces[i].computeObjectBytes()); @@ -327,7 +327,7 @@ private boolean unalignedChunkFitsInSurvivors(UnalignedHeapChunk.UnalignedHeader AlignedHeapChunk.AlignedHeader requestAlignedSurvivorChunk() { assert VMOperation.isGCInProgress() : "Should only be called from the collector."; if (!alignedChunkFitsInSurvivors()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } return HeapImpl.getChunkProvider().produceAlignedChunk(); } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/MarkStack.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/MarkStack.java index 1a1004a8c886..e652da9304ff 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/MarkStack.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/MarkStack.java @@ -27,6 +27,7 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; import static jdk.vm.ci.code.CodeUtil.K; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.struct.RawField; @@ -35,7 +36,6 @@ import org.graalvm.nativeimage.c.struct.UniqueLocationIdentity; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -127,7 +127,7 @@ interface Segment extends PointerBase { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) private static Segment allocateSegment(Segment next) { - UnsignedWord size = WordFactory.unsigned(SEGMENT_SIZE); + UnsignedWord size = Word.unsigned(SEGMENT_SIZE); Segment segment = NullableNativeMemory.malloc(size, NmtCategory.GC); VMError.guarantee(segment.isNonNull(), "Could not allocate mark stack memory: malloc() returned null."); segment.setNext(next); @@ -138,7 +138,7 @@ private static Segment allocateSegment(Segment next) { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) private static UnsignedWord getOffsetAtIndex(int index) { int refSize = ConfigurationValues.getObjectLayout().getReferenceSize(); - return WordFactory.unsigned(index).multiply(refSize).add(SizeOf.unsigned(Segment.class)); + return Word.unsigned(index).multiply(refSize).add(SizeOf.unsigned(Segment.class)); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) @@ -146,7 +146,7 @@ public void tearDown() { if (top.isNonNull()) { assert top.getNext().isNull(); NullableNativeMemory.free(top); - top = WordFactory.nullPointer(); + top = Word.nullPointer(); } } } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/ObjectMoveInfo.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/ObjectMoveInfo.java index 862537cd2287..e0e0d9fe9240 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/ObjectMoveInfo.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/ObjectMoveInfo.java @@ -27,9 +27,9 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; import com.oracle.svm.core.util.VMError; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -98,7 +98,7 @@ static Pointer getNewAddress(Pointer objSeqStart) { if (useCompressedLayout()) { long offset = objSeqStart.readInt(-8); offset *= ConfigurationValues.getObjectLayout().getAlignment(); - return objSeqStart.add(WordFactory.signed(offset)); + return objSeqStart.add(Word.signed(offset)); } else { return objSeqStart.readWord(-16); } @@ -117,10 +117,10 @@ static void setObjectSeqSize(Pointer objSeqStart, UnsignedWord nbytes) { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) static UnsignedWord getObjectSeqSize(Pointer objSeqStart) { if (useCompressedLayout()) { - UnsignedWord value = WordFactory.unsigned(objSeqStart.readShort(-4) & 0xffff); + UnsignedWord value = Word.unsigned(objSeqStart.readShort(-4) & 0xffff); return value.multiply(ConfigurationValues.getObjectLayout().getAlignment()); } else { - return WordFactory.unsigned(objSeqStart.readInt(-8)); + return Word.unsigned(objSeqStart.readInt(-8)); } } @@ -137,10 +137,10 @@ static void setNextObjectSeqOffset(Pointer objSeqStart, UnsignedWord offset) { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) static UnsignedWord getNextObjectSeqOffset(Pointer objSeqStart) { if (useCompressedLayout()) { - UnsignedWord value = WordFactory.unsigned(objSeqStart.readShort(-2) & 0xffff); + UnsignedWord value = Word.unsigned(objSeqStart.readShort(-2) & 0xffff); return value.multiply(ConfigurationValues.getObjectLayout().getAlignment()); } else { - return WordFactory.unsigned(objSeqStart.readInt(-4)); + return Word.unsigned(objSeqStart.readInt(-4)); } } @@ -148,7 +148,7 @@ static UnsignedWord getNextObjectSeqOffset(Pointer objSeqStart) { static Pointer getNextObjectSeqAddress(Pointer objSeqStart) { UnsignedWord offset = getNextObjectSeqOffset(objSeqStart); if (offset.equal(0)) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } return objSeqStart.add(offset); } @@ -190,12 +190,12 @@ static Pointer getNewObjectAddress(Pointer objPointer) { AlignedHeapChunk.AlignedHeader chunk = AlignedHeapChunk.getEnclosingChunkFromObjectPointer(objPointer); if (objPointer.aboveOrEqual(HeapChunk.getTopPointer(chunk))) { - return WordFactory.nullPointer(); // object did not survive, is in gap at chunk end + return Word.nullPointer(); // object did not survive, is in gap at chunk end } Pointer objSeq = BrickTable.getEntry(chunk, BrickTable.getIndex(chunk, objPointer)); if (objSeq.aboveThan(objPointer)) { // object not alive, in gap across brick table entries - return WordFactory.nullPointer(); + return Word.nullPointer(); } Pointer nextObjSeq = getNextObjectSeqAddress(objSeq); @@ -204,7 +204,7 @@ static Pointer getNewObjectAddress(Pointer objPointer) { nextObjSeq = getNextObjectSeqAddress(objSeq); } if (objPointer.aboveOrEqual(objSeq.add(getObjectSeqSize(objSeq)))) { - return WordFactory.nullPointer(); // object did not survive, in gap between objects + return Word.nullPointer(); // object did not survive, in gap between objects } Pointer newObjSeqAddress = getNewAddress(objSeq); @@ -224,9 +224,9 @@ public static void visit(AlignedHeapChunk.AlignedHeader chunk, Visitor visitor) Pointer next = getNextObjectSeqAddress(p); do { // The visitor might overwrite the current and/or next move info, so read it eagerly. - UnsignedWord nextSize = next.isNonNull() ? getObjectSeqSize(next) : WordFactory.zero(); - Pointer nextNewAddress = next.isNonNull() ? getNewAddress(next) : WordFactory.nullPointer(); - Pointer nextNext = next.isNonNull() ? getNextObjectSeqAddress(next) : WordFactory.nullPointer(); + UnsignedWord nextSize = next.isNonNull() ? getObjectSeqSize(next) : Word.zero(); + Pointer nextNewAddress = next.isNonNull() ? getNewAddress(next) : Word.nullPointer(); + Pointer nextNext = next.isNonNull() ? getNextObjectSeqAddress(next) : Word.nullPointer(); if (!visitor.visit(p, size, newAddress, next)) { return; diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/PlanningVisitor.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/PlanningVisitor.java index ed7e0cbc192d..5d3c0ff28f8b 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/PlanningVisitor.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/compacting/PlanningVisitor.java @@ -28,7 +28,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.genscavenge.AlignedHeapChunk; @@ -65,14 +64,14 @@ public boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk) { Pointer initialTop = HeapChunk.getTopPointer(chunk); // top doesn't move until we are done Pointer objSeq = AlignedHeapChunk.getObjectsStart(chunk); - UnsignedWord gapSize = WordFactory.zero(); - UnsignedWord objSeqSize = WordFactory.zero(); - UnsignedWord brickIndex = WordFactory.zero(); + UnsignedWord gapSize = Word.zero(); + UnsignedWord objSeqSize = Word.zero(); + UnsignedWord brickIndex = Word.zero(); /* Initialize the move info structure at the chunk's object start location. */ ObjectMoveInfo.setNewAddress(objSeq, allocPointer); - ObjectMoveInfo.setObjectSeqSize(objSeq, WordFactory.zero()); - ObjectMoveInfo.setNextObjectSeqOffset(objSeq, WordFactory.zero()); + ObjectMoveInfo.setObjectSeqSize(objSeq, Word.zero()); + ObjectMoveInfo.setNextObjectSeqOffset(objSeq, Word.zero()); BrickTable.setEntry(chunk, brickIndex, objSeq); @@ -110,9 +109,9 @@ public boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk) { // Initialize new move info. objSeq = p; - ObjectMoveInfo.setNextObjectSeqOffset(objSeq, WordFactory.zero()); + ObjectMoveInfo.setNextObjectSeqOffset(objSeq, Word.zero()); - gapSize = WordFactory.zero(); + gapSize = Word.zero(); } objSeqSize = objSeqSize.add(objSize); @@ -123,7 +122,7 @@ public boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk) { ObjectMoveInfo.setNewAddress(objSeq, newAddress); ObjectMoveInfo.setObjectSeqSize(objSeq, objSeqSize); - objSeqSize = WordFactory.zero(); + objSeqSize = Word.zero(); /* Set brick table entries. */ UnsignedWord currentBrick = BrickTable.getIndex(chunk, p); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/AlignedChunkRememberedSet.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/AlignedChunkRememberedSet.java index b6829f655957..fb2358b02856 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/AlignedChunkRememberedSet.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/AlignedChunkRememberedSet.java @@ -31,7 +31,6 @@ import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -70,7 +69,7 @@ public static UnsignedWord getHeaderSize() { // Compaction needs room for a ObjectMoveInfo structure before the first object. headerSize = headerSize.add(ObjectMoveInfo.getSize()); } - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(headerSize, alignment); } @@ -84,10 +83,10 @@ public static void enableRememberedSet(HostedByteBufferPointer chunk, int chunkP UnsignedWord objectsStartOffset = AlignedHeapChunk.getObjectsStartOffset(); for (ImageHeapObject obj : objects) { long offsetWithinChunk = obj.getOffset() - chunkPosition; - assert offsetWithinChunk > 0 && WordFactory.unsigned(offsetWithinChunk).aboveOrEqual(objectsStartOffset); + assert offsetWithinChunk > 0 && Word.unsigned(offsetWithinChunk).aboveOrEqual(objectsStartOffset); - UnsignedWord startOffset = WordFactory.unsigned(offsetWithinChunk).subtract(objectsStartOffset); - UnsignedWord endOffset = startOffset.add(WordFactory.unsigned(obj.getSize())); + UnsignedWord startOffset = Word.unsigned(offsetWithinChunk).subtract(objectsStartOffset); + UnsignedWord endOffset = startOffset.add(Word.unsigned(obj.getSize())); FirstObjectTable.setTableForObject(fotStart, startOffset, endOffset); // The remembered set bit in the header will be set by the code that writes the objects. } @@ -175,7 +174,7 @@ public static void walkDirtyObjects(AlignedHeader chunk, GreyToBlackObjectVisito walkObjects(chunk, dirtyHeapStart, dirtyHeapEnd, visitor); } - if (PointerUtils.isAMultiple(cardPos, WordFactory.unsigned(wordSize()))) { + if (PointerUtils.isAMultiple(cardPos, Word.unsigned(wordSize()))) { /* Fast forward through word-aligned continuous range of clean cards. */ cardPos = cardPos.subtract(wordSize()); while (cardPos.aboveOrEqual(cardTableStart) && ((UnsignedWord) cardPos.readWord(0)).equal(CardTable.CLEAN_WORD)) { @@ -229,7 +228,7 @@ private static UnsignedWord getObjectIndex(AlignedHeader chunk, Pointer objectPo @Fold static UnsignedWord getStructSize() { - return WordFactory.unsigned(SizeOf.get(AlignedHeader.class)); + return Word.unsigned(SizeOf.get(AlignedHeader.class)); } @Fold @@ -238,7 +237,7 @@ static UnsignedWord getCardTableSize() { UnsignedWord structSize = getStructSize(); UnsignedWord available = HeapParameters.getAlignedHeapChunkSize().subtract(structSize); UnsignedWord requiredSize = CardTable.tableSizeForMemorySize(available); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(requiredSize, alignment); } @@ -250,7 +249,7 @@ static UnsignedWord getFirstObjectTableSize() { @Fold static UnsignedWord getFirstObjectTableStartOffset() { UnsignedWord cardTableLimit = getCardTableLimitOffset(); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(cardTableLimit, alignment); } @@ -259,14 +258,14 @@ static UnsignedWord getFirstObjectTableLimitOffset() { UnsignedWord fotStart = getFirstObjectTableStartOffset(); UnsignedWord fotSize = getFirstObjectTableSize(); UnsignedWord fotLimit = fotStart.add(fotSize); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(fotLimit, alignment); } @Fold static UnsignedWord getCardTableStartOffset() { UnsignedWord structSize = getStructSize(); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(structSize, alignment); } @@ -275,7 +274,7 @@ static UnsignedWord getCardTableLimitOffset() { UnsignedWord tableStart = getCardTableStartOffset(); UnsignedWord tableSize = getCardTableSize(); UnsignedWord tableLimit = tableStart.add(tableSize); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(tableLimit, alignment); } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/CardTable.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/CardTable.java index da3db8c45bd7..4c2159fe7459 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/CardTable.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/CardTable.java @@ -28,7 +28,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.UnmanagedMemoryUtil; @@ -81,7 +80,7 @@ final class CardTable { static final byte DIRTY_ENTRY = 0; static final byte CLEAN_ENTRY = 1; - static final UnsignedWord CLEAN_WORD = WordFactory.unsigned(0x0101010101010101L); + static final UnsignedWord CLEAN_WORD = Word.unsigned(0x0101010101010101L); private static final CardTableVerificationVisitor CARD_TABLE_VERIFICATION_VISITOR = new CardTableVerificationVisitor(); @@ -148,7 +147,7 @@ public static UnsignedWord tableSizeForMemorySize(UnsignedWord memorySize) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static UnsignedWord indexLimitForMemorySize(UnsignedWord memorySize) { - UnsignedWord roundedMemory = UnsignedUtils.roundUp(memorySize, WordFactory.unsigned(BYTES_COVERED_BY_ENTRY)); + UnsignedWord roundedMemory = UnsignedUtils.roundUp(memorySize, Word.unsigned(BYTES_COVERED_BY_ENTRY)); return CardTable.memoryOffsetToIndex(roundedMemory); } @@ -238,8 +237,8 @@ public void initialize(Object parentObject, Pointer cardTableStart, Pointer obje public void reset() { this.parentObject = null; - this.cardTableStart = WordFactory.nullPointer(); - this.objectsStart = WordFactory.nullPointer(); + this.cardTableStart = Word.nullPointer(); + this.objectsStart = Word.nullPointer(); this.success = false; } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/CardTableBasedRememberedSet.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/CardTableBasedRememberedSet.java index a6a2fb29dcd8..d9cbb6c97bbd 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/CardTableBasedRememberedSet.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/CardTableBasedRememberedSet.java @@ -26,10 +26,10 @@ import java.util.List; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -215,7 +215,7 @@ public boolean verify(AlignedHeader firstAlignedHeapChunk) { @Override public boolean verify(UnalignedHeader firstUnalignedHeapChunk) { - return verify(firstUnalignedHeapChunk, WordFactory.nullPointer()); + return verify(firstUnalignedHeapChunk, Word.nullPointer()); } @Override diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/FirstObjectTable.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/FirstObjectTable.java index 07c6679bd2f0..da526e240466 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/FirstObjectTable.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/FirstObjectTable.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.genscavenge.remset; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.SubstrateUtil; @@ -288,7 +288,7 @@ private static Pointer getFirstObject(Pointer tableStart, Pointer objectsStart, @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static UnsignedWord entryToMemoryOffset(UnsignedWord index, int entry) { assert isMemoryOffsetEntry(entry) : "Entry out of bounds."; - UnsignedWord entryOffset = WordFactory.unsigned(-entry).multiply(memoryOffsetScale()); + UnsignedWord entryOffset = Word.unsigned(-entry).multiply(memoryOffsetScale()); assert entryOffset.belowThan(BYTES_COVERED_BY_ENTRY) : "Entry out of bounds."; UnsignedWord indexOffset = indexToMemoryOffset(index); @@ -297,7 +297,7 @@ private static UnsignedWord entryToMemoryOffset(UnsignedWord index, int entry) { public static boolean verify(Pointer tableStart, Pointer objectsStart, Pointer objectsLimit) { UnsignedWord indexLimit = getTableSizeForMemoryRange(objectsStart, objectsLimit); - for (UnsignedWord index = WordFactory.unsigned(0); index.belowThan(indexLimit); index = index.add(1)) { + for (UnsignedWord index = Word.unsigned(0); index.belowThan(indexLimit); index = index.add(1)) { Pointer objStart = getFirstObject(tableStart, objectsStart, index); if (objStart.belowThan(objectsStart) || objectsLimit.belowOrEqual(objStart)) { Log.log().string("The first object table entry at index ").unsigned(index).string(" points to an object that is outside of the current chunk: obj: ").zhex(objStart) @@ -327,7 +327,7 @@ public static boolean verify(Pointer tableStart, Pointer objectsStart, Pointer o private static UnsignedWord getTableSizeForMemoryRange(Pointer memoryStart, Pointer memoryLimit) { assert memoryStart.belowOrEqual(memoryLimit) : "Pointers out of order"; UnsignedWord memorySize = memoryLimit.subtract(memoryStart); - UnsignedWord roundedMemory = UnsignedUtils.roundUp(memorySize, WordFactory.unsigned(BYTES_COVERED_BY_ENTRY)); + UnsignedWord roundedMemory = UnsignedUtils.roundUp(memorySize, Word.unsigned(BYTES_COVERED_BY_ENTRY)); UnsignedWord index = FirstObjectTable.memoryOffsetToIndex(roundedMemory); return index.multiply(ENTRY_SIZE_BYTES); } @@ -394,7 +394,7 @@ private static int unbiasExponent(int entry) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static UnsignedWord exponentToOffset(int n) { assert 0 <= n && n <= 63 : "Exponent out of bounds."; - return WordFactory.unsigned(1L << n); + return Word.unsigned(1L << n); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/NoRememberedSet.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/NoRememberedSet.java index 98f9e539e445..d9a95e236f00 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/NoRememberedSet.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/NoRememberedSet.java @@ -26,11 +26,11 @@ import java.util.List; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -61,15 +61,15 @@ public BarrierSet createBarrierSet(MetaAccessProvider metaAccess) { @Override public UnsignedWord getHeaderSizeOfAlignedChunk() { - UnsignedWord headerSize = WordFactory.unsigned(SizeOf.get(AlignedHeader.class)); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord headerSize = Word.unsigned(SizeOf.get(AlignedHeader.class)); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(headerSize, alignment); } @Override public UnsignedWord getHeaderSizeOfUnalignedChunk() { - UnsignedWord headerSize = WordFactory.unsigned(SizeOf.get(UnalignedHeader.class)); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord headerSize = Word.unsigned(SizeOf.get(UnalignedHeader.class)); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(headerSize, alignment); } diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/UnalignedChunkRememberedSet.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/UnalignedChunkRememberedSet.java index f48b02f7339c..851e27ca5d99 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/UnalignedChunkRememberedSet.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/remset/UnalignedChunkRememberedSet.java @@ -24,12 +24,12 @@ */ package com.oracle.svm.core.genscavenge.remset; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.config.ConfigurationValues; @@ -51,7 +51,7 @@ private UnalignedChunkRememberedSet() { @Fold public static UnsignedWord getHeaderSize() { UnsignedWord headerSize = getCardTableLimitOffset(); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(headerSize, alignment); } @@ -112,15 +112,15 @@ public static boolean verify(UnalignedHeader chunk) { @Fold static UnsignedWord getCardTableStartOffset() { - UnsignedWord headerSize = WordFactory.unsigned(SizeOf.get(UnalignedHeader.class)); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord headerSize = Word.unsigned(SizeOf.get(UnalignedHeader.class)); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(headerSize, alignment); } @Fold static UnsignedWord getCardTableSize() { - UnsignedWord requiredSize = CardTable.tableSizeForMemorySize(WordFactory.unsigned(1)); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord requiredSize = CardTable.tableSizeForMemorySize(Word.unsigned(1)); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(requiredSize, alignment); } @@ -129,13 +129,13 @@ static UnsignedWord getCardTableLimitOffset() { UnsignedWord tableStart = getCardTableStartOffset(); UnsignedWord tableSize = getCardTableSize(); UnsignedWord tableLimit = tableStart.add(tableSize); - UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); + UnsignedWord alignment = Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()); return UnsignedUtils.roundUp(tableLimit, alignment); } @Fold static UnsignedWord getObjectIndex() { - return WordFactory.zero(); + return Word.zero(); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64InterpreterStubs.java b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64InterpreterStubs.java index 4dfae74a7c6e..0b0055494816 100644 --- a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64InterpreterStubs.java +++ b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64InterpreterStubs.java @@ -35,6 +35,7 @@ import jdk.graal.compiler.asm.aarch64.AArch64MacroAssembler; import jdk.graal.compiler.core.common.NumUtil; import jdk.graal.compiler.lir.asm.CompilationResultBuilder; +import jdk.graal.compiler.word.Word; import jdk.vm.ci.aarch64.AArch64; import jdk.vm.ci.code.Register; import jdk.vm.ci.code.RegisterValue; @@ -45,7 +46,6 @@ import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; -import org.graalvm.word.WordFactory; import static jdk.graal.compiler.asm.aarch64.AArch64Address.AddressingMode.IMMEDIATE_POST_INDEXED; import static jdk.graal.compiler.asm.aarch64.AArch64Address.AddressingMode.IMMEDIATE_SIGNED_UNSCALED; @@ -520,7 +520,7 @@ public long getGpArgumentAt(AllocatableValue ccArg, Pointer data, int pos) { case 7 -> p.getAbiGpArg7(); default -> { StackSlot stackSlot = (StackSlot) ccArg; - Pointer spVal = WordFactory.pointer(p.getAbiSpReg()); + Pointer spVal = Word.pointer(p.getAbiSpReg()); yield spVal.readLong(stackSlot.getOffset(0)); } }; @@ -546,7 +546,7 @@ public long setGpArgumentAt(AllocatableValue ccArg, Pointer data, int pos, long } StackSlot stackSlot = (StackSlot) ccArg; - Pointer spVal = WordFactory.pointer(p.getAbiSpReg()); + Pointer spVal = Word.pointer(p.getAbiSpReg()); int offset = stackSlot.getOffset(0); VMError.guarantee(spVal.isNonNull()); VMError.guarantee(offset < p.getStackSize()); @@ -571,7 +571,7 @@ public long getFpArgumentAt(AllocatableValue ccArg, Pointer data, int pos) { case 7 -> p.getAbiFpArg7(); default -> { StackSlot stackSlot = (StackSlot) ccArg; - Pointer spVal = WordFactory.pointer(p.getAbiSpReg()); + Pointer spVal = Word.pointer(p.getAbiSpReg()); yield spVal.readLong(stackSlot.getOffset(0)); } }; @@ -592,7 +592,7 @@ public void setFpArgumentAt(AllocatableValue ccArg, Pointer data, int pos, long default -> { StackSlot stackSlot = (StackSlot) ccArg; - Pointer spVal = WordFactory.pointer(p.getAbiSpReg()); + Pointer spVal = Word.pointer(p.getAbiSpReg()); int offset = stackSlot.getOffset(0); VMError.guarantee(spVal.isNonNull()); diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64InterpreterStubs.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64InterpreterStubs.java index dcbea077eefe..e14f17ea2fe1 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64InterpreterStubs.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64InterpreterStubs.java @@ -39,6 +39,7 @@ import jdk.graal.compiler.asm.amd64.AMD64MacroAssembler; import jdk.graal.compiler.core.common.NumUtil; import jdk.graal.compiler.lir.asm.CompilationResultBuilder; +import jdk.graal.compiler.word.Word; import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.code.CallingConvention; import jdk.vm.ci.code.Register; @@ -52,7 +53,6 @@ import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; -import org.graalvm.word.WordFactory; import static jdk.vm.ci.amd64.AMD64.rax; import static jdk.vm.ci.amd64.AMD64.rsp; @@ -516,7 +516,7 @@ public long getGpArgumentAt(AllocatableValue ccArg, Pointer data, int pos) { case 5 -> p.getAbiGp5(); default -> { StackSlot stackSlot = (StackSlot) ccArg; - Pointer sp = WordFactory.pointer(p.getAbiSpReg()); + Pointer sp = Word.pointer(p.getAbiSpReg()); int spAdjustmentOnCall = ConfigurationValues.getTarget().wordSize; int offset = stackSlot.getOffset(0) + spAdjustmentOnCall; yield sp.readLong(offset); @@ -542,7 +542,7 @@ public long setGpArgumentAt(AllocatableValue ccArg, Pointer data, int pos, long } StackSlot stackSlot = (StackSlot) ccArg; - Pointer sp = WordFactory.pointer(p.getAbiSpReg()); + Pointer sp = Word.pointer(p.getAbiSpReg()); int offset = stackSlot.getOffset(0); VMError.guarantee(sp.isNonNull()); VMError.guarantee(offset < p.getStackSize()); @@ -583,7 +583,7 @@ public long getFpArgumentAt(AllocatableValue ccArg, Pointer data, int pos) { } } StackSlot stackSlot = (StackSlot) ccArg; - Pointer sp = WordFactory.pointer(p.getAbiSpReg()); + Pointer sp = Word.pointer(p.getAbiSpReg()); int spAdjustmentOnCall = ConfigurationValues.getTarget().wordSize; int offset = stackSlot.getOffset(0) + spAdjustmentOnCall; @@ -609,7 +609,7 @@ public void setFpArgumentAt(AllocatableValue ccArg, Pointer data, int pos, long } else { StackSlot stackSlot = (StackSlot) ccArg; - Pointer sp = WordFactory.pointer(p.getAbiSpReg()); + Pointer sp = Word.pointer(p.getAbiSpReg()); int offset = stackSlot.getOffset(0); VMError.guarantee(sp.isNonNull()); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixNativeLibraryFeature.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixNativeLibraryFeature.java index 9c091522abaa..8b059ed67407 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixNativeLibraryFeature.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixNativeLibraryFeature.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.core.posix; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -32,7 +33,6 @@ import org.graalvm.nativeimage.impl.InternalPlatform; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Isolates; import com.oracle.svm.core.annotate.Alias; @@ -83,7 +83,7 @@ public boolean initializeBuiltinLibraries() { if (Platform.includedIn(Platform.DARWIN.class)) { // On Darwin, getrlimit may return RLIM_INFINITY for rlim_max, but then OPEN_MAX // must be used for setrlimit or it will fail with errno EINVAL. - newValue = WordFactory.unsigned(DarwinSyslimits.OPEN_MAX()); + newValue = Word.unsigned(DarwinSyslimits.OPEN_MAX()); } rlp.set_rlim_cur(newValue); if (Resource.setrlimit(Resource.RLIMIT_NOFILE(), rlp) != 0) { @@ -114,7 +114,7 @@ public boolean initializeBuiltinLibraries() { */ if (Platform.includedIn(Platform.DARWIN.class)) { Time.timeval tv = UnsafeStackValue.get(Time.timeval.class); - Time.NoTransitions.gettimeofday(tv, WordFactory.nullPointer()); + Time.NoTransitions.gettimeofday(tv, Word.nullPointer()); Time.tm tm = UnsafeStackValue.get(Time.tm.class); Time.NoTransitions.localtime_r(tv.addressOftv_sec(), tm); } @@ -163,7 +163,7 @@ class PosixNativeLibrary implements NativeLibrary { private final String canonicalIdentifier; private final boolean builtin; - private PointerBase dlhandle = WordFactory.nullPointer(); + private PointerBase dlhandle = Word.nullPointer(); private boolean loaded = false; PosixNativeLibrary(String canonicalIdentifier, boolean builtin) { @@ -196,7 +196,7 @@ public boolean unload() { } assert dlhandle.isNonNull(); if (PosixUtils.dlclose(dlhandle)) { - dlhandle = WordFactory.nullPointer(); + dlhandle = Word.nullPointer(); return true; } else { return false; diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixProcessPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixProcessPropertiesSupport.java index c4f5b0812fc4..12b87ac0b2c3 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixProcessPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixProcessPropertiesSupport.java @@ -33,11 +33,11 @@ import java.util.Map.Entry; import java.util.stream.Collectors; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.BaseProcessPropertiesSupport; import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue; @@ -96,7 +96,7 @@ public String getObjectFile(PointerBase symbolAddress) { if (Dlfcn.dladdr(symbolAddress, info) == 0) { return null; } - CCharPointer realpath = Stdlib.realpath(info.dli_fname(), WordFactory.nullPointer()); + CCharPointer realpath = Stdlib.realpath(info.dli_fname(), Word.nullPointer()); if (realpath.isNull()) { return null; } @@ -157,7 +157,7 @@ protected static String realpath(String path) { * pointer to it, so I have to free it. */ try (CCharPointerHolder pathHolder = CTypeConversion.toCString(path)) { - CCharPointer realpath = Stdlib.realpath(pathHolder.get(), WordFactory.nullPointer()); + CCharPointer realpath = Stdlib.realpath(pathHolder.get(), Word.nullPointer()); if (realpath.isNull()) { /* Failure to find a real path. */ return null; diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixRawFileOperationSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixRawFileOperationSupport.java index 5f37c9a83358..ee413e5bf95e 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixRawFileOperationSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixRawFileOperationSupport.java @@ -27,6 +27,7 @@ import java.io.File; import java.nio.ByteOrder; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -35,7 +36,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; @@ -56,9 +56,9 @@ public PosixRawFileOperationSupport(boolean useNativeByteOrder) { @Override public CCharPointer allocateCPath(String path) { byte[] data = path.getBytes(); - CCharPointer filename = UntrackedNullableNativeMemory.malloc(WordFactory.unsigned(data.length + 1)); + CCharPointer filename = UntrackedNullableNativeMemory.malloc(Word.unsigned(data.length + 1)); if (filename.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } for (int i = 0; i < data.length; i++) { @@ -105,7 +105,7 @@ private static RawFileDescriptor open0(String path, int flags) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static RawFileDescriptor open0(CCharPointer cPath, int flags) { int permissions = PosixStat.S_IRUSR() | PosixStat.S_IWUSR(); - return WordFactory.signed(Fcntl.NoTransitions.open(cPath, flags, permissions)); + return Word.signed(Fcntl.NoTransitions.open(cPath, flags, permissions)); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -135,14 +135,14 @@ public long size(RawFileDescriptor fd) { @Override public long position(RawFileDescriptor fd) { int posixFd = getPosixFileDescriptor(fd); - return Unistd.NoTransitions.lseek(posixFd, WordFactory.signed(0), Unistd.SEEK_CUR()).rawValue(); + return Unistd.NoTransitions.lseek(posixFd, Word.signed(0), Unistd.SEEK_CUR()).rawValue(); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @Override public boolean seek(RawFileDescriptor fd, long position) { int posixFd = getPosixFileDescriptor(fd); - SignedWord newPos = Unistd.NoTransitions.lseek(posixFd, WordFactory.signed(position), Unistd.SEEK_SET()); + SignedWord newPos = Unistd.NoTransitions.lseek(posixFd, Word.signed(position), Unistd.SEEK_SET()); return position == newPos.rawValue(); } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSignalHandlerSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSignalHandlerSupport.java index 43aa534492c8..d45f31e6925c 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSignalHandlerSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSignalHandlerSupport.java @@ -46,7 +46,6 @@ import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; @@ -178,7 +177,7 @@ private static long installJavaSignalHandler0(int sig, long nativeH, boolean isS sigset_tPointer sigset = UnsafeStackValue.get(sigset_tPointer.class); Signal.NoTransitions.sigemptyset(sigset); Signal.NoTransitions.sigaddset(sigset, sig); - Signal.NoTransitions.sigprocmask(Signal.SIG_UNBLOCK(), sigset, WordFactory.nullPointer()); + Signal.NoTransitions.sigprocmask(Signal.SIG_UNBLOCK(), sigset, Word.nullPointer()); return dispatcherToHandler(oldDispatcher); } finally { @@ -290,7 +289,7 @@ private static SignalDispatcher handlerToDispatcher(long nativeH) { } else if (nativeH == ERROR_HANDLER) { return Signal.SIG_ERR(); } else { - return WordFactory.pointer(nativeH); + return Word.pointer(nativeH); } } @@ -351,7 +350,7 @@ static SignalDispatcher installNativeSignalHandler0(int signum, SignalDispatcher int structSigActionSize = SizeOf.get(Signal.sigaction.class); Signal.sigaction act = UnsafeStackValue.get(structSigActionSize); - LibC.memset(act, WordFactory.signed(0), WordFactory.unsigned(structSigActionSize)); + LibC.memset(act, Word.signed(0), Word.unsigned(structSigActionSize)); act.sa_flags(flags); act.sa_handler(handler); @@ -370,11 +369,11 @@ private static void installNativeSignalHandler0(int signum, Signal.AdvancedSigna int structSigActionSize = SizeOf.get(Signal.sigaction.class); Signal.sigaction act = UnsafeStackValue.get(structSigActionSize); - LibC.memset(act, WordFactory.signed(0), WordFactory.unsigned(structSigActionSize)); + LibC.memset(act, Word.signed(0), Word.unsigned(structSigActionSize)); act.sa_flags(Signal.SA_SIGINFO() | flags); act.sa_sigaction(handler); - int result = sigaction(signum, act, WordFactory.nullPointer(), isSignalHandlingAllowed); + int result = sigaction(signum, act, Word.nullPointer(), isSignalHandlingAllowed); PosixUtils.checkStatusIs0(result, "sigaction failed in installSignalHandler()."); } @@ -383,7 +382,7 @@ static PointerBase getCurrentDispatcher(int sig) { assert NativeSpinLockUtils.isLocked(LOCK.get()); Signal.sigaction handler = UnsafeStackValue.get(Signal.sigaction.class); - Signal.sigaction(sig, WordFactory.nullPointer(), handler); + Signal.sigaction(sig, Word.nullPointer(), handler); if ((handler.sa_flags() & Signal.SA_SIGINFO()) != Signal.SA_SIGINFO()) { return handler.sa_sigaction(); } @@ -523,8 +522,8 @@ public void execute(boolean isFirstIsolate) { } private static boolean isFirst() { - Word expected = WordFactory.zero(); - Word actual = NOOP_HANDLERS_INSTALLED.get().compareAndSwapWord(0, expected, WordFactory.unsigned(1), LocationIdentity.ANY_LOCATION); + Word expected = Word.zero(); + Word actual = NOOP_HANDLERS_INSTALLED.get().compareAndSwapWord(0, expected, Word.unsigned(1), LocationIdentity.ANY_LOCATION); return expected == actual; } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateGlobalSigprofHandler.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateGlobalSigprofHandler.java index 03b8bf79a00b..42b717c03967 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateGlobalSigprofHandler.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateGlobalSigprofHandler.java @@ -27,10 +27,10 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue; @@ -58,7 +58,7 @@ private static void updateInterval(long us) { newValue.it_interval().set_tv_sec(us / TimeUtils.microsPerSecond); newValue.it_interval().set_tv_usec(us % TimeUtils.microsPerSecond); - int status = Time.NoTransitions.setitimer(Time.TimerTypeEnum.ITIMER_PROF, newValue, WordFactory.nullPointer()); + int status = Time.NoTransitions.setitimer(Time.TimerTypeEnum.ITIMER_PROF, newValue, Word.nullPointer()); PosixUtils.checkStatusIs0(status, "setitimer(which, newValue, oldValue): wrong arguments."); } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSystemPropertiesSupport.java index 1587e32f2477..928b61540c85 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSystemPropertiesSupport.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.posix; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue; import com.oracle.svm.core.jdk.SystemPropertiesSupport; @@ -56,7 +56,7 @@ protected String userHomeValue() { protected String userDirValue() { int bufSize = Limits.MAXPATHLEN(); CCharPointer buf = UnsafeStackValue.get(bufSize); - if (Unistd.getcwd(buf, WordFactory.unsigned(bufSize)).isNonNull()) { + if (Unistd.getcwd(buf, Word.unsigned(bufSize)).isNonNull()) { return CTypeConversion.toJavaString(buf); } else { throw new java.lang.Error("Properties init: Could not determine current working directory."); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixUtils.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixUtils.java index 05dc5e506f8c..ffb232eb456e 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixUtils.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixUtils.java @@ -39,7 +39,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.Uninterruptible; @@ -79,7 +78,7 @@ static String setLocale(String category, String locale) { private static String setLocale(int category, String locale) { if (locale == null) { - CCharPointer cstrResult = Locale.setlocale(category, WordFactory.nullPointer()); + CCharPointer cstrResult = Locale.setlocale(category, Word.nullPointer()); return CTypeConversion.toJavaString(cstrResult); } try (CCharPointerHolder localePin = CTypeConversion.toCString(locale)) { @@ -224,7 +223,7 @@ public static boolean writeUninterruptibly(int fd, byte[] data) { DynamicHub hub = KnownIntrinsics.readHub(data); UnsignedWord baseOffset = LayoutEncoding.getArrayBaseOffset(hub.getLayoutEncoding()); Pointer dataPtr = Word.objectToUntrackedPointer(data).add(baseOffset); - return writeUninterruptibly(fd, dataPtr, WordFactory.unsigned(data.length)); + return writeUninterruptibly(fd, dataPtr, Word.unsigned(data.length)); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) @@ -283,7 +282,7 @@ public static int readUninterruptibly(int fd, Pointer buffer, int bufferLen, int int readBytes = -1; if (bufferOffset < bufferLen) { do { - readBytes = (int) Unistd.NoTransitions.read(fd, buffer.add(bufferOffset), WordFactory.unsigned(bufferLen - bufferOffset)).rawValue(); + readBytes = (int) Unistd.NoTransitions.read(fd, buffer.add(bufferOffset), Word.unsigned(bufferLen - bufferOffset)).rawValue(); } while (readBytes == -1 && LibC.errno() == Errno.EINTR()); } return readBytes; @@ -292,7 +291,7 @@ public static int readUninterruptibly(int fd, Pointer buffer, int bufferLen, int @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) public static int readUninterruptibly(int fd, Pointer buffer, int bufferSize) { VMError.guarantee(bufferSize >= 0); - long readBytes = readUninterruptibly(fd, buffer, WordFactory.unsigned(bufferSize)); + long readBytes = readUninterruptibly(fd, buffer, Word.unsigned(bufferSize)); assert (int) readBytes == readBytes; return (int) readBytes; } @@ -336,7 +335,7 @@ private static String getUserNameOrDir(int uid, boolean name) { } /* Does not use StackValue because it is not safe to use in virtual threads. */ - UnsignedWord allocSize = WordFactory.unsigned(SizeOf.get(passwdPointer.class) + SizeOf.get(passwd.class) + bufSize); + UnsignedWord allocSize = Word.unsigned(SizeOf.get(passwdPointer.class) + SizeOf.get(passwd.class) + bufSize); Pointer alloc = NullableNativeMemory.malloc(allocSize, NmtCategory.Internal); if (alloc.isNull()) { return null; @@ -346,7 +345,7 @@ private static String getUserNameOrDir(int uid, boolean name) { passwdPointer p = (passwdPointer) alloc; passwd pwent = (passwd) ((Pointer) p).add(SizeOf.get(passwdPointer.class)); CCharPointer pwBuf = (CCharPointer) ((Pointer) pwent).add(SizeOf.get(passwd.class)); - int code = Pwd.getpwuid_r(uid, pwent, pwBuf, WordFactory.unsigned(bufSize), p); + int code = Pwd.getpwuid_r(uid, pwent, pwBuf, Word.unsigned(bufSize), p); if (code != 0) { return null; } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixVirtualMemoryProvider.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixVirtualMemoryProvider.java index 6c6c3dbf5bf8..9668834fff82 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixVirtualMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixVirtualMemoryProvider.java @@ -37,7 +37,7 @@ import static com.oracle.svm.core.posix.headers.Mman.NoTransitions.mmap; import static com.oracle.svm.core.posix.headers.Mman.NoTransitions.mprotect; import static com.oracle.svm.core.posix.headers.Mman.NoTransitions.munmap; -import static jdk.graal.compiler.word.WordFactory.nullPointer; +import static jdk.graal.compiler.word.Word.nullPointer; import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; @@ -47,7 +47,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -78,9 +77,9 @@ public class PosixVirtualMemoryProvider implements VirtualMemoryProvider { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static UnsignedWord getPageSize() { Word value = CACHED_PAGE_SIZE.get().read(); - if (value.equal(WordFactory.zero())) { + if (value.equal(Word.zero())) { long queried = Unistd.NoTransitions.sysconf(Unistd._SC_PAGE_SIZE()); - value = WordFactory.unsigned(queried); + value = Word.unsigned(queried); CACHED_PAGE_SIZE.get().write(value); } return value; @@ -111,7 +110,7 @@ public UnsignedWord getGranularity() { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public Pointer reserve(UnsignedWord nbytes, UnsignedWord alignment, boolean executable) { if (nbytes.equal(0)) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } UnsignedWord granularity = getGranularity(); @@ -148,7 +147,7 @@ public Pointer reserve(UnsignedWord nbytes, UnsignedWord alignment, boolean exec @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public Pointer mapFile(PointerBase start, UnsignedWord nbytes, WordBase fileHandle, UnsignedWord offset, int access) { if ((start.isNonNull() && !isAligned(start)) || nbytes.equal(0)) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } int flags = MAP_PRIVATE(); @@ -157,14 +156,14 @@ public Pointer mapFile(PointerBase start, UnsignedWord nbytes, WordBase fileHand } int fd = (int) fileHandle.rawValue(); Pointer result = mmap(start, nbytes, accessAsProt(access), flags, fd, offset.rawValue()); - return result.notEqual(MAP_FAILED()) ? result : WordFactory.nullPointer(); + return result.notEqual(MAP_FAILED()) ? result : Word.nullPointer(); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public Pointer commit(PointerBase start, UnsignedWord nbytes, int access) { if ((start.isNonNull() && !isAligned(start)) || nbytes.equal(0)) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } int flags = MAP_ANON() | MAP_PRIVATE(); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64DarwinUContextRegisterDumper.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64DarwinUContextRegisterDumper.java index 2a629e2b61fd..f5b126432f96 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64DarwinUContextRegisterDumper.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64DarwinUContextRegisterDumper.java @@ -26,10 +26,10 @@ import static com.oracle.svm.core.RegisterDumper.dumpReg; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.RegisterDumper; import com.oracle.svm.core.Uninterruptible; @@ -93,27 +93,27 @@ public void dumpRegisters(Log log, Signal.ucontext_t uContext, boolean printLoca @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getHeapBase(Signal.ucontext_t uContext) { Signal.AArch64DarwinMContext64 sigcontext = uContext.uc_mcontext_darwin_aarch64(); - return WordFactory.pointer(sigcontext.regs().read(27)); + return Word.pointer(sigcontext.regs().read(27)); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getThreadPointer(Signal.ucontext_t uContext) { Signal.AArch64DarwinMContext64 sigcontext = uContext.uc_mcontext_darwin_aarch64(); - return WordFactory.pointer(sigcontext.regs().read(28)); + return Word.pointer(sigcontext.regs().read(28)); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getSP(Signal.ucontext_t uContext) { Signal.AArch64DarwinMContext64 sigcontext = uContext.uc_mcontext_darwin_aarch64(); - return WordFactory.pointer(sigcontext.sp()); + return Word.pointer(sigcontext.sp()); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getIP(Signal.ucontext_t uContext) { Signal.AArch64DarwinMContext64 sigcontext = uContext.uc_mcontext_darwin_aarch64(); - return WordFactory.pointer(sigcontext.pc()); + return Word.pointer(sigcontext.pc()); } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64LinuxUContextRegisterDumper.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64LinuxUContextRegisterDumper.java index f75eacabce03..7593dd45437f 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64LinuxUContextRegisterDumper.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64LinuxUContextRegisterDumper.java @@ -26,10 +26,10 @@ import static com.oracle.svm.core.RegisterDumper.dumpReg; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.RegisterDumper; import com.oracle.svm.core.Uninterruptible; @@ -95,27 +95,27 @@ public void dumpRegisters(Log log, ucontext_t uContext, boolean printLocationInf @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getHeapBase(ucontext_t uContext) { GregsPointer regs = uContext.uc_mcontext_linux_aarch64().regs(); - return WordFactory.pointer(regs.read(27)); + return Word.pointer(regs.read(27)); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getThreadPointer(ucontext_t uContext) { GregsPointer regs = uContext.uc_mcontext_linux_aarch64().regs(); - return WordFactory.pointer(regs.read(28)); + return Word.pointer(regs.read(28)); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getSP(ucontext_t uContext) { mcontext_linux_aarch64_t sigcontext = uContext.uc_mcontext_linux_aarch64(); - return WordFactory.pointer(sigcontext.sp()); + return Word.pointer(sigcontext.sp()); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getIP(ucontext_t uContext) { mcontext_linux_aarch64_t sigcontext = uContext.uc_mcontext_linux_aarch64(); - return WordFactory.pointer(sigcontext.pc()); + return Word.pointer(sigcontext.pc()); } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64LinuxUContextRegisterDumper.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64LinuxUContextRegisterDumper.java index e631a0e3f08c..174c48cb3467 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64LinuxUContextRegisterDumper.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64LinuxUContextRegisterDumper.java @@ -26,10 +26,10 @@ import static com.oracle.svm.core.RegisterDumper.dumpReg; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.RegisterDumper; import com.oracle.svm.core.Uninterruptible; @@ -79,27 +79,27 @@ public void dumpRegisters(Log log, ucontext_t uContext, boolean printLocationInf @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getHeapBase(ucontext_t uContext) { GregsPointer gregs = uContext.uc_mcontext_linux_amd64_gregs(); - return WordFactory.pointer(gregs.read(GregEnumLinuxAMD64.REG_R14())); + return Word.pointer(gregs.read(GregEnumLinuxAMD64.REG_R14())); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getThreadPointer(ucontext_t uContext) { GregsPointer gregs = uContext.uc_mcontext_linux_amd64_gregs(); - return WordFactory.pointer(gregs.read(GregEnumLinuxAMD64.REG_R15())); + return Word.pointer(gregs.read(GregEnumLinuxAMD64.REG_R15())); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getSP(ucontext_t uContext) { GregsPointer gregs = uContext.uc_mcontext_linux_amd64_gregs(); - return WordFactory.pointer(gregs.read(GregEnumLinuxAMD64.REG_RSP())); + return Word.pointer(gregs.read(GregEnumLinuxAMD64.REG_RSP())); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getIP(ucontext_t uContext) { GregsPointer gregs = uContext.uc_mcontext_linux_amd64_gregs(); - return WordFactory.pointer(gregs.read(GregEnumLinuxAMD64.REG_RIP())); + return Word.pointer(gregs.read(GregEnumLinuxAMD64.REG_RIP())); } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/attach/PosixAttachListenerThread.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/attach/PosixAttachListenerThread.java index 21c6dbaa310f..616dcfed9c95 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/attach/PosixAttachListenerThread.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/attach/PosixAttachListenerThread.java @@ -28,11 +28,11 @@ import java.nio.charset.StandardCharsets; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.attach.AttachListenerThread; import com.oracle.svm.core.posix.PosixUtils; @@ -145,7 +145,7 @@ private static String decodeString(Pointer buf, int[] stringEnds, int index) { int start = index == 0 ? 0 : stringEnds[index - 1] + 1; int length = stringEnds[index] - start; assert length >= 0; - return CTypeConversion.toJavaString((CCharPointer) buf.add(start), WordFactory.unsigned(length), StandardCharsets.UTF_8); + return CTypeConversion.toJavaString((CCharPointer) buf.add(start), Word.unsigned(length), StandardCharsets.UTF_8); } @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+18/src/hotspot/os/posix/attachListener_posix.cpp#L436-L455") diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinGOTHeapSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinGOTHeapSupport.java index 6fcda0a1f941..1cea26ef4858 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinGOTHeapSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinGOTHeapSupport.java @@ -31,11 +31,11 @@ import static com.oracle.svm.core.posix.headers.Mman.PROT_WRITE; import static com.oracle.svm.core.posix.headers.Mman.NoTransitions.mmap; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -55,7 +55,7 @@ public class DarwinGOTHeapSupport extends GOTHeapSupport { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) protected int initialize(WordPointer gotStartAddress) { int flags = MAP_ANON() | MAP_PRIVATE(); - Pointer gotMemory = mmap(WordFactory.nullPointer(), getPageAlignedGotSize(), PROT_READ() | PROT_WRITE(), flags, -1, 0); + Pointer gotMemory = mmap(Word.nullPointer(), getPageAlignedGotSize(), PROT_READ() | PROT_WRITE(), flags, -1, 0); if (gotMemory.isNull() || gotMemory.equal(MAP_FAILED())) { return CEntryPointErrors.DYNAMIC_METHOD_ADDRESS_RESOLUTION_GOT_FD_CREATE_FAILED; } @@ -92,7 +92,7 @@ public int mapGot(Pointer start) { * Map reserved address space for GOT to "global" GOT allocation, so that all isolates are * backed by the same table. */ - ret = DarwinVirtualMemory.vm_remap(taskSelf, gotStart, getPageAlignedGotSize(), WordFactory.nullPointer(), intFalse, + ret = DarwinVirtualMemory.vm_remap(taskSelf, gotStart, getPageAlignedGotSize(), Word.nullPointer(), intFalse, taskSelf, DARWIN_GOT_START_ADDRESS.get().read(), intFalse, currentProt, maxProt, DarwinVirtualMemory.VM_INHERIT_SHARE()); if (ret != 0) { return CEntryPointErrors.DYNAMIC_METHOD_ADDRESS_RESOLUTION_GOT_WRONG_MMAP; diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemorySupportImpl.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemorySupportImpl.java index 20e3bebb8713..7e68fb59d37c 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemorySupportImpl.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemorySupportImpl.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.posix.darwin; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue; @@ -51,7 +51,7 @@ public UnsignedWord size() { WordPointer physicalMemoryPointer = UnsafeStackValue.get(WordPointer.class); WordPointer physicalMemorySizePointer = UnsafeStackValue.get(WordPointer.class); physicalMemorySizePointer.write(SizeOf.unsigned(WordPointer.class)); - final int sysctlResult = Sysctl.sysctl(namePointer, 2, physicalMemoryPointer, physicalMemorySizePointer, WordFactory.nullPointer(), 0); + final int sysctlResult = Sysctl.sysctl(namePointer, 2, physicalMemoryPointer, physicalMemorySizePointer, Word.nullPointer(), 0); if (sysctlResult != 0) { Log.log().string("DarwinPhysicalMemory.PhysicalMemorySupportImpl.size(): sysctl() returns with errno: ").signed(LibC.errno()).newline(); throw VMError.shouldNotReachHere("DarwinPhysicalMemory.PhysicalMemorySupportImpl.size() failed."); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinProcessPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinProcessPropertiesSupport.java index bc9f508229a9..1a476e124260 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinProcessPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinProcessPropertiesSupport.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.posix.darwin; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.impl.ProcessPropertiesSupport; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue; @@ -45,7 +45,7 @@ public String getExecutableName() { /* Find out how long the executable path is. */ final CIntPointer sizePointer = UnsafeStackValue.get(CIntPointer.class); sizePointer.write(0); - if (DarwinDyld._NSGetExecutablePath(WordFactory.nullPointer(), sizePointer) != -1) { + if (DarwinDyld._NSGetExecutablePath(Word.nullPointer(), sizePointer) != -1) { VMError.shouldNotReachHere("DarwinProcessPropertiesSupport.getExecutableName: Executable path length is 0?"); } /* Allocate a correctly-sized buffer and ask again. */ diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinStackOverflowSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinStackOverflowSupport.java index 7e7e516a8d46..8156c2999610 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinStackOverflowSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinStackOverflowSupport.java @@ -32,11 +32,11 @@ import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.mach_vm_region; import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.vm_region_basic_info_data_64_t; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; @@ -66,12 +66,12 @@ public boolean lookupStack(WordPointer stackBasePtr, WordPointer stackEndPtr) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static UnsignedWord vmComputeStackGuardSize(UnsignedWord stackend) { - UnsignedWord guardsize = WordFactory.zero(); + UnsignedWord guardsize = Word.zero(); WordPointer address = StackValue.get(WordPointer.class); address.write(stackend); WordPointer size = StackValue.get(WordPointer.class); - size.write(WordFactory.zero()); + size.write(Word.zero()); vm_region_basic_info_data_64_t info = StackValue.get(vm_region_basic_info_data_64_t.class); WordPointer task = mach_task_self(); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java index 1d866a9fbdb0..c1c93cde9435 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.core.posix.darwin; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.c.function.CLibrary; @@ -32,7 +33,6 @@ import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder; import org.graalvm.nativeimage.impl.RuntimeSystemPropertiesSupport; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; @@ -53,7 +53,7 @@ protected String javaIoTmpdirValue() { /* Darwin has a per-user temp dir */ int buflen = Limits.PATH_MAX(); CCharPointer tmpPath = UnsafeStackValue.get(buflen); - UnsignedWord pathSize = Unistd.confstr(Unistd._CS_DARWIN_USER_TEMP_DIR(), tmpPath, WordFactory.unsigned(buflen)); + UnsignedWord pathSize = Unistd.confstr(Unistd._CS_DARWIN_USER_TEMP_DIR(), tmpPath, Word.unsigned(buflen)); if (pathSize.aboveThan(0) && pathSize.belowOrEqual(buflen)) { return CTypeConversion.toJavaString(tmpPath); } else { diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/jvmstat/PosixPerfMemoryProvider.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/jvmstat/PosixPerfMemoryProvider.java index 0aa03367a7f8..05dbbdddc3fb 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/jvmstat/PosixPerfMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/jvmstat/PosixPerfMemoryProvider.java @@ -40,6 +40,7 @@ import java.nio.ByteBuffer; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platform.LINUX; @@ -48,7 +49,6 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.VMInspectionOptions; @@ -128,7 +128,7 @@ public ByteBuffer create() { return null; } - Pointer mapAddress = Mman.mmap(WordFactory.nullPointer(), WordFactory.unsigned(size), Mman.PROT_READ() | Mman.PROT_WRITE(), Mman.MAP_SHARED(), fd, 0); + Pointer mapAddress = Mman.mmap(Word.nullPointer(), Word.unsigned(size), Mman.PROT_READ() | Mman.PROT_WRITE(), Mman.MAP_SHARED(), fd, 0); int result = Unistd.NoTransitions.close(fd); assert result != -1; @@ -142,7 +142,7 @@ public ByteBuffer create() { backingFilePath = filePath; /* Clear the shared memory region. */ - LibC.memset(mapAddress, WordFactory.signed(0), WordFactory.unsigned(size)); + LibC.memset(mapAddress, Word.signed(0), Word.unsigned(size)); return DirectByteBufferUtil.allocate(mapAddress.rawValue(), size); } @@ -275,7 +275,7 @@ private static int createSharedMemFile(CCharPointer directoryPath, CCharPointer * memory accesses if we don't. */ RawFileOperationSupport fs = RawFileOperationSupport.nativeByteOrder(); - RawFileDescriptor rawFd = WordFactory.signed(fd); + RawFileDescriptor rawFd = Word.signed(fd); int pageSize = NumUtil.safeToInt(VirtualMemoryProvider.get().getGranularity().rawValue()); boolean success = true; @@ -506,7 +506,7 @@ private static int restartableUnlink(CCharPointer pathname) { private static int restartableFtruncate(int fd, int size) { int result; do { - result = Unistd.NoTransitions.ftruncate(fd, WordFactory.signed(size)); + result = Unistd.NoTransitions.ftruncate(fd, Word.signed(size)); } while (result == -1 && LibC.errno() == Errno.EINTR()); return result; diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/DumpLinuxOSInfo.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/DumpLinuxOSInfo.java index f1ca19beb13d..7f7e9cd76071 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/DumpLinuxOSInfo.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/DumpLinuxOSInfo.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.posix.linux; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateDiagnostics; import com.oracle.svm.core.SubstrateDiagnostics.DiagnosticThunkRegistry; @@ -84,7 +84,7 @@ private static void printFirstLine(Log log, CCharPointer filename) { try { int bufferSize = 64; CCharPointer buffer = StackValue.get(bufferSize); - long readBytes = fs.read(fd, (Pointer) buffer, WordFactory.unsigned(bufferSize)); + long readBytes = fs.read(fd, (Pointer) buffer, Word.unsigned(bufferSize)); int length = countLineBytes(buffer, NumUtil.safeToInt(readBytes)); log.string(buffer, length); } finally { diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxGOTHeapSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxGOTHeapSupport.java index df5d4d030738..ae7a2c88cd60 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxGOTHeapSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxGOTHeapSupport.java @@ -31,6 +31,7 @@ import static com.oracle.svm.core.posix.headers.Mman.NoTransitions.shm_open; import static com.oracle.svm.core.posix.headers.Mman.NoTransitions.shm_unlink; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.CCharPointer; @@ -39,7 +40,6 @@ import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -58,7 +58,7 @@ public class LinuxGOTHeapSupport extends GOTHeapSupport { private static final String FILE_NAME_PREFIX = "/ni-got-"; private static final int FILE_NAME_PREFIX_LEN = FILE_NAME_PREFIX.length(); - private static final CGlobalData memoryViewFd = CGlobalDataFactory.createWord((WordBase) WordFactory.signed(-1)); + private static final CGlobalData memoryViewFd = CGlobalDataFactory.createWord((WordBase) Word.signed(-1)); private static final CGlobalData fileNamePrefix = CGlobalDataFactory.createCString(FILE_NAME_PREFIX); @Override @@ -74,7 +74,7 @@ protected int initialize(WordPointer gotStartAddress) { /* GOT shared memory file name format: fileNamePrefix-pid */ CCharPointer nameStr = StackValue.get(64 * SizeOf.get(CCharPointer.class)); - LibC.memcpy(nameStr, fileNamePrefix.get(), WordFactory.unsigned(FILE_NAME_PREFIX_LEN)); + LibC.memcpy(nameStr, fileNamePrefix.get(), Word.unsigned(FILE_NAME_PREFIX_LEN)); int iter = FILE_NAME_PREFIX_LEN + pidLen; nameStr.write(iter, (byte) '\0'); @@ -107,12 +107,12 @@ protected int initialize(WordPointer gotStartAddress) { UnsignedWord gotPageAlignedSize = getPageAlignedGotSize(); - if (Unistd.NoTransitions.ftruncate(fd, WordFactory.signed(gotPageAlignedSize.rawValue())) != 0) { + if (Unistd.NoTransitions.ftruncate(fd, Word.signed(gotPageAlignedSize.rawValue())) != 0) { Unistd.NoTransitions.close(fd); return CEntryPointErrors.DYNAMIC_METHOD_ADDRESS_RESOLUTION_GOT_FD_RESIZE_FAILED; } - Pointer gotMemory = mmap(WordFactory.nullPointer(), gotPageAlignedSize, PROT_READ() | PROT_WRITE(), MAP_SHARED(), fd, 0); + Pointer gotMemory = mmap(Word.nullPointer(), gotPageAlignedSize, PROT_READ() | PROT_WRITE(), MAP_SHARED(), fd, 0); if (gotMemory.isNull()) { Unistd.NoTransitions.close(fd); return CEntryPointErrors.DYNAMIC_METHOD_ADDRESS_RESOLUTION_GOT_FD_MAP_FAILED; @@ -123,7 +123,7 @@ protected int initialize(WordPointer gotStartAddress) { /* Keep the initial GOT mapping for writing. */ - memoryViewFd.get().write(WordFactory.signed(fd)); + memoryViewFd.get().write(Word.signed(fd)); gotStartAddress.write(gotMemory); return CEntryPointErrors.NO_ERROR; @@ -141,7 +141,7 @@ public int mapGot(Pointer start) { start, getPageAlignedGotSize(), memViewFd, - WordFactory.zero(), + Word.zero(), Access.READ); if (mappedAddress.isNull()) { diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java index 69829714701b..0d85948d70aa 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java @@ -47,7 +47,7 @@ import static com.oracle.svm.core.util.PointerUtils.roundDown; import static com.oracle.svm.core.util.UnsignedUtils.isAMultiple; import static com.oracle.svm.core.util.UnsignedUtils.roundUp; -import static jdk.graal.compiler.word.WordFactory.signed; +import static jdk.graal.compiler.word.Word.signed; import java.util.concurrent.ThreadLocalRandom; @@ -60,7 +60,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; @@ -103,7 +102,7 @@ */ public class LinuxImageHeapProvider extends AbstractImageHeapProvider { /** Magic value to verify that a located image file matches our loaded image. */ - public static final CGlobalData MAGIC = CGlobalDataFactory.createWord(WordFactory. signed(ThreadLocalRandom.current().nextLong())); + public static final CGlobalData MAGIC = CGlobalDataFactory.createWord(Word. signed(ThreadLocalRandom.current().nextLong())); private static final CGlobalData PROC_SELF_MAPS = CGlobalDataFactory.createCString("/proc/self/maps"); @@ -133,7 +132,7 @@ private static UnsignedWord getLayeredImageHeapAddressSpaceSize() { } int imageHeapOffset = Heap.getHeap().getImageHeapOffsetInAddressSpace(); assert imageHeapOffset >= 0; - UnsignedWord size = WordFactory.unsigned(imageHeapOffset); + UnsignedWord size = Word.unsigned(imageHeapOffset); UnsignedWord granularity = VirtualMemoryProvider.get().getGranularity(); assert isAMultiple(size, granularity); @@ -217,10 +216,10 @@ protected int initializeLayeredImage(Pointer firstHeapStart, Pointer selfReserve @Override @Uninterruptible(reason = "Called during isolate initialization.") public int initialize(Pointer reservedAddressSpace, UnsignedWord reservedSize, WordPointer basePointer, WordPointer endPointer) { - Pointer selfReservedMemory = WordFactory.nullPointer(); + Pointer selfReservedMemory = Word.nullPointer(); UnsignedWord requiredSize = getTotalRequiredAddressSpaceSize(); if (reservedAddressSpace.isNull()) { - UnsignedWord alignment = WordFactory.unsigned(Heap.getHeap().getPreferredAddressSpaceAlignment()); + UnsignedWord alignment = Word.unsigned(Heap.getHeap().getPreferredAddressSpaceAlignment()); selfReservedMemory = VirtualMemoryProvider.get().reserve(requiredSize, alignment, false); if (selfReservedMemory.isNull()) { return CEntryPointErrors.RESERVE_ADDRESS_SPACE_FAILED; @@ -239,7 +238,7 @@ public int initialize(Pointer reservedAddressSpace, UnsignedWord reservedSize, W heapBase = selfReservedHeapBase; } else { heapBase = reservedAddressSpace.add(preHeapRequiredBytes); - selfReservedHeapBase = WordFactory.nullPointer(); + selfReservedHeapBase = Word.nullPointer(); } remainingSize = remainingSize.subtract(preHeapRequiredBytes); @@ -340,7 +339,7 @@ private static int initializeImageHeap(Pointer imageHeap, UnsignedWord reservedS } int result = copyRelocations(imageHeap, pageSize, heapBeginSym, heapRelocsSym, heapAnyRelocPointer, heapRelocsEndSym, heapWritablePatchedSym, heapWritablePatchedEndSym, - WordFactory.nullPointer()); + Word.nullPointer()); if (result != CEntryPointErrors.NO_ERROR) { return result; } @@ -395,7 +394,7 @@ private static int initializeImageHeapWithMremap(Pointer imageHeap, UnsignedWord private static Pointer getCachedImageHeapRelocations(Pointer cachedImageHeapRelocationsPtr, UnsignedWord pageSize, Word heapRelocsSym, Word heapWritablePatchedEndSym) { Pointer imageHeapRelocations = cachedImageHeapRelocationsPtr.readWord(0, LocationIdentity.ANY_LOCATION); if (imageHeapRelocations.isNull() || imageHeapRelocations.equal(COPY_RELOCATIONS_IN_PROGRESS)) { - if (!cachedImageHeapRelocationsPtr.logicCompareAndSwapWord(0, WordFactory.nullPointer(), COPY_RELOCATIONS_IN_PROGRESS, LocationIdentity.ANY_LOCATION)) { + if (!cachedImageHeapRelocationsPtr.logicCompareAndSwapWord(0, Word.nullPointer(), COPY_RELOCATIONS_IN_PROGRESS, LocationIdentity.ANY_LOCATION)) { /* Wait for other thread to initialize heap relocations. */ while ((imageHeapRelocations = cachedImageHeapRelocationsPtr.readWordVolatile(0, LocationIdentity.ANY_LOCATION)).equal(COPY_RELOCATIONS_IN_PROGRESS)) { PauseNode.pause(); @@ -409,7 +408,7 @@ private static Pointer getCachedImageHeapRelocations(Pointer cachedImageHeapRelo Pointer linkedRelocsBoundary = roundDown(heapRelocsSym, pageSize); UnsignedWord heapRelocsLength = roundUp(heapWritablePatchedEndSym.subtract(linkedRelocsBoundary), pageSize); int mremapFlags = LinuxLibCHelper.MREMAP_MAYMOVE() | LinuxLibCHelper.MREMAP_DONTUNMAP(); - imageHeapRelocations = LinuxLibCHelper.NoTransitions.mremapP(linkedRelocsBoundary, heapRelocsLength, heapRelocsLength, mremapFlags, WordFactory.nullPointer()); + imageHeapRelocations = LinuxLibCHelper.NoTransitions.mremapP(linkedRelocsBoundary, heapRelocsLength, heapRelocsLength, mremapFlags, Word.nullPointer()); if (imageHeapRelocations.equal(-1)) { if (LibC.errno() == Errno.EINVAL()) { @@ -420,13 +419,13 @@ private static Pointer getCachedImageHeapRelocations(Pointer cachedImageHeapRelo * https://github.com/torvalds/linux/commit/ * a4609387859f0281951f5e476d9f76d7fb9ab321 */ - imageHeapRelocations = WordFactory.pointer(-CEntryPointErrors.MREMAP_NOT_SUPPORTED); + imageHeapRelocations = Word.pointer(-CEntryPointErrors.MREMAP_NOT_SUPPORTED); } else { - imageHeapRelocations = WordFactory.pointer(-CEntryPointErrors.MAP_HEAP_FAILED); + imageHeapRelocations = Word.pointer(-CEntryPointErrors.MAP_HEAP_FAILED); } } else { if (VirtualMemoryProvider.get().protect(imageHeapRelocations, heapRelocsLength, Access.READ) != 0) { - imageHeapRelocations = WordFactory.pointer(-CEntryPointErrors.PROTECT_HEAP_FAILED); + imageHeapRelocations = Word.pointer(-CEntryPointErrors.PROTECT_HEAP_FAILED); } } @@ -443,7 +442,7 @@ private static int copyRelocations(Pointer imageHeap, UnsignedWord pageSize, Wor Word heapWritablePatchedSym, Word heapWritablePatchedEndSym, Pointer cachedRelocsBoundary) { Pointer linkedRelocsBoundary = roundDown(heapRelocsSym, pageSize); Pointer sourceRelocsBoundary = cachedRelocsBoundary.isNonNull() ? cachedRelocsBoundary : linkedRelocsBoundary; - Pointer linkedCopyStart = WordFactory.nullPointer(); + Pointer linkedCopyStart = Word.nullPointer(); if (heapRelocsEndSym.subtract(heapRelocsSym).isNonNull()) { /* * Use a representative pointer to determine whether it is necessary to copy over the diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java index 843fdbeff2ed..b776fa262c78 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java @@ -31,9 +31,9 @@ import java.util.ArrayList; import java.util.List; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.container.Container; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; @@ -54,7 +54,7 @@ public UnsignedWord size() { if (numberOfPhysicalMemoryPages == -1 || sizeOfAPhysicalMemoryPage == -1) { throw VMError.shouldNotReachHere("Physical memory size (number of pages or page size) not available"); } - return WordFactory.unsigned(numberOfPhysicalMemoryPages).multiply(WordFactory.unsigned(sizeOfAPhysicalMemoryPage)); + return Word.unsigned(numberOfPhysicalMemoryPages).multiply(Word.unsigned(sizeOfAPhysicalMemoryPage)); } @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxStackOverflowSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxStackOverflowSupport.java index 59c9e876e9c8..22793fffcc77 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxStackOverflowSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxStackOverflowSupport.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.posix.linux; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; @@ -42,8 +42,8 @@ final class LinuxStackOverflowSupport implements StackOverflowCheck.PlatformSupp public boolean lookupStack(WordPointer stackBasePtr, WordPointer stackEndPtr) { boolean result = lookupStack0(stackBasePtr, stackEndPtr); if (!result) { - stackBasePtr.write(WordFactory.zero()); - stackEndPtr.write(WordFactory.zero()); + stackBasePtr.write(Word.zero()); + stackEndPtr.write(Word.zero()); } return result; } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSubstrateSigprofHandler.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSubstrateSigprofHandler.java index 396a8dddb5a5..792b53ec5766 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSubstrateSigprofHandler.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSubstrateSigprofHandler.java @@ -27,6 +27,7 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; @@ -35,7 +36,6 @@ import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue; @@ -89,7 +89,7 @@ protected void install0(IsolateThread thread) { sigevent.sigev_notify(Signal.SIGEV_SIGNAL()); sigevent.sigev_signo(Signal.SignalEnum.SIGPROF.getCValue()); WordPointer timerPointer = StackValue.get(WordPointer.class); - timerPointer.write(WordFactory.zero()); + timerPointer.write(Word.zero()); int status = LinuxTime.NoTransitions.timer_create(LinuxTime.CLOCK_MONOTONIC(), sigevent, timerPointer); PosixUtils.checkStatusIs0(status, "timer_create(clockid, sevp, timerid): wrong arguments."); @@ -118,31 +118,31 @@ private void updateInterval(IsolateThread thread) { newTimerSpec.it_interval().set_tv_sec(ns / TimeUtils.nanosPerSecond); newTimerSpec.it_interval().set_tv_nsec(ns % TimeUtils.nanosPerSecond); - int status = LinuxTime.NoTransitions.timer_settime(getSamplerTimerId(thread), 0, newTimerSpec, WordFactory.nullPointer()); + int status = LinuxTime.NoTransitions.timer_settime(getSamplerTimerId(thread), 0, newTimerSpec, Word.nullPointer()); PosixUtils.checkStatusIs0(status, "timer_settime(timerid, flags, newTimerSpec, oldValue): wrong arguments."); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) private static boolean hasSamplerTimerId(IsolateThread thread) { assert CurrentIsolate.getCurrentThread() == thread || VMOperation.isInProgressAtSafepoint(); - return samplerTimerId.get(thread).and(WordFactory.unsigned(MARKER)).notEqual(0); + return samplerTimerId.get(thread).and(Word.unsigned(MARKER)).notEqual(0); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) private static UnsignedWord getSamplerTimerId(IsolateThread thread) { assert hasSamplerTimerId(thread); - return samplerTimerId.get(thread).and(WordFactory.unsigned(~MARKER)); + return samplerTimerId.get(thread).and(Word.unsigned(~MARKER)); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) private static void setSamplerTimerId(IsolateThread thread, UnsignedWord timerId) { - assert !hasSamplerTimerId(thread) && timerId.and(WordFactory.unsigned(MARKER)).equal(0); - samplerTimerId.set(thread, timerId.or(WordFactory.unsigned(MARKER))); + assert !hasSamplerTimerId(thread) && timerId.and(Word.unsigned(MARKER)).equal(0); + samplerTimerId.set(thread, timerId.or(Word.unsigned(MARKER))); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) private static void clearSamplerTimerId(IsolateThread thread) { assert hasSamplerTimerId(thread); - samplerTimerId.set(thread, WordFactory.zero()); + samplerTimerId.set(thread, Word.zero()); } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxVMLockSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxVMLockSupport.java index ed4fb9df3bec..15ca7eb2eef8 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxVMLockSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxVMLockSupport.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.posix.linux; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CIsolateData; @@ -64,7 +64,7 @@ private Semaphore.sem_t getStructPointer() { @Override @Uninterruptible(reason = "Too early for safepoints.") public int initialize() { - return Semaphore.NoTransitions.sem_init(getStructPointer(), WordFactory.signed(0), WordFactory.unsigned(0)); + return Semaphore.NoTransitions.sem_init(getStructPointer(), Word.signed(0), Word.unsigned(0)); } @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/ProcFSSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/ProcFSSupport.java index 42b0dfde0e5d..e499a92fb5b8 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/ProcFSSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/ProcFSSupport.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.posix.linux; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.posix.PosixUtils; @@ -72,9 +72,9 @@ static boolean findMapping(int fd, CCharPointer buffer, int bufferLen, UnsignedW int state = ST_ADDR_START; int b; - UnsignedWord start = WordFactory.zero(); - UnsignedWord end = WordFactory.zero(); - UnsignedWord fileOffset = WordFactory.zero(); + UnsignedWord start = Word.zero(); + UnsignedWord end = Word.zero(); + UnsignedWord fileOffset = Word.zero(); OUT: for (;;) { while (position == endOffset) { // fill buffer int readBytes = PosixUtils.readUninterruptibly(fd, (Pointer) buffer, bufferLen, readOffset); @@ -112,7 +112,7 @@ static boolean findMapping(int fd, CCharPointer buffer, int bufferLen, UnsignedW } case ST_PERMS: { if (b == ' ') { - fileOffset = WordFactory.zero(); + fileOffset = Word.zero(); state = ST_OFFSET; } break; // ignore anything else @@ -169,8 +169,8 @@ static boolean findMapping(int fd, CCharPointer buffer, int bufferLen, UnsignedW } case ST_SKIP: { if (b == '\n') { - start = WordFactory.zero(); - end = WordFactory.zero(); + start = Word.zero(); + end = Word.zero(); state = ST_ADDR_START; } break; diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadConditionUtils.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadConditionUtils.java index d699f5597c48..04c651442edd 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadConditionUtils.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadConditionUtils.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.posix.pthread; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.StackValue; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.posix.PosixUtils; @@ -78,7 +78,7 @@ static boolean useMonotonicClockForRelativeWait() { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static int initConditionWithAbsoluteTime(pthread_cond_t cond) { - return Pthread.pthread_cond_init(cond, WordFactory.nullPointer()); + return Pthread.pthread_cond_init(cond, Word.nullPointer()); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java index 4deedb016543..e2a48f6ef6ef 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java @@ -26,11 +26,11 @@ import static com.oracle.svm.core.heap.RestrictHeapAccess.Access.NO_ALLOCATION; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.LogHandler; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CIsolateData; @@ -102,7 +102,7 @@ Pthread.pthread_mutex_t getStructPointer() { @Override @Uninterruptible(reason = "Too early for safepoints.") public int initialize() { - return Pthread.pthread_mutex_init(getStructPointer(), WordFactory.nullPointer()); + return Pthread.pthread_mutex_init(getStructPointer(), Word.nullPointer()); } @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/riscv64/RISCV64LinuxUContextRegisterDumperFeature.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/riscv64/RISCV64LinuxUContextRegisterDumperFeature.java index ef5fc0b52956..0286633e3eac 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/riscv64/RISCV64LinuxUContextRegisterDumperFeature.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/riscv64/RISCV64LinuxUContextRegisterDumperFeature.java @@ -26,10 +26,10 @@ import static com.oracle.svm.core.RegisterDumper.dumpReg; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.RegisterDumper; import com.oracle.svm.core.Uninterruptible; @@ -95,21 +95,21 @@ public void dumpRegisters(Log log, Signal.ucontext_t uContext, boolean printLoca @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getHeapBase(ucontext_t uContext) { GregsPointer regs = uContext.uc_mcontext_linux_riscv64().gregs(); - return WordFactory.pointer(regs.read(27)); + return Word.pointer(regs.read(27)); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getThreadPointer(ucontext_t uContext) { GregsPointer regs = uContext.uc_mcontext_linux_riscv64().gregs(); - return WordFactory.pointer(regs.read(23)); + return Word.pointer(regs.read(23)); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getSP(ucontext_t uContext) { GregsPointer regs = uContext.uc_mcontext_linux_riscv64().gregs(); - return WordFactory.pointer(regs.read(2)); + return Word.pointer(regs.read(2)); } @Override @@ -117,6 +117,6 @@ public PointerBase getSP(ucontext_t uContext) { public PointerBase getIP(ucontext_t uContext) { // gregs[0] holds the program counter. GregsPointer regs = uContext.uc_mcontext_linux_riscv64().gregs(); - return WordFactory.pointer(regs.read(0)); + return Word.pointer(regs.read(0)); } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java index d6c27d752c97..80dca1fbd70f 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.core.posix.thread; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platform.HOSTED_ONLY; @@ -39,7 +40,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.Uninterruptible; @@ -97,13 +97,13 @@ protected boolean doStartThread(Thread thread, long stackSize) { return false; } - UnsignedWord threadStackSize = WordFactory.unsigned(stackSize); + UnsignedWord threadStackSize = Word.unsigned(stackSize); /* If there is a chosen stack size, use it as the stack size. */ - if (threadStackSize.notEqual(WordFactory.zero())) { + if (threadStackSize.notEqual(Word.zero())) { /* Make sure the chosen stack size is large enough. */ threadStackSize = UnsignedUtils.max(threadStackSize, Pthread.PTHREAD_STACK_MIN()); /* Make sure the chosen stack size is a multiple of the system page size. */ - threadStackSize = UnsignedUtils.roundUp(threadStackSize, WordFactory.unsigned(Unistd.getpagesize())); + threadStackSize = UnsignedUtils.roundUp(threadStackSize, Word.unsigned(Unistd.getpagesize())); if (Pthread.pthread_attr_setstacksize(attributes, threadStackSize) != 0) { return false; @@ -213,25 +213,25 @@ public OSThreadHandle startThreadUnmanaged(CFunctionPointer threadRoutine, Point pthread_attr_t attributes = StackValue.get(pthread_attr_t.class); int status = Pthread.pthread_attr_init_no_transition(attributes); if (status != 0) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } try { status = Pthread.pthread_attr_setdetachstate_no_transition(attributes, Pthread.PTHREAD_CREATE_JOINABLE()); if (status != 0) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } - UnsignedWord threadStackSize = WordFactory.unsigned(stackSize); + UnsignedWord threadStackSize = Word.unsigned(stackSize); /* If there is a chosen stack size, use it as the stack size. */ - if (threadStackSize.notEqual(WordFactory.zero())) { + if (threadStackSize.notEqual(Word.zero())) { /* Make sure the chosen stack size is large enough. */ threadStackSize = UnsignedUtils.max(threadStackSize, Pthread.PTHREAD_STACK_MIN()); /* Make sure the chosen stack size is a multiple of the system page size. */ - threadStackSize = UnsignedUtils.roundUp(threadStackSize, WordFactory.unsigned(Unistd.NoTransitions.getpagesize())); + threadStackSize = UnsignedUtils.roundUp(threadStackSize, Word.unsigned(Unistd.NoTransitions.getpagesize())); status = Pthread.pthread_attr_setstacksize_no_transition(attributes, threadStackSize); if (status != 0) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } } @@ -239,7 +239,7 @@ public OSThreadHandle startThreadUnmanaged(CFunctionPointer threadRoutine, Point status = Pthread.pthread_create_no_transition(newThread, attributes, threadRoutine, userData); if (status != 0) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } return newThread.read(); @@ -259,7 +259,7 @@ public boolean joinThreadUnmanaged(OSThreadHandle threadHandle, WordPointer thre @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public ThreadLocalKey createUnmanagedThreadLocal() { Pthread.pthread_key_tPointer key = StackValue.get(Pthread.pthread_key_tPointer.class); - PosixUtils.checkStatusIs0(Pthread.pthread_key_create(key, WordFactory.nullPointer()), "pthread_key_create(key, keyDestructor): failed."); + PosixUtils.checkStatusIs0(Pthread.pthread_key_create(key, Word.nullPointer()), "pthread_key_create(key, keyDestructor): failed."); return (ThreadLocalKey) key.read(); } @@ -326,7 +326,7 @@ final class PosixParker extends Parker { relativeCond = (pthread_cond_t) memory.add(mutexSize); absoluteCond = (pthread_cond_t) memory.add(mutexSize).add(condSize); - final Pthread.pthread_mutexattr_t mutexAttr = WordFactory.nullPointer(); + final Pthread.pthread_mutexattr_t mutexAttr = Word.nullPointer(); PosixUtils.checkStatusIs0(Pthread.pthread_mutex_init(mutex, mutexAttr), "mutex initialization"); PosixUtils.checkStatusIs0(PthreadConditionUtils.initConditionWithRelativeTime(relativeCond), "relative-time condition variable initialization"); PosixUtils.checkStatusIs0(PthreadConditionUtils.initConditionWithAbsoluteTime(absoluteCond), "absolute-time condition variable initialization"); @@ -378,7 +378,7 @@ private void park0(boolean isAbsolute, long time) { } assert status == 0 || status == Errno.ETIMEDOUT(); } finally { - currentCond = WordFactory.nullPointer(); + currentCond = Word.nullPointer(); } } event = 0; @@ -429,16 +429,16 @@ protected void release() { /* The conditions and the mutex are allocated with a single malloc. */ int status = Pthread.pthread_cond_destroy(relativeCond); assert status == 0; - relativeCond = WordFactory.nullPointer(); + relativeCond = Word.nullPointer(); status = Pthread.pthread_cond_destroy(absoluteCond); assert status == 0; - absoluteCond = WordFactory.nullPointer(); + absoluteCond = Word.nullPointer(); status = Pthread.pthread_mutex_destroy(mutex); assert status == 0; NativeMemory.free(mutex); - mutex = WordFactory.nullPointer(); + mutex = Word.nullPointer(); } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixVMThreads.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixVMThreads.java index 9700d44a4b1a..96fd2b95f6df 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixVMThreads.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixVMThreads.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.core.posix.thread; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; @@ -33,7 +34,6 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.word.ComparableWord; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -70,11 +70,11 @@ public OSThreadHandle getCurrentOSThreadHandle() { protected OSThreadId getCurrentOSThreadId() { if (Platform.includedIn(Platform.DARWIN.class)) { Pthread.pthread_t pthread = Pthread.pthread_self(); - return WordFactory.unsigned(DarwinPthread.pthread_mach_thread_np(pthread)); + return Word.unsigned(DarwinPthread.pthread_mach_thread_np(pthread)); } else if (Platform.includedIn(Platform.LINUX.class)) { int result = LinuxLibCHelper.getThreadId(); VMError.guarantee(result != -1, "SYS_gettid failed"); - return WordFactory.signed(result); + return Word.signed(result); } else { throw VMError.unsupportedFeature("PosixVMThreads.getCurrentOSThreadId() on unexpected OS: " + ImageSingletons.lookup(Platform.class).getOS()); } @@ -84,7 +84,7 @@ protected OSThreadId getCurrentOSThreadId() { @Override protected void joinNoTransition(OSThreadHandle osThreadHandle) { Pthread.pthread_t pthread = (Pthread.pthread_t) osThreadHandle; - PosixUtils.checkStatusIs0(Pthread.pthread_join_no_transition(pthread, WordFactory.nullPointer()), "Pthread.joinNoTransition"); + PosixUtils.checkStatusIs0(Pthread.pthread_join_no_transition(pthread, Word.nullPointer()), "Pthread.joinNoTransition"); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -93,7 +93,7 @@ public void nativeSleep(int milliseconds) { timespec ts = StackValue.get(timespec.class); ts.set_tv_sec(milliseconds / TimeUtils.millisPerSecond); ts.set_tv_nsec((milliseconds % TimeUtils.millisPerSecond) * TimeUtils.nanosPerMilli); - Time.NoTransitions.nanosleep(ts, WordFactory.nullPointer()); + Time.NoTransitions.nanosleep(ts, Word.nullPointer()); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsGOTHeapSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsGOTHeapSupport.java index 24e1bc281e3e..6af693468dec 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsGOTHeapSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsGOTHeapSupport.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.windows; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -53,11 +53,11 @@ protected int initialize(WordPointer gotStartAddress) { HANDLE gotMappingHandle = MemoryAPI.CreateFileMappingW( WinBase.INVALID_HANDLE_VALUE(), // in-memory - WordFactory.nullPointer(), + Word.nullPointer(), MemoryAPI.PAGE_READWRITE(), 0, UnsignedUtils.safeToInt(alignedGotSize), - WordFactory.nullPointer() // anonymous + Word.nullPointer() // anonymous ); if (gotMappingHandle.isNull()) { @@ -69,7 +69,7 @@ protected int initialize(WordPointer gotStartAddress) { MemoryAPI.FILE_MAP_READ() | MemoryAPI.FILE_MAP_WRITE(), 0, 0, - WordFactory.zero() // map it whole + Word.zero() // map it whole ); if (gotMappedAddress.isNull()) { @@ -100,7 +100,7 @@ public int mapGot(Pointer address) { address, getPageAlignedGotSize(), gotMappingHandle, - WordFactory.zero(), + Word.zero(), Access.READ); if (mappedAddress.isNull()) { diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsImageHeapProvider.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsImageHeapProvider.java index a0d36c4dbef8..b240f3b5e874 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsImageHeapProvider.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsImageHeapProvider.java @@ -29,6 +29,7 @@ import static com.oracle.svm.core.Isolates.IMAGE_HEAP_RELOCATABLE_END; import static org.graalvm.nativeimage.c.function.CFunction.Transition.NO_TRANSITION; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CFunctionPointer; import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; @@ -38,7 +39,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -126,19 +126,19 @@ private static HANDLE createImageHeapFileMapping() { WCharPointer filePath = StackValue.get(WinBase.MAX_PATH, WCharPointer.class); int length = LibLoaderAPI.GetModuleFileNameW((HMODULE) IMAGE_BASE.get(), filePath, WinBase.MAX_PATH); if (length == 0 || length == WinBase.MAX_PATH) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } /* Open the file for mapping. */ HANDLE fileHandle = FileAPI.CreateFileW(filePath, FileAPI.GENERIC_READ(), FileAPI.FILE_SHARE_READ() | FileAPI.FILE_SHARE_DELETE(), - WordFactory.nullPointer(), FileAPI.OPEN_EXISTING(), 0, WordFactory.nullPointer()); + Word.nullPointer(), FileAPI.OPEN_EXISTING(), 0, Word.nullPointer()); if (fileHandle.equal(WinBase.INVALID_HANDLE_VALUE())) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } /* Create the mapping and close the file. */ - HANDLE fileMapping = MemoryAPI.CreateFileMappingW(fileHandle, WordFactory.nullPointer(), MemoryAPI.PAGE_READONLY(), - 0, 0, WordFactory.nullPointer()); + HANDLE fileMapping = MemoryAPI.CreateFileMappingW(fileHandle, Word.nullPointer(), MemoryAPI.PAGE_READONLY(), + 0, 0, Word.nullPointer()); WinBase.CloseHandle(fileHandle); return fileMapping; } @@ -202,7 +202,7 @@ private interface RtlImageNtHeader extends CFunctionPointer { @Uninterruptible(reason = "Called during isolate initialization.") private static UnsignedWord invokeRtlAddressInSectionTable(PointerBase ntHeader, int rva) { RtlAddressInSectionTable rtlAddressInSectionTable = WindowsUtils.getFunctionPointer(NTDLL_DLL.get(), RTL_ADDRESS_IN_SECTION_TABLE.get(), true); - UnsignedWord offset = (UnsignedWord) rtlAddressInSectionTable.invoke(ntHeader, WordFactory.nullPointer(), rva); + UnsignedWord offset = (UnsignedWord) rtlAddressInSectionTable.invoke(ntHeader, Word.nullPointer(), rva); if (offset.equal(0)) { CEntryPointActions.failFatally(ERROR_BAD_EXE_FORMAT, RTL_ADDRESS_IN_SECTION_TABLE.get()); } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsJavaLangSubstitutions.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsJavaLangSubstitutions.java index 55c0c73d0fd5..a79a2664a7ba 100755 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsJavaLangSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsJavaLangSubstitutions.java @@ -27,9 +27,9 @@ import java.io.Console; import java.util.Objects; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.annotate.Alias; @@ -59,7 +59,7 @@ public static String mapLibraryName(String libname) { @Substitute @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static long currentTimeMillis() { - return Jvm.JVM_CurrentTimeMillis(WordFactory.nullPointer(), WordFactory.nullPointer()); + return Jvm.JVM_CurrentTimeMillis(Word.nullPointer(), Word.nullPointer()); } } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsNativeLibrarySupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsNativeLibrarySupport.java index af0831d4335f..3ff52c85a68d 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsNativeLibrarySupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsNativeLibrarySupport.java @@ -26,13 +26,13 @@ import java.io.FileDescriptor; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Isolates; import com.oracle.svm.core.annotate.Alias; @@ -110,7 +110,7 @@ public WindowsNativeLibrary createLibrary(String canonical, boolean builtIn) { @Override public PointerBase findBuiltinSymbol(String name) { try (CCharPointerHolder symbol = CTypeConversion.toCString(name)) { - HMODULE builtinHandle = LibLoaderAPI.GetModuleHandleA(WordFactory.nullPointer()); + HMODULE builtinHandle = LibLoaderAPI.GetModuleHandleA(Word.nullPointer()); return LibLoaderAPI.GetProcAddress(builtinHandle, symbol.get()); } } @@ -152,7 +152,7 @@ public boolean unload() { } assert dlhandle.isNonNull(); if (LibLoaderAPI.FreeLibrary(dlhandle) != 0) { - dlhandle = WordFactory.nullPointer(); + dlhandle = Word.nullPointer(); return true; } else { return false; diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java index 61703c93ea94..28e13fbf9a09 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java @@ -26,9 +26,9 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; @@ -45,6 +45,6 @@ public UnsignedWord size() { SysinfoAPI.MEMORYSTATUSEX memStatusEx = UnsafeStackValue.get(SysinfoAPI.MEMORYSTATUSEX.class); memStatusEx.set_dwLength(SizeOf.get(SysinfoAPI.MEMORYSTATUSEX.class)); SysinfoAPI.GlobalMemoryStatusEx(memStatusEx); - return WordFactory.unsigned(memStatusEx.ullTotalPhys()); + return Word.unsigned(memStatusEx.ullTotalPhys()); } } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java index 4af4a73d6e71..b619fafbd9f7 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.core.windows; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platform.HOSTED_ONLY; import org.graalvm.nativeimage.Platforms; @@ -34,7 +35,6 @@ import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.PointerBase; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; @@ -84,7 +84,7 @@ protected boolean doStartThread(Thread thread, long stackSize) { private boolean doStartThread0(Thread thread, int threadStackSize, int initFlag) { ThreadStartData startData = prepareStart(thread, SizeOf.get(ThreadStartData.class)); try { - WinBase.HANDLE osThreadHandle = Process._beginthreadex(WordFactory.nullPointer(), threadStackSize, threadStartRoutine.getFunctionPointer(), startData, initFlag, WordFactory.nullPointer()); + WinBase.HANDLE osThreadHandle = Process._beginthreadex(Word.nullPointer(), threadStackSize, threadStartRoutine.getFunctionPointer(), startData, initFlag, Word.nullPointer()); if (osThreadHandle.isNull()) { undoPrepareStartOnError(thread, startData); return false; @@ -106,8 +106,8 @@ public OSThreadHandle startThreadUnmanaged(CFunctionPointer threadRoutine, Point initFlag |= Process.STACK_SIZE_PARAM_IS_A_RESERVATION(); } - WinBase.HANDLE osThreadHandle = Process.NoTransitions._beginthreadex(WordFactory.nullPointer(), stackSize, - threadRoutine, userData, initFlag, WordFactory.nullPointer()); + WinBase.HANDLE osThreadHandle = Process.NoTransitions._beginthreadex(Word.nullPointer(), stackSize, + threadRoutine, userData, initFlag, Word.nullPointer()); return (OSThreadHandle) osThreadHandle; } @@ -122,7 +122,7 @@ public boolean joinThreadUnmanaged(OSThreadHandle threadHandle, WordPointer thre } // Since only an int is written, first clear word - threadExitStatus.write(WordFactory.zero()); + threadExitStatus.write(Word.zero()); return Process.NoTransitions.GetExitCodeThread((WinBase.HANDLE) threadHandle, (CIntPointer) threadExitStatus) != 0; } @@ -131,7 +131,7 @@ public boolean joinThreadUnmanaged(OSThreadHandle threadHandle, WordPointer thre public ThreadLocalKey createUnmanagedThreadLocal() { int result = Process.NoTransitions.TlsAlloc(); VMError.guarantee(result != Process.TLS_OUT_OF_INDEXES(), "TlsAlloc failed."); - return WordFactory.unsigned(result); + return Word.unsigned(result); } @Override @@ -192,7 +192,7 @@ class WindowsParker extends Parker { private WinBase.HANDLE eventHandle; WindowsParker() { - eventHandle = SynchAPI.CreateEventA(WordFactory.nullPointer(), 1, 0, WordFactory.nullPointer()); + eventHandle = SynchAPI.CreateEventA(Word.nullPointer(), 1, 0, Word.nullPointer()); VMError.guarantee(eventHandle.rawValue() != 0, "CreateEventA failed"); } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformTimeUtils.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformTimeUtils.java index c6765e392461..15dca5f55343 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformTimeUtils.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformTimeUtils.java @@ -26,8 +26,8 @@ import static com.oracle.svm.core.windows.headers.SysinfoAPI.GetSystemTimeAsFileTime; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.BasedOnJDKFile; @@ -48,7 +48,7 @@ private static long offset() { /* Returns time ticks in (10th of micro seconds) */ @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+3/src/hotspot/os/windows/os_windows.cpp#L1158-L1161") private static long windowsToTimeTicks(FILETIME wt) { - long a = WordFactory.unsigned(wt.dwHighDateTime()).shiftLeft(32).or(WordFactory.unsigned(wt.dwLowDateTime())).rawValue(); + long a = Word.unsigned(wt.dwHighDateTime()).shiftLeft(32).or(Word.unsigned(wt.dwLowDateTime())).rawValue(); return (a - offset()); } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsProcessPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsProcessPropertiesSupport.java index 31daaf278d45..057ba03622d4 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsProcessPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsProcessPropertiesSupport.java @@ -32,11 +32,11 @@ import java.util.List; import java.util.Map; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.impl.ProcessPropertiesSupport; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.BaseProcessPropertiesSupport; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; @@ -53,7 +53,7 @@ public class WindowsProcessPropertiesSupport extends BaseProcessPropertiesSuppor @Override public String getExecutableName() { - return getModulePath(LibLoaderAPI.GetModuleHandleA(WordFactory.nullPointer())); + return getModulePath(LibLoaderAPI.GetModuleHandleA(Word.nullPointer())); } @Override @@ -104,7 +104,7 @@ public long getProcessID(java.lang.Process process) { @Override public String getObjectFile(String symbol) { try (CTypeConversion.CCharPointerHolder symbolHolder = CTypeConversion.toCString(symbol)) { - WinBase.HMODULE builtinHandle = LibLoaderAPI.GetModuleHandleA(WordFactory.nullPointer()); + WinBase.HMODULE builtinHandle = LibLoaderAPI.GetModuleHandleA(Word.nullPointer()); PointerBase symbolAddress = LibLoaderAPI.GetProcAddress(builtinHandle, symbolHolder.get()); if (symbolAddress.isNonNull()) { return getObjectFile(symbolAddress); diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsRegisterDumper.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsRegisterDumper.java index 9a1c960a005d..7173eb1f66fb 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsRegisterDumper.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsRegisterDumper.java @@ -26,8 +26,8 @@ import static com.oracle.svm.core.RegisterDumper.dumpReg; +import jdk.graal.compiler.word.Word; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.RegisterDumper; import com.oracle.svm.core.Uninterruptible; @@ -75,24 +75,24 @@ private static void dumpRegisters(Log log, CONTEXT context, boolean printLocatio @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getHeapBase(Context context) { - return WordFactory.pointer(((CONTEXT) context).R14()); + return Word.pointer(((CONTEXT) context).R14()); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getThreadPointer(Context context) { - return WordFactory.pointer(((CONTEXT) context).R15()); + return Word.pointer(((CONTEXT) context).R15()); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getSP(Context context) { - return WordFactory.pointer(((CONTEXT) context).Rsp()); + return Word.pointer(((CONTEXT) context).Rsp()); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public PointerBase getIP(Context context) { - return WordFactory.pointer(((CONTEXT) context).Rip()); + return Word.pointer(((CONTEXT) context).Rip()); } } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSignalHandlerSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSignalHandlerSupport.java index 7c17d6d90491..ea07b3ce6af2 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSignalHandlerSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSignalHandlerSupport.java @@ -28,10 +28,10 @@ import java.util.Locale; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CFunction; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Isolates; import com.oracle.svm.core.Uninterruptible; @@ -60,7 +60,7 @@ public long installJavaSignalHandler(int sig, long nativeH) { assert MonitorSupport.singleton().isLockedByCurrentThread(Target_jdk_internal_misc_Signal.class); ensureInitialized(); - return Jvm.JVM_RegisterSignal(sig, WordFactory.pointer(nativeH)).rawValue(); + return Jvm.JVM_RegisterSignal(sig, Word.pointer(nativeH)).rawValue(); } private void ensureInitialized() { diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsStackOverflowSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsStackOverflowSupport.java index 72d6e598f250..bed3cfb65791 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsStackOverflowSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsStackOverflowSupport.java @@ -24,12 +24,12 @@ */ package com.oracle.svm.core.windows; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; @@ -43,14 +43,14 @@ final class WindowsStackOverflowSupport implements StackOverflowCheck.PlatformSu public boolean lookupStack(WordPointer stackBasePtr, WordPointer stackEndPtr) { int sizeOfMInfo = SizeOf.get(MemoryAPI.MEMORY_BASIC_INFORMATION.class); MemoryAPI.MEMORY_BASIC_INFORMATION minfo = StackValue.get(sizeOfMInfo); - MemoryAPI.VirtualQuery(minfo, minfo, WordFactory.unsigned(sizeOfMInfo)); + MemoryAPI.VirtualQuery(minfo, minfo, Word.unsigned(sizeOfMInfo)); Pointer bottom = (Pointer) minfo.AllocationBase(); stackEndPtr.write(bottom); UnsignedWord stackSize = minfo.RegionSize(); /* Add up the sizes of all the regions with the same AllocationBase. */ while (true) { - MemoryAPI.VirtualQuery(bottom.add(stackSize), minfo, WordFactory.unsigned(sizeOfMInfo)); + MemoryAPI.VirtualQuery(bottom.add(stackSize), minfo, Word.unsigned(sizeOfMInfo)); if (bottom.equal(minfo.AllocationBase())) { stackSize = stackSize.add(minfo.RegionSize()); } else { diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java index 959a1553ddb0..d7e3fec75571 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java @@ -28,6 +28,7 @@ import java.nio.CharBuffer; import java.nio.charset.StandardCharsets; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -38,7 +39,6 @@ import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.nativeimage.impl.RuntimeSystemPropertiesSupport; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.c.NonmovableArrays; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; @@ -152,7 +152,7 @@ protected String javaLibraryPathValue() { StringBuilder libraryPath = new StringBuilder(3 * WinBase.MAX_PATH + pathLength + 5); /* Add the directory from which application is loaded. */ - tmpLength = LibLoaderAPI.GetModuleFileNameW(WordFactory.nullPointer(), tmp, WinBase.MAX_PATH); + tmpLength = LibLoaderAPI.GetModuleFileNameW(Word.nullPointer(), tmp, WinBase.MAX_PATH); VMError.guarantee(tmpLength > 0 && tmpLength < WinBase.MAX_PATH); libraryPath.append(asCharBuffer(tmp, tmpLength)); /* Get rid of `\.exe`. */ @@ -238,15 +238,15 @@ private void computeOsNameAndVersion() { if (ret == 0 || ret > len) { break; } - WindowsLibC.wcsncat(kernel32Path, kernel32Dll, WordFactory.unsigned(WinBase.MAX_PATH - ret)); + WindowsLibC.wcsncat(kernel32Path, kernel32Dll, Word.unsigned(WinBase.MAX_PATH - ret)); /* ... and use that for determining what version of Windows we're running on. */ - int versionSize = WinVer.GetFileVersionInfoSizeW(kernel32Path, WordFactory.nullPointer()); + int versionSize = WinVer.GetFileVersionInfoSizeW(kernel32Path, Word.nullPointer()); if (versionSize == 0) { break; } - VoidPointer versionInfo = NullableNativeMemory.malloc(WordFactory.unsigned(versionSize), NmtCategory.Internal); + VoidPointer versionInfo = NullableNativeMemory.malloc(Word.unsigned(versionSize), NmtCategory.Internal); if (versionInfo.isNull()) { break; } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java index d37fd39136fc..483643ad01e0 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java @@ -25,11 +25,11 @@ package com.oracle.svm.core.windows; import com.oracle.svm.core.util.BasedOnJDKFile; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.StackValue; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; @@ -83,7 +83,7 @@ private static long getThreadCpuTime(HANDLE hThread, boolean includeSystemTime) */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static UnsignedWord fileTimeToNanos(FILETIME ft) { - UnsignedWord value = WordFactory.unsigned(ft.dwHighDateTime()).shiftLeft(32).or(WordFactory.unsigned(ft.dwLowDateTime())); + UnsignedWord value = Word.unsigned(ft.dwHighDateTime()).shiftLeft(32).or(Word.unsigned(ft.dwLowDateTime())); return value.multiply(100); } } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUtils.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUtils.java index 53f0dd63f402..cf3261f8953b 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUtils.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUtils.java @@ -28,6 +28,7 @@ import java.io.FileDescriptor; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CFunctionPointer; import org.graalvm.nativeimage.c.struct.CPointerTo; @@ -37,7 +38,6 @@ import org.graalvm.nativeimage.hosted.FieldValueTransformer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.Uninterruptible; @@ -61,7 +61,7 @@ private static final class Target_java_lang_ProcessImpl { public static int getpid(java.lang.Process process) { Target_java_lang_ProcessImpl processImpl = SubstrateUtil.cast(process, Target_java_lang_ProcessImpl.class); - return com.oracle.svm.core.windows.headers.Process.NoTransitions.GetProcessId(WordFactory.pointer(processImpl.handle)); + return com.oracle.svm.core.windows.headers.Process.NoTransitions.GetProcessId(Word.pointer(processImpl.handle)); } @TargetClass(java.io.FileDescriptor.class) @@ -102,7 +102,7 @@ public static boolean writeBytes(int handle, CCharPointer bytes, UnsignedWord le CIntPointer bytesWritten = UnsafeStackValue.get(CIntPointer.class); - int ret = FileAPI.WriteFile(handle, curBuf, curLen, bytesWritten, WordFactory.nullPointer()); + int ret = FileAPI.WriteFile(handle, curBuf, curLen, bytesWritten, Word.nullPointer()); if (ret == 0) { return false; @@ -150,7 +150,7 @@ public static long getNanoCounter() { } /** Sentinel value denoting the uninitialized kernel handle. */ - public static final PointerBase UNINITIALIZED_HANDLE = WordFactory.pointer(1); + public static final PointerBase UNINITIALIZED_HANDLE = Word.pointer(1); @CPointerTo(nameOfCType = "void*") interface CFunctionPointerPointer extends PointerBase { @@ -160,7 +160,7 @@ interface CFunctionPointerPointer extends PointerBas } /** Sentinel value denoting the uninitialized pointer. */ - static final PointerBase UNINITIALIZED_POINTER = WordFactory.pointer(0xBAD); + static final PointerBase UNINITIALIZED_POINTER = Word.pointer(0xBAD); /** * Retrieves and caches the address of an exported function from an already loaded DLL if the diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java index 051e7db735c6..f6957a1b47a6 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java @@ -26,11 +26,11 @@ import static com.oracle.svm.core.heap.RestrictHeapAccess.Access.NO_ALLOCATION; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.LogHandler; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CIsolateData; @@ -289,7 +289,7 @@ final class WindowsVMSemaphore extends VMSemaphore { @Override @Uninterruptible(reason = "Too early for safepoints.") public int initialize() { - hSemaphore = WinBase.CreateSemaphoreA(WordFactory.nullPointer(), 0, Integer.MAX_VALUE, WordFactory.nullPointer()); + hSemaphore = WinBase.CreateSemaphoreA(Word.nullPointer(), 0, Integer.MAX_VALUE, Word.nullPointer()); return hSemaphore.isNonNull() ? 0 : 1; } @@ -297,7 +297,7 @@ public int initialize() { @Uninterruptible(reason = "The isolate teardown is in progress.") public int destroy() { int errorCode = WinBase.CloseHandle(hSemaphore); - hSemaphore = WordFactory.nullPointer(); + hSemaphore = Word.nullPointer(); return errorCode; } @@ -309,6 +309,6 @@ public void await() { @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public void signal() { - WindowsVMLockSupport.checkResult(SynchAPI.NoTransitions.ReleaseSemaphore(hSemaphore, 1, WordFactory.nullPointer()), "ReleaseSemaphore"); + WindowsVMLockSupport.checkResult(SynchAPI.NoTransitions.ReleaseSemaphore(hSemaphore, 1, Word.nullPointer()), "ReleaseSemaphore"); } } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMThreads.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMThreads.java index a4b7f6e5584f..84de384f11fb 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMThreads.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMThreads.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.windows; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CCharPointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; @@ -59,7 +59,7 @@ public OSThreadHandle getCurrentOSThreadHandle() { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @Override protected OSThreadId getCurrentOSThreadId() { - return WordFactory.unsigned(Process.NoTransitions.GetCurrentThreadId()); + return Word.unsigned(Process.NoTransitions.GetCurrentThreadId()); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVirtualMemoryProvider.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVirtualMemoryProvider.java index cfd4dda73831..7e63304342e8 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVirtualMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVirtualMemoryProvider.java @@ -26,6 +26,7 @@ import static org.graalvm.nativeimage.c.function.CFunction.Transition.NO_TRANSITION; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CFunctionPointer; import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; @@ -39,7 +40,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -65,14 +65,14 @@ public class WindowsVirtualMemoryProvider implements VirtualMemoryProvider { private static void initCaches() { SysinfoAPI.SYSTEM_INFO sysInfo = StackValue.get(SysinfoAPI.SYSTEM_INFO.class); SysinfoAPI.GetSystemInfo(sysInfo); - CACHED_PAGE_SIZE.get().write(WordFactory.unsigned(sysInfo.dwPageSize())); - CACHED_ALLOC_GRAN.get().write(WordFactory.unsigned(sysInfo.dwAllocationGranularity())); + CACHED_PAGE_SIZE.get().write(Word.unsigned(sysInfo.dwPageSize())); + CACHED_ALLOC_GRAN.get().write(Word.unsigned(sysInfo.dwAllocationGranularity())); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static UnsignedWord getPageSize() { UnsignedWord value = CACHED_PAGE_SIZE.get().read(); - if (value.equal(WordFactory.zero())) { + if (value.equal(Word.zero())) { initCaches(); value = CACHED_PAGE_SIZE.get().read(); } @@ -82,7 +82,7 @@ private static UnsignedWord getPageSize() { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static UnsignedWord getAllocationGranularity() { UnsignedWord value = CACHED_ALLOC_GRAN.get().read(); - if (value.equal(WordFactory.zero())) { + if (value.equal(Word.zero())) { initCaches(); value = CACHED_ALLOC_GRAN.get().read(); } @@ -121,13 +121,13 @@ private static int accessAsProt(int access) { } /** Sentinel value indicating that no special alignment is required. */ - private static final UnsignedWord UNALIGNED = WordFactory.zero(); + private static final UnsignedWord UNALIGNED = Word.zero(); @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public Pointer reserve(UnsignedWord nbytes, UnsignedWord alignment, boolean executable) { if (nbytes.equal(0)) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } UnsignedWord requiredAlignment = alignment; @@ -156,9 +156,9 @@ public Pointer reserve(UnsignedWord nbytes, UnsignedWord alignment, boolean exec assert reservedPlaceholder.isNull(); /* Reserve a container that is large enough for the requested size *and* the alignment. */ - Pointer reserved = MemoryAPI.VirtualAlloc(WordFactory.nullPointer(), nbytes.add(requiredAlignment), MemoryAPI.MEM_RESERVE(), MemoryAPI.PAGE_NOACCESS()); + Pointer reserved = MemoryAPI.VirtualAlloc(Word.nullPointer(), nbytes.add(requiredAlignment), MemoryAPI.MEM_RESERVE(), MemoryAPI.PAGE_NOACCESS()); if (reserved.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } return requiredAlignment.equal(UNALIGNED) ? reserved : PointerUtils.roundUp(reserved, requiredAlignment); } @@ -169,7 +169,7 @@ public Pointer reserve(UnsignedWord nbytes, UnsignedWord alignment, boolean exec @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static Pointer reservePlaceholder(UnsignedWord size, UnsignedWord alignment) { int allocationType = MemoryAPI.MEM_RESERVE() | MEM_RESERVE_PLACEHOLDER; - return invokeVirtualAlloc2(WordFactory.nullPointer(), size, allocationType, MemoryAPI.PAGE_NOACCESS(), alignment); + return invokeVirtualAlloc2(Word.nullPointer(), size, allocationType, MemoryAPI.PAGE_NOACCESS(), alignment); } private static final int MEM_REPLACE_PLACEHOLDER = 0x00004000; @@ -179,7 +179,7 @@ private static Pointer reservePlaceholder(UnsignedWord size, UnsignedWord alignm @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static void replacePlaceholder(PointerBase placeholder, UnsignedWord size) { int allocationType = MemoryAPI.MEM_RESERVE() | MEM_REPLACE_PLACEHOLDER; - if (invokeVirtualAlloc2(placeholder, size, allocationType, MemoryAPI.PAGE_NOACCESS(), WordFactory.zero()).isNull()) { + if (invokeVirtualAlloc2(placeholder, size, allocationType, MemoryAPI.PAGE_NOACCESS(), Word.zero()).isNull()) { CEntryPointActions.failFatally(WinBase.GetLastError(), REPLACE_PLACEHOLDER_ERROR_MESSAGE.get()); } } @@ -201,11 +201,11 @@ private static Pointer invokeVirtualAlloc2(PointerBase baseAddress, UnsignedWord VirtualAlloc2 virtualAlloc2 = WindowsUtils.getAndCacheFunctionPointer(VIRTUAL_ALLOC_2_POINTER.get(), KERNELBASE_DLL.get(), VIRTUAL_ALLOC_2.get()); if (virtualAlloc2.isNull()) { /* The OS does not provide VirtualAlloc2 (nor placeholders). */ - return WordFactory.nullPointer(); + return Word.nullPointer(); } MEM_EXTENDED_PARAMETER extendedParameter = StackValue.get(MEM_EXTENDED_PARAMETER.class); specifyAlignment(extendedParameter, StackValue.get(MEM_ADDRESS_REQUIREMENTS.class), alignment); - return virtualAlloc2.invoke(WordFactory.nullPointer(), baseAddress, size, allocationType, pageProtection, extendedParameter, 1); + return virtualAlloc2.invoke(Word.nullPointer(), baseAddress, size, allocationType, pageProtection, extendedParameter, 1); } private interface VirtualAlloc2 extends CFunctionPointer { @@ -230,8 +230,8 @@ private static void specifyAlignment(MEM_EXTENDED_PARAMETER extendedParameter, M */ extendedParameter.setF1Type(MemExtendedParameterAddressRequirements); extendedParameter.setF2Pointer(addressRequirements.rawValue()); - addressRequirements.setF1LowestStartingAddress(WordFactory.nullPointer()); - addressRequirements.setF2HighestEndingAddress(WordFactory.nullPointer()); + addressRequirements.setF1LowestStartingAddress(Word.nullPointer()); + addressRequirements.setF2HighestEndingAddress(Word.nullPointer()); addressRequirements.setF3Alignment(alignment); } @@ -285,7 +285,7 @@ private interface MEM_ADDRESS_REQUIREMENTS extends PointerBase { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public Pointer mapFile(PointerBase start, UnsignedWord nbytes, WordBase fileHandle, UnsignedWord offset, int access) { if ((start.isNonNull() && !isAligned(start)) || nbytes.equal(0)) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } /* @@ -297,13 +297,13 @@ public Pointer mapFile(PointerBase start, UnsignedWord nbytes, WordBase fileHand * Memory mapping to an unreserved address range imposes an additional restriction on * the alignment of the `offset`, which we do not currently support. */ - return WordFactory.nullPointer(); + return Word.nullPointer(); } /* First split off a placeholder from the reserved address range ... */ if (!splitPlaceholder(start, nbytes)) { /* The OS does not support placeholders. */ - return WordFactory.nullPointer(); + return Word.nullPointer(); } /* ... and then map a view into the placeholder. */ @@ -337,10 +337,10 @@ private static Pointer invokeMapViewOfFile3(HANDLE fileMapping, PointerBase base MapViewOfFile3 mapViewOfFile3 = WindowsUtils.getAndCacheFunctionPointer(MAP_VIEW_OF_FILE_3_POINTER.get(), KERNELBASE_DLL.get(), MAP_VIEW_OF_FILE_3.get()); if (mapViewOfFile3.isNull()) { /* The OS does not provide MapViewOfFile3 (nor placeholders). */ - return WordFactory.nullPointer(); + return Word.nullPointer(); } - return mapViewOfFile3.invoke(fileMapping, WordFactory.nullPointer(), baseAddress, offset, viewSize, MEM_REPLACE_PLACEHOLDER, - pageProtection, WordFactory.nullPointer(), 0); + return mapViewOfFile3.invoke(fileMapping, Word.nullPointer(), baseAddress, offset, viewSize, MEM_REPLACE_PLACEHOLDER, + pageProtection, Word.nullPointer(), 0); } private interface MapViewOfFile3 extends CFunctionPointer { @@ -353,7 +353,7 @@ Pointer invoke(HANDLE fileMapping, HANDLE process, PointerBase baseAddress, long @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public Pointer commit(PointerBase start, UnsignedWord nbytes, int access) { if ((start.isNonNull() && !isAligned(start)) || nbytes.equal(0)) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } /* @@ -417,7 +417,7 @@ private static boolean free(PointerBase allocationBase, boolean isMemoryMapped) if (isMemoryMapped) { return MemoryAPI.UnmapViewOfFile(allocationBase) != 0; } else { - return MemoryAPI.VirtualFree(allocationBase, WordFactory.zero(), MemoryAPI.MEM_RELEASE()) != 0; + return MemoryAPI.VirtualFree(allocationBase, Word.zero(), MemoryAPI.MEM_RELEASE()) != 0; } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DebugHelper.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DebugHelper.java index c41d4c3f7fae..ec2cbcb86cea 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DebugHelper.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DebugHelper.java @@ -33,7 +33,6 @@ import org.graalvm.nativeimage.c.function.CEntryPoint.Publish; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.c.SetThreadAndHeapBasePrologue; import com.oracle.svm.core.c.function.CEntryPointOptions; @@ -279,7 +278,7 @@ public static void printString(@SuppressWarnings("unused") IsolateThread thread, @CEntryPoint(name = "svm_dbg_print_fatalErrorDiagnostics", include = IncludeDebugHelperMethods.class, publishAs = Publish.SymbolOnly) @CEntryPointOptions(prologue = SetThreadAndHeapBasePrologue.class, epilogue = NoEpilogue.class) public static void printFatalErrorDiagnostics(@SuppressWarnings("unused") IsolateThread thread, Pointer sp, CodePointer ip) { - SubstrateDiagnostics.printFatalError(Log.log(), sp, ip, WordFactory.nullPointer(), false); + SubstrateDiagnostics.printFatalError(Log.log(), sp, ip, Word.nullPointer(), false); } @Uninterruptible(reason = "Just to keep the verification happy.", calleeMustBe = false) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/InvalidMethodPointerHandler.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/InvalidMethodPointerHandler.java index b8d79214e633..8f11b8253c1e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/InvalidMethodPointerHandler.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/InvalidMethodPointerHandler.java @@ -28,13 +28,13 @@ import java.lang.reflect.Method; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.LogHandler; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.graal.code.StubCallingConvention; import com.oracle.svm.core.heap.RestrictHeapAccess; @@ -89,7 +89,7 @@ private static void failFatally(Pointer callerSP, CodePointer callerIP, String m LogHandler logHandler = ImageSingletons.lookup(LogHandler.class); Log log = Log.enterFatalContext(logHandler, callerIP, message, null); if (log != null) { - SubstrateDiagnostics.printFatalError(log, callerSP, callerIP, WordFactory.nullPointer(), true); + SubstrateDiagnostics.printFatalError(log, callerSP, callerIP, Word.nullPointer(), true); log.string(message).newline(); } logHandler.fatalError(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentAccess.java index 0823fcd51f80..f2a3871dc2a0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentAccess.java @@ -26,8 +26,8 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.type.CCharPointer; -import jdk.graal.compiler.word.WordFactory; public class IsolateArgumentAccess { @@ -63,7 +63,7 @@ public static void writeBoolean(IsolateArguments arguments, int index, boolean v @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) public static CCharPointer readCCharPointer(IsolateArguments arguments, int index) { - return WordFactory.pointer(readLong(arguments, index)); + return Word.pointer(readLong(arguments, index)); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentParser.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentParser.java index 00d21b6264b7..f103edbb59a2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentParser.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentParser.java @@ -35,6 +35,7 @@ import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -45,7 +46,6 @@ import org.graalvm.nativeimage.c.type.CLongPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; @@ -224,7 +224,7 @@ public boolean tearDown(IsolateArguments arguments) { for (int i = 0; i < getOptionCount(); i++) { if (OPTION_TYPES.get().read(i) == OptionValueType.C_CHAR_POINTER) { UntrackedNullableNativeMemory.free(readCCharPointer(arguments, i)); - writeCCharPointer(arguments, i, WordFactory.nullPointer()); + writeCCharPointer(arguments, i, Word.nullPointer()); } } return true; @@ -234,7 +234,7 @@ public boolean tearDown(IsolateArguments arguments) { public boolean tearDown() { for (int i = 0; i < getOptionCount(); i++) { if (OPTION_TYPES.get().read(i) == OptionValueType.C_CHAR_POINTER) { - UntrackedNullableNativeMemory.free(WordFactory.pointer(parsedOptionValues[i])); + UntrackedNullableNativeMemory.free(Word.pointer(parsedOptionValues[i])); parsedOptionValues[i] = 0; } } @@ -260,7 +260,7 @@ private static void copyStringArguments(IsolateArguments arguments) { VMError.guarantee(copy.isNonNull(), "Copying of string argument failed."); writeCCharPointer(arguments, i, copy); } else { - writeCCharPointer(arguments, i, WordFactory.nullPointer()); + writeCCharPointer(arguments, i, Word.nullPointer()); } } } @@ -332,7 +332,7 @@ public long getLongOptionValue(int index) { } protected CCharPointer getCCharPointerOptionValue(int index) { - return WordFactory.pointer(parsedOptionValues[index]); + return Word.pointer(parsedOptionValues[index]); } protected Object getOptionValue(int index) { @@ -350,7 +350,7 @@ protected Object getOptionValue(int index) { return null; } - return CTypeConversion.toJavaString(WordFactory.pointer(value)); + return CTypeConversion.toJavaString(Word.pointer(value)); } else { throw VMError.shouldNotReachHere("Option value has unexpected type: " + optionValueType); } @@ -380,7 +380,7 @@ protected void initialize(IsolateArguments arguments, CEntryPointCreateIsolatePa arguments.setProtectionKey(parameters.protectionKey()); } else { arguments.setArgc(0); - arguments.setArgv(WordFactory.nullPointer()); + arguments.setArgv(Word.nullPointer()); arguments.setProtectionKey(0); } @@ -398,7 +398,7 @@ private static CCharPointer matchPrefix(CCharPointer arg) { if (arg.read(0) == '-') { return arg.addressOf(1); } - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) @@ -406,7 +406,7 @@ private static CCharPointer matchXOption(CCharPointer arg) { if (arg.read(0) == 'X' && arg.read(1) == 'm') { return arg.addressOf(2); } - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) @@ -414,7 +414,7 @@ private static CCharPointer matchXXOption(CCharPointer arg) { if (arg.read(0) == 'X' && arg.read(1) == 'X' && arg.read(2) == ':') { return arg.addressOf(3); } - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) @@ -519,7 +519,7 @@ private static boolean atojulong(CCharPointer s, CLongPointer result) { } } - UnsignedWord value = n.multiply(WordFactory.unsigned(modifier)); + UnsignedWord value = n.multiply(Word.unsigned(modifier)); if (checkForOverflow(value, n, modifier)) { return false; } @@ -529,7 +529,7 @@ private static boolean atojulong(CCharPointer s, CLongPointer result) { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) private static boolean checkForOverflow(UnsignedWord value, UnsignedWord n, long modifier) { - return value.unsignedDivide(WordFactory.unsigned(modifier)) != n; + return value.unsignedDivide(Word.unsigned(modifier)) != n; } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) @@ -548,7 +548,7 @@ private static CCharPointer startsWith(CCharPointer input, CCharPointer prefix) if (prefix.read(i) == 0) { return input.addressOf(i); } - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Fold diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/Isolates.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/Isolates.java index 66b0845dee2f..f32850b6a2fd 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/Isolates.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/Isolates.java @@ -32,7 +32,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; @@ -70,7 +69,7 @@ public class Isolates { public static final CGlobalData IMAGE_HEAP_WRITABLE_END = CGlobalDataFactory.forSymbol(IMAGE_HEAP_WRITABLE_END_SYMBOL_NAME); public static final CGlobalData IMAGE_HEAP_WRITABLE_PATCHED_BEGIN = CGlobalDataFactory.forSymbol(IMAGE_HEAP_WRITABLE_PATCHED_BEGIN_SYMBOL_NAME); public static final CGlobalData IMAGE_HEAP_WRITABLE_PATCHED_END = CGlobalDataFactory.forSymbol(IMAGE_HEAP_WRITABLE_PATCHED_END_SYMBOL_NAME); - public static final CGlobalData ISOLATE_COUNTER = CGlobalDataFactory.createWord((WordBase) WordFactory.unsigned(1)); + public static final CGlobalData ISOLATE_COUNTER = CGlobalDataFactory.createWord((WordBase) Word.unsigned(1)); /* Only used if SpawnIsolates is disabled. */ private static final CGlobalData SINGLE_ISOLATE_ALREADY_CREATED = CGlobalDataFactory.createWord(); @@ -148,7 +147,7 @@ public static int checkIsolate(Isolate isolate) { @Uninterruptible(reason = "Thread state not yet set up.") public static int create(WordPointer isolatePointer, IsolateArguments arguments) { if (!SubstrateOptions.SpawnIsolates.getValue()) { - if (!SINGLE_ISOLATE_ALREADY_CREATED.get().logicCompareAndSwapWord(0, WordFactory.zero(), WordFactory.signed(1), NamedLocationIdentity.OFF_HEAP_LOCATION)) { + if (!SINGLE_ISOLATE_ALREADY_CREATED.get().logicCompareAndSwapWord(0, Word.zero(), Word.signed(1), NamedLocationIdentity.OFF_HEAP_LOCATION)) { return CEntryPointErrors.SINGLE_ISOLATE_ALREADY_CREATED; } } @@ -162,7 +161,7 @@ public static int create(WordPointer isolatePointer, IsolateArguments arguments) Isolate isolate = heapBasePointer.read(); result = checkIsolate(isolate); if (result != CEntryPointErrors.NO_ERROR) { - isolatePointer.write(WordFactory.nullPointer()); + isolatePointer.write(Word.nullPointer()); return result; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMainWrapper.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMainWrapper.java index a82c1d516693..bb18e8e369af 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMainWrapper.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMainWrapper.java @@ -35,6 +35,7 @@ import java.util.List; import java.util.function.BooleanSupplier; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Isolate; @@ -54,7 +55,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; @@ -88,7 +88,7 @@ public class JavaMainWrapper { */ public static final CGlobalData MAIN_ISOLATE_PARAMETERS = CGlobalDataFactory.createBytes(() -> SizeOf.get(CEntryPointCreateIsolateParameters.class)); - private static UnsignedWord argvLength = WordFactory.zero(); + private static UnsignedWord argvLength = Word.zero(); public static class JavaMainSupport { @@ -321,7 +321,7 @@ private static int doRunInNewThread(int argc, CCharPointerPointer argv) { MAIN_ISOLATE_PARAMETERS.get().setArgc(argc); MAIN_ISOLATE_PARAMETERS.get().setArgv(argv); long stackSize = SubstrateOptions.StackSize.getHostedValue(); - OSThreadHandle osThreadHandle = PlatformThreads.singleton().startThreadUnmanaged(RUN_MAIN_ROUTINE.get(), WordFactory.nullPointer(), (int) stackSize); + OSThreadHandle osThreadHandle = PlatformThreads.singleton().startThreadUnmanaged(RUN_MAIN_ROUTINE.get(), Word.nullPointer(), (int) stackSize); if (osThreadHandle.isNull()) { CEntryPointActions.failFatally(1, START_THREAD_UNMANAGED_ERROR_MESSAGE.get()); return 1; @@ -357,7 +357,7 @@ public boolean getAsBoolean() { @CEntryPointOptions(prologue = CEntryPointOptions.NoPrologue.class, epilogue = CEntryPointOptions.NoEpilogue.class) static WordBase runMainRoutine(PointerBase data) { int exitStatus = doRun(MAIN_ISOLATE_PARAMETERS.get().getArgc(), MAIN_ISOLATE_PARAMETERS.get().getArgv()); - return WordFactory.signed(exitStatus); + return Word.signed(exitStatus); } private static boolean isArgumentBlockSupported() { @@ -392,13 +392,13 @@ public static int getCRuntimeArgumentBlockLength() { CEntryPointCreateIsolateParameters args = MAIN_ISOLATE_PARAMETERS.get(); CCharPointer firstArgPos = args.getArgv().read(0); - if (argvLength.equal(WordFactory.zero())) { + if (argvLength.equal(Word.zero())) { // Get char* to last program argument CCharPointer lastArgPos = args.getArgv().read(args.getArgc() - 1); // Determine the length of the last program argument UnsignedWord lastArgLength = SubstrateUtil.strlen(lastArgPos); // Determine maximum C string length that can be stored in the program argument part - argvLength = WordFactory.unsigned(lastArgPos.rawValue()).add(lastArgLength).subtract(WordFactory.unsigned(firstArgPos.rawValue())); + argvLength = Word.unsigned(lastArgPos.rawValue()).add(lastArgLength).subtract(Word.unsigned(firstArgPos.rawValue())); } return Math.toIntExact(argvLength.rawValue()); } @@ -413,7 +413,7 @@ public static boolean setCRuntimeArgument0(String arg0) { CCharPointer arg0Pointer = arg0Pin.get(); UnsignedWord arg0Length = SubstrateUtil.strlen(arg0Pointer); - UnsignedWord origLength = WordFactory.unsigned(getCRuntimeArgumentBlockLength()); + UnsignedWord origLength = Word.unsigned(getCRuntimeArgumentBlockLength()); UnsignedWord newArgLength = origLength; if (arg0Length.add(1).belowThan(origLength)) { newArgLength = arg0Length.add(1); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMemoryUtil.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMemoryUtil.java index 4a9d8c01f1f5..eacc7e181e80 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMemoryUtil.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMemoryUtil.java @@ -26,7 +26,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.hub.LayoutEncoding; @@ -142,7 +141,7 @@ public static void copyForward(Pointer from, Pointer to, UnsignedWord size) { UnsignedWord alignBits = diffBits.not().and(diffBits.subtract(1)).and(0x7); UnsignedWord alignment = alignBits.add(1); if (alignment.equal(1)) { - for (UnsignedWord offset = WordFactory.zero(); offset.belowThan(size); offset = offset.add(1)) { + for (UnsignedWord offset = Word.zero(); offset.belowThan(size); offset = offset.add(1)) { to.writeByte(offset, from.readByte(offset)); } return; @@ -179,7 +178,7 @@ public static void copyForward(Pointer from, Pointer to, UnsignedWord size) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static void copyUnalignedLower(Pointer from, Pointer to, UnsignedWord length) { - UnsignedWord offset = WordFactory.zero(); + UnsignedWord offset = Word.zero(); if (length.and(1).notEqual(0)) { to.writeByte(offset, from.readByte(offset)); offset = offset.add(1); @@ -195,7 +194,7 @@ private static void copyUnalignedLower(Pointer from, Pointer to, UnsignedWord le @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static void copyUnalignedUpper(Pointer from, Pointer to, UnsignedWord length) { - UnsignedWord offset = WordFactory.zero(); + UnsignedWord offset = Word.zero(); if (length.and(4).notEqual(0)) { to.writeInt(offset, from.readInt(offset)); offset = offset.add(4); @@ -293,8 +292,8 @@ public static void fill(Pointer to, UnsignedWord size, byte value) { v = (v << 16) | v; v = (v << 32) | v; - UnsignedWord alignMask = WordFactory.unsigned(0x7); - UnsignedWord lowerSize = WordFactory.unsigned(0x8).subtract(to).and(alignMask); + UnsignedWord alignMask = Word.unsigned(0x7); + UnsignedWord lowerSize = Word.unsigned(0x8).subtract(to).and(alignMask); if (lowerSize.aboveThan(0)) { if (size.belowThan(lowerSize)) { lowerSize = size.and(lowerSize); @@ -315,7 +314,7 @@ public static void fill(Pointer to, UnsignedWord size, byte value) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static void fillUnalignedLower(Pointer to, long value, UnsignedWord length) { - UnsignedWord offset = WordFactory.zero(); + UnsignedWord offset = Word.zero(); if (length.and(1).notEqual(0)) { to.writeByte(offset, (byte) value); offset = offset.add(1); @@ -332,7 +331,7 @@ private static void fillUnalignedLower(Pointer to, long value, UnsignedWord leng @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static void fillUnalignedUpper(Pointer to, long value, UnsignedWord upperSize) { - UnsignedWord offset = WordFactory.zero(); + UnsignedWord offset = Word.zero(); if (upperSize.and(4).notEqual(0)) { to.writeInt(offset, (int) value); offset = offset.add(4); @@ -349,8 +348,8 @@ private static void fillUnalignedUpper(Pointer to, long value, UnsignedWord uppe @Uninterruptible(reason = "Accessed memory is on the heap, code must not be interrupted.") static void fillOnHeap(Object destBase, long destOffset, long bytes, byte bvalue) { - Word fromPtr = Word.objectToUntrackedPointer(destBase).add(WordFactory.unsigned(destOffset)); - fill(fromPtr, WordFactory.unsigned(bytes), bvalue); + Word fromPtr = Word.objectToUntrackedPointer(destBase).add(Word.unsigned(destOffset)); + fill(fromPtr, Word.unsigned(bytes), bvalue); } /** @@ -380,15 +379,15 @@ public static void copySwap(Pointer from, Pointer to, UnsignedWord size, Unsigne @Uninterruptible(reason = "Accessed memory is on the heap, code must not be interrupted.") static void copySwapOnHeap(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes, long elemSize) { - Word fromPtr = Word.objectToUntrackedPointer(srcBase).add(WordFactory.unsigned(srcOffset)); - Word toPtr = Word.objectToUntrackedPointer(destBase).add(WordFactory.unsigned(destOffset)); - copySwap(fromPtr, toPtr, WordFactory.unsigned(bytes), WordFactory.unsigned(elemSize)); + Word fromPtr = Word.objectToUntrackedPointer(srcBase).add(Word.unsigned(srcOffset)); + Word toPtr = Word.objectToUntrackedPointer(destBase).add(Word.unsigned(destOffset)); + copySwap(fromPtr, toPtr, Word.unsigned(bytes), Word.unsigned(elemSize)); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static void copySwap2(Pointer from, Pointer to, UnsignedWord size) { if (from.aboveThan(to)) { - for (UnsignedWord offset = WordFactory.zero(); offset.belowThan(size); offset = offset.add(2)) { + for (UnsignedWord offset = Word.zero(); offset.belowThan(size); offset = offset.add(2)) { to.writeShort(offset, Short.reverseBytes(from.readShort(offset))); } } else if (from.belowThan(to)) { @@ -401,7 +400,7 @@ private static void copySwap2(Pointer from, Pointer to, UnsignedWord size) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static void copySwap4(Pointer from, Pointer to, UnsignedWord size) { if (from.aboveThan(to)) { - for (UnsignedWord offset = WordFactory.zero(); offset.belowThan(size); offset = offset.add(4)) { + for (UnsignedWord offset = Word.zero(); offset.belowThan(size); offset = offset.add(4)) { to.writeInt(offset, Integer.reverseBytes(from.readInt(offset))); } } else if (from.belowThan(to)) { @@ -414,7 +413,7 @@ private static void copySwap4(Pointer from, Pointer to, UnsignedWord size) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static void copySwap8(Pointer from, Pointer to, UnsignedWord size) { if (from.aboveThan(to)) { - for (UnsignedWord offset = WordFactory.zero(); offset.belowThan(size); offset = offset.add(8)) { + for (UnsignedWord offset = Word.zero(); offset.belowThan(size); offset = offset.add(8)) { to.writeLong(offset, Long.reverseBytes(from.readLong(offset))); } } else if (from.belowThan(to)) { @@ -434,7 +433,7 @@ public static void copyObjectArrayForward(Object fromArray, int fromIndex, Objec UnsignedWord fromOffset = LayoutEncoding.getArrayElementOffset(layoutEncoding, fromIndex); UnsignedWord toOffset = LayoutEncoding.getArrayElementOffset(layoutEncoding, toIndex); - UnsignedWord count = WordFactory.unsigned(length); + UnsignedWord count = Word.unsigned(length); copyReferencesForward(fromArray, fromOffset, toArray, toOffset, count); } @@ -449,7 +448,7 @@ public static void copyObjectArrayBackward(Object fromArray, int fromIndex, Obje UnsignedWord fromOffset = LayoutEncoding.getArrayElementOffset(layoutEncoding, fromIndex); UnsignedWord toOffset = LayoutEncoding.getArrayElementOffset(layoutEncoding, toIndex); - UnsignedWord count = WordFactory.unsigned(length); + UnsignedWord count = Word.unsigned(length); copyReferencesBackward(fromArray, fromOffset, toArray, toOffset, count); } @@ -462,7 +461,7 @@ public static void copyObjectArrayBackward(Object fromArray, int fromIndex, Obje public static void copyReferencesForward(Object from, UnsignedWord fromOffset, Object to, UnsignedWord toOffset, UnsignedWord length) { int elementSize = ConfigurationValues.getObjectLayout().getReferenceSize(); UnsignedWord size = length.multiply(elementSize); - UnsignedWord copied = WordFactory.zero(); + UnsignedWord copied = Word.zero(); while (copied.belowThan(size)) { BarrieredAccess.writeObject(to, toOffset.add(copied), BarrieredAccess.readObject(from, fromOffset.add(copied))); copied = copied.add(elementSize); @@ -509,7 +508,7 @@ public static void copyPrimitiveArrayForward(Object fromArray, int fromIndex, Ob UnsignedWord fromOffset = LayoutEncoding.getArrayElementOffset(layoutEncoding, fromIndex); UnsignedWord toOffset = LayoutEncoding.getArrayElementOffset(layoutEncoding, toIndex); - UnsignedWord elementSize = WordFactory.unsigned(LayoutEncoding.getArrayIndexScale(layoutEncoding)); + UnsignedWord elementSize = Word.unsigned(LayoutEncoding.getArrayIndexScale(layoutEncoding)); UnsignedWord size = elementSize.multiply(length); copyPrimitiveArrayForward(fromArray, fromOffset, toArray, toOffset, size); @@ -544,7 +543,7 @@ public static void copyPrimitiveArrayBackward(Object fromArray, int fromIndex, O UnsignedWord fromOffset = LayoutEncoding.getArrayElementOffset(layoutEncoding, fromIndex); UnsignedWord toOffset = LayoutEncoding.getArrayElementOffset(layoutEncoding, toIndex); - UnsignedWord elementSize = WordFactory.unsigned(LayoutEncoding.getArrayIndexScale(layoutEncoding)); + UnsignedWord elementSize = Word.unsigned(LayoutEncoding.getArrayIndexScale(layoutEncoding)); UnsignedWord size = elementSize.multiply(length); copyPrimitiveArrayBackward(fromArray, fromOffset, toArray, toOffset, size); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/RegisterDumper.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/RegisterDumper.java index 86ba51e9a7f9..2f3e132815b9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/RegisterDumper.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/RegisterDumper.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.util.VMError; @@ -44,7 +44,7 @@ static void dumpReg(Log log, String label, long value, boolean printLocationInfo log.string(label).zhex(value); if (printLocationInfo) { log.spaces(1); - SubstrateDiagnostics.printLocationInfo(log, WordFactory.unsigned(value), allowJavaHeapAccess, allowUnsafeOperations); + SubstrateDiagnostics.printLocationInfo(log, Word.unsigned(value), allowJavaHeapAccess, allowUnsafeOperations); } log.newline(); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java index cf601dec35f1..f6c6809c52e0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java @@ -44,7 +44,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateDiagnostics.DiagnosticThunkRegistry; import com.oracle.svm.core.SubstrateDiagnostics.DumpCodeCacheHistory; @@ -198,8 +197,8 @@ private static void printSomeArrayData(Log log, Object obj, int length, int layo int maxPrintedBytes = elementSize == 1 ? 8 : 16; int printedElements = UninterruptibleUtils.Math.min(length, maxPrintedBytes / elementSize); - UnsignedWord curOffset = WordFactory.unsigned(arrayBaseOffset); - UnsignedWord endOffset = curOffset.add(WordFactory.unsigned(printedElements).multiply(elementSize)); + UnsignedWord curOffset = Word.unsigned(arrayBaseOffset); + UnsignedWord endOffset = curOffset.add(Word.unsigned(printedElements).multiply(elementSize)); while (curOffset.belowThan(endOffset)) { switch (elementSize) { case 1 -> log.zhex(ObjectAccess.readByte(obj, curOffset)); @@ -221,7 +220,7 @@ private static void printSomeArrayData(Log log, Object obj, int length, int layo * See {@link #printInformation(Log, Pointer, CodePointer, RegisterDumper.Context, boolean)}. */ public static void printInformation(Log log, Pointer sp, CodePointer ip) { - printInformation(log, sp, ip, WordFactory.nullPointer(), false); + printInformation(log, sp, ip, Word.nullPointer(), false); } /** @@ -254,7 +253,7 @@ public static void printInformation(Log log, Pointer sp, CodePointer ip, Registe * See {@link #printFatalError(Log, Pointer, CodePointer, RegisterDumper.Context, boolean)}. */ public static boolean printFatalError(Log log, Pointer sp, CodePointer ip) { - return printFatalError(log, sp, ip, WordFactory.nullPointer(), false); + return printFatalError(log, sp, ip, Word.nullPointer(), false); } /** @@ -506,7 +505,7 @@ private static Pointer findPotentialReturnAddressPosition(Pointer originalSp) { } pos = pos.add(wordSize); } - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Uninterruptible(reason = "Prevent the GC from freeing the CodeInfo.") @@ -538,7 +537,7 @@ public ErrorContext getErrorContext() { @SuppressWarnings("hiding") public boolean trySet(Log log, Pointer sp, CodePointer ip, RegisterDumper.Context registerContext, boolean frameHasCalleeSavedRegisters) { - if (diagnosticThread.compareAndSet(WordFactory.nullPointer(), CurrentIsolate.getCurrentThread())) { + if (diagnosticThread.compareAndSet(Word.nullPointer(), CurrentIsolate.getCurrentThread())) { assert diagnosticThunkIndex == -1; assert invocationCount == 0; this.log = log; @@ -557,15 +556,15 @@ public void clear() { log = null; ErrorContext errorContext = getErrorContext(); - errorContext.setStackPointer(WordFactory.nullPointer()); - errorContext.setInstructionPointer(WordFactory.nullPointer()); - errorContext.setRegisterContext(WordFactory.nullPointer()); + errorContext.setStackPointer(Word.nullPointer()); + errorContext.setInstructionPointer(Word.nullPointer()); + errorContext.setRegisterContext(Word.nullPointer()); errorContext.setFrameHasCalleeSavedRegisters(false); diagnosticThunkIndex = -1; invocationCount = 0; - diagnosticThread.set(WordFactory.nullPointer()); + diagnosticThread.set(Word.nullPointer()); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateGCOptions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateGCOptions.java index 506c8de0cb48..982ded5cea10 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateGCOptions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateGCOptions.java @@ -27,8 +27,8 @@ import static com.oracle.svm.core.option.RuntimeOptionKey.RuntimeOptionKeyFlag.Immutable; import static com.oracle.svm.core.option.RuntimeOptionKey.RuntimeOptionKeyFlag.IsolateCreationOnly; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicMap; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.heap.HeapSizeVerifier; import com.oracle.svm.core.option.HostedOptionKey; @@ -51,7 +51,7 @@ public class SubstrateGCOptions { @Override protected void onValueUpdate(EconomicMap, Object> values, Long oldValue, Long newValue) { if (!SubstrateUtil.HOSTED) { - HeapSizeVerifier.verifyMinHeapSizeAgainstMaxAddressSpaceSize(WordFactory.unsigned(newValue)); + HeapSizeVerifier.verifyMinHeapSizeAgainstMaxAddressSpaceSize(Word.unsigned(newValue)); } super.onValueUpdate(values, oldValue, newValue); } @@ -62,7 +62,7 @@ protected void onValueUpdate(EconomicMap, Object> values, Long oldV @Override protected void onValueUpdate(EconomicMap, Object> values, Long oldValue, Long newValue) { if (!SubstrateUtil.HOSTED) { - HeapSizeVerifier.verifyMaxHeapSizeAgainstMaxAddressSpaceSize(WordFactory.unsigned(newValue)); + HeapSizeVerifier.verifyMaxHeapSizeAgainstMaxAddressSpaceSize(Word.unsigned(newValue)); } super.onValueUpdate(values, oldValue, newValue); } @@ -73,7 +73,7 @@ protected void onValueUpdate(EconomicMap, Object> values, Long oldV @Override protected void onValueUpdate(EconomicMap, Object> values, Long oldValue, Long newValue) { if (!SubstrateUtil.HOSTED) { - HeapSizeVerifier.verifyMaxNewSizeAgainstMaxAddressSpaceSize(WordFactory.unsigned(newValue)); + HeapSizeVerifier.verifyMaxNewSizeAgainstMaxAddressSpaceSize(Word.unsigned(newValue)); } super.onValueUpdate(values, oldValue, newValue); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateSegfaultHandler.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateSegfaultHandler.java index 8be03d2ddd8b..a6d974254765 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateSegfaultHandler.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateSegfaultHandler.java @@ -41,7 +41,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.BuildPhaseProvider.ReadyForCompilation; import com.oracle.svm.core.IsolateListenerSupport.IsolateListener; @@ -120,8 +119,8 @@ public void execute(boolean isFirstIsolate) { } private static boolean isFirst() { - Word expected = WordFactory.zero(); - Word actual = SEGFAULT_HANDLER_INSTALLED.get().compareAndSwapWord(0, expected, WordFactory.unsigned(1), LocationIdentity.ANY_LOCATION); + Word expected = Word.zero(); + Word actual = SEGFAULT_HANDLER_INSTALLED.get().compareAndSwapWord(0, expected, Word.unsigned(1), LocationIdentity.ANY_LOCATION); return expected == actual; } } @@ -182,7 +181,7 @@ private static boolean tryEnterIsolateViaThreadRegister(RegisterDumper.Context c * Try to determine the isolate via the thread register. Set the thread register to null so * that we don't execute this code more than once if we trigger a recursive segfault. */ - WriteCurrentVMThreadNode.writeCurrentVMThread(WordFactory.nullPointer()); + WriteCurrentVMThreadNode.writeCurrentVMThread(Word.nullPointer()); IsolateThread isolateThread = (IsolateThread) RegisterDumper.singleton().getThreadPointer(context); if (isolateThread.isNonNull()) { @@ -203,7 +202,7 @@ private static boolean tryEnterIsolateViaHeapBaseRegister(RegisterDumper.Context * Set the heap base register to null so that we don't execute this code more than once if * we trigger a recursive segfault. */ - CEntryPointSnippets.setHeapBase(WordFactory.nullPointer()); + CEntryPointSnippets.setHeapBase(Word.nullPointer()); Isolate isolate = (Isolate) RegisterDumper.singleton().getHeapBase(context); if (isValid(isolate)) { @@ -225,7 +224,7 @@ private static boolean isValid(Isolate isolate) { * invalid value when we execute this code, which makes things a bit more complex. */ UnsignedWord staticFieldsOffsets = ReferenceAccess.singleton().getCompressedRepresentation(StaticFieldsSupport.getStaticPrimitiveFields()); - UnsignedWord wellKnownFieldOffset = staticFieldsOffsets.shiftLeft(ReferenceAccess.singleton().getCompressionShift()).add(WordFactory.unsigned(offsetOfStaticFieldWithWellKnownValue)); + UnsignedWord wellKnownFieldOffset = staticFieldsOffsets.shiftLeft(ReferenceAccess.singleton().getCompressionShift()).add(Word.unsigned(offsetOfStaticFieldWithWellKnownValue)); Pointer wellKnownField = ((Pointer) isolate).add(wellKnownFieldOffset); return wellKnownField.readLong(0) == MARKER_VALUE; } @@ -246,7 +245,7 @@ public static void enterIsolateAsyncSignalSafe(Isolate isolate) { */ int isolateThreadSize = VMThreadLocalSupport.singleton().vmThreadSize; IsolateThread structForUnattachedThread = UnsafeLateStackValue.get(isolateThreadSize); - UnmanagedMemoryUtil.fill((Pointer) structForUnattachedThread, WordFactory.unsigned(isolateThreadSize), (byte) 0); + UnmanagedMemoryUtil.fill((Pointer) structForUnattachedThread, Word.unsigned(isolateThreadSize), (byte) 0); CEntryPointSnippets.initializeIsolateThreadForCrashHandler(isolate, structForUnattachedThread); } } @@ -321,9 +320,9 @@ public static SingleIsolateSegfaultSetup singleton() { @Override @Uninterruptible(reason = "Thread state not yet set up.") public void afterCreateIsolate(Isolate isolate) { - PointerBase value = baseIsolate.get().compareAndSwapWord(0, WordFactory.zero(), isolate, LocationIdentity.ANY_LOCATION); + PointerBase value = baseIsolate.get().compareAndSwapWord(0, Word.zero(), isolate, LocationIdentity.ANY_LOCATION); if (!value.isNull()) { - baseIsolate.get().writeWord(0, WordFactory.signed(-1)); + baseIsolate.get().writeWord(0, Word.signed(-1)); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateUtil.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateUtil.java index 14725c568f79..d7459d547695 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateUtil.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateUtil.java @@ -38,6 +38,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.type.CCharPointer; @@ -45,7 +46,6 @@ import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.RecomputeFieldValue; @@ -184,7 +184,7 @@ public static String[] convertCToJavaArgs(int argc, CCharPointerPointer argv) { */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static UnsignedWord strlen(CCharPointer str) { - UnsignedWord n = WordFactory.zero(); + UnsignedWord n = Word.zero(); while (((Pointer) str).readByte(n) != 0) { n = n.add(1); } @@ -203,7 +203,7 @@ public static CCharPointer strchr(CCharPointer str, int c) { return str.addressOf(index); } if (b == 0) { - return WordFactory.zero(); + return Word.zero(); } index += 1; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/UnmanagedMemoryUtil.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/UnmanagedMemoryUtil.java index 97606486838c..f31ba4a5bbed 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/UnmanagedMemoryUtil.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/UnmanagedMemoryUtil.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.config.ConfigurationValues; @@ -76,7 +76,7 @@ public static void copy(Pointer from, Pointer to, UnsignedWord size) { @IntrinsicCandidate @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static void copyForward(Pointer from, Pointer to, UnsignedWord size) { - UnsignedWord alignBits = WordFactory.unsigned(0x7); + UnsignedWord alignBits = Word.unsigned(0x7); UnsignedWord alignedSize = size.and(alignBits.not()); copyLongsForward(from, to, alignedSize); @@ -105,7 +105,7 @@ public static void copyForward(Pointer from, Pointer to, UnsignedWord size) { @IntrinsicCandidate @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static void copyBackward(Pointer from, Pointer to, UnsignedWord size) { - UnsignedWord alignBits = WordFactory.unsigned(0x7); + UnsignedWord alignBits = Word.unsigned(0x7); UnsignedWord alignedSize = size.and(alignBits.not()); UnsignedWord unalignedSize = size.subtract(alignedSize); copyLongsBackward(from.add(unalignedSize), to.add(unalignedSize), alignedSize); @@ -135,7 +135,7 @@ public static void copyBackward(Pointer from, Pointer to, UnsignedWord size) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static void copyLongsForward(Pointer from, Pointer to, UnsignedWord size) { assert size.unsignedRemainder(8).equal(0); - UnsignedWord offset = WordFactory.zero(); + UnsignedWord offset = Word.zero(); for (UnsignedWord next = offset.add(32); next.belowOrEqual(size); next = offset.add(32)) { Pointer src = from.add(offset); Pointer dst = to.add(offset); @@ -180,7 +180,7 @@ public static void copyWordsForward(Pointer from, Pointer to, UnsignedWord size) } while (src.belowThan(srcEnd)) { - dst.writeWord(WordFactory.zero(), src.readWord(WordFactory.zero())); + dst.writeWord(Word.zero(), src.readWord(Word.zero())); src = src.add(wordSize); dst = dst.add(wordSize); } @@ -219,7 +219,7 @@ public static void copyLongsBackward(Pointer from, Pointer to, UnsignedWord size @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static UnsignedWord compareLongs(Pointer x, Pointer y, UnsignedWord size) { assert size.unsignedRemainder(8).equal(0); - UnsignedWord offset = WordFactory.zero(); + UnsignedWord offset = Word.zero(); while (offset.belowThan(size)) { if (x.readLong(offset) != y.readLong(offset)) { return offset; @@ -231,7 +231,7 @@ private static UnsignedWord compareLongs(Pointer x, Pointer y, UnsignedWord size @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static UnsignedWord compareBytes(Pointer x, Pointer y, UnsignedWord size) { - UnsignedWord offset = WordFactory.zero(); + UnsignedWord offset = Word.zero(); while (offset.belowThan(size)) { if (x.readByte(offset) != y.readByte(offset)) { return offset; @@ -247,7 +247,7 @@ private static UnsignedWord compareBytes(Pointer x, Pointer y, UnsignedWord size */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static UnsignedWord compare(Pointer x, Pointer y, UnsignedWord size) { - UnsignedWord alignBits = WordFactory.unsigned(0x7); + UnsignedWord alignBits = Word.unsigned(0x7); UnsignedWord alignedSize = size.and(alignBits.not()); UnsignedWord offset = compareLongs(x, y, alignedSize); return offset.add(compareBytes(x.add(offset), y.add(offset), size.subtract(offset))); @@ -265,7 +265,7 @@ public static void fill(Pointer to, UnsignedWord size, byte value) { v = (v << 16) | v; v = (v << 32) | v; - UnsignedWord alignBits = WordFactory.unsigned(0x7); + UnsignedWord alignBits = Word.unsigned(0x7); UnsignedWord alignedSize = size.and(alignBits.not()); fillLongs(to, alignedSize, v); @@ -294,7 +294,7 @@ public static void fill(Pointer to, UnsignedWord size, byte value) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static void fillLongs(Pointer to, UnsignedWord size, long longValue) { assert size.unsignedRemainder(8).equal(0); - UnsignedWord offset = WordFactory.zero(); + UnsignedWord offset = Word.zero(); for (UnsignedWord next = offset.add(32); next.belowOrEqual(size); next = offset.add(32)) { Pointer p = to.add(offset); p.writeLong(0, longValue); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/UnsafeMemoryUtil.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/UnsafeMemoryUtil.java index e2e05a59acb6..f86e4744e531 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/UnsafeMemoryUtil.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/UnsafeMemoryUtil.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.impl.InternalPlatform; import org.graalvm.nativeimage.impl.UnsafeMemorySupport; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; @@ -39,9 +39,9 @@ public class UnsafeMemoryUtil implements UnsafeMemorySupport { @Override public void unsafeCopyMemory(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes) { if (srcBase != null || destBase != null) { - JavaMemoryUtil.copyOnHeap(srcBase, WordFactory.unsigned(srcOffset), destBase, WordFactory.unsigned(destOffset), WordFactory.unsigned(bytes)); + JavaMemoryUtil.copyOnHeap(srcBase, Word.unsigned(srcOffset), destBase, Word.unsigned(destOffset), Word.unsigned(bytes)); } else { - UnmanagedMemoryUtil.copy(WordFactory.pointer(srcOffset), WordFactory.pointer(destOffset), WordFactory.unsigned(bytes)); + UnmanagedMemoryUtil.copy(Word.pointer(srcOffset), Word.pointer(destOffset), Word.unsigned(bytes)); } } @@ -52,7 +52,7 @@ public void unsafeSetMemory(Object destBase, long destOffset, long bytes, byte b if (destBase != null) { JavaMemoryUtil.fillOnHeap(destBase, destOffset, bytes, bvalue); } else { - JavaMemoryUtil.fill(WordFactory.pointer(destOffset), WordFactory.unsigned(bytes), bvalue); + JavaMemoryUtil.fill(Word.pointer(destOffset), Word.unsigned(bytes), bvalue); } } @@ -62,7 +62,7 @@ public void unsafeCopySwapMemory(Object srcBase, long srcOffset, Object destBase if (srcBase != null || destBase != null) { JavaMemoryUtil.copySwapOnHeap(srcBase, srcOffset, destBase, destOffset, bytes, elemSize); } else { - JavaMemoryUtil.copySwap(WordFactory.unsigned(srcOffset), WordFactory.unsigned(destOffset), WordFactory.unsigned(bytes), WordFactory.unsigned(elemSize)); + JavaMemoryUtil.copySwap(Word.unsigned(srcOffset), Word.unsigned(destOffset), Word.unsigned(bytes), Word.unsigned(elemSize)); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CIsolateDataStorage.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CIsolateDataStorage.java index 69c7bbd3665e..53053edbb334 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CIsolateDataStorage.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CIsolateDataStorage.java @@ -40,7 +40,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import jdk.vm.ci.meta.JavaKind; @@ -67,7 +66,7 @@ public CIsolateDataStorage() { @Platforms(Platform.HOSTED_ONLY.class) public void setSize(UnsignedWord size) { assert managedIsolateSectionData == null; - UnsignedWord allocationSize = size.add(WordFactory.unsigned(ALIGNMENT - 1)); + UnsignedWord allocationSize = size.add(Word.unsigned(ALIGNMENT - 1)); managedIsolateSectionData = new byte[UnsignedUtils.safeToInt(allocationSize)]; } @@ -79,7 +78,7 @@ public static CIsolateDataStorage singleton() { @Fold protected static UnsignedWord arrayBaseOffset() { int offset = ConfigurationValues.getObjectLayout().getArrayBaseOffset(JavaKind.Byte); - return UnsignedUtils.roundUp(WordFactory.unsigned(offset), WordFactory.unsigned(ALIGNMENT)); + return UnsignedUtils.roundUp(Word.unsigned(offset), Word.unsigned(ALIGNMENT)); } @SuppressWarnings("unchecked") diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CTypeConversionSupportImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CTypeConversionSupportImpl.java index 4bb9fe78f983..28444296e3a9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CTypeConversionSupportImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CTypeConversionSupportImpl.java @@ -29,6 +29,7 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CCharPointerPointer; @@ -38,7 +39,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.config.ConfigurationValues; @@ -52,7 +52,7 @@ class CTypeConversionSupportImpl implements CTypeConversionSupport { static final CCharPointerHolder NULL_HOLDER = new CCharPointerHolder() { @Override public CCharPointer get() { - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Override @@ -64,7 +64,7 @@ public void close() { static final CCharPointerPointerHolder NULL_POINTER_POINTER_HOLDER = new CCharPointerPointerHolder() { @Override public CCharPointerPointer get() { - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Override @@ -144,7 +144,7 @@ public UnsignedWord toCString(CharSequence javaString, Charset charset, CCharPoi if (capacity != 0) { throw new IllegalArgumentException("Non zero buffer size passed along with nullptr"); } - return WordFactory.unsigned(baseString.length); + return Word.unsigned(baseString.length); } else if (capacity < baseString.length + 1) { throw new IllegalArgumentException("Provided buffer is too small to hold 0 terminated java string."); @@ -157,7 +157,7 @@ public UnsignedWord toCString(CharSequence javaString, Charset charset, CCharPoi // write null terminator at end buffer.write(baseString.length, (byte) 0); - return WordFactory.unsigned(baseString.length); + return Word.unsigned(baseString.length); } @Override @@ -235,7 +235,7 @@ final class CCharPointerPointerHolderImpl extends CCharPointerPointerHolder { ccpArray[i] = ccpHolderArray[i].get(); } /* Null-terminate the CCharPointer[]. */ - ccpArray[csArray.length] = WordFactory.nullPointer(); + ccpArray[csArray.length] = Word.nullPointer(); /* Pin the CCharPointer[] so I can get the &ccpArray[0]. */ refCCPArray = PrimitiveArrayView.createForReading(ccpArray); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/NonmovableArrays.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/NonmovableArrays.java index e55ad201f78b..fe20441cf3e2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/NonmovableArrays.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/NonmovableArrays.java @@ -35,7 +35,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.JavaMemoryUtil; import com.oracle.svm.core.SubstrateUtil; @@ -148,7 +147,7 @@ public static int lengthOf(NonmovableArray array) { /** Provides the size of the given array in bytes. */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static UnsignedWord byteSizeOf(NonmovableArray array) { - return array.isNonNull() ? LayoutEncoding.getArrayAllocationSize(readLayoutEncoding(array), lengthOf(array)) : WordFactory.zero(); + return array.isNonNull() ? LayoutEncoding.getArrayAllocationSize(readLayoutEncoding(array), lengthOf(array)) : Word.zero(); } /** @see System#arraycopy */ @@ -160,7 +159,7 @@ public static void arraycopy(NonmovableArray src, int srcPos, NonmovableArray } assert srcPos >= 0 && destPos >= 0 && length >= 0 && srcPos + length <= lengthOf(src) && destPos + length <= lengthOf(dest); assert readHub(src) == readHub(dest) : "copying is only allowed with same component types"; - UnmanagedMemoryUtil.copy(addressOf(src, srcPos), addressOf(dest, destPos), WordFactory.unsigned(length << readElementShift(dest))); + UnmanagedMemoryUtil.copy(addressOf(src, srcPos), addressOf(dest, destPos), Word.unsigned(length << readElementShift(dest))); } /** Provides an array for which {@link NonmovableArray#isNull()} returns {@code true}. */ @@ -170,7 +169,7 @@ public static > T nullArray() { if (SubstrateUtil.HOSTED) { return (T) HOSTED_NULL_VALUE; } - return WordFactory.nullPointer(); + return Word.nullPointer(); } /** @@ -286,7 +285,7 @@ private static T arraycopyToHeap(NonmovableArray src, int srcPos, T dest, Pointer destAddressAtPos = Word.objectToUntrackedPointer(dest).add(LayoutEncoding.getArrayElementOffset(destHub.getLayoutEncoding(), destPos)); if (LayoutEncoding.isPrimitiveArray(destHub.getLayoutEncoding())) { Pointer srcAddressAtPos = addressOf(src, srcPos); - JavaMemoryUtil.copyPrimitiveArrayForward(srcAddressAtPos, destAddressAtPos, WordFactory.unsigned(length << readElementShift(src))); + JavaMemoryUtil.copyPrimitiveArrayForward(srcAddressAtPos, destAddressAtPos, Word.unsigned(length << readElementShift(src))); } else { // needs barriers Object[] destArr = (Object[]) dest; for (int i = 0; i < length; i++) { @@ -322,7 +321,7 @@ public static NonmovableArray fromImageHeap(Object array) { return new HostedNonmovableArray<>(array); } assert array == null || Heap.getHeap().isInImageHeap(array); - return (array != null) ? (NonmovableArray) Word.objectToUntrackedPointer(array) : WordFactory.nullPointer(); + return (array != null) ? (NonmovableArray) Word.objectToUntrackedPointer(array) : Word.nullPointer(); } /** Returns a {@link NonmovableObjectArray} for an object array in the image heap. */ diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/UnmanagedPrimitiveArrays.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/UnmanagedPrimitiveArrays.java index 5b82ecf53e6f..3d6932283d80 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/UnmanagedPrimitiveArrays.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/UnmanagedPrimitiveArrays.java @@ -27,7 +27,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.JavaMemoryUtil; import com.oracle.svm.core.SubstrateUtil; @@ -61,7 +60,7 @@ public final class UnmanagedPrimitiveArrays { public static > T createArray(int length, Class arrayType, NmtCategory nmtCategory) { DynamicHub hub = SubstrateUtil.cast(arrayType, DynamicHub.class); VMError.guarantee(LayoutEncoding.isPrimitiveArray(hub.getLayoutEncoding())); - UnsignedWord size = WordFactory.unsigned(length).shiftLeft(LayoutEncoding.getArrayIndexShift(hub.getLayoutEncoding())); + UnsignedWord size = Word.unsigned(length).shiftLeft(LayoutEncoding.getArrayIndexShift(hub.getLayoutEncoding())); Pointer array = NullableNativeMemory.calloc(size, nmtCategory); if (array.isNull()) { throw OUT_OF_MEMORY_ERROR; @@ -107,7 +106,7 @@ public static T copyToHeap(UnmanagedPrimitiveArray src, int srcPos, T des VMError.guarantee(srcPos >= 0 && destPos >= 0 && length >= 0 && destPos + length <= ArrayLengthNode.arrayLength(dest)); Pointer destAddressAtPos = Word.objectToUntrackedPointer(dest).add(LayoutEncoding.getArrayElementOffset(destHub.getLayoutEncoding(), destPos)); Pointer srcAddressAtPos = getAddressOf(src, destHub.getLayoutEncoding(), srcPos); - JavaMemoryUtil.copyPrimitiveArrayForward(srcAddressAtPos, destAddressAtPos, WordFactory.unsigned(length).shiftLeft(LayoutEncoding.getArrayIndexShift(destHub.getLayoutEncoding()))); + JavaMemoryUtil.copyPrimitiveArrayForward(srcAddressAtPos, destAddressAtPos, Word.unsigned(length).shiftLeft(LayoutEncoding.getArrayIndexShift(destHub.getLayoutEncoding()))); return dest; } @@ -119,13 +118,13 @@ public static T compareOrCopyToHeap(UnmanagedPrimitiveArray src, int srcP Pointer destAddressAtPos = Word.objectToUntrackedPointer(dest).add(LayoutEncoding.getArrayElementOffset(destHub.getLayoutEncoding(), destPos)); Pointer srcAddressAtPos = getAddressOf(src, destHub.getLayoutEncoding(), srcPos); - UnsignedWord size = WordFactory.unsigned(length).shiftLeft(LayoutEncoding.getArrayIndexShift(destHub.getLayoutEncoding())); + UnsignedWord size = Word.unsigned(length).shiftLeft(LayoutEncoding.getArrayIndexShift(destHub.getLayoutEncoding())); // First compare until a difference is found UnsignedWord equalBytes = UnmanagedMemoryUtil.compare(srcAddressAtPos, destAddressAtPos, size); if (equalBytes.belowThan(size)) { // If the two arrays are not equal, copy over the remaining bytes - UnsignedWord alignBits = WordFactory.unsigned(0x7); + UnsignedWord alignBits = Word.unsigned(0x7); UnsignedWord offset = equalBytes.and(alignBits.not()); JavaMemoryUtil.copyPrimitiveArrayForward(srcAddressAtPos.add(offset), destAddressAtPos.add(offset), size.subtract(offset)); } @@ -140,7 +139,7 @@ public static UnmanagedPrimitiveArray copyFromHeap(T src, int srcPos, Unm VMError.guarantee(srcPos >= 0 && destPos >= 0 && length >= 0 && srcPos + length <= ArrayLengthNode.arrayLength(src)); Pointer srcAddressAtPos = Word.objectToUntrackedPointer(src).add(LayoutEncoding.getArrayElementOffset(srcHub.getLayoutEncoding(), srcPos)); Pointer destAddressAtPos = getAddressOf(dest, srcHub.getLayoutEncoding(), destPos); - JavaMemoryUtil.copyPrimitiveArrayForward(srcAddressAtPos, destAddressAtPos, WordFactory.unsigned(length).shiftLeft(LayoutEncoding.getArrayIndexShift(srcHub.getLayoutEncoding()))); + JavaMemoryUtil.copyPrimitiveArrayForward(srcAddressAtPos, destAddressAtPos, Word.unsigned(length).shiftLeft(LayoutEncoding.getArrayIndexShift(srcHub.getLayoutEncoding()))); return dest; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/enums/CEnumRuntimeData.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/enums/CEnumRuntimeData.java index 8d2ba5e16b18..48bbbfbf56ac 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/enums/CEnumRuntimeData.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/enums/CEnumRuntimeData.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.c.enums; +import jdk.graal.compiler.word.Word; import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.jdk.UninterruptibleUtils.CodeUtil; @@ -82,13 +82,13 @@ public final long enumToLong(Enum value) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public final SignedWord enumToSignedWord(Enum value) { long result = enumToLong(value); - return WordFactory.signed(result); + return Word.signed(result); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public final UnsignedWord enumToUnsignedWord(Enum value) { long result = CodeUtil.zeroExtend(enumToLong(value), bytesInC * Byte.SIZE); - return WordFactory.unsigned(result); + return Word.unsigned(result); } /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointActions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointActions.java index 736543bc8c00..3d6e9458e46f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointActions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointActions.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.c.function; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Isolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.type.CCharPointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.thread.PlatformThreads; @@ -124,7 +124,7 @@ private CEntryPointActions() { * * @param code An integer representing the cause (should be non-zero by convention). * @param message A message describing the cause (may be omitted by passing - * {@link WordFactory#nullPointer() null}). + * {@link Word#nullPointer() null}). */ public static native void failFatally(int code, CCharPointer message); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointBuiltins.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointBuiltins.java index 017e798aadd9..7e6957f6329a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointBuiltins.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointBuiltins.java @@ -29,13 +29,13 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.Isolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.function.CEntryPoint.Builtin; import org.graalvm.nativeimage.c.function.CEntryPoint.Publish; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.function.CEntryPointOptions.NoEpilogue; @@ -61,9 +61,9 @@ public final class CEntryPointBuiltins { @CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class) @CEntryPointBuiltinImplementation(builtin = Builtin.CREATE_ISOLATE) public static IsolateThread createIsolate() { - int status = CEntryPointActions.enterCreateIsolate(WordFactory.nullPointer()); + int status = CEntryPointActions.enterCreateIsolate(Word.nullPointer()); if (status != 0) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } IsolateThread result = CurrentIsolate.getCurrentThread(); @@ -78,7 +78,7 @@ public static IsolateThread createIsolate() { public static IsolateThread attachThread(Isolate isolate) { int status = CEntryPointActions.enterAttachThread(isolate, false, true); if (status != 0) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } IsolateThread result = CurrentIsolate.getCurrentThread(); @@ -93,7 +93,7 @@ public static IsolateThread attachThread(Isolate isolate) { public static IsolateThread getCurrentThread(Isolate isolate) { int status = CEntryPointActions.enterByIsolate(isolate); if (status != 0) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } IsolateThread thread = CurrentIsolate.getCurrentThread(); @@ -108,7 +108,7 @@ public static IsolateThread getCurrentThread(Isolate isolate) { public static Isolate getIsolate(IsolateThread thread) { int status = CEntryPointActions.enter(thread); if (status != 0) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } Isolate isolate = CurrentIsolate.getIsolate(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointErrors.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointErrors.java index 6a6cbf8e5eaa..8fd66dc87389 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointErrors.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointErrors.java @@ -36,12 +36,12 @@ import java.util.Arrays; import java.util.Objects; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.AnnotationAccess; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -219,7 +219,7 @@ private static Pointer getDescriptionAsCString(int code, Pointer cstrings) { } offset++; } - return WordFactory.nullPointer(); + return Word.nullPointer(); } private static final String[] DESCRIPTIONS; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointNativeFunctions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointNativeFunctions.java index 2466a944d585..082d5460bb2e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointNativeFunctions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointNativeFunctions.java @@ -26,6 +26,7 @@ import java.util.function.Function; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.Isolate; import org.graalvm.nativeimage.IsolateThread; @@ -33,7 +34,6 @@ import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.struct.CPointerTo; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; @@ -117,7 +117,7 @@ public static int attachThread(Isolate isolate, IsolateThreadPointer thread) { public static IsolateThread getCurrentThread(Isolate isolate) { int status = CEntryPointActions.enterByIsolate(isolate); if (status != 0) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } IsolateThread thread = CurrentIsolate.getCurrentThread(); @@ -136,7 +136,7 @@ public static Isolate getIsolate(IsolateThread thread) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static Isolate getIsolateOf(IsolateThread thread) { - Isolate isolate = WordFactory.nullPointer(); + Isolate isolate = Word.nullPointer(); if (thread.isNonNull()) { isolate = VMThreads.IsolateTL.get(thread); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointOptions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointOptions.java index a434d2f3834b..4bcb1d7ef0fe 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointOptions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointOptions.java @@ -30,9 +30,9 @@ import java.lang.annotation.Target; import java.util.function.Function; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; @@ -106,7 +106,7 @@ final class ReturnNullPointer implements PrologueBailout { @SuppressWarnings("unused") @Uninterruptible(reason = "Thread state not set up yet.") public static PointerBase bailout(int prologueResult) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointSetup.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointSetup.java index a99c930d5548..0c31edbaf1f0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointSetup.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/CEntryPointSetup.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.c.function; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.c.type.CCharPointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -52,7 +52,7 @@ public static final class EnterCreateIsolatePrologue implements CEntryPointOptio @Uninterruptible(reason = "prologue") public static void enter() { - int code = CEntryPointActions.enterCreateIsolate(WordFactory.nullPointer()); + int code = CEntryPointActions.enterCreateIsolate(Word.nullPointer()); if (code != CEntryPointErrors.NO_ERROR) { CEntryPointActions.failFatally(code, errorMessage.get()); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/IsolateSupportImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/IsolateSupportImpl.java index 753acfcddb1a..e0dc0b6165eb 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/IsolateSupportImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/IsolateSupportImpl.java @@ -28,6 +28,7 @@ import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Isolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Isolates.CreateIsolateParameters; @@ -38,7 +39,6 @@ import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.impl.IsolateSupport; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.c.function.CEntryPointNativeFunctions.IsolateThreadPointer; @@ -85,7 +85,7 @@ public static IsolateThread createIsolate(CreateIsolateParameters parameters, bo // Prepare argc and argv. int argc = 0; - CCharPointerPointer argv = WordFactory.nullPointer(); + CCharPointerPointer argv = Word.nullPointer(); List args = parameters.getArguments(); CTypeConversion.CCharPointerHolder[] pointerHolders = null; @@ -96,7 +96,7 @@ public static IsolateThread createIsolate(CreateIsolateParameters parameters, bo // the name of the binary. We use null when isolates are created manually. argc = isolateArgCount + 1; argv = NativeMemory.malloc(SizeOf.unsigned(CCharPointerPointer.class).multiply(argc), NmtCategory.Internal); - argv.write(0, WordFactory.nullPointer()); + argv.write(0, Word.nullPointer()); pointerHolders = new CTypeConversion.CCharPointerHolder[isolateArgCount]; for (int i = 0; i < isolateArgCount; i++) { @@ -119,7 +119,7 @@ public static IsolateThread createIsolate(CreateIsolateParameters parameters, bo // Try to create the isolate. IsolateThreadPointer isolateThreadPtr = UnsafeStackValue.get(IsolateThreadPointer.class); - int result = CEntryPointNativeFunctions.createIsolate(params, WordFactory.nullPointer(), isolateThreadPtr); + int result = CEntryPointNativeFunctions.createIsolate(params, Word.nullPointer(), isolateThreadPtr); IsolateThread isolateThread = isolateThreadPtr.read(); // Cleanup all native memory related to argv. @@ -173,7 +173,7 @@ private static void throwOnError(int code) { } } - private static final CGlobalData nextIsolateId = CGlobalDataFactory.createWord((Pointer) WordFactory.unsigned(1L)); + private static final CGlobalData nextIsolateId = CGlobalDataFactory.createWord((Pointer) Word.unsigned(1L)); private volatile long isolateId = 0; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/struct/OffsetOf.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/struct/OffsetOf.java index fb772051311f..f877b14075fc 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/struct/OffsetOf.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/struct/OffsetOf.java @@ -24,12 +24,12 @@ */ package com.oracle.svm.core.c.struct; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.struct.CStruct; import org.graalvm.nativeimage.c.struct.RawStructure; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; /** * Supplies static methods that provide access to the offset of fields of {@link CStruct} and @@ -48,6 +48,6 @@ public static int get(Class clazz, String fieldName) { } public static UnsignedWord unsigned(Class clazz, String fieldName) { - return WordFactory.unsigned(get(clazz, fieldName)); + return Word.unsigned(get(clazz, fieldName)); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java index e780bdd716e7..258dd7436253 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java @@ -28,12 +28,12 @@ import java.util.concurrent.locks.ReentrantLock; import com.oracle.svm.core.hub.RuntimeClassLoading; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CFunctionPointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.FunctionPointerHolder; import com.oracle.svm.core.c.InvokeJavaFunctionPointer; @@ -556,7 +556,7 @@ private void setInitializationStateAndNotify(InitState state) { if (initState == InitState.FullyInitialized) { this.slowPathRequired = false; } - this.initThread = WordFactory.nullPointer(); + this.initThread = Word.nullPointer(); /* Make sure previous stores are all done, notably the initState. */ Unsafe.getUnsafe().storeFence(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/AbstractRuntimeCodeInstaller.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/AbstractRuntimeCodeInstaller.java index edd415eb86ad..694377ba3ceb 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/AbstractRuntimeCodeInstaller.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/AbstractRuntimeCodeInstaller.java @@ -24,12 +24,12 @@ */ package com.oracle.svm.core.code; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.deopt.SubstrateInstalledCode; import com.oracle.svm.core.heap.VMOperationInfos; @@ -39,7 +39,7 @@ public class AbstractRuntimeCodeInstaller { protected Pointer allocateCodeMemory(long size) { - PointerBase result = RuntimeCodeInfoAccess.allocateCodeMemory(WordFactory.unsigned(size)); + PointerBase result = RuntimeCodeInfoAccess.allocateCodeMemory(Word.unsigned(size)); if (result.isNull()) { throw new OutOfMemoryError("Could not allocate memory for runtime-compiled code."); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoAccess.java index c245623372a9..d3eab8589ab2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoAccess.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.code; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.RuntimeAssertionsSupport; @@ -249,7 +249,7 @@ public static long relativeIP(CodeInfo info, CodePointer ip) { } public static CodePointer absoluteIP(CodeInfo info, long relativeIP) { - return (CodePointer) ((UnsignedWord) cast(info).getCodeStart()).add(WordFactory.unsigned(relativeIP)); + return (CodePointer) ((UnsignedWord) cast(info).getCodeStart()).add(Word.unsigned(relativeIP)); } @SuppressWarnings("unchecked") diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoEncoder.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoEncoder.java index 5e5e65a8b008..cc9874230e81 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoEncoder.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoEncoder.java @@ -34,12 +34,12 @@ import java.util.function.IntFunction; import java.util.stream.Stream; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicSet; import org.graalvm.collections.Equivalence; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.CalleeSavedRegisters; import com.oracle.svm.core.ReservedRegisters; @@ -673,7 +673,7 @@ void verifyMethod(SharedMethod method, CompilationResult compilation, int compil CodeInfoAccess.lookupCodeInfo(info, offset + compilationOffset, queryResult, constantAccess); CollectingObjectReferenceVisitor visitor = new CollectingObjectReferenceVisitor(); - CodeReferenceMapDecoder.walkOffsetsFromPointer(WordFactory.zero(), CodeInfoAccess.getStackReferenceMapEncoding(info), queryResult.getReferenceMapIndex(), visitor, null); + CodeReferenceMapDecoder.walkOffsetsFromPointer(Word.zero(), CodeInfoAccess.getStackReferenceMapEncoding(info), queryResult.getReferenceMapIndex(), visitor, null); ReferenceMapEncoder.Input expected = (ReferenceMapEncoder.Input) infopoint.debugInfo.getReferenceMap(); visitor.result.verify(); assert expected.equals(visitor.result) : infopoint; @@ -791,7 +791,7 @@ private void verifyVirtualObject(CompilationResult compilation, VirtualObject ex int expectedLength = 0; for (int i = 0; i < expectedObject.getValues().length; i++) { JavaValue expectedValue = expectedObject.getValues()[i]; - UnsignedWord expectedOffset = WordFactory.unsigned(objectLayout.getArrayElementOffset(kind, expectedLength)); + UnsignedWord expectedOffset = Word.unsigned(objectLayout.getArrayElementOffset(kind, expectedLength)); ValueInfo actualValue = findActualArrayElement(actualObject, expectedOffset); verifyValue(compilation, expectedValue, actualValue, actualFrame, visitedVirtualObjects); @@ -831,7 +831,7 @@ private void verifyVirtualObject(CompilationResult compilation, VirtualObject ex fieldIdx++; } - UnsignedWord expectedOffset = WordFactory.unsigned(expectedField.getLocation()); + UnsignedWord expectedOffset = Word.unsigned(expectedField.getLocation()); ValueInfo actualValue = findActualField(actualObject, expectedOffset); verifyValue(compilation, expectedValue, actualValue, actualFrame, visitedVirtualObjects); } @@ -849,7 +849,7 @@ private ValueInfo findActualField(ValueInfo[] actualObject, UnsignedWord expecte DynamicHub hub = (DynamicHub) constantAccess.asObject(actualObject[0].getValue()); ObjectLayout objectLayout = ConfigurationValues.getObjectLayout(); assert LayoutEncoding.isPureInstance(hub.getLayoutEncoding()) : hub; - return findActualValue(actualObject, expectedOffset, objectLayout, WordFactory.unsigned(objectLayout.getFirstFieldOffset()), 1); + return findActualValue(actualObject, expectedOffset, objectLayout, Word.unsigned(objectLayout.getFirstFieldOffset()), 1); } private static ValueInfo findActualValue(ValueInfo[] actualObject, UnsignedWord expectedOffset, ObjectLayout objectLayout, UnsignedWord startOffset, int startIdx) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoTable.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoTable.java index 74d3043e1ce5..458a250a6bfd 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoTable.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoTable.java @@ -27,11 +27,11 @@ import java.util.Arrays; import java.util.List; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.NonmovableArray; @@ -91,12 +91,12 @@ public static RuntimeCodeCache getRuntimeCodeCache() { public static void prepareImageCodeInfo() { // Stored in this class because ImageCodeInfo is immutable imageCodeInfo = getImageCodeCache().prepareCodeInfo(); - assert imageCodeInfo.notEqual(WordFactory.zero()); + assert imageCodeInfo.notEqual(Word.zero()); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static CodeInfo getFirstImageCodeInfo() { - assert imageCodeInfo.notEqual(WordFactory.zero()) : "uninitialized"; + assert imageCodeInfo.notEqual(Word.zero()) : "uninitialized"; return imageCodeInfo; } @@ -289,7 +289,7 @@ private static class InvalidateInstalledCodeOperation extends JavaVMOperation { @Override protected void operate() { counters().invalidateInstalledCodeCount.inc(); - CodePointer codePointer = WordFactory.pointer(installedCode.getAddress()); + CodePointer codePointer = Word.pointer(installedCode.getAddress()); invalidateInstalledCodeAtSafepoint(installedCode, codePointer); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/FrameInfoQueryResult.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/FrameInfoQueryResult.java index 76e808c3ea1c..bdaa3e862dc8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/FrameInfoQueryResult.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/FrameInfoQueryResult.java @@ -26,8 +26,8 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.function.CodePointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.CalleeSavedRegisters; import com.oracle.svm.core.ReservedRegisters; @@ -191,7 +191,7 @@ public void init() { caller = null; deoptMethod = null; deoptMethodOffset = 0; - deoptMethodImageCodeInfo = SubstrateUtil.HOSTED ? null : WordFactory.nullPointer(); + deoptMethodImageCodeInfo = SubstrateUtil.HOSTED ? null : Word.nullPointer(); isDeoptEntry = false; numLocals = 0; numStack = 0; @@ -250,7 +250,7 @@ public CodeInfo getDeoptMethodImageCodeInfo() { */ public CodePointer getDeoptMethodAddress() { if (deoptMethodOffset == 0) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } return CodeInfoAccess.absoluteIP(getDeoptMethodImageCodeInfo(), deoptMethodOffset); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/ImageCodeInfo.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/ImageCodeInfo.java index 5a17e7d380fe..e109288fd855 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/ImageCodeInfo.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/ImageCodeInfo.java @@ -32,7 +32,6 @@ import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.ComparableWord; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.BuildPhaseProvider.AfterCompilation; import com.oracle.svm.core.Uninterruptible; @@ -92,7 +91,7 @@ CodeInfo prepareCodeInfo() { for (int i = 0; i < size; i++) { ImageCodeInfo imageCodeInfo = imageCodeInfos[i]; CodeInfoImpl codeInfoImpl = runtimeCodeInfos[i].getData(); - CodeInfoImpl nextCodeInfoImpl = i + 1 < size ? runtimeCodeInfos[i + 1].getData() : WordFactory.nullPointer(); + CodeInfoImpl nextCodeInfoImpl = i + 1 < size ? runtimeCodeInfos[i + 1].getData() : Word.nullPointer(); ImageCodeInfo.prepareCodeInfo0(imageCodeInfo, codeInfoImpl, nextCodeInfoImpl); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/ImageCodeInfoStorage.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/ImageCodeInfoStorage.java index 0a6ed999db51..0171b43fa9d0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/ImageCodeInfoStorage.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/ImageCodeInfoStorage.java @@ -30,7 +30,6 @@ import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CIsolateData; @@ -71,7 +70,7 @@ static CodeInfoImpl get() { @Fold protected static UnsignedWord offset() { - return WordFactory.unsigned(calculateOffset()); + return Word.unsigned(calculateOffset()); } static int calculateOffset() { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/InstalledCodeObserverSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/InstalledCodeObserverSupport.java index 5ebe24d74189..8a3b92ec2b51 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/InstalledCodeObserverSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/InstalledCodeObserverSupport.java @@ -27,10 +27,10 @@ import java.util.ArrayList; import java.util.List; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.NonmovableArray; @@ -129,7 +129,7 @@ public static void removeObserversOnTearDown(NonmovableArray= 0 : "info must be in table"; NonmovableArrays.arraycopy(codeInfos, idx + 1, codeInfos, idx, numCodeInfos - (idx + 1)); numCodeInfos--; - NonmovableArrays.setWord(codeInfos, numCodeInfos, WordFactory.nullPointer()); + NonmovableArrays.setWord(codeInfos, numCodeInfos, Word.nullPointer()); RuntimeCodeInfoAccess.markAsInvalidated(info); assert verifyTable(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeInfoAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeInfoAccess.java index ae0b7bd24c27..1268cc368d53 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeInfoAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeInfoAccess.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.code; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.SubstrateUtil; @@ -70,11 +70,11 @@ public static void initialize(CodeInfo info, Pointer codeStart, int entryPointOf CodeInfoImpl impl = cast(info); impl.setCodeStart((CodePointer) codeStart); - impl.setCodeEntryPointOffset(WordFactory.unsigned(entryPointOffset)); - impl.setCodeSize(WordFactory.unsigned(codeSize)); - impl.setDataOffset(WordFactory.unsigned(dataOffset)); - impl.setDataSize(WordFactory.unsigned(dataSize)); - impl.setCodeAndDataMemorySize(WordFactory.unsigned(codeAndDataMemorySize)); + impl.setCodeEntryPointOffset(Word.unsigned(entryPointOffset)); + impl.setCodeSize(Word.unsigned(codeSize)); + impl.setDataOffset(Word.unsigned(dataOffset)); + impl.setDataSize(Word.unsigned(dataSize)); + impl.setCodeAndDataMemorySize(Word.unsigned(codeAndDataMemorySize)); impl.setTier(tier); impl.setCodeObserverHandles(observerHandles); impl.setAllObjectsAreInImageHeap(allObjectsAreInImageHeap); @@ -227,12 +227,12 @@ static void markAsInvalidated(CodeInfo info) { } public static CodePointer allocateCodeMemory(UnsignedWord size) { - return (CodePointer) CommittedMemoryProvider.get().allocateExecutableMemory(size, WordFactory.unsigned(SubstrateOptions.codeAlignment())); + return (CodePointer) CommittedMemoryProvider.get().allocateExecutableMemory(size, Word.unsigned(SubstrateOptions.codeAlignment())); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static void releaseCodeMemory(CodePointer codeStart, UnsignedWord codeSize) { - CommittedMemoryProvider.get().freeExecutableMemory(codeStart, codeSize, WordFactory.unsigned(SubstrateOptions.codeAlignment())); + CommittedMemoryProvider.get().freeExecutableMemory(codeStart, codeSize, Word.unsigned(SubstrateOptions.codeAlignment())); } public static void makeCodeMemoryExecutableReadOnly(CodePointer codeStart, UnsignedWord codeSize) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeInfoMemory.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeInfoMemory.java index 629f6383592d..d6227faa5780 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeInfoMemory.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeInfoMemory.java @@ -26,12 +26,12 @@ import java.util.concurrent.locks.ReentrantLock; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.Uninterruptible; @@ -110,11 +110,11 @@ public UnsignedWord totalSize() { } public void clearPeakCodeAndDataCounters() { - peakCodeAndDataMemorySize = WordFactory.zero(); + peakCodeAndDataMemorySize = Word.zero(); } public void clearPeakNativeMetadataCounters() { - peakNativeMetadataSize = WordFactory.zero(); + peakNativeMetadataSize = Word.zero(); } @Uninterruptible(reason = "Manipulate the counters atomically with regard to GC.") @@ -276,7 +276,7 @@ private boolean resize(int newLength) { for (int i = 0; i < oldLength; i++) { UntetheredCodeInfo tag = NonmovableArrays.getWord(oldTable, i); if (tag.isNonNull()) { - NonmovableArrays.setWord(oldTable, i, WordFactory.zero()); + NonmovableArrays.setWord(oldTable, i, Word.zero()); int u = hashIndex(tag, newLength); while (NonmovableArrays.getWord(table, u).isNonNull()) { u = nextIndex(u, newLength); @@ -295,7 +295,7 @@ private boolean remove0(CodeInfo info) { UntetheredCodeInfo entry = NonmovableArrays.getWord(table, index); while (entry.isNonNull()) { if (entry.equal(info)) { - NonmovableArrays.setWord(table, index, WordFactory.zero()); + NonmovableArrays.setWord(table, index, Word.zero()); count--; assert count >= 0 : "invalid counter value"; rehashAfterUnregisterAt(index); @@ -319,7 +319,7 @@ private void rehashAfterUnregisterAt(int index) { // from IdentityHashMap: Knuth int r = hashIndex(info, length); if ((i < r && (r <= d || d <= i)) || (r <= d && d <= i)) { NonmovableArrays.setWord(table, d, info); - NonmovableArrays.setWord(table, i, WordFactory.zero()); + NonmovableArrays.setWord(table, i, Word.zero()); d = i; } i = nextIndex(i, length); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/collections/AbstractUninterruptibleHashtable.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/collections/AbstractUninterruptibleHashtable.java index 13be0d4cc8f5..f056da7f97b6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/collections/AbstractUninterruptibleHashtable.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/collections/AbstractUninterruptibleHashtable.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.collections; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.UnmanagedMemoryUtil; @@ -74,7 +74,7 @@ protected UninterruptibleEntry copyToHeap(UninterruptibleEntry pointerOnStack, U UnmanagedMemoryUtil.copy((Pointer) pointerOnStack, (Pointer) pointerOnHeap, sizeToAlloc); return pointerOnHeap; } - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -94,14 +94,14 @@ protected UninterruptibleEntry insertEntry(UninterruptibleEntry valueOnStack) { size++; return newEntry; } - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public boolean remove(UninterruptibleEntry valueOnStack) { int index = Integer.remainderUnsigned(valueOnStack.getHash(), DEFAULT_TABLE_LENGTH); UninterruptibleEntry entry = table[index]; - UninterruptibleEntry prev = WordFactory.nullPointer(); + UninterruptibleEntry prev = Word.nullPointer(); while (entry.isNonNull()) { if (isEqual(valueOnStack, entry)) { if (prev.isNull()) { @@ -141,7 +141,7 @@ public UninterruptibleEntry get(UninterruptibleEntry valueOnStack) { } entry = entry.getNext(); } - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Override @@ -189,7 +189,7 @@ public void clear() { entry = entry.getNext(); free(tmp); } - table[i] = WordFactory.nullPointer(); + table[i] = Word.nullPointer(); } assert size == 0 : "The table is not empty!"; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/collections/GrowableWordArrayAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/collections/GrowableWordArrayAccess.java index bc54aa4ddce2..9f7874f31eb8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/collections/GrowableWordArrayAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/collections/GrowableWordArrayAccess.java @@ -26,7 +26,6 @@ import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.UnmanagedMemoryUtil; import com.oracle.svm.core.config.ConfigurationValues; @@ -42,7 +41,7 @@ public class GrowableWordArrayAccess { public static void initialize(GrowableWordArray array) { array.setSize(0); array.setCapacity(0); - array.setData(WordFactory.nullPointer()); + array.setData(Word.nullPointer()); } public static Word get(GrowableWordArray array, int i) { @@ -63,7 +62,7 @@ public static boolean add(GrowableWordArray array, Word element, NmtCategory nmt public static void freeData(GrowableWordArray array) { if (array.isNonNull()) { NullableNativeMemory.free(array.getData()); - array.setData(WordFactory.nullPointer()); + array.setData(Word.nullPointer()); array.setSize(0); array.setCapacity(0); } @@ -78,12 +77,12 @@ private static boolean grow(GrowableWordArray array, NmtCategory nmtCategory) { assert newCapacity >= INITIAL_CAPACITY; WordPointer oldData = array.getData(); - WordPointer newData = NullableNativeMemory.malloc(WordFactory.unsigned(newCapacity).multiply(wordSize()), nmtCategory); + WordPointer newData = NullableNativeMemory.malloc(Word.unsigned(newCapacity).multiply(wordSize()), nmtCategory); if (newData.isNull()) { return false; } - UnmanagedMemoryUtil.copyForward((Pointer) oldData, (Pointer) newData, WordFactory.unsigned(array.getSize()).multiply(wordSize())); + UnmanagedMemoryUtil.copyForward((Pointer) oldData, (Pointer) newData, Word.unsigned(array.getSize()).multiply(wordSize())); NullableNativeMemory.free(oldData); array.setData(newData); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/Container.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/Container.java index 6f0ca8d2d521..75892227f5e8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/Container.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/Container.java @@ -26,13 +26,13 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; @@ -176,12 +176,12 @@ public long getCachedMemoryLimitInBytes() { } private static class State { - static final UnsignedWord UNINITIALIZED = WordFactory.unsigned(0); - static final UnsignedWord INITIALIZING = WordFactory.unsigned(1); - static final UnsignedWord NOT_CONTAINERIZED = WordFactory.unsigned(2); - static final UnsignedWord CONTAINERIZED = WordFactory.unsigned(3); - static final UnsignedWord ERROR_LIBCONTAINER_TOO_OLD = WordFactory.unsigned(4); - static final UnsignedWord ERROR_LIBCONTAINER_TOO_NEW = WordFactory.unsigned(5); - static final UnsignedWord ERROR_UNKNOWN = WordFactory.unsigned(6); + static final UnsignedWord UNINITIALIZED = Word.unsigned(0); + static final UnsignedWord INITIALIZING = Word.unsigned(1); + static final UnsignedWord NOT_CONTAINERIZED = Word.unsigned(2); + static final UnsignedWord CONTAINERIZED = Word.unsigned(3); + static final UnsignedWord ERROR_LIBCONTAINER_TOO_OLD = Word.unsigned(4); + static final UnsignedWord ERROR_LIBCONTAINER_TOO_NEW = Word.unsigned(5); + static final UnsignedWord ERROR_UNKNOWN = Word.unsigned(6); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/DeoptState.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/DeoptState.java index e5d7465c64d5..3c78353adb54 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/DeoptState.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/DeoptState.java @@ -44,7 +44,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import java.lang.reflect.Array; @@ -96,7 +95,7 @@ protected JavaConstant readValue(FrameInfoQueryResult.ValueInfo valueInfo, Frame return valueInfo.getValue(); case StackSlot: case Register: - return readConstant(sourceSp, WordFactory.signed(valueInfo.getData()), valueInfo.getKind(), valueInfo.isCompressedReference(), sourceFrame); + return readConstant(sourceSp, Word.signed(valueInfo.getData()), valueInfo.getKind(), valueInfo.isCompressedReference(), sourceFrame); case ReservedRegister: if (ReservedRegisters.singleton().getThreadRegister() != null && ReservedRegisters.singleton().getThreadRegister().number == valueInfo.getData()) { return JavaConstant.forIntegerKind(ConfigurationValues.getWordKind(), targetThread.rawValue()); @@ -158,7 +157,7 @@ private Object materializeObject(int virtualObjectId, FrameInfoQueryResult sourc } catch (InstantiationException ex) { throw fatalDeoptimizationError("Instantiation exception: " + ex, sourceFrame); } - curOffset = WordFactory.unsigned(objectLayout.getFirstFieldOffset()); + curOffset = Word.unsigned(objectLayout.getFirstFieldOffset()); curIdx = 1; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/DeoptimizedFrame.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/DeoptimizedFrame.java index 9112fd7180d8..308e5c64078c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/DeoptimizedFrame.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/DeoptimizedFrame.java @@ -26,10 +26,10 @@ import java.lang.ref.WeakReference; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.PinnedObject; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.Uninterruptible; @@ -247,7 +247,7 @@ protected SavedBasePointer(int offset, long valueRelativeToNewSp) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) protected void write(Deoptimizer.TargetContent targetContent, Pointer newSp) { - targetContent.writeWord(offset, newSp.add(WordFactory.unsigned(valueRelativeToNewSp))); + targetContent.writeWord(offset, newSp.add(Word.unsigned(valueRelativeToNewSp))); } } @@ -410,7 +410,7 @@ public void takeException() { return; } ReturnAddress firstAddressEntry = topFrame.returnAddress; - CodePointer ip = WordFactory.pointer(firstAddressEntry.returnAddress); + CodePointer ip = Word.pointer(firstAddressEntry.returnAddress); CodeInfo info = CodeInfoTable.getImageCodeInfo(ip); SimpleCodeInfoQueryResult codeInfoQueryResult = UnsafeStackValue.get(SimpleCodeInfoQueryResult.class); CodeInfoAccess.lookupCodeInfo(info, ip, codeInfoQueryResult); @@ -425,7 +425,7 @@ public void takeException() { @RestrictHeapAccess(access = RestrictHeapAccess.Access.UNRESTRICTED, reason = "Printing out error and then crashing.") private static void throwMissingExceptionHandler(CodeInfo info, ReturnAddress firstAddressEntry) { CodeInfoQueryResult detailedQueryResult = new CodeInfoQueryResult(); - CodeInfoAccess.lookupCodeInfo(info, WordFactory.pointer(firstAddressEntry.returnAddress), detailedQueryResult); + CodeInfoAccess.lookupCodeInfo(info, Word.pointer(firstAddressEntry.returnAddress), detailedQueryResult); FrameInfoQueryResult frameInfo = detailedQueryResult.getFrameInfo(); throw Deoptimizer.fatalDeoptimizationError("No exception handler registered for deopt target", frameInfo); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/Deoptimizer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/Deoptimizer.java index 61fbb60c6b82..5399848bdd17 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/Deoptimizer.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/Deoptimizer.java @@ -41,7 +41,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.FrameAccess; import com.oracle.svm.core.Isolates; @@ -305,7 +304,7 @@ private static class DeoptimizeAllOperation extends JavaVMOperation { @Override protected void operate() { - deoptimizeInRange(WordFactory.zero(), WordFactory.zero(), true); + deoptimizeInRange(Word.zero(), Word.zero(), true); } } @@ -597,7 +596,7 @@ public boolean isInterpreterStub() { @DeoptStub(stubType = StubType.EntryStub) @Uninterruptible(reason = "Frame holds Objects in unmanaged storage.") public static UnsignedWord deoptStub(Pointer framePointer, UnsignedWord gpReturnValue, UnsignedWord fpReturnValue) { - assert PointerUtils.isAMultiple(KnownIntrinsics.readStackPointer(), WordFactory.unsigned(ConfigurationValues.getTarget().stackAlignment)); + assert PointerUtils.isAMultiple(KnownIntrinsics.readStackPointer(), Word.unsigned(ConfigurationValues.getTarget().stackAlignment)); VMError.guarantee(VMThreads.StatusSupport.isStatusJava(), "Deopt stub execution must not be visible to other threads."); DeoptimizedFrame frame = (DeoptimizedFrame) ReferenceAccess.singleton().readObjectAt(framePointer, true); @@ -609,7 +608,7 @@ public static UnsignedWord deoptStub(Pointer framePointer, UnsignedWord gpReturn /* Computation of the new stack pointer: we start with the stack pointer of this frame. */ final Pointer newSp = framePointer /* Remove the size of the frame that gets deoptimized. */ - .add(WordFactory.unsigned(frame.getSourceTotalFrameSize())) + .add(Word.unsigned(frame.getSourceTotalFrameSize())) /* Add the size of the deoptimization target frames. */ .subtract(frame.getTargetContent().getSize()); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateObjectCloneSnippets.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateObjectCloneSnippets.java index 31d818c7edf1..b0590e650e42 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateObjectCloneSnippets.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateObjectCloneSnippets.java @@ -30,8 +30,8 @@ import java.util.Map; +import jdk.graal.compiler.word.Word; import org.graalvm.word.LocationIdentity; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.JavaMemoryUtil; import com.oracle.svm.core.c.NonmovableArray; @@ -144,13 +144,13 @@ private static Object doClone(Object original) throws CloneNotSupportedException int primitiveDataSize = objectOffset - curOffset; assert primitiveDataSize >= 0; assert curOffset >= 0; - JavaMemoryUtil.copyForward(original, WordFactory.unsigned(curOffset), result, WordFactory.unsigned(curOffset), WordFactory.unsigned(primitiveDataSize)); + JavaMemoryUtil.copyForward(original, Word.unsigned(curOffset), result, Word.unsigned(curOffset), Word.unsigned(primitiveDataSize)); curOffset += primitiveDataSize; // copy object data assert curOffset >= 0; assert count >= 0; - JavaMemoryUtil.copyReferencesForward(original, WordFactory.unsigned(curOffset), result, WordFactory.unsigned(curOffset), WordFactory.unsigned(count)); + JavaMemoryUtil.copyReferencesForward(original, Word.unsigned(curOffset), result, Word.unsigned(curOffset), Word.unsigned(count)); curOffset += count * referenceSize; } @@ -160,7 +160,7 @@ private static Object doClone(Object original) throws CloneNotSupportedException int primitiveDataSize = endOffset - curOffset; assert primitiveDataSize >= 0; assert curOffset >= 0; - JavaMemoryUtil.copyForward(original, WordFactory.unsigned(curOffset), result, WordFactory.unsigned(curOffset), WordFactory.unsigned(primitiveDataSize)); + JavaMemoryUtil.copyForward(original, Word.unsigned(curOffset), result, Word.unsigned(curOffset), Word.unsigned(primitiveDataSize)); curOffset += primitiveDataSize; assert curOffset == endOffset; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CEntryPointSnippets.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CEntryPointSnippets.java index bbca0438e7f3..204644fef217 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CEntryPointSnippets.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CEntryPointSnippets.java @@ -46,7 +46,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.CPUFeatureAccess; import com.oracle.svm.core.IsolateArgumentParser; @@ -206,7 +205,7 @@ public static void setHeapBase(PointerBase heapBase) { @Snippet(allowMissingProbabilities = true) public static int createIsolateSnippet(CEntryPointCreateIsolateParameters parameters) { - writeCurrentVMThread(WordFactory.nullPointer()); + writeCurrentVMThread(Word.nullPointer()); int result = runtimeCall(CREATE_ISOLATE, parameters); if (result != CEntryPointErrors.NO_ERROR) { return result; @@ -219,9 +218,9 @@ public static int createIsolateSnippet(CEntryPointCreateIsolateParameters parame private static final CGlobalData IMAGE_HEAP_PATCHING_STATE = CGlobalDataFactory.createWord(); private static final class ImageHeapPatchingState { - static final Word UNINITIALIZED = WordFactory.zero(); - static final Word IN_PROGRESS = WordFactory.unsigned(1); - static final Word SUCCESSFUL = WordFactory.unsigned(2); + static final Word UNINITIALIZED = Word.zero(); + static final Word IN_PROGRESS = Word.unsigned(1); + static final Word SUCCESSFUL = Word.unsigned(2); } @Uninterruptible(reason = "Thread state not yet set up.") @@ -282,7 +281,7 @@ private static int createIsolate(CEntryPointCreateIsolateParameters providedPara } UnsignedWord runtimePageSize = VirtualMemoryProvider.get().getGranularity(); - UnsignedWord imagePageSize = WordFactory.unsigned(SubstrateOptions.getPageSize()); + UnsignedWord imagePageSize = Word.unsigned(SubstrateOptions.getPageSize()); boolean validPageSize = UnsignedUtils.isAMultiple(imagePageSize, runtimePageSize); if (!validPageSize) { return CEntryPointErrors.PAGE_SIZE_CHECK_FAILED; @@ -295,7 +294,7 @@ private static int createIsolate(CEntryPointCreateIsolateParameters providedPara CEntryPointCreateIsolateParameters parameters = providedParameters; if (parameters.isNull() || parameters.version() < 1) { parameters = StackValue.get(CEntryPointCreateIsolateParameters.class); - parameters.setReservedSpaceSize(WordFactory.zero()); + parameters.setReservedSpaceSize(Word.zero()); parameters.setVersion(1); } @@ -500,7 +499,7 @@ private static int initializeIsolateInterruptibly1(CEntryPointCreateIsolateParam @Snippet(allowMissingProbabilities = true) public static int attachThreadSnippet(Isolate isolate, boolean startedByIsolate, boolean ensureJavaThread) { - writeCurrentVMThread(WordFactory.nullPointer()); + writeCurrentVMThread(Word.nullPointer()); int error = runtimeCall(ATTACH_THREAD, isolate, startedByIsolate, ensureJavaThread); if (error != CEntryPointErrors.NO_ERROR) { return error; @@ -536,7 +535,7 @@ private static int enterAttachThread0(Isolate isolate, boolean startedByIsolate, return CEntryPointErrors.UNINITIALIZED_ISOLATE; } - IsolateThread thread = WordFactory.nullPointer(); + IsolateThread thread = Word.nullPointer(); if (startedByIsolate) { assert VMThreads.singleton().findIsolateThreadForCurrentOSThread(inCrashHandler).isNull(); } else { @@ -711,7 +710,7 @@ private static boolean initiateTearDownIsolateInterruptibly() { @Snippet(allowMissingProbabilities = true) public static int enterByIsolateSnippet(Isolate isolate) { int result; - writeCurrentVMThread(WordFactory.nullPointer()); + writeCurrentVMThread(Word.nullPointer()); result = runtimeCall(ENTER_BY_ISOLATE, isolate); if (result == CEntryPointErrors.NO_ERROR) { if (VMThreads.StatusSupport.isStatusNativeOrSafepoint()) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/StackOverflowCheckImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/StackOverflowCheckImpl.java index f6fdf58823bc..d11e230c60dc 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/StackOverflowCheckImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/StackOverflowCheckImpl.java @@ -32,13 +32,13 @@ import java.util.Map; import java.util.function.Predicate; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageInfo; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -259,7 +259,7 @@ public void disableStackOverflowChecksForFatalError() { * Setting the boundary to a low value effectively disables the check. We are not using 0 so * that we can distinguish the value set here from an uninitialized value. */ - stackBoundaryTL.set(WordFactory.unsigned(1)); + stackBoundaryTL.set(Word.unsigned(1)); /* * A random marker value. The actual value does not matter, but having a high value also * ensures that any future calls to protectYellowZone() do not modify the stack boundary @@ -293,7 +293,7 @@ private static void updateStackOverflowBoundary(UnsignedWord requestedStackSize) public void updateStackOverflowBoundary() { long threadSize = PlatformThreads.getRequestedStackSize(Thread.currentThread()); if (threadSize != 0) { - updateStackOverflowBoundary(WordFactory.unsigned(threadSize)); + updateStackOverflowBoundary(Word.unsigned(threadSize)); } } @@ -466,7 +466,7 @@ private static void stackOverflowCheckSnippet(@ConstantParameter boolean mustNot * Methods that can deoptimize must have enough space on the stack for all frames after * deoptimization. */ - stackBoundary = stackBoundary.add(WordFactory.unsigned(deoptFrameSize)); + stackBoundary = stackBoundary.add(Word.unsigned(deoptFrameSize)); } if (probability(EXTREMELY_SLOW_PATH_PROBABILITY, KnownIntrinsics.readStackPointer().belowOrEqual(stackBoundary))) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SubstrateAllocationSnippets.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SubstrateAllocationSnippets.java index 22f186a10133..bcdab1271587 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SubstrateAllocationSnippets.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SubstrateAllocationSnippets.java @@ -41,7 +41,6 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.word.LocationIdentity; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.MissingRegistrationUtils; import com.oracle.svm.core.SubstrateOptions; @@ -142,7 +141,7 @@ protected Object allocateInstance(@NonNullParameter DynamicHub hub, @ConstantParameter boolean emitMemoryBarrier, @ConstantParameter AllocationProfilingData profilingData, @ConstantParameter boolean withException) { - Object result = allocateInstanceImpl(encodeAsTLABObjectHeader(hub), WordFactory.unsigned(size), forceSlowPath, fillContents, emitMemoryBarrier, true, profilingData, withException); + Object result = allocateInstanceImpl(encodeAsTLABObjectHeader(hub), Word.unsigned(size), forceSlowPath, fillContents, emitMemoryBarrier, true, profilingData, withException); return piCastToSnippetReplaceeStamp(result); } @@ -404,7 +403,7 @@ public Object formatArray(Word hub, UnsignedWord allocationSize, int length, Wor public Object formatStoredContinuation(Word objectHeader, UnsignedWord allocationSize, int arrayLength, Word memory, boolean emitMemoryBarrier, long ipOffset, AllocationSnippetCounters snippetCounters) { Object result = formatArray(objectHeader, allocationSize, arrayLength, memory, FillContent.DO_NOT_FILL, false, false, false, false, snippetCounters); - memory.writeWord(WordFactory.unsigned(ipOffset), WordFactory.nullPointer(), LocationIdentity.init()); + memory.writeWord(Word.unsigned(ipOffset), Word.nullPointer(), LocationIdentity.init()); emitMemoryBarrierIf(emitMemoryBarrier); return result; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ObjectHandlesImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ObjectHandlesImpl.java index 3f417c3faed2..6c5d6417dd45 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ObjectHandlesImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ObjectHandlesImpl.java @@ -26,11 +26,11 @@ import java.lang.ref.WeakReference; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ObjectHandle; import org.graalvm.nativeimage.ObjectHandles; import org.graalvm.word.SignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import jdk.internal.misc.Unsafe; @@ -73,7 +73,7 @@ private static final class HandleWeakReference extends WeakReference { private volatile long unusedHandleSearchIndex = 0; public ObjectHandlesImpl() { - this(WordFactory.signed(1), WordFactory.signed(Long.MAX_VALUE), WordFactory.signed(0)); + this(Word.signed(1), Word.signed(Long.MAX_VALUE), Word.signed(0)); } public ObjectHandlesImpl(SignedWord rangeMin, SignedWord rangeMax, SignedWord nullHandle) { @@ -106,7 +106,7 @@ private static long toIndex(int bucketIndex, int indexInBucket) { private ObjectHandle toHandle(int bucketIndex, int indexInBucket) { long index = toIndex(bucketIndex, indexInBucket); - return (ObjectHandle) rangeMin.add(WordFactory.signed(index)); + return (ObjectHandle) rangeMin.add(Word.signed(index)); } private long toIndex(WordBase handle) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ThreadLocalHandles.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ThreadLocalHandles.java index e2ad4b56924d..0b5487093923 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ThreadLocalHandles.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ThreadLocalHandles.java @@ -26,9 +26,9 @@ import java.util.Arrays; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ObjectHandle; import org.graalvm.word.SignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.Uninterruptible; @@ -46,7 +46,7 @@ public final class ThreadLocalHandles { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static U nullHandle() { - return WordFactory.signed(0); + return Word.signed(0); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -109,7 +109,7 @@ public T tryCreateNonNull(Object obj) { int index = top; objects[index] = obj; top++; - return WordFactory.signed(index); + return Word.signed(index); } @SuppressWarnings("unchecked") diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/CodeReferenceMapDecoder.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/CodeReferenceMapDecoder.java index 889334001f08..f527aeaae498 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/CodeReferenceMapDecoder.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/CodeReferenceMapDecoder.java @@ -26,10 +26,10 @@ import jdk.graal.compiler.core.common.util.AbstractTypeReader; import jdk.graal.compiler.core.common.util.UnsafeArrayTypeWriter; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.FrameAccess; @@ -58,8 +58,8 @@ public class CodeReferenceMapDecoder { public static boolean walkOffsetsFromPointer(PointerBase baseAddress, NonmovableArray referenceMapEncoding, long referenceMapIndex, ObjectReferenceVisitor visitor, Object holderObject) { assert referenceMapIndex != ReferenceMapIndex.NO_REFERENCE_MAP; assert referenceMapEncoding.isNonNull(); - UnsignedWord uncompressedSize = WordFactory.unsigned(FrameAccess.uncompressedReferenceSize()); - UnsignedWord compressedSize = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getReferenceSize()); + UnsignedWord uncompressedSize = Word.unsigned(FrameAccess.uncompressedReferenceSize()); + UnsignedWord compressedSize = Word.unsigned(ConfigurationValues.getObjectLayout().getReferenceSize()); Pointer objRef = (Pointer) baseAddress; long idx = referenceMapIndex; @@ -115,7 +115,7 @@ public static boolean walkOffsetsFromPointer(PointerBase baseAddress, Nonmovable } firstRun = false; - objRef = objRef.add(WordFactory.unsigned(gap)); + objRef = objRef.add(Word.unsigned(gap)); boolean compressed = (count < 0); UnsignedWord refSize = compressed ? compressedSize : uncompressedSize; count = (count < 0) ? -count : count; @@ -152,9 +152,9 @@ public static boolean walkOffsetsFromPointer(PointerBase baseAddress, Nonmovable Pointer derivedRef; if (refOffset >= 0) { - derivedRef = objRef.add(WordFactory.unsigned(refOffset).multiply(refSize)); + derivedRef = objRef.add(Word.unsigned(refOffset).multiply(refSize)); } else { - derivedRef = objRef.subtract(WordFactory.unsigned(-refOffset).multiply(refSize)); + derivedRef = objRef.subtract(Word.unsigned(-refOffset).multiply(refSize)); } Pointer derivedPtr = baseAddress.isNull() ? derivedRef : derivedRef.readWord(0); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/HeapSizeVerifier.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/HeapSizeVerifier.java index 4276135a519b..92b3972fb19f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/HeapSizeVerifier.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/HeapSizeVerifier.java @@ -24,8 +24,8 @@ */ package com.oracle.svm.core.heap; +import jdk.graal.compiler.word.Word; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateGCOptions; import com.oracle.svm.core.SubstrateUtil; @@ -55,33 +55,33 @@ public static void verifyHeapOptions() { } private static void verifyReservedAddressSpaceSize() { - UnsignedWord reservedAddressSpaceSize = WordFactory.unsigned(SubstrateGCOptions.ReservedAddressSpaceSize.getValue()); + UnsignedWord reservedAddressSpaceSize = Word.unsigned(SubstrateGCOptions.ReservedAddressSpaceSize.getValue()); verifyAgainstMaxAddressSpaceSize(reservedAddressSpaceSize, "value of the option '" + SubstrateGCOptions.ReservedAddressSpaceSize.getName() + "'"); } private static void verifyMaxHeapSize() { - UnsignedWord maxHeapSize = WordFactory.unsigned(SubstrateGCOptions.MaxHeapSize.getValue()); + UnsignedWord maxHeapSize = Word.unsigned(SubstrateGCOptions.MaxHeapSize.getValue()); verifyMaxHeapSizeAgainstMaxAddressSpaceSize(maxHeapSize); verifyAgainstReservedAddressSpaceSize(maxHeapSize, MAX_HEAP_SIZE_NAME); } private static void verifyMinHeapSize() { - UnsignedWord minHeapSize = WordFactory.unsigned(SubstrateGCOptions.MinHeapSize.getValue()); + UnsignedWord minHeapSize = Word.unsigned(SubstrateGCOptions.MinHeapSize.getValue()); verifyMinHeapSizeAgainstMaxAddressSpaceSize(minHeapSize); verifyAgainstReservedAddressSpaceSize(minHeapSize, MIN_HEAP_SIZE_NAME); - UnsignedWord maxHeapSize = WordFactory.unsigned(SubstrateGCOptions.MaxHeapSize.getValue()); + UnsignedWord maxHeapSize = Word.unsigned(SubstrateGCOptions.MaxHeapSize.getValue()); if (maxHeapSize.notEqual(0) && minHeapSize.aboveThan(maxHeapSize)) { throwError(minHeapSize, MIN_HEAP_SIZE_NAME, maxHeapSize, MAX_HEAP_SIZE_NAME); } } private static void verifyMaxNewSize() { - UnsignedWord maxNewSize = WordFactory.unsigned(SubstrateGCOptions.MaxNewSize.getValue()); + UnsignedWord maxNewSize = Word.unsigned(SubstrateGCOptions.MaxNewSize.getValue()); verifyMaxNewSizeAgainstMaxAddressSpaceSize(maxNewSize); verifyAgainstReservedAddressSpaceSize(maxNewSize, MAX_NEW_SIZE_NAME); - UnsignedWord maxHeapSize = WordFactory.unsigned(SubstrateGCOptions.MaxHeapSize.getValue()); + UnsignedWord maxHeapSize = Word.unsigned(SubstrateGCOptions.MaxHeapSize.getValue()); if (maxHeapSize.notEqual(0) && maxNewSize.aboveThan(maxHeapSize)) { throwError(maxNewSize, MAX_NEW_SIZE_NAME, maxHeapSize, MAX_HEAP_SIZE_NAME); } @@ -107,7 +107,7 @@ private static void verifyAgainstMaxAddressSpaceSize(UnsignedWord actualValue, S } private static void verifyAgainstReservedAddressSpaceSize(UnsignedWord actualValue, String actualValueName) { - UnsignedWord reservedAddressSpaceSize = WordFactory.unsigned(SubstrateGCOptions.ReservedAddressSpaceSize.getValue()); + UnsignedWord reservedAddressSpaceSize = Word.unsigned(SubstrateGCOptions.ReservedAddressSpaceSize.getValue()); if (reservedAddressSpaceSize.notEqual(0) && actualValue.aboveThan(reservedAddressSpaceSize)) { throwError(actualValue, actualValueName, reservedAddressSpaceSize, "value of the option '" + SubstrateGCOptions.ReservedAddressSpaceSize.getName() + "'"); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/InstanceReferenceMapDecoder.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/InstanceReferenceMapDecoder.java index 4f90e1dafdbb..c303de2453cb 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/InstanceReferenceMapDecoder.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/InstanceReferenceMapDecoder.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.heap; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -52,7 +52,7 @@ public static boolean walkOffsetsFromPointer(Pointer baseAddress, NonmovableArra boolean compressed = ReferenceAccess.singleton().haveCompressedReferences(); assert entryCount >= 0; - UnsignedWord sizeOfEntries = WordFactory.unsigned(InstanceReferenceMapEncoder.MAP_ENTRY_SIZE).multiply(entryCount); + UnsignedWord sizeOfEntries = Word.unsigned(InstanceReferenceMapEncoder.MAP_ENTRY_SIZE).multiply(entryCount); Pointer end = position.add(sizeOfEntries); while (position.belowThan(end)) { int offset = position.readInt(0); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ObjectHeader.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ObjectHeader.java index d43371ca56c8..b43a91332442 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ObjectHeader.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ObjectHeader.java @@ -28,7 +28,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -83,7 +82,7 @@ public static DynamicHub readDynamicHubFromObject(Object o) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static Word readHeaderFromPointer(Pointer objectPointer) { if (getReferenceSize() == Integer.BYTES) { - return WordFactory.unsigned(objectPointer.readInt(getHubOffset())); + return Word.unsigned(objectPointer.readInt(getHubOffset())); } else { return objectPointer.readWord(getHubOffset()); } @@ -92,7 +91,7 @@ public static Word readHeaderFromPointer(Pointer objectPointer) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static Word readHeaderFromObject(Object o) { if (getReferenceSize() == Integer.BYTES) { - return WordFactory.unsigned(ObjectAccess.readInt(o, getHubOffset())); + return Word.unsigned(ObjectAccess.readInt(o, getHubOffset())); } else { return ObjectAccess.readWord(o, getHubOffset()); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PhysicalMemory.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PhysicalMemory.java index f7181f7e297b..69afe73a2299 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PhysicalMemory.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PhysicalMemory.java @@ -26,10 +26,10 @@ import java.lang.management.ManagementFactory; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.IsolateArgumentParser; import com.oracle.svm.core.SubstrateOptions; @@ -83,7 +83,7 @@ public static void initialize() { assert !isInitialized() : "Physical memory already initialized."; long memoryLimit = IsolateArgumentParser.singleton().getLongOptionValue(IsolateArgumentParser.getOptionIndex(SubstrateOptions.ConcealedOptions.MaxRAM)); if (memoryLimit > 0) { - cachedSize = WordFactory.unsigned(memoryLimit); + cachedSize = Word.unsigned(memoryLimit); } else if (Container.singleton().isContainerized()) { cachedSize = Container.singleton().getPhysicalMemory(); } else { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PodReferenceMapDecoder.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PodReferenceMapDecoder.java index 6ba53280ad03..a956b3990a55 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PodReferenceMapDecoder.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PodReferenceMapDecoder.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.heap; +import jdk.graal.compiler.word.Word; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.JavaMemoryUtil; @@ -129,8 +129,8 @@ private static void copyArray(Object original, Object copy, int layoutEncoding, UnsignedWord nrefs; do { mapOffset = mapOffset.subtract(2); - gap = WordFactory.unsigned(Byte.toUnsignedInt(BarrieredAccess.readByte(copy, mapOffset))); - nrefs = WordFactory.unsigned(Byte.toUnsignedInt(BarrieredAccess.readByte(copy, mapOffset.add(1)))); + gap = Word.unsigned(Byte.toUnsignedInt(BarrieredAccess.readByte(copy, mapOffset))); + nrefs = Word.unsigned(Byte.toUnsignedInt(BarrieredAccess.readByte(copy, mapOffset.add(1)))); // Copy references separately with the required barriers JavaMemoryUtil.copyReferencesForward(original, refOffset, copy, refOffset, nrefs); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceAccessImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceAccessImpl.java index d1aec87b66d0..0afb66052c16 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceAccessImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceAccessImpl.java @@ -29,7 +29,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.SubstrateOptions; @@ -62,7 +61,7 @@ public Word readObjectAsUntrackedPointer(Pointer p, boolean compressed) { public Object readObjectAt(Pointer p, boolean compressed) { Word w = (Word) p; if (compressed) { - return ObjectAccess.readObject(WordFactory.nullPointer(), p); + return ObjectAccess.readObject(Word.nullPointer(), p); } else { return w.readObject(0); } @@ -74,7 +73,7 @@ public Object readObjectAt(Pointer p, boolean compressed) { public void writeObjectAt(Pointer p, Object value, boolean compressed) { Word w = (Word) p; if (compressed) { - ObjectAccess.writeObject(WordFactory.nullPointer(), p, value); + ObjectAccess.writeObject(Word.nullPointer(), p, value); } else { // this overload has no uncompression semantics w.writeObject(0, value); @@ -114,10 +113,10 @@ public UnsignedWord getAddressSpaceSize() { int compressionShift = ReferenceAccess.singleton().getCompressEncoding().getShift(); if (compressionShift > 0) { int referenceSize = ConfigurationValues.getObjectLayout().getReferenceSize(); - return WordFactory.unsigned(1L << (referenceSize * Byte.SIZE)).shiftLeft(compressionShift); + return Word.unsigned(1L << (referenceSize * Byte.SIZE)).shiftLeft(compressionShift); } // Assume that 48 bit is the maximum address space that can be used. - return WordFactory.unsigned((1L << 48) - 1); + return Word.unsigned((1L << 48) - 1); } @Fold diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java index 6b032db63b97..6e0a6cccb877 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java @@ -31,7 +31,6 @@ import java.lang.ref.SoftReference; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.SubstrateUtil; @@ -73,7 +72,7 @@ static Reference uncast(Target_java_lang_ref_Reference instance) { /** Barrier-less read of {@link Target_java_lang_ref_Reference#referent} as a pointer. */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static Pointer getReferentPointer(Reference instance) { - return Word.objectToUntrackedPointer(ObjectAccess.readObject(instance, WordFactory.signed(Target_java_lang_ref_Reference.referentFieldOffset))); + return Word.objectToUntrackedPointer(ObjectAccess.readObject(instance, Word.signed(Target_java_lang_ref_Reference.referentFieldOffset))); } @SuppressWarnings("unchecked") @@ -85,7 +84,7 @@ public static T getReferent(Reference instance) { /** Write {@link Target_java_lang_ref_Reference#referent}. */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static void setReferent(Reference instance, Object value) { - BarrieredAccess.writeObject(instance, WordFactory.signed(Target_java_lang_ref_Reference.referentFieldOffset), value); + BarrieredAccess.writeObject(instance, Word.signed(Target_java_lang_ref_Reference.referentFieldOffset), value); } @Uninterruptible(reason = "Must be atomic with regard to garbage collection.") @@ -94,7 +93,7 @@ public static boolean refersTo(Reference instance, Object value) { * Use a read without a barrier to avoid that this code keeps the object alive, see * JDK-8188055. */ - return value == ObjectAccess.readObject(instance, WordFactory.signed(Target_java_lang_ref_Reference.referentFieldOffset)); + return value == ObjectAccess.readObject(instance, Word.signed(Target_java_lang_ref_Reference.referentFieldOffset)); } @Uninterruptible(reason = "Must be atomic with regard to garbage collection.") @@ -114,12 +113,12 @@ public static void clear(Reference instance) { * * This barrier-less write is to resolve JDK-8240696. */ - ObjectAccess.writeObject(instance, WordFactory.signed(Target_java_lang_ref_Reference.referentFieldOffset), null); + ObjectAccess.writeObject(instance, Word.signed(Target_java_lang_ref_Reference.referentFieldOffset), null); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static Pointer getReferentFieldAddress(Reference instance) { - return Word.objectToUntrackedPointer(instance).add(WordFactory.unsigned(Target_java_lang_ref_Reference.referentFieldOffset)); + return Word.objectToUntrackedPointer(instance).add(Word.unsigned(Target_java_lang_ref_Reference.referentFieldOffset)); } public static long getReferentFieldOffset() { @@ -134,7 +133,7 @@ public static Reference getNextDiscovered(Reference instance) { /** Barrier-less read of {@link Target_java_lang_ref_Reference#discovered} as a pointer. */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static Pointer getDiscoveredPointer(Reference instance) { - return Word.objectToUntrackedPointer(ObjectAccess.readObject(instance, WordFactory.signed(Target_java_lang_ref_Reference.discoveredFieldOffset))); + return Word.objectToUntrackedPointer(ObjectAccess.readObject(instance, Word.signed(Target_java_lang_ref_Reference.discoveredFieldOffset))); } public static long getQueueFieldOffset() { @@ -157,7 +156,7 @@ public static boolean isAnyReferenceFieldOffset(long offset) { /** Write {@link Target_java_lang_ref_Reference#discovered}. */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static void setNextDiscovered(Reference instance, Reference newNext) { - BarrieredAccess.writeObject(instance, WordFactory.signed(Target_java_lang_ref_Reference.discoveredFieldOffset), newNext); + BarrieredAccess.writeObject(instance, Word.signed(Target_java_lang_ref_Reference.discoveredFieldOffset), newNext); } public static boolean hasQueue(Reference instance) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/StoredContinuationAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/StoredContinuationAccess.java index 918920816121..701b6fb03e5c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/StoredContinuationAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/StoredContinuationAccess.java @@ -32,7 +32,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -127,7 +126,7 @@ public static int allocateToYield(Target_jdk_internal_vm_Continuation c, Pointer @Uninterruptible(reason = "Prevent modifications to the stack while initializing instance and copying frames.") private static void fillUninterruptibly(StoredContinuation stored, CodePointer ip, Pointer sp, int size) { - UnmanagedMemoryUtil.copyWordsForward(sp, getFramesStart(stored), WordFactory.unsigned(size)); + UnmanagedMemoryUtil.copyWordsForward(sp, getFramesStart(stored), Word.unsigned(size)); setIP(stored, ip); afterFill(stored); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpMetadata.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpMetadata.java index ea703b8072e5..79f73b148ae6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpMetadata.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpMetadata.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.core.heap.dump; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -36,7 +37,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.BuildPhaseProvider.AfterCompilation; import com.oracle.svm.core.c.NonmovableArrays; @@ -141,19 +141,19 @@ public boolean initialize() { * encoded data more efficiently. At first, we allocate some memory for those data * structures so that we can abort right away in case that an allocation fails. */ - UnsignedWord classInfosSize = WordFactory.unsigned(classInfoCount).multiply(SizeOf.get(ClassInfo.class)); + UnsignedWord classInfosSize = Word.unsigned(classInfoCount).multiply(SizeOf.get(ClassInfo.class)); classInfos = NullableNativeMemory.calloc(classInfosSize, NmtCategory.HeapDump); if (classInfos.isNull()) { return false; } - UnsignedWord fieldStartsSize = WordFactory.unsigned(totalFieldCount).multiply(SizeOf.get(FieldInfoPointer.class)); + UnsignedWord fieldStartsSize = Word.unsigned(totalFieldCount).multiply(SizeOf.get(FieldInfoPointer.class)); fieldInfoTable = NullableNativeMemory.calloc(fieldStartsSize, NmtCategory.HeapDump); if (fieldInfoTable.isNull()) { return false; } - UnsignedWord fieldNameTableSize = WordFactory.unsigned(fieldNameCount).multiply(SizeOf.get(FieldNamePointer.class)); + UnsignedWord fieldNameTableSize = Word.unsigned(fieldNameCount).multiply(SizeOf.get(FieldNamePointer.class)); fieldNameTable = NullableNativeMemory.calloc(fieldNameTableSize, NmtCategory.HeapDump); if (fieldNameTable.isNull()) { return false; @@ -217,13 +217,13 @@ public boolean initialize() { */ public void teardown() { NullableNativeMemory.free(classInfos); - classInfos = WordFactory.nullPointer(); + classInfos = Word.nullPointer(); NullableNativeMemory.free(fieldInfoTable); - fieldInfoTable = WordFactory.nullPointer(); + fieldInfoTable = Word.nullPointer(); NullableNativeMemory.free(fieldNameTable); - fieldNameTable = WordFactory.nullPointer(); + fieldNameTable = Word.nullPointer(); } public int getClassInfoCount() { @@ -232,14 +232,14 @@ public int getClassInfoCount() { public ClassInfo getClassInfo(Class clazz) { if (clazz == null) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } return getClassInfo(DynamicHub.fromClass(clazz)); } public ClassInfo getClassInfo(DynamicHub hub) { if (hub == null) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } return getClassInfo(hub.getTypeID()); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpSupportImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpSupportImpl.java index c7dab111abf2..b4f26a9ff46d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpSupportImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpSupportImpl.java @@ -28,6 +28,7 @@ import java.io.IOException; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.StackValue; @@ -36,7 +37,6 @@ import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.UnmanagedMemoryUtil; import com.oracle.svm.core.heap.GCCause; @@ -81,7 +81,7 @@ public void initializeDumpHeapOnOutOfMemoryError() { @Override public void teardownDumpHeapOnOutOfMemoryError() { UntrackedNullableNativeMemory.free(outOfMemoryHeapDumpPath); - outOfMemoryHeapDumpPath = WordFactory.nullPointer(); + outOfMemoryHeapDumpPath = Word.nullPointer(); } @Override @@ -149,7 +149,7 @@ public void dumpHeap(String filename, boolean gcBefore, boolean overwrite) throw private boolean dumpHeap(RawFileDescriptor fd, boolean gcBefore) { int size = SizeOf.get(HeapDumpVMOperationData.class); HeapDumpVMOperationData data = StackValue.get(size); - UnmanagedMemoryUtil.fill((Pointer) data, WordFactory.unsigned(size), (byte) 0); + UnmanagedMemoryUtil.fill((Pointer) data, Word.unsigned(size), (byte) 0); data.setGCBefore(gcBefore); data.setRawFileDescriptor(fd); heapDumpOperation.enqueue(data); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpWriter.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpWriter.java index 680b4d08fae6..196999b34800 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpWriter.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpWriter.java @@ -35,7 +35,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.StaticFieldsSupport; @@ -459,7 +458,7 @@ private void teardown() { assert f.isNull() || error || file().getUnflushedDataSize(f) == 0; file().free(f); - this.f = WordFactory.nullPointer(); + this.f = Word.nullPointer(); this.topLevelRecordBegin = -1; this.subRecordBegin = -1; @@ -562,7 +561,7 @@ private void writeSymbol(String value) { private void writeSymbol(FieldName fieldName) { startTopLevelRecord(HProfTopLevelRecord.UTF8); writeFieldNameId(fieldName); - write((Pointer) FieldNameAccess.getChars(fieldName), WordFactory.unsigned(FieldNameAccess.getLength(fieldName))); + write((Pointer) FieldNameAccess.getChars(fieldName), Word.unsigned(FieldNameAccess.getLength(fieldName))); endTopLevelRecord(); } @@ -774,7 +773,7 @@ private void writeObjects() { writeLargeObjects(largeObjects); } finally { GrowableWordArrayAccess.freeData(largeObjects); - largeObjects = WordFactory.nullPointer(); + largeObjects = Word.nullPointer(); } } @@ -968,8 +967,8 @@ private void writeObjectArray(Object array) { */ private static int calculateMaxArrayLength(Object array, int elementSize, int recordHeaderSize) { int length = ArrayLengthNode.arrayLength(array); - UnsignedWord lengthInBytes = WordFactory.unsigned(length).multiply(elementSize); - UnsignedWord maxBytes = WordFactory.unsigned(MAX_UNSIGNED_INT).subtract(recordHeaderSize); + UnsignedWord lengthInBytes = Word.unsigned(length).multiply(elementSize); + UnsignedWord maxBytes = Word.unsigned(MAX_UNSIGNED_INT).subtract(recordHeaderSize); if (lengthInBytes.belowOrEqual(maxBytes)) { return length; @@ -993,7 +992,7 @@ private void writeWordArray(Object array, int length, int arrayBaseOffset) { private void writeU1ArrayData(Object array, int length, int arrayBaseOffset) { Pointer data = getArrayData(array, arrayBaseOffset); - write(data, WordFactory.unsigned(length)); + write(data, Word.unsigned(length)); } private void writeU2ArrayData(Object array, int length, int arrayBaseOffset) { @@ -1377,10 +1376,10 @@ private UnsignedWord getObjectSize(Object obj) { elementSize = wordSize(); } int length = ArrayLengthNode.arrayLength(obj); - return WordFactory.unsigned(length).multiply(elementSize); + return Word.unsigned(length).multiply(elementSize); } else { ClassInfo classInfo = metadata.getClassInfo(obj.getClass()); - return WordFactory.unsigned(classInfo.getInstanceFieldsDumpSize()); + return Word.unsigned(classInfo.getInstanceFieldsDumpSize()); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/InteriorObjRefWalker.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/InteriorObjRefWalker.java index fcfa569306e8..74a16935b981 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/InteriorObjRefWalker.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/InteriorObjRefWalker.java @@ -27,7 +27,6 @@ import java.util.function.IntConsumer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.NeverInline; @@ -104,7 +103,7 @@ public static boolean walkInstanceReferenceOffsets(DynamicHub objHub, IntConsume NonmovableArray referenceMapEncoding = DynamicHubSupport.forLayer(objHub.getLayerId()).getReferenceMapEncoding(); long referenceMapIndex = objHub.getReferenceMapIndex(); - return InstanceReferenceMapDecoder.walkOffsetsFromPointer(WordFactory.zero(), referenceMapEncoding, referenceMapIndex, new ObjectReferenceVisitor() { + return InstanceReferenceMapDecoder.walkOffsetsFromPointer(Word.zero(), referenceMapEncoding, referenceMapIndex, new ObjectReferenceVisitor() { @Override public boolean visitObjectReference(Pointer objRef, boolean compressed, Object holderObject) { offsetConsumer.accept((int) objRef.rawValue()); @@ -127,7 +126,7 @@ private static boolean walkInstance(Object obj, ObjectReferenceVisitor visitor, @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static boolean walkReferenceInstance(Object obj, ObjectReferenceVisitor visitor, DynamicHub objHub, Pointer objPointer) { long discoveredOffset = ReferenceInternals.getNextDiscoveredFieldOffset(); - Pointer objRef = objPointer.add(WordFactory.unsigned(discoveredOffset)); + Pointer objRef = objPointer.add(Word.unsigned(discoveredOffset)); // The Object reference at the discovered offset needs to be visited separately as it is not // part of the reference map. @@ -167,7 +166,7 @@ private static boolean walkObjectArray(Object obj, ObjectReferenceVisitor visito boolean isCompressed = ReferenceAccess.singleton().haveCompressedReferences(); Pointer pos = objPointer.add(LayoutEncoding.getArrayBaseOffset(objHub.getLayoutEncoding())); - Pointer end = pos.add(WordFactory.unsigned(referenceSize).multiply(length)); + Pointer end = pos.add(Word.unsigned(referenceSize).multiply(length)); while (pos.belowThan(end)) { final boolean visitResult = callVisitor(obj, visitor, isCompressed, pos); if (!visitResult) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/LayoutEncoding.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/LayoutEncoding.java index f86f8ff03593..a39a8b09a2f7 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/LayoutEncoding.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/LayoutEncoding.java @@ -28,7 +28,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; @@ -125,7 +124,7 @@ public static int forPureInstance(ResolvedJavaType type, int size) { guaranteeEncoding(type, false, isHybrid(encoding), "Instance type encoding denotes a hybrid"); guaranteeEncoding(type, false, isObjectArray(encoding) || isArrayLikeWithObjectElements(encoding), "Instance type encoding denotes an object array"); guaranteeEncoding(type, false, isPrimitiveArray(encoding) || isArrayLikeWithPrimitiveElements(encoding), "Instance type encoding denotes a primitive array"); - guaranteeEncoding(type, true, getPureInstanceAllocationSize(encoding).equal(WordFactory.unsigned(size)), "Instance type encoding size matches type size"); + guaranteeEncoding(type, true, getPureInstanceAllocationSize(encoding).equal(Word.unsigned(size)), "Instance type encoding size matches type size"); return encoding; } @@ -159,7 +158,7 @@ private static int forArrayLike(ResolvedJavaType type, boolean isHybrid, boolean guaranteeEncoding(type, !objectElements, isArrayLikeWithPrimitiveElements(encoding), "Encoding denotes an array-like object with primitive elements"); guaranteeEncoding(type, !isHybrid && objectElements, isObjectArray(encoding), "Encoding denotes an object array"); guaranteeEncoding(type, !isHybrid && !objectElements, isPrimitiveArray(encoding), "Encoding denotes a primitive array"); - guaranteeEncoding(type, true, getArrayBaseOffset(encoding).equal(WordFactory.unsigned(arrayBaseOffset)), + guaranteeEncoding(type, true, getArrayBaseOffset(encoding).equal(Word.unsigned(arrayBaseOffset)), "Encoding denotes a base offset of " + arrayBaseOffset + " (actual value: " + getArrayBaseOffset(encoding) + ')'); guaranteeEncoding(type, true, getArrayIndexShift(encoding) == arrayIndexShift, "Encoding denotes an index shift of " + arrayIndexShift + " (actual value: " + getArrayIndexShift(encoding) + ')'); @@ -195,7 +194,7 @@ public static boolean isPureInstance(int encoding) { */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static UnsignedWord getPureInstanceAllocationSize(int encoding) { - return WordFactory.unsigned(encoding); + return Word.unsigned(encoding); } /** @@ -210,7 +209,7 @@ public static UnsignedWord getPureInstanceSize(DynamicHub hub, boolean withOptio int afterIdHashField = hub.getIdentityHashOffset() + Integer.BYTES; if (size.belowThan(afterIdHashField)) { /* Identity hash is at the end of the object and does not fit in a gap. */ - size = WordFactory.unsigned(ol.alignUp(afterIdHashField)); + size = Word.unsigned(ol.alignUp(afterIdHashField)); } } return size; @@ -262,7 +261,7 @@ public static int getArrayBaseOffsetAsInt(int encoding) { // May be inlined because it does not deal in Pointers. @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static UnsignedWord getArrayBaseOffset(int encoding) { - return WordFactory.unsigned(getArrayBaseOffsetAsInt(encoding)); + return Word.unsigned(getArrayBaseOffsetAsInt(encoding)); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -277,7 +276,7 @@ public static int getArrayIndexScale(int encoding) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static UnsignedWord getArrayElementOffset(int encoding, int index) { - return getArrayBaseOffset(encoding).add(WordFactory.unsigned(index).shiftLeft(getArrayIndexShift(encoding))); + return getArrayBaseOffset(encoding).add(Word.unsigned(index).shiftLeft(getArrayIndexShift(encoding))); } /** @@ -297,7 +296,7 @@ public static UnsignedWord getArrayAllocationSize(int encoding, int length) { public static UnsignedWord getArraySize(int encoding, int length, boolean withOptionalIdHashField) { long unalignedSize = getArrayElementOffset(encoding, length).rawValue(); long totalSize = ConfigurationValues.getObjectLayout().computeArrayTotalSize(unalignedSize, withOptionalIdHashField); - return WordFactory.unsigned(totalSize); + return Word.unsigned(totalSize); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/identityhashcode/IdentityHashCodeSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/identityhashcode/IdentityHashCodeSupport.java index b10b4549d05b..1b6ab6077687 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/identityhashcode/IdentityHashCodeSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/identityhashcode/IdentityHashCodeSupport.java @@ -28,7 +28,6 @@ import org.graalvm.word.LocationIdentity; import org.graalvm.word.SignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.config.ConfigurationValues; @@ -90,7 +89,7 @@ public static int generateIdentityHashCode(Object obj) { public static int computeHashCodeFromAddress(Object obj) { Word address = Word.objectToUntrackedPointer(obj); long salt = Heap.getHeap().getIdentityHashSalt(obj); - SignedWord salted = WordFactory.signed(salt).xor(address); + SignedWord salted = Word.signed(salt).xor(address); int hash = mix32(salted.rawValue()) >>> 1; // shift: ensure positive, same as on HotSpot return (hash == 0) ? 1 : hash; // ensure nonzero } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/BacktraceDecoder.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/BacktraceDecoder.java index 35334308443e..d7ecfa995246 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/BacktraceDecoder.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/BacktraceDecoder.java @@ -24,8 +24,8 @@ */ package com.oracle.svm.core.jdk; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.function.CodePointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.code.CodeInfo; @@ -68,7 +68,7 @@ protected final int visitBacktrace(long[] backtrace, int maxFramesProcessed, int backtraceIndex += BacktraceVisitor.entriesPerSourceReference(); } else { /* Entry is a raw code pointer. */ - CodePointer ip = WordFactory.pointer(entry); + CodePointer ip = Word.pointer(entry); /* Arbitrary number of Java frames for a single native frame (inlining). */ framesDecoded = visitCodePointer(ip, framesDecoded, maxFramesProcessed, maxFramesDecodeLimit); backtraceIndex++; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetSubstitutions.java index a144f949a71a..6d72082686a6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetSubstitutions.java @@ -36,13 +36,13 @@ import java.util.List; import java.util.Set; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; import org.graalvm.word.SignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.annotate.Alias; @@ -107,8 +107,8 @@ static boolean get() { return hasSystemProxies; } - static final SignedWord UNINITIALIZED = WordFactory.signed(-2); - static final SignedWord INITIALIZING = WordFactory.signed(-1); + static final SignedWord UNINITIALIZED = Word.signed(-2); + static final SignedWord INITIALIZING = Word.signed(-1); static final CGlobalData initState = CGlobalDataFactory.createWord(UNINITIALIZED); @@ -124,7 +124,7 @@ static boolean ensureInitialized() { } if (initState.get().logicCompareAndSwapWord(0, UNINITIALIZED, INITIALIZING, LocationIdentity.ANY_LOCATION)) { boolean result = Target_sun_net_spi_DefaultProxySelector.init(); - initState.get().writeWord(0, WordFactory.signed(result ? 1 : 0)); + initState.get().writeWord(0, Word.signed(result ? 1 : 0)); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibraries.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibraries.java index 3485354a52e7..0c551ff417d1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibraries.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibraries.java @@ -31,11 +31,11 @@ import java.util.Arrays; import java.util.Collection; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.ProcessProperties; import org.graalvm.nativeimage.impl.ProcessPropertiesSupport; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.SubstrateOptions; @@ -58,7 +58,7 @@ protected static PointerBase findSymbol(Collection readSourceClass(long[] backtrace, int pos) { if (useCompressedReferences()) { - UnsignedWord ref = WordFactory.unsigned(backtrace[pos + 1]).unsignedShiftRight(32); + UnsignedWord ref = Word.unsigned(backtrace[pos + 1]).unsignedShiftRight(32); return (Class) ReferenceAccess.singleton().uncompressReference(ref); } else { - Word sourceClassPtr = WordFactory.pointer(backtrace[pos + 1]); + Word sourceClassPtr = Word.pointer(backtrace[pos + 1]); return sourceClassPtr.toObject(Class.class, true); } } @@ -561,10 +560,10 @@ static Class readSourceClass(long[] backtrace, int pos) { */ static String readSourceMethodName(long[] backtrace, int pos) { if (useCompressedReferences()) { - UnsignedWord ref = WordFactory.unsigned(backtrace[pos + 1]).and(WordFactory.unsigned(0xffffffffL)); + UnsignedWord ref = Word.unsigned(backtrace[pos + 1]).and(Word.unsigned(0xffffffffL)); return (String) ReferenceAccess.singleton().uncompressReference(ref); } else { - Word sourceMethodNamePtr = WordFactory.pointer(backtrace[pos + 2]); + Word sourceMethodNamePtr = Word.pointer(backtrace[pos + 2]); return sourceMethodNamePtr.toObject(String.class, true); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java index 7c27f72265d8..b6dd6faf452d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java @@ -29,9 +29,9 @@ import java.lang.reflect.Method; import java.security.ProtectionDomain; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.impl.UnsafeMemorySupport; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.annotate.Alias; @@ -57,17 +57,17 @@ final class Target_jdk_internal_misc_Unsafe_Core { @Substitute private long allocateMemory0(long bytes) { - return NativeMemory.malloc(WordFactory.unsigned(bytes), NmtCategory.Unsafe).rawValue(); + return NativeMemory.malloc(Word.unsigned(bytes), NmtCategory.Unsafe).rawValue(); } @Substitute private long reallocateMemory0(long address, long bytes) { - return NativeMemory.realloc(WordFactory.unsigned(address), WordFactory.unsigned(bytes), NmtCategory.Unsafe).rawValue(); + return NativeMemory.realloc(Word.unsigned(address), Word.unsigned(bytes), NmtCategory.Unsafe).rawValue(); } @Substitute private void freeMemory0(long address) { - NativeMemory.free(WordFactory.unsigned(address)); + NativeMemory.free(Word.unsigned(address)); } @Substitute @@ -153,7 +153,7 @@ private int getLoadAverage0(double[] loadavg, int nelems) { @Substitute public Object getUncompressedObject(long address) { /* Adapted from `Unsafe_GetUncompressedObject` in `src/hotspot/share/prims/unsafe.cpp`. */ - return ReferenceAccess.singleton().readObjectAt(WordFactory.pointer(address), false); + return ReferenceAccess.singleton().readObjectAt(Word.pointer(address), false); } /* diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_StackWalker.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_StackWalker.java index 061ba02d0ea5..2e87c44fb35b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_StackWalker.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_StackWalker.java @@ -35,13 +35,13 @@ import java.util.stream.StreamSupport; import com.oracle.svm.core.code.FrameSourceInfo; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.nativeimage.impl.InternalPlatform; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.Uninterruptible; @@ -150,7 +150,7 @@ private T walk(Function, ? extends T> function) { /* Walk the stack of the current thread. */ IsolateThread isolateThread = CurrentIsolate.getCurrentThread(); Pointer sp = KnownIntrinsics.readCallerStackPointer(); - Pointer endSP = WordFactory.nullPointer(); + Pointer endSP = Word.nullPointer(); if (ContinuationSupport.isSupported() && (contScope != null || JavaThreads.isCurrentThreadVirtual())) { var scope = (contScope != null) ? contScope : Target_java_lang_VirtualThread.continuationScope(); var top = Target_jdk_internal_vm_Continuation.getCurrentContinuation(scope); @@ -335,7 +335,7 @@ private boolean advancePhysically0() { @Override protected void invalidate() { - walk = WordFactory.nullPointer(); + walk = Word.nullPointer(); continuation = null; stored = null; } @@ -366,7 +366,7 @@ final class StackFrameSpliterator extends AbstractStackFrameSpliterator { @Override protected void invalidate() { - walk = WordFactory.nullPointer(); + walk = Word.nullPointer(); } @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java index efe23adaf3b3..c5d162f7b4d8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java @@ -31,13 +31,13 @@ import java.time.ZoneId; import java.util.TimeZone; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicMap; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.impl.InternalPlatform; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.LibCHelper; import com.oracle.svm.core.OS; @@ -88,7 +88,7 @@ final class Target_java_util_TimeZone { @Substitute private static String getSystemTimeZoneID(String javaHome) { - CCharPointer tzMappingsPtr = WordFactory.nullPointer(); + CCharPointer tzMappingsPtr = Word.nullPointer(); int contentLen = 0; PrimitiveArrayView refContent = null; try { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/UninterruptibleUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/UninterruptibleUtils.java index 84b58afe1060..6ed9536c7a5f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/UninterruptibleUtils.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/UninterruptibleUtils.java @@ -26,11 +26,11 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.Uninterruptible; @@ -225,7 +225,7 @@ public static class AtomicWord { protected final AtomicLong value; /** - * Creates a new AtomicWord with initial value {@link WordFactory#zero}. + * Creates a new AtomicWord with initial value {@link Word#zero}. */ public AtomicWord() { value = new AtomicLong(0L); @@ -238,7 +238,7 @@ public AtomicWord() { */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public final T get() { - return WordFactory.unsigned(value.get()); + return Word.unsigned(value.get()); } /** @@ -259,7 +259,7 @@ public final void set(T newValue) { */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public final T getAndSet(T newValue) { - return WordFactory.unsigned(value.getAndSet(newValue.rawValue())); + return Word.unsigned(value.getAndSet(newValue.rawValue())); } /** @@ -292,7 +292,7 @@ public static class AtomicUnsigned extends AtomicWord { */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public final UnsignedWord getAndAdd(UnsignedWord delta) { - return WordFactory.unsigned(value.getAndAdd(delta.rawValue())); + return Word.unsigned(value.getAndAdd(delta.rawValue())); } /** @@ -303,7 +303,7 @@ public final UnsignedWord getAndAdd(UnsignedWord delta) { */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public final UnsignedWord addAndGet(UnsignedWord delta) { - return WordFactory.unsigned(value.addAndGet(delta.rawValue())); + return Word.unsigned(value.addAndGet(delta.rawValue())); } /** @@ -314,7 +314,7 @@ public final UnsignedWord addAndGet(UnsignedWord delta) { */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public final UnsignedWord getAndSubtract(UnsignedWord delta) { - return WordFactory.unsigned(value.getAndAdd(-delta.rawValue())); + return Word.unsigned(value.getAndAdd(-delta.rawValue())); } /** @@ -325,7 +325,7 @@ public final UnsignedWord getAndSubtract(UnsignedWord delta) { */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public final UnsignedWord subtractAndGet(UnsignedWord delta) { - return WordFactory.unsigned(value.addAndGet(-delta.rawValue())); + return Word.unsigned(value.addAndGet(-delta.rawValue())); } } @@ -346,7 +346,7 @@ public static class AtomicPointer { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public T get() { - return WordFactory.pointer(value); + return Word.pointer(value); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferAccess.java index b7ea2c151401..cc38a316cba5 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferAccess.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.jfr; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.config.ConfigurationValues; @@ -50,7 +50,7 @@ private JfrBufferAccess() { @Fold public static UnsignedWord getHeaderSize() { - return UnsignedUtils.roundUp(SizeOf.unsigned(JfrBuffer.class), WordFactory.unsigned(ConfigurationValues.getTarget().wordSize)); + return UnsignedUtils.roundUp(SizeOf.unsigned(JfrBuffer.class), Word.unsigned(ConfigurationValues.getTarget().wordSize)); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -66,7 +66,7 @@ public static JfrBuffer allocate(UnsignedWord dataSize, JfrBufferType bufferType if (result.isNonNull()) { result.setSize(dataSize); result.setBufferType(bufferType); - result.setNode(WordFactory.nullPointer()); + result.setNode(Word.nullPointer()); result.setFlags(NO_FLAGS); reinitialize(result); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferList.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferList.java index 65c7ed3aeec8..2e53cc8bc1d0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferList.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferList.java @@ -26,9 +26,9 @@ package com.oracle.svm.core.jfr; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.thread.JavaSpinLockUtils; @@ -69,14 +69,14 @@ public void teardown() { JfrBuffer buffer = JfrBufferNodeAccess.getBuffer(node); if (buffer.isNonNull()) { assert JfrBufferAccess.isRetired(buffer); - buffer.setNode(WordFactory.nullPointer()); + buffer.setNode(Word.nullPointer()); } JfrBufferNode next = node.getNext(); JfrBufferNodeAccess.free(node); node = next; } - head = WordFactory.nullPointer(); + head = Word.nullPointer(); } @Uninterruptible(reason = "Locking without transition requires that the whole critical section is uninterruptible.") @@ -96,7 +96,7 @@ public JfrBufferNode addNode(JfrBuffer buffer) { JfrBufferNode node = JfrBufferNodeAccess.allocate(buffer); if (node.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } lockNoTransition(); @@ -145,7 +145,7 @@ public void removeNode(JfrBufferNode node, JfrBufferNode prev) { @Uninterruptible(reason = "Locking without transition requires that the whole critical section is uninterruptible.") private JfrBufferNode findPrev(JfrBufferNode node) { JfrBufferNode cur = head; - JfrBufferNode prev = WordFactory.nullPointer(); + JfrBufferNode prev = Word.nullPointer(); while (cur.isNonNull()) { if (cur == node) { return prev; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferNodeAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferNodeAccess.java index 251bc2646b97..14bfd317c85a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferNodeAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrBufferNodeAccess.java @@ -26,11 +26,11 @@ package com.oracle.svm.core.jfr; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.memory.NullableNativeMemory; @@ -50,8 +50,8 @@ public static JfrBufferNode allocate(JfrBuffer buffer) { JfrBufferNode node = NullableNativeMemory.malloc(SizeOf.unsigned(JfrBufferNode.class), NmtCategory.JFR); if (node.isNonNull()) { node.setBuffer(buffer); - node.setNext(WordFactory.nullPointer()); - node.setLockOwner(WordFactory.nullPointer()); + node.setNext(Word.nullPointer()); + node.setLockOwner(Word.nullPointer()); NativeSpinLockUtils.initialize(ptrToLock(node)); } return node; @@ -90,7 +90,7 @@ public static void lockNoTransition(JfrBufferNode node) { public static void unlock(JfrBufferNode node) { assert node.isNonNull(); assert isLockedByCurrentThread(node); - node.setLockOwner(WordFactory.nullPointer()); + node.setLockOwner(Word.nullPointer()); NativeSpinLockUtils.unlock(ptrToLock(node)); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrChunkFileWriter.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrChunkFileWriter.java index e9234cc443eb..4ec94068c78a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrChunkFileWriter.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrChunkFileWriter.java @@ -30,11 +30,11 @@ import java.nio.charset.StandardCharsets; import com.oracle.svm.core.jfr.oldobject.JfrOldObjectRepository; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.heap.VMOperationInfos; @@ -238,7 +238,7 @@ public void closeFile() { getFileSupport().close(fd); filename = null; - fd = WordFactory.nullPointer(); + fd = Word.nullPointer(); } private void writeFileHeader() { @@ -542,7 +542,7 @@ private void flushStorage(boolean flushpoint) { @Uninterruptible(reason = "Locking without transition requires that the whole critical section is uninterruptible.") private void traverseThreadLocalBuffers(JfrBufferList list, boolean flushpoint) { JfrBufferNode node = list.getHead(); - JfrBufferNode prev = WordFactory.nullPointer(); + JfrBufferNode prev = Word.nullPointer(); while (node.isNonNull()) { JfrBufferNode next = node.getNext(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrGlobalMemory.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrGlobalMemory.java index 3fdcbde0f200..772cd071b090 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrGlobalMemory.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrGlobalMemory.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.jfr; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.UnmanagedMemoryUtil; @@ -96,7 +96,7 @@ private void freeBuffers() { try { JfrBuffer buffer = JfrBufferNodeAccess.getBuffer(node); JfrBufferAccess.free(buffer); - node.setBuffer(WordFactory.nullPointer()); + node.setBuffer(Word.nullPointer()); } finally { JfrBufferNodeAccess.unlock(node); } @@ -169,6 +169,6 @@ private JfrBufferNode tryAcquirePromotionBuffer(UnsignedWord size) { node = node.getNext(); } } - return WordFactory.nullPointer(); + return Word.nullPointer(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrMethodRepository.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrMethodRepository.java index ef8c17ae3c4f..4a7e4d1d1e39 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrMethodRepository.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrMethodRepository.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.jfr; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.StackValue; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.jdk.StackTraceUtils; @@ -153,7 +153,7 @@ void teardown() { table.teardown(); unflushedEntries = 0; JfrBufferAccess.free(buffer); - buffer = WordFactory.nullPointer(); + buffer = Word.nullPointer(); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrNativeEventWriter.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrNativeEventWriter.java index e122fe303635..4d23fe0f96e0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrNativeEventWriter.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrNativeEventWriter.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.jfr; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.UnmanagedMemoryUtil; @@ -234,7 +234,7 @@ public static void putString(JfrNativeEventWriterData data, Pointer utf8Buffer, putByte(data, JfrChunkFileWriter.StringEncoding.UTF8_BYTE_ARRAY.getValue()); putInt(data, numBytes); if (ensureSize(data, numBytes)) { - UnmanagedMemoryUtil.copy(utf8Buffer, data.getCurrentPos(), WordFactory.unsigned(numBytes)); + UnmanagedMemoryUtil.copy(utf8Buffer, data.getCurrentPos(), Word.unsigned(numBytes)); data.setCurrentPos(data.getCurrentPos().add(numBytes)); } } @@ -308,7 +308,7 @@ private static void reset(JfrNativeEventWriterData data) { @Uninterruptible(reason = "Accesses a native JFR buffer.", callerMustBe = true) private static void cancel(JfrNativeEventWriterData data) { - data.setEndPos(WordFactory.nullPointer()); + data.setEndPos(Word.nullPointer()); } @Uninterruptible(reason = "Accesses a native JFR buffer.", callerMustBe = true) @@ -353,7 +353,7 @@ private static JfrBuffer reuseOrReallocateBuffer(JfrBuffer oldBuffer, UnsignedWo JfrBuffer result = JfrBufferAccess.allocate(newSize, oldBuffer.getBufferType()); if (result.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } // Copy all unflushed data (no matter if committed or uncommitted) from the old buffer diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrNativeEventWriterDataAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrNativeEventWriterDataAccess.java index 535365c55efa..a8ea1976fac3 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrNativeEventWriterDataAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrNativeEventWriterDataAccess.java @@ -24,8 +24,8 @@ */ package com.oracle.svm.core.jfr; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; @@ -49,10 +49,10 @@ public static void initialize(JfrNativeEventWriterData data, JfrBuffer buffer) { data.setCurrentPos(buffer.getCommittedPos()); data.setEndPos(JfrBufferAccess.getDataEnd(buffer)); } else { - data.setJfrBuffer(WordFactory.nullPointer()); - data.setStartPos(WordFactory.nullPointer()); - data.setCurrentPos(WordFactory.nullPointer()); - data.setEndPos(WordFactory.nullPointer()); + data.setJfrBuffer(Word.nullPointer()); + data.setStartPos(Word.nullPointer()); + data.setCurrentPos(Word.nullPointer()); + data.setEndPos(Word.nullPointer()); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrStackTraceRepository.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrStackTraceRepository.java index 0b9105bab46b..323b26dc48ad 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrStackTraceRepository.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrStackTraceRepository.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.core.jfr; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -35,7 +36,6 @@ import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.FrameAccess; import com.oracle.svm.core.NeverInline; @@ -211,12 +211,12 @@ private JfrStackTraceTableEntry getOrPutStackTrace0(Pointer start, UnsignedWord /* Hashtable entry allocation failed. */ NullableNativeMemory.free(to); - to = WordFactory.nullPointer(); + to = Word.nullPointer(); } /* Some allocation failed. */ statusPtr.write(JfrStackTraceTableEntryStatus.INSERT_FAILED); - return WordFactory.nullPointer(); + return Word.nullPointer(); } } @@ -326,7 +326,7 @@ protected boolean isEqual(UninterruptibleEntry a, UninterruptibleEntry b) { JfrStackTraceTableEntry entry1 = (JfrStackTraceTableEntry) a; JfrStackTraceTableEntry entry2 = (JfrStackTraceTableEntry) b; /* We explicitly ignore the field 'serialized' because its value can change. */ - return entry1.getSize() == entry2.getSize() && LibC.memcmp(entry1.getRawStackTrace(), entry2.getRawStackTrace(), WordFactory.unsigned(entry1.getSize())) == 0; + return entry1.getSize() == entry2.getSize() && LibC.memcmp(entry1.getRawStackTrace(), entry2.getRawStackTrace(), Word.unsigned(entry1.getSize())) == 0; } @Override @@ -385,7 +385,7 @@ void teardown() { table.teardown(); unflushedEntries = 0; JfrBufferAccess.free(buffer); - buffer = WordFactory.nullPointer(); + buffer = Word.nullPointer(); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrStackWalker.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrStackWalker.java index dea8d03d11c0..ab264cbfd782 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrStackWalker.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrStackWalker.java @@ -27,6 +27,7 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; @@ -34,7 +35,6 @@ import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.FrameAccess; import com.oracle.svm.core.SubstrateOptions; @@ -156,7 +156,7 @@ public static int walkCurrentThread(SamplerSampleWriterData data, CodePointer to } else { /* Both the top frame and its caller are probably Java frames. */ if (isSPAligned(sp)) { - UnsignedWord topFrameSize = WordFactory.unsigned(CodeInfoQueryResult.getTotalFrameSize(topFrameEncodedSize)); + UnsignedWord topFrameSize = Word.unsigned(CodeInfoQueryResult.getTotalFrameSize(topFrameEncodedSize)); if (SubstrateOptions.hasFramePointer() && !hasValidCaller(sp, topFrameSize, topFrameIsEntryPoint, anchor)) { /* * If we have a frame pointer, then the stack pointer can be aligned @@ -372,7 +372,7 @@ private static boolean isCallerSPValid(Pointer currentSP, Pointer callerSP) { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) private static boolean isSPAligned(Pointer sp) { - return PointerUtils.isAMultiple(sp, WordFactory.unsigned(ConfigurationValues.getTarget().stackAlignment)); + return PointerUtils.isAMultiple(sp, Word.unsigned(ConfigurationValues.getTarget().stackAlignment)); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrSymbolRepository.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrSymbolRepository.java index 0bc284648128..57f8e1a9452b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrSymbolRepository.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrSymbolRepository.java @@ -30,7 +30,6 @@ import org.graalvm.nativeimage.c.struct.RawField; import org.graalvm.nativeimage.c.struct.RawStructure; import org.graalvm.nativeimage.c.struct.SizeOf; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.struct.PinnedObjectField; @@ -242,7 +241,7 @@ void teardown() { table.teardown(); unflushedEntries = 0; JfrBufferAccess.free(buffer); - buffer = WordFactory.nullPointer(); + buffer = Word.nullPointer(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrThreadLocal.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrThreadLocal.java index 6ec4ed6d5dc4..d5f58382182d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrThreadLocal.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrThreadLocal.java @@ -26,13 +26,13 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.StackValue; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.JavaMainWrapper; import com.oracle.svm.core.SubstrateUtil; @@ -157,11 +157,11 @@ public void afterThreadExit(IsolateThread isolateThread, Thread javaThread) { public static void stopRecording(IsolateThread isolateThread, boolean freeJavaBuffer) { /* Flush event buffers. From this point onwards, no further JFR events may be emitted. */ JfrBuffer nb = nativeBuffer.get(isolateThread); - nativeBuffer.set(isolateThread, WordFactory.nullPointer()); + nativeBuffer.set(isolateThread, Word.nullPointer()); flushToGlobalMemoryAndFreeBuffer(nb); JfrBuffer jb = javaBuffer.get(isolateThread); - javaBuffer.set(isolateThread, WordFactory.nullPointer()); + javaBuffer.set(isolateThread, Word.nullPointer()); if (freeJavaBuffer) { flushToGlobalMemoryAndFreeBuffer(jb); } else { @@ -170,7 +170,7 @@ public static void stopRecording(IsolateThread isolateThread, boolean freeJavaBu /* Clear the other event-related thread-locals. */ javaEventWriter.set(isolateThread, null); - dataLost.set(isolateThread, WordFactory.unsigned(0)); + dataLost.set(isolateThread, Word.unsigned(0)); /* Clear stacktrace-related thread-locals. */ SamplerStatistics.singleton().addMissedSamples(getMissedSamples(isolateThread)); @@ -181,7 +181,7 @@ public static void stopRecording(IsolateThread isolateThread, boolean freeJavaBu SamplerBuffer buffer = samplerBuffer.get(isolateThread); if (buffer.isNonNull()) { SubstrateJVM.getSamplerBufferPool().pushFullBuffer(buffer); - samplerBuffer.set(isolateThread, WordFactory.nullPointer()); + samplerBuffer.set(isolateThread, Word.nullPointer()); } } @@ -202,8 +202,8 @@ private static void flushToGlobalMemoryAndFreeBuffer(JfrBuffer buffer) { /* Free the buffer but leave the node alive as it may still be needed. */ JfrBufferNodeAccess.lockNoTransition(node); try { - flushToGlobalMemory0(buffer, WordFactory.unsigned(0), 0); - node.setBuffer(WordFactory.nullPointer()); + flushToGlobalMemory0(buffer, Word.unsigned(0), 0); + node.setBuffer(Word.nullPointer()); JfrBufferAccess.free(buffer); } finally { JfrBufferNodeAccess.unlock(node); @@ -220,7 +220,7 @@ private static void flushToGlobalMemoryAndRetireBuffer(JfrBuffer buffer) { JfrBufferNode node = buffer.getNode(); JfrBufferNodeAccess.lockNoTransition(node); try { - flushToGlobalMemory0(buffer, WordFactory.unsigned(0), 0); + flushToGlobalMemory0(buffer, Word.unsigned(0), 0); JfrBufferAccess.setRetired(buffer); } finally { JfrBufferNodeAccess.unlock(node); @@ -302,7 +302,7 @@ public Target_jdk_jfr_internal_event_EventWriter newEventWriter() { @Uninterruptible(reason = "Locking without transition requires that the whole critical section is uninterruptible.") private static JfrBuffer reinstateJavaBuffer(JfrBuffer buffer) { if (buffer.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } JfrBufferNode node = buffer.getNode(); @@ -313,7 +313,7 @@ private static JfrBuffer reinstateJavaBuffer(JfrBuffer buffer) { node = javaBufferList.addNode(buffer); if (node.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } } @@ -331,13 +331,13 @@ public JfrBuffer getJavaBuffer() { if (buffer.isNull()) { buffer = JfrBufferAccess.allocate(threadLocalBufferSize, JfrBufferType.THREAD_LOCAL_JAVA); if (buffer.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } JfrBufferNode node = javaBufferList.addNode(buffer); if (node.isNull()) { JfrBufferAccess.free(buffer); - return WordFactory.nullPointer(); + return Word.nullPointer(); } javaBuffer.set(buffer); } @@ -350,13 +350,13 @@ public JfrBuffer getNativeBuffer() { if (buffer.isNull()) { buffer = JfrBufferAccess.allocate(threadLocalBufferSize, JfrBufferType.THREAD_LOCAL_NATIVE); if (buffer.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } JfrBufferNode node = nativeBufferList.addNode(buffer); if (node.isNull()) { JfrBufferAccess.free(buffer); - return WordFactory.nullPointer(); + return Word.nullPointer(); } nativeBuffer.set(buffer); } @@ -391,7 +391,7 @@ public static JfrBuffer flushToGlobalMemory(JfrBuffer buffer, UnsignedWord uncom JfrBufferNode node = buffer.getNode(); if (node.isNull()) { assert JfrBufferAccess.isRetired(buffer); - return WordFactory.nullPointer(); + return Word.nullPointer(); } JfrBufferNodeAccess.lockNoTransition(node); @@ -411,7 +411,7 @@ private static JfrBuffer flushToGlobalMemory0(JfrBuffer buffer, UnsignedWord unc if (!SubstrateJVM.getGlobalMemory().write(buffer, unflushedSize, false)) { JfrBufferAccess.reinitialize(buffer); writeDataLoss(buffer, unflushedSize); - return WordFactory.nullPointer(); + return Word.nullPointer(); } if (uncommitted.aboveThan(0)) { @@ -424,7 +424,7 @@ private static JfrBuffer flushToGlobalMemory0(JfrBuffer buffer, UnsignedWord unc if (buffer.getSize().aboveOrEqual(uncommitted.add(requested))) { return buffer; } - return WordFactory.nullPointer(); + return Word.nullPointer(); } @Uninterruptible(reason = "Accesses a JFR buffer.") diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrThreadRepository.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrThreadRepository.java index 1f679f17cc7f..62bd2f978384 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrThreadRepository.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrThreadRepository.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.jfr; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.StackValue; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.jdk.UninterruptibleUtils; @@ -307,10 +307,10 @@ void teardown() { unflushedThreadGroupCount = 0; JfrBufferAccess.free(threadBuffer); - threadBuffer = WordFactory.nullPointer(); + threadBuffer = Word.nullPointer(); JfrBufferAccess.free(threadGroupBuffer); - threadGroupBuffer = WordFactory.nullPointer(); + threadGroupBuffer = Word.nullPointer(); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/SubstrateJVM.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/SubstrateJVM.java index ee0f39bd0c44..d29ec2501445 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/SubstrateJVM.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/SubstrateJVM.java @@ -26,12 +26,12 @@ import java.util.List; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.heap.VMOperationInfos; @@ -238,11 +238,11 @@ public boolean createJFR(boolean simulateFailure) { long threadLocalBufferSize = options.threadBufferSize.getValue(); assert threadLocalBufferSize > 0; - threadLocal.initialize(WordFactory.unsigned(threadLocalBufferSize)); + threadLocal.initialize(Word.unsigned(threadLocalBufferSize)); long globalBufferSize = options.globalBufferSize.getValue(); assert globalBufferSize > 0; - globalMemory.initialize(WordFactory.unsigned(globalBufferSize), options.globalBufferCount.getValue()); + globalMemory.initialize(Word.unsigned(globalBufferSize), options.globalBufferCount.getValue()); unlockedChunkWriter.initialize(options.maxChunkSize.getValue()); stackTraceRepo.setStackTraceDepth(NumUtil.safeToInt(options.stackDepth.getValue())); @@ -513,7 +513,7 @@ public boolean flush(Target_jdk_jfr_internal_event_EventWriter writer, int uncom JfrBuffer oldBuffer = threadLocal.getJavaBuffer(); assert oldBuffer.isNonNull() : "Java EventWriter should not be used otherwise"; - JfrBuffer newBuffer = JfrThreadLocal.flushToGlobalMemory(oldBuffer, WordFactory.unsigned(uncommittedSize), requestedSize); + JfrBuffer newBuffer = JfrThreadLocal.flushToGlobalMemory(oldBuffer, Word.unsigned(uncommittedSize), requestedSize); if (newBuffer.isNull()) { /* The flush failed, so mark the EventWriter as invalid for this write attempt. */ JfrEventWriterAccess.update(writer, oldBuffer, 0, false); @@ -552,7 +552,7 @@ public long commit(long nextPosition) { return nextPosition; } - Pointer next = WordFactory.pointer(nextPosition); + Pointer next = Word.pointer(nextPosition); assert next.aboveOrEqual(current.getCommittedPos()) : "invariant"; assert next.belowOrEqual(JfrBufferAccess.getDataEnd(current)) : "invariant"; if (JfrThreadLocal.isNotified()) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObject.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObject.java index 0e1360625fa5..65453fc6976b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObject.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObject.java @@ -30,8 +30,8 @@ import java.lang.ref.WeakReference; +import jdk.graal.compiler.word.Word; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.collections.UninterruptibleComparable; @@ -75,12 +75,12 @@ void initialize(Object obj, UnsignedWord span, UnsignedWord allocatedSize, long @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) void reset() { ReferenceInternals.setReferent(reference, null); - this.span = WordFactory.zero(); - this.objectSize = WordFactory.zero(); + this.span = Word.zero(); + this.objectSize = Word.zero(); this.allocationTicks = 0L; this.threadId = 0L; this.stackTraceId = 0L; - this.heapUsedAfterLastGC = WordFactory.zero(); + this.heapUsedAfterLastGC = Word.zero(); this.arrayLength = 0; this.next = null; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObjectRepository.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObjectRepository.java index a1856014b9c2..18441411bbe0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObjectRepository.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/oldobject/JfrOldObjectRepository.java @@ -32,7 +32,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.StackValue; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue; @@ -198,7 +197,7 @@ void clear(@SuppressWarnings("unused") boolean flushpoint) { void teardown() { unflushedEntries = 0; JfrBufferAccess.free(buffer); - buffer = WordFactory.nullPointer(); + buffer = Word.nullPointer(); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNIJavaVMList.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNIJavaVMList.java index d9a03a5e3b9f..e909ee86129c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNIJavaVMList.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNIJavaVMList.java @@ -25,9 +25,9 @@ package com.oracle.svm.core.jni; import static org.graalvm.word.LocationIdentity.ANY_LOCATION; -import static jdk.graal.compiler.word.WordFactory.nullPointer; -import static jdk.graal.compiler.word.WordFactory.unsigned; -import static jdk.graal.compiler.word.WordFactory.zero; +import static jdk.graal.compiler.word.Word.nullPointer; +import static jdk.graal.compiler.word.Word.unsigned; +import static jdk.graal.compiler.word.Word.zero; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.CIntPointer; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNILibraryInitializer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNILibraryInitializer.java index ccf1012b8f88..70f683aae88b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNILibraryInitializer.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNILibraryInitializer.java @@ -29,6 +29,7 @@ import java.util.Collection; import java.util.List; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.Equivalence; import org.graalvm.nativeimage.Platform; @@ -36,7 +37,6 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.VoidPointer; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; @@ -115,7 +115,7 @@ public void initialize(PlatformNativeLibrarySupport.NativeLibrary lib) { } if (onLoadFunction.isNonNull()) { JNIOnLoadFunctionPointer onLoad = (JNIOnLoadFunctionPointer) onLoadFunction; - int expected = onLoad.invoke(JNIFunctionTables.singleton().getGlobalJavaVM(), WordFactory.nullPointer()); + int expected = onLoad.invoke(JNIFunctionTables.singleton().getGlobalJavaVM(), Word.nullPointer()); if (!JNIVersion.isSupported(expected, lib.isBuiltin())) { throw new UnsatisfiedLinkError("Unsupported JNI version 0x" + Integer.toHexString(expected) + ", required by " + libName); } @@ -124,6 +124,6 @@ public void initialize(PlatformNativeLibrarySupport.NativeLibrary lib) { private PointerBase getOnLoadSymbolAddress(String libName) { CGlobalData symbol = onLoadCGlobalDataMap.get(libName); - return symbol == null ? WordFactory.nullPointer() : symbol.get(); + return symbol == null ? Word.nullPointer() : symbol.get(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNIObjectHandles.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNIObjectHandles.java index ae2b2ae1155c..91b39f6ec6eb 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNIObjectHandles.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNIObjectHandles.java @@ -29,7 +29,6 @@ import org.graalvm.nativeimage.ObjectHandle; import org.graalvm.word.Pointer; import org.graalvm.word.SignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.RuntimeAssertionsSupport; @@ -294,18 +293,18 @@ static long computeCurrentGlobalHandleCount() { * for example by native code that is unaware of isolates. */ final class JNIGlobalHandles { - static final SignedWord MIN_VALUE = WordFactory.signed(Long.MIN_VALUE); + static final SignedWord MIN_VALUE = Word.signed(Long.MIN_VALUE); static final SignedWord MAX_VALUE = JNIObjectHandles.nullHandle().subtract(1); static { - assert JNIObjectHandles.nullHandle().equal(WordFactory.zero()); + assert JNIObjectHandles.nullHandle().equal(Word.zero()); } private static final int HANDLE_BITS_COUNT = 31; - private static final SignedWord HANDLE_BITS_MASK = WordFactory.signed((1L << HANDLE_BITS_COUNT) - 1); + private static final SignedWord HANDLE_BITS_MASK = Word.signed((1L << HANDLE_BITS_COUNT) - 1); private static final int VALIDATION_BITS_SHIFT = HANDLE_BITS_COUNT; private static final int VALIDATION_BITS_COUNT = 32; - private static final SignedWord VALIDATION_BITS_MASK = WordFactory.signed((1L << VALIDATION_BITS_COUNT) - 1).shiftLeft(VALIDATION_BITS_SHIFT); - private static final SignedWord MSB = WordFactory.signed(1L << 63); + private static final SignedWord VALIDATION_BITS_MASK = Word.signed((1L << VALIDATION_BITS_COUNT) - 1).shiftLeft(VALIDATION_BITS_SHIFT); + private static final SignedWord MSB = Word.signed(1L << 63); private static final ObjectHandlesImpl globalHandles = new ObjectHandlesImpl(JNIObjectHandles.nullHandle().add(1), HANDLE_BITS_MASK, JNIObjectHandles.nullHandle()); @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -315,7 +314,7 @@ static boolean isInRange(JNIObjectHandle handle) { private static Word isolateHash() { int isolateHash = Long.hashCode(CurrentIsolate.getIsolate().rawValue()); - return WordFactory.unsigned(isolateHash); + return Word.unsigned(isolateHash); } private static JNIObjectHandle encode(ObjectHandle handle) { @@ -383,10 +382,10 @@ public static long computeCurrentCount() { */ final class JNIImageHeapHandles { private static final int OBJ_OFFSET_BITS_COUNT = 32; - private static final Word OBJ_OFFSET_BITS_MASK = WordFactory.unsigned((1L << OBJ_OFFSET_BITS_COUNT) - 1); - private static final SignedWord LOCAL_RANGE_MIN = WordFactory.signed(0b01).shiftLeft(OBJ_OFFSET_BITS_COUNT); - private static final SignedWord GLOBAL_RANGE_MIN = WordFactory.signed(0b10).shiftLeft(OBJ_OFFSET_BITS_COUNT); - private static final SignedWord WEAK_GLOBAL_RANGE_MIN = WordFactory.signed(0b11).shiftLeft(OBJ_OFFSET_BITS_COUNT); + private static final Word OBJ_OFFSET_BITS_MASK = Word.unsigned((1L << OBJ_OFFSET_BITS_COUNT) - 1); + private static final SignedWord LOCAL_RANGE_MIN = Word.signed(0b01).shiftLeft(OBJ_OFFSET_BITS_COUNT); + private static final SignedWord GLOBAL_RANGE_MIN = Word.signed(0b10).shiftLeft(OBJ_OFFSET_BITS_COUNT); + private static final SignedWord WEAK_GLOBAL_RANGE_MIN = Word.signed(0b11).shiftLeft(OBJ_OFFSET_BITS_COUNT); private static final SignedWord ENTIRE_RANGE_MIN = LOCAL_RANGE_MIN; private static final SignedWord ENTIRE_RANGE_MAX = WEAK_GLOBAL_RANGE_MIN.add(OBJ_OFFSET_BITS_MASK); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIAccessibleField.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIAccessibleField.java index e7d689c70cfc..f1092f39756d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIAccessibleField.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIAccessibleField.java @@ -26,12 +26,12 @@ import java.lang.reflect.Modifier; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicSet; import org.graalvm.nativeimage.Platform.HOSTED_ONLY; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.BuildPhaseProvider.ReadyForCompilation; import com.oracle.svm.core.StaticFieldsSupport; @@ -46,7 +46,7 @@ */ public final class JNIAccessibleField extends JNIAccessibleMember { /* 10000000...0 */ - private static final UnsignedWord ID_STATIC_FLAG = WordFactory.unsigned(-1L).unsignedShiftRight(1).add(1); + private static final UnsignedWord ID_STATIC_FLAG = Word.unsigned(-1L).unsignedShiftRight(1).add(1); /* 01000000...0 */ private static final UnsignedWord ID_OBJECT_FLAG = ID_STATIC_FLAG.unsignedShiftRight(1); /* 00100000...0 */ @@ -86,13 +86,13 @@ public static WordBase getOffsetFromId(JNIFieldId id) { * */ @UnknownPrimitiveField(availability = ReadyForCompilation.class)// - private UnsignedWord id = WordFactory.zero(); + private UnsignedWord id = Word.zero(); @Platforms(HOSTED_ONLY.class) public JNIAccessibleField(JNIAccessibleClass declaringClass, JavaKind kind, int modifiers) { super(declaringClass); - UnsignedWord bits = Modifier.isStatic(modifiers) ? ID_STATIC_FLAG : WordFactory.zero(); + UnsignedWord bits = Modifier.isStatic(modifiers) ? ID_STATIC_FLAG : Word.zero(); if (kind == null) { bits = bits.or(ID_NEGATIVE_FLAG); } else if (kind.isObject()) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIAccessibleMethod.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIAccessibleMethod.java index 973e8c8c8759..add0b97ac30f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIAccessibleMethod.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIAccessibleMethod.java @@ -26,12 +26,12 @@ import java.lang.reflect.Modifier; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicSet; import org.graalvm.nativeimage.Platform.HOSTED_ONLY; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.BuildPhaseProvider.ReadyForCompilation; @@ -138,7 +138,7 @@ CodePointer getJavaCallAddress(Object instance, boolean nonVirtual) { if (vtableOffset != STATICALLY_BOUND_METHOD) { long tableStartingOffset = LoadOpenTypeWorldDispatchTableStartingOffset.createOpenTypeWorldLoadDispatchTableStartingOffset(instance.getClass(), interfaceTypeID); - return BarrieredAccess.readWord(instance.getClass(), WordFactory.pointer(tableStartingOffset + vtableOffset), NamedLocationIdentity.FINAL_LOCATION); + return BarrieredAccess.readWord(instance.getClass(), Word.pointer(tableStartingOffset + vtableOffset), NamedLocationIdentity.FINAL_LOCATION); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNINativeLinkage.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNINativeLinkage.java index 92717cb9b4a8..91436c06ebdf 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNINativeLinkage.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNINativeLinkage.java @@ -28,9 +28,9 @@ import java.util.function.Function; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.function.CFunctionPointer; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.graal.code.CGlobalDataInfo; import com.oracle.svm.core.jdk.NativeLibrarySupport; @@ -46,7 +46,7 @@ */ public final class JNINativeLinkage { - private PointerBase entryPoint = WordFactory.nullPointer(); + private PointerBase entryPoint = Word.nullPointer(); private final CharSequence declaringClass; private final CharSequence name; @@ -105,7 +105,7 @@ public void setEntryPoint(CFunctionPointer fnptr) { * symbol lookup when the method is called the next time. */ public void unsetEntryPoint() { - entryPoint = WordFactory.nullPointer(); + entryPoint = Word.nullPointer(); } @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIReflectionDictionary.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIReflectionDictionary.java index e0e0f1dea8e7..35d4f96ead00 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIReflectionDictionary.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIReflectionDictionary.java @@ -39,7 +39,6 @@ import org.graalvm.nativeimage.Platform.HOSTED_ONLY; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; @@ -260,7 +259,7 @@ public JNIMethodId getMethodID(Class classObject, CharSequence name, CharSequ private static JNIMethodId toMethodID(JNIAccessibleMethod method) { if (method == null) { - return WordFactory.zero(); + return Word.zero(); } assert Heap.getHeap().isInImageHeap(method); return (JNIMethodId) Word.objectToUntrackedPointer(method).subtract(KnownIntrinsics.heapBase()); @@ -268,7 +267,7 @@ private static JNIMethodId toMethodID(JNIAccessibleMethod method) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static JNIAccessibleMethod getMethodByID(JNIMethodId method) { - if (!SubstrateOptions.SpawnIsolates.getValue() && method == WordFactory.zero()) { + if (!SubstrateOptions.SpawnIsolates.getValue() && method == Word.zero()) { return null; } Pointer p = KnownIntrinsics.heapBase().add((Pointer) method); @@ -305,7 +304,7 @@ private JNIAccessibleField getDeclaredField(Class classObject, CharSequence n public JNIFieldId getDeclaredFieldID(Class classObject, String name, boolean isStatic) { JNIAccessibleField field = getDeclaredField(classObject, name, isStatic, "getDeclaredFieldID"); field = checkField(field, classObject, name); - return (field != null) ? field.getId() : WordFactory.nullPointer(); + return (field != null) ? field.getId() : Word.nullPointer(); } private JNIAccessibleField findField(Class clazz, CharSequence name, boolean isStatic, String dumpLabel) { @@ -336,7 +335,7 @@ private JNIAccessibleField findSuperinterfaceField(Class clazz, CharSequence public JNIFieldId getFieldID(Class clazz, CharSequence name, boolean isStatic) { JNIAccessibleField field = findField(clazz, name, isStatic, "getFieldID"); field = checkField(field, clazz, name); - return (field != null && field.isDiscoverableIn(clazz)) ? field.getId() : WordFactory.nullPointer(); + return (field != null && field.isDiscoverableIn(clazz)) ? field.getId() : Word.nullPointer(); } public String getFieldNameByID(Class classObject, JNIFieldId id) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/functions/JNIFunctions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/functions/JNIFunctions.java index 34f33e1d61a4..3fa74785a3e1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/functions/JNIFunctions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/functions/JNIFunctions.java @@ -34,6 +34,7 @@ import java.nio.ByteBuffer; import java.util.Arrays; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.LogHandler; @@ -53,7 +54,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.JavaMemoryUtil; import com.oracle.svm.core.NeverInline; @@ -557,7 +557,7 @@ static void ReleaseStringChars(JNIEnvironment env, JNIObjectHandle hstr, CShortP static CCharPointer GetStringUTFChars(JNIEnvironment env, JNIObjectHandle hstr, CCharPointer isCopy) { String str = JNIObjectHandles.getObject(hstr); if (str == null) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } if (isCopy.isNonNull()) { isCopy.write((byte) 1); @@ -661,7 +661,7 @@ static final class Target_java_nio_Buffer { @CEntryPointOptions(prologue = JNIEnvEnterPrologue.class, prologueBailout = ReturnNullPointer.class) static WordPointer GetDirectBufferAddress(JNIEnvironment env, JNIObjectHandle handle) { Target_java_nio_Buffer buf = Support.directBufferFromJNIHandle(handle); - return (buf == null) ? WordFactory.nullPointer() : WordFactory.pointer(buf.address); + return (buf == null) ? Word.nullPointer() : Word.pointer(buf.address); } /* @@ -801,7 +801,7 @@ static void SetObjectArrayElement(JNIEnvironment env, JNIObjectHandle harray, in static WordPointer GetPrimitiveArrayCritical(JNIEnvironment env, JNIObjectHandle harray, CCharPointer isCopy) { Object array = JNIObjectHandles.getObject(harray); if (array == null) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } PrimitiveArrayView ref = JNIThreadLocalPrimitiveArrayViews.createArrayView(array); if (isCopy.isNonNull()) { @@ -948,7 +948,7 @@ static int GetJavaVM(JNIEnvironment env, JNIJavaVMPointer vm) { @CEntryPoint(exceptionHandler = JNIExceptionHandlerReturnNullWord.class, include = CEntryPoint.NotIncludedAutomatically.class, publishAs = Publish.NotPublished) @CEntryPointOptions(prologue = JNIEnvEnterPrologue.class, prologueBailout = ReturnNullPointer.class) static JNIFieldId FromReflectedField(JNIEnvironment env, JNIObjectHandle fieldHandle) { - JNIFieldId fieldId = WordFactory.zero(); + JNIFieldId fieldId = Word.zero(); Field obj = JNIObjectHandles.getObject(fieldHandle); if (obj != null) { boolean isStatic = Modifier.isStatic(obj.getModifiers()); @@ -984,7 +984,7 @@ static JNIObjectHandle ToReflectedField(JNIEnvironment env, JNIObjectHandle clas @CEntryPoint(exceptionHandler = JNIExceptionHandlerReturnNullWord.class, include = CEntryPoint.NotIncludedAutomatically.class, publishAs = Publish.NotPublished) @CEntryPointOptions(prologue = JNIEnvEnterPrologue.class, prologueBailout = ReturnNullPointer.class) static JNIMethodId FromReflectedMethod(JNIEnvironment env, JNIObjectHandle methodHandle) { - JNIMethodId methodId = WordFactory.nullPointer(); + JNIMethodId methodId = Word.nullPointer(); Executable method = JNIObjectHandles.getObject(methodHandle); if (method != null) { boolean isStatic = Modifier.isStatic(method.getModifiers()); @@ -1730,7 +1730,7 @@ static class JNIExceptionHandlerReturnNullWord implements CEntryPoint.ExceptionH @Uninterruptible(reason = "exception handler") static WordBase handle(Throwable t) { Support.handleException(t); - return WordFactory.nullPointer(); + return Word.nullPointer(); } } @@ -1875,7 +1875,7 @@ static JNIFieldId getFieldID(JNIObjectHandle hclazz, CCharPointer cname, CCharPo static CShortPointer getNulTerminatedStringCharsAndPin(JNIObjectHandle hstr, CCharPointer isCopy) { String str = JNIObjectHandles.getObject(hstr); if (str == null) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } if (isCopy.isNonNull()) { isCopy.write((byte) 1); @@ -1971,8 +1971,8 @@ static void getPrimitiveArrayRegion(JavaKind elementKind, JNIObjectHandle handle if (count > 0) { long offset = ConfigurationValues.getObjectLayout().getArrayElementOffset(elementKind, start); int elementSize = ConfigurationValues.getObjectLayout().sizeInBytes(elementKind); - UnsignedWord bytes = WordFactory.unsigned(count).multiply(elementSize); - JavaMemoryUtil.copyOnHeap(obj, WordFactory.unsigned(offset), null, WordFactory.unsigned(buffer.rawValue()), bytes); + UnsignedWord bytes = Word.unsigned(count).multiply(elementSize); + JavaMemoryUtil.copyOnHeap(obj, Word.unsigned(offset), null, Word.unsigned(buffer.rawValue()), bytes); } } @@ -1984,8 +1984,8 @@ static void setPrimitiveArrayRegion(JavaKind elementKind, JNIObjectHandle handle if (count > 0) { long offset = ConfigurationValues.getObjectLayout().getArrayElementOffset(elementKind, start); int elementSize = ConfigurationValues.getObjectLayout().sizeInBytes(elementKind); - UnsignedWord bytes = WordFactory.unsigned(count).multiply(elementSize); - JavaMemoryUtil.copyOnHeap(null, WordFactory.unsigned(buffer.rawValue()), obj, WordFactory.unsigned(offset), bytes); + UnsignedWord bytes = Word.unsigned(count).multiply(elementSize); + JavaMemoryUtil.copyOnHeap(null, Word.unsigned(buffer.rawValue()), obj, Word.unsigned(offset), bytes); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/functions/JNIInvocationInterface.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/functions/JNIInvocationInterface.java index 6b504c673c7f..a3b11aa67ded 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/functions/JNIInvocationInterface.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/functions/JNIInvocationInterface.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.core.jni.functions; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.LogHandler; import org.graalvm.nativeimage.StackValue; @@ -37,7 +38,6 @@ import org.graalvm.nativeimage.impl.IsolateSupport; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; @@ -113,8 +113,8 @@ static class JNICreateJavaVMPrologue implements CEntryPointOptions.Prologue { @Uninterruptible(reason = "prologue") static int enter(JNIJavaVMPointer vmBuf, JNIEnvironmentPointer penv, JNIJavaVMInitArgs vmArgs) { boolean hasSpecialVmOptions = false; - CEntryPointCreateIsolateParameters params = WordFactory.nullPointer(); - CCharPointerPointer errorstr = WordFactory.nullPointer(); + CEntryPointCreateIsolateParameters params = Word.nullPointer(); + CCharPointerPointer errorstr = Word.nullPointer(); if (vmArgs.isNonNull()) { int vmArgc = vmArgs.getNOptions(); if (vmArgc > 0) { @@ -127,7 +127,7 @@ static int enter(JNIJavaVMPointer vmBuf, JNIEnvironmentPointer penv, JNIJavaVMIn // The first argument is reserved for the name of the binary. We use null // when we are called via JNI. int argc = 0; - argv.addressOf(argc).write(WordFactory.nullPointer()); + argv.addressOf(argc).write(Word.nullPointer()); argc++; Pointer p = (Pointer) vmArgs.getOptions(); @@ -161,7 +161,7 @@ static int enter(JNIJavaVMPointer vmBuf, JNIEnvironmentPointer penv, JNIJavaVMIn int code = CEntryPointActions.enterCreateIsolate(params); if (params.isNonNull()) { UntrackedNullableNativeMemory.free(params.getArgv()); - params = WordFactory.nullPointer(); + params = Word.nullPointer(); } if (code == CEntryPointErrors.NO_ERROR) { @@ -171,7 +171,7 @@ static int enter(JNIJavaVMPointer vmBuf, JNIEnvironmentPointer penv, JNIJavaVMIn if (errorstr.isNonNull()) { CCharPointer msg = CEntryPointErrors.getDescriptionAsCString(code); - CCharPointer msgCopy = msg.isNonNull() ? LibC.strdup(msg) : WordFactory.nullPointer(); + CCharPointer msgCopy = msg.isNonNull() ? LibC.strdup(msg) : Word.nullPointer(); errorstr.write(msgCopy); } return JNIFunctions.Support.convertCEntryPointErrorToJNIError(code, true); @@ -303,7 +303,7 @@ static int GetEnv(JNIJavaVM vm, WordPointer env, int version) { env.write(JNIThreadLocalEnvironment.getAddress()); return JNIErrors.JNI_OK(); } else { - env.write(WordFactory.nullPointer()); + env.write(Word.nullPointer()); return JNIErrors.JNI_EVERSION(); } } @@ -326,7 +326,7 @@ static int enter(JNIJavaVM vm, WordPointer env) { return JNIErrors.JNI_ERR(); } if (!CEntryPointActions.isCurrentThreadAttachedTo(vm.getFunctions().getIsolate())) { - env.write(WordFactory.nullPointer()); + env.write(Word.nullPointer()); return JNIErrors.JNI_EDETACHED(); } if (CEntryPointActions.enterByIsolate(vm.getFunctions().getIsolate()) != 0) { @@ -385,7 +385,7 @@ static int finishInitialization(JNIJavaVMPointer vmBuf, JNIEnvironmentPointer pe } private static int finishInitialization0(JNIJavaVMPointer vmBuf, JNIEnvironmentPointer penv, JNIJavaVMInitArgs vmArgs, boolean hasSpecialVmOptions) { - WordPointer javaVmIdPointer = WordFactory.nullPointer(); + WordPointer javaVmIdPointer = Word.nullPointer(); if (hasSpecialVmOptions) { javaVmIdPointer = parseVMOptions(vmArgs); } @@ -394,7 +394,7 @@ private static int finishInitialization0(JNIJavaVMPointer vmBuf, JNIEnvironmentP JNIJavaVMList.addJavaVM(javaVm); if (javaVmIdPointer.isNonNull()) { long javaVmId = ImageSingletons.lookup(IsolateSupport.class).getIsolateID(); - javaVmIdPointer.write(WordFactory.pointer(javaVmId)); + javaVmIdPointer.write(Word.pointer(javaVmId)); } RuntimeSupport.getRuntimeSupport().addTearDownHook(new RuntimeSupport.Hook() { @Override @@ -408,7 +408,7 @@ public void execute(boolean isFirstIsolate) { } static WordPointer parseVMOptions(JNIJavaVMInitArgs vmArgs) { - WordPointer javaVmIdPointer = WordFactory.nullPointer(); + WordPointer javaVmIdPointer = Word.nullPointer(); Pointer p = (Pointer) vmArgs.getOptions(); int vmArgc = vmArgs.getNOptions(); for (int i = 0; i < vmArgc; i++) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/CHeapPerfMemoryProvider.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/CHeapPerfMemoryProvider.java index 98f72fbe3219..8f3c42e2f6ab 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/CHeapPerfMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/CHeapPerfMemoryProvider.java @@ -26,8 +26,8 @@ import java.nio.ByteBuffer; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.jdk.DirectByteBufferUtil; import com.oracle.svm.core.memory.NativeMemory; @@ -51,7 +51,7 @@ public ByteBuffer create() { public void teardown() { if (memory.isNonNull()) { NativeMemory.free(memory); - memory = WordFactory.nullPointer(); + memory = Word.nullPointer(); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfManager.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfManager.java index b015991794a8..93795fa4c3cf 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfManager.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfManager.java @@ -34,7 +34,6 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.type.CLongPointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.IsolateArgumentParser; import com.oracle.svm.core.SubstrateOptions; @@ -119,7 +118,7 @@ public CLongPointer getLongPerfEntry(String name) { waitForInitialization(); PerfLong entry = longEntries.get(name); assert Heap.getHeap().isInImageHeap(entry); - return (CLongPointer) Word.objectToUntrackedPointer(entry).add(WordFactory.unsigned(PerfLong.VALUE_OFFSET)); + return (CLongPointer) Word.objectToUntrackedPointer(entry).add(Word.unsigned(PerfLong.VALUE_OFFSET)); } public boolean hasLongPerfEntry(String name) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfMemory.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfMemory.java index a13ea7995921..577f3b5b2b1a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfMemory.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfMemory.java @@ -35,7 +35,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.SubstrateUtil; @@ -112,7 +111,7 @@ private boolean createBuffer() { memoryProvider = m; buffer = b; capacity = b.capacity(); - rawMemory = WordFactory.pointer(SubstrateUtil.cast(b, Target_java_nio_Buffer.class).address); + rawMemory = Word.pointer(SubstrateUtil.cast(b, Target_java_nio_Buffer.class).address); assert verifyRawMemoryAccess(); @@ -193,7 +192,7 @@ public void setAccessible() { public void teardown() { if (buffer != null) { buffer = null; - rawMemory = WordFactory.zero(); + rawMemory = Word.zero(); capacity = 0; used = 0; } @@ -213,13 +212,13 @@ public void teardown() { private static boolean tryAcquirePerfDataFile() { Pointer perfDataIsolatePtr = PERF_DATA_ISOLATE.get(); - return perfDataIsolatePtr.logicCompareAndSwapWord(0, WordFactory.nullPointer(), CurrentIsolate.getIsolate(), LocationIdentity.ANY_LOCATION); + return perfDataIsolatePtr.logicCompareAndSwapWord(0, Word.nullPointer(), CurrentIsolate.getIsolate(), LocationIdentity.ANY_LOCATION); } private static void releasePerfDataFile() { Pointer perfDataIsolatePtr = PERF_DATA_ISOLATE.get(); if (perfDataIsolatePtr.readWord(0) == CurrentIsolate.getIsolate()) { - perfDataIsolatePtr.writeWord(0, WordFactory.nullPointer()); + perfDataIsolatePtr.writeWord(0, Word.nullPointer()); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiAgents.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiAgents.java index 1c3918531332..83ae666058ca 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiAgents.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiAgents.java @@ -29,6 +29,7 @@ import java.io.Serial; import java.util.ArrayList; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -38,7 +39,6 @@ import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.VoidPointer; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.jdk.NativeLibrarySupport; @@ -152,7 +152,7 @@ private static String getAgentFile(String agent, boolean relative) { private static boolean callOnLoadFunction(PointerBase function, String options) { JvmtiOnLoadFunctionPointer onLoad = (JvmtiOnLoadFunctionPointer) function; try (CTypeConversion.CCharPointerHolder holder = CTypeConversion.toCString(options)) { - int result = onLoad.invoke(JNIFunctionTables.singleton().getGlobalJavaVM(), holder.get(), WordFactory.nullPointer()); + int result = onLoad.invoke(JNIFunctionTables.singleton().getGlobalJavaVM(), holder.get(), Word.nullPointer()); /* Any value other than 0 is an error. */ return result == 0; } @@ -160,7 +160,7 @@ private static boolean callOnLoadFunction(PointerBase function, String options) private static void callOnUnLoadFunction(PointerBase function) { JvmtiOnUnLoadFunctionPointer onLoad = (JvmtiOnUnLoadFunctionPointer) function; - onLoad.invoke(JNIFunctionTables.singleton().getGlobalJavaVM(), WordFactory.nullPointer()); + onLoad.invoke(JNIFunctionTables.singleton().getGlobalJavaVM(), Word.nullPointer()); } private static class AgentInitException extends RuntimeException { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvUtil.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvUtil.java index 6aa044aec539..4106dc5b32f0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvUtil.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvUtil.java @@ -27,6 +27,7 @@ import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_NONE; import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_NOT_AVAILABLE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.Isolate; import org.graalvm.nativeimage.Platform; @@ -34,7 +35,6 @@ import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.config.ConfigurationValues; @@ -62,13 +62,13 @@ private JvmtiEnvUtil() { static JvmtiEnv allocate() { JvmtiInterface functionTable = JvmtiFunctionTable.allocateFunctionTable(); if (functionTable.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } - JvmtiEnv env = NullableNativeMemory.calloc(WordFactory.unsigned(internalEnvSize()), NmtCategory.JVMTI); + JvmtiEnv env = NullableNativeMemory.calloc(Word.unsigned(internalEnvSize()), NmtCategory.JVMTI); if (env.isNull()) { JvmtiFunctionTable.freeFunctionTable(functionTable); - return WordFactory.nullPointer(); + return Word.nullPointer(); } env.setIsolate(CurrentIsolate.getIsolate()); @@ -89,7 +89,7 @@ static void dispose(JvmtiEnv env) { static void free(JvmtiEnv env) { JvmtiExternalEnv externalEnv = toExternal(env); JvmtiFunctionTable.freeFunctionTable(externalEnv.getFunctions()); - externalEnv.setFunctions(WordFactory.nullPointer()); + externalEnv.setFunctions(Word.nullPointer()); NullableNativeMemory.free(env); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvs.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvs.java index 9535302bc25b..3a5ef12e88c4 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvs.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvs.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.jvmti; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.jvmti.headers.JvmtiExternalEnv; import com.oracle.svm.core.locks.VMMutex; @@ -62,7 +62,7 @@ public JvmtiEnv getHead() { public JvmtiExternalEnv create() { JvmtiEnv env = JvmtiEnvUtil.allocate(); if (env.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } mutex.lock(); @@ -117,7 +117,7 @@ private void cleanup() { assert hasDisposedEnvs; JvmtiEnv cur = headEnv; - JvmtiEnv prev = WordFactory.nullPointer(); + JvmtiEnv prev = Word.nullPointer(); while (cur.isNonNull()) { if (JvmtiEnvUtil.isDead(cur)) { remove(cur, prev); @@ -153,7 +153,7 @@ public void teardown() { cur = next; } - headEnv = WordFactory.nullPointer(); - tailEnv = WordFactory.nullPointer(); + headEnv = Word.nullPointer(); + tailEnv = Word.nullPointer(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEventCallbacksUtil.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEventCallbacksUtil.java index 9b5c38feb038..cc579c5aeed8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEventCallbacksUtil.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEventCallbacksUtil.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.jvmti; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.UnmanagedMemoryUtil; import com.oracle.svm.core.jdk.UninterruptibleUtils; @@ -42,11 +42,11 @@ private JvmtiEventCallbacksUtil() { public static void setEventCallbacks(JvmtiEventCallbacks envEventCallbacks, JvmtiEventCallbacks newCallbacks, int sizeOfCallbacks) { int internalStructSize = SizeOf.get(JvmtiEventCallbacks.class); - UnmanagedMemoryUtil.fill((Pointer) envEventCallbacks, WordFactory.unsigned(internalStructSize), (byte) 0); + UnmanagedMemoryUtil.fill((Pointer) envEventCallbacks, Word.unsigned(internalStructSize), (byte) 0); if (newCallbacks.isNonNull()) { int bytesToCopy = UninterruptibleUtils.Math.min(internalStructSize, sizeOfCallbacks); - UnmanagedMemoryUtil.copy((Pointer) newCallbacks, (Pointer) envEventCallbacks, WordFactory.unsigned(bytesToCopy)); + UnmanagedMemoryUtil.copy((Pointer) newCallbacks, (Pointer) envEventCallbacks, Word.unsigned(bytesToCopy)); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiFunctions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiFunctions.java index e728b51f94ef..6e0fd4c70286 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiFunctions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiFunctions.java @@ -33,6 +33,7 @@ import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_NULL_POINTER; import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_OUT_OF_MEMORY; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CEntryPoint; @@ -49,7 +50,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.function.CEntryPointActions; @@ -142,14 +142,14 @@ static int Allocate(JvmtiExternalEnv externalEnv, long size, CCharPointerPointer if (memPtr.isNull()) { return JVMTI_ERROR_NULL_POINTER.getCValue(); } else if (size < 0) { - memPtr.write(WordFactory.nullPointer()); + memPtr.write(Word.nullPointer()); return JVMTI_ERROR_ILLEGAL_ARGUMENT.getCValue(); } if (size == 0) { - memPtr.write(WordFactory.nullPointer()); + memPtr.write(Word.nullPointer()); } else { - CCharPointer mem = NullableNativeMemory.malloc(WordFactory.unsigned(size), NmtCategory.JVMTI); + CCharPointer mem = NullableNativeMemory.malloc(Word.unsigned(size), NmtCategory.JVMTI); memPtr.write(mem); if (mem.isNull()) { return JVMTI_ERROR_OUT_OF_MEMORY.getCValue(); @@ -180,7 +180,7 @@ static int GetThreadState(JvmtiExternalEnv externalEnv, JThread thread, CIntPoin @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) static int GetCurrentThread(JvmtiExternalEnv externalEnv, JThreadPointer threadPtr) { - if (threadPtr.equal(WordFactory.nullPointer())) { + if (threadPtr.equal(Word.nullPointer())) { return JVMTI_ERROR_NULL_POINTER.getCValue(); } return JVMTI_ERROR_ACCESS_DENIED.getCValue(); @@ -1345,12 +1345,12 @@ static int GetErrorName(JvmtiExternalEnv externalEnv, JvmtiError jvmtiError, CCh if (namePtr.isNull()) { return JVMTI_ERROR_NULL_POINTER.getCValue(); } else if (jvmtiError == null) { - namePtr.write(WordFactory.nullPointer()); + namePtr.write(Word.nullPointer()); return JVMTI_ERROR_ILLEGAL_ARGUMENT.getCValue(); } String name = jvmtiError.name(); - UnsignedWord bufferSize = WordFactory.unsigned(name.length() + 1); + UnsignedWord bufferSize = Word.unsigned(name.length() + 1); Pointer mem = NullableNativeMemory.malloc(bufferSize, NmtCategory.JVMTI); namePtr.write((CCharPointer) mem); if (mem.isNull()) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMMutex.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMMutex.java index 32c5cd1954c5..903b5f5f3a69 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMMutex.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMMutex.java @@ -24,12 +24,12 @@ */ package com.oracle.svm.core.locks; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CIsolateDataFactory; @@ -51,7 +51,7 @@ * with platform-specific implementations. */ public class VMMutex extends VMLockingPrimitive { - static final UnsignedWord UNSPECIFIED_OWNER = WordFactory.unsigned(-1); + static final UnsignedWord UNSPECIFIED_OWNER = Word.unsigned(-1); private final String name; IsolateThread owner; @@ -176,13 +176,13 @@ public void setOwnerToUnspecified() { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public void clearCurrentThreadOwner() { assert isOwner() : "Only the thread that holds the mutex can clear the owner."; - owner = WordFactory.nullPointer(); + owner = Word.nullPointer(); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public void clearUnspecifiedOwner() { assert hasUnspecifiedOwner(); - owner = WordFactory.nullPointer(); + owner = Word.nullPointer(); } /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/log/RealLog.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/log/RealLog.java index a8e035718f52..819e36de937f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/log/RealLog.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/log/RealLog.java @@ -34,7 +34,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.SubstrateOptions; @@ -120,7 +119,7 @@ public Log string(byte[] value, int offset, int length) { } else if ((offset < 0) || (offset > value.length) || (length < 0) || ((offset + length) > value.length) || ((offset + length) < 0)) { rawString("OUT OF BOUNDS"); } else if (Heap.getHeap().isInImageHeap(value)) { - rawBytes(NonmovableArrays.addressOf(NonmovableArrays.fromImageHeap(value), offset), WordFactory.unsigned(length)); + rawBytes(NonmovableArrays.addressOf(NonmovableArrays.fromImageHeap(value), offset), Word.unsigned(length)); } else { rawBytes(value, offset, length); } @@ -165,7 +164,7 @@ private void rawBytes(Object value, int offset, int length) { } bytes.write(i, b); } - rawBytes(bytes, WordFactory.unsigned(chunkLength)); + rawBytes(bytes, Word.unsigned(chunkLength)); chunkOffset += chunkLength; inputLength -= chunkLength; @@ -181,7 +180,7 @@ private static char charAt(String s, int index) { @NeverInline("Logging is always slow-path code") @RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate when logging.") public Log string(CCharPointer value) { - if (value.notEqual(WordFactory.nullPointer())) { + if (value.notEqual(Word.nullPointer())) { rawBytes(value, SubstrateUtil.strlen(value)); } else { rawString("null"); @@ -195,7 +194,7 @@ public Log string(CCharPointer bytes, int length) { if (length == 0) { return this; } - return rawBytes(bytes, WordFactory.unsigned(length)); + return rawBytes(bytes, Word.unsigned(length)); } @Override @@ -204,7 +203,7 @@ public Log string(CCharPointer bytes, int length) { public Log character(char value) { CCharPointer bytes = UnsafeStackValue.get(CCharPointer.class); bytes.write((byte) value); - rawBytes(bytes, WordFactory.unsigned(1)); + rawBytes(bytes, Word.unsigned(1)); return this; } @@ -284,7 +283,7 @@ private Log number(long value, int radix, boolean signed, int fill, int align) { spaces(spaces); } - rawBytes(bytes.addressOf(charPos), WordFactory.unsigned(length)); + rawBytes(bytes.addressOf(charPos), Word.unsigned(length)); if (align == LEFT_ALIGN) { int spaces = fill - length; @@ -611,7 +610,7 @@ public Log hexdump(PointerBase from, int wordSize, int numWords) { @NeverInline("Logging is always slow-path code") @RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate when logging.") public Log hexdump(PointerBase from, int wordSize, int numWords, int bytesPerLine) { - Pointer base = WordFactory.pointer(from.rawValue()); + Pointer base = Word.pointer(from.rawValue()); int sanitizedWordsize = wordSize > 0 ? Integer.highestOneBit(Math.min(wordSize, 8)) : 2; for (int offset = 0; offset < sanitizedWordsize * numWords; offset += sanitizedWordsize) { if (offset % bytesPerLine == 0) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/NativeMemory.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/NativeMemory.java index 621dd9ce15de..5d5c0422e903 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/NativeMemory.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/NativeMemory.java @@ -27,11 +27,11 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.UnmanagedMemory; import org.graalvm.nativeimage.impl.UnmanagedMemorySupport; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.nmt.NmtCategory; @@ -78,7 +78,7 @@ public static T malloc(UnsignedWord size, NmtCategory ca */ public static T malloc(int size, NmtCategory category) { assert size >= 0; - return malloc(WordFactory.unsigned(size), category); + return malloc(Word.unsigned(size), category); } /** @@ -103,7 +103,7 @@ public static T calloc(UnsignedWord size, NmtCategory ca */ public static T calloc(int size, NmtCategory category) { assert size >= 0; - return calloc(WordFactory.unsigned(size), category); + return calloc(Word.unsigned(size), category); } /** @@ -130,7 +130,7 @@ public static T realloc(T ptr, UnsignedWord size, NmtCat */ public static T realloc(T ptr, int size, NmtCategory category) { assert size >= 0; - return realloc(ptr, WordFactory.unsigned(size), category); + return realloc(ptr, Word.unsigned(size), category); } /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/NullableNativeMemory.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/NullableNativeMemory.java index 33554f9a3a00..759692322cbb 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/NullableNativeMemory.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/NullableNativeMemory.java @@ -27,12 +27,12 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.UnmanagedMemory; import org.graalvm.nativeimage.impl.UnmanagedMemorySupport; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; @@ -77,7 +77,7 @@ public static T malloc(UnsignedWord size, NmtCategory ca @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) public static T malloc(int size, NmtCategory category) { assert size >= 0; - return malloc(WordFactory.unsigned(size), category); + return malloc(Word.unsigned(size), category); } /** @@ -99,7 +99,7 @@ public static T calloc(UnsignedWord size, NmtCategory ca @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) public static T calloc(int size, NmtCategory category) { assert size >= 0; - return calloc(WordFactory.unsigned(size), category); + return calloc(Word.unsigned(size), category); } /** @@ -127,10 +127,10 @@ public static T realloc(T ptr, UnsignedWord size, NmtCat /* Try to realloc. */ T newOuterPointer = UntrackedNullableNativeMemory.realloc(oldOuterPointer, getAllocationSize(size)); if (newOuterPointer.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } - oldOuterPointer = WordFactory.nullPointer(); + oldOuterPointer = Word.nullPointer(); /* Only untrack the old block if the allocation was successful. */ NativeMemoryTracking.singleton().untrack(oldSize, oldCategory); @@ -154,7 +154,7 @@ public static T realloc(T ptr, UnsignedWord size, NmtCat @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) public static T realloc(T ptr, int size, NmtCategory category) { assert size >= 0; - return realloc(ptr, WordFactory.unsigned(size), category); + return realloc(ptr, Word.unsigned(size), category); } /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UnmanagedMemorySupportImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UnmanagedMemorySupportImpl.java index 886ed42fd545..602dfb7f4876 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UnmanagedMemorySupportImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UnmanagedMemorySupportImpl.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.memory; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.impl.UnmanagedMemorySupport; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; @@ -50,14 +50,14 @@ public T malloc(UnsignedWord size) { * Some libc implementations may return a nullptr when the size is 0. We use a minimum size * of 1 to ensure that we always get a unique pointer if the allocation succeeds. */ - UnsignedWord allocationSize = UnsignedUtils.max(size, WordFactory.unsigned(1)); + UnsignedWord allocationSize = UnsignedUtils.max(size, Word.unsigned(1)); return libc().malloc(allocationSize); } @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public T calloc(UnsignedWord size) { - return libc().calloc(WordFactory.unsigned(1), size); + return libc().calloc(Word.unsigned(1), size); } @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UntrackedNullableNativeMemory.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UntrackedNullableNativeMemory.java index 2f11850f9bb2..686c7609908d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UntrackedNullableNativeMemory.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/memory/UntrackedNullableNativeMemory.java @@ -26,11 +26,11 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.impl.UnmanagedMemorySupport; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; @@ -65,7 +65,7 @@ public static T malloc(UnsignedWord size) { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) public static T malloc(int size) { assert size >= 0; - return malloc(WordFactory.unsigned(size)); + return malloc(Word.unsigned(size)); } /** @@ -86,7 +86,7 @@ public static T calloc(UnsignedWord size) { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) public static T calloc(int size) { assert size >= 0; - return calloc(WordFactory.unsigned(size)); + return calloc(Word.unsigned(size)); } /** @@ -111,7 +111,7 @@ public static T realloc(T ptr, UnsignedWord size) { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) public static T realloc(T ptr, int size) { assert size >= 0; - return realloc(ptr, WordFactory.unsigned(size)); + return realloc(ptr, Word.unsigned(size)); } /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/nmt/NativeMemoryTracking.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/nmt/NativeMemoryTracking.java index be9baae74528..2158e99a0090 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/nmt/NativeMemoryTracking.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/nmt/NativeMemoryTracking.java @@ -28,6 +28,7 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -35,7 +36,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.VMInspectionOptions; @@ -61,7 +61,7 @@ * model of virtual memory is maintained. */ public class NativeMemoryTracking { - private static final UnsignedWord ALIGNMENT = WordFactory.unsigned(16); + private static final UnsignedWord ALIGNMENT = Word.unsigned(16); private static final int MAGIC = 0xF0F1F2F3; private static final long KB = 1024; @@ -140,7 +140,7 @@ public void track(PointerBase innerPtr) { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) public PointerBase untrack(PointerBase innerPtr) { if (innerPtr.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } NmtMallocHeader header = getHeader(innerPtr); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractCommittedMemoryProvider.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractCommittedMemoryProvider.java index 357ed06f6f41..1d5e927182d5 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractCommittedMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractCommittedMemoryProvider.java @@ -28,12 +28,12 @@ import static com.oracle.svm.core.Isolates.IMAGE_HEAP_END; import static com.oracle.svm.core.Isolates.IMAGE_HEAP_WRITABLE_BEGIN; import static com.oracle.svm.core.Isolates.IMAGE_HEAP_WRITABLE_END; -import static jdk.graal.compiler.word.WordFactory.nullPointer; +import static jdk.graal.compiler.word.Word.nullPointer; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; @@ -80,7 +80,7 @@ public Pointer allocateExecutableMemory(UnsignedWord nbytes, UnsignedWord alignm @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) protected Pointer allocate(UnsignedWord size, UnsignedWord alignment, boolean executable, NmtCategory nmtCategory) { - Pointer reserved = WordFactory.nullPointer(); + Pointer reserved = Word.nullPointer(); if (!UnsignedUtils.isAMultiple(getGranularity(), alignment)) { reserved = VirtualMemoryProvider.get().reserve(size, alignment, executable); if (reserved.isNull()) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractCopyingImageHeapProvider.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractCopyingImageHeapProvider.java index 82018aeaac49..f81660685d81 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractCopyingImageHeapProvider.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractCopyingImageHeapProvider.java @@ -30,11 +30,11 @@ import static com.oracle.svm.core.Isolates.IMAGE_HEAP_WRITABLE_END; import static com.oracle.svm.core.util.PointerUtils.roundUp; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.function.CEntryPointErrors; @@ -47,10 +47,10 @@ public abstract class AbstractCopyingImageHeapProvider extends AbstractImageHeap @Override @Uninterruptible(reason = "Called during isolate initialization.") public int initialize(Pointer reservedAddressSpace, UnsignedWord reservedSize, WordPointer basePointer, WordPointer endPointer) { - Pointer selfReservedMemory = WordFactory.nullPointer(); + Pointer selfReservedMemory = Word.nullPointer(); UnsignedWord requiredSize = getTotalRequiredAddressSpaceSize(); if (reservedAddressSpace.isNull()) { - UnsignedWord alignment = WordFactory.unsigned(Heap.getHeap().getPreferredAddressSpaceAlignment()); + UnsignedWord alignment = Word.unsigned(Heap.getHeap().getPreferredAddressSpaceAlignment()); selfReservedMemory = VirtualMemoryProvider.get().reserve(requiredSize, alignment, false); if (selfReservedMemory.isNull()) { return CEntryPointErrors.RESERVE_ADDRESS_SPACE_FAILED; @@ -68,7 +68,7 @@ public int initialize(Pointer reservedAddressSpace, UnsignedWord reservedSize, W heapBase = selfReservedHeapBase; } else { heapBase = reservedAddressSpace.add(preHeapRequiredBytes); - selfReservedHeapBase = WordFactory.nullPointer(); + selfReservedHeapBase = Word.nullPointer(); } int error = DynamicMethodAddressResolutionHeapSupport.get().initialize(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractImageHeapProvider.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractImageHeapProvider.java index 0fed67251528..a9aa47620350 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractImageHeapProvider.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractImageHeapProvider.java @@ -31,7 +31,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.code.DynamicMethodAddressResolutionHeapSupport; @@ -56,7 +55,7 @@ public UnsignedWord getImageHeapAddressSpaceSize() { UnsignedWord pageSize = VirtualMemoryProvider.get().getGranularity(); int imageHeapOffset = Heap.getHeap().getImageHeapOffsetInAddressSpace(); assert imageHeapOffset >= 0; - UnsignedWord size = WordFactory.unsigned(imageHeapOffset); + UnsignedWord size = Word.unsigned(imageHeapOffset); size = size.add(getImageHeapSizeInFile()); size = UnsignedUtils.roundUp(size, pageSize); return size; @@ -82,7 +81,7 @@ protected static Pointer getImageHeapBegin(Pointer heapBase) { protected static UnsignedWord getPreHeapAlignedSizeForDynamicMethodAddressResolver() { UnsignedWord requiredPreHeapMemoryInBytes = DynamicMethodAddressResolutionHeapSupport.get().getRequiredPreHeapMemoryInBytes(); /* Ensure there is enough space to properly align the heap */ - UnsignedWord heapAlignment = WordFactory.unsigned(Heap.getHeap().getPreferredAddressSpaceAlignment()); + UnsignedWord heapAlignment = Word.unsigned(Heap.getHeap().getPreferredAddressSpaceAlignment()); return roundUp((PointerBase) requiredPreHeapMemoryInBytes, heapAlignment); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractRawFileOperationSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractRawFileOperationSupport.java index be48238162bc..e3434db566b3 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractRawFileOperationSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/AbstractRawFileOperationSupport.java @@ -32,7 +32,6 @@ import org.graalvm.nativeimage.StackValue; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.hub.DynamicHub; @@ -66,7 +65,7 @@ public boolean write(RawFileDescriptor fd, byte[] data) { DynamicHub hub = KnownIntrinsics.readHub(data); UnsignedWord baseOffset = LayoutEncoding.getArrayBaseOffset(hub.getLayoutEncoding()); Pointer dataPtr = Word.objectToUntrackedPointer(data).add(baseOffset); - return write(fd, dataPtr, WordFactory.unsigned(data.length)); + return write(fd, dataPtr, Word.unsigned(data.length)); } @Override @@ -81,7 +80,7 @@ public boolean writeByte(RawFileDescriptor fd, byte data) { int sizeInBytes = Byte.BYTES; Pointer dataPtr = StackValue.get(sizeInBytes); dataPtr.writeByte(0, data); - return write(fd, dataPtr, WordFactory.unsigned(sizeInBytes)); + return write(fd, dataPtr, Word.unsigned(sizeInBytes)); } @Override @@ -90,7 +89,7 @@ public boolean writeShort(RawFileDescriptor fd, short data) { int sizeInBytes = Short.BYTES; Pointer dataPtr = StackValue.get(sizeInBytes); dataPtr.writeShort(0, useNativeByteOrder ? data : Short.reverseBytes(data)); - return write(fd, dataPtr, WordFactory.unsigned(sizeInBytes)); + return write(fd, dataPtr, Word.unsigned(sizeInBytes)); } @Override @@ -99,7 +98,7 @@ public boolean writeChar(RawFileDescriptor fd, char data) { int sizeInBytes = Character.BYTES; Pointer dataPtr = StackValue.get(sizeInBytes); dataPtr.writeChar(0, useNativeByteOrder ? data : Character.reverseBytes(data)); - return write(fd, dataPtr, WordFactory.unsigned(sizeInBytes)); + return write(fd, dataPtr, Word.unsigned(sizeInBytes)); } @Override @@ -108,7 +107,7 @@ public boolean writeInt(RawFileDescriptor fd, int data) { int sizeInBytes = Integer.BYTES; Pointer dataPtr = StackValue.get(sizeInBytes); dataPtr.writeInt(0, useNativeByteOrder ? data : Integer.reverseBytes(data)); - return write(fd, dataPtr, WordFactory.unsigned(sizeInBytes)); + return write(fd, dataPtr, Word.unsigned(sizeInBytes)); } @Override @@ -117,7 +116,7 @@ public boolean writeLong(RawFileDescriptor fd, long data) { int sizeInBytes = Long.BYTES; Pointer dataPtr = StackValue.get(sizeInBytes); dataPtr.writeLong(0, useNativeByteOrder ? data : Long.reverseBytes(data)); - return write(fd, dataPtr, WordFactory.unsigned(sizeInBytes)); + return write(fd, dataPtr, Word.unsigned(sizeInBytes)); } @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/BufferedFileOperationSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/BufferedFileOperationSupport.java index 31bd8912c26b..bb82329409cb 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/BufferedFileOperationSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/BufferedFileOperationSupport.java @@ -35,7 +35,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.UnmanagedMemoryUtil; @@ -103,18 +102,18 @@ protected BufferedFileOperationSupport(boolean useNativeByteOrder) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public BufferedFile allocate(RawFileDescriptor fd, NmtCategory nmtCategory) { if (!rawFiles().isValid(fd)) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } long filePosition = rawFiles().position(fd); if (filePosition < 0) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } /* Use a single allocation for the struct and the corresponding buffer. */ - UnsignedWord totalSize = SizeOf.unsigned(BufferedFile.class).add(WordFactory.unsigned(BUFFER_SIZE)); + UnsignedWord totalSize = SizeOf.unsigned(BufferedFile.class).add(Word.unsigned(BUFFER_SIZE)); BufferedFile result = NullableNativeMemory.malloc(totalSize, nmtCategory); if (result.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } result.setFileDescriptor(fd); @@ -145,7 +144,7 @@ public boolean flush(BufferedFile f) { return true; } - boolean success = rawFiles().write(f.getFileDescriptor(), getBufferStart(f), WordFactory.unsigned(unflushed)); + boolean success = rawFiles().write(f.getFileDescriptor(), getBufferStart(f), Word.unsigned(unflushed)); if (success) { f.setBufferPos(getBufferStart(f)); f.setFilePosition(f.getFilePosition() + unflushed); @@ -220,7 +219,7 @@ public boolean write(BufferedFile f, byte[] data) { DynamicHub hub = KnownIntrinsics.readHub(data); UnsignedWord baseOffset = LayoutEncoding.getArrayBaseOffset(hub.getLayoutEncoding()); Pointer dataPtr = Word.objectToUntrackedPointer(data).add(baseOffset); - return write(f, dataPtr, WordFactory.unsigned(data.length)); + return write(f, dataPtr, Word.unsigned(data.length)); } /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/ChunkBasedCommittedMemoryProvider.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/ChunkBasedCommittedMemoryProvider.java index 1b6ea632d2c0..77ef55d28e94 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/ChunkBasedCommittedMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/ChunkBasedCommittedMemoryProvider.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.os; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.config.ConfigurationValues; @@ -91,7 +91,7 @@ public void freeUnalignedChunk(PointerBase start, UnsignedWord nbytes) { @Fold protected static UnsignedWord getAlignmentForUnalignedChunks() { int alignment = Math.max(ConfigurationValues.getTarget().wordSize, ConfigurationValues.getObjectLayout().getAlignment()); - return WordFactory.unsigned(alignment); + return Word.unsigned(alignment); } /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/OSCommittedMemoryProvider.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/OSCommittedMemoryProvider.java index 2b5bfd043ccd..98318d2f801c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/OSCommittedMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/OSCommittedMemoryProvider.java @@ -24,8 +24,8 @@ */ package com.oracle.svm.core.os; -import static jdk.graal.compiler.word.WordFactory.nullPointer; -import static jdk.graal.compiler.word.WordFactory.zero; +import static jdk.graal.compiler.word.Word.nullPointer; +import static jdk.graal.compiler.word.Word.zero; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/VirtualMemoryProvider.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/VirtualMemoryProvider.java index 5acb91e68375..fa650a7912b8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/VirtualMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/VirtualMemoryProvider.java @@ -25,12 +25,12 @@ package com.oracle.svm.core.os; import jdk.graal.compiler.api.replacements.Fold; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; /** * Primitive operations for low-level virtual memory management. @@ -90,7 +90,7 @@ default UnsignedWord getAlignment() { * @param alignment The alignment in bytes of the start of the address range to be reserved. * @param code whether the memory may store instructions (see {@link Access#FUTURE_EXECUTE}). * @return An {@linkplain #getAlignment aligned} pointer to the beginning of the reserved - * address range, or {@link WordFactory#nullPointer()} in case of an error. + * address range, or {@link Word#nullPointer()} in case of an error. */ Pointer reserve(UnsignedWord nbytes, UnsignedWord alignment, boolean code); @@ -102,17 +102,17 @@ default UnsignedWord getAlignment() { * visible through the mapping. * * @param start The start of the address range to contain the mapping, which must be a multiple - * of the {@linkplain #getGranularity() granularity}, or - * {@link WordFactory#nullPointer() null} to select an available (unreserved, - * uncommitted) address range in an arbitrary location. + * of the {@linkplain #getGranularity() granularity}, or {@link Word#nullPointer() + * null} to select an available (unreserved, uncommitted) address range in an + * arbitrary location. * @param nbytes The size in bytes of the file region to be mapped, which need not be a multiple * of the {@linkplain #getGranularity() granularity}. This value must not be 0. * @param fileHandle A platform-specific open file handle. * @param offset The offset in bytes of the region within the file to be mapped, which must be a * multiple of the {@linkplain #getGranularity() granularity}. * @param access The modes in which the memory is permitted to be accessed, see {@link Access}. - * @return The start of the mapped address range, or {@link WordFactory#nullPointer()} in case - * of an error. + * @return The start of the mapped address range, or {@link Word#nullPointer()} in case of an + * error. */ Pointer mapFile(PointerBase start, UnsignedWord nbytes, WordBase fileHandle, UnsignedWord offset, int access); @@ -126,21 +126,21 @@ default UnsignedWord getAlignment() { * ranges. If the provided range covers addresses outside of such ranges, or from multiple * independently reserved ranges, undefined effects can occur. *

- * Alternatively, {@link WordFactory#nullPointer() NULL} can be passed for the start address, in - * which case an available (unreserved, uncommitted) address range in an arbitrary but + * Alternatively, {@link Word#nullPointer() NULL} can be passed for the start address, in which + * case an available (unreserved, uncommitted) address range in an arbitrary but * {@linkplain #getAlignment aligned} location will be selected, reserved and committed in one * step. * * @param start The start of the address range to be committed, which must be a multiple of the - * {@linkplain #getGranularity() granularity}, or {@link WordFactory#nullPointer() - * NULL} to select an available (unreserved, uncommitted) address range in an - * arbitrary but {@linkplain #getAlignment aligned} location. + * {@linkplain #getGranularity() granularity}, or {@link Word#nullPointer() NULL} to + * select an available (unreserved, uncommitted) address range in an arbitrary but + * {@linkplain #getAlignment aligned} location. * @param nbytes The size in bytes of the address range to be committed, which will be rounded * up to a multiple of the {@linkplain #getGranularity() granularity}. This value * must not be 0. * @param access The modes in which the memory is permitted to be accessed, see {@link Access}. - * @return The start of the committed address range, or {@link WordFactory#nullPointer()} in - * case of an error, such as inadequate physical memory. + * @return The start of the committed address range, or {@link Word#nullPointer()} in case of an + * error, such as inadequate physical memory. */ Pointer commit(PointerBase start, UnsignedWord nbytes, int access); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/GOTHeapSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/GOTHeapSupport.java index c5bdd4ebae14..007bb5d3183a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/GOTHeapSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/GOTHeapSupport.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.core.pltgot; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.type.WordPointer; import org.graalvm.word.LocationIdentity; @@ -31,7 +32,6 @@ import org.graalvm.word.PointerBase; import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -54,8 +54,8 @@ public abstract class GOTHeapSupport extends DynamicMethodAddressResolutionHeapS public static final String IMAGE_GOT_BEGIN_SYMBOL_NAME = "__svm_got_begin"; public static final CGlobalData IMAGE_GOT_BEGIN = CGlobalDataFactory.forSymbol(IMAGE_GOT_BEGIN_SYMBOL_NAME); - private static final SignedWord GOT_UNINITIALIZED = WordFactory.signed(-1); - private static final SignedWord GOT_INITIALIZATION_IN_PROGRESS = WordFactory.signed(-2); + private static final SignedWord GOT_UNINITIALIZED = Word.signed(-1); + private static final SignedWord GOT_INITIALIZATION_IN_PROGRESS = Word.signed(-2); private static final CGlobalData GOT_STATUS = CGlobalDataFactory.createWord(GOT_UNINITIALIZED); static final CGlobalData GOT_START_ADDRESS = CGlobalDataFactory.createWord(); @@ -150,7 +150,7 @@ public int initialize() { if (ret == CEntryPointErrors.NO_ERROR) { makeGOTReadOnly(); } - GOT_STATUS.get().writeWordVolatile(0, WordFactory.signed(ret)); + GOT_STATUS.get().writeWordVolatile(0, Word.signed(ret)); return ret; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/IdentityMethodAddressResolver.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/IdentityMethodAddressResolver.java index 72bfa050fdcc..19ad8af5d4d8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/IdentityMethodAddressResolver.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/IdentityMethodAddressResolver.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.pltgot; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -41,7 +41,7 @@ public class IdentityMethodAddressResolver implements MethodAddressResolver { @Uninterruptible(reason = "Called from the PLT stub where stack walks are not safe.") public long resolveMethodWithGotEntry(long gotEntry) { /* Fetch the absolute address of the method that corresponds to the target GOT entry. */ - UnsignedWord methodTableOffset = WordFactory.unsigned(gotEntry).multiply(ConfigurationValues.getTarget().wordSize); + UnsignedWord methodTableOffset = Word.unsigned(gotEntry).multiply(ConfigurationValues.getTarget().wordSize); UnsignedWord address = methodTable.get().readWord(methodTableOffset); /* * Write the resolved address to the GOT entry so that it can be directly used for future diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/aarch64/AArch64MethodAddressResolutionDispatcher.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/aarch64/AArch64MethodAddressResolutionDispatcher.java index e4175e7fc353..cdb31ba54562 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/aarch64/AArch64MethodAddressResolutionDispatcher.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/aarch64/AArch64MethodAddressResolutionDispatcher.java @@ -26,8 +26,8 @@ import static com.oracle.svm.core.pltgot.ExitMethodAddressResolutionNode.exitMethodAddressResolution; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.Uninterruptible; @@ -54,7 +54,7 @@ public static void resolveMethodAddress() { Pointer paddingSlot = KnownIntrinsics.readCallerStackPointer(); long gotEntry = DeoptimizationSlotPacking.decodeGOTIndex(paddingSlot.readWord(0).rawValue()); long resolvedMethodAddress = MethodAddressResolutionDispatcher.resolveMethodAddress(gotEntry); - exitMethodAddressResolution(WordFactory.pointer(resolvedMethodAddress)); + exitMethodAddressResolution(Word.pointer(resolvedMethodAddress)); throw UnreachableNode.unreachable(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/amd64/AMD64MethodAddressResolutionDispatcher.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/amd64/AMD64MethodAddressResolutionDispatcher.java index 96fb84d5d031..cb6d6826cb88 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/amd64/AMD64MethodAddressResolutionDispatcher.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/pltgot/amd64/AMD64MethodAddressResolutionDispatcher.java @@ -26,7 +26,7 @@ import static com.oracle.svm.core.pltgot.ExitMethodAddressResolutionNode.exitMethodAddressResolution; -import jdk.graal.compiler.word.WordFactory; +import jdk.graal.compiler.word.Word; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.Uninterruptible; @@ -57,7 +57,7 @@ public final class AMD64MethodAddressResolutionDispatcher extends MethodAddressR @NeverInline("This method must never be inlined or called directly because we only jump to it from the PLT stub.") public static long resolveMethodAddress(long gotEntry) { long resolvedMethodAddress = MethodAddressResolutionDispatcher.resolveMethodAddress(gotEntry); - exitMethodAddressResolution(WordFactory.pointer(resolvedMethodAddress)); + exitMethodAddressResolution(Word.pointer(resolvedMethodAddress)); throw UnreachableNode.unreachable(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/SubstrateMethodAccessor.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/SubstrateMethodAccessor.java index c9c20843729a..5e2bd925b4ce 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/SubstrateMethodAccessor.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/SubstrateMethodAccessor.java @@ -26,10 +26,10 @@ import java.lang.reflect.Executable; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CFunctionPointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.classinitialization.EnsureClassInitializedNode; @@ -128,7 +128,7 @@ private CFunctionPointer invokeTarget(Object obj) { */ long methodOffset = tableStartingOffset + vtableOffset; - target = BarrieredAccess.readWord(obj.getClass(), WordFactory.pointer(methodOffset), NamedLocationIdentity.FINAL_LOCATION); + target = BarrieredAccess.readWord(obj.getClass(), Word.pointer(methodOffset), NamedLocationIdentity.FINAL_LOCATION); } else { target = directTarget; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferAccess.java index 99fa1ab47134..969441356c1e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferAccess.java @@ -27,10 +27,10 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.config.ConfigurationValues; @@ -48,7 +48,7 @@ private SamplerBufferAccess() { @Fold static UnsignedWord getHeaderSize() { - return UnsignedUtils.roundUp(SizeOf.unsigned(SamplerBuffer.class), WordFactory.unsigned(ConfigurationValues.getTarget().wordSize)); + return UnsignedUtils.roundUp(SizeOf.unsigned(SamplerBuffer.class), Word.unsigned(ConfigurationValues.getTarget().wordSize)); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferPool.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferPool.java index 5ee63b4fa30e..0d67b8aa3235 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferPool.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferPool.java @@ -25,11 +25,11 @@ package com.oracle.svm.core.sampler; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.jdk.management.SubstrateThreadMXBean; @@ -163,7 +163,7 @@ private SamplerBuffer tryAllocateBuffer0() { if (result.isNonNull()) { bufferCount++; result.setSize(dataSize); - result.setNext(WordFactory.nullPointer()); + result.setNext(Word.nullPointer()); SamplerBufferAccess.reinitialize(result); } return result; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferStack.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferStack.java index dbe5913d0900..2101c234ab75 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferStack.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerBufferStack.java @@ -25,9 +25,9 @@ package com.oracle.svm.core.sampler; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; @@ -71,7 +71,7 @@ public SamplerBuffer popBuffer() { SamplerBuffer result = head; if (result.isNonNull()) { head = head.getNext(); - result.setNext(WordFactory.nullPointer()); + result.setNext(Word.nullPointer()); } return result; } finally { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerJfrStackTraceSerializer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerJfrStackTraceSerializer.java index 2069945a9763..e5b929a73350 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerJfrStackTraceSerializer.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerJfrStackTraceSerializer.java @@ -25,11 +25,11 @@ package com.oracle.svm.core.sampler; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.code.CodeInfo; @@ -63,7 +63,7 @@ public Pointer serializeStackTrace(Pointer rawStackTrace, Pointer bufferEnd, int boolean isTruncated, long sampleTick, long threadId, long threadState) { Pointer current = rawStackTrace; CIntPointer statusPtr = StackValue.get(CIntPointer.class); - JfrStackTraceRepository.JfrStackTraceTableEntry entry = SubstrateJVM.getStackTraceRepo().getOrPutStackTrace(current, WordFactory.unsigned(sampleSize), sampleHash, statusPtr); + JfrStackTraceRepository.JfrStackTraceTableEntry entry = SubstrateJVM.getStackTraceRepo().getOrPutStackTrace(current, Word.unsigned(sampleSize), sampleHash, statusPtr); long stackTraceId = entry.isNull() ? 0 : entry.getId(); int status = statusPtr.read(); @@ -113,7 +113,7 @@ private static boolean serializeStackTrace(Pointer rawStackTrace, int sampleSize * number of stack trace elements because the count can't be patched later on * (JfrNativeEventWriter.putInt() would not necessarily reserve enough bytes). */ - int numStackTraceElements = visitRawStackTrace(rawStackTrace, sampleSize, WordFactory.nullPointer()); + int numStackTraceElements = visitRawStackTrace(rawStackTrace, sampleSize, Word.nullPointer()); if (numStackTraceElements == 0) { return false; } @@ -146,7 +146,7 @@ private static int visitRawStackTrace(Pointer rawStackTrace, int sampleSize, Jfr @Uninterruptible(reason = "Prevent JFR recording, epoch change, and that the GC frees the CodeInfo.") private static int visitFrame(JfrNativeEventWriterData data, long address) { - CodePointer ip = WordFactory.pointer(address); + CodePointer ip = Word.pointer(address); UntetheredCodeInfo untetheredInfo = CodeInfoTable.lookupCodeInfo(ip); if (untetheredInfo.isNull()) { /* Unknown frame. Must not happen for AOT-compiled code. */ diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerSampleWriter.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerSampleWriter.java index 309fae4c77d2..322b3bceac11 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerSampleWriter.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerSampleWriter.java @@ -26,9 +26,9 @@ package com.oracle.svm.core.sampler; import jdk.graal.compiler.api.replacements.Fold; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.UnmanagedMemoryUtil; @@ -111,7 +111,7 @@ private static void putUncheckedLong(SamplerSampleWriterData data, long value) { /* This method is only called if ensureSize() succeeded earlier. */ assert getAvailableSize(data).aboveOrEqual(Long.BYTES); data.getCurrentPos().writeLong(0, value); - increaseCurrentPos(data, WordFactory.unsigned(Long.BYTES)); + increaseCurrentPos(data, Word.unsigned(Long.BYTES)); } @Uninterruptible(reason = "Accesses a sampler buffer.", callerMustBe = true) @@ -129,7 +129,7 @@ private static void putUncheckedInt(SamplerSampleWriterData data, int value) { /* This method is only called if ensureSize() succeeded earlier. */ assert getAvailableSize(data).aboveOrEqual(Integer.BYTES); data.getCurrentPos().writeInt(0, value); - increaseCurrentPos(data, WordFactory.unsigned(Integer.BYTES)); + increaseCurrentPos(data, Word.unsigned(Integer.BYTES)); } @Uninterruptible(reason = "Accesses a sampler buffer.", callerMustBe = true) @@ -207,7 +207,7 @@ private static void reset(SamplerSampleWriterData data) { @Uninterruptible(reason = "Accesses a native JFR buffer.", callerMustBe = true) private static void cancel(SamplerSampleWriterData data) { - data.setEndPos(WordFactory.nullPointer()); + data.setEndPos(Word.nullPointer()); JfrThreadLocal.increaseMissedSamples(); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerSpinLock.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerSpinLock.java index acc79e42ca6f..9842598baa02 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerSpinLock.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SamplerSpinLock.java @@ -26,11 +26,11 @@ package com.oracle.svm.core.sampler; import jdk.graal.compiler.nodes.PauseNode; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.jdk.UninterruptibleUtils; @@ -61,7 +61,7 @@ public boolean isOwner() { public void lock() { VMError.guarantee(!isOwner(), "The current thread already has the lock!"); IsolateThread currentThread = CurrentIsolate.getCurrentThread(); - while (!owner.compareAndSet(WordFactory.nullPointer(), currentThread)) { + while (!owner.compareAndSet(Word.nullPointer(), currentThread)) { PauseNode.pause(); } } @@ -69,6 +69,6 @@ public void lock() { @Uninterruptible(reason = "The whole critical section must be uninterruptible.", callerMustBe = true) public void unlock() { VMError.guarantee(isOwner(), "The current thread doesn't have the lock!"); - owner.compareAndSet(CurrentIsolate.getCurrentThread(), WordFactory.nullPointer()); + owner.compareAndSet(CurrentIsolate.getCurrentThread(), Word.nullPointer()); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SubstrateSigprofHandler.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SubstrateSigprofHandler.java index 7cc0e7146963..3e75f11189a0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SubstrateSigprofHandler.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SubstrateSigprofHandler.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.core.sampler; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Isolate; @@ -31,7 +32,6 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.IsolateListenerSupport.IsolateListener; import com.oracle.svm.core.Isolates; @@ -86,7 +86,7 @@ public void afterCreateIsolate(Isolate isolate) { @Uninterruptible(reason = "The isolate teardown is in progress.") public void onIsolateTeardown() { ThreadLocalKey oldKey = keyForNativeThreadLocal; - keyForNativeThreadLocal = WordFactory.nullPointer(); + keyForNativeThreadLocal = Word.nullPointer(); PlatformThreads.singleton().deleteUnmanagedThreadLocal(oldKey); } @@ -119,7 +119,7 @@ protected void stopSampling() { /* Wait until all threads exited the signal handler and cleanup no longer needed data. */ disallowThreadsInSamplerCode(); try { - setSignalHandlerIsolate(WordFactory.nullPointer()); + setSignalHandlerIsolate(Word.nullPointer()); } finally { allowThreadsInSamplerCode(); } @@ -180,7 +180,7 @@ protected void uninstall(IsolateThread thread) { * Invalidate thread-local area. Once this value is set to null, the signal handler * can't interrupt this thread anymore. */ - storeIsolateThreadInNativeThreadLocal(WordFactory.nullPointer()); + storeIsolateThreadInNativeThreadLocal(Word.nullPointer()); ExecutionSamplerInstallation.uninstalled(thread); uninstall0(thread); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/snippets/ExceptionUnwind.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/snippets/ExceptionUnwind.java index 484996199be3..af76191567d2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/snippets/ExceptionUnwind.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/snippets/ExceptionUnwind.java @@ -26,6 +26,7 @@ import static jdk.graal.compiler.core.common.spi.ForeignCallDescriptor.CallSideEffect.NO_SIDE_EFFECT; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.IsolateThread; @@ -35,7 +36,6 @@ import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.code.CodeInfoQueryResult; @@ -208,7 +208,7 @@ private static void defaultUnwindException(Pointer startSP, boolean fromMethodWi long exceptionOffset = frame.getExceptionOffset(); if (exceptionOffset != CodeInfoQueryResult.NO_EXCEPTION_OFFSET) { - CodePointer handlerIP = (CodePointer) ((UnsignedWord) frame.getIP()).add(WordFactory.signed(exceptionOffset)); + CodePointer handlerIP = (CodePointer) ((UnsignedWord) frame.getIP()).add(Word.signed(exceptionOffset)); jumpToHandler(sp, handlerIP, hasCalleeSavedRegisters); UnreachableNode.unreachable(); return; /* Unreachable */ diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaFrameAnchors.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaFrameAnchors.java index 64bd6dc4793b..f53e995ed585 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaFrameAnchors.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaFrameAnchors.java @@ -27,10 +27,10 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; import static jdk.graal.compiler.core.common.spi.ForeignCallDescriptor.CallSideEffect.NO_SIDE_EFFECT; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateDiagnostics; import com.oracle.svm.core.SubstrateOptions; @@ -75,8 +75,8 @@ public static void pushFrameAnchor(JavaFrameAnchor newAnchor) { * proper ones (see usages of KnownOffsets.getJavaFrameAnchorLastSPOffset() in the backend). * The intention is to not see stale values when debugging or in signal handlers. */ - newAnchor.setLastJavaIP(WordFactory.nullPointer()); - newAnchor.setLastJavaSP(WordFactory.nullPointer()); + newAnchor.setLastJavaIP(Word.nullPointer()); + newAnchor.setLastJavaSP(Word.nullPointer()); JavaFrameAnchor prev = lastAnchorTL.get(); newAnchor.setPreviousAnchor(prev); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaFrames.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaFrames.java index 6d9b99743a8f..5de17c85306c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaFrames.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaFrames.java @@ -27,10 +27,10 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; import com.oracle.svm.core.interpreter.InterpreterSupport; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.code.CodeInfo; @@ -66,7 +66,7 @@ public static boolean isInterpreterLeaveStub(JavaFrame frame) { public static UnsignedWord getTotalFrameSize(JavaFrame frame) { long size = CodeInfoQueryResult.getTotalFrameSize(frame.getEncodedFrameSize()); assert size > 0; - return WordFactory.unsigned(size); + return Word.unsigned(size); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) @@ -77,9 +77,9 @@ public static Pointer getCallerSP(JavaFrame frame) { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) static void clearData(JavaFrame frame) { - frame.setSP(WordFactory.nullPointer()); - frame.setIP(WordFactory.nullPointer()); - frame.setIPCodeInfo(WordFactory.nullPointer()); + frame.setSP(Word.nullPointer()); + frame.setIP(Word.nullPointer()); + frame.setIPCodeInfo(Word.nullPointer()); frame.setEncodedFrameSize(CodeInfoDecoder.INVALID_SIZE_ENCODING); frame.setExceptionOffset(CodeInfoQueryResult.NO_EXCEPTION_OFFSET); @@ -93,7 +93,7 @@ public static void setData(JavaFrame frame, Pointer sp, CodePointer ip) { DeoptimizedFrame deoptimizedFrame = Deoptimizer.checkDeoptimized(frame); if (deoptimizedFrame != null) { - frame.setIPCodeInfo(WordFactory.nullPointer()); + frame.setIPCodeInfo(Word.nullPointer()); frame.setEncodedFrameSize(deoptimizedFrame.getSourceEncodedFrameSize()); frame.setExceptionOffset(CodeInfoQueryResult.NO_EXCEPTION_OFFSET); frame.setReferenceMapIndex(ReferenceMapIndex.NO_REFERENCE_MAP); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaStackWalker.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaStackWalker.java index 23355a70e163..807b1679bf04 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaStackWalker.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/JavaStackWalker.java @@ -27,6 +27,7 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; import com.oracle.svm.core.deopt.DeoptimizationSlotPacking; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; @@ -37,7 +38,6 @@ import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.FrameAccess; import com.oracle.svm.core.Uninterruptible; @@ -145,17 +145,17 @@ public static JavaFrameAnchor getFrameAnchor(JavaStackWalk walk) { @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.", callerMustBe = true) public static void initialize(JavaStackWalk walk, IsolateThread thread) { - initializeFromFrameAnchor(walk, thread, WordFactory.nullPointer()); + initializeFromFrameAnchor(walk, thread, Word.nullPointer()); } @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.", callerMustBe = true) public static void initialize(JavaStackWalk walk, IsolateThread thread, Pointer startSP) { - initWalk(walk, thread, startSP, WordFactory.nullPointer(), WordFactory.nullPointer(), JavaFrameAnchors.getFrameAnchor(thread)); + initWalk(walk, thread, startSP, Word.nullPointer(), Word.nullPointer(), JavaFrameAnchors.getFrameAnchor(thread)); } @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.", callerMustBe = true) public static void initialize(JavaStackWalk walk, IsolateThread thread, Pointer startSP, Pointer endSP) { - initWalk(walk, thread, startSP, endSP, WordFactory.nullPointer(), JavaFrameAnchors.getFrameAnchor(thread)); + initWalk(walk, thread, startSP, endSP, Word.nullPointer(), JavaFrameAnchors.getFrameAnchor(thread)); } /** @@ -164,7 +164,7 @@ public static void initialize(JavaStackWalk walk, IsolateThread thread, Pointer */ @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.", callerMustBe = true) public static void initialize(JavaStackWalk walk, IsolateThread thread, Pointer startSP, CodePointer startIP) { - initWalk(walk, thread, startSP, WordFactory.nullPointer(), startIP, JavaFrameAnchors.getFrameAnchor(thread)); + initWalk(walk, thread, startSP, Word.nullPointer(), startIP, JavaFrameAnchors.getFrameAnchor(thread)); } /** @@ -173,7 +173,7 @@ public static void initialize(JavaStackWalk walk, IsolateThread thread, Pointer */ @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.", callerMustBe = true) public static void initialize(JavaStackWalk walk, IsolateThread thread, Pointer startSP, CodePointer startIP, JavaFrameAnchor anchor) { - initWalk(walk, thread, startSP, WordFactory.nullPointer(), startIP, anchor); + initWalk(walk, thread, startSP, Word.nullPointer(), startIP, anchor); } @Uninterruptible(reason = "StoredContinuation must not move.", callerMustBe = true) @@ -187,7 +187,7 @@ public static void initializeForContinuation(JavaStackWalk walk, StoredContinuat } else { Pointer startSP = StoredContinuationAccess.getFramesStart(continuation); Pointer endSP = StoredContinuationAccess.getFramesEnd(continuation); - initWalk0(walk, startSP, endSP, startIP, WordFactory.nullPointer()); + initWalk0(walk, startSP, endSP, startIP, Word.nullPointer()); } } @@ -198,7 +198,7 @@ public static void initializeForContinuation(JavaStackWalk walk, StoredContinuat Pointer startSP = StoredContinuationAccess.getFramesStart(continuation); Pointer endSP = StoredContinuationAccess.getFramesEnd(continuation); - initWalk0(walk, startSP, endSP, startIP, WordFactory.nullPointer()); + initWalk0(walk, startSP, endSP, startIP, Word.nullPointer()); } @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.", callerMustBe = true) @@ -230,7 +230,7 @@ private static void initWalk(JavaStackWalk walk, IsolateThread thread, Pointer s @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) private static void markAsNotWalkable(JavaStackWalk walk) { - initWalk0(walk, WordFactory.nullPointer(), WordFactory.nullPointer(), WordFactory.nullPointer(), WordFactory.nullPointer()); + initWalk0(walk, Word.nullPointer(), Word.nullPointer(), Word.nullPointer(), Word.nullPointer()); } @Uninterruptible(reason = "JavaStackWalk must not contain stale values when this method returns.", callerMustBe = true) @@ -254,12 +254,12 @@ public static void updateStackPointerForContinuation(JavaStackWalk walk, StoredC long newEndSP = w.getEndSP().rawValue() + delta; w.setStartSP(newStartSP); - w.setEndSP(WordFactory.pointer(newEndSP)); + w.setEndSP(Word.pointer(newEndSP)); JavaFrame frame = getCurrentFrame(walk); if (frame.getSP().isNonNull()) { long newSP = frame.getSP().rawValue() + delta; - frame.setSP(WordFactory.pointer(newSP)); + frame.setSP(Word.pointer(newSP)); } } @@ -270,7 +270,7 @@ public static boolean advance(JavaStackWalk walk, IsolateThread thread) { @Uninterruptible(reason = "Prevent deoptimization and GC while in this method.", callerMustBe = true) public static boolean advanceForContinuation(JavaStackWalk walk, StoredContinuation continuation) { - return advance0(walk, WordFactory.nullPointer(), continuation); + return advance0(walk, Word.nullPointer(), continuation); } @Uninterruptible(reason = "Prevent deoptimization and GC while in this method.", callerMustBe = true) @@ -347,7 +347,7 @@ private static boolean continueStackWalk(JavaStackWalkImpl walk, IsolateThread t */ long deoptSlot = sp.readLong((int) -totalFrameSize); long varStackSize = DeoptimizationSlotPacking.decodeVariableFrameSizeFromDeoptSlot(deoptSlot); - Pointer actualSp = sp.add(WordFactory.unsigned(varStackSize)); + Pointer actualSp = sp.add(Word.unsigned(varStackSize)); CodePointer ip = readReturnAddress(thread, continuation, actualSp); JavaFrames.setData(frame, actualSp, ip); @@ -416,17 +416,17 @@ public static boolean walkCurrentThread(Pointer startSP, StackFrameVisitor visit @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.") public static boolean walkCurrentThread(Pointer startSP, Pointer endSP, StackFrameVisitor visitor) { assert startSP.isNonNull(); - return walkCurrentThread(startSP, endSP, WordFactory.nullPointer(), visitor, null); + return walkCurrentThread(startSP, endSP, Word.nullPointer(), visitor, null); } @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.") public static boolean walkCurrentThread(Pointer startSP, ParameterizedStackFrameVisitor visitor, Object data) { - return walkCurrentThread(startSP, WordFactory.nullPointer(), WordFactory.nullPointer(), visitor, data); + return walkCurrentThread(startSP, Word.nullPointer(), Word.nullPointer(), visitor, data); } @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) public static boolean walkCurrentThread(Pointer startSP, CodePointer startIP, ParameterizedStackFrameVisitor visitor) { - return walkCurrentThread(startSP, WordFactory.nullPointer(), startIP, visitor, null); + return walkCurrentThread(startSP, Word.nullPointer(), startIP, visitor, null); } @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.") @@ -444,7 +444,7 @@ public static boolean walkThread(IsolateThread thread, StackFrameVisitor visitor @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.") public static boolean walkThread(IsolateThread thread, ParameterizedStackFrameVisitor visitor, Object data) { - return walkThread(thread, WordFactory.nullPointer(), visitor, data); + return walkThread(thread, Word.nullPointer(), visitor, data); } @Uninterruptible(reason = "Prevent deoptimization of stack frames while in this method.") diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/ThreadStackPrinter.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/ThreadStackPrinter.java index 849e41d82b67..25511da2d42b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/ThreadStackPrinter.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/stack/ThreadStackPrinter.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.stack; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.code.CodeInfo; @@ -127,7 +127,7 @@ private boolean visitFrame(Pointer sp, CodePointer ip, CodeInfo codeInfo, Deopti @Override protected final boolean unknownFrame(Pointer sp, CodePointer ip, Object data) { Log log = (Log) data; - logFrameRaw(log, sp, ip, WordFactory.nullPointer()); + logFrameRaw(log, sp, ip, Word.nullPointer()); log.string(" IP is not within Java code. Aborting stack trace printing.").newline(); printedFrames++; return false; @@ -173,7 +173,7 @@ protected void logVirtualFrames(Log log, Pointer sp, CodePointer ip, CodeInfo co } boolean compilationRoot = frame.getCaller() == null; - printFrameIdentifier(log, WordFactory.nullPointer(), deoptFrame, compilationRoot); + printFrameIdentifier(log, Word.nullPointer(), deoptFrame, compilationRoot); logFrameRaw(log, sp, ip, codeInfo); logFrameInfo(log, frame.getFrameInfo(), ImageCodeInfo.CODE_INFO_NAME + ", deopt"); if (!compilationRoot) { @@ -245,7 +245,7 @@ public static boolean printStacktrace(IsolateThread thread, Pointer initialSP, C @Uninterruptible(reason = "IP is not within Java code, so there is no risk that it gets invalidated.", calleeMustBe = false) private static void logFrame(Log log, Pointer sp, CodePointer ip) { - Stage0StackFramePrintVisitor.logFrameRaw(log, sp, ip, WordFactory.nullPointer()); + Stage0StackFramePrintVisitor.logFrameRaw(log, sp, ip, Word.nullPointer()); log.string(" IP is not within Java code. Trying frame anchor of last Java frame instead.").newline(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationInternals.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationInternals.java index 8d895d1a615e..e10fdda19449 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationInternals.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationInternals.java @@ -24,10 +24,10 @@ */ package com.oracle.svm.core.thread; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.Uninterruptible; @@ -122,9 +122,9 @@ private static void enterSpecial2(Target_jdk_internal_vm_Continuation c) { Pointer returnSP = c.sp; CodePointer returnIP = c.ip; - c.ip = WordFactory.nullPointer(); - c.sp = WordFactory.nullPointer(); - c.baseSP = WordFactory.nullPointer(); + c.ip = Word.nullPointer(); + c.sp = Word.nullPointer(); + c.baseSP = Word.nullPointer(); assert c.isEmpty(); KnownIntrinsics.farReturn(null, returnSP, returnIP, false); @@ -155,9 +155,9 @@ private static Integer doYield1(Target_jdk_internal_vm_Continuation c) { return preemptStatus; } - c.ip = WordFactory.nullPointer(); - c.sp = WordFactory.nullPointer(); - c.baseSP = WordFactory.nullPointer(); + c.ip = Word.nullPointer(); + c.sp = Word.nullPointer(); + c.baseSP = Word.nullPointer(); KnownIntrinsics.farReturn(null, returnSP, returnIP, false); throw VMError.shouldNotReachHereAtRuntime(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationSupport.java index 4c80fde97b1f..4036379d99bf 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationSupport.java @@ -24,12 +24,12 @@ */ package com.oracle.svm.core.thread; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.Uninterruptible; @@ -123,7 +123,7 @@ protected CodePointer copyFrames(StoredContinuation storedCont, Pointer topSP, @ assert totalSize % ConfigurationValues.getTarget().wordSize == 0; Pointer frameData = StoredContinuationAccess.getFramesStart(storedCont); - UnmanagedMemoryUtil.copyWordsForward(frameData, topSP, WordFactory.unsigned(totalSize)); + UnmanagedMemoryUtil.copyWordsForward(frameData, topSP, Word.unsigned(totalSize)); return StoredContinuationAccess.getIP(storedCont); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java index 6a1160d9b822..b58d8ac6d069 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java @@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.IsolateThread; @@ -38,7 +39,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.impl.InternalPlatform; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.NeverInline; @@ -249,7 +249,7 @@ private static StackTraceElement[] getMountedVirtualThreadStackTrace(boolean fil if (carrier == null) { return null; } - Pointer endSP = PlatformThreads.getCarrierSPOrElse(carrier, WordFactory.nullPointer()); + Pointer endSP = PlatformThreads.getCarrierSPOrElse(carrier, Word.nullPointer()); if (endSP.isNull()) { return null; } @@ -303,7 +303,7 @@ public static void visitCurrentStackFrames(StackFrameVisitor visitor) { private static void visitCurrentVirtualThreadStackFrames(Pointer callerSP, StackFrameVisitor visitor) { Thread carrier = toVirtualTarget(Thread.currentThread()).carrierThread; if (carrier != null) { - Pointer endSP = PlatformThreads.getCarrierSPOrElse(carrier, WordFactory.nullPointer()); + Pointer endSP = PlatformThreads.getCarrierSPOrElse(carrier, Word.nullPointer()); if (endSP.isNonNull()) { StackTraceUtils.visitCurrentThreadStackFrames(callerSP, endSP, visitor); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaVMOperation.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaVMOperation.java index 0ab12ba47e56..f26f131a637c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaVMOperation.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaVMOperation.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.thread; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions.ConcealedOptions; import com.oracle.svm.core.SubstrateUtil; @@ -105,7 +105,7 @@ protected void markAsQueued(NativeVMOperationData data) { @Override protected void markAsFinished(NativeVMOperationData data) { - queuingThread = WordFactory.nullPointer(); + queuingThread = Word.nullPointer(); queuingThreadId = 0; finished = true; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/NativeVMOperation.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/NativeVMOperation.java index 8029a6e50d52..1948d6dcfbbc 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/NativeVMOperation.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/NativeVMOperation.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.thread; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.heap.VMOperationInfo; @@ -81,7 +81,7 @@ protected void markAsQueued(NativeVMOperationData data) { @Override protected void markAsFinished(NativeVMOperationData data) { - data.setQueuingThread(WordFactory.nullPointer()); + data.setQueuingThread(Word.nullPointer()); data.setQueuingThreadId(0); data.setFinished(true); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java index dcbd5c80ae13..6d41c5aa31cc 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java @@ -47,6 +47,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.ImageInfo; import org.graalvm.nativeimage.ImageSingletons; @@ -67,7 +68,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.SubstrateDiagnostics; @@ -481,7 +481,7 @@ public static void detach(IsolateThread vmThread) { Thread thread = currentThread.get(vmThread); if (thread != null) { toTarget(thread).threadData.detach(); - toTarget(thread).isolateThread = WordFactory.nullPointer(); + toTarget(thread).isolateThread = Word.nullPointer(); if (!thread.isDaemon()) { decrementNonDaemonThreads(); @@ -713,8 +713,8 @@ protected interface ThreadStartData extends PointerBase { } protected T prepareStart(Thread thread, int startDataSize) { - T startData = WordFactory.nullPointer(); - ObjectHandle threadHandle = WordFactory.zero(); + T startData = Word.nullPointer(); + ObjectHandle threadHandle = Word.zero(); try { startData = NativeMemory.malloc(startDataSize, NmtCategory.Threading); threadHandle = ObjectHandles.getGlobal().create(thread); @@ -725,7 +725,7 @@ protected T prepareStart(Thread thread, int startDat if (startData.isNonNull()) { freeStartData(startData); } - if (threadHandle.notEqual(WordFactory.zero())) { + if (threadHandle.notEqual(Word.zero())) { ObjectHandles.getGlobal().destroy(threadHandle); } throw e; @@ -806,7 +806,7 @@ protected static WordBase threadStartRoutine(ThreadStartData data) { freeStartData(data); threadStartRoutine(threadHandle); - return WordFactory.nullPointer(); + return Word.nullPointer(); } @SuppressFBWarnings(value = "Ru", justification = "We really want to call Thread.run and not Thread.start because we are in the low-level thread start routine") @@ -861,7 +861,7 @@ static StackTraceElement[] getStackTrace(boolean filterExceptions, Thread thread assert !isVirtual(thread); if (thread != null && thread == currentThread.get()) { Pointer startSP = getCarrierSPOrElse(thread, callerSP); - return StackTraceUtils.getCurrentThreadStackTrace(filterExceptions, startSP, WordFactory.nullPointer()); + return StackTraceUtils.getCurrentThreadStackTrace(filterExceptions, startSP, Word.nullPointer()); } assert !filterExceptions : "exception stack traces can be taken only for the current thread"; return StackTraceUtils.asyncGetStackTrace(thread); @@ -870,12 +870,12 @@ static StackTraceElement[] getStackTrace(boolean filterExceptions, Thread thread static void visitCurrentStackFrames(Pointer callerSP, StackFrameVisitor visitor) { assert !isVirtual(Thread.currentThread()); Pointer startSP = getCarrierSPOrElse(Thread.currentThread(), callerSP); - StackTraceUtils.visitCurrentThreadStackFrames(startSP, WordFactory.nullPointer(), visitor); + StackTraceUtils.visitCurrentThreadStackFrames(startSP, Word.nullPointer(), visitor); } static StackTraceElement[] getStackTraceAtSafepoint(Thread thread, Pointer callerSP) { assert thread != null && !isVirtual(thread) : "may only be called for platform or carrier threads"; - Pointer carrierSP = getCarrierSPOrElse(thread, WordFactory.nullPointer()); + Pointer carrierSP = getCarrierSPOrElse(thread, Word.nullPointer()); IsolateThread isolateThread = getIsolateThread(thread); if (isolateThread == CurrentIsolate.getCurrentThread()) { Pointer startSP = carrierSP.isNonNull() ? carrierSP : callerSP; @@ -883,7 +883,7 @@ static StackTraceElement[] getStackTraceAtSafepoint(Thread thread, Pointer calle * Internal frames from the VMOperation handling show up in the stack traces, but we are * OK with that. */ - return StackTraceUtils.getCurrentThreadStackTrace(false, startSP, WordFactory.nullPointer()); + return StackTraceUtils.getCurrentThreadStackTrace(false, startSP, Word.nullPointer()); } if (carrierSP.isNonNull()) { /* @@ -891,7 +891,7 @@ static StackTraceElement[] getStackTraceAtSafepoint(Thread thread, Pointer calle * frames of the virtual thread and only visit the stack frames that belong to the * carrier thread. */ - return StackTraceUtils.getStackTraceAtSafepoint(isolateThread, carrierSP, WordFactory.nullPointer()); + return StackTraceUtils.getStackTraceAtSafepoint(isolateThread, carrierSP, Word.nullPointer()); } return StackTraceUtils.getStackTraceAtSafepoint(isolateThread); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Safepoint.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Safepoint.java index ff8e113f9321..791ef5cd7517 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Safepoint.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Safepoint.java @@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.IsolateThread; @@ -36,7 +37,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.word.LocationIdentity; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.NeverInline; @@ -629,7 +629,7 @@ void thaw(boolean unlock) { SafepointEndEvent.emit(getSafepointId(), startTicks); ImageSingletons.lookup(Heap.class).endSafepoint(); Statistics.setThawedNanos(); - requestingThread = WordFactory.nullPointer(); + requestingThread = Word.nullPointer(); if (unlock) { VMThreads.THREAD_MUTEX.unlock(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationControl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationControl.java index f565aecef9f2..4eaac32be541 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationControl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationControl.java @@ -33,7 +33,6 @@ import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Isolates; import com.oracle.svm.core.NeverInline; @@ -140,7 +139,7 @@ public static void shutdownAndDetachVMOperationThread() { int size = SizeOf.get(NativeVMOperationData.class); NativeVMOperationData data = StackValue.get(size); - UnmanagedMemoryUtil.fill((Pointer) data, WordFactory.unsigned(size), (byte) 0); + UnmanagedMemoryUtil.fill((Pointer) data, Word.unsigned(size), (byte) 0); NativeStopVMOperationThread operation = get().stopVMOperationThreadOperation; data.setNativeVMOperation(operation); /* @@ -266,7 +265,7 @@ void setInProgress(VMOperation operation, IsolateThread queueingThread, IsolateT } void enqueue(JavaVMOperation operation) { - enqueue(operation, WordFactory.nullPointer()); + enqueue(operation, Word.nullPointer()); } void enqueue(NativeVMOperationData data) { @@ -619,9 +618,9 @@ private void drain(JavaVMOperationQueue workQueue) { while (!workQueue.isEmpty()) { JavaVMOperation operation = workQueue.pop(); try { - operation.execute(WordFactory.nullPointer()); + operation.execute(Word.nullPointer()); } finally { - markAsFinished(operation, WordFactory.nullPointer(), operationFinished); + markAsFinished(operation, Word.nullPointer(), operationFinished); } } trace.string("]").newline(); @@ -634,10 +633,10 @@ private void filterUnnecessary(JavaVMOperationQueue workQueue) { JavaVMOperation op = workQueue.peek(); while (op != null) { JavaVMOperation next = op.getNext(); - if (!op.hasWork(WordFactory.nullPointer())) { + if (!op.hasWork(Word.nullPointer())) { trace.string("[Skipping unnecessary operation in queue ").string(workQueue.name).string(": ").string(op.getName()); workQueue.remove(prev, op); - markAsFinished(op, WordFactory.nullPointer(), operationFinished); + markAsFinished(op, Word.nullPointer(), operationFinished); } else { prev = op; } @@ -647,7 +646,7 @@ private void filterUnnecessary(JavaVMOperationQueue workQueue) { private void filterUnnecessary(NativeVMOperationQueue workQueue) { Log trace = log(); - NativeVMOperationData prev = WordFactory.nullPointer(); + NativeVMOperationData prev = Word.nullPointer(); NativeVMOperationData data = workQueue.peek(); while (data.isNonNull()) { NativeVMOperation op = data.getNativeVMOperation(); @@ -821,11 +820,11 @@ public void push(NativeVMOperationData element) { @Override public NativeVMOperationData pop() { if (head.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } NativeVMOperationData resultElement = head; head = resultElement.getNext(); - resultElement.setNext(WordFactory.nullPointer()); + resultElement.setNext(Word.nullPointer()); return resultElement; } @@ -839,7 +838,7 @@ void remove(NativeVMOperationData prev, NativeVMOperationData remove) { if (prev.isNull()) { assert head == remove; head = remove.getNext(); - remove.setNext(WordFactory.nullPointer()); + remove.setNext(Word.nullPointer()); } else { prev.setNext(remove.getNext()); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMThreads.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMThreads.java index 00d99414aaac..8e291e8b06b5 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMThreads.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMThreads.java @@ -26,6 +26,7 @@ import static com.oracle.svm.core.graal.nodes.WriteCurrentVMThreadNode.writeCurrentVMThread; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Isolate; @@ -36,7 +37,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.Uninterruptible; @@ -251,12 +251,12 @@ public IsolateThread allocateIsolateThread(int isolateThreadSize) { * size from the OS, we just use a hard-coded best guess. Using an inaccurate value does not * lead to correctness problems. */ - UnsignedWord alignment = WordFactory.unsigned(64); + UnsignedWord alignment = Word.unsigned(64); - UnsignedWord memorySize = WordFactory.unsigned(isolateThreadSize).add(alignment); + UnsignedWord memorySize = Word.unsigned(isolateThreadSize).add(alignment); Pointer memory = UntrackedNullableNativeMemory.calloc(memorySize); if (memory.isNull()) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } IsolateThread isolateThread = (IsolateThread) UnsignedUtils.roundUp(memory, alignment); @@ -267,7 +267,7 @@ public IsolateThread allocateIsolateThread(int isolateThreadSize) { @Uninterruptible(reason = "Thread state no longer set up.") public void freeCurrentIsolateThread() { freeIsolateThread(CurrentIsolate.getCurrentThread()); - writeCurrentVMThread(WordFactory.nullPointer()); + writeCurrentVMThread(Word.nullPointer()); } /** Free the native memory allocated by {@link #allocateIsolateThread}. */ @@ -371,7 +371,7 @@ protected int attachThread(IsolateThread thread) { public void detachCurrentThread() { threadExit(); detachThread(CurrentIsolate.getCurrentThread(), true); - writeCurrentVMThread(WordFactory.nullPointer()); + writeCurrentVMThread(Word.nullPointer()); } /** @@ -386,7 +386,7 @@ protected void detachThread(IsolateThread thread, boolean currentThread) { assert currentThread == (thread == CurrentIsolate.getCurrentThread()); assert currentThread || VMOperation.isInProgressAtSafepoint(); - OSThreadHandle threadToCleanup = WordFactory.nullPointer(); + OSThreadHandle threadToCleanup = Word.nullPointer(); if (currentThread) { lockThreadMutexInNativeCode(false); } @@ -454,7 +454,7 @@ private static void lockThreadMutexInNativeCode0(boolean unspecifiedOwner) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) protected void cleanupExitedOsThreads() { - OSThreadHandle threadToCleanup = detachedOsThreadToCleanup.getAndSet(WordFactory.nullPointer()); + OSThreadHandle threadToCleanup = detachedOsThreadToCleanup.getAndSet(Word.nullPointer()); cleanupExitedOsThread(threadToCleanup); } @@ -472,7 +472,7 @@ private void cleanupExitedOsThread(OSThreadHandle threadToCleanup) { @Uninterruptible(reason = "Thread is detaching and holds the THREAD_MUTEX.") private static void removeFromThreadList(IsolateThread thread) { - IsolateThread previous = WordFactory.nullPointer(); + IsolateThread previous = Word.nullPointer(); IsolateThread current = head; while (current.isNonNull()) { IsolateThread next = nextTL.get(current); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/threadlocal/VMThreadLocalInfos.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/threadlocal/VMThreadLocalInfos.java index 13ae09435647..49811c460312 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/threadlocal/VMThreadLocalInfos.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/threadlocal/VMThreadLocalInfos.java @@ -35,7 +35,6 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.BuildPhaseProvider.ReadyForCompilation; import com.oracle.svm.core.SubstrateDiagnostics; @@ -69,13 +68,13 @@ public static void dumpToLog(Log log, IsolateThread thread, boolean isJavaHeapAc for (VMThreadLocalInfo info : ImageSingletons.lookup(VMThreadLocalInfos.class).infos) { log.signed(info.offset).string(": ").string(info.name).string(" = "); if (info.threadLocalClass == FastThreadLocalInt.class) { - int value = threadLocals.readInt(WordFactory.signed(info.offset)); + int value = threadLocals.readInt(Word.signed(info.offset)); log.string("(int) ").zhex(value).string(" (").signed(value).string(")"); } else if (info.threadLocalClass == FastThreadLocalLong.class) { - long value = threadLocals.readLong(WordFactory.signed(info.offset)); + long value = threadLocals.readLong(Word.signed(info.offset)); log.string("(long) ").zhex(value).string(" (").signed(value).string(")"); } else if (info.threadLocalClass == FastThreadLocalWord.class) { - WordBase value = threadLocals.readWord(WordFactory.signed(info.offset)); + WordBase value = threadLocals.readWord(Word.signed(info.offset)); log.string("(Word) ").zhex(value).string(" (").signed(value).string(")"); } else if (info.threadLocalClass == FastThreadLocalObject.class) { if (isJavaHeapAccessAllowed) { @@ -92,7 +91,7 @@ public static void dumpToLog(Log log, IsolateThread thread, boolean isJavaHeapAc } } else if (info.threadLocalClass == FastThreadLocalBytes.class) { log.string("(bytes) "); - Pointer data = threadLocals.add(WordFactory.signed(info.offset)); + Pointer data = threadLocals.add(Word.signed(info.offset)); if (info.sizeInBytes == 8) { log.zhex(data.readWord(0)); } else { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/MetricsLogUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/MetricsLogUtils.java index 0fea5262666b..aa948966c869 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/MetricsLogUtils.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/MetricsLogUtils.java @@ -24,8 +24,8 @@ */ package com.oracle.svm.core.util; +import jdk.graal.compiler.word.Word; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.log.Log; @@ -61,7 +61,7 @@ public static void logSection(String section, int ident) { } public static void logMemoryMetric(String category, long bytes) { - logMemoryMetric(category, WordFactory.unsigned(bytes)); + logMemoryMetric(category, Word.unsigned(bytes)); } public static void logMemoryMetric(String category, UnsignedWord bytes) { @@ -202,7 +202,7 @@ public String symbol() { abstract UnsignedWord fromBytes(UnsignedWord bytes); private static UnsignedWord toKilo(final UnsignedWord bytes) { - final UnsignedWord bytedPerKilo = WordFactory.unsigned(1_024L); + final UnsignedWord bytedPerKilo = Word.unsigned(1_024L); final UnsignedWord result = bytes.unsignedDivide(bytedPerKilo); return result; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/TimeUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/TimeUtils.java index 1621b31bf925..6d940b9d0847 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/TimeUtils.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/TimeUtils.java @@ -26,8 +26,8 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; +import jdk.graal.compiler.word.Word; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.jdk.UninterruptibleUtils; @@ -150,7 +150,7 @@ public static long roundedUpDivide(long numerator, long denominator) { /** Weight a nanosecond value by a percentage between 0 and 100. */ public static long weightedNanos(int percent, long nanos) { - final UnsignedWord unweightedNanos = WordFactory.unsigned(nanos); + final UnsignedWord unweightedNanos = Word.unsigned(nanos); return unweightedNanos.unsignedDivide(100).multiply(percent).rawValue(); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/UnsignedUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/UnsignedUtils.java index 68f2170a72c2..8964da7fe5d8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/UnsignedUtils.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/UnsignedUtils.java @@ -24,8 +24,8 @@ */ package com.oracle.svm.core.util; +import jdk.graal.compiler.word.Word; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; @@ -35,7 +35,7 @@ public final class UnsignedUtils { /** The UnsignedWord of the greatest magnitude. */ - public static final UnsignedWord MAX_VALUE = WordFactory.unsigned(0xffffffffffffffffL); + public static final UnsignedWord MAX_VALUE = Word.unsigned(0xffffffffffffffffL); private UnsignedUtils() { // This is a class of static methods, so no need for any instances. @@ -133,10 +133,10 @@ public static double toDouble(UnsignedWord u) { public static UnsignedWord fromDouble(double d) { // follows JLS 5.1.3 long l = (long) d; if (Double.isNaN(d) || l <= 0) { // includes -inf - return WordFactory.zero(); + return Word.zero(); } if (l < Long.MAX_VALUE) { - return WordFactory.unsigned(l); + return Word.unsigned(l); } /* * This division does not lose precision with these large numbers because the double's @@ -148,6 +148,6 @@ public static UnsignedWord fromDouble(double d) { // follows JLS 5.1.3 if (l == Long.MAX_VALUE) { // too large or +inf return UnsignedUtils.MAX_VALUE; } - return WordFactory.unsigned(l).shiftLeft(1); + return Word.unsigned(l).shiftLeft(1); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/coder/NativeCoder.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/coder/NativeCoder.java index 2b809b0aa3fb..712232a38f67 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/coder/NativeCoder.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/coder/NativeCoder.java @@ -24,9 +24,9 @@ */ package com.oracle.svm.core.util.coder; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; @@ -49,7 +49,7 @@ public static long readU4(Pointer ptr) { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public static UnsignedWord readU8(Pointer ptr) { - return WordFactory.unsigned(ptr.readLong(0)); + return Word.unsigned(ptr.readLong(0)); } @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalEntryPoints.java b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalEntryPoints.java index cfa6494fa96c..c4b3ca421d73 100644 --- a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalEntryPoints.java +++ b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalEntryPoints.java @@ -59,6 +59,7 @@ import jdk.graal.compiler.options.OptionKey; import jdk.graal.compiler.options.OptionValues; import jdk.graal.compiler.options.OptionsParser; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicMap; import org.graalvm.jniutils.HSObject; import org.graalvm.jniutils.JNI; @@ -86,7 +87,6 @@ import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.impl.IsolateSupport; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.heap.Heap; import com.sun.management.ThreadMXBean; @@ -133,7 +133,7 @@ private static LibGraalEntryPoints singleton() { static JNI.JNIEnv getJNIEnv() { try { long raw = (long) singleton().getJNIEnv.invoke(); - return WordFactory.unsigned(raw); + return Word.unsigned(raw); } catch (RuntimeException | Error e) { throw e; } catch (Throwable e) { @@ -250,7 +250,7 @@ private static long compileMethod(JNIEnv jniEnv, try (JNIMethodScope jniScope = new JNIMethodScope("compileMethod", jniEnv)) { String profileLoadPath; if (profilePathBufferAddress > 0) { - profileLoadPath = CTypeConversion.toJavaString(WordFactory.pointer(profilePathBufferAddress)); + profileLoadPath = CTypeConversion.toJavaString(Word.pointer(profilePathBufferAddress)); } else { profileLoadPath = null; } @@ -485,8 +485,8 @@ private static JNIMethodScope openScope(Enum id, JNIEnv env) throws Throwable offset = (int) singleton().getLastJavaPCOffset.invoke(); lastJavaPCOffset = offset; } - CLongPointer currentThreadLastJavaPCOffset = (CLongPointer) WordFactory.unsigned((long) singleton().getCurrentJavaThread.invoke()).add(offset); - PointerBase javaFrameAnchor = WordFactory.pointer(currentThreadLastJavaPCOffset.read()); + CLongPointer currentThreadLastJavaPCOffset = (CLongPointer) Word.unsigned((long) singleton().getCurrentJavaThread.invoke()).add(offset); + PointerBase javaFrameAnchor = Word.pointer(currentThreadLastJavaPCOffset.read()); return LibGraalJNIMethodScope.open(scopeName, env, javaFrameAnchor.isNonNull()); } @@ -573,7 +573,7 @@ public static JString getCompilerConfigurationFactoryName(JNIEnv env, JClass hsC return scope.getObjectResult(); } catch (Throwable t) { JNIExceptionWrapper.throwInHotSpot(env, t); - return WordFactory.nullPointer(); + return Word.nullPointer(); } } @@ -664,13 +664,13 @@ public static JString getSuppliedString(JNIEnv env, JClass hsClazz, @IsolateThre String stackTrace = (String) singleton().getSuppliedString.invoke(stringSupplier); scope.setObjectResult(JNIUtil.createHSString(env, stackTrace)); } else { - scope.setObjectResult(WordFactory.nullPointer()); + scope.setObjectResult(Word.nullPointer()); } } return scope.getObjectResult(); } catch (Throwable t) { JNIExceptionWrapper.throwInHotSpot(env, t); - return WordFactory.nullPointer(); + return Word.nullPointer(); } } @@ -697,7 +697,7 @@ public static JObjectArray getNodeTypes(JNIEnv env, JClass hsClazz, @IsolateThre Object graphInfo = LibGraalObjectHandles.resolve(handle, Object.class); String[] nodeTypes = (String[]) singleton().getNodeTypes.invoke(graphInfo, simpleNames); JClass componentType = getStringClass(env); - JObjectArray res = JNIUtil.NewObjectArray(env, nodeTypes.length, componentType, WordFactory.nullPointer()); + JObjectArray res = JNIUtil.NewObjectArray(env, nodeTypes.length, componentType, Word.nullPointer()); for (int i = 0; i < nodeTypes.length; i++) { JNIUtil.SetObjectArrayElement(env, res, i, JNIUtil.createHSString(env, nodeTypes[i])); } @@ -706,7 +706,7 @@ public static JObjectArray getNodeTypes(JNIEnv env, JClass hsClazz, @IsolateThre return scope.getObjectResult(); } catch (Throwable t) { JNIExceptionWrapper.throwInHotSpot(env, t); - return WordFactory.nullPointer(); + return Word.nullPointer(); } } @@ -776,7 +776,7 @@ public static JObjectArray getInfopoints(JNIEnv env, JClass hsClazz, @IsolateThr Object compilationResultInfo = LibGraalObjectHandles.resolve(handle, Object.class); String[] infoPoints = (String[]) singleton().getInfopoints.invoke(compilationResultInfo); JClass componentType = getStringClass(env); - JObjectArray res = JNIUtil.NewObjectArray(env, infoPoints.length, componentType, WordFactory.nullPointer()); + JObjectArray res = JNIUtil.NewObjectArray(env, infoPoints.length, componentType, Word.nullPointer()); for (int i = 0; i < infoPoints.length; i++) { JNIUtil.SetObjectArrayElement(env, res, i, JNIUtil.createHSString(env, infoPoints[i])); } @@ -785,7 +785,7 @@ public static JObjectArray getInfopoints(JNIEnv env, JClass hsClazz, @IsolateThr return scope.getObjectResult(); } catch (Throwable t) { JNIExceptionWrapper.throwInHotSpot(env, t); - return WordFactory.nullPointer(); + return Word.nullPointer(); } } @@ -839,7 +839,7 @@ public static JByteArray listCompilerOptions(JNIEnv env, JClass hsClazz, @Isolat return scope.getObjectResult(); } catch (Throwable t) { JNIExceptionWrapper.throwInHotSpot(env, t); - return WordFactory.nullPointer(); + return Word.nullPointer(); } } @@ -868,7 +868,7 @@ public static JString validateCompilerOption(JNIEnv env, JClass hsClazz, @Isolat return scope.getObjectResult(); } catch (Throwable t) { JNIExceptionWrapper.throwInHotSpot(env, t); - return WordFactory.nullPointer(); + return Word.nullPointer(); } } @@ -899,7 +899,7 @@ public static JString getCompilerVersion(JNIEnv env, JClass hsClass, @IsolateThr return scope.getObjectResult(); } catch (Throwable t) { JNIExceptionWrapper.throwInHotSpot(env, t); - return WordFactory.nullPointer(); + return Word.nullPointer(); } } @@ -907,7 +907,7 @@ public static JString getCompilerVersion(JNIEnv env, JClass hsClass, @IsolateThr @SuppressWarnings("unused") public static boolean releaseHandle(JNIEnv jniEnv, JClass jclass, @IsolateThreadContext long isolateThreadId, long handle) { try { - ObjectHandles.getGlobal().destroy(WordFactory.pointer(handle)); + ObjectHandles.getGlobal().destroy(Word.pointer(handle)); return true; } catch (Throwable t) { return false; diff --git a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalObjectHandles.java b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalObjectHandles.java index d1d1f0347693..9e9819d0beb0 100644 --- a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalObjectHandles.java +++ b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalObjectHandles.java @@ -24,8 +24,8 @@ */ package com.oracle.svm.graal.hotspot.libgraal; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ObjectHandles; -import jdk.graal.compiler.word.WordFactory; /** * Manages handles to libgraal objects whose lifetime is controlled by @@ -49,7 +49,7 @@ static long create(Object object) { * @throws IllegalArgumentException if {@code} is invalid */ static T resolve(long handle, Class type) { - return type.cast(ObjectHandles.getGlobal().get(WordFactory.pointer(handle))); + return type.cast(ObjectHandles.getGlobal().get(Word.pointer(handle))); } /** @@ -57,6 +57,6 @@ static T resolve(long handle, Class type) { * method, the handle must not be used anymore. */ static void remove(long handle) { - ObjectHandles.getGlobal().destroy(WordFactory.pointer(handle)); + ObjectHandles.getGlobal().destroy(Word.pointer(handle)); } } diff --git a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalSubstitutions.java b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalSubstitutions.java index 500526de8867..3a70db24f24b 100644 --- a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalSubstitutions.java +++ b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalSubstitutions.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.function.Supplier; +import jdk.graal.compiler.word.Word; import org.graalvm.jniutils.JNI; import org.graalvm.jniutils.JNIExceptionWrapper; import org.graalvm.jniutils.JNIMethodScope; @@ -44,7 +45,6 @@ import org.graalvm.nativeimage.hosted.FieldValueTransformer; import org.graalvm.nativeimage.impl.IsolateSupport; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.annotate.Alias; @@ -212,7 +212,7 @@ public Object transform(Object receiver, Object originalValue) { } catch (Throwable e) { throw VMError.shouldNotReachHere(e); } - return CGlobalDataFactory.createWord(WordFactory.unsigned(initialValue), null, true); + return CGlobalDataFactory.createWord(Word.unsigned(initialValue), null, true); } } diff --git a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/NativeImageHostEntryPoints.java b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/NativeImageHostEntryPoints.java index e582c955295f..40d44b7f3f68 100644 --- a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/NativeImageHostEntryPoints.java +++ b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/NativeImageHostEntryPoints.java @@ -25,11 +25,11 @@ package com.oracle.svm.graal.hotspot.libgraal; import com.oracle.truffle.compiler.TruffleCompilerOptionDescriptor; +import jdk.graal.compiler.word.Word; import org.graalvm.jniutils.HSObject; import org.graalvm.jniutils.JNI.JObject; import org.graalvm.jniutils.JNIMethodScope; import org.graalvm.jniutils.JNIUtil; -import jdk.graal.compiler.word.WordFactory; /** * Entry points for native-image specific methods called by guest Graal using method handles. @@ -40,7 +40,7 @@ private NativeImageHostEntryPoints() { } public static void initializeHost(long runtimeClass) { - TruffleFromLibGraalStartPoints.initializeJNI(WordFactory.pointer(runtimeClass)); + TruffleFromLibGraalStartPoints.initializeJNI(Word.pointer(runtimeClass)); } public static Object createLocalHandleForLocalReference(long jniLocalRef) { @@ -48,12 +48,12 @@ public static Object createLocalHandleForLocalReference(long jniLocalRef) { if (scope == null) { return null; } - return new HSObject(scope, WordFactory.pointer(jniLocalRef)); + return new HSObject(scope, Word.pointer(jniLocalRef)); } public static Object createLocalHandleForWeakGlobalReference(long jniWeakGlobalRef) { JNIMethodScope scope = JNIMethodScope.scope(); - JObject localRef = JNIUtil.NewLocalRef(scope.getEnv(), WordFactory.pointer(jniWeakGlobalRef)); + JObject localRef = JNIUtil.NewLocalRef(scope.getEnv(), Word.pointer(jniWeakGlobalRef)); return localRef.isNull() ? null : new HSObject(scope, localRef); } diff --git a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/TruffleFromLibGraalStartPoints.java b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/TruffleFromLibGraalStartPoints.java index 1abea7832c5c..f42aecce5bca 100644 --- a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/TruffleFromLibGraalStartPoints.java +++ b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/TruffleFromLibGraalStartPoints.java @@ -80,6 +80,7 @@ import java.util.LinkedHashMap; import java.util.Map; +import jdk.graal.compiler.word.Word; import org.graalvm.jniutils.HSObject; import org.graalvm.jniutils.JNI.JByteArray; import org.graalvm.jniutils.JNI.JClass; @@ -95,7 +96,6 @@ import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; -import jdk.graal.compiler.word.WordFactory; import com.oracle.truffle.compiler.hotspot.libgraal.FromLibGraalId; import com.oracle.truffle.compiler.hotspot.libgraal.TruffleFromLibGraal; @@ -340,7 +340,7 @@ public static boolean cancelCompilation(Object hsHandle, CharSequence reason) { public static boolean isSameOrSplit(Object hsHandle, Object otherHsHandle) { JNIEnv env = JNIMethodScope.env(); return callIsSameOrSplit(calls, env, ((HSObject) hsHandle).getHandle(), - otherHsHandle == null ? WordFactory.nullPointer() : ((HSObject) otherHsHandle).getHandle()); + otherHsHandle == null ? Word.nullPointer() : ((HSObject) otherHsHandle).getHandle()); } @TruffleFromLibGraal(Id.GetKnownCallSiteCount) @@ -353,7 +353,7 @@ public static int getKnownCallSiteCount(Object hsHandle) { public static void consumeOptimizedAssumptionDependency(Object hsHandle, Object compilableHsHandle, long installedCode) { JNIEnv env = JNIMethodScope.env(); callConsumeOptimizedAssumptionDependency(calls, env, ((HSObject) hsHandle).getHandle(), - compilableHsHandle == null ? WordFactory.nullPointer() : ((HSObject) compilableHsHandle).getHandle(), + compilableHsHandle == null ? Word.nullPointer() : ((HSObject) compilableHsHandle).getHandle(), installedCode); } diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/ConstantData.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/ConstantData.java index 96816b8ef28f..271f5de94bb5 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/ConstantData.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/ConstantData.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.graal.isolated; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.struct.RawField; import org.graalvm.nativeimage.c.struct.RawStructure; import org.graalvm.word.PointerBase; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.meta.DirectSubstrateObjectConstant; import com.oracle.svm.core.meta.SubstrateObjectConstant; @@ -114,11 +114,11 @@ private static void fromCompilerOrClient(JavaConstant constant, ConstantData dat rawBits = IsolatedHandles.nullHandle(); data.setCompressed(SubstrateObjectConstant.isCompressed(constant)); } else if (kind.isNumericInteger()) { - rawBits = WordFactory.signed(constant.asLong()); + rawBits = Word.signed(constant.asLong()); } else if (kind == JavaKind.Float) { - rawBits = WordFactory.unsigned(Float.floatToRawIntBits(constant.asFloat())); + rawBits = Word.unsigned(Float.floatToRawIntBits(constant.asFloat())); } else if (kind == JavaKind.Double) { - rawBits = WordFactory.unsigned(Double.doubleToRawLongBits(constant.asDouble())); + rawBits = Word.unsigned(Double.doubleToRawLongBits(constant.asDouble())); } else { throw VMError.shouldNotReachHere("unsupported constant kind: " + kind); } diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/ImageHeapObjects.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/ImageHeapObjects.java index 13a20b6966d1..af78dae7d21c 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/ImageHeapObjects.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/ImageHeapObjects.java @@ -26,7 +26,6 @@ import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; @@ -45,12 +44,12 @@ static boolean isInImageHeap(Object obj) { /** * Provides the image heap location of the specified image heap object that is independent of a - * specific isolate. Java {@code null} becomes {@link WordFactory#nullPointer() NULL}. + * specific isolate. Java {@code null} becomes {@link Word#nullPointer() NULL}. */ @SuppressWarnings("unchecked") public static ImageHeapRef ref(T t) { if (t == null) { - return WordFactory.nullPointer(); + return Word.nullPointer(); } VMError.guarantee(isInImageHeap(t)); Word result = Word.objectToUntrackedPointer(t); @@ -62,10 +61,10 @@ public static ImageHeapRef ref(T t) { /** * Provides the object instance in the current isolate at the given image heap location. - * {@link WordFactory#nullPointer() NULL} becomes Java {@code null}. + * {@link Word#nullPointer() NULL} becomes Java {@code null}. */ public static T deref(ImageHeapRef ref) { - if (ref.equal(WordFactory.nullPointer())) { + if (ref.equal(Word.nullPointer())) { return null; } Pointer objectAddress = (Pointer) ref; diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolateAwareConstantReflectionProvider.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolateAwareConstantReflectionProvider.java index b0f40d410c12..2cb710a0bcb4 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolateAwareConstantReflectionProvider.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolateAwareConstantReflectionProvider.java @@ -27,9 +27,9 @@ import java.lang.reflect.Array; import jdk.graal.compiler.core.common.CompressEncoding; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CEntryPoint; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.graal.meta.SubstrateMemoryAccessProvider; @@ -236,7 +236,7 @@ public ResolvedJavaType asJavaType(Constant hub) { private static ImageHeapRef getHubConstantAsImageHeapRef(@SuppressWarnings("unused") ClientIsolateThread client, ConstantData hubData) { JavaConstant hub = ConstantDataConverter.toClient(hubData); Object target = SubstrateObjectConstant.asObject(hub); - return (target instanceof DynamicHub) ? ImageHeapObjects.ref((DynamicHub) target) : WordFactory.nullPointer(); + return (target instanceof DynamicHub) ? ImageHeapObjects.ref((DynamicHub) target) : Word.nullPointer(); } @Override diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedGraalUtils.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedGraalUtils.java index aba1b4619c58..5fbe5e5cb5b5 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedGraalUtils.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedGraalUtils.java @@ -27,6 +27,7 @@ import java.lang.reflect.Array; import java.nio.ByteBuffer; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicMap; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.Isolates; @@ -36,7 +37,6 @@ import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.c.function.IsolateSupportImpl; @@ -94,7 +94,7 @@ public static CompilerIsolateThread createCompilationIsolate() { CreateIsolateParameters.Builder builder = new CreateIsolateParameters.Builder(); long addressSpaceSize = SubstrateOptions.CompilationIsolateAddressSpaceSize.getValue(); if (addressSpaceSize > 0) { - builder.reservedAddressSpaceSize(WordFactory.signed(addressSpaceSize)); + builder.reservedAddressSpaceSize(Word.signed(addressSpaceSize)); } /* * if protection keys are used, the compilation isolate needs to use the same protection diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedReferenceAdjuster.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedReferenceAdjuster.java index 1dc72d783e21..793471fa7bba 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedReferenceAdjuster.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedReferenceAdjuster.java @@ -24,11 +24,11 @@ */ package com.oracle.svm.graal.isolated; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ObjectHandle; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.NonmovableArray; @@ -120,8 +120,8 @@ public ForeignIsolateReferenceAdjusterData exportData() { data.setAddresses(addresses); data.setHandles(handles); - addresses = WordFactory.nullPointer(); - handles = WordFactory.nullPointer(); + addresses = Word.nullPointer(); + handles = Word.nullPointer(); count = 0; return data; diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedRuntimeCodeInstaller.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedRuntimeCodeInstaller.java index 56a3a918daf3..62a62c31a6c1 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedRuntimeCodeInstaller.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedRuntimeCodeInstaller.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.graal.isolated; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.function.CodePointer; @@ -31,7 +32,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.code.CodeInfo; import com.oracle.svm.core.code.RuntimeCodeInfoAccess; @@ -129,7 +129,7 @@ private static void installPrepared(SharedMethod method, CodeInstallInfo install IsolatedRuntimeMethodInfoAccess.startTrackingInCurrentIsolate(installInfo); IsolatedReferenceAdjuster.adjustAndDispose(installInfo.getAdjusterData(), IsolatedCompileClient.get().getHandleSet()); - installInfo.setAdjusterData(WordFactory.nullPointer()); + installInfo.setAdjusterData(Word.nullPointer()); doInstallPrepared(method, installInfo.getCodeInfo(), installedCode); NativeMemory.free(installInfo); @@ -146,7 +146,7 @@ private IsolatedRuntimeCodeInstaller(IsolateThread targetIsolate, SharedRuntimeM @Override protected Pointer allocateCodeMemory(long size) { - PointerBase memory = allocateCodeMemory0(targetIsolate, WordFactory.unsigned(size)); + PointerBase memory = allocateCodeMemory0(targetIsolate, Word.unsigned(size)); if (memory.isNull()) { throw new OutOfMemoryError("Could not allocate memory for runtime-compiled code."); } diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/OptionValuesEncoder.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/OptionValuesEncoder.java index 6d476ad0d44f..3f19a9232570 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/OptionValuesEncoder.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/OptionValuesEncoder.java @@ -28,13 +28,13 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.UnmodifiableEconomicMap; import org.graalvm.collections.UnmodifiableMapCursor; import jdk.graal.compiler.options.OptionKey; import jdk.graal.compiler.util.TypedDataInputStream; import jdk.graal.compiler.util.TypedDataOutputStream; -import jdk.graal.compiler.word.WordFactory; final class OptionValuesEncoder { @@ -65,7 +65,7 @@ public static EconomicMap, Object> decode(byte[] input) { try (TypedDataInputStream in = new TypedDataInputStream(new ByteArrayInputStream(input))) { final int size = in.readInt(); for (int i = 0; i < size; i++) { - ImageHeapRef> keyRef = WordFactory.signed(in.readLong()); + ImageHeapRef> keyRef = Word.signed(in.readLong()); final OptionKey key = ImageHeapObjects.deref(keyRef); final Object value = in.readTypedValue(); options.put(key, value); diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/RuntimeCodeInstaller.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/RuntimeCodeInstaller.java index 513422cf847f..acf3c18576ff 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/RuntimeCodeInstaller.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/RuntimeCodeInstaller.java @@ -29,11 +29,11 @@ import java.util.HashSet; import java.util.Map; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.Uninterruptible; @@ -130,15 +130,15 @@ private void prepareCodeMemory() { dataOffset = NumUtil.roundUp(codeSize, compilation.getDataSection().getSectionAlignment()); if (!RuntimeCodeCache.Options.WriteableCodeCache.getValue()) { // round up for readonly code cache so that the data section can remain writeable - dataOffset = UnsignedUtils.safeToInt(UnsignedUtils.roundUp(WordFactory.unsigned(dataOffset), CommittedMemoryProvider.get().getGranularity())); + dataOffset = UnsignedUtils.safeToInt(UnsignedUtils.roundUp(Word.unsigned(dataOffset), CommittedMemoryProvider.get().getGranularity())); } - codeAndDataMemorySize = UnsignedUtils.safeToInt(UnsignedUtils.roundUp(WordFactory.unsigned(dataOffset + dataSize), CommittedMemoryProvider.get().getGranularity())); + codeAndDataMemorySize = UnsignedUtils.safeToInt(UnsignedUtils.roundUp(Word.unsigned(dataOffset + dataSize), CommittedMemoryProvider.get().getGranularity())); code = allocateCodeMemory(codeAndDataMemorySize); compiledBytes = compilation.getTargetCode(); if (RuntimeCodeCache.Options.WriteableCodeCache.getValue()) { - UnsignedWord alignedAfterCodeOffset = UnsignedUtils.roundUp(WordFactory.unsigned(codeSize), CommittedMemoryProvider.get().getGranularity()); + UnsignedWord alignedAfterCodeOffset = UnsignedUtils.roundUp(Word.unsigned(codeSize), CommittedMemoryProvider.get().getGranularity()); assert alignedAfterCodeOffset.belowOrEqual(codeAndDataMemorySize); makeCodeMemoryExecutableWritable(code, alignedAfterCodeOffset); @@ -217,7 +217,7 @@ protected void doPrepareInstall(ReferenceAdjuster adjuster, CodeInfo codeInfo) { // remove write access from code if (!RuntimeCodeCache.Options.WriteableCodeCache.getValue()) { - makeCodeMemoryExecutableReadOnly(code, WordFactory.unsigned(codeSize)); + makeCodeMemoryExecutableReadOnly(code, Word.unsigned(codeSize)); } /* Write primitive constants to the buffer, record object constants with offsets */ diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/SubstrateMemoryAccessProviderImpl.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/SubstrateMemoryAccessProviderImpl.java index 4a5028027fef..d3d61d76a4d1 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/SubstrateMemoryAccessProviderImpl.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/SubstrateMemoryAccessProviderImpl.java @@ -26,10 +26,10 @@ import jdk.graal.compiler.core.common.CompressEncoding; import jdk.graal.compiler.word.BarrieredAccess; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.SignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.graal.meta.SubstrateMemoryAccessProvider; import com.oracle.svm.core.heap.ReferenceAccess; @@ -109,7 +109,7 @@ private static JavaConstant readObjectChecked(Constant baseConstant, long displa if (displacement < LayoutEncoding.getArrayBaseOffsetAsInt(layoutEncoding)) { /* Trying to read before the first array element. */ return null; - } else if (WordFactory.unsigned(displacement).aboveOrEqual(LayoutEncoding.getArrayElementOffset(layoutEncoding, ((Object[]) baseObject).length))) { + } else if (Word.unsigned(displacement).aboveOrEqual(LayoutEncoding.getArrayElementOffset(layoutEncoding, ((Object[]) baseObject).length))) { /* Trying to read after the last array element. */ return null; } else if ((displacement & (LayoutEncoding.getArrayIndexScale(layoutEncoding) - 1)) != 0) { @@ -124,7 +124,7 @@ private static JavaConstant readObjectChecked(Constant baseConstant, long displa } static JavaConstant readObjectUnchecked(Object baseObject, long displacement, boolean createCompressedConstant, boolean isVolatile) { - Object rawValue = isVolatile ? BarrieredAccess.readObjectVolatile(baseObject, WordFactory.signed(displacement)) : BarrieredAccess.readObject(baseObject, WordFactory.signed(displacement)); + Object rawValue = isVolatile ? BarrieredAccess.readObjectVolatile(baseObject, Word.signed(displacement)) : BarrieredAccess.readObject(baseObject, Word.signed(displacement)); return SubstrateObjectConstant.forObject(rawValue, createCompressedConstant); } @@ -150,7 +150,7 @@ private static JavaConstant readPrimitiveChecked(JavaKind kind, Constant baseCon } else if (displacement <= 0) { /* Trying to read before the object, or the hub. No need to look into the object. */ return null; - } else if (WordFactory.unsigned(displacement + bits / 8).aboveThan(LayoutEncoding.getMomentarySizeFromObject(baseObject))) { + } else if (Word.unsigned(displacement + bits / 8).aboveThan(LayoutEncoding.getMomentarySizeFromObject(baseObject))) { /* Trying to read after the end of the object. */ return null; } @@ -158,7 +158,7 @@ private static JavaConstant readPrimitiveChecked(JavaKind kind, Constant baseCon } static JavaConstant readPrimitiveUnchecked(JavaKind kind, Object baseObject, long displacement, int bits, boolean isVolatile) { - SignedWord offset = WordFactory.signed(displacement); + SignedWord offset = Word.signed(displacement); long rawValue; switch (bits) { case Byte.SIZE: diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/substitutions/GraalSubstitutions.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/substitutions/GraalSubstitutions.java index ba9e51aa25d9..670bc0cf9f0e 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/substitutions/GraalSubstitutions.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/substitutions/GraalSubstitutions.java @@ -34,6 +34,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.EconomicSet; import org.graalvm.collections.Equivalence; @@ -42,7 +43,6 @@ import org.graalvm.nativeimage.hosted.FieldValueTransformer; import org.graalvm.nativeimage.impl.IsolateSupport; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateTargetDescription; import com.oracle.svm.core.annotate.Alias; @@ -234,7 +234,7 @@ class GlobalAtomicLongAddressProvider implements FieldValueTransformer { @Override public Object transform(Object receiver, Object originalValue) { long initialValue = ((GlobalAtomicLong) receiver).getInitialValue(); - return CGlobalDataFactory.createWord(WordFactory.unsigned(initialValue), null, true); + return CGlobalDataFactory.createWord(Word.unsigned(initialValue), null, true); } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java index f3ba255ffc3f..6855785b4deb 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java @@ -28,10 +28,10 @@ import java.util.Locale; import java.util.stream.Collectors; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.graal.pointsto.reports.ReportUtils; import com.oracle.svm.core.SubstrateOptions; @@ -114,7 +114,7 @@ public void afterAnalysis(AfterAnalysisAccess access) { } if (!Platform.includedIn(Platform.WINDOWS.class)) { - CGlobalData isStaticBinaryMarker = CGlobalDataFactory.createWord(WordFactory.unsigned(SubstrateOptions.StaticExecutable.getValue() ? 1 : 0), STATIC_BINARY_MARKER_SYMBOL_NAME); + CGlobalData isStaticBinaryMarker = CGlobalDataFactory.createWord(Word.unsigned(SubstrateOptions.StaticExecutable.getValue() ? 1 : 0), STATIC_BINARY_MARKER_SYMBOL_NAME); CGlobalDataFeature.singleton().registerWithGlobalHiddenSymbol(isStaticBinaryMarker); } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/CIsolateDataFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/CIsolateDataFeature.java index 2e4ed9de73b8..8c72ba43ab46 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/CIsolateDataFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/CIsolateDataFeature.java @@ -36,8 +36,8 @@ import com.oracle.svm.core.util.UnsignedUtils; import com.oracle.svm.core.util.VMError; +import jdk.graal.compiler.word.Word; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; @AutomaticallyRegisteredFeature public class CIsolateDataFeature implements InternalFeature { @@ -62,13 +62,13 @@ private Object replaceObject(Object obj) { @Override public void afterAnalysis(AfterAnalysisAccess access) { - UnsignedWord offset = WordFactory.zero(); + UnsignedWord offset = Word.zero(); CIsolateData[] entries = usedEntries.values().toArray(new CIsolateData[0]); Arrays.sort(entries, Comparator.comparing(CIsolateData::getSize).thenComparing(CIsolateData::getName)); for (CIsolateData entry : entries) { - offset = UnsignedUtils.roundUp(offset, WordFactory.unsigned(CIsolateDataStorage.ALIGNMENT)); + offset = UnsignedUtils.roundUp(offset, Word.unsigned(CIsolateDataStorage.ALIGNMENT)); entry.setOffset(offset); - offset = offset.add(WordFactory.unsigned(entry.getSize())); + offset = offset.add(Word.unsigned(entry.getSize())); } CIsolateDataStorage.singleton().setSize(offset); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/NativeLibraries.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/NativeLibraries.java index c31572f879af..07a12c3fa930 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/NativeLibraries.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/NativeLibraries.java @@ -65,7 +65,7 @@ import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; +import org.graalvm.word.WordFactory; import com.oracle.graal.pointsto.infrastructure.WrappedElement; import com.oracle.graal.pointsto.meta.AnalysisType; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageCodeCache.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageCodeCache.java index 97ee5f30f4c1..c0d750c2cd1c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageCodeCache.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageCodeCache.java @@ -49,12 +49,12 @@ import java.util.Set; import java.util.stream.Collectors; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.Pair; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.c.function.CFunctionPointer; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.graal.pointsto.AbstractAnalysisEngine; import com.oracle.graal.pointsto.BigBang; @@ -290,7 +290,7 @@ public int getAlignedConstantsSize() { } public void buildRuntimeMetadata(DebugContext debug, SnippetReflectionProvider snippetReflectionProvider) { - buildRuntimeMetadata(debug, snippetReflectionProvider, new MethodPointer(getFirstCompilation().getLeft(), true), WordFactory.signed(getCodeAreaSize())); + buildRuntimeMetadata(debug, snippetReflectionProvider, new MethodPointer(getFirstCompilation().getLeft(), true), Word.signed(getCodeAreaSize())); } static class HostedConstantAccess extends ConstantAccess { @@ -528,7 +528,7 @@ protected HostedImageCodeInfo installCodeInfo(SnippetReflectionProvider snippetR imageCodeInfo.setCodeStart(firstMethod); imageCodeInfo.setCodeSize(codeSize); imageCodeInfo.setDataOffset(codeSize); - imageCodeInfo.setDataSize(WordFactory.zero()); // (only for data immediately after code) + imageCodeInfo.setDataSize(Word.zero()); // (only for data immediately after code) imageCodeInfo.setCodeAndDataMemorySize(codeSize); return imageCodeInfo; } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoFeature.java index 97f3c213bb14..818cb347bde3 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoFeature.java @@ -31,10 +31,10 @@ import java.util.function.Supplier; import com.oracle.svm.core.ReservedRegisters; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.graal.pointsto.util.GraalAccess; import com.oracle.graal.pointsto.util.Timer; @@ -118,11 +118,11 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { access.registerAsAccessed(ReflectionUtil.lookupField(ClassLoader.class, "nameAndId")); CompressEncoding compressEncoding = ImageSingletons.lookup(CompressEncoding.class); - CGlobalData compressionShift = CGlobalDataFactory.createWord(WordFactory.signed(compressEncoding.getShift()), "__svm_compression_shift"); - CGlobalData useHeapBase = CGlobalDataFactory.createWord(WordFactory.unsigned(compressEncoding.hasBase() ? 1 : 0), "__svm_use_heap_base"); - CGlobalData reservedBitsMask = CGlobalDataFactory.createWord(WordFactory.unsigned(Heap.getHeap().getObjectHeader().getReservedBitsMask()), "__svm_reserved_bits_mask"); - CGlobalData objectAlignment = CGlobalDataFactory.createWord(WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment()), "__svm_object_alignment"); - CGlobalData heapBaseRegnum = CGlobalDataFactory.createWord(WordFactory.unsigned(ReservedRegisters.singleton().getHeapBaseRegister().number), "__svm_heap_base_regnum"); + CGlobalData compressionShift = CGlobalDataFactory.createWord(Word.signed(compressEncoding.getShift()), "__svm_compression_shift"); + CGlobalData useHeapBase = CGlobalDataFactory.createWord(Word.unsigned(compressEncoding.hasBase() ? 1 : 0), "__svm_use_heap_base"); + CGlobalData reservedBitsMask = CGlobalDataFactory.createWord(Word.unsigned(Heap.getHeap().getObjectHeader().getReservedBitsMask()), "__svm_reserved_bits_mask"); + CGlobalData objectAlignment = CGlobalDataFactory.createWord(Word.unsigned(ConfigurationValues.getObjectLayout().getAlignment()), "__svm_object_alignment"); + CGlobalData heapBaseRegnum = CGlobalDataFactory.createWord(Word.unsigned(ReservedRegisters.singleton().getHeapBaseRegister().number), "__svm_heap_base_regnum"); CGlobalDataFeature.singleton().registerWithGlobalHiddenSymbol(compressionShift); CGlobalDataFeature.singleton().registerWithGlobalHiddenSymbol(useHeapBase); CGlobalDataFeature.singleton().registerWithGlobalHiddenSymbol(reservedBitsMask); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/imagelayer/ImageLayerSectionFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/imagelayer/ImageLayerSectionFeature.java index 19812c7f3d2d..08d2f081ccc3 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/imagelayer/ImageLayerSectionFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/imagelayer/ImageLayerSectionFeature.java @@ -24,7 +24,7 @@ */ package com.oracle.svm.hosted.imagelayer; -import static jdk.graal.compiler.word.WordFactory.signed; +import static jdk.graal.compiler.word.Word.signed; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -38,7 +38,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.SignedWord; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.objectfile.BasicProgbitsSectionImpl; import com.oracle.objectfile.ObjectFile; @@ -154,8 +153,8 @@ private static ImageLayerSectionImpl createImageLayerSection() { cachedImageHeapRelocations = CGlobalDataFactory.forSymbol(CACHED_IMAGE_HEAP_RELOCATIONS_NAME); } else if (ImageLayerBuildingSupport.buildingApplicationLayer()) { cachedImageFDs = CGlobalDataFactory.createBytes(() -> createWords(DynamicImageLayerInfo.singleton().numLayers, UNASSIGNED_FD), CACHED_IMAGE_FDS_NAME); - cachedImageHeapOffsets = CGlobalDataFactory.createBytes(() -> createWords(DynamicImageLayerInfo.singleton().numLayers, WordFactory.zero()), CACHED_IMAGE_HEAP_OFFSETS_NAME); - cachedImageHeapRelocations = CGlobalDataFactory.createBytes(() -> createWords(DynamicImageLayerInfo.singleton().numLayers, WordFactory.zero()), CACHED_IMAGE_HEAP_RELOCATIONS_NAME); + cachedImageHeapOffsets = CGlobalDataFactory.createBytes(() -> createWords(DynamicImageLayerInfo.singleton().numLayers, Word.zero()), CACHED_IMAGE_HEAP_OFFSETS_NAME); + cachedImageHeapRelocations = CGlobalDataFactory.createBytes(() -> createWords(DynamicImageLayerInfo.singleton().numLayers, Word.zero()), CACHED_IMAGE_HEAP_RELOCATIONS_NAME); } else { cachedImageFDs = null; cachedImageHeapOffsets = null; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAccessFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAccessFeature.java index 19fe964cddae..ecd895a00128 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAccessFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAccessFeature.java @@ -43,6 +43,7 @@ import java.util.function.Predicate; import java.util.stream.Stream; +import jdk.graal.compiler.word.Word; import org.graalvm.collections.EconomicSet; import org.graalvm.collections.Equivalence; import org.graalvm.collections.Pair; @@ -53,7 +54,6 @@ import org.graalvm.nativeimage.impl.ConfigurationCondition; import org.graalvm.nativeimage.impl.RuntimeJNIAccessSupport; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.graal.pointsto.BigBang; import com.oracle.graal.pointsto.infrastructure.ResolvedSignature; @@ -603,7 +603,7 @@ private static void finishMethodBeforeCompilation(JNICallableJavaMethod method, newObjectTarget = new MethodPointer(hUniverse.lookup(aUniverse.lookup(method.newObjectMethod))); } else if (method.targetMethod.isConstructor()) { assert method.targetMethod.getDeclaringClass().isAbstract(); - newObjectTarget = WordFactory.signed(JNIAccessibleMethod.NEW_OBJECT_INVALID_FOR_ABSTRACT_TYPE); + newObjectTarget = Word.signed(JNIAccessibleMethod.NEW_OBJECT_INVALID_FOR_ABSTRACT_TYPE); } CodePointer callWrapper = new MethodPointer(hUniverse.lookup(aUniverse.lookup(method.callWrapper))); CodePointer varargs = new MethodPointer(hUniverse.lookup(aUniverse.lookup(method.variantWrappers.varargs))); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/CInterfaceInvocationPlugin.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/CInterfaceInvocationPlugin.java index ac7ed9fc7f73..ffbd5030f59f 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/CInterfaceInvocationPlugin.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/CInterfaceInvocationPlugin.java @@ -29,7 +29,7 @@ import java.util.Arrays; -import jdk.graal.compiler.word.WordFactory; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.function.CFunctionPointer; @@ -649,7 +649,7 @@ private static Object createReturnObject(Class returnType, long value) { } else if (returnType == Long.class) { return value; } else if (WordBase.class.isAssignableFrom(returnType)) { - return WordFactory.unsigned(value); + return Word.unsigned(value); } else { throw VMError.shouldNotReachHere("Unexpected returnType: " + returnType.getName()); } diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/JVMFuncFallbackTest.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/JVMFuncFallbackTest.java index 79e830c02e72..bf68dd114989 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/JVMFuncFallbackTest.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/JVMFuncFallbackTest.java @@ -24,12 +24,12 @@ */ package com.oracle.svm.test; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CFunction; import org.graalvm.nativeimage.c.function.CLibrary; import org.graalvm.nativeimage.impl.InternalPlatform; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import org.junit.Test; // Checkstyle: stop @@ -43,7 +43,7 @@ public void testImageCodeMethods() { * Cause image to link to JVM_IHashCode. This will trigger a linker error if libjvm.a * does not contain the autogenerated JVM_* fallbacks. */ - Jvm.JVM_IHashCode(WordFactory.nullPointer()); + Jvm.JVM_IHashCode(Word.nullPointer()); } } } diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/StackTraceTests.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/StackTraceTests.java index f9d72fa95c2a..7268c6547812 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/StackTraceTests.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/StackTraceTests.java @@ -27,7 +27,7 @@ import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertSame; -import jdk.graal.compiler.word.WordFactory; +import jdk.graal.compiler.word.Word; import org.junit.Test; import com.oracle.svm.core.NeverInline; @@ -66,7 +66,7 @@ public static void c(Type type) { assertSame(B.class, callerClass); } if (type == Type.GET_STACKTRACE) { - StackTraceElement[] stackTrace = StackTraceUtils.getCurrentThreadStackTrace(true, KnownIntrinsics.readCallerStackPointer(), WordFactory.nullPointer()); + StackTraceElement[] stackTrace = StackTraceUtils.getCurrentThreadStackTrace(true, KnownIntrinsics.readCallerStackPointer(), Word.nullPointer()); assertTrue(stackTrace.length > 0); assertSame(B.class.getName(), stackTrace[0].getClassName()); assertSame(A.class.getName(), stackTrace[1].getClassName()); diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestNmtEvents.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestNmtEvents.java index 76a9e7f229cf..f0978371c605 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestNmtEvents.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestNmtEvents.java @@ -30,8 +30,8 @@ import java.util.List; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import org.junit.Test; import com.oracle.svm.core.jfr.JfrEvent; @@ -54,7 +54,7 @@ public void test() throws Throwable { }; Recording recording = startRecording(events); - Pointer ptr = NativeMemory.malloc(WordFactory.unsigned(ALLOCATION_SIZE), NmtCategory.Code); + Pointer ptr = NativeMemory.malloc(Word.unsigned(ALLOCATION_SIZE), NmtCategory.Code); /* Force a chunk rotation to trigger periodic event emission. */ recording.dump(createTempJfrFile()); diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/JfrOldObjectTest.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/JfrOldObjectTest.java index ddf2c15a2c4a..a873ee5d79c3 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/JfrOldObjectTest.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/JfrOldObjectTest.java @@ -36,7 +36,7 @@ import java.util.List; import java.util.Map; -import jdk.graal.compiler.word.WordFactory; +import jdk.graal.compiler.word.Word; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -85,7 +85,7 @@ protected void testSampling(Object obj, int arrayLength, EventValidator validato boolean success; long endTime = System.currentTimeMillis() + TimeUtils.secondsToMillis(5); do { - success = SubstrateJVM.getOldObjectProfiler().sample(obj, WordFactory.unsigned(1024 * 1024 * 1024), arrayLength); + success = SubstrateJVM.getOldObjectProfiler().sample(obj, Word.unsigned(1024 * 1024 * 1024), arrayLength); } while (!success && System.currentTimeMillis() < endTime); Assert.assertTrue("Timed out waiting for sampling to complete", success); diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java index ae76897a4e15..86b29c49a243 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/oldobject/TestOldObjectProfiler.java @@ -33,8 +33,8 @@ import java.util.Collections; import java.util.List; +import jdk.graal.compiler.word.Word; import jdk.jfr.Recording; -import jdk.graal.compiler.word.WordFactory; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -210,7 +210,7 @@ private static List sampleObjects(JfrOldObjectProfiler profiler, int TinyObject obj = new TinyObject(value); result.add(obj); - boolean success = JfrOldObjectProfiler.TestingBackdoor.sample(profiler, obj, WordFactory.unsigned(value), Integer.MIN_VALUE); + boolean success = JfrOldObjectProfiler.TestingBackdoor.sample(profiler, obj, Word.unsigned(value), Integer.MIN_VALUE); assertTrue(success); } return result; diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/nmt/NativeMemoryTrackingTests.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/nmt/NativeMemoryTrackingTests.java index 0b64dd2fde47..61747876e0a8 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/nmt/NativeMemoryTrackingTests.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/nmt/NativeMemoryTrackingTests.java @@ -29,8 +29,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; -import jdk.graal.compiler.word.WordFactory; import org.junit.Test; import com.oracle.svm.core.memory.NativeMemory; @@ -75,7 +75,7 @@ public void testRealloc() { assertEquals(getUsedMemory(), 16 * K); assertTrue(getUsedMemory() > 0); - Pointer reallocPtr = NativeMemory.realloc(ptr, WordFactory.unsigned(8 * K), NmtCategory.Code); + Pointer reallocPtr = NativeMemory.realloc(ptr, Word.unsigned(8 * K), NmtCategory.Code); assertEquals(8 * K, getUsedMemory()); NativeMemory.free(reallocPtr); @@ -95,10 +95,10 @@ public void testPeakTracking() { assertEquals(2 * M, peakUsed); NativeMemory.free(ptr1); - ptr1 = WordFactory.nullPointer(); + ptr1 = Word.nullPointer(); NativeMemory.free(ptr2); - ptr2 = WordFactory.nullPointer(); + ptr2 = Word.nullPointer(); assertEquals(0, getUsedMemory()); assertEquals(2 * M, NativeMemoryTracking.singleton().getPeakMallocMemory(NmtCategory.Code)); @@ -108,7 +108,7 @@ public void testPeakTracking() { assertEquals(3 * M, peakUsed); NativeMemory.free(ptr3); - ptr3 = WordFactory.nullPointer(); + ptr3 = Word.nullPointer(); assertEquals(0, getUsedMemory()); assertEquals(3 * M, NativeMemoryTracking.singleton().getPeakMallocMemory(NmtCategory.Code)); diff --git a/substratevm/src/com.oracle.svm.truffle.nfi.posix/src/com/oracle/svm/truffle/nfi/posix/PosixTruffleNFIFeature.java b/substratevm/src/com.oracle.svm.truffle.nfi.posix/src/com/oracle/svm/truffle/nfi/posix/PosixTruffleNFIFeature.java index fa83d8d93b69..96e24263cb94 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi.posix/src/com/oracle/svm/truffle/nfi/posix/PosixTruffleNFIFeature.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi.posix/src/com/oracle/svm/truffle/nfi/posix/PosixTruffleNFIFeature.java @@ -26,13 +26,13 @@ import static com.oracle.svm.core.posix.headers.Dlfcn.GNUExtensions.LM_ID_NEWLM; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.c.libc.GLibC; @@ -121,8 +121,8 @@ private static PointerBase loadLibraryInNamespace(long nativeContext, String nam synchronized (context) { namespaceId = context.isolatedNamespaceId; if (namespaceId == 0) { - PointerBase handle = dlmopen(WordFactory.signed(LM_ID_NEWLM()), name, mode); - if (handle.equal(WordFactory.zero())) { + PointerBase handle = dlmopen(Word.signed(LM_ID_NEWLM()), name, mode); + if (handle.equal(Word.zero())) { return handle; } @@ -143,7 +143,7 @@ private static PointerBase loadLibraryInNamespace(long nativeContext, String nam // Namespace already created. assert namespaceId != 0; - return dlmopen(WordFactory.signed(namespaceId), name, mode); + return dlmopen(Word.signed(namespaceId), name, mode); } @Override @@ -154,7 +154,7 @@ protected long loadLibraryImpl(long nativeContext, String name, int flags) { } else { handle = PosixUtils.dlopen(name, flags); } - if (handle.equal(WordFactory.zero())) { + if (handle.equal(Word.zero())) { CompilerDirectives.transferToInterpreter(); String error = PosixUtils.dlerror(); throw SubstrateUtil.cast(new Target_com_oracle_truffle_nfi_backend_libffi_NFIUnsatisfiedLinkError(error), AbstractTruffleException.class); @@ -164,7 +164,7 @@ protected long loadLibraryImpl(long nativeContext, String name, int flags) { @Override protected void freeLibraryImpl(long library) { - Dlfcn.dlclose(WordFactory.pointer(library)); + Dlfcn.dlclose(Word.pointer(library)); } @Override @@ -177,10 +177,10 @@ protected long lookupImpl(long nativeContext, long library, String name) { if (library == 0) { ret = nativeLibrarySupport.findBuiltinSymbol(name); } else { - ret = PosixUtils.dlsym(WordFactory.pointer(library), name); + ret = PosixUtils.dlsym(Word.pointer(library), name); } - if (ret.equal(WordFactory.zero())) { + if (ret.equal(Word.zero())) { CompilerDirectives.transferToInterpreter(); String error = PosixUtils.dlerror(); if (error != null) { diff --git a/substratevm/src/com.oracle.svm.truffle.nfi.windows/src/com/oracle/svm/truffle/nfi/windows/WindowsTruffleNFIFeature.java b/substratevm/src/com.oracle.svm.truffle.nfi.windows/src/com/oracle/svm/truffle/nfi/windows/WindowsTruffleNFIFeature.java index 2244783c638b..e16773ab30f7 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi.windows/src/com/oracle/svm/truffle/nfi/windows/WindowsTruffleNFIFeature.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi.windows/src/com/oracle/svm/truffle/nfi/windows/WindowsTruffleNFIFeature.java @@ -24,12 +24,12 @@ */ package com.oracle.svm.truffle.nfi.windows; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.feature.InternalFeature; @@ -76,7 +76,7 @@ protected long loadLibraryImpl(long nativeContext, String name, int flags) { String dllPath = name; HMODULE dlhandle; try (CTypeConversion.CCharPointerHolder dllpathPin = CTypeConversion.toCString(dllPath)) { - dlhandle = LibLoaderAPI.LoadLibraryExA(dllpathPin.get(), WordFactory.nullPointer(), flags); + dlhandle = LibLoaderAPI.LoadLibraryExA(dllpathPin.get(), Word.nullPointer(), flags); } if (dlhandle.isNull()) { CompilerDirectives.transferToInterpreter(); @@ -87,7 +87,7 @@ protected long loadLibraryImpl(long nativeContext, String name, int flags) { @Override protected void freeLibraryImpl(long library) { - LibLoaderAPI.FreeLibrary(WordFactory.pointer(library)); + LibLoaderAPI.FreeLibrary(Word.pointer(library)); } @Override @@ -101,7 +101,7 @@ protected long lookupImpl(long nativeContext, long library, String name) { ret = nativeLibrarySupport.findBuiltinSymbol(name); } else { try (CTypeConversion.CCharPointerHolder symbol = CTypeConversion.toCString(name)) { - ret = LibLoaderAPI.GetProcAddress(WordFactory.pointer(library), symbol.get()); + ret = LibLoaderAPI.GetProcAddress(Word.pointer(library), symbol.get()); } } diff --git a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/LocalNativeScope.java b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/LocalNativeScope.java index 01ed420e1c7a..ace2774f61c4 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/LocalNativeScope.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/LocalNativeScope.java @@ -28,7 +28,6 @@ import jdk.graal.compiler.word.Word; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.handles.PrimitiveArrayView; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -67,7 +66,7 @@ public TruffleObjectHandle createLocalHandle(Object obj) { localHandles.add(obj); assert localHandles.get(idx) == obj; - return (TruffleObjectHandle) WordFactory.unsigned(idx).shiftLeft(16).or(scopeId & 0xFFFF).not(); + return (TruffleObjectHandle) Word.unsigned(idx).shiftLeft(16).or(scopeId & 0xFFFF).not(); } private LocalNativeScope findScope(short id) { diff --git a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeAPIImpl.java b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeAPIImpl.java index aace5c1e849d..bfd072312102 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeAPIImpl.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeAPIImpl.java @@ -24,13 +24,13 @@ */ package com.oracle.svm.truffle.nfi; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.function.CEntryPoint.Publish; import org.graalvm.nativeimage.c.function.CEntryPointLiteral; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; @@ -155,7 +155,7 @@ static boolean exceptionCheck(NativeTruffleEnv env) { static NativeTruffleEnv getTruffleEnv(NativeTruffleContext context) { TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class); Target_com_oracle_truffle_nfi_backend_libffi_LibFFIContext ctx = support.resolveContextHandle(context.contextHandle()); - return WordFactory.pointer(ctx.getNativeEnv()); + return Word.pointer(ctx.getNativeEnv()); } static class GetTruffleEnvPrologue implements CEntryPointOptions.Prologue { @@ -171,9 +171,9 @@ static NativeTruffleEnv attachCurrentThread(NativeTruffleContext context) { TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class); Target_com_oracle_truffle_nfi_backend_libffi_LibFFIContext ctx = support.resolveContextHandle(context.contextHandle()); if (ctx.attachThread()) { - return WordFactory.pointer(ctx.getNativeEnv()); + return Word.pointer(ctx.getNativeEnv()); } else { - return WordFactory.nullPointer(); + return Word.nullPointer(); } } diff --git a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeClosure.java b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeClosure.java index 4d797318ce9a..9a4365e74057 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeClosure.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeClosure.java @@ -30,6 +30,7 @@ import java.lang.ref.WeakReference; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CEntryPoint; @@ -42,7 +43,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.Uninterruptible; @@ -144,7 +144,7 @@ static Target_com_oracle_truffle_nfi_backend_libffi_ClosureNativePointer prepare data.setEnvArgIdx(envArgIdx); PointerBase code = codePtr.read(); - LibFFI.ffi_prep_closure_loc(data.ffiClosure(), WordFactory.pointer(signature.cif), callback, data, code); + LibFFI.ffi_prep_closure_loc(data.ffiClosure(), Word.pointer(signature.cif), callback, data, code); return ctx.createClosureNativePointer(data.rawValue(), code.rawValue(), callTarget, signature, receiver); } @@ -204,10 +204,10 @@ private static NativeClosure lookup(ClosureData data) { private static PointerBase serializeStringRet(Object retValue) { if (retValue == null) { - return WordFactory.zero(); + return Word.zero(); } else if (retValue instanceof Target_com_oracle_truffle_nfi_backend_libffi_NativeString) { Target_com_oracle_truffle_nfi_backend_libffi_NativeString nativeString = (Target_com_oracle_truffle_nfi_backend_libffi_NativeString) retValue; - return WordFactory.pointer(nativeString.nativePointer); + return Word.pointer(nativeString.nativePointer); } else if (retValue instanceof String) { byte[] utf8 = TruffleNFISupport.javaStringToUtf8((String) retValue); try (PrimitiveArrayView ref = PrimitiveArrayView.createForReading(utf8)) { @@ -216,7 +216,7 @@ private static PointerBase serializeStringRet(Object retValue) { } } else { // unsupported type - return WordFactory.zero(); + return Word.zero(); } } @@ -469,7 +469,7 @@ private static void doInvokeClosureObjectRet(WordPointer ret, WordPointer args, try { Object obj = closure.call(args, null); if (obj == null) { - ret.write(WordFactory.zero()); + ret.write(Word.zero()); } else { TruffleObjectHandle handle = ImageSingletons.lookup(TruffleNFISupport.class).createGlobalHandle(obj); ret.write(handle); diff --git a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeSignature.java b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeSignature.java index 2cc23bb89e11..c7b8ff51ab90 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeSignature.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/NativeSignature.java @@ -27,6 +27,7 @@ import static com.oracle.svm.truffle.nfi.Target_com_oracle_truffle_nfi_backend_libffi_NativeArgumentBuffer_TypeTag.getOffset; import static com.oracle.svm.truffle.nfi.Target_com_oracle_truffle_nfi_backend_libffi_NativeArgumentBuffer_TypeTag.getTag; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.UnmanagedMemory; import org.graalvm.nativeimage.c.CContext; import org.graalvm.nativeimage.c.struct.CFieldAddress; @@ -37,7 +38,6 @@ import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.WordBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.Uninterruptible; @@ -74,7 +74,7 @@ static CifData prepareArgs(int argCount, Target_com_oracle_truffle_nfi_backend_l CifData data = UnmanagedMemory.malloc(SizeOf.get(CifData.class) + argCount * SizeOf.get(ffi_type_array.class)); for (int i = 0; i < argCount; i++) { - data.args().write(i, WordFactory.pointer(args[i].type)); + data.args().write(i, Word.pointer(args[i].type)); } return data; @@ -141,7 +141,7 @@ static void execute(NativeTruffleContext ctx, ffi_cif cif, PointerBase ret, long } } - ffiCall(cif, WordFactory.pointer(functionPointer), ret, argPtrs, ErrnoMirror.errnoMirror.getAddress()); + ffiCall(cif, Word.pointer(functionPointer), ret, argPtrs, ErrnoMirror.errnoMirror.getAddress()); } finally { UnmanagedMemory.free(argPtrs); } diff --git a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_ClosureNativePointer.java b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_ClosureNativePointer.java index 5dcb301407d2..def48b3190d0 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_ClosureNativePointer.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_ClosureNativePointer.java @@ -24,8 +24,8 @@ */ package com.oracle.svm.truffle.nfi; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; @@ -36,7 +36,7 @@ final class Target_com_oracle_truffle_nfi_backend_libffi_ClosureNativePointer { @Substitute private static void freeClosure(long closure) { - com.oracle.svm.truffle.nfi.LibFFI.ClosureData data = WordFactory.pointer(closure); + com.oracle.svm.truffle.nfi.LibFFI.ClosureData data = Word.pointer(closure); ImageSingletons.lookup(TruffleNFISupport.class).destroyClosureHandle(data.nativeClosureHandle()); LibFFI.ffi_closure_free(data); } diff --git a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_LibFFIContext.java b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_LibFFIContext.java index 3d5ace225422..0f9958e37036 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_LibFFIContext.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_LibFFIContext.java @@ -26,13 +26,13 @@ import static com.oracle.svm.truffle.nfi.NativeSignature.ExecuteHelper; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.UnmanagedMemory; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.CLongPointer; import org.graalvm.nativeimage.c.type.WordPointer; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.RecomputeFieldValue; @@ -102,7 +102,7 @@ private long initializeNativeContext() { @Substitute private static void disposeNativeContext(long context) { TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class); - NativeTruffleContext ctx = WordFactory.pointer(context); + NativeTruffleContext ctx = Word.pointer(context); support.destroyContextHandle(ctx.contextHandle()); UnmanagedMemory.free(ctx); } @@ -118,12 +118,12 @@ private static long initializeNativeEnvV2(long context, @SuppressWarnings("unuse @Substitute private static void disposeNativeEnvV2(long env) { - UnmanagedMemory.free(WordFactory.pointer(env)); + UnmanagedMemory.free(Word.pointer(env)); } @Substitute private static long initializeNativeEnv(long context) { - NativeTruffleContext ctx = WordFactory.pointer(context); + NativeTruffleContext ctx = Word.pointer(context); NativeTruffleEnv env = UnmanagedMemory.malloc(SizeOf.get(NativeTruffleEnv.class)); NFIInitialization.initializeEnv(env, ctx); return env.rawValue(); @@ -157,7 +157,7 @@ Target_com_oracle_truffle_nfi_backend_libffi_ClosureNativePointer allocateClosur @SuppressWarnings("static-method") long prepareSignature(Target_com_oracle_truffle_nfi_backend_libffi_LibFFIType retType, int argCount, Target_com_oracle_truffle_nfi_backend_libffi_LibFFIType... args) { CifData data = PrepareHelper.prepareArgs(argCount, args); - int ret = LibFFI.ffi_prep_cif(data.cif(), LibFFI.FFI_DEFAULT_ABI(), WordFactory.unsigned(argCount), WordFactory.pointer(retType.type), data.args()); + int ret = LibFFI.ffi_prep_cif(data.cif(), LibFFI.FFI_DEFAULT_ABI(), Word.unsigned(argCount), Word.pointer(retType.type), data.args()); return PrepareHelper.checkRet(data, ret); } @@ -165,7 +165,7 @@ long prepareSignature(Target_com_oracle_truffle_nfi_backend_libffi_LibFFIType re @SuppressWarnings("static-method") long prepareSignatureVarargs(Target_com_oracle_truffle_nfi_backend_libffi_LibFFIType retType, int argCount, int nFixedArgs, Target_com_oracle_truffle_nfi_backend_libffi_LibFFIType... args) { CifData data = PrepareHelper.prepareArgs(argCount, args); - int ret = LibFFI.ffi_prep_cif_var(data.cif(), LibFFI.FFI_DEFAULT_ABI(), WordFactory.unsigned(nFixedArgs), WordFactory.unsigned(argCount), WordFactory.pointer(retType.type), data.args()); + int ret = LibFFI.ffi_prep_cif_var(data.cif(), LibFFI.FFI_DEFAULT_ABI(), Word.unsigned(nFixedArgs), Word.unsigned(argCount), Word.pointer(retType.type), data.args()); return PrepareHelper.checkRet(data, ret); } @@ -174,8 +174,8 @@ long prepareSignatureVarargs(Target_com_oracle_truffle_nfi_backend_libffi_LibFFI void executeNative(long cif, long functionPointer, byte[] primArgs, int patchCount, int[] patchOffsets, Object[] objArgs, byte[] ret) { try (LocalNativeScope scope = TruffleNFISupport.createLocalScope(patchCount); PrimitiveArrayView retBuffer = PrimitiveArrayView.createForReadingAndWriting(ret)) { - NativeTruffleContext ctx = WordFactory.pointer(nativeContext); - LibFFI.ffi_cif ffiCif = WordFactory.pointer(cif); + NativeTruffleContext ctx = Word.pointer(nativeContext); + LibFFI.ffi_cif ffiCif = Word.pointer(cif); ExecuteHelper.execute(ctx, ffiCif, retBuffer.addressOfArrayElement(0), functionPointer, primArgs, patchCount, patchOffsets, objArgs, scope); } } @@ -184,8 +184,8 @@ void executeNative(long cif, long functionPointer, byte[] primArgs, int patchCou @TruffleBoundary long executePrimitive(long cif, long functionPointer, byte[] primArgs, int patchCount, int[] patchOffsets, Object[] objArgs) { try (LocalNativeScope scope = TruffleNFISupport.createLocalScope(patchCount)) { - NativeTruffleContext ctx = WordFactory.pointer(nativeContext); - ffi_cif ffiCif = WordFactory.pointer(cif); + NativeTruffleContext ctx = Word.pointer(nativeContext); + ffi_cif ffiCif = Word.pointer(cif); CLongPointer retPtr = StackValue.get(8); ExecuteHelper.execute(ctx, ffiCif, retPtr, functionPointer, primArgs, patchCount, patchOffsets, objArgs, scope); return retPtr.read(); @@ -196,8 +196,8 @@ long executePrimitive(long cif, long functionPointer, byte[] primArgs, int patch @TruffleBoundary Object executeObject(long cif, long functionPointer, byte[] primArgs, int patchCount, int[] patchOffsets, Object[] objArgs) { try (LocalNativeScope scope = TruffleNFISupport.createLocalScope(patchCount)) { - NativeTruffleContext ctx = WordFactory.pointer(nativeContext); - ffi_cif ffiCif = WordFactory.pointer(cif); + NativeTruffleContext ctx = Word.pointer(nativeContext); + ffi_cif ffiCif = Word.pointer(cif); WordPointer retPtr = StackValue.get(8); ExecuteHelper.execute(ctx, ffiCif, retPtr, functionPointer, primArgs, patchCount, patchOffsets, objArgs, scope); return ImageSingletons.lookup(TruffleNFISupport.class).resolveHandle(retPtr.read()); diff --git a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_NativeAllocation.java b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_NativeAllocation.java index 73c5215fa795..1479fd574764 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_NativeAllocation.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_NativeAllocation.java @@ -32,15 +32,15 @@ import java.lang.ref.ReferenceQueue; import java.util.concurrent.atomic.AtomicReference; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.UnmanagedMemory; -import jdk.graal.compiler.word.WordFactory; @TargetClass(className = "com.oracle.truffle.nfi.backend.libffi.NativeAllocation", onlyWith = TruffleNFIFeature.IsEnabled.class) final class Target_com_oracle_truffle_nfi_backend_libffi_NativeAllocation { @Substitute static void free(long pointer) { - UnmanagedMemory.free(WordFactory.pointer(pointer)); + UnmanagedMemory.free(Word.pointer(pointer)); } /** diff --git a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_NativeString.java b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_NativeString.java index 41c20b07d175..2071ab8f88fe 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_NativeString.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/Target_com_oracle_truffle_nfi_backend_libffi_NativeString.java @@ -24,7 +24,7 @@ */ package com.oracle.svm.truffle.nfi; -import jdk.graal.compiler.word.WordFactory; +import jdk.graal.compiler.word.Word; import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.Substitute; @@ -39,6 +39,6 @@ final class Target_com_oracle_truffle_nfi_backend_libffi_NativeString { @Substitute @TruffleBoundary static String toJavaString(long pointer) { - return TruffleNFISupport.utf8ToJavaString(WordFactory.pointer(pointer)); + return TruffleNFISupport.utf8ToJavaString(Word.pointer(pointer)); } } diff --git a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/TruffleNFISupport.java b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/TruffleNFISupport.java index 1224ed160d98..ab9b1eda8537 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/TruffleNFISupport.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/TruffleNFISupport.java @@ -28,6 +28,7 @@ import java.nio.CharBuffer; import java.nio.charset.Charset; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.ObjectHandle; import org.graalvm.nativeimage.ObjectHandles; @@ -35,7 +36,6 @@ import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.threadlocal.FastThreadLocalFactory; @@ -126,7 +126,7 @@ public void destroyContextHandle(TruffleContextHandle handle) { @TruffleBoundary public static String utf8ToJavaString(CCharPointer str) { - if (str.equal(WordFactory.zero())) { + if (str.equal(Word.zero())) { return null; } else { UnsignedWord len = SubstrateUtil.strlen(str); @@ -207,7 +207,7 @@ public static long lookup(long nativeContext, long library, String name) { protected static Target_com_oracle_truffle_nfi_backend_libffi_LibFFIContext getContext(long nativeContext) { TruffleNFISupport truffleNFISupport = ImageSingletons.lookup(TruffleNFISupport.class); - NativeAPI.NativeTruffleContext ctx = WordFactory.pointer(nativeContext); + NativeAPI.NativeTruffleContext ctx = Word.pointer(nativeContext); return truffleNFISupport.resolveContextHandle(ctx.contextHandle()); } } diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTargetInstalledCode.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTargetInstalledCode.java index 7a3bdeb08eb6..c56f56a1c47f 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTargetInstalledCode.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTargetInstalledCode.java @@ -26,7 +26,7 @@ import java.lang.ref.WeakReference; -import jdk.graal.compiler.word.WordFactory; +import jdk.graal.compiler.word.Word; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.code.CodeInfo; @@ -198,7 +198,7 @@ public void invalidateWithoutDeoptimization() { private void invalidateWithoutDeoptimization0() { this.entryPoint = 0; - UntetheredCodeInfo untetheredInfo = CodeInfoTable.lookupCodeInfo(WordFactory.pointer(this.address)); + UntetheredCodeInfo untetheredInfo = CodeInfoTable.lookupCodeInfo(Word.pointer(this.address)); assert untetheredInfo.isNonNull() && !UntetheredCodeInfoAccess.isAOTImageCode(untetheredInfo); Object tether = CodeInfoAccess.acquireTether(untetheredInfo); @@ -226,7 +226,7 @@ static Object doInvoke(SubstrateOptimizedCallTarget callTarget, Object[] args) { */ long start = callTarget.installedCode.entryPoint; if (start != 0) { - SubstrateOptimizedCallTarget.CallBoundaryFunctionPointer target = WordFactory.pointer(start); + SubstrateOptimizedCallTarget.CallBoundaryFunctionPointer target = Word.pointer(start); return target.invoke(callTarget, args); } else { return callTarget.invokeCallBoundary(args); @@ -238,7 +238,7 @@ boolean isValidLastTier() { if (entryPoint == 0) { return false; // not valid } - UntetheredCodeInfo info = CodeInfoTable.lookupCodeInfo(WordFactory.pointer(entryPoint)); + UntetheredCodeInfo info = CodeInfoTable.lookupCodeInfo(Word.pointer(entryPoint)); return info.isNonNull() && !UntetheredCodeInfoAccess.isAOTImageCode(info) && UntetheredCodeInfoAccess.getTier(info) == TruffleCompilerImpl.LAST_TIER_INDEX; } diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/isolated/BinaryOutput.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/isolated/BinaryOutput.java index 7138adb6b082..662cb2b30b8c 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/isolated/BinaryOutput.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/isolated/BinaryOutput.java @@ -29,10 +29,10 @@ import java.util.Arrays; import java.util.Objects; +import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.UnmanagedMemory; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; -import jdk.graal.compiler.word.WordFactory; /** * Copy from native-bridge to avoid depenency from now. Keep in sync with native-bridge. @@ -614,7 +614,7 @@ public void close() { if (unmanaged) { UnmanagedMemory.free(address); byteBufferView = null; - address = WordFactory.nullPointer(); + address = Word.nullPointer(); length = 0; unmanaged = false; pos = Integer.MIN_VALUE; @@ -638,7 +638,7 @@ private void ensureCapacity(int neededCapacity) { throw new OutOfMemoryError(); } if (unmanaged) { - address = UnmanagedMemory.realloc(address, WordFactory.unsigned(newCapacity)); + address = UnmanagedMemory.realloc(address, Word.unsigned(newCapacity)); } else { CCharPointer newAddress = UnmanagedMemory.malloc(newCapacity); memcpy(newAddress, address, pos); diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/isolated/IsolateAwareTruffleCompiler.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/isolated/IsolateAwareTruffleCompiler.java index b1e4d6f582b6..243536523bb7 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/isolated/IsolateAwareTruffleCompiler.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/isolated/IsolateAwareTruffleCompiler.java @@ -38,7 +38,6 @@ import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.word.PointerBase; -import jdk.graal.compiler.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.heap.Heap; @@ -68,7 +67,7 @@ import jdk.graal.compiler.word.Word; public class IsolateAwareTruffleCompiler implements SubstrateTruffleCompiler { - private static final Word ISOLATE_INITIALIZING = WordFactory.signed(-1); + private static final Word ISOLATE_INITIALIZING = Word.signed(-1); private final UninterruptibleUtils.AtomicWord sharedIsolate = new UninterruptibleUtils.AtomicWord<>(); @@ -133,7 +132,7 @@ public void doCompile(TruffleCompilationTask task, TruffleCompilable compilable, protected CompilerIsolateThread beforeCompilation() { Isolate isolate = getSharedIsolate(); if (isolate.isNull()) { - if (sharedIsolate.compareAndSet(WordFactory.nullPointer(), (Isolate) ISOLATE_INITIALIZING)) { + if (sharedIsolate.compareAndSet(Word.nullPointer(), (Isolate) ISOLATE_INITIALIZING)) { try { /* Adding the shutdown hook may fail if a shutdown is already in progress. */ Runtime.getRuntime().addShutdownHook(new Thread(this::sharedIsolateShutdown)); @@ -143,7 +142,7 @@ protected CompilerIsolateThread beforeCompilation() { } catch (Throwable e) { /* Reset the value so that the teardown hook doesn't hang. */ assert sharedIsolate.get().equal(ISOLATE_INITIALIZING); - sharedIsolate.set(WordFactory.nullPointer()); + sharedIsolate.set(Word.nullPointer()); throw e; } }