Reinhard Grafl
Christian Thalinger
- $Id: asmpart.S 2272 2005-04-11 15:49:51Z twisti $
+ $Id: asmpart.S 2285 2005-04-12 20:32:34Z twisti $
*/
.globl asm_handle_exception
.globl asm_handle_nat_exception
- .globl asm_get_putstatic
- .globl asm_get_putfield
- .globl asm_builtin_new
- .globl asm_builtin_newarray
- .globl asm_builtin_multianewarray
- .globl asm_invokestatic_special
- .globl asm_invokevirtual
- .globl asm_invokeinterface
- .globl asm_checkcast_instanceof_flags
- .globl asm_checkcast_instanceof_interface
- .globl asm_checkcast_class
- .globl asm_instanceof_class
+ .globl asm_patcher_get_putstatic
+ .globl asm_patcher_get_putfield
+ .globl asm_patcher_builtin_new
+ .globl asm_patcher_builtin_newarray
+ .globl asm_patcher_builtin_multianewarray
+ .globl asm_patcher_builtin_checkarraycast
+ .globl asm_patcher_builtin_arrayinstanceof
+ .globl asm_patcher_invokestatic_special
+ .globl asm_patcher_invokevirtual
+ .globl asm_patcher_invokeinterface
+ .globl asm_patcher_checkcast_instanceof_flags
+ .globl asm_patcher_checkcast_instanceof_interface
+ .globl asm_patcher_checkcast_class
+ .globl asm_patcher_instanceof_class
+
.globl asm_check_clinit
.globl asm_builtin_checkarraycast
jmp ex_stack_loop
-/* asm_get_putstatic ***********************************************************
+/* asm_patcher_get_putstatic ***************************************************
XXX
*******************************************************************************/
-asm_get_putstatic:
+asm_patcher_get_putstatic:
sub $(15*8),%rsp /* stack frame (16-byte aligned) */
SAVE_ARGUMENT_REGISTERS
add $((2+15)*8),%rsp /* remove stack frame, keep ra */
test v0,v0 /* exception thrown? */
- jz L_asm_codepatcher_exception
+ jz L_asm_patcher_exception
pop itmp2 /* get return address */
sub $5,itmp2 /* remove size of `call rel32' */
mov v0,(itmp3) /* move field address to data segment */
jmp *itmp2 /* call new patched code */
-L_asm_codepatcher_exception:
+L_asm_patcher_exception:
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
call builtin_asm_get_exceptionptrptr
mov v0,itmp2
jmp asm_handle_exception
-/* asm_get_putfield ************************************************************
+/* asm_patcher_get_putfield ****************************************************
XXX
*******************************************************************************/
-asm_get_putfield:
+asm_patcher_get_putfield:
sub $(17*8),%rsp /* stack frame (16-byte aligned) */
SAVE_ARGUMENT_REGISTERS
cmp $-1,v0l /* exception thrown? test for -1, */
/* because field offset can be 0 */
- jz L_asm_codepatcher_exception_with_stack_frame
+ jz L_asm_patcher_exception_with_stack_frame
mov (1+17)*8(%rsp),itmp3 /* get machine code */
mov (2+17)*8(%rsp),itmp2 /* get return address */
mov itmp3,(itmp2) /* patch back original code (8 bytes) */
cmpb $0xf2,(itmp2) /* test for movsd */
- je L_asm_get_putfield_float
+ je L_asm_patcher_get_putfield_float
cmpb $0xf3,(itmp2) /* test for movss */
- je L_asm_get_putfield_float
+ je L_asm_patcher_get_putfield_float
cmpb $0x24,3(itmp2) /* check for (%rsp) or (%r12) */
- je L_asm_get_putfield_r12_membase
+ je L_asm_patcher_get_putfield_r12_membase
mov v0l,3(itmp2) /* patch field offset */
- jmp L_asm_get_putfield_normal
+ jmp L_asm_patcher_get_putfield_normal
-L_asm_get_putfield_float:
+L_asm_patcher_get_putfield_float:
mov v0l,5(itmp2) /* patch field offset (position + 2) */
- jmp L_asm_get_putfield_normal
+ jmp L_asm_patcher_get_putfield_normal
-L_asm_get_putfield_r12_membase:
+L_asm_patcher_get_putfield_r12_membase:
mov v0l,4(itmp2) /* patch field offset (position + 1) */
-L_asm_get_putfield_normal:
+L_asm_patcher_get_putfield_normal:
mov itmp2,itmp3
mov 15*8(%rsp),itmp1 /* restore itmp1 and itmp2 */
add $((3+17)*8),%rsp /* remove stack frame */
jmp *itmp3 /* call new patched code */
-L_asm_codepatcher_exception_with_stack_frame:
+L_asm_patcher_exception_with_stack_frame:
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
call builtin_asm_get_exceptionptrptr
mov %rax,itmp2
jmp asm_handle_exception
-/* asm_builtin_new *************************************************************
+/* asm_patcher_builtin_new *****************************************************
XXX
*******************************************************************************/
-asm_builtin_new:
+asm_patcher_builtin_new:
sub $(8*1),%rsp /* stack frame (16-byte aligned) */
call helper_resolve_classinfo /* call the helper function */
add $(8*1),%rsp /* remove stack frame */
test v0,v0 /* exception thrown? */
- jz L_asm_codepatcher_exception
+ jz L_asm_patcher_exception
pop itmp2 /* get return address */
- sub $(3+10+10),itmp2 /* 3 (callq) + 10 (movi) + 10 (movi) */
+ sub $(10+10+3),itmp2 /* 10 (movi) + 10 (movi) + 3 (callq) */
mov v0,2(itmp2) /* patch in new classinfo*: 2 (mov) */
lea builtin_new,itmp1 /* get address from builtin_new */
jmp *itmp2 /* call new patched code */
-/* asm_builtin_newarray ********************************************************
+/* asm_patcher_builtin_newarray ************************************************
XXX
*******************************************************************************/
-asm_builtin_newarray:
+asm_patcher_builtin_newarray:
sub $(8*1),%rsp /* stack frame (16-byte aligned) */
mov a0,0*8(%rsp) /* save argument */
mov a1,a0 /* pass class reference */
mov 0*8(%rsp),a0 /* restore argument */
add $(8*1),%rsp /* remove stack frame */
test v0,v0 /* exception thrown? */
- jz L_asm_codepatcher_exception
+ jz L_asm_patcher_exception
pop itmp2 /* get return address */
- sub $(3+10+10),itmp2 /* 3 (callq) + 10 (movi) + 10 (movi) */
+ sub $(10+10+3),itmp2 /* 10 (movi) + 10 (movi) + 3 (callq) */
mov v0,2(itmp2) /* patch in new vftbl*: 2 (mov) */
lea builtin_newarray,itmp1 /* get address from builtin_newarray */
jmp *itmp2 /* call new patched code */
-/* asm_builtin_multianewarray **************************************************
+/* asm_patcher_builtin_multianewarray ******************************************
XXX
*******************************************************************************/
-asm_builtin_multianewarray:
+asm_patcher_builtin_multianewarray:
sub $(1*8),%rsp /* stack frame (16-byte aligned) */
mov a1,a0 /* pass class reference */
call helper_resolve_classinfo_vftbl /* call the helper function */
add $(1*8),%rsp /* remove stack frame */
test v0,v0 /* exception thrown? */
- jz L_asm_codepatcher_exception
+ jz L_asm_patcher_exception
pop itmp2 /* get return address */
sub $(3+10+3+10+10),itmp2 /* go back to a0 mov */
jmp *itmp2 /* call new patched code */
-/* asm_invokestatic_special ****************************************************
+/* asm_patcher_builtin_checkarraycast ******************************************
+
+ XXX
+
+ Arguments:
+ a1 contains the class reference
+
+*******************************************************************************/
+
+asm_patcher_builtin_checkarraycast:
+ sub $(8*1),%rsp /* stack frame (16-byte aligned) */
+ mov a0,0*8(%rsp) /* save argument */
+ mov a1,a0 /* pass class reference */
+ call helper_resolve_classinfo_vftbl /* call the helper function */
+ mov 0*8(%rsp),a0 /* restore argument */
+ add $(8*1),%rsp /* remove stack frame */
+ test v0,v0 /* exception thrown? */
+ jz L_asm_patcher_exception
+
+ pop itmp2 /* get return address */
+ sub $(10+10+3),itmp2 /* 10 (movi) + 10 (movi) + 3 (callq) */
+ mov v0,2(itmp2) /* patch in new vftbl*: 2 (mov) */
+
+ lea asm_builtin_checkarraycast,itmp1 /* get function address */
+ mov itmp1,12(itmp2) /* patch back function address */
+ jmp *itmp2 /* call new patched code */
+
+
+/* asm_patcher_builtin_arrayinstanceof *****************************************
+
+ XXX
+
+ Arguments:
+ a1 contains the class reference
+
+*******************************************************************************/
+
+asm_patcher_builtin_arrayinstanceof:
+ sub $(8*1),%rsp /* stack frame (16-byte aligned) */
+ mov a0,0*8(%rsp) /* save argument */
+ mov a1,a0 /* pass class reference */
+ call helper_resolve_classinfo_vftbl /* call the helper function */
+ mov 0*8(%rsp),a0 /* restore argument */
+ add $(8*1),%rsp /* remove stack frame */
+ test v0,v0 /* exception thrown? */
+ jz L_asm_patcher_exception
+
+ pop itmp2 /* get return address */
+ sub $(10+10+3),itmp2 /* 10 (movi) + 10 (movi) + 3 (callq) */
+ mov v0,2(itmp2) /* patch in new vftbl*: 2 (mov) */
+
+ lea builtin_arrayinstanceof,itmp1 /* get function address */
+ mov itmp1,12(itmp2) /* patch back function address */
+ jmp *itmp2 /* call new patched code */
+
+
+/* asm_patcher_invokestatic_special ********************************************
XXX
*******************************************************************************/
-asm_invokestatic_special:
+asm_patcher_invokestatic_special:
sub $(15*8),%rsp /* stack frame (16-byte aligned) */
SAVE_ARGUMENT_REGISTERS
add $((2+15)*8),%rsp /* remove stack frame, keep ra */
test v0,v0 /* exception thrown? */
- jz L_asm_codepatcher_exception
+ jz L_asm_patcher_exception
pop itmp2 /* get return address */
sub $5,itmp2 /* remove size of `call rel32' */
jmp *itmp2 /* call new patched code */
-/* asm_invokevirtual ***********************************************************
+/* asm_patcher_invokevirtual ***************************************************
XXX
*******************************************************************************/
-asm_invokevirtual:
+asm_patcher_invokevirtual:
sub $(15*8),%rsp /* stack frame (16-byte aligned) */
SAVE_ARGUMENT_REGISTERS
cmp $-1,v0l /* exception thrown? test for -1, */
/* because vftblindex can be 0 */
- je L_asm_codepatcher_exception
+ je L_asm_patcher_exception
pop itmp2 /* get return address */
sub $5,itmp2 /* remove size of `call rel32' */
jmp *itmp2 /* call new patched code */
-/* asm_invokeinterface *********************************************************
+/* asm_patcher_invokeinterface *************************************************
XXX
*******************************************************************************/
-asm_invokeinterface:
+asm_patcher_invokeinterface:
sub $(15*8),%rsp /* stack frame (16-byte aligned) */
SAVE_ARGUMENT_REGISTERS
add $((2+15)*8),%rsp /* remove stack frame, keep ra */
test v0,v0 /* exception thrown? */
- jz L_asm_codepatcher_exception
+ jz L_asm_patcher_exception
pop itmp2 /* get return address */
sub $5,itmp2 /* remove size of `call rel32' */
jmp *itmp2 /* call new patched code */
-/* asm_checkcast_instanceof_flags **********************************************
+/* asm_patcher_checkcast_instanceof_flags **************************************
XXX
*******************************************************************************/
-asm_checkcast_instanceof_flags:
+asm_patcher_checkcast_instanceof_flags:
sub $(17*8),%rsp /* stack frame (16-byte aligned) */
SAVE_ARGUMENT_REGISTERS
cmp $-1,v0l /* exception thrown? test for -1, */
/* because class flags can be 0 */
- jz L_asm_codepatcher_exception_with_stack_frame
+ jz L_asm_patcher_exception_with_stack_frame
mov (1+17)*8(%rsp),itmp3 /* get machine code */
mov (2+17)*8(%rsp),itmp2 /* get return address */
jmp *itmp3 /* call new patched code */
-/* asm_checkcast_instanceof_interface ******************************************
+/* asm_patcher_checkcast_instanceof_interface **********************************
XXX
*******************************************************************************/
-asm_checkcast_instanceof_interface:
+asm_patcher_checkcast_instanceof_interface:
sub $(17*8),%rsp /* stack frame (16-byte aligned) */
SAVE_ARGUMENT_REGISTERS
cmp $-1,v0l /* exception thrown? test for -1, */
/* because class index can be 0 */
- jz L_asm_codepatcher_exception_with_stack_frame
+ jz L_asm_patcher_exception_with_stack_frame
mov (1+17)*8(%rsp),itmp3 /* get machine code */
mov (2+17)*8(%rsp),itmp2 /* get return address */
jmp *itmp3 /* call new patched code */
-/* asm_checkcast_class *********************************************************
+/* asm_patcher_checkcast_class *************************************************
XXX
*******************************************************************************/
-asm_checkcast_class:
+asm_patcher_checkcast_class:
sub $(17*8),%rsp /* stack frame (16-byte aligned) */
SAVE_ARGUMENT_REGISTERS
RESTORE_TEMPORARY_REGISTERS
test v0,v0 /* exception thrown? */
- jz L_asm_codepatcher_exception_with_stack_frame
+ jz L_asm_patcher_exception_with_stack_frame
mov (1+17)*8(%rsp),itmp3 /* get machine code */
mov (2+17)*8(%rsp),itmp2 /* get return address */
jmp *itmp3 /* call new patched code */
-/* asm_instanceof_class ********************************************************
+/* asm_patcher_instanceof_class ************************************************
XXX
*******************************************************************************/
-asm_instanceof_class:
+asm_patcher_instanceof_class:
sub $(17*8),%rsp /* stack frame (16-byte aligned) */
SAVE_ARGUMENT_REGISTERS
RESTORE_TEMPORARY_REGISTERS
test v0,v0 /* exception thrown? */
- jz L_asm_codepatcher_exception_with_stack_frame
+ jz L_asm_patcher_exception_with_stack_frame
mov (1+17)*8(%rsp),itmp3 /* get machine code */
mov (2+17)*8(%rsp),itmp2 /* get return address */