From: Chiyuan Zhang Date: 2008-04-16T14:47:56+09:00 Subject: Re: [ruby-core:16395] RFC: VM Instruction Manipulation gem(s)? ------=_Part_4312_30822200.1208324876867 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline The instruction table is generated from insns.def by the script in tools directory and template from templates directory as far as I know. So if this working flow doesn't change, the tool might not change much since it use the same script and templates to generate code. The manipulation will focus on modifying iseq and iseq_encoded of an InstructionSequence. The implementation is not finished yet, but some code have to be copied from Ruby 1.9 source tree because they are not exposed to the external world. Something like rb_iseq_struct and code to encoding the instruction sequence. Currently the tool is not finished yet. We can show you the code when something usable is constructed. It would be nice that some functions would be exposed as API to be called. I think if the instruction set changed, it will be transparent to us, but if something like the structure of the rb_iseq_struct changed, porting will be needed. On Wed, Apr 16, 2008 at 12:41 PM, SASADA Koichi wrote: > Hi, > > > Rocky Bernstein wrote: > > > Is anyone aware of or working on a package/gem for facilitation VM > > instruction manipulation? Things like replace, insert or delete a > > sequence > > of VM instructions. I understand rubinius may have something like this. > > I > > ask because a colleague is considering writing one. > > > > (I've posted a query on ruby-talk but so there's been silence which I > > guess > > means there's been nothing.) > > > > I don't know about it. > > But VM bytecodes are not stable, because I want to remove/modify some > instructions which are not used frequently such as "definemethod". > > And I'm not sure which API is suitable. If you have any idea, please > teach me or see your implementation. > > Regards, > -- > // SASADA Koichi at atdot dot net > > -- pluskid ------=_Part_4312_30822200.1208324876867 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline The instruction table is generated from insns.def by the script in tools directory and template from templates directory as far as I know. So if this working flow doesn't change, the tool might not change much since it use the same script and templates to generate code. The manipulation will focus on modifying iseq and iseq_encoded of an InstructionSequence.

The implementation is not finished yet, but some code have to be copied from Ruby 1.9 source tree because they are not exposed to the external world. Something like rb_iseq_struct and code to encoding the instruction sequence. Currently the tool is not finished yet. We can show you the code when something usable is constructed. It would be nice that some functions would be exposed as API to be called.

I think if the instruction set changed, it will be transparent to us, but if something like the structure of the rb_iseq_struct changed, porting will be needed.

On Wed, Apr 16, 2008 at 12:41 PM, SASADA Koichi <ko1@atdot.net> wrote:
Hi,


Rocky Bernstein wrote:
Is anyone aware of or working on a package/gem for facilitation VM
instruction manipulation? Things like replace, insert or delete a sequence
of VM instructions. I understand rubinius may have something like this. I
ask because a colleague is considering writing one.

(I've posted a query on ruby-talk but so there's been silence which I guess
means there's been nothing.)

I don't know about it.

But VM bytecodes are not stable, because I want to remove/modify some instructions which are not used frequently such as "definemethod".

And I'm not sure which API is suitable.  If you have any idea, please teach me or see your implementation.

Regards,
--
// SASADA Koichi at atdot dot net




--
pluskid ------=_Part_4312_30822200.1208324876867--