YARVInstructionSequence/SimpleDataFormat

InstructionSequence:

[“YARVInstructionSequence/SimpleDataFormat”, # magic
1, # major version
2, # minor version
1, # format type (hardcoded to 1 as of 1.9.3)
{:arg_size=>3, :local_size=>6, :stack_max=>2}, # misc data
“method_name”, # label (name of method)
“”, # file name (relative path)
nil, # absolute path
1, # first line number
:method, # type
[:arg1, :arg2, :args, :loc1, :loc2], # locals
[2, [], 0, 3, 2, -1, 0], # args
catch_table, # exception (catch_table)
# body
[1, # line number
[:trace, 1], # YARV instruction
:label_1, #label
…,
[:leave] # YARV instruction
]
]

# example of catch table
catch_table = [
[:rescue, InstructionSequence, :label_2, :label_15, :label_16, 0],
[:retry, nil, :label_15, :label_16, :label_2, 0]
]

type:

:top, :method, :block, :class, :rescue, :ensure, :eval, :main, :defined_guard

args:

[
argc, # argc
[label1, label2, …] # opt labels
post_len,
post_start,
rest index,
block index,
simple
]

For more info look at “iseq_data_to_ary” in iseq.c.

Examples:

def x &block
@m = block
end

2,
1,
{:arg_size=>1, :local_size=>2, :stack_max=>2},
“x”,
“<compiled>”,
nil,
1,
:method,
[:block],
[0, [], 0, 0, -1, 0, 0],
[],
[1,
[:trace, 8],
[:trace, 1],
[:getlocal, 2],
[:dup],
[:setinstancevariable, :@m, 0],
[:trace, 16],
[:leave]]]

###

def x
yield
end

1,
2,
1,
{:arg_size=>0, :local_size=>1, :stack_max=>1},
“x”,
“<compiled>”,
nil,
1,
:method,
[],
0,
[],
[1,
[:trace, 8],
[:trace, 1],
[:invokeblock, 0, 0],
[:trace, 16],
[:leave]]]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s