current status of ruby -> {c, java} optimizers

Currently it appears

1) jruby has ruby2java which uses annotations to know how.

annotate :go :boolean => :boolean

2) druby has a parse tree to lookup dependencies (ocaml) and “see if anything doesn’t fit the duck typing” based on its dependencies.

3) ruby2c has a parse tree to lookup dependencies (ruby) and, from the types currently passed in, convert methods to c.   Haven’t quite gotten it to work yet.

4) duby uses its own syntax:

go(a => :boolean); return a; end

5) druby also can add “extra dynamic tests” which wrap methods and watch what things are passed to them during runtime.  When the script executes, it re runs (?) its dependencies parse tree to look for discrepancies.

So basically there’s nothing out there that’s automatic, but there’s some tools that, if combined, would work (note–haven’t yet gotten ruby2c to work–if it did that might be real nice).

Assuming that  ruby2c doesn’t work, the shortest path would seem to be somehow combining a dependencies analyzer with ruby2java to generate final objects.

Thoughts?

using gdb to get the c level backtrace of a ruby app

I suppose one way would be to fork the current process, then have gdb attach to it and call “backtrace” then unattach.

here is the example, in linux:

(gdb) bt
#3 0x0815e92b in vm_call_method (th=0×8350480, cfp=0xb7b66ee8, num=1,
blockptr=0×1, flag=8, id=7688, mn=0x82717b4, recv=136505600)
at vm_insnhelper.c:379
#4 0x08150eee in vm_exec_core (th=0×8350480, initial=<value optimized out>)
at insns.def:1000
#5 0x08157c82 in vm_exec (th=0×8350480) at vm.c:1079
#6 0×08159326 in loop_i () at vm.c:524

ruby 1.9.2 has the possibility of a more verbose debug output, too (somehow)– you might be able to tie into that.
ruby 1.9.2dev (2009-05-21) [i386-mingw32]

– control frame ———-
c:0015 p:—- s:0073 b:0073 l:000072 d:000072 CFUNC :join
c:0014 p:0286 s:0069 b:0069 l:00070c d:00070c METHOD c:/dev/ruby/downloads/ruby_trunk/test/ruby/envutil.rb:133
c:0013 p:0093 s:0048 b:0048 l:000047 d:000047 METHOD c:/dev/ruby/downloads/ruby_trunk/test/ruby/test_exception.rb:217

—————————
c:/dev/ruby/downloads/ruby_trunk/lib/minitest/unit.rb:333:in `block in autorun’
c:/dev/ruby/downloads/ruby_trunk/lib/minitest/unit.rb:392:in `run’
c:/dev/ruby/downloads/ruby_trunk/lib/minitest/unit.rb:412:in `run_test_suites’
c:/dev/ruby/downloads/ruby_trunk/lib/minitest/unit.rb:412:in `each’
c:/dev/ruby/downloads/ruby_trunk/lib/minitest/unit.rb:413:in `block in run_test_suites’
c:/dev/ruby/downloads/ruby_trunk/lib/minitest/unit.rb:413:in `each’
c:/dev/ruby/downloads/ruby_trunk/lib/minitest/unit.rb:420:in `block (2 levels) in run_test_suites’
c:/dev/ruby/downloads/ruby_trunk/lib/minitest/unit.rb:441:in `run’
c:/dev/ruby/downloads/ruby_trunk/test/ruby/test_exception.rb:217:in `test_errat’
c:/dev/ruby/downloads/ruby_trunk/test/ruby/envutil.rb:133:in `assert_in_out_err’
c:/dev/ruby/downloads/ruby_trunk/test/ruby/envutil.rb:133:in `join’

Unfortunately, in mingw I can’t seem to get gdb attach to print out *anything.*

nokogiri on mingw

don’t know how yet, but…here’s a beginning

C:/ruby19/bin/ruby.exe extconf.rb install nokogiri –platform=mswin32
checking for iconv.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,C:/ruby19/include/libxml2,C:/ruby19/include,/usr/local/include/libxml2,/usr/include/libxml2… no
iconv is missing. try ‘port install iconv’ or ‘yum install iconv’
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

meant “you need the full dev environment, not just the devkit, instructions at http://programming-gone-awry.blogspot.com/2009/05/how-to-setup-complete-mingw-msys-build.html”

ruby sqlite install woes

C:\dev\ruby\DOWNLO~1\SQLITE~1>rake-compiler

c:/ruby/lib/ruby/gems/1.9.1/gems/rake-compiler-0.5.0/lib/rake/extensioncompiler.rb:28:in `mingw_host’: No MinGW tools or unknown setup platform? (RuntimeError)

