Skip to content

Commit 85bb1db

Browse files
committed
Adapt JDK-8336768: Allow captureCallState and critical linker options to be combined
Closes: #10304
1 parent ca7e8b3 commit 85bb1db

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/AbiUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ public NativeEntryPointInfo makeNativeEntrypoint(FunctionDescriptor desc, Linker
649649

650650
// From NativeEntrypoint.make
651651
return NativeEntryPointInfo.make(argMoves, returnMoves, boundaryType, needsReturnBuffer, callingSequence.capturedStateMask(), callingSequence.needsTransition(),
652-
optionSet.allowsHeapAccess());
652+
callingSequence.usingAddressPairs(), optionSet.allowsHeapAccess());
653653
}
654654

655655
@Override

substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/NativeEntryPointInfo.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ public final class NativeEntryPointInfo {
5555
private final boolean needsReturnBuffer;
5656
private final boolean capturesState;
5757
private final boolean needsTransition;
58+
private final boolean usingAddressPairs;
5859
private final boolean allowHeapAccess;
5960

6061
private NativeEntryPointInfo(MethodType methodType, VMStorage[] cc, VMStorage[] returnBuffering, boolean needsReturnBuffer, boolean capturesState, boolean needsTransition,
61-
boolean allowHeapAccess) {
62+
boolean usingAddressPairs, boolean allowHeapAccess) {
6263
assert methodType.parameterCount() == cc.length;
6364
assert needsReturnBuffer == (returnBuffering.length > 1);
6465
// when no transition, allowHeapAccess is unused, so it must be set to false
@@ -69,6 +70,7 @@ private NativeEntryPointInfo(MethodType methodType, VMStorage[] cc, VMStorage[]
6970
this.needsReturnBuffer = needsReturnBuffer;
7071
this.capturesState = capturesState;
7172
this.needsTransition = needsTransition;
73+
this.usingAddressPairs = usingAddressPairs;
7274
this.allowHeapAccess = allowHeapAccess;
7375
}
7476

@@ -78,6 +80,7 @@ public static NativeEntryPointInfo make(
7880
boolean needsReturnBuffer,
7981
int capturedStateMask,
8082
boolean needsTransition,
83+
boolean usingAddressPairs,
8184
boolean allowHeapAccess) {
8285
if ((returnMoves.length > 1) != needsReturnBuffer) {
8386
throw new AssertionError("Multiple register return, but needsReturnBuffer was false");
@@ -99,7 +102,7 @@ public static NativeEntryPointInfo make(
99102
*/
100103
allowHeapAccess = false;
101104
}
102-
return new NativeEntryPointInfo(methodType, argMoves, returnMoves, needsReturnBuffer, capturedStateMask != 0, needsTransition, allowHeapAccess);
105+
return new NativeEntryPointInfo(methodType, argMoves, returnMoves, needsReturnBuffer, capturedStateMask != 0, needsTransition, usingAddressPairs, allowHeapAccess);
103106
}
104107

105108
public static Target_jdk_internal_foreign_abi_NativeEntryPoint makeEntryPoint(
@@ -109,8 +112,9 @@ public static Target_jdk_internal_foreign_abi_NativeEntryPoint makeEntryPoint(
109112
boolean needsReturnBuffer,
110113
int capturedStateMask,
111114
boolean needsTransition,
115+
boolean usingAddressPairs,
112116
boolean allowHeapAccess) {
113-
var info = make(argMoves, returnMoves, methodType, needsReturnBuffer, capturedStateMask, needsTransition, allowHeapAccess);
117+
var info = make(argMoves, returnMoves, methodType, needsReturnBuffer, capturedStateMask, needsTransition, usingAddressPairs, allowHeapAccess);
114118
long addr = ForeignFunctionsRuntime.singleton().getDowncallStubPointer(info).rawValue();
115119
return new Target_jdk_internal_foreign_abi_NativeEntryPoint(info.methodType(), addr, capturedStateMask);
116120
}
@@ -153,13 +157,13 @@ public boolean equals(Object o) {
153157
return false;
154158
}
155159
NativeEntryPointInfo that = (NativeEntryPointInfo) o;
156-
return capturesState == that.capturesState && needsTransition == that.needsTransition && needsReturnBuffer == that.needsReturnBuffer && allowHeapAccess == that.allowHeapAccess &&
160+
return capturesState == that.capturesState && needsTransition == that.needsTransition && usingAddressPairs == that.usingAddressPairs && needsReturnBuffer == that.needsReturnBuffer && allowHeapAccess == that.allowHeapAccess &&
157161
Objects.equals(methodType, that.methodType) &&
158162
Arrays.equals(parameterAssignments, that.parameterAssignments) && Arrays.equals(returnBuffering, that.returnBuffering);
159163
}
160164

161165
@Override
162166
public int hashCode() {
163-
return Objects.hash(methodType, needsReturnBuffer, capturesState, needsTransition, allowHeapAccess, Arrays.hashCode(parameterAssignments), Arrays.hashCode(returnBuffering));
167+
return Objects.hash(methodType, needsReturnBuffer, capturesState, needsTransition, usingAddressPairs, allowHeapAccess, Arrays.hashCode(parameterAssignments), Arrays.hashCode(returnBuffering));
164168
}
165169
}

substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_abi_NativeEntryPoint.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.oracle.svm.core.annotate.Substitute;
3232
import com.oracle.svm.core.annotate.TargetClass;
3333

34+
import com.oracle.svm.core.util.BasedOnJDKFile;
3435
import jdk.internal.foreign.abi.ABIDescriptor;
3536
import jdk.internal.foreign.abi.VMStorage;
3637

@@ -53,12 +54,14 @@ public final class Target_jdk_internal_foreign_abi_NativeEntryPoint {
5354
}
5455

5556
@Substitute
57+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+27/src/java.base/share/classes/jdk/internal/foreign/abi/NativeEntryPoint.java#L58-L82")
5658
public static Target_jdk_internal_foreign_abi_NativeEntryPoint make(ABIDescriptor abi,
5759
VMStorage[] argMoves, VMStorage[] returnMoves,
5860
MethodType methodType,
5961
boolean needsReturnBuffer,
6062
int capturedStateMask,
61-
boolean needsTransition) {
63+
boolean needsTransition,
64+
boolean usingAddressPairs) {
6265
/*
6366
* A VMStorage may be null only when the Linker.Option.critical(allowHeapAccess=true) option
6467
* is passed. (see
@@ -69,10 +72,11 @@ public static Target_jdk_internal_foreign_abi_NativeEntryPoint make(ABIDescripto
6972
* construction in the NativeEntryPointInfo.make function.
7073
*/
7174
boolean allowHeapAccess = Arrays.stream(argMoves).anyMatch(Objects::isNull);
72-
return NativeEntryPointInfo.makeEntryPoint(abi, argMoves, returnMoves, methodType, needsReturnBuffer, capturedStateMask, needsTransition, allowHeapAccess);
75+
return NativeEntryPointInfo.makeEntryPoint(abi, argMoves, returnMoves, methodType, needsReturnBuffer, capturedStateMask, needsTransition, usingAddressPairs, allowHeapAccess);
7376
}
7477

7578
@Substitute
79+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+27/src/java.base/share/classes/jdk/internal/foreign/abi/NativeEntryPoint.java#L120-L122")
7680
public MethodType type() {
7781
return methodType;
7882
}

0 commit comments

Comments
 (0)