From: Adam Strzelecki Date: 2008-06-05T20:52:51+09:00 Subject: [ruby-core:17122] Re: Bytecode handling (compilation) extensions to Ruby 1.9 > to_ary() convert ISeq object to Array and well known objects such as > Numbers, Regexps, Strings, and so on. iseq_load() loads such data > structure. Point of this feature is you can write down YARV > assember with Ruby Script or YAML or something. YASM, the YARV > bytecode assembler use this feature. > Have you looked at VM::InstructionSequence#to_a, > VM::InstructionSequence::load ? Ahh, there it is :) Thank you both for pointing me that out. I'll start playing around there. > ISeq#to_a is supported, but ISeq.load is not supported because of > absence of bytecode verifyer. You can cause SEGV easily. I see - commented-out in the source. CRC + magic cookie + version checking would be enough? > Now, we are developing following features (on a time of practical > work in our university, 1 student is working on this topic): > > (1) ISeq -> external file that packed > (2) ISeq -> external file -> .c file > > (1) is like Java class file approach. (2) make us happy with > implanting Ruby codes to Ruby core or extension libraries written in > C. Great! Have you thought about using LLVM for: ISeq -> LLVM -> native, this would be a way for HotSpot YARV or native Ruby compiler producing .o file then linked with Ruby runtime into single ELF or MSCOFF. Evan Phoenix from Rubinius is testing LLVM for integrating with their VM http://blog.fallingsnow.net/2008/05/23/simple-vm-jit-with-llvm/ I think it may be interesting for mainstream Ruby too. BTW. What about following all non dynamically referenced "require" and instead generating Kernel.require call. Triggering rb_load at core parsing stage could be an option ? (See my 1st mail) I don't know if it does make sense, but if we want to compile whole project that starts from "start.rb" + requires other files from current folder & subfolders into one single binary form, we'd need to make such a trick. Or maybe asking it upside down, can Kernel.require check whether target file was already loaded by ruby and just call relative ISeq chunk? Best regards, -- Adam Strzelecki |: nanoant.com :|