-
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?
Conversation
This commit implements rb_frame_method_and_id internal API, that is needed by the rice gem. The corresponding changeset represents a first but hopefully significant step to get torch.rb working on Truffleruby.
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 comment
The 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.
You need to return something which contains both (e.g. a Method Ruby object or a Ruby Array of two elements).
|
||
int rb_frame_method_id_and_class(ID *idp, VALUE *klassp) { | ||
return RUBY_CEXT_INVOKE("rb_frame_method_id_and_class", idp, klassp); | ||
} |
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
} | ||
|
||
@TruffleBoundary | ||
private static Frame findCallingMethodFrame() { |
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.
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.
This commit implements the rb_frame_method_and_id internal API, that is needed by the rice gem. The corresponding changeset represents a first but hopefully significant step to get the torch.rb gem working on Truffleruby.