Running ruby1.9 bytecode

J

James Coglan

[Note: parts of this message were removed to make it a legal post.]

Hi all,

I just found out about the VM::InstructionSequence.compile method for
turning Ruby code strings into ruby1.9 bytecode. Is there a standard method
of de/serializing this bytecode to/from files, and is there a way of running
bytecode directly? I'm looking at generating bytecode from another language
to get it to run on Ruby.
 
R

Robert Dober

Hi all,

I just found out about the VM::InstructionSequence.compile method for
turning Ruby code strings into ruby1.9 bytecode. Is there a standard method
of de/serializing this bytecode to/from files, and is there a way of running
bytecode directly? I'm looking at generating bytecode from another language
to get it to run on Ruby.
Quoting from the Pickaxe book
no, because the bytecode verifier is not ready yet, that seems the
only missing bit.
HTH
Robert


--
There are some people who begin the Zoo at the beginning, called
WAYIN, and walk as quickly as they can past every cage until they get
to the one called WAYOUT, but the nicest people go straight to the
animal they love the most, and stay there. ~ A.A. Milne (from
Winnie-the-Pooh)
 
R

Rick DeNatale

[Note: parts of this message were removed to make it a legal post.]

Quoting from the Pickaxe book
no, because the bytecode verifier is not ready yet, that seems the
only missing bit.
HTH
Robert

Well that's part of it. But, if by "generating bytecode from another
language" means, for instance, executing JVM bytecodes, I don't think it
will fly. The term bytecode here is being used rather generically. The YARV
"bytecodes" aren't the same as the JVM bytecodes, any more than Smalltalk-80
bytecodes are the same as either.

It's like the difference between an Intel and Motorola processor, both have
instruction sets with binary representations, but those instruction sets
aren't necessarily interchangeable.

Getting another language to produce YARV bytecodes would be an exercise for
the reader.
--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
 
J

James Coglan

[Note: parts of this message were removed to make it a legal post.]
Well that's part of it. But, if by "generating bytecode from another
language" means, for instance, executing JVM bytecodes, I don't think it
will fly. The term bytecode here is being used rather generically. The YARV
"bytecodes" aren't the same as the JVM bytecodes, any more than
Smalltalk-80
bytecodes are the same as either..

Getting another language to produce YARV bytecodes would be an exercise for
the reader.


I meant that I'd like to try and generate YARV bytecode from non-Ruby
source. Mostly a pie-in-the-sky idea, only just writing my first AST-walking
interpreter, just wondering if it's possible.
 
M

Michael Malone

James said:
I meant that I'd like to try and generate YARV bytecode from non-Ruby
source. Mostly a pie-in-the-sky idea, only just writing my first AST-walking
interpreter, just wondering if it's possible.
It's definitely possible. I suggest you take a look at the parrot
interpreter. It is a one-for-all interpreter (well, that's the aim,
anyway), which began life as an April Fool's joke that someone took one
step further. It officially hit version 1.0 the other day, so it should
be a good example for you. By one-for-all I mean, it's a generic
interpreter that can handle many languages, much like .NET and the clr,
I guess.

=======================================================================
This email, including any attachments, is only for the intended
addressee. It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
=======================================================================
 
R

Robert Dober

I meant that I'd like to try and generate YARV bytecode from non-Ruby
source. Mostly a pie-in-the-sky idea, only just writing my first AST-walking
interpreter, just wondering if it's possible.
Having YARV/Rubinius as a backend for other languages is certainly a
very reasonable idea.
And if I understood correctly it is planned to be possible in the
(near?) future.

Cheers
R.



--
There are some people who begin the Zoo at the beginning, called
WAYIN, and walk as quickly as they can past every cage until they get
to the one called WAYOUT, but the nicest people go straight to the
animal they love the most, and stay there. ~ A.A. Milne (from
Winnie-the-Pooh)
 

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

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,197
Latest member
ScottChare

Latest Threads

Top