-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8360389: Support printing from C2 compiled code #26475
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back bmaillard! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@benoitmaillard The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
8360389: Add dump-style printing in recursive template 8360389: Use template for make_debug_print 8360389: Make debug_print_Type() template-based
…ked to CHECK_UNHANDLED_OOPS
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.
Great work Benoît! This will be very useful for debugging.
With the current changes, we only support adding printing during parsing, i.e. when GraphKit
is available. I think it would be great if we could add printing after parsing, for example only once a specific IGVN or loop optimization happened. Do you think that's feasible?
void OptoRuntime::debug_print_convert_type(const Type** fields, int* argp, Node *parm) { | ||
switch (parm->bottom_type()->basic_type()) { | ||
case T_BOOLEAN: | ||
fields[(*argp)++] = TypeInt::BOOL; |
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 you can use Type::get_const_basic_type(parm->bottom_type()->basic_type())
here and special case T_DOUBLE
/ T_LONG
.
fields[(*argp)++] = Type::HALF; | ||
break; | ||
case T_OBJECT: | ||
fields[(*argp)++] = TypePtr::NOTNULL; |
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 passing null should be okay as well, right? I would use TypeInstPtr::BOTTOM
here, which will be taking care of by Type::get_const_basic_type
.
int flags = RC_LEAF; | ||
address call_addr = CAST_FROM_FN_PTR(address, SharedRuntime::debug_print<TT...>); | ||
|
||
Node* str_node = new ConPNode(TypeRawPtr::make(((address) str))); |
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.
Don't you need a transform
here?
This PR adds support for printf-style from C2 compiled code. This is implemented as a runtime call to a C++ method that prints the values of the nodes passed as arguments. The runtime C++ method is with the help of variadic templates, as it is expected to support various combination of argument types.
Usage
Suppose we have the following java code:
We can attempt to print several things using the debug node. Here are two examples:
Printing arguments
Let's change the
Compile::return_values
method as follows. We can extract the argument nodes in a static array and then pass them toGraphKit::make_debug_print
along with a static string.Printing the return value
Similarly, we can extract the return value and pass it to
GraphKit::make_debug_print
:Running the code
We can then execute either example as follows:
We obtain the following output for the arguments example:
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26475/head:pull/26475
$ git checkout pull/26475
Update a local copy of the PR:
$ git checkout pull/26475
$ git pull https://git.openjdk.org/jdk.git pull/26475/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26475
View PR using the GUI difftool:
$ git pr show -t 26475
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26475.diff