0

I did everything well in window, but fail in linux. What i want to do is to compile ruby script to java bytecode with -Xcompile.invokedynamic=true parameters:


        [sxu3@** rubyscript]$ jrubyc -Xcompile.invokedynamic=true hello.rb
        OptionParser::InvalidOption: invalid option: -Xcompile.invokedynamic=true
             complete at /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1542
               catch at org/jruby/RubyKernel.java:1282
            complete at /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1540
         parse_in_order at /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1380
               catch at org/jruby/RubyKernel.java:1282
          parse_in_order at /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1347
              order! at /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1341
            permute! at /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1432
              parse! at /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1453
        compile_argv at /homes/sxu3/tools/jruby-1.7.10/lib/ruby/shared/jruby/compiler.rb:83
          initialize at /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:882
        compile_argv at /homes/sxu3/tools/jruby-1.7.10/lib/ruby/shared/jruby/compiler.rb:35
              (root) at /homes/sxu3/tools/jruby-1.7.10/bin/jrubyc:5
    [sxu3@** rubyscript]$ jrubyc -Xcompile.invokedynamic=true hello.rb ^C
    [sxu3@** rubyscript]$ which jrubyc
    ~/tools/jruby-1.7.10/bin/jrubyc
    [sxu3@** rubyscript]$ jruby -v
    jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on Java HotSpot(TM) Server VM 1.7.0_51-b13 [linux-i386]
    [sxu3@** rubyscript]$


    [sxu3@** rubyscript]$ uname -a
    Linux .. 2.6.32-358.23.2.el6.x86_64 #1 SMP Wed Oct 16 18:37:12 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Without -Xcompile.invokedynamic=true, jrubyc works but none of invokedynamic instruction is in generated bytecodes. Also,

      "jrubyc -Xcompile.invokedynamic=true hello.rb" 

works in window and i saw invokedynamic in class file in window.

I leave all other jrubyc properties(.jrubyrc) as default value

hello.rb is one line ruby script:

   puts "hello world"

I also tried jrubyc 1.7.6 and the same errors . Anyone could provide some clue ?

[Update]:

Finally, I think the exception indicates jrubyc does not support -Xcompile.invokedynamic=true option. The jruby wiki page says jruby, instead of "jrubyc" can work with option.

shijie xu
  • 1,975
  • 21
  • 52

1 Answers1

1

I also had issues with jruby and invokedynamic. The problem is that invokedynamic is not really supported on JVM 1.7. To get it working you should install the JVM 1.8. You can read about the issues here: https://github.com/jruby/jruby/wiki/PerformanceTuning But be careful when installing Java 8 - it's not so easy switching between versions and some programs like several eclipse IDEs don't want to run on that JVM.

However maybe jruby with invokedynamic works on Windows, because you have installed the Oracle JVM, which is a little bit different from the HotSpot OpenJDK version.

Thorben
  • 953
  • 13
  • 28
  • The pages says that invokedynamic is off as default in Java 7, but it can be enabled by -Xcompiler.invokedynamic=true: For applications that do not run into the errors or degraded performance, invokedynamic is recommended for maximum performance. It can be forcibly enabled by passing -Xcompile.invokedynamic=true to JRuby (or in JRUBY_OPTS) or by setting the jruby.compile.invokedynamic=true property at the JVM level. We recommend testing your application thoroughly with invokedynamic enabled before enabling it in production settings. – shijie xu Jan 21 '14 at 17:38
  • Yeah I think that is a little bit too optimistic. It didn't work for me with the simpliest skripts. Okay it was version 1.7.2, but the documentation was the same. Nevertheless it's not recommended to use it without Java 8, but if you really want to get it working on linux, then try to install the Oracle JVM (if it worked with it on Windows). – Thorben Jan 21 '14 at 19:45