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.