8318586: Explicitly handle upcall stub allocation failure

8318653: UpcallTestHelper::runInNewProcess waits for forked process without timeout

Reviewed-by: shade, mcimadamore
This commit is contained in:
Jorn Vernee 2023-11-30 19:26:54 +00:00
parent 630bafd9c6
commit e96e191952
21 changed files with 207 additions and 20 deletions

View file

@ -71,6 +71,9 @@ public class NativeEntryPoint {
return NEP_CACHE.get(key, k -> {
long downcallStub = makeDowncallStub(methodType, abi, argMoves, returnMoves, needsReturnBuffer,
capturedStateMask, needsTransition);
if (downcallStub == 0) {
throw new OutOfMemoryError("Failed to allocate downcall stub");
}
NativeEntryPoint nep = new NativeEntryPoint(methodType, downcallStub);
CLEANER.register(nep, () -> freeDowncallStub(downcallStub));
return nep;

View file

@ -106,6 +106,9 @@ public class UpcallLinker {
doBindings = insertArguments(exactInvoker(doBindings.type()), 0, doBindings);
long entryPoint = makeUpcallStub(doBindings, abi, conv,
callingSequence.needsReturnBuffer(), callingSequence.returnBufferSize());
if (entryPoint == 0) {
throw new OutOfMemoryError("Failed to allocate upcall stub");
}
return UpcallStubs.makeUpcall(entryPoint, scope);
};
}