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

Enhance extensibility of JitBuilder classes #2515

Merged
merged 16 commits into from
Jun 27, 2018

Conversation

mstoodle
Copy link
Contributor

@mstoodle mstoodle commented May 1, 2018

The JitBuilder implementation files in compiler/ilgen are not really in the right shape to be extended by other compilers. This pull request moves these files closer to the extensible classes shape used by some classes in the rest of the compiler, but not all the way (on purpose). I am willing to change my position on these aspects, but for now I want to see where we can get without them:

  1. I strongly prefer not to introduce architectural variations in these files, so I only provided an OMR implementation without the usual Connector stuff that enables architectural specializations.
  2. I also avoided the use of self() throughout these classes, which is an implicit statement that I am hoping extensions of these classes will only add function rather than override function.

Note for JitBuilder clients: OMR::VirtualMachine* classes have been promoted to full TR::VirtualMachine* classes. However, once the new client API work lands, all those classes are moving to the OMR::JitBuilder namespace anyway (sorry for the dual migration).

@mstoodle
Copy link
Contributor Author

mstoodle commented May 1, 2018

@genie-omr build all

@mstoodle mstoodle force-pushed the jitbuilder_enhance_extensibility branch from ac3df52 to 1d04a44 Compare May 1, 2018 14:37
@mstoodle
Copy link
Contributor Author

mstoodle commented May 1, 2018

@genie-omr build zlinux

@mstoodle mstoodle force-pushed the jitbuilder_enhance_extensibility branch from 1d04a44 to fb26736 Compare May 1, 2018 15:41
@mstoodle
Copy link
Contributor Author

mstoodle commented May 1, 2018

@genie-omr build zlinux

@0xdaryl 0xdaryl self-assigned this May 1, 2018
@mstoodle mstoodle force-pushed the jitbuilder_enhance_extensibility branch from fb26736 to 10101dc Compare May 1, 2018 17:00
@mstoodle
Copy link
Contributor Author

mstoodle commented May 1, 2018

(At least) One more time! @genie-omr build zlinux

@mstoodle
Copy link
Contributor Author

mstoodle commented May 1, 2018

@genie-omr build plinux

@mstoodle mstoodle force-pushed the jitbuilder_enhance_extensibility branch 5 times, most recently from 00ed563 to ca11e27 Compare May 1, 2018 20:11
@mstoodle
Copy link
Contributor Author

mstoodle commented May 1, 2018

yay @genie-omr build all

@mstoodle mstoodle changed the title WIP: enhance extensibility of JitBuilder classes Enhance extensibility of JitBuilder classes May 1, 2018
@mstoodle
Copy link
Contributor Author

mstoodle commented May 2, 2018

For the record, I think this one is ready for your consideration when you're ready, @0xdaryl (which is to say: I think I'm finally done iterating through build failures!).

@mstoodle mstoodle force-pushed the jitbuilder_enhance_extensibility branch from ca11e27 to 1271c17 Compare May 11, 2018 15:51
@mstoodle
Copy link
Contributor Author

Latest push only fixed the merge conflicts induced by #2529 .

@0xdaryl
Copy link
Contributor

0xdaryl commented May 14, 2018

With the constraints that you want, I wonder if we should start to use C++ language features to enforce some of these rules. Otherwise, your intentions will be lost over time. For instance, for the functions you expect to provide functionality for but do not want to be overridden, would you consider marking them virtual and use the C++11 final keyword to enable compile-time enforcement? Not every OMR build compiler supports the same level of C++11 unfortunately, but we could use an OMR_FINAL (for lack of a better name) macro in its place that maps to the final keyword on compiler versions that do support it and to nothing on those that don't. Very soon I suspect the OMR toolchain will be moving up to support newer compilers which means that at least some of the builds will be validating the proper use of the code as you intended (which is better than nothing), and hopefully armed with better devirtualization optimizations for final functions.

