[ANN] Ruva: Pure-ruby toy (J)VM

R

Ross Bamford

Hi,

For anyone who's interested in this kind of stuff, I just uploaded my
pure-ruby toy JVM to Rubyforge. It's obviously very slow, but can be
useful for seeing how things work or debugging generated classes that
won't verify. It can do some reasonable class-dumps and execution
traces, too. It's probably about 70% complete, with most instructions
implemented, and currently has some integration with the GNU Classpath
runtime library.

http://ruva.rubyforge.org/
http://rubyforge.org/projects/ruva
svn checkout svn://rubyforge.org/var/svn/ruva/trunk
 
P

pat eyler

Wow!

Hi,

For anyone who's interested in this kind of stuff, I just uploaded my
pure-ruby toy JVM to Rubyforge. It's obviously very slow, but can be
useful for seeing how things work or debugging generated classes that
won't verify. It can do some reasonable class-dumps and execution
traces, too. It's probably about 70% complete, with most instructions
implemented, and currently has some integration with the GNU Classpath
runtime library.

Okay, I'm boggled. This is really cool (even it it's just a toy).
 
S

Simen Edvardsen

Hi,

For anyone who's interested in this kind of stuff, I just uploaded my
pure-ruby toy JVM to Rubyforge. It's obviously very slow, but can be
useful for seeing how things work or debugging generated classes that
won't verify. It can do some reasonable class-dumps and execution
traces, too. It's probably about 70% complete, with most instructions
implemented, and currently has some integration with the GNU Classpath
runtime library.

http://ruva.rubyforge.org/
http://rubyforge.org/projects/ruva
svn checkout svn://rubyforge.org/var/svn/ruva/trunk

That is very very cool. I'll definetely be playing with this.
 
A

Austin Ziegler

For anyone who's interested in this kind of stuff, I just uploaded my
pure-ruby toy JVM to Rubyforge. It's obviously very slow, but can be
useful for seeing how things work or debugging generated classes that
won't verify. It can do some reasonable class-dumps and execution
traces, too. It's probably about 70% complete, with most instructions
implemented, and currently has some integration with the GNU Classpath
runtime library.

So ... anyone up for JRuby on Ruva?

-austin
 
M

Matt Lawrence

Thank you.

You are quite welcome. Hope to see you at RubyConf.

-- Matt
It's not what I know that counts.
It's what I can remember in time to use.
 
P

pat eyler

Why stop there? Can JRuby run Ruva?

and why stop there ... how much work will it take to get JRuby on
Ruva on MetaRuby on Cardinal? I want to be able to read the
line of code currently being interpreted ;^)
 
C

Charles Oliver Nutter

Ross said:
For anyone who's interested in this kind of stuff, I just uploaded my
pure-ruby toy JVM to Rubyforge. It's obviously very slow, but can be
useful for seeing how things work or debugging generated classes that
won't verify. It can do some reasonable class-dumps and execution
traces, too. It's probably about 70% complete, with most instructions
implemented, and currently has some integration with the GNU Classpath
runtime library.

http://ruva.rubyforge.org/
http://rubyforge.org/projects/ruva
svn checkout svn://rubyforge.org/var/svn/ruva/trunk

Seriously though, this might have real applications in JRuby. Existing
libraries for examining bytecodes are far from friendly, and having a
nice API to examine classes and code could be useful. We're planning on
writing the next iteration of the Ruby-bytecode compiler in Ruby, and
having a library like this to examine the results will make that easier.
 
R

Ross Bamford

What aboute the reverse -- load Ruva inside of JRuby -- or better (worse?)
still, JRuby inside of Ruva inside of JRuby -- now there's an incestuous
cycle. The image of two snakes eating each others' tail comes to mind.

Hmm, y'know, there _is_ a JPython I believe.... :D
 
R

Ross Bamford

Seriously though, this might have real applications in JRuby. Existing
libraries for examining bytecodes are far from friendly, and having a
nice API to examine classes and code could be useful. We're planning on
writing the next iteration of the Ruby-bytecode compiler in Ruby, and
having a library like this to examine the results will make that easier.

Yeah, that kind of thing was the reason I started on Ruva last year.
Doing a lot of stuff with generated classes, and the JVM's preverifier
errors are, shall we say "unhelpful", to say the least ...

Anyway, I'll be glad (plus a bit surprised) if anything in there's of
use...
 
C

Charles Oliver Nutter

Ross said:
For anyone who's interested in this kind of stuff, I just uploaded my
pure-ruby toy JVM to Rubyforge. It's obviously very slow, but can be

I tried to play with it a bit but I don't have Classpath installed. Is
there a way to read in classes for inspection without Classpath?
 
R

Ross Bamford

I tried to play with it a bit but I don't have Classpath installed. Is
there a way to read in classes for inspection without Classpath?

Sure is. This gets a dump of a class just as it's read in (before it's
resolved):

pp
Ruva::VM::Class::Reader.file("test/java_classes/TestFunctional10.class")

The unresolved class returned by Reader.file is visitable too - there's
a bit of a basic TraceClassVisitor in ruva/utils/class_visitor.rb but it
gives too much output most of the time...

If you're after the code, it's easier to get the class resolved or
you'll have to find the code attributes yourself, so try something like:

loader = Ruva::VM::ClassLoader.new(nil, 'test/java_classes')
# => #<Ruva::VM::ClassLoader:0xb7dac098 ... >

clz = loader.load_class('TestFunctional10')
# => TestFunctional10

clz.methods.each { |m| puts m; Ruva::Utils::CodeDumper.print(m.code) }
# public void <init>(int)
# seq | bytes | mnemonic | operands
# ----------------------------------------------------------
# 0 | 0x0000..0x0000 | ALOAD_0 | []
# 1 | 0x0001..0x0003 | INVOKESPECIAL | [0, 1]
# [ ... etc ... ]

Also, have a look at the bottom of class_loader.rb and a few others,
there are small test programs there sometimes...

Hope that helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top