Tiered compilation leads to "unloaded signature class" inlining failures in JRuby

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Mon Aug 31 13:52:58 UTC 2020


Hi Charlie,

> So we have a puzzle. Why does running this code with tiered
> compilation cause it to (erroneously?) claim a signature class has not
> been loaded?

I didn't try to answer this exact question, but looked at what happens 
during the failed inlining attempt.

What surprised me is that the absent class which causes the failure is 
java.lang.String. But it turns out java.lang.String is never accessed 
from callee method [1] and hence there are no guarantees it is resolved 
in the context of the context class loader (instance of 
org/jruby/util/OneShotClassLoader) by the time the compilation kicks in.

You can workaround that by forcing j.l.String resolution when 
instantiating the class loader.

Best regards,
Vladimir Ivanov

[1]
Users.vlivanov.ws.tmp.TIERED.inline::RUBY$method$bar$0
(Lorg/jruby/runtime/ThreadContext;Lorg/jruby/parser/StaticScope;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;Lorg/jruby/RubyModule;Ljava/lang/String;)Lorg/jruby/runtime/builtin/IRubyObject;
     0 nop
     1 nop
     2 fast_aload_0
     3 invokedynamic bsm=18 22 
<fixnum(Lorg/jruby/runtime/ThreadContext;)Lorg/jruby/runtime/builtin/IRubyObject;>
       0   bci: 3    CounterData         count(14485)
                     argument types      0: stack(0) 
'org/jruby/runtime/ThreadContext'
                     return type         'org/jruby/RubyFixnum'
     8 areturn
     9 athrow

  - class loader data:  loader data: 0x0000000134c18570 for instance a 
'org/jruby/util/OneShotClassLoader'{0x0000000702198648}
Java dictionary (table_size=107, classes=10, resizable=true)
^ indicates that initiating loader is different from defining loader
    8: ^java.lang.Object, loader data: 0x000000010043e520 of 'bootstrap'
   15: ^org.jruby.ir.targets.Bootstrap, loader data: 0x0000000127b2e010 
for instance a 
'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x0000000700001480}
   36: ^org.jruby.runtime.builtin.IRubyObject, loader data: 
0x0000000127b2e010 for instance a 
'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x0000000700001480}
   53: ^org.jruby.runtime.Block, loader data: 0x0000000127b2e010 for 
instance a 
'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x0000000700001480}
   53: ^org.jruby.ir.IRScope, loader data: 0x0000000127b2e010 for 
instance a 
'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x0000000700001480}
   69:  Users.vlivanov.ws.tmp.TIERED.inline, loader data: 
0x0000000134c18570 for instance a 
'org/jruby/util/OneShotClassLoader'{0x0000000702198648}
   73: ^org.jruby.runtime.ThreadContext, loader data: 0x0000000127b2e010 
for instance a 
'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x0000000700001480}
   74: ^org.jruby.ir.targets.FixnumObjectSite, loader data: 
0x0000000127b2e010 for instance a 
'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x0000000700001480}
   94: ^org.jruby.parser.StaticScope, loader data: 0x0000000127b2e010 
for instance a 
'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x0000000700001480}
   95: ^org.jruby.RubyModule, loader data: 0x0000000127b2e010 for 
instance a 
'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x0000000700001480}


> This appears to affect every OpenJDK release at least back to 8u222,
> the earliest version we tested.
> 
> To reproduce, create the two scripts in the bug, download a JRuby
> distribution from jruby.org, and execute the main script like this:
> 
> bin/jruby -Xcompile.invokedynamic -J-XX:+WhateverHotspotFlag main.rb
> 
> PrintInlining and PrintAssembly output will show that the "bar" method
> fails to inline into "foo" in the inline.rb part of the example.
> 
> Help!
> 
> - Charlie
> 


More information about the hotspot-compiler-dev mailing list