On a related note, there is an experiment underway to "revirtualize" the extension points in the extensible class hierarchy. That is, turn the extensibility points of a class into virtual functions and thereby eliminate the requirement for the self() functions. Using virtual functions as extension points is also useful in that we can introduce pure virtual functions for those extension points that must be supplied by a consuming class (for which there isn't a sensible default OMR implementation). I expect an issue to be created to describe this work soon, and it will be a discussion topic at the June 6 compiler architecture meeting.

@charliegracie
Copy link
Contributor

I would really recommend against the use of C++11 features. I am actively trying to get all current uses of C++11 features removed from the codebase as they are not supported on all of our platforms / compilers.

@mstoodle
Copy link
Contributor Author

@0xdaryl I'm not sure I understand your suggestion. What is the benefit to make a function virtual but marked as final versus just not making it virtual in the first place?

@mstoodle
Copy link
Contributor Author

mstoodle commented May 14, 2018

oh, i see, to prevent a subclass from overriding it anyway which would be visible via calls to the TR namespaced class but not to calls within that class's hierarchy (i.e. calls implicitly or explicitly via this)

@mstoodle
Copy link
Contributor Author

having all methods be tagged with virtual OMR_FINAL feels pretty ugly though :( .

@charliegracie
Copy link
Contributor

I would agree that tagging all of the functions would look ugly and not really add any value. @mstoodle can you rebase to get rid of the merge conflicts? @0xdaryl is there anything else you would like to see changed?

@mstoodle mstoodle force-pushed the jitbuilder_enhance_extensibility branch from 1271c17 to f538edf Compare June 11, 2018 03:10
@mstoodle
Copy link
Contributor Author

@genie-omr build all

@mstoodle
Copy link
Contributor Author

@charliegracie @0xdaryl rebased now. Anything else you think should be changed at this point?

@0xdaryl
Copy link
Contributor

0xdaryl commented Jun 25, 2018

I don't believe we should preclude the use of more modern C++ features if it makes understanding the code easier or allows the compiler to perform compile-time checks to enforce rules we have in the code base. Even more so if it avoids the development of specialized "linter" tools to catch transgressions. This is especially true if that C++ feature can easily be avoided on build compilers that do not support said feature (for instance, by simply hiding its use behind a macro). I get the argument that we need to avoid "modern" language features in order to increase broadest possible adoption, but there is also an argument to be made that some of those features are actually useful and beneficial to some projects. Precluding new language features may in fact be punishing those projects that choose to build with more modern toolchains by leaving important performance optimizations on the table or limiting their effect. It's a bit of a double-edged sword.

This PR is not the right forum to debate this topic and likely needs a broader project-level discussion to define the minimum language level that will be accepted and the minimum compiler levels (and there should be CI jobs that test them). We don't have a clearly documented standard to apply to changes proposed in a PR as to whether they're acceptable from a toolchain perspective or not. And since we don't, debates such as this will recur. Perhaps this should be part of the OMR release discussion (#2274) or make the toolchain part of the API we define for a release.

In the interests of moving this PR forward, however, I don't think there's any particular technique employed in this PR that's outside the spirit of extensible classes.

@mstoodle, the PR does need a rebase though.

@mstoodle
Copy link
Contributor Author

I'll rebase tonight and ping when it's ready. Thanks Daryl!

mstoodle added 16 commits June 26, 2018 09:42
In preparation for creating a JitBuilder extension for IlBuilder,
to facilitate the client API creation, the IlBuilder class needs
to become more like a fully extensible with an independent header.

Since compilertest provides an IlBuilder extension, it also needs
to be adjusted to account for the new structure.

Sigsned-off-by: Mark Stoodley <[email protected]>
In preparation for creating a JitBuilder extension for MethodBuilder,
to facilitate the client API creation, the MethodBuilder class needs
to become more like a fully extensible with an independent header.

Because the test compiler provides an extension of MethodBuilder,
its files were also adjusted to define a separate header file.

Signed-off-by: Mark Stoodley <[email protected]>
In preparation for creating a JitBuilder extension for BytecodeBuilder,
to facilitate the client API creation, the BytecodeBuilder class needs
to become more like a fully extensible with an independent header.

Signed-off-by: Mark Stoodley <[email protected]>
In preparation for creating a JitBuilder extension for IlType and
TypeDictionary, to facilitate the client API creation, the IlType
class needs to be separated from TypeDictionary.hpp/cpp and both
classes need to become more fully extensible with independent
headers.

Signed-off-by: Mark Stoodley <[email protected]>
In preparation for creating a JitBuilder extension for IlValue,
to facilitate the client API creation, the IlValue class needs
to become more like a fully extensible with an independent header.

Signed-off-by: Mark Stoodley <[email protected]>
In preparation for creating a JitBuilder extension for ThunkBuilder,
to facilitate the client API creation, the ThunkBuilder class needs
to become more like a fully extensible with an independent header.

Signed-off-by: Mark Stoodley <[email protected]>
In preparation for creating a JitBuilder extension for VirtualMachineState,
to facilitate the client API creation, the VirtualMachineState class needs
to become more like a fully extensible with an independent header.

Also change references to OMR::VirtualMachineState to TR::VirtualMachineState.

Signed-off-by: Mark Stoodley <[email protected]>
In preparation for creating a JitBuilder extension for VirtualMachineRegister,
to facilitate the client API creation, the VirtualMachineRegister class needs
to become more like a fully extensible with an independent header.

Also change references to OMR::VirtualMachineRegister to TR::VirtualMachineRegister.

Signed-off-by: Mark Stoodley <[email protected]>
In preparation for creating a JitBuilder extension for VirtualMachineRegisterInStruct,
to facilitate the client API creation, the VirtualMachineRegisterInStruct class needs
to become more like a fully extensible class with an independent header.

Signed-off-by: Mark Stoodley <[email protected]>
In preparation for creating a JitBuilder extension for VirtualMachineOperandArray,
to facilitate the client API creation, the VirtualMachineOperandArray class needs
to become more like a fully extensible with an independent header.

Signed-off-by: Mark Stoodley <[email protected]>
In preparation for creating a JitBuilder extension for VirtualMachineOperandStack,
to facilitate the client API creation, the VirtualMachineOperandStack class needs
to become more like a fully extensible with an independent header.

Signed-off-by: Mark Stoodley <[email protected]>
Makes these fields more usable as part of an extensible class.

Signed-off-by: Mark Stoodley <[email protected]>
Makes it easier to find a file; not much harder to maintain.

Signed-off-by: Mark Stoodley <[email protected]>
JitBuilder doesn't need to explicitly include these anymore; it gets
them from the base compiler objects.

Signed-off-by: Mark Stoodley <[email protected]>
Needed to prevent build errors for JitBuilder samples, but
will become unnecessary when JitBuilder migrates to the new
client API generators.

Signed-off-by: Mark Stoodley <[email protected]>
@mstoodle mstoodle force-pushed the jitbuilder_enhance_extensibility branch from f538edf to 902e227 Compare June 26, 2018 13:44
@mstoodle
Copy link
Contributor Author

For extra insurance: @genie-omr build all

@0xdaryl 0xdaryl merged commit 62ce390 into eclipse-omr:master Jun 27, 2018
dnakamura added a commit to dnakamura/openj9 that referenced this pull request Jun 28, 2018
Fixes error in omr acceptance build caused by eclipse-omr/omr#2515
Files marked "# Delete me" should be removed when omr changes are merged

Signed-off-by: Devin Nakamura <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants