Skip to content

Commit

Permalink
better keep the static nature of the MethodHandles.publicLookup
Browse files Browse the repository at this point in the history
static in the sense of global lookup per classloader. related to #2091
  • Loading branch information
mkristian committed Nov 23, 2014
1 parent 3bb5c15 commit db10c66
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions core/src/main/java/org/jruby/compiler/JITCompiler.java
Expand Up @@ -173,18 +173,20 @@ public void jitThresholdReached(final InterpretedIRMethod method, final RubyInst
jitTask.run();
}
}


private static final MethodHandles.Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup().in(Ruby.class);

private class JITTask implements Runnable {
private final String className;
private final InterpretedIRMethod method;
private final String methodName;

public JITTask(String className, InterpretedIRMethod method, String methodName) {
this.className = className;
this.method = method;
this.methodName = methodName;
}

public void run() {
try {
// Check if the method has been explicitly excluded
Expand Down Expand Up @@ -247,7 +249,7 @@ public void run() {
// only variable-arity
method.switchToJitted(
new CompiledIRMethod(
MethodHandles.publicLookup().in(Ruby.class).findStatic(sourceClass, jittedName, signatures.get(-1)),
PUBLIC_LOOKUP.findStatic(sourceClass, jittedName, signatures.get(-1)),
method.getIRMethod(),
method.getVisibility(),
method.getImplementationClass()));
Expand All @@ -258,8 +260,8 @@ public void run() {

method.switchToJitted(
new CompiledIRMethod(
MethodHandles.publicLookup().in(Ruby.class).findStatic(sourceClass, jittedName, signatures.get(-1)),
MethodHandles.publicLookup().in(Ruby.class).findStatic(sourceClass, jittedName, entry.getValue()),
PUBLIC_LOOKUP.findStatic(sourceClass, jittedName, signatures.get(-1)),
PUBLIC_LOOKUP.findStatic(sourceClass, jittedName, entry.getValue()),
entry.getKey(),
method.getIRMethod(),
method.getVisibility(),
Expand Down

0 comments on commit db10c66

Please sign in to comment.