# Bytecode in Ruby 1.9

**URL:** <https://rubytalk.org/t/bytecode-in-ruby-1-9/55246>\
**Category:** ruby-talk\
**Created:** [4 September 2009 14:58 UTC](https://rubytalk.org/t/bytecode-in-ruby-1-9/55246 "2009-09-04T14:58:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wim\_Vander\_schelden](https://avatars.discourse-cdn.com/v4/letter/w/ed655f/32.png) [@Wim\_Vander\_schelden](https://rubytalk.org/u/Wim_Vander_schelden)\
**Post date:** [4 September 2009 14:58 UTC](https://rubytalk.org/t/bytecode-in-ruby-1-9/55246/1 "2009-09-04T14:58:58Z")

</div>

Hi,

I've looked all over and I can't seem to find any complete documentation  
about the YARV bytecode. Is there a reference or spec somewhere?

On instruction I find nothing about is the trace instruction. Does  
anyone know how it works?

Kind regards,

Wim

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Mark\_Moseley](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@Mark\_Moseley](https://rubytalk.org/u/Mark_Moseley)\
**Post date:** [4 September 2009 15:50 UTC](https://rubytalk.org/t/bytecode-in-ruby-1-9/55246/2 "2009-09-04T15:50:47Z")

</div>

Wim Vander schelden wrote:

> Hi,
> 
> I've looked all over and I can't seem to find any complete documentation  
> about the YARV bytecode. Is there a reference or spec somewhere?

Not that I know of. What I've learned came from debugging vm\_exec().

> On instruction I find nothing about is the trace instruction. Does  
> anyone know how it works?

Sure. Whether trace instructions are included or not into the bytecode  
is a compile-time switch. It's on by default in all 1.9.x releases so  
you don't need to worry about that.

To use them, you need to install a hook function via  
rb\_add\_event\_hook(). Then the hook will get the trace events when they  
occur.

The ruby-debug-base19 gem uses this extensively; you might want to take  
a look at it.

Mark

> **···**
>
> > Kind regards,
> > 
> > Wim
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
