|
29 | 29 | */
|
30 | 30 | package com.oracle.truffle.llvm.runtime;
|
31 | 31 |
|
| 32 | +import java.io.IOException; |
| 33 | +import java.nio.file.Path; |
| 34 | +import java.nio.file.Paths; |
| 35 | +import java.security.SecureRandom; |
| 36 | +import java.util.ArrayList; |
| 37 | +import java.util.Arrays; |
| 38 | +import java.util.Collections; |
| 39 | +import java.util.HashMap; |
| 40 | +import java.util.LinkedHashMap; |
| 41 | +import java.util.List; |
| 42 | +import java.util.Map; |
| 43 | +import java.util.concurrent.ConcurrentHashMap; |
| 44 | +import java.util.concurrent.locks.ReentrantLock; |
| 45 | +import java.util.logging.Level; |
| 46 | +import java.util.stream.Collectors; |
| 47 | + |
| 48 | +import org.graalvm.collections.EconomicMap; |
| 49 | +import org.graalvm.collections.EconomicSet; |
| 50 | +import org.graalvm.collections.Equivalence; |
| 51 | +import org.graalvm.collections.Pair; |
| 52 | + |
32 | 53 | import com.oracle.truffle.api.Assumption;
|
33 | 54 | import com.oracle.truffle.api.CallTarget;
|
34 | 55 | import com.oracle.truffle.api.CompilerAsserts;
|
|
45 | 66 | import com.oracle.truffle.api.TruffleSafepoint;
|
46 | 67 | import com.oracle.truffle.api.nodes.ControlFlowException;
|
47 | 68 | import com.oracle.truffle.api.nodes.Node;
|
| 69 | +import com.oracle.truffle.api.profiles.BranchProfile; |
48 | 70 | import com.oracle.truffle.api.source.Source;
|
49 | 71 | import com.oracle.truffle.llvm.api.Toolchain;
|
50 | 72 | import com.oracle.truffle.llvm.runtime.IDGenerater.BitcodeID;
|
|
67 | 89 | import com.oracle.truffle.llvm.runtime.pointer.LLVMPointer;
|
68 | 90 | import com.oracle.truffle.llvm.runtime.pthread.LLVMPThreadContext;
|
69 | 91 |
|
70 |
| -import org.graalvm.collections.EconomicMap; |
71 |
| -import org.graalvm.collections.Pair; |
72 |
| - |
73 |
| -import java.io.IOException; |
74 |
| -import java.nio.file.Path; |
75 |
| -import java.nio.file.Paths; |
76 |
| -import java.security.SecureRandom; |
77 |
| -import java.util.ArrayList; |
78 |
| -import java.util.Arrays; |
79 |
| -import java.util.Collections; |
80 |
| -import java.util.HashMap; |
81 |
| -import java.util.LinkedHashMap; |
82 |
| -import java.util.List; |
83 |
| -import java.util.Map; |
84 |
| -import java.util.concurrent.ConcurrentHashMap; |
85 |
| -import java.util.concurrent.locks.ReentrantLock; |
86 |
| -import java.util.logging.Level; |
87 |
| -import java.util.stream.Collectors; |
88 |
| - |
89 |
| -import com.oracle.truffle.api.profiles.BranchProfile; |
90 |
| -import org.graalvm.collections.EconomicSet; |
91 |
| -import org.graalvm.collections.Equivalence; |
92 |
| - |
93 | 92 | public final class LLVMContext {
|
94 | 93 | public static final String SULONG_INIT_CONTEXT = "__sulong_init_context";
|
95 | 94 | public static final String SULONG_DISPOSE_CONTEXT = "__sulong_dispose_context";
|
@@ -552,7 +551,7 @@ private void cleanUpNoGuestCode() {
|
552 | 551 | }
|
553 | 552 |
|
554 | 553 | Thread[] allThreads;
|
555 |
| - try (TLSInitializerAccess access = getTLSInitializerAccess()) { |
| 554 | + try (TLSInitializerAccess access = getTLSInitializerAccess(true)) { |
556 | 555 | allThreads = access.getAllRunningThreads();
|
557 | 556 | }
|
558 | 557 |
|
@@ -1047,8 +1046,12 @@ public synchronized void unregisterThread(LLVMThread thread) {
|
1047 | 1046 | public final class TLSInitializerAccess implements AutoCloseable {
|
1048 | 1047 |
|
1049 | 1048 | @TruffleBoundary
|
1050 |
| - private TLSInitializerAccess() { |
1051 |
| - threadInitLock.lock(); |
| 1049 | + private TLSInitializerAccess(boolean interruptible) { |
| 1050 | + if (interruptible) { |
| 1051 | + TruffleSafepoint.setBlockedThreadInterruptible(null, ReentrantLock::lockInterruptibly, threadInitLock); |
| 1052 | + } else { |
| 1053 | + threadInitLock.lock(); |
| 1054 | + } |
1052 | 1055 | }
|
1053 | 1056 |
|
1054 | 1057 | @TruffleBoundary
|
@@ -1088,8 +1091,8 @@ public List<AggregateTLGlobalInPlaceNode> getThreadLocalGlobalInitializer() {
|
1088 | 1091 | }
|
1089 | 1092 | }
|
1090 | 1093 |
|
1091 |
| - public TLSInitializerAccess getTLSInitializerAccess() { |
1092 |
| - return new TLSInitializerAccess(); |
| 1094 | + public TLSInitializerAccess getTLSInitializerAccess(boolean interruptible) { |
| 1095 | + return new TLSInitializerAccess(interruptible); |
1093 | 1096 | }
|
1094 | 1097 |
|
1095 | 1098 | @TruffleBoundary
|
|
0 commit comments