Forum: JRuby Can I enable invokedynamic in JRUBYC command

11f2061dae26489e2e0502ad1f9880aa?d=identicon&s=25 O. L. (xiaoni_l)
on 2014-08-08 01:58
Hi I've read from the JRuby release log here
http://www.jruby.org/2013/10/07/jruby-1-7-5.html that the invokedynamic
has been disabled since JRuby 1.7.5. However, it still can be enabled
using -Xcompile.invokedynamic=true command.

I'm currently working on a research project in which I need to produce
the java class files explicitly and analyze those invokedynamic commands
in the byte codes. I tried to use a JRuby version later than 1.7.4 and
issued the following command:

jrubyc Xcompile.invokedynamic=true myfile.rb

But I get the following error:

    OptionParser::InvalidOption: invalid option:
-Xcompile.invokedynamic=true
        complete at
/Users/x5lai/.rvm/rubies/jruby-1.7.5/lib/ruby/1.9/optparse.rb:1542
           catch at org/jruby/RubyKernel.java:1282
        complete at
/Users/x5lai/.rvm/rubies/jruby-1.7.5/lib/ruby/1.9/optparse.rb:1540
  parse_in_order at
/Users/x5lai/.rvm/rubies/jruby-1.7.5/lib/ruby/1.9/optparse.rb:1380
           catch at org/jruby/RubyKernel.java:1282
  parse_in_order at
/Users/x5lai/.rvm/rubies/jruby-1.7.5/lib/ruby/1.9/optparse.rb:1347
          order! at
/Users/x5lai/.rvm/rubies/jruby-1.7.5/lib/ruby/1.9/optparse.rb:1341
        permute! at
/Users/x5lai/.rvm/rubies/jruby-1.7.5/lib/ruby/1.9/optparse.rb:1432
          parse! at
/Users/x5lai/.rvm/rubies/jruby-1.7.5/lib/ruby/1.9/optparse.rb:1453
    compile_argv at
/Users/x5lai/.rvm/rubies/jruby-1.7.5/lib/ruby/shared/jruby/compiler.rb:83
      initialize at
/Users/x5lai/.rvm/rubies/jruby-1.7.5/lib/ruby/1.9/optparse.rb:882
    compile_argv at
/Users/x5lai/.rvm/rubies/jruby-1.7.5/lib/ruby/shared/jruby/compiler.rb:35
          (root) at /Users/x5lai/.rvm/rubies/jruby-1.7.5/bin/jrubyc:5


Is it that this command flag is only present for the 'jruby' command and
not the 'jrubyc' command? Is there an equivalent parameter in jrubyc
command that I could turn on the invokedynamic in the byte codes
produced?
2b2507f727d700eb59819b3a2e0c4a24?d=identicon&s=25 Chris Seaton (Guest)
on 2014-08-08 02:06
(Received via mailing list)
I can't answer your jrubyc question, but have you tried
-Xcompile.dump=true
with jruby rather than jrubyc? I can see the indy instructions when I
use
this.

This lets you see the byte code generated. It's not in a class file, but
if
you really want a file on disk for some reason you could probably write
the
generated code to disk instead of passing it to a class loader when
JRuby
compiles it.

Chris
11f2061dae26489e2e0502ad1f9880aa?d=identicon&s=25 O. L. (xiaoni_l)
on 2014-08-08 21:19
Thank you for your reply. But the output looks more like a dynamic call
sequence, which is not what I'm looking for--byte codes that are
generated statically.

Nevertheless, my teacher has found a way to deal with this issue so I
post his solution here in case anyone else is looking for similar
solution:

export JRUBY_OPTS=-Xcompile.invokedynamic=true


Chris Seaton wrote in post #1154612:
> I can't answer your jrubyc question, but have you tried
> -Xcompile.dump=true
> with jruby rather than jrubyc? I can see the indy instructions when I
> use
> this.
>
> This lets you see the byte code generated. It's not in a class file, but
> if
> you really want a file on disk for some reason you could probably write
> the
> generated code to disk instead of passing it to a class loader when
> JRuby
> compiles it.
>
> Chris
This topic is locked and can not be replied to.