Skip to content
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

Upgrading inlined code to virtual methods for register scavenger #6781

Merged
merged 1 commit into from
Oct 21, 2022

Conversation

LinHu2016
Copy link
Contributor

@LinHu2016 LinHu2016 commented Oct 20, 2022

Upgrading inlined code to virtual methods for register scavenger
so that subclasses could override behavior.

Signed-off-by: Lin Hu linhu@ca.ibm.com

@LinHu2016
Copy link
Contributor Author

@amicic @dmitripivkine please review the change, Thanks

/* register the scavenger in GCExtensionsBase */
_extensions->registerScavenger(this);
#endif /* OMR_GC_MODRON_SCAVENGER */

Copy link
Contributor

@amicic amicic Oct 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor difference, but i'd keep it at original spot (higher level entity knows better to whom it should be registered)

comment is redundant (the method name is self explanatory)

@@ -906,6 +906,9 @@ class MM_GCExtensionsBase : public MM_BaseVirtual {
MMINLINE OMR_VM* getOmrVM() { return _omrVM; }
MMINLINE void setOmrVM(OMR_VM* omrVM) { _omrVM = omrVM; }

#if defined(OMR_GC_MODRON_SCAVENGER)
virtual void registerScavenger(MM_Scavenger *scavenger) { this->scavenger = scavenger; }
Copy link
Contributor

@amicic amicic Oct 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for symmetry, let's introduce unregister, too

it'd be used in MM_ConfigurationGenerational::tearDown

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://github.com/eclipse/omr/blob/master/doc/CodingStandard.md#variables.

In C++, member variable names should start with an underscore: _scavenger. This is just a note and does not need to be addressed in this PR since the scavenger member field was introduced in the past.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately whole that class/file does not follow that standard, although by far most of other GC classes do.

Being a top level global GC class, conforming it to the standard would likely touch almost every GC file.

That's probably why nobody so far have tried to do it, but it should have really be done during the major OMR/J9 separation.

@LinHu2016 LinHu2016 force-pushed the master branch 2 times, most recently from 68bb805 to 5e9f7c6 Compare October 20, 2022 17:23
@@ -202,8 +201,7 @@ MM_ConfigurationGenerational::createDefaultMemorySpace(MM_EnvironmentBase *envBa
return NULL;
}

/* register the scavenger in GCExtensionsBase */
ext->scavenger = scavenger;
_extensions->registerScavenger(this);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not 'this' but scavenger

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does _extensions really exist?

@LinHu2016 LinHu2016 force-pushed the master branch 2 times, most recently from a15acfa to 41e4080 Compare October 20, 2022 17:43
@amicic
Copy link
Contributor

amicic commented Oct 20, 2022

subject and comment are not really correct

you are not changing any behavior

just upgrading inlined code to virtual methods so that subclasses could override behavior

@LinHu2016 LinHu2016 changed the title Register scavenger instance in GCExtensionsBase earlier Upgrading inlined code to virtual methods for register scavenger Oct 20, 2022
@LinHu2016
Copy link
Contributor Author

@babsingh Could you please review the change, Thanks

Copy link
Contributor

@babsingh babsingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpicks.

gc/base/GCExtensionsBase.hpp Outdated Show resolved Hide resolved
@@ -906,6 +906,9 @@ class MM_GCExtensionsBase : public MM_BaseVirtual {
MMINLINE OMR_VM* getOmrVM() { return _omrVM; }
MMINLINE void setOmrVM(OMR_VM* omrVM) { _omrVM = omrVM; }

#if defined(OMR_GC_MODRON_SCAVENGER)
virtual void registerScavenger(MM_Scavenger *scavenger) { this->scavenger = scavenger; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://github.com/eclipse/omr/blob/master/doc/CodingStandard.md#variables.

In C++, member variable names should start with an underscore: _scavenger. This is just a note and does not need to be addressed in this PR since the scavenger member field was introduced in the past.

@babsingh
Copy link
Contributor

@LinHu2016 There is a standalone commit for the new change. There should be only one commit and it should include all the changes.

@babsingh
Copy link
Contributor

jenkins build all

@LinHu2016 LinHu2016 force-pushed the master branch 2 times, most recently from 5c6e5b9 to 2b7ff60 Compare October 21, 2022 14:50
@babsingh
Copy link
Contributor

jenkins build all

@babsingh
Copy link
Contributor

babsingh commented Oct 21, 2022

Old zLinux PR build: https://ci.eclipse.org/omr/job/PullRequest-linux_390-64/3942.
Also, running the zLinux PR build with DOMR_GC_MODRON_SCAVENGER disabled.

jenkins build zlinux(cmake:'-DOMR_GC_MODRON_SCAVENGER=OFF')

@babsingh
Copy link
Contributor

https://ci.eclipse.org/omr/job/PullRequest-linux_390-64/3943/console

In the zLinux PR build with OMR_GC_MODRON_SCAVENGER disabled, the following error is seen:

11:09:42  /home/omr/workspace/Build/gc/base/GCExtensionsBase.hpp:989:33: error: ‘MM_Scavenger’ has not been declared
11:09:42    virtual void registerScavenger(MM_Scavenger *scavenger)
11:09:42                                   ^
11:09:42  gc/CMakeFiles/omrgc.dir/build.make:62: recipe for target 'gc/CMakeFiles/omrgc.dir/base/AddressOrderedListPopulator.cpp.o' failed
11:09:42  make[2]: *** [gc/CMakeFiles/omrgc.dir/base/AddressOrderedListPopulator.cpp.o] Error 1
11:09:42  CMakeFiles/Makefile2:1984: recipe for target 'gc/CMakeFiles/omrgc.dir/all' failed

@amicic
Copy link
Contributor

amicic commented Oct 21, 2022

https://ci.eclipse.org/omr/job/PullRequest-linux_390-64/3943/console

In the zLinux PR build with OMR_GC_MODRON_SCAVENGER disabled, the following error is seen:

11:09:42  /home/omr/workspace/Build/gc/base/GCExtensionsBase.hpp:989:33: error: ‘MM_Scavenger’ has not been declared
11:09:42    virtual void registerScavenger(MM_Scavenger *scavenger)
11:09:42                                   ^
11:09:42  gc/CMakeFiles/omrgc.dir/build.make:62: recipe for target 'gc/CMakeFiles/omrgc.dir/base/AddressOrderedListPopulator.cpp.o' failed
11:09:42  make[2]: *** [gc/CMakeFiles/omrgc.dir/base/AddressOrderedListPopulator.cpp.o] Error 1
11:09:42  CMakeFiles/Makefile2:1984: recipe for target 'gc/CMakeFiles/omrgc.dir/all' failed

Argh, we either have to revert to having #ifdef outside or use void * (and upcast later)
I'm slightly more inclined to revert this part, but i'm open for the other option (or anything else new).

@amicic
Copy link
Contributor

amicic commented Oct 21, 2022

Argh, we either have to revert to having #ifdef outside or use void * (and upcast later) I'm slightly more inclined to revert this part, but i'm open for the other option (or anything else new).

Third option is to remove #ifdef around forward declaration

#if defined(OMR_GC_MODRON_SCAVENGER)
class MM_Scavenger;
#endif /* defined(OMR_GC_MODRON_SCAVENGER) */

Still, I slightly prefer the least radical (but ugliest to my eye) option to keep (un)registerScavenger under #ifdef, but again open to hear opinions.

@LinHu2016
Copy link
Contributor Author

I will remove #ifdef around forward declaration

Upgrading inlined code to virtual methods for register scavenger
so that subclasses could override behavior

Signed-off-by: Lin Hu <linhu@ca.ibm.com>
@amicic
Copy link
Contributor

amicic commented Oct 21, 2022

jenkins build zlinux(cmake:'-DOMR_GC_MODRON_SCAVENGER=OFF')

@babsingh
Copy link
Contributor

babsingh commented Oct 21, 2022

zLinux PR build with OMR_GC_MODRON_SCAVENGER disabled passed: https://ci.eclipse.org/omr/job/PullRequest-linux_390-64/3945/consoleFull. Running PR builds with OMR_GC_MODRON_SCAVENGER enabled.

jenkins build all

Copy link
Contributor

@babsingh babsingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://ci.eclipse.org/omr/job/PullRequest-linux_ppc-64_le_gcc/3855/console

Known failure: #6571

All other PR builds passed successfully.

@babsingh babsingh merged commit 0ae182f into eclipse-omr:master Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants