Print JIT Build Code for Java Jotspot

I wrote a very silly test class in Java:

public class Vector3 {
   public double x,y,z ;

   public Vector3(double x, double y, double z) {
       this.x=x ; this.y=y ; this.z=z ;
   }

   public Vector3 subst(Vector3 v) {
      return new Vector3(x-v.x,y-v.y,z-v.z) ;
   }
}

Then I wanted to see the code generated by the JIT Java Hotspot JIT (Client VM build 23.7-b01). I used the option "-XX: + PrintAssembly" and hsdis-i386.dll from http://classparser.blogspot.dk/2010/03/hsdis-i386dll.html

Here is the interesting part of the generated code (I skipped initializing a new object. EDIT: code for the subst method). Obviously, ebx is a pointer to "this", and edx is a pointer to an argument.

lds    edi,(bad)
sti    
adc    BYTE PTR [ebx+8],al  ;*getfield x
mov    edx,DWORD PTR [esp+56]
lds    edi,(bad)          ; implicit exception: dispatches to 0x02611f2d
sti    
adc    BYTE PTR [edx+8],cl  ;*getfield x
lds    edi,(bad)
sti    
adc    BYTE PTR [ebx+16],dl  ;*getfield y
lds    edi,(bad)
sti    
adc    BYTE PTR [edx+16],bl  ;*getfield y
lds    edi,(bad)
sti    
adc    BYTE PTR [ebx+24],ah  ;*getfield z
lds    edi,(bad)
sti    
adc    BYTE PTR [edx+24],ch  ;*getfield z
lds    edi,(bad)
sti    
pop    esp
rol    ebp,0xfb
adc    DWORD PTR [eax+8],eax  ;*putfield x
lds    ebp,(bad)
jmp    0x02611f66
rol    ebp,cl
sti    
adc    DWORD PTR [eax+16],edx  ;*putfield y
lds    ebx,(bad)
fistp  DWORD PTR [ebp-59]
sti    
adc    DWORD PTR [eax+24],esp  ;*putfield z

Honestly, I'm not very familiar with the x86 build, but does this code make sense to you? What are these weird instructions like "adc BYTE PTR [edx + 8], cl" do? I would expect some FPU instructions.

+5
1

. hsdis-i386.dll, binutils 2.23. , http://dropzone.nfshost.com/hsdis.htm ( , x86. 64- , JVM )

:

vmovsd xmm0,QWORD PTR [ebx+0x8]  ;*getfield x
mov    edx,DWORD PTR [esp+0x40]
vmovsd xmm1,QWORD PTR [edx+0x8]  ;*getfield x
vmovsd xmm2,QWORD PTR [ebx+0x10] ;*getfield y
vmovsd xmm3,QWORD PTR [edx+0x10] ;*getfield y
vmovsd xmm4,QWORD PTR [ebx+0x18] ;*getfield z
vmovsd xmm5,QWORD PTR [edx+0x18] ;*getfield z
vsubsd xmm0,xmm0,xmm1
vmovsd QWORD PTR [eax+0x8],xmm0  ;*putfield x
vsubsd xmm2,xmm2,xmm3
vmovsd QWORD PTR [eax+0x10],xmm2 ;*putfield y
vsubsd xmm4,xmm4,xmm5
vmovsd QWORD PTR [eax+0x18],xmm4 ;*putfield z
+6

All Articles