from c:/ruby/lib/ruby/gems/1.9.1/gems/rake-compiler-0.5.0/bin/../tasks/bin/cross-ruby.rake:38:in `<top (required)>’

from c:/ruby/lib/ruby/gems/1.9.1/gems/rake-compiler-0.5.0/bin/rake-compiler:21:in `load’

from c:/ruby/lib/ruby/gems/1.9.1/gems/rake-compiler-0.5.0/bin/rake-compiler:21:in `<top (required)>’

from c:/ruby/bin/rake-compiler:19:in `load’

from c:/ruby/bin/rake-compiler:19:in `<main>’

meant “rake compiler doesn’t like gcc.bat files–not it doesn’t”

fix: add mingw/bin to your path first

gem install woe

d:\dev>gem install extlib
ERROR: While executing gem … (Errno::ENOENT)
No such file or directory – \Documents and Settings\Melissa.BLACKY

meant “you need to be in the C drive”

the cause “for some reason ruby on this one box does an File.expand_path(‘~’) -> without a drive letter”

despite these settings:
d:\dev>set | grep HOME
HOME=\Documents and Settings\Melissa.BLACKY
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\Melissa.BLACKY

d:\dev>set | grep USER
ALLUSERSPROFILE=C:\Documents and Settings\All Users.WINDOWS
USERDOMAIN=BLACKY
USERNAME=Melissa
USERPROFILE=C:\Documents and Settings\Melissa.BLACKY

mysql compiling in windows woes

c:/mysql/lib/opt//mysqlclient.lib(./mysqlclient.dir/RelWithDebInfo/md2.obj):f:\build\mysql-5.0:(.text[??1MD2@TaoCrypt@@UAE@XZ]+0x5b): undefined reference to `??3@YAXPAX@Z’

c:/mysql/lib/opt//mysqlclient.lib(./mysqlclient.dir/RelWithDebInfo/trees.obj): In function `gen_codes’:

f:\build\mysql-5.0:(.text[_gen_codes]+0×4): undefined reference to `__security_cookie’

f:\build\mysql-5.0:27: undefined reference to `@__security_check_cookie@4′

c:/mysql/lib/opt//mysqlclient.lib(./mysqlclient.dir/RelWithDebInfo/inftrees.obj): In function `inflate_table’:

f:\build\mysql-5.0:(.text[_inflate_table]+0×7): undefined reference to `__security_cookie’

f:\build\mysql-5.0:289: undefined reference to `@__security_check_cookie@4′

f:\build\mysql-5.0:289: undefined reference to `@__security_check_cookie@4′

f:\build\mysql-5.0:289: undefined reference to `@__security_check_cookie@4′

f:\build\mysql-5.0:289: undefined reference to `@__security_check_cookie@4′

f:\build\mysql-5.0:289: undefined reference to `@__security_check_cookie@4′

fu000067.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname’

fu000068.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname’

fu000071.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname’

fu000073.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname’

fu000074.o:(.idata$2+0xc): undefined reference to `libmsvcrt_a_iname’

fu000076.o:(.idata$2+0xc): more undefined references to `libmsvcrt_a_iname’ follow

nmth000066.o:(.idata$4+0×0): undefined reference to `_nm___iob’

collect2: ld returned 1 exit status

meant “you’re linking against the wrong thing”

gcc woe

collect2: installation problem, cannot exec `C:\dev\ruby\rubyinstaller\sandbox\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe’: Exec format error

might mean “a corrupted mingw gcc” since if you search for ld.exe’s, shouldn’t they be the same?

maybe rebuild? what the heck?