-
Notifications
You must be signed in to change notification settings - Fork 722
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
Fix array constructor for Object Lists #17503
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Paretheses should not be used after the class name (and there should be a space after
new
):Same comment applies to other files included in this change.
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 personally like space between new and open bracket, but no-space is already very much adopted in J9 GC code (there are dozens of examples without space and barely any with).
As far as I know, the oval brackets are needed at the end - it's an indication that (in this case default) constructor should be invoked.
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.
They are not needed; their presence represents a possible ambiguity.
Here we want the compiler to invoke the (user-defined) default constructor.
Using parentheses is a request for zero-initialization instead.
There's a discussion of this at https://stackoverflow.com/questions/620137/do-the-parentheses-after-the-type-name-make-a-difference-with-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.
Thanks for the reference to the discussion. But from what I can see, our case resembles to 'C' class (non-POD, with user defined ctor), and in both older/newer versions of compilers, calling it with '()', will call default ctor, what we want. I don't understand from where you get that it will do zero-init?
BTW, we have this pattern at a couple of 100 of spots, already. If we are indeed calling it wrong we are really lucky (that default ctor is just pretty much zero-init).
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.
Perhaps an analogy will help. You wouldn't write
to declare an initialize a local variable (the snippet declares a function which returns
MM_ContinuationObjectList
). Instead you would sayAlong the same lines, I'm suggesting we should write
new (where) T
instead ofnew (where) T()
. I believe there's potential to create ambiguity when a suitable call operator (operator()()
) is available (although I haven't yet had luck constructing a concrete example).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 somewhat buy that analogy and from that perspective, it would more consistent to do
new (where) T
instead ofnew (where) T()
. But I don't see the reason to use the former to reduce/remove ambiguity. We probably always have default ctor (so it will be called over zero-init), and even if we don't I don't see a problem (it will call zero-init, what was likely the intention).In presence of overloaded
operator()()
, yes, there could be ambiguity problems, but I don't want to go there. We have never overloaded it, and pretty sure never will. It's just such an extreme operator to overload.So, do we want to go and change 10s of spots just for this analogy argument? I'd be ok if we are writing the code from scratch, but now, it's a tougher call. I'll think about it more...
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.
It may not be worth fixing the existing instances of this, but I think it's something to keep in mind going forward: let's not make it worse.