|
28 | 28 | import java.io.IOException;
|
29 | 29 | import java.util.ArrayList;
|
30 | 30 | import java.util.Arrays;
|
31 |
| -import java.util.IdentityHashMap; |
32 | 31 | import java.util.concurrent.ConcurrentHashMap;
|
33 | 32 | import java.util.concurrent.Semaphore;
|
34 | 33 | import java.util.logging.Level;
|
|
50 | 49 | import com.oracle.graal.python.nodes.NodeFactory;
|
51 | 50 | import com.oracle.graal.python.nodes.control.TopLevelExceptionHandler;
|
52 | 51 | import com.oracle.graal.python.nodes.expression.ExpressionNode;
|
| 52 | +import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; |
53 | 53 | import com.oracle.graal.python.parser.PythonParserImpl;
|
54 | 54 | import com.oracle.graal.python.runtime.PythonContext;
|
55 | 55 | import com.oracle.graal.python.runtime.PythonCore;
|
@@ -129,7 +129,7 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
|
129 | 129 | public final Assumption singleContextAssumption = Truffle.getRuntime().createAssumption("Only a single context is active");
|
130 | 130 |
|
131 | 131 | private final NodeFactory nodeFactory;
|
132 |
| - private final IdentityHashMap<Builtin, RootCallTarget> builtinCallTargetCache = new IdentityHashMap<>(); |
| 132 | + private final ConcurrentHashMap<String, RootCallTarget> builtinCallTargetCache = new ConcurrentHashMap<>(); |
133 | 133 |
|
134 | 134 | @CompilationFinal(dimensions = 1) private static final Object[] CONTEXT_INSENSITIVE_SINGLETONS = new Object[]{PNone.NONE, PNone.NO_VALUE, PEllipsis.INSTANCE, PNotImplemented.NOT_IMPLEMENTED};
|
135 | 135 |
|
@@ -581,9 +581,8 @@ protected void disposeThread(PythonContext context, Thread thread) {
|
581 | 581 | context.disposeThread(thread);
|
582 | 582 | }
|
583 | 583 |
|
584 |
| - public RootCallTarget getOrComputeBuiltinCallTarget(Builtin builtin, Function<Builtin, RootCallTarget> supplier) { |
585 |
| - synchronized (this) { |
586 |
| - return builtinCallTargetCache.computeIfAbsent(builtin, supplier); |
587 |
| - } |
| 584 | + public RootCallTarget getOrComputeBuiltinCallTarget(Builtin builtin, Class<? extends PythonBuiltinBaseNode> nodeClass, Function<Builtin, RootCallTarget> supplier) { |
| 585 | + String key = builtin.name() + nodeClass.getName(); |
| 586 | + return builtinCallTargetCache.computeIfAbsent(key, (k) -> supplier.apply(builtin)); |
588 | 587 | }
|
589 | 588 | }
|
0 commit comments