Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8360389

Support printing from C2 compiled code

XMLWordPrintable

      For debugging purposes, it would be useful to have a node in C2 IR that takes a string or integer value that is then printed when the compiled code is executed. For example, this would be useful to print intermediate values in registers / on stack or print errors in verification code.

      I think this could be implemented as a CallLeafPureNode to a runtime method that just prints the value (see JDK-8347901).

      We already have HaltNodes that print something but then fail hard (which we don't want for this kind of debug printing):

      instruct ShouldNotReachHere() %{
        match(Halt);
        format %{ "stop\t# ShouldNotReachHere" %}
        ins_encode %{
          if (is_reachable()) {
            const char* str = __ code_string(_halt_reason);
            __ stop(str);
          }
        %}
        ins_pipe(pipe_slow);
      %}

      Also, they don't allow printing dynamic values.

            bmaillard BenoƮt Maillard
            thartmann Tobias Hartmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: