Skip to content

Commit

Permalink
associate the MethodHandles with classloader which loaded jruby - fixes
Browse files Browse the repository at this point in the history
#2091

the static MethodHandles#publicLookup does not work when the JVM has two (or more) classloaders
where jruby is running in - the lookup uses Object.class as "reference". to separate the jitted methods the lookup needs to be on a per
classloader level. since Ruby.class is different when coming from different classloaders it is used
to separate the lookup of MethodHandles.
  • Loading branch information
mkristian committed Nov 23, 2014
1 parent 5749171 commit a007df9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/compiler/JITCompiler.java
Expand Up @@ -247,7 +247,7 @@ public void run() {
// only variable-arity
method.switchToJitted(
new CompiledIRMethod(
MethodHandles.publicLookup().findStatic(sourceClass, jittedName, signatures.get(-1)),
MethodHandles.publicLookup().in(Ruby.class).findStatic(sourceClass, jittedName, signatures.get(-1)),
method.getIRMethod(),
method.getVisibility(),
method.getImplementationClass()));
Expand All @@ -258,8 +258,8 @@ public void run() {

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

0 comments on commit a007df9

Please sign in to comment.