|
26 | 26 |
|
27 | 27 | import static com.oracle.svm.core.heap.RestrictHeapAccess.Access.NO_ALLOCATION;
|
28 | 28 |
|
29 |
| -import jdk.graal.compiler.word.Word; |
30 | 29 | import org.graalvm.nativeimage.ImageSingletons;
|
31 | 30 | import org.graalvm.nativeimage.LogHandler;
|
32 | 31 | import org.graalvm.nativeimage.Platform;
|
|
48 | 47 | import com.oracle.svm.core.windows.headers.SynchAPI;
|
49 | 48 | import com.oracle.svm.core.windows.headers.WinBase;
|
50 | 49 |
|
| 50 | +import jdk.graal.compiler.word.Word; |
| 51 | + |
51 | 52 | @AutomaticallyRegisteredImageSingleton(VMLockSupport.class)
|
52 | 53 | public final class WindowsVMLockSupport extends VMLockSupport {
|
53 | 54 |
|
@@ -78,7 +79,7 @@ static void checkResult(int result, String functionName) {
|
78 | 79 |
|
79 | 80 | @Uninterruptible(reason = "Error handling is interruptible.", calleeMustBe = false)
|
80 | 81 | @RestrictHeapAccess(access = NO_ALLOCATION, reason = "Must not allocate in fatal error handling.")
|
81 |
| - private static void fatalError(String functionName) { |
| 82 | + static void fatalError(String functionName) { |
82 | 83 | /*
|
83 | 84 | * Functions are called very early and late during our execution, so there is not much we
|
84 | 85 | * can do when they fail.
|
@@ -296,14 +297,18 @@ public int initialize() {
|
296 | 297 | @Override
|
297 | 298 | @Uninterruptible(reason = "The isolate teardown is in progress.")
|
298 | 299 | public int destroy() {
|
299 |
| - int errorCode = WinBase.CloseHandle(hSemaphore); |
| 300 | + int result = WinBase.CloseHandle(hSemaphore); |
300 | 301 | hSemaphore = Word.nullPointer();
|
301 |
| - return errorCode; |
| 302 | + return result != 0 ? 0 : 1; |
302 | 303 | }
|
303 | 304 |
|
304 | 305 | @Override
|
305 | 306 | public void await() {
|
306 |
| - WindowsVMLockSupport.checkResult(SynchAPI.WaitForSingleObject(hSemaphore, SynchAPI.INFINITE()), "WaitForSingleObject"); |
| 307 | + int result = SynchAPI.WaitForSingleObject(hSemaphore, SynchAPI.INFINITE()); |
| 308 | + if (result != SynchAPI.WAIT_OBJECT_0()) { |
| 309 | + assert result == SynchAPI.WAIT_FAILED() : result; |
| 310 | + WindowsVMLockSupport.fatalError("WaitForSingleObject"); |
| 311 | + } |
307 | 312 | }
|
308 | 313 |
|
309 | 314 | @Override
|
|
0 commit comments