# Bytecode in Ruby 1.9

**URL:** <https://www.ruby-forum.com/t/bytecode-in-ruby-1-9/174954>\
**Category:** Ruby\
**Created:** [September 4, 2009, 4:58pm UTC](https://www.ruby-forum.com/t/bytecode-in-ruby-1-9/174954 "2009-09-04T16:58:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wvdschel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/da6949/32.png) [@wvdschel](https://www.ruby-forum.com/u/wvdschel)\
**Post date:** [September 4, 2009, 4:58pm UTC](https://www.ruby-forum.com/t/bytecode-in-ruby-1-9/174954/1 "2009-09-04T16:58:55Z")

</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

---

<div class="post-metadata">

**Author:** ![wvdschel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/da6949/32.png) [@wvdschel](https://www.ruby-forum.com/u/wvdschel)\
**Post date:** [September 4, 2009, 5:50pm UTC](https://www.ruby-forum.com/t/bytecode-in-ruby-1-9/174954/2 "2009-09-04T17:50:45Z")

</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
