Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Inline Class#new. #13080
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
Inline Class#new. #13080
Changes from all commits
e97034c
52acae4
36c0e2d
1a0896f
fffde57
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
The
nil
seems wrong because it looks like it basically breaks theObjectSpace.trace_object_allocations
functionality, at least theallocation_class_path
andallocation_method_id
methods.Though to be fair if those basically always return
"Class"
and:new
they probably have little value.Notably the spec no longer works on TruffleRuby because of the changed expectations due to this commit.
TruffleRuby also inlines Class#new, and has logic inside the implementation of Class#new that if allocation tracing is enabled then it records the relevant information directly on the object, while this information is available.
Maybe CRuby could do the same? Or maybe these methods should be deprecated?
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.
What if CRuby would return
"Class"
for allocation_class_path and:new
forallocation_method_id
if the information is not there? Then we could revert this commit and avoid changing behavior.Would it be incorrect? In which case?
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.
@eregon We could probably do that, but to be honest I think we should delete these tests (or update them not to run inside anonymous blocks). As you noted, returning
Class
and:new
is not very helpful information. I think the current behavior is actually more helpful. AFAICT, the reason it's returningnil
in this case has something to do with how the test runner is set up (I think because everything is being executed in blocks?)For example:
Output is this:
The
nil
is odd, but there is no class or method name in that case. Also the first example is way more useful than just returningClass
and:new
.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.
Good point, we'll refactor those specs to move the
trace_object_allocations
usages inside named classes and methods and test that as it's more representative of a real usage of the feature.