-
Bug
-
Resolution: Unresolved
-
P3
-
17, 18
The nice abstract assembly dumping added by JDK-8213084 is not so precise with respect to the position of code comments. On x86, this means post processing MachCode sections with a disassembler can get confused.
This is best shown with an example. With Graal, a ScopeDesc can be associated with the instruction immediately following a call (which is often a nop).
So we expect to see something like this:
----------------------------------------------------------------------------------------------------------------
0x00000001101bf5f4: ; {runtime_call DeoptimizationBlob}
0x00000001101bf5f4: e881 6cfd | ff
0x00000001101bf5f9: ; ImmutableOopMap {}
;*iload_1 {reexecute=1 rethrow=0 return_oop=0}
; - (reexecute) java.util.stream.StreamOpFlag::combineOpFlags@0 (line 708)
; {runtime_call Stub<ExceptionHandlerStub.exceptionHandler>}
0x00000001101bf5f9: 90 e801 | cdff ff90
----------------------------------------------------------------------------------------------------------------
However, the output produced for this case is:
----------------------------------------------------------------------------------------------------------------
0x00000001101bf5f4: ; {runtime_call DeoptimizationBlob}
0x00000001101bf5f4: e881 6cfd
0x00000001101bf5f8: ; ImmutableOopMap {}
;*iload_1 {reexecute=1 rethrow=0 return_oop=0}
; - (reexecute) java.util.stream.StreamOpFlag::combineOpFlags@0 (line 708)
; {runtime_call Stub<ExceptionHandlerStub.exceptionHandler>}
0x00000001101bf5f8: ff90 e801 | cdff ff90
----------------------------------------------------------------------------------------------------------------
When post-processing with a disassembler, this means we get:
----------------------------------------------------------------------------------------------------------------
0x00000001101bf5f4: <unknown: e8 81 6c fd> ; {runtime_call DeoptimizationBlob}
0x00000001101bf5f8: call qword ptr [rax - 0x32fe18] ; ImmutableOopMap {}
;*iload_1 {reexecute=1 rethrow=0 return_oop=0}
; - (reexecute) java.util.stream.StreamOpFlag::combineOpFlags@0 (line 708)
; {runtime_call Stub<ExceptionHandlerStub.exceptionHandler>}
[Deopt Handler Code]
0x00000001101bf600: call 0x110196020 ; {runtime_call DeoptimizationBlob}
----------------------------------------------------------------------------------------------------------------
instead of:
----------------------------------------------------------------------------------------------------------------
0x00000001101bf5f4: call 0x11019627a ; {runtime_call DeoptimizationBlob}
0x00000001101bf5f9: nop ; ImmutableOopMap {}
;*iload_1 {reexecute=1 rethrow=0 return_oop=0}
; - (reexecute) java.util.stream.StreamOpFlag::combineOpFlags@0 (line 708)
; {runtime_call Stub<ExceptionHandlerStub.exceptionHandler>}
0x00000001101bf5fa: call 0x1101bc300
----------------------------------------------------------------------------------------------------------------
I think the main change needed is for a code comment to be emitted at exactly the start address of the instruction it is associated with. That will prevent the instruction stream in a MachNode section from being interrupted in the middle of an instruction.
This is best shown with an example. With Graal, a ScopeDesc can be associated with the instruction immediately following a call (which is often a nop).
So we expect to see something like this:
----------------------------------------------------------------------------------------------------------------
0x00000001101bf5f4: ; {runtime_call DeoptimizationBlob}
0x00000001101bf5f4: e881 6cfd | ff
0x00000001101bf5f9: ; ImmutableOopMap {}
;*iload_1 {reexecute=1 rethrow=0 return_oop=0}
; - (reexecute) java.util.stream.StreamOpFlag::combineOpFlags@0 (line 708)
; {runtime_call Stub<ExceptionHandlerStub.exceptionHandler>}
0x00000001101bf5f9: 90 e801 | cdff ff90
----------------------------------------------------------------------------------------------------------------
However, the output produced for this case is:
----------------------------------------------------------------------------------------------------------------
0x00000001101bf5f4: ; {runtime_call DeoptimizationBlob}
0x00000001101bf5f4: e881 6cfd
0x00000001101bf5f8: ; ImmutableOopMap {}
;*iload_1 {reexecute=1 rethrow=0 return_oop=0}
; - (reexecute) java.util.stream.StreamOpFlag::combineOpFlags@0 (line 708)
; {runtime_call Stub<ExceptionHandlerStub.exceptionHandler>}
0x00000001101bf5f8: ff90 e801 | cdff ff90
----------------------------------------------------------------------------------------------------------------
When post-processing with a disassembler, this means we get:
----------------------------------------------------------------------------------------------------------------
0x00000001101bf5f4: <unknown: e8 81 6c fd> ; {runtime_call DeoptimizationBlob}
0x00000001101bf5f8: call qword ptr [rax - 0x32fe18] ; ImmutableOopMap {}
;*iload_1 {reexecute=1 rethrow=0 return_oop=0}
; - (reexecute) java.util.stream.StreamOpFlag::combineOpFlags@0 (line 708)
; {runtime_call Stub<ExceptionHandlerStub.exceptionHandler>}
[Deopt Handler Code]
0x00000001101bf600: call 0x110196020 ; {runtime_call DeoptimizationBlob}
----------------------------------------------------------------------------------------------------------------
instead of:
----------------------------------------------------------------------------------------------------------------
0x00000001101bf5f4: call 0x11019627a ; {runtime_call DeoptimizationBlob}
0x00000001101bf5f9: nop ; ImmutableOopMap {}
;*iload_1 {reexecute=1 rethrow=0 return_oop=0}
; - (reexecute) java.util.stream.StreamOpFlag::combineOpFlags@0 (line 708)
; {runtime_call Stub<ExceptionHandlerStub.exceptionHandler>}
0x00000001101bf5fa: call 0x1101bc300
----------------------------------------------------------------------------------------------------------------
I think the main change needed is for a code comment to be emitted at exactly the start address of the instruction it is associated with. That will prevent the instruction stream in a MachNode section from being interrupted in the middle of an instruction.
- relates to
-
JDK-8213084 Rework and enhance Print[Opto]Assembly output
- Resolved