- mov 6*8(%rsp),%rax /* restore return address */
- add $(7*8),%rsp /* free stack frame */
- mov %rax,(%rsp)
- ret
-
-
-/********************* function asm_switchstackandcall *************************
-* *
-* int asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
-* void *p); *
-* *
-* Switches to a new stack, calls a function and switches back. *
-* a0 (%rdi) new stack pointer *
-* a1 (%rsi) function pointer *
-* a2 (%rdx) pointer to variable where stack top should be stored *
-* a3 (%rcx) pointer to user data, is passed to the function *
-* *
-*******************************************************************************/
-
-asm_switchstackandcall:
- sub $(1*8),%rsp /* keep stack 16-byte aligned */
- sub $16,%rdi /* allocate new stack */
-
- mov 8(%rsp),%rax /* save return address on new stack */
- mov %rax,(%rdi)
- mov %rsp,8(%rdi) /* save old stack pointer on new stack*/
- mov %rsp,(%rdx) /* save old stack pointer to variable */
-
- mov %rdi,%rsp /* switch to new stack */
-
- mov %rcx,%rdi /* pass pointer */
- call *%rsi /* and call function */
-
- mov (%rsp),%r10 /* load return address */
- mov 8(%rsp),%rsp /* switch to old stack */
- add $(1*8),%rsp /* free stack space */
- mov %r10,(%rsp) /* write return adress */
- ret
-
-
-
-
-/************************ function asm_prepare_native_stackinfo ****************************
-* *
-* creates a stackfame for the begin of a native function (either builtin or not ) *
-* expected stack at begin of function *
-* .... *
-* address of the jit call which invokes the native *
-* begin address of stack frame of the java method *
-* method pointer or 0 (for built ins) *
-* padding for stackframesize 16*n+8 *
-* return address *
-* *
-* at end of function: *
-* ... *
-* address of the jit call which invokes the native *
-* begin address of stack frame of the java method *
-* method pointer or 0 (for built ins) *
-* address of thread specific top of native list *
-* old value of thread specific head *
-* padding for stackframesize 16*n+8) *
-* return address *
-* *
-* .... *
-* This thing is less efficient than the original #define (callerside) *
-* destroyes REG_ITMP2, keeps REG_ITMP1 *
-********************************************************************************************/
-
-
-asm_prepare_native_stackinfo:
- sub $16,%rsp /*space for the 2 new pointers*/
- mov 16(%rsp),itmp2
- mov itmp2,(%rsp)
- push itmp1
- call builtin_asm_get_stackframeinfo
-
- mov itmp1, 32(%rsp)
- mov (itmp1),itmp2
- mov itmp2,24(%rsp)
- mov %rsp,itmp2
- add $24,itmp2
- mov itmp2,(itmp1)
- pop itmp1
- ret
-
-
-
-/************************ function asm_remove _native_stackinfo *******************************************
-* *
-* removes a stackfame for the begin of a native function (either builtin or not) *
-* expected stack at begin of function *
-* address of the jit call which invokes the native *
-* begin address of stack frame of the java method *
-* method pointer or 0 (for built ins) *
-* address thread specific top of native list *
-* old value of thread specific head *
-* padding *
-* return address *
-* *
-* at end of function: *
-* .... *
-* return adresss of the jit call which invokes the native *
-* padding *
-* return address *
-* *
-* *
-* *
-* This thing is less efficient than the original #define (callerside), uses ITMP2,uses ITMP3,keeps ITMP1 *
-***********************************************************************************************************/
-
-asm_remove_native_stackinfo:
- mov 16(%rsp),itmp2
- mov 24(%rsp),itmp3
- mov itmp2,(itmp3)
- pop itmp3
- add $32,%rsp
- push itmp3
- ret
-
-
-
-asm_throw_and_handle_exception:
- push xpc /* the pushed XPC is directly below the java frame*/
- push $0
- push $0
- push $0 /*padding*/
- call asm_prepare_native_stackinfo /* be aware of the stack effect and calling convention explained above*/
- mov itmp1,%rdi
-
- call new_exception
-
- call asm_remove_native_stackinfo /* be aware of the stack effect and calling convention explained above*/
-
- pop xpc
- pop xpc
-
- jmp asm_handle_exception
- ret /*should never be reached */
-
-
-asm_throw_and_handle_hardware_arithmetic_exception:
-
- push xpc
- push $0 /* the pushed XPC is directly below the java frame*/
- push $0
- push $0 /*padding*/
- call asm_prepare_native_stackinfo /* be aware of the stack effect and calling convention explained above*/
-
- mov string_java_lang_ArithmeticException_message,%rsi
- mov string_java_lang_ArithmeticException,%rdi
-
- call new_exception_message
-
- call asm_remove_native_stackinfo /* be aware of the stack effect and calling convention explained above*/
- pop xpc
- pop xpc
-
- jmp asm_handle_exception
- ret /*should never be reached */
-
-
-asm_getclassvalues_atomic:
-_crit_restart2:
-_crit_begin2:
- movl offbaseval(a0),itmp1l
- movl offdiffval(a0),itmp2l
- movl offbaseval(a1),itmp3l
-_crit_end2:
- movl itmp1l,offcast_super_baseval(a2)
- movl itmp2l,offcast_super_diffval(a2)
- movl itmp3l,offcast_sub_baseval(a2)
- ret
-
- .data
-
-asm_criticalsections:
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
- .quad _crit_begin1
- .quad _crit_end1
- .quad _crit_restart1
- .quad _crit_begin2
- .quad _crit_end2
- .quad _crit_restart2