-
Notifications
You must be signed in to change notification settings - Fork 728
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
Initial Commit of the MicroJIT Project #9578
base: master
Are you sure you want to change the base?
Initial Commit of the MicroJIT Project #9578
Conversation
1897524
to
9e2c60e
Compare
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.
This is a massive PR. Could this be broken up into smaller pieces? Also is there an issue outlining the general design?
This definitely warrants and issue with a design. FYI @mstoodle since this likely is big enought to trigger a higher level eclipse process. |
Perhaps also introducing this work at one of the upcoming OpenJ9 community calls. |
I had not thought of that, I'll begin creating the issue immediately and link it in the PR 👍 |
yes, the size may warrant a CQ be filled out, as we get closer to the final state of the PR. |
An issue has been created and mentioned in the PR. Thank you for the feedback 😄 |
I think the discussion should move over to the design issue (which needs a lot more details on the proposal) and probably discussion on a community call before a contribution of this size and complexity can be reviewed. @Scott-Young-6746 is the commit history as clean as it could be? It would be nice to have logical commits for the places where the code integrates into OpenJ9 as well as for the various parts of the microjit. At present it seems more like a stream of evoluation which is going to make the review harder since everyone has to look at everything... @0xdaryl I am guesisng we are going to need some manual ECA verification on this because there are multiple commit authors on this code... |
Thank you for the feedback Andrew. Are there any resources you can point me to that would illustrate how to modify the commit history? I also received a suggestion late in the creation of the PR to wrap my code in |
compiler/microjit/x/amd64/AMD64Linkage.cpp \ | ||
compiler/microjit/x/amd64/templates/linkage.nasm \ | ||
compiler/microjit/x/amd64/templates/bytecodes.nasm | ||
endif |
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 line-end is missing here.
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.
Thank you, I've updated all file-endings to have the required new-line at EOF.
@@ -288,7 +288,8 @@ ifeq ($(HOST_ARCH),x) | |||
NASM_INCLUDES=\ | |||
$(J9SRC)/oti \ | |||
$(J9SRC)/compiler \ | |||
$(J9SRC)/compiler/x/runtime | |||
$(J9SRC)/compiler/x/runtime \ | |||
$(J9SRC)/compiler/microjit/assembly |
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.
Why is this not conditional on J9VM_OPT_MICROJIT
?
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.
Thank you for catching this, it has been moved into a guarded area.
static void setInitialMJITCountUnsynchronized(J9Method *method, int32_t mjitThreshold, int32_t trThreshold) | ||
{ | ||
int32_t value = 0; | ||
if(mjitThreshold < trThreshold) |
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.
Formatting: space after if
(throughout).
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 have updated the formatting of all if statements added by us in this file. Thank you for catching this!
int32_t value = 0; | ||
if(mjitThreshold < trThreshold) | ||
{ | ||
value = (trThreshold - mjitThreshold << 1) | 1; |
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.
More parentheses required:
value = ((trThreshold - mjitThreshold) << 1) | 1;
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.
Updated now, thank you for catching this.
|
||
char * jitStackOverflowPatchLocation = NULL; | ||
|
||
mjit_cg.setPeakStackSize(romMethod->maxStack * 8); |
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 is 8
here? Does it assume a 64-bit target?
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 are starting with x86-64, however this should not have been a magic value and we do want to make supporting other architectures easier. I added a method for getting the pointer size from the MicroJIT code generator.
runtime/oti/j9generated.h
Outdated
@@ -39,6 +39,10 @@ typedef struct J9SidecarExitFunction { | |||
void (*func)(void); | |||
} J9SidecarExitFunction; | |||
|
|||
#if defined(J9VM_OPT_MICROJIT) | |||
typedef struct J9JITConfig J9MicroJITConfig; |
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's the value of this definition? Why not just use struct J9JITConfig
?
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 this was a hold-over from the original attempt to port the old MicroJIT. I've removed it and replaced usage with the struct J9JITConfig
as suggested.
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 only remaining change to this file is the copyright date: please revert that - no changes are required here.
@@ -282,7 +282,7 @@ const char * const maciek_JavaBCNames[] = { | |||
"JBunimplemented" /* 240 */, | |||
"JBunimplemented" /* 241 */, | |||
"JBunimplemented" /* 242 */, | |||
"JBreturnToMicroJIT" /* 243 */, | |||
"JBunimplemented" /* 243 */, |
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 this change should be conditional on defined(J9VM_OPT_MICROJIT)
.
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've replaced it with an if defined() else endif
section. This might need to be removed later though; as far as I know JBreturnToMicroJIT
was for the old MicroJIT and nothing is using it anymore that I know of.
I just took a quick glance over the code so I haven't digested this technically yet. However, one question I do have is other than the compilation control aspects, is there any sharing between the OpenJ9 JIT (i.e., what you find in the |
Even if it is standalone in terms of operation of the template part could we share assets from the codegens (like the instruction encoding etc) to save duplication? Could we share some of the linkage implementation? GC mode support for things like read/write barriers? It would also be good if we could standardize control options and logging formats/styles where reasonable. I would love an overview of where the current version is at. Again, my goal here is to lower the barrier to entry. We could almost even think of the microjit as another opt level below noOpt perhaps? |
Thanks for the feedback Daryl! We do currently use the J9JITConfig, and methods supporting MicroJIT have been added to MetaData creation. We do have our own space for building supporting calls to allow the GC to work, but this area has a lot of work left to do. We will likely be moving towards using the existing Linkage and Properties in TR for MicroJIT as it might help with porting later. |
Thanks for taking a look at this Andrew! I'll put a quick overview of the project's progress so far here: Currently the project supports compiling a limited number of leaf methods. We have implemented and tested addition, subtraction, and multiplication of |
A fairly large number of bytecodes not in the PR are being tested and will be PRed once we get everything here up to code. On our internal build we are able to compile methods with the following bytecodes:
We are also trying to clean up as much of the debugging infrastructure so that it is in one place instead of peppered throughout the code. We currently use the Compilation object for acquiring some meta-data for compilation. We use a copy&patch approach to templates, which are all written in NASM assembly at the moment. MicroJIT relies on TR for some data structures and is called by TR in the CompilationThread.cpp, so I don't know how we could cleanly separate the two unless we took the common components used by both and lifted them to a separate folder. Something like:
|
Issue #9714 details a missing component of MicroJIT, namely support for OSR. OSR support is not planned for this PR, however, MicroJIT should not cause unexpected behavior when OSR is enabled. |
{ | ||
value = ((trThreshold - mjitThreshold) << 1) | 1; | ||
} | ||
method->extra2 = reinterpret_cast<void *>(value); |
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.
This is likely to elicit a warning from the compiler: the cast simultaneously changes both the width and signed-ness.
TR_MethodMetaData* metaData = NULL; | ||
J9Method *method = NULL; | ||
TR::CodeCache* codeCache = NULL; |
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'd like to see better formatting consistency; this method uses three styles:
TR_ResolvedMethod * compilee
TR_MethodMetaData* metaData
J9Method *method
Semantically, the *
binds more tightly to the parameter or local name, so the first and third styles are less mis-leading. Pick one (not the second style) and be consistent.
if (_methodBeingCompiled->isDLTCompile()) | ||
compiler->setDltBcIndex(static_cast<J9::MethodInProgressDetails &>(_methodBeingCompiled->getMethodDetails()).getByteCodeIndex()); | ||
|
||
bool volatile haveLockedClassUnloadMonitor = false; // used for compilation without VM acces |
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.
typo: acces -> access
addParamIntToStack(RegisterStack* stack, U_16 size) | ||
{ | ||
if(!stack->useRAX){ | ||
stack->useRAX = size/8; |
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 is the range of values for size
? If it might be as large as 64, then useRAX
must be wider than 2 bits.
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.
Thank you for the review Keith. This function is called from a function which is checking the parameters that are passed via type signature. It's converting bytes to slots so the range should be {8,16}. Though I am interested in knowing if there are any special cases which might not conform to that on the JIT side.
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.
Thank you for the review Keith. This function is called from a function which is checking the parameters that are passed via type signature. It's converting bytes to slots so the range should be {8,16}. Though I am interested in knowing if there are any special cases which might not conform to that on the JIT side.
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'm not sure the space savings here is worth the added complexity: Why not just use uint8_t
for fields like useRAX
? The name could be improved the 'use' prefix implies 'boolean' to me.
*(uint32_t *)cursor = e->_instructionStartPC, cursor += 4; | ||
*(uint32_t *)cursor = e->_instructionEndPC, cursor += 4; | ||
*(uint32_t *)cursor = e->_instructionHandlerPC, cursor += 4; | ||
*(uint32_t *)cursor = e->_catchType, cursor += 4; |
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.
There's no need to use the comma operator here, and the statements should be on separate lines:
*(uint32_t *)cursor = e->_instructionStartPC;
cursor += 4;
Likewise, several places below.
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 again for the review Keith. This code was created because we needed a function to work on the MJIT_ExceptionTableEntryIterator
. There is a nearly identical one used by TR above which was used as a starting point for this. The above lines of code were copied from that location.
Should I leave this code a is, modify both, or only make the change in the createMJITExceptionTable
version?
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'll let someone more familiar with the existing code comment on whether it should be updated, but my suggestion is to avoid the comma operator in new code.
|
||
return data; | ||
} | ||
#endif /* J9VM_OPT_MICROJIT */ |
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.
Every file should end with a final new-line.
5c323b3
to
73ef3a3
Compare
This PR has been rebased and updated with changes to address the previous review by @keithc-ca |
First meeting to discuss microjit in OpenJ9 Friday 19 June 2020 1pm EST on https://ibm.webex.com/join/ajcraik all are welcome |
73ef3a3
to
e338498
Compare
The first meeting to discuss the contribution of MicroJIT to the OpenJ9 project has concluded. Overall it was a very positive and informative discussion - thank you everyone who participated and @Scott-Young-6746 for the overview of the current compiler design. We have agreed to have another call on July 3 at 1pm EST continue discussions. In the meantime I will enumerate here some of the specific areas of integration where the MicroJIT developers are looking to get some specific technical help with integration:
We have not had a discussion around testing, but we do need to consider how the template JIT is tested both at a unit and integration level (@fjeremic @Leonardo2718 @smlambert @LinHu2016 ) There is probably also a need for some documentation of the design in a markdown document to summarize some of the overview provided, but that can wait until the integration discussion/design has progressed. I will post a link to the follow-on agenda once I have found a home for it as well as a posting to the recording of this meeting on the openj9 youtube channel once it is ready. We will also look to create a microjit channel on the openj9 community slack for further specific technical discussions to avoid this issue getting too large since there are a number of things to be worked through in preparation for a merge. |
Regarding the compilation control question, I am wondering if there is some indication as to the relative compilation (CPU) time and scratch memory taken for micro JIT compiles in relation to cold and warm compilations in the full JIT. Perhaps @Scott-Young-6746 or @mpirvu have or can collect some data to give some insight that may help with the thought process on how to view these compiles in the overall picture. |
071a1b5
to
3967023
Compare
…JIT project. This project aims to introduce a lightweight templated JIT compiler to the OpenJ9 project. While this feature is not yet production ready, it is usable in short applications from compiling some methods. Co-authored-by: Eric Coffin <[email protected]> Co-authored-by: Julie Brown <[email protected]> Co-authored-by: Shubham Verma <[email protected]> Co-authored-by: Harpreet Kaur <[email protected]> Co-authored-by: Aaron Graham <[email protected]> Signed-off-by: Scott Young <[email protected]> Added assembly macro to aid in future template generation for a new lightweight templated JIT (MicroJIT) //Signed-off-by: Scott Young <[email protected]> Added MicroJIT exception table and included MetaData creation functions for later use by a MicroJIT compiler. //Signed-off-by: Scott Young <[email protected]> Added an assert for MicroJIT to identify errors as separate from TR. //Signed-off-by: Scott Young <[email protected]> Added first templates to be used by a future MicroJIT code generator for x86_64. //Signed-off-by: Scott Young <[email protected]> Added a MicroJIT code generator. This code generator is not yet used to create runnable compiled methods. //Signed-off-by: Scott Young <[email protected]> Added links and options to allow MicroJIT code to be generated and executed. //Signed-off-by: Scott Young <[email protected]> Cleaned up or correct rebased code where functionality tested on an earlier pull of OpenJ9 no longer integrated correctly. WIP. //Signed-off-by: Scott Young <[email protected]> Fixed issue setting initial MicroJIT theshold count for methods. //Signed-off-by: Scott Young <[email protected]> Added MicroJIT exception table and included MetaData creation functions for later use by a MicroJIT compiler. //Signed-off-by: Scott Young <[email protected]> Added links and options to allow MicroJIT code to be generated and executed. //Signed-off-by: Scott Young <[email protected]> Cleaned up or correct rebased code where functionality tested on an earlier pull of OpenJ9 no longer integrated correctly. WIP. //Signed-off-by: Scott Young <[email protected]> Fixed issue setting initial MicroJIT theshold count for methods. //Signed-off-by: Scott Young <[email protected]> Fixed the Microjit threshold count The counter in countAndCompile counts down from the TR threshold to zero; we need to set the MJIT threshold to the difference between the TR threshold and the provided MJIT count. For example if the TR threshold is 1000 and the MJIT threshold is 100, this would set the extra2 counter to 900. After 100 iteration MJIT would compile the method. //Signed-off-by: Eric Coffin <[email protected]> Log the method signature after the method has compiled The log message can be used by a test script to ensure the target method has been compiled by the MicroJIT compiler. //Signed-off-by: Eric Coffin <[email protected]> Add isub bytecode support for MJIT //Signed-off-by: Eric Coffin <[email protected]> Add imul bytecode //Signed-off-by: Eric Coffin <[email protected]> Add idiv bytecode TODO: Add support for ArithmeticException (divide by zero check) //Signed-off-by: Eric Coffin <[email protected]> Fix idiv bytecode Given we're dealing with a DWORD rather than a QWORD, use eax rather than rax. Ensures sign bit is extended into edx (via cdq). //Signed-off-by: Eric Coffin <[email protected]> Added new macros for MicroJIT assembly; Moved peak stack allocation from CompilationInfoPerThreadBase::mjit to AMD64CodeGenerator; Replaced specalized loading for loading tempaltes with generic loading template. //Signed-off-by: Scott Young <[email protected]> Fixed an error related to tool assisted merge conflic resolution and a bug related to the initial storing of arguments in the local array. //Signed-off-by: Scott Young <[email protected]> Added support for storing in the local array. Cleaned up Bytecode switch statement in generate body for loading and storing bytecodes using helper macros //Signed-off-by: Scott Young <[email protected]> Remove unused iload templates //Signed-off-by: Eric Coffin <[email protected]> Fixed error in calculating size of stack for MicroJIT //Signed-off-by: Scott Young <[email protected]> Changed the stack based parameter map to a table based map. //Signed-off-by: Scott Young <[email protected]> Initial commit of CodegenGC files used for creating GCMaps and Stack Atlas for MJIT //Signed-off-by: Scott Young <[email protected]> Support recompilation after MJIT failure //Signed-off-by: Eric Coffin <[email protected]> Add support for ladd and lreturn //Signed-off-by: Hapreet Kaur <[email protected]> Clean up formatting //Signed-off-by: Eric Coffin <[email protected]> Add JIT Hooks to mjit //Signed-off-by: Eric Coffin <[email protected]> Added Paramater map creation to MJIT AMD64CodegenGC, added aload and getfield bytecodes to templates and CodeGen, added support for storing params on the stack into the local array during prologue. //Signed-off-by: Scott Young <[email protected]> Release code cache after MJIT failure //Signed-off-by: Eric Coffin <[email protected]> Support long method arguments TR appears to require 1 slot (8 bytes) when the last argument in a method is a long. //Signed-off-by: Eric Coffin <[email protected]> Implemented the getstatic and putstatic bytecode templates. Updated the return templates to support void return type functions and moved the return generation to a separate function similar to the load and store bytecodes. //Signed-off-by: Scott Young <[email protected]> Implemented the lsub and lmul bytecodes //Signed-off-by: Harpreet Kaur <[email protected]> Added or updated copyright on files created for MJIT. Completed new MJIT specific stack atlas and GC Maps, and supporting side tables. //Signed-off-by: Scott Young <[email protected]> Fixed errors created during rebase. //Signed-off-by: Scott Young <[email protected]> Added support for compiling OpenJ9 with or without MicroJIT //Signed-off-by: Scott Young <[email protected]> Updated outdated copyright information in files modified as part of initial PR to public Eclipse OpenJ9 repository //Signed-off-by: Scott Young <[email protected]> Misc changes to MicroJIT files, detailed below: Guarded against several inclusions of MicroJIT files in build processes using define guards. Gaurded against changes for MicroJIT in files outside of compiler/microjit using define guards. Corrected file endings to include a newline at EOF for all modified or added files for MicroJIT. Removed typedef for J9MicroJITConfig and changed old usages to directly use struct J9JITConfig. Replaced magic numbers referencing pointer size to use an inlined call instead. Fixed copyright begin dates for newly created files for MicroJIT. Repalced accidently removed lines for debug symbol stripping. //Signed-off-by: Scott Young <[email protected]> Misc changes to MicroJIT files, detailed below: Fixed problems with build files incorrectly updating includes Updated spacing between `if` and opening paren in CompilationThread Added descriptions to public methods of MJIT::CodeGenerator Removed duplicate comment in BytecodeInterpreter //Signed-off-by: Scott Young <[email protected]> Replaced erronious tab characters with appropreate space counts. //Signed-off-by: Scott Young <[email protected]> Replaced erronious tab characters with appropreate space counts in MicroJIT linkage. //Signed-off-by: Scott Young <[email protected]> Fixed incorrect usage of spaces over tabs when readding line to strip debug symbols. //Signed-off-by: Scott Young <[email protected]> Misc. changes to for MicroJIT detailed below: Added J9VM_OPT_MICROJIT comments to several `endif` statements. Fixed incorrectly ordered options in J9Options caused by previous fix to accidently deleted option. //Signed-off-by: Scott Young <[email protected]> Fixed incorrect indexing when making local parameter table in MicroJIT prologue. //Signed-off-by: Scott Young <[email protected]> Added newline to end of MetaData.cpp. Changed types in setInitialMJITCountUnsynchronized to prevent compiler warnings about increasing size. Fixed inconsitent placement of pointer specifier in variable declarations in CompilationThread.cpp //Signed-off-by: Scott Young <[email protected]> Reverted copyright change in j9generated.h, since file is no longer modified from master version. //Signed-off-by: Scott Young <[email protected]> Updated pointer syntax in MicroJIT directory to match usage in CompilationThread.cpp and maintain internal consistency. //Signed-off-by: Scott Young <[email protected]> Partial implementation of GCR for MicroJIT //Signed-off-by: Scott Young <[email protected]> Modified MicroJIT to use GCR as a recompilation trigger to cause TR to compile. Removed the extra2 field. MicroJIT now shares an extra field with TR. //Signed-off-by: Scott Young <[email protected]> Fixed bug causing microjit to compile even when not given the Xjit:mjitEnabled=1 option //Signed-off-by: Scott Young <[email protected]> Fixed incorrect options usage when getting the mjitEnabled flag for choosing whether to compile with MicroJIT or TR. Fixed a bug causing the MicroJIT default count overriding the TR count in the extra field when not using mjitEnabled as an xjit option. //Signed-off-by: Scott Young <[email protected]> Modified the count setting to correctly set the extra field when using microjit. Changed code formatting of added code in HookedByTheJit for microjit to match surrounding code. Removed gaurd from counting in microjited methods to prevent microjited code from running for too long. //Signed-off-by: Scott Young <[email protected]> Fixed problems with patching after removing gaurd in microjit GCR code generation. //Signed-off-by: Scott Young <[email protected]> Added support for TR compilations after failing to compile with MicroJIT. Removed TRCount field from J9Method and changed mechanism for setting counts for MicroJIT counting blocks. //Signed-off-by: Scott Young <[email protected]> Added CMakeList.txt files to microjit to allow for compilation with CMake //Signed-off-by: Scott Young <[email protected]> Fixed issues with CMake build configuration for MicroJIT.\n Updated configuration files that prevented MicroJIT from being compiled correctly with CMake. Removed dead code from BytecodeInterpreter.hpp from previous verion of MicroJIT. //Signed-off-by: Scott Young <[email protected]> Added missing Copyright information to newly added CMakeLists.txt files //Signed-off-by: Scott Young <[email protected]> Update copyright and removed dead code. Changed boolean to bit flag in J9PersistenInfo. Added debugging text entry for logging in rossa.cpp //Signed-off-by: Scott Young <[email protected]> stashed changes for workstation transfer //Signed-off-by: Scott Young <[email protected]> Fixed signature logging and stack atlas for MJIT Added new line to print format string for signature in the mjit method of CompilationThreadInfoPerThreadBase The stack atlas creator now correctly skips the second slot of two slot data types when iterating over the local array. //Signed-off-by: Scott Young <[email protected]> Overhauled the creation of CFGs in MicroJIT The CFG creation in MicroJIT was needlessly terse and did not hold all the information that was needed for getting profiling data from the interpreter profiler. The CFG creation process now stores all the required information to get these values from the profiler when using the JProfilingBlock optimization. //Signed-off-by: Scott Young <[email protected]> Added MicroJIT methods for profiling to CFG. The J9CFG has recieved new methods which will only exist and be compiled when using MicroJIT. These methods will allow for the setting of edge frequencies without any IL trees in the CFG. //Signed-off-by: Scott Young <[email protected]> Custom MJIT ByteCodeIterator Exposes printByteCodes() for printing entire method and adds helpers for getting the mnemonic and opcode. Add _printByteCodes boolean to CodeGenerator to limit BC debug statements in MJIT. Fixes opcode on compilation failure. //Signed-off-by: Eric Coffin <[email protected]> //Signed-off-by: Scott Young <[email protected]> Changed InternalMetaData to MJIT::ByteCodeIterator //Signed-off-by: Scott Young <[email protected]> Partial implementation of `invokestatic` support //Signed-off-by: Scott Young <[email protected]> Added support for `invokestatic` in MicroJIT code generation. Fixed problem with integers using full 64-bit registers, instead of lower 32-bit for MicroJIT code. //Signed-off-by: Scott Young <[email protected]> Support for conditionals and goto Adds initial support for ifne and ificmpge and goto. //Signed-off-by: Eric Coffin <[email protected]> //Signed-off-by: Scott Young <[email protected]> MicroJIT - Add constants and iand Adds support for: - iconst_<i> - lconst_<l> - fconst_<f> - bipush - iand - land - ior - lor - ixor - lxor //Signed-off-by: Julie Brown <[email protected]> Add ificmpgt to MJIT Adds ificmpgt and add fixes the missing switch statements for other branching bytecodes. //Signed-off-by: Eric Coffin <[email protected]> MicroJIT - Patch missing break statement This commit patches a previous commit in which there was a missing break statement //Signed-off-by: Julie Brown <[email protected]> MicroJIT - Patch iconst<i> and lconst_<l> This commit updates the bytecode templates for iconst_<i> and lconst_<l> to use dword for integer types and qword for long types //Signed-off-by: Julie Brown <[email protected]> Added support for iinc bytecode //Signed-off-by: Harpreet Kaur <[email protected]> Fixes for MJIT Fixes ifne by replacing cmp with test. Allocates correct array size on the stack, which was previously causing a crash. //Signed-off-by: Eric Coffin <[email protected]> //Signed-off-by: Scott Young <[email protected]> Fixed accidental setting of extra field with MicroJIT start address during post compilation phase. Clearing registers in tempaltes before moves to prevent incorrect values from being partially kept. Fixed accidental exclusion of J9VM_OPT_MICROJIT from nasm defines. Now saving caller preserved registers used by MicroJIT before calling. //Signed-off-by: Scott Young <[email protected]> MicroJIT - Add support for dup bytecodes This commit adds bytecode support for: - dup - dup_x1 - dup_x2 - dup2 - dup2_x1 - dup2_x2 These bytecodes have not yet been tested for correctness; writing test files for these will require support for invokespecial and new. //Signed-off-by: Julie Brown <[email protected]> Added support for ldiv bytecode //Signed-off-by: Harpreet Kaur <[email protected]> MicroJIT - Add support for ineg and lneg This commit adds support for ineg and lneg bytecodes //Signed-off-by: Julie Brown <[email protected]> Log compilation success //Signed-off-by: Eric Coffin <[email protected]> Wrap logging in define guards To improve performance wrap all logging in define guards. //Signed-off-by: Eric Coffin <[email protected]> //Signed-off-by: Scott Young <[email protected]> MicroJIT - Added support for irem and lrem //Signed-off-by: Harpreet Kaur <[email protected]> Changed extra2 to act similarly to the extra field to help, fixing a crash caused when not running MicroJIT, but compiling it. //Signed-off-by: Scott Young <[email protected]> MicroJIT: Add support for i2l and l2i This commit adds support for the i2l and l2i bytecodes //Signed-off-by: Julie Brown <[email protected]> Fixed errors causing invokestatic to fail in some cases. MicroJIT now checks if the method has been compiled with TR before running it from interpreter. Fixed problem causing invokations of MicroJITed methods from JITed methods to enter at the interpreters entry point. //Signed-off-by: Scott Young <[email protected]> Removed unnecessary comment from j2iTransition. //Signed-off-by: Scott Young <[email protected]> Fixed problem with bipush patching. //Signed-off-by: Scott Young <[email protected]> MicroJIT - Added support for shift bytecodes //Signed-off-by: Harpreet Kaur <[email protected]> Some edits to the long shift bytecodes //Signed-off-by: Harpreet Kaur <[email protected]> Fixed long paramters and shortened shift templates //Signed-off-by: Harpreet Kaur <[email protected]> //Signed-off-by: Scott Young <[email protected]> Function Declaration Edit //Signed-off-by: Harpreet Kaur <[email protected]> MicroJIT: Add support for i2b and i2s bytecodes This commit adds support for the i2b and i2s bytecodes. //Signed-off-by: Julie Brown <[email protected]> //Signed-off-by: Scott Young <[email protected]> MicroJIT: Add support for sipush bytecode This commit adds support for the sipush bytecode. Also makes some edits to the iconst templates to specify the stack slot as being qword instead of dword. //Signed-off-by: Julie Brown <[email protected]> MicroJIT: Add support for i2c bytecode This commit adds support for the i2c bytecode //Signed-off-by: Julie Brown <[email protected]> MicroJIT: Add support for if<cond> and if_icmp<cond> This commit adds support for ifeq, iflt, ifle, ifgt, ifge, if_icmpeq, if_icmpne, if_icmplt, and if_icmple //Signed-off-by: Julie Brown <[email protected]> MicroJIT: Add support for lcmp This commit adds support for the lcmp bytecode //Signed-off-by: Julie Brown <[email protected]> //Signed-off-by: Scott Young <[email protected]> MicroJIT - Added support for fadd, fsub and fmul //Signed-off-by: Harpreet Kaur <[email protected]> Added fReturnTemplate for returning floats //Signed-off-by: Harpreet Kaur <[email protected]> MicroJIT - Added support for fdiv and fneg bytecodes //Signed-off-by: Harpreet Kaur <[email protected]> MicroJIT - Added support for double bytecodes //Signed-off-by: Harpreet Kaur <[email protected]> MicroJIT: Add support for fcmpg and fcmpl This commit adds support for fcmpg and fcmpl. Also makes changes to lcmp which was not behaving properly. //Signed-off-by: Julie Brown <[email protected]> MicroJIT: Remove comment about fconst //Signed-off-by: Julie Brown <[email protected]> MicroJIT - Added support for ddiv and dneg //Signed-off-by: Harpreet Kaur <[email protected]> MicroJIT - Fixed bug for longs //Signed-off-by: Harpreet Kaur <[email protected]> //Signed-off-by: Scott Young <[email protected]> Change MJIT computation stack longs to single slot This commit makes changes to the MicroJIT computation stack to use two slots for longs and doubles. This change is necessary for the stack bytecodes to work properly. It is also beneficial for future work with TR, as this will make the MicroJIT computation stack match up with TR //Signed-off-by: Julie Brown <[email protected]> //Signed-off-by: Scott Young <[email protected]> MJIT: Insert missing break statement This commit patches a previous commit in which a break statement was omitted //Signed-off-by: Julie Brown <[email protected]> MicroJIT: Add support for all stack bytecodes //Signed-off-by: Julie Brown <[email protected]> MicroJIT: Add supoort for dcmpl and dcmpg //Signed-off-by: Julie Brown <[email protected]> MicroJIT: Add support for dconst //Signed-off-by: Julie Brown <[email protected]> MicroJIT: Add support for i2d, l2d, d2i, d2l //Signed-off-by: Julie Brown <[email protected]> MicroJIT: Add support ifnull, ifnonnull, if_acmpeq, if_acmpne Adds support for above listed bytecodes. These are untested //Signed-off-by: Julie Brown <[email protected]> MicroJIT - Added support for d2f and f2d bytecodes //Signed-off-by: Harpreet Kaur <[email protected]> MicroJIT: Add support for i2f, l2f, f2i, f2l //Signed-off-by: Harpreet Kaur <[email protected]> MicroJIT - Added support for frem and drem //Signed-off-by: Harpreet Kaur <[email protected]> //Signed-off-by: Scott Young <[email protected]> MicroJIT - Added support for getfield and putfield //Signed-off-by: Harpreet Kaur <[email protected]> //Signed-off-by: Scott Young <[email protected]> Removed references to the old extra2 During the rebase, references to the old extra2 field reappered These references were removed. //Signed-off-by: Scott Young <[email protected]> Misc. changes to MicroJIT code detailed below Removed references to the now removed trtlookup IL Changed signed ints that were not meant to be negative to unsigned Changed iterator in MicroJIT MetaData creation to the MJIT iterator Fixed mismatched declaration and definition signatures from rebase Switched SSE remainder helper calls in MJIT to use the helper lookup //Signed-off-by: Scott Young <[email protected]> Changed assertion to log in MJIT Change an assertion in the logic for finding the stack offsets to instead log the info and end compilation. //Signed-off-by: Scott Young <[email protected]> Readded unintentionally removed newline //Signed-off-by: Scott Young <[email protected]> Fixed placement of define guard in J9CFG //Signed-off-by: Scott Young <[email protected]> Linkage & Properties Structure Changes //Signed-off-by: Harpreet Kaur <[email protected]> Added define guard on include for microjit //Signed-off-by: Scott Young <[email protected]> Misc changes to profiling for MicroJIT Added checks for calling MicroJIT frequency setter on methods compiled by MJIT. Fixed incorrect usage of heap memory by supporting classes for making CFGs in MicroJIT. Fixed logical errors in the supporting classes used to generate a CFG in MicroJIT. Added optimization strategy for MicroJIT. Added early exit in JProfilingBlock for MicroJIT to allow for early testing of MicroJIT frequency setting before creation of counter placement code path for MicroJIT. //Signed-off-by: Scott Young <[email protected]> Fixed errors with JNI in MJIT //Signed-off-by: Scott Young <[email protected]> Temporarily removed support for addresses in MJIT //Signed-off-by: Scott Young <[email protected]> Uncommented disabled BCs and Fixed issue with sipush //Signed-off-by: Scott Young <[email protected]> Added GotoW support (Untested) //Signed-off-by: Shubham Verma <[email protected]> Changes to Codegen for invokestatic to fix interpreter calling and stack slot count problems. //Signed-off-by: Scott Young <[email protected]> MicroJIT - Fix compile errors in gotow //Signed-off-by: Harpreet Kaur <[email protected]> Fixed MicroJIT causing crashes when mis-handling object references. Added codesize estimation calculation. //Signed-off-by: Scott Young <[email protected]> Fixed GCMap and Invoke static issues. Slotcount was not being multiplied by slot-size when setting offsets for saving and loading arguments. Local index was being incorrectly assigned when looping over the parameter map in meta-data creation phase. //Signed-off-by: Scott Young <[email protected]> Fixed typo in comments for several templates Fixed slot errors on jumps Some conditional branches were reducing from 2 to 1 slot when they should have been reducing from 2 to 0. This has been corrected. //Signed-off-by: Scott Young <[email protected]> MicroJIT Linkage Refactoring //Signed-off-by: Harpreet Kaur <[email protected]> Replacing MJIT CodeGenerator class parameter with TR Compilation class in linkage constructor //Signed-off-by: Harpreet Kaur <[email protected]> Passing comp->cg() as parameter to the linkage constructor //Signed-off-by: Harpreet Kaur <[email protected]> Fetching TR properties initialization code //Signed-off-by: Harpreet Kaur <[email protected]> Using cg and _properties for function parameters //Signed-off-by: Harpreet Kaur <[email protected]> Parameter name changes and passing properties structure as a pointer TODO: MicroJIT to use the setOffsetToFirstParm method //Signed-off-by: Harpreet Kaur <[email protected]> Fetching default return registers from properties structure //Signed-off-by: Harpreet Kaur <[email protected]> Handling addresses and patching requisite slots for different datatypes //Signed-off-by: Harpreet Kaur <[email protected]> Changes to generateBody //Signed-off-by: Harpreet Kaur <[email protected]> Fetching default argument registers from properties structure //Signed-off-by: Harpreet Kaur <[email protected]> Getting default return registers from linkage properties in remainder bytecodes //Signed-off-by: Harpreet Kaur <[email protected]> Misc. Changes to linkage and bytecodes to fix bugs. Turned off support for get and put field until write barriers can be implemented. Added verbose log check for mjit log messages //Signed-off-by: Scott Young <[email protected]> MJIT DSL for templates and new jmp template //Signed-off-by: Scott Young <[email protected]> Added define guards to microjit hook in profiler //Signed-off-by: Scott Young <[email protected]> Misc bug fixes to MJIT compiler Fixed preprologue incorrect use of 5 byte jump instead of 2 byte jump. Added field to identify uninitialized entries in local and param tables. Fixed handling of loading and storing of references. Fixed handling of passing references to callee methods. Added verbose log checks to verbose logging in MJIT compiler. //Signed-off-by: Scott Young <[email protected]> Handle Special Case for Longs and Doubles in the First Slot of the Param Table //Signed-off-by: Aaron Graham <[email protected]> Guard Against Negative Indices Being Accessible in the Param, or Local, Table Entries //Signed-off-by: Aaron Graham <[email protected]> Fix Initialization Check in Param and Local Table Entries //Signed-off-by: Aaron Graham <[email protected]> Fixing compile errors during linkage rebase //Signed-off-by: Harpreet Kaur <[email protected]> Changing copyright dates and formatting in bytecodes.nasm //Signed-off-by: Harpreet Kaur <[email protected]> Commenting out the untested goto_w bytecode and some copyright changes //Signed-off-by: Harpreet Kaur <[email protected]> Fixed holes in codecache. Rewrote side tables. //Signed-off-by: Scott <[email protected]> Fixed MJIT issue with references and static fields //Co-authored-by: Scott <[email protected]> //Signed-off-by: Harpreet Kaur <[email protected]> Removed trailing whitespace from modified cpp/hpp/nasm files //Signed-off-by: Scott Young <[email protected]> Removed additional whitespace found in .mk files and missed .cpp files. //Signed-off-by: Scott Young <[email protected]> Updated Copyright on files changed by this PR that were not changed this year to the current year. //Signed-off-by: Scott Young <[email protected]> Fixed additional trailing whitepace missed from previous commits //Signed-off-by: Scott Young <[email protected]> Co-authored-by: Eric Coffin <[email protected]> Co-authored-by: Julie Brown <[email protected]> Co-authored-by: Shubham Verma <[email protected]> Co-authored-by: Harpreet Kaur <[email protected]> Co-authored-by: Aaron Graham <[email protected]> Signed-off-by: Scott Young <[email protected]>
Signed-off-by: Scott Young <[email protected]>
Signed-off-by: Scott Young <[email protected]>
Signed-off-by: Scott Young <[email protected]>
Signed-off-by: Scott Young <[email protected]>
Signed-off-by: Scott Young <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Scott Young <[email protected]>
Signed-off-by: Scott Young <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
… and documentation for HW and LW Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
…tended flags Signed-off-by: Harpreet Kaur <[email protected]>
…ing suggestions Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
Signed-off-by: Harpreet Kaur <[email protected]>
3967023
to
0de87ac
Compare
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 didn't go through the codegen/optimizer changes, but the infra and control updates look good.
MicroJIT is a work-in-progress templated JIT compiler that is a part of a research project between IBM and UNB. This PR is the initial contribution of MicroJIT.
Given an
openj9-openjdk-jdk8
repository with support for the--enable-microjit
flag, these commits will allow someone to test the current partial implementation of MicroJIT which can compile relatively few methods, however, it is asynchronous and does not prevent TR from compiling.Compiling this project without the
--enable-microjit
flag in a supportingopenj9-openjdk-jdk8
, or in a repository without support for--enable-microjit
, does not compile code associated with the MicroJIT project.When compiling with the
--enable-microjit
flag in a supportingopenj9-openjdk-jdk8
this code modifies theBytecodeInterpreter
and theCompilationInfoPerThreadBase
to allow methods to be compiled with the prototypical MicroJIT, and execute those compiled methods, without impeding the interpreter's ability to maintain an accurate count for TRs compilation threshold.This PR also contains additions to several files in
openj9/runtime/compiler
to support MicroJIT compilation and MetaData structures to support both method compilation and execution of compiled methods.See also:
ibmruntimes/openj9-openjdk-jdk8#413
Issue #9582
Signed-off-by: Scott Young [email protected]