-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement rb_frame_method_id_and_class internal API. #3363
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2071,4 +2071,35 @@ RubyArray zlibGetCRCTable() { | |
} | ||
} | ||
|
||
@CoreMethod(names = "rb_frame_method_and_id", onSingleton = true, required = 2) | ||
public abstract static class FrameMethodAndId extends CoreMethodArrayArgumentsNode { | ||
|
||
@Specialization | ||
boolean frameMethodAndId(Object frameMethod, Object frameId) { | ||
final Frame callingMethodFrame = findCallingMethodFrame(); | ||
frameMethod = RubyArguments.getMethod(callingMethodFrame); | ||
frameId = System.identityHashCode(RubyArguments.tryGetSelf(callingMethodFrame)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These assignments have no effect, they only assign the local Java variable, not the C pointer. |
||
return true; | ||
} | ||
|
||
@TruffleBoundary | ||
private static Frame findCallingMethodFrame() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think org.truffleruby.language.CallStackManager#getCallingMethod should work instead of this and be a lot cleaner. And if not probably a variant of it. |
||
return Truffle.getRuntime().iterateFrames(frameInstance -> { | ||
final Frame frame = frameInstance.getFrame(FrameAccess.READ_ONLY); | ||
|
||
final InternalMethod method = RubyArguments.tryGetMethod(frame); | ||
|
||
if (method == null) { | ||
return null; | ||
} else if (method.getName().equals(/* Truffle::CExt. */ "rb_frame_method_and_id") || | ||
method.getName().equals(/* Truffle::Interop */ "execute_without_conversion")) { | ||
// TODO CS 11-Mar-17 must have a more precise check to skip these methods | ||
return null; | ||
} else { | ||
return frame; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need specs for this, under
spec/ruby/optional/capi
.rb_frame_method_id_and_class
is actually not a private function but it seems public C API, it's declared and documented in https://github.com/ruby/ruby/blob/fc48a679062e422b475ccea11574bf5b4368b732/include/ruby/internal/intern/vm.h#L62