- mov itmp1,%rdi /* move index into a0 */
- call new_arrayindexoutofboundsexception
-
- call asm_remove_native_stackinfo
-
- pop xpc /* just remove one quadword */
- pop xpc /* delete return address */
- sub $3,xpc /* faulting address is return adress - 3 */
- jmp asm_handle_exception
-
-nb_aastore_throw:
- /*call new_arraystoreexception*/
- add $24,%rsp
- pop xpc /* delete return address */
- sub $3,xpc /* faulting address is return adress - 3 */
- mov string_java_lang_ArrayStoreException,xptr
- jmp asm_throw_and_handle_exception
-
-
-/******************* function asm_initialize_thread_stack **********************
-* *
-* initialized a thread stack *
-* (to)->restorePoint = asm_initialize_thread_stack((u1*)(func), (to)->stackEnd)*
-* *
-*******************************************************************************/
-
-asm_initialize_thread_stack:
- sub $(7*8),%rsi
-
- xor %r10,%r10
- mov %r10,0*8(%rsi)
- mov %r10,1*8(%rsi)
- mov %r10,2*8(%rsi)
- mov %r10,3*8(%rsi)
- mov %r10,4*8(%rsi)
- mov %r10,5*8(%rsi)
-
- mov %rdi,6*8(%rsi) /* save (u1*) (func) */
- mov %rsi,%rax /* return restorepoint in %rax */
- ret
-
-
-/******************* function asm_perform_threadswitch *************************
-* *
-* void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
-* *
-* performs a threadswitch *
-* *
-*******************************************************************************/
-
-asm_perform_threadswitch:
- sub $(7*8),%rsp /* allocate stack frame */
-
- mov %rbx,0*8(%rsp)
- mov %rbp,1*8(%rsp)
- mov %r12,2*8(%rsp)
- mov %r13,3*8(%rsp)
- mov %r14,4*8(%rsp)
- mov %r15,5*8(%rsp)
-
- mov 7*8(%rsp),%rax /* save current return address */
- mov %rax,6*8(%rsp)
-
- mov %rsp,(%rdi) /* first argument **from */
- mov %rsp,(%rdx) /* third argument **stackTop */
-
- mov (%rsi),%rsp /* load new stack pointer */
-
- mov 0*8(%rsp),%rbx
- mov 1*8(%rsp),%rbp
- mov 2*8(%rsp),%r12
- mov 3*8(%rsp),%r13
- mov 4*8(%rsp),%r14
- mov 5*8(%rsp),%r15
-
- 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