Experiment with storing method invocation/definition location
Reported by Kevin Clark | December 17th, 2007 @ 01:20 AM | in 1.0 preview
This ticket is so I remember to try and hack at this. Please don't close it unless you're me, or I've told you to do it.
Comments are welcome ;)
------
Coda Hale
1:16
http://blog.codahale.com/2007/12...
Kevin Clark
1:18
Oh shit, you know what I really want in Rubinius? A way to turn on MethodContext location info. So you can flip a switch in the VM, and MethodContexts and CompiledMethod's store where they were initiated/defined from (in source).
Coda Hale
1:18
YES
Kevin Clark
1:18
I should write that.
Coda Hale
1:18
PLZ YES GO NOW
Comments and changes to this ticket
-
Eero Saynatkari December 17th, 2007 @ 02:08 PM
- → State changed from new to open
Actually, we can probably already do this. Basically we are just dealing with backtraces.
Look at
CompiledMethodinkernel/core/compiled_method.rb. We already have the#fileand#line_from_ipmethods that pretty much give us the info we need.#fileis self-explanatory and then:some_method.line_from_ip 0Can be used to find the first line of the method and I cannot test until I get home (I think, you may need to use 1 instead.)
Also,
MethodContextfromkernel/core/context.rbdefinesMethodContext#fileandMethodContext#lineare both proxy methods that use the currently executing @CompiledMethod@'s interface (convenience method#locationalso exists.)So that already tells us where the method is defined. Secondly, we wanted to know where it is being called? For that, of course, there already is
Kernel.caller(standard MRI too), but you can access it slightly more programmatically:sender = MethodContext.current.sender p sender.file, sender.line cm = sender.method p cm.file, cm.line_from_ip(0)Tadaa!
Is this the part where you tell me I completely misunderstood what you are talking about?
-
Kevin Clark December 17th, 2007 @ 02:11 PM
Oh rue, you make me so happy. That's basically what I was looking for. I'm going to do some hacking and see if I can't come up with some nice helpers to handle that. Maybe a command line interface to load up libs, and then tell where a block of code's methods come from.
-
Eero Saynatkari January 8th, 2008 @ 11:34 AM
- → State changed from open to resolved
Closing since my awesomeness saved the day here. CM and MC are working nicely in HEAD.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
