rubyomr-preview / ruby

The Ruby+OMR Preview
Other
68 stars 9 forks source link

Helper Methods and Bytecodes #101

Closed efferifick closed 7 years ago

efferifick commented 7 years ago

Hello again,

I have made an optimization pass that attempts to construct a callgraph for a single method. I do this by iterating over every node in the trees and finding whether or not it is a node that refers to a call instruction. After some filtering to make sure that there are no multiple targets I am inspecting the nodes.

It seems that there are no "call" instructions available in the YARV but some of YARV's instruction's get translated into "call" instructions. In particular I am interested in "send*" instructions (I think, please correct me if I'm wrong). All the "sendWithoutBlock" bytecode instruction get transformed into preparing the arguments and calling RubyHelper_vm_send_without_block. My questions are:

Thanks!

mgaudet commented 7 years ago

Hey, Sorry for the delayed reply! I was away getting married :bride_with_veil: :man_in_tuxedo:

YARV presents some challenges; because method lookup happens dynamically at run time, we don't generate calls directly. Instead, we generate calls to helpers, that are responsible for looking up the correct method to dispatch, and in turn invokes the interpreter on that method (which will then call into JIT code, if it exists).

So, to answer your questions directly: RubyHelper_vm_send_without_block is neither interpreted, nor compiled: It's a helper function, implemented in C, that invokes a ruby method. As a helper, it doesn't partake in most of the normal method resolution procedures in OMR, and so is not a "ResolvedMethod" as we assume we always have the address of the helper directly, which is stored in the RuntimeHelpers table.

efferifick commented 7 years ago

Congrats!

And thanks!