RFR: 8360389: Support printing from C2 compiled code [v3]

Benoît Maillard bmaillard at openjdk.org
Mon Aug 25 12:47:54 UTC 2025


On Wed, 20 Aug 2025 22:37:40 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

> What assembler is look like?
> 
> AOT code generation may have issue with this. We need to preserve C string passed to runtime call.

This is for example what we obtain with `-XX:CompileCommand=printassembly` for the `Square` example @vnkozlov. As arguments to the runtime call we pass a pointer to the `const char* str` and the value(s)/pointer(s) for the node(s) we want to print.


[Disassembly]
--------------------------------------------------------------------------------
[Constant Pool (empty)]

--------------------------------------------------------------------------------

[Verified Entry Point]
  # {method} {0x00007f4d6d07c230} 'square' '(I)I' in 'Square'
  # parm0:    rsi       = int
  #           [sp+0x20]  (sp of caller)
 ;; N1: #	out( B1 ) <- in( B1 )  Freq: 1
 ;; B1: #	out( N1 ) <- BLOCK HEAD IS JUNK  Freq: 1
  0x00007f4da0562b80:   	movl	%eax, -0x18000(%rsp)
  0x00007f4da0562b87:   	pushq	%rbp
  0x00007f4da0562b88:   	subq	$0x10, %rsp
  0x00007f4da0562b8c:   	cmpl	$0x0, 0x20(%r15)
  0x00007f4da0562b94:   	jne	0x4e                ;*synchronization entry
                                                            ; - Square::square at -1 (line 3)
  0x00007f4da0562b9a:   	movl	%esi, %ebp
  0x00007f4da0562b9c:   	imull	%esi, %ebp          ;*imul {reexecute=0 rethrow=0 return_oop=0}
                                                            ; - Square::square at 2 (line 3)
  0x00007f4da0562b9f:   	movabsq	$0x7f4da53eaed2, %rdi
  0x00007f4da0562ba9:   	movl	%ebp, %esi
  0x00007f4da0562bab:   	movabsq	$0x7f4da4df30f0, %r10;   {runtime_call void SharedRuntime::debug_print<int>(char const*, int)}
  0x00007f4da0562bb5:   	callq	*%r10
  0x00007f4da0562bb8:   	nopl	(%rax,%rax)         ;   {post_call_nop}
  0x00007f4da0562bc0:   	movl	%ebp, %eax
  0x00007f4da0562bc2:   	addq	$0x10, %rsp
  0x00007f4da0562bc6:   	popq	%rbp
  0x00007f4da0562bc7:   	cmpq	0x28(%r15), %rsp    ;   {poll_return}
  0x00007f4da0562bcb:   	ja	0x1
  0x00007f4da0562bd1:   	retq
  0x00007f4da0562bd2:   	movabsq	$0x7f4da0562bc7, %r10;   {internal_word}
  0x00007f4da0562bdc:   	movq	%r10, 0x5a8(%r15)
  0x00007f4da0562be3:   	jmp	0xb7078             ;   {runtime_call SafepointBlob}
  0x00007f4da0562be8:   	callq	0x9c793             ;   {runtime_call Stub::Stub Generator method_entry_barrier_stub}
  0x00007f4da0562bed:   	jmp	-0x58
  0x00007f4da0562bf2:   	hlt
  0x00007f4da0562bf3:   	hlt
  0x00007f4da0562bf4:   	hlt
  0x00007f4da0562bf5:   	hlt
  0x00007f4da0562bf6:   	hlt
  0x00007f4da0562bf7:   	hlt
[Exception Handler]
  0x00007f4da0562bf8:   	jmp	0x4f663             ;   {runtime_call ExceptionBlob}
[Deopt Handler Code]
  0x00007f4da0562bfd:   	callq	0x0
  0x00007f4da0562c02:   	subq	$0x5, (%rsp)
  0x00007f4da0562c07:   	jmp	0xb7374             ;   {runtime_call DeoptimizationBlob}
  0x00007f4da0562c0c:   	hlt
  0x00007f4da0562c0d:   	hlt
  0x00007f4da0562c0e:   	hlt
  0x00007f4da0562c0f:   	hlt
--------------------------------------------------------------------------------
[/Disassembly]



Is AOT code generation a concern even if this is only a debug feature, and that we have to modify the code to actually use it?

-------------

PR Comment: https://git.openjdk.org/jdk/pull/26475#issuecomment-3220117523


More information about the hotspot-dev mailing list