Skip to content

Commit 7d5592a

Browse files
committed
removed IsolateSupport.getIsolateID
1 parent 9a744b5 commit 7d5592a

File tree

10 files changed

+20
-61
lines changed

10 files changed

+20
-61
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/LibGraalSupport.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ public interface LibGraalSupport {
108108
/**
109109
* Gets an identifier for the current isolate that is guaranteed to be unique for the first
110110
* {@code 2^64 - 1} isolates in the process.
111-
*
112-
* @return a non-zero value
113111
*/
114112
long getIsolateID();
115113

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/debug/GlobalMetrics.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ private static PrintStream openPrintStream(String metricsFile, Path[] outPath) t
8888
}
8989

9090
static Path generateFileName(String metricsFile) {
91-
long isolateID = IsolateUtil.getIsolateID();
9291
Path path;
93-
if (isolateID != 0L) {
92+
if (IsolateUtil.getIsolateAddress() != 0L) {
93+
long isolateID = IsolateUtil.getIsolateID();
9494
int lastDot = metricsFile.lastIndexOf('.');
9595
if (lastDot != -1) {
9696
path = Paths.get(metricsFile.substring(0, lastDot) + '@' + isolateID + metricsFile.substring(lastDot));

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/IsolateUtil.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public static long getIsolateAddress() {
4343
}
4444

4545
/**
46-
* Gets a non-zero identifier for the current isolate or 0 if this not an isolate-aware runtime.
47-
* The returned value is guaranteed to be unique for the first {@code 2^64 - 1} isolates in the
48-
* process.
46+
* Gets an identifier for the current isolate. This will return 0 if
47+
* {@link #getIsolateAddress()} returns 0. The returned value is guaranteed to be unique for the
48+
* first {@code 2^64 - 1} isolates in the process.
4949
*/
5050
public static long getIsolateID() {
5151
LibGraalSupport libgraal = LibGraalSupport.INSTANCE;
@@ -58,7 +58,8 @@ public static long getIsolateID() {
5858
/**
5959
* Gets a string identifying the current isolate.
6060
*
61-
* If this is not an isolate-aware runtime, an empty string is returned.
61+
* If this is not an isolate-aware runtime (i.e. {@link #getIsolateAddress()} returns 0), an
62+
* empty string is returned.
6263
*
6364
* If {@code withAddress == true}, then
6465
* {@code String.format("%d@%x", getIsolateID(), getIsolateAddress())} is returned.

sdk/src/org.graalvm.nativeimage.libgraal/src/org/graalvm/nativeimage/libgraal/LibGraalRuntime.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ public static void notifyLowMemoryPoint(boolean suggestFullGC) {
7979
/**
8080
* Gets an identifier for the current isolate that is guaranteed to be unique for the first
8181
* {@code 2^64 - 1} isolates in the process.
82-
*
83-
* @return a non-zero value
8482
*/
8583
public static long getIsolateID() {
8684
return ImageSingletons.lookup(LibGraalRuntimeSupport.class).getIsolateID();

sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/IsolateSupport.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -58,12 +58,4 @@ public interface IsolateSupport {
5858
void detachThread(IsolateThread thread) throws IsolateException;
5959

6060
void tearDownIsolate(IsolateThread thread) throws IsolateException;
61-
62-
/**
63-
* Gets an identifier for the current isolate that is guaranteed to be unique for the first
64-
* {@code 2^64 - 1} isolates in the process.
65-
*
66-
* @return a non-zero value
67-
*/
68-
long getIsolateID();
6961
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/Isolates.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ public static long getStartTimeNanos() {
133133
return startTimeNanos;
134134
}
135135

136+
/**
137+
* Gets an identifier for the current isolate that is guaranteed to be unique for the first
138+
* {@code 2^64 - 1} isolates in the process.
139+
*/
136140
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
137141
public static long getIsolateId() {
138142
assert isolateId >= 0;

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/IsolateSupportImpl.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
import java.util.List;
2828

29-
import com.oracle.svm.core.c.CGlobalData;
30-
import com.oracle.svm.core.c.CGlobalDataFactory;
3129
import jdk.graal.compiler.word.Word;
3230
import org.graalvm.nativeimage.Isolate;
3331
import org.graalvm.nativeimage.IsolateThread;
@@ -38,7 +36,6 @@
3836
import org.graalvm.nativeimage.c.type.CCharPointerPointer;
3937
import org.graalvm.nativeimage.c.type.CTypeConversion;
4038
import org.graalvm.nativeimage.impl.IsolateSupport;
41-
import org.graalvm.word.Pointer;
4239

4340
import com.oracle.svm.core.SubstrateOptions;
4441
import com.oracle.svm.core.c.function.CEntryPointNativeFunctions.IsolateThreadPointer;
@@ -50,8 +47,6 @@
5047
import com.oracle.svm.core.os.MemoryProtectionProvider;
5148
import com.oracle.svm.core.os.MemoryProtectionProvider.UnsupportedDomainException;
5249

53-
import static org.graalvm.word.LocationIdentity.ANY_LOCATION;
54-
5550
@AutomaticallyRegisteredImageSingleton(IsolateSupport.class)
5651
public final class IsolateSupportImpl implements IsolateSupport {
5752
private static final String ISOLATES_DISABLED_MESSAGE = "Spawning of multiple isolates is disabled, use " +
@@ -172,31 +167,4 @@ private static void throwOnError(int code) {
172167
throw new IsolateException(message);
173168
}
174169
}
175-
176-
private static final CGlobalData<Pointer> nextIsolateId = CGlobalDataFactory.createWord((Pointer) Word.unsigned(1L));
177-
178-
private volatile long isolateId = 0;
179-
180-
@Override
181-
public long getIsolateID() {
182-
if (isolateId == 0) {
183-
synchronized (this) {
184-
if (isolateId == 0) {
185-
Pointer p = nextIsolateId.get();
186-
long value;
187-
long nextValue;
188-
do {
189-
value = p.readLong(0);
190-
nextValue = value + 1;
191-
if (nextValue == 0) {
192-
// Avoid setting id to reserved 0 value after long integer overflow
193-
nextValue = 1;
194-
}
195-
} while (p.compareAndSwapLong(0, value, nextValue, ANY_LOCATION) != value);
196-
isolateId = value;
197-
}
198-
}
199-
}
200-
return isolateId;
201-
}
202170
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/functions/JNIInvocationInterface.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
*/
2525
package com.oracle.svm.core.jni.functions;
2626

27+
import com.oracle.svm.core.Isolates;
2728
import jdk.graal.compiler.word.Word;
28-
import org.graalvm.nativeimage.ImageSingletons;
2929
import org.graalvm.nativeimage.LogHandler;
3030
import org.graalvm.nativeimage.StackValue;
3131
import org.graalvm.nativeimage.c.function.CEntryPoint;
@@ -35,7 +35,6 @@
3535
import org.graalvm.nativeimage.c.type.CCharPointerPointer;
3636
import org.graalvm.nativeimage.c.type.CIntPointer;
3737
import org.graalvm.nativeimage.c.type.WordPointer;
38-
import org.graalvm.nativeimage.impl.IsolateSupport;
3938
import org.graalvm.word.Pointer;
4039
import org.graalvm.word.UnsignedWord;
4140

@@ -204,8 +203,8 @@ static int enter(JNIJavaVMPointer vmBuf, JNIEnvironmentPointer penv, JNIJavaVMIn
204203
| | 0-terminated C string describing the error if a description is available, |
205204
| | otherwise extraInfo is set to null. |
206205
|--------------------|-----------------------------------------------------------------------------------|
207-
| _javavm_id | extraInfo is a "unsigned long*" value. |
208-
| | A non-zero identifier for the current isolate that is guaranteed to be unique for |
206+
| _javavm_id | extraInfo is a "jlong*" value. |
207+
| | An identifier for the current isolate that is guaranteed to be unique for |
209208
| | the first 2^64 - 1 isolates in the process is returned in *value. |
210209
|--------------------|-----------------------------------------------------------------------------------|
211210
* </pre>
@@ -393,7 +392,7 @@ private static int finishInitialization0(JNIJavaVMPointer vmBuf, JNIEnvironmentP
393392
JNIJavaVM javaVm = JNIFunctionTables.singleton().getGlobalJavaVM();
394393
JNIJavaVMList.addJavaVM(javaVm);
395394
if (javaVmIdPointer.isNonNull()) {
396-
long javaVmId = ImageSingletons.lookup(IsolateSupport.class).getIsolateID();
395+
long javaVmId = Isolates.getIsolateId();
397396
javaVmIdPointer.write(Word.pointer(javaVmId));
398397
}
399398
RuntimeSupport.getRuntimeSupport().addTearDownHook(new RuntimeSupport.Hook() {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/libgraal/LibGraalRuntimeSupportImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
*/
2525
package com.oracle.svm.core.libgraal;
2626

27-
import org.graalvm.nativeimage.ImageSingletons;
28-
import org.graalvm.nativeimage.impl.IsolateSupport;
27+
import com.oracle.svm.core.Isolates;
2928

3029
import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton;
3130
import com.oracle.svm.core.heap.Heap;
@@ -48,7 +47,7 @@ public void notifyLowMemoryPoint(boolean suggestFullGC) {
4847

4948
@Override
5049
public long getIsolateID() {
51-
return ImageSingletons.lookup(IsolateSupport.class).getIsolateID();
50+
return Isolates.getIsolateId();
5251
}
5352

5453
@Override

substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/substitutions/GraalSubstitutions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
import java.util.Map;
3434
import java.util.concurrent.ConcurrentHashMap;
3535

36+
import com.oracle.svm.core.Isolates;
3637
import jdk.graal.compiler.graph.Edges;
3738
import org.graalvm.collections.EconomicMap;
3839
import org.graalvm.collections.EconomicSet;
3940
import org.graalvm.collections.Equivalence;
4041
import org.graalvm.nativeimage.CurrentIsolate;
4142
import org.graalvm.nativeimage.ImageSingletons;
4243
import org.graalvm.nativeimage.hosted.FieldValueTransformer;
43-
import org.graalvm.nativeimage.impl.IsolateSupport;
4444

4545
import com.oracle.svm.core.SubstrateTargetDescription;
4646
import com.oracle.svm.core.annotate.Alias;
@@ -218,7 +218,7 @@ public static long getIsolateAddress() {
218218

219219
@Substitute
220220
public static long getIsolateID() {
221-
return ImageSingletons.lookup(IsolateSupport.class).getIsolateID();
221+
return Isolates.getIsolateId();
222222
}
223223
}
224224

0 commit comments

Comments
 (0)