1 /* src/vm/jit/x86_64/asmpart.S - Java-C interface functions for x86_64
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Andreas Krall
31 Changes: Edwin Steiner
33 $Id: asmpart.S 4623 2006-03-16 00:05:18Z edwin $
43 #include "vm/jit/abi.h"
44 #include "vm/jit/x86_64/arch.h"
45 #include "vm/jit/x86_64/offsets.h"
47 #include "vm/jit/methodheader.h"
53 /* exported functions and variables *******************************************/
55 .globl asm_vm_call_method
56 .globl asm_vm_call_method_int
57 .globl asm_vm_call_method_long
58 .globl asm_vm_call_method_float
59 .globl asm_vm_call_method_double
61 .globl asm_call_jit_compiler
62 .globl asm_handle_exception
63 .globl asm_handle_nat_exception
65 .globl asm_wrapper_patcher
67 .globl asm_replacement_out
68 .globl asm_replacement_in
70 .globl asm_builtin_f2i
71 .globl asm_builtin_f2l
72 .globl asm_builtin_d2i
73 .globl asm_builtin_d2l
75 .globl asm_perform_threadswitch
76 .globl asm_initialize_thread_stack
77 .globl asm_switchstackandcall
78 .globl asm_criticalsections
79 .globl asm_getclassvalues_atomic
82 /********************* function asm_calljavafunction ***************************
84 * This function calls a Java-method (which possibly needs compilation) *
85 * with up to 4 address parameters. *
87 * This functions calls the JIT-compiler which eventually translates the *
88 * method into machine code. *
91 * javaobject_header *asm_calljavamethod (methodinfo *m, *
92 * void *arg1, void *arg2, void *arg3, void *arg4); *
94 *******************************************************************************/
98 .quad 0 /* catch type all */
99 .quad calljava_xhandler2 /* handler pc */
100 .quad calljava_xhandler2 /* end pc */
101 .quad L_asm_vm_call_method /* start pc */
102 .long 1 /* extable size */
104 .quad 0 /* line number table start */
105 .quad 0 /* line number table size */
107 .long 0 /* fltsave */
108 .long 0 /* intsave */
111 .long 24 /* frame size */
112 .quad 0 /* method pointer (pointer to name) */
115 asm_vm_call_method_int:
116 asm_vm_call_method_long:
117 asm_vm_call_method_float:
118 asm_vm_call_method_double:
119 L_asm_vm_call_method: /* required for PIC code */
120 sub $(7*8),sp /* keep stack 16-byte aligned */
121 mov %rbx,0*8(sp) /* %rbx is not a callee saved in cacao*/
128 mov a0,itmp1 /* move method pointer for compiler */
129 xor %rbp,%rbp /* set argument stack frame to zero */
131 test a1,a1 /* maybe we have no args... */
134 mov a1,itmp3 /* arg count */
135 mov a2,itmp2 /* pointer to arg block */
137 mov itmp2,%r14 /* save argument block pointer */
138 mov itmp3,%r15 /* save argument count */
140 sub $sizevmarg,itmp2 /* initialize pointer (smaller code) */
141 add $1,itmp3 /* initialize argument count */
142 xor %r12,%r12 /* initialize integer argument counter*/
143 xor %r13,%r13 /* initialize float argument counter */
146 add $sizevmarg,itmp2 /* goto next argument block */
147 dec itmp3 /* argument count - 1 */
148 jz L_register_copy_done
149 andb $0x02,offvmargtype(itmp2) /* is this a float/double type? */
150 jnz L_register_handle_float /* yes, handle it */
152 cmp $INT_ARG_CNT,%r12 /* are we out of integer argument */
153 je L_register_copy /* register? yes, next loop */
155 lea jumptable_integer(%rip),%rbp
156 mov 0(%rbp,%r12,8),%rbx
157 inc %r12 /* integer argument counter + 1 */
160 L_register_handle_float:
161 cmp $FLT_ARG_CNT,%r13 /* are we out of float argument */
162 je L_register_copy /* register? yes, next loop */
164 lea jumptable_float(%rip),%rbp
165 mov 0(%rbp,%r13,8),%rbx
166 inc %r13 /* float argument counter + 1 */
169 L_register_copy_done:
170 mov %r15,%rbp /* calculate remaining arguments */
171 sub %r12,%rbp /* - integer arguments in registers */
172 sub %r13,%rbp /* - float arguments in registers */
173 jle L_copy_done /* are all assigned to registers? */
175 and $0xfffffffffffffffe,%rbp /* keep stack 16-byte aligned */
176 shl $3,%rbp /* calculate stack size */
177 sub %rbp,sp /* stack frame for arguments */
178 mov sp,%rbx /* use %rbx as temp sp */
180 sub $sizevmarg,%r14 /* initialize pointer (smaller code) */
181 add $1,%r15 /* initialize argument count */
184 add $sizevmarg,%r14 /* goto next argument block */
185 dec %r15 /* are there any arguments left? */
186 jz L_copy_done /* no test needed after dec */
188 andb $0x02,offvmargtype(%r14) /* is this a float/double type? */
189 jnz L_stack_handle_float
190 dec %r12 /* arguments assigned to registers */
191 jge L_stack_copy_loop
194 L_stack_handle_float:
195 dec %r13 /* arguments assigned to registers */
196 jge L_stack_copy_loop
199 mov offvmargdata(%r14),itmp3 /* copy s8 argument onto stack */
201 add $8,%rbx /* increase sp to next argument */
202 jmp L_stack_copy_loop
205 /* itmp1 still contains method pointer*/
206 lea L_asm_call_jit_compiler(%rip),itmp3
207 call *itmp3 /* call JIT compiler */
209 add bp,sp /* remove argument stack frame if any */
211 L_asm_vm_call_method_return:
212 mov 0*8(sp),%rbx /* restore callee saved registers */
218 add $(7*8),sp /* free stack space */
222 mov xptr,a0 /* pass exception pointer */
223 call builtin_throw_exception@PLT
224 xor v0,v0 /* return NULL */
225 jmp L_asm_vm_call_method_return
237 mov offvmargdata(itmp2),a0
240 mov offvmargdata(itmp2),a1
243 mov offvmargdata(itmp2),a2
246 mov offvmargdata(itmp2),a3
249 mov offvmargdata(itmp2),a4
252 mov offvmargdata(itmp2),a5
267 movq offvmargdata(itmp2),fa0
270 movq offvmargdata(itmp2),fa1
273 movq offvmargdata(itmp2),fa2
276 movq offvmargdata(itmp2),fa3
279 movq offvmargdata(itmp2),fa4
282 movq offvmargdata(itmp2),fa5
285 movq offvmargdata(itmp2),fa6
288 movq offvmargdata(itmp2),fa7
292 /****************** function asm_call_jit_compiler *****************************
294 * invokes the compiler for untranslated JavaVM methods. *
296 * Register R0 contains a pointer to the method info structure (prepared *
297 * by createcompilerstub). Using the return address in R26 and the *
298 * offset in the LDA instruction or using the value in methodptr R28 the *
299 * patching address for storing the method address can be computed: *
301 * method address was either loaded using *
303 * i386_mov_imm_reg(a, REG_ITMP2) ; invokestatic/special *
304 * i386_call_reg(REG_ITMP2) *
308 * i386_mov_membase_reg(REG_SP, 0, REG_ITMP2) ; invokevirtual/interface *
309 * i386_mov_membase_reg(REG_ITMP2, OFFSET(, vftbl), REG_ITMP3) *
310 * i386_mov_membase_reg(REG_ITMP3, OFFSET(vftbl, table[0]) + \ *
311 * sizeof(methodptr) * m->vftblindex, REG_ITMP1) *
312 * i386_call_reg(REG_ITMP1) *
314 * in the static case the method pointer can be computed using the *
315 * return address and the lda function following the jmp instruction *
317 *******************************************************************************/
319 asm_call_jit_compiler:
320 L_asm_call_jit_compiler: /* required for PIC code */
321 /* keep stack 16-byte aligned */
322 sub $((3+ARG_CNT)*8+sizestackframeinfo),sp
324 mov t0,0*8(sp) /* save register */
326 mov (3+ARG_CNT)*8+sizestackframeinfo(sp),itmp3 /* get return address */
327 mov -1(itmp3),%bl /* get function code */
328 cmp $0xd2,%bl /* called with `call *REG_ITMP2'? */
329 jne L_not_static_special
331 sub $11,itmp3 /* calculate address of immediate */
332 jmp L_call_jit_compile
334 L_not_static_special:
335 cmp $0xd0,%bl /* called with `call *REG_ITMP1' */
336 jne L_not_virtual_interface
338 sub $7,itmp3 /* calculate address of offset */
339 mov (itmp3),itmp3l /* get offset (32-bit) */
340 add itmp2,itmp3 /* add base address to get method addr*/
341 jmp L_call_jit_compile
343 L_not_virtual_interface: /* a call from asm_calljavamethod */
347 mov 0*8(sp),t0 /* restore register */
348 mov itmp3,0*8(sp) /* save address for method pointer */
349 mov itmp1,1*8(sp) /* save method pointer */
351 SAVE_ARGUMENT_REGISTERS(3)
353 mov sp,a0 /* create stackframe info */
354 add $((3+ARG_CNT)*8),a0 /* pass sfi */
355 xor a1,a1 /* if pv is NULL, use findmethod */
356 mov sp,a2 /* pass java sp */
357 add $((1+3+ARG_CNT)*8+sizestackframeinfo),a2
358 /* pass ra to java function */
359 mov ((3+ARG_CNT)*8+sizestackframeinfo)(sp),a3
360 mov a3,a4 /* xpc is equal to ra */
361 call stacktrace_create_extern_stackframeinfo@PLT
363 mov 1*8(sp),a0 /* pass method pointer */
365 mov v0,1*8(sp) /* save return value */
367 mov sp,a0 /* remove stackframe info */
368 add $((3+ARG_CNT)*8),a0 /* pass sfi */
369 call stacktrace_remove_stackframeinfo@PLT
371 mov 0*8(sp),itmp3 /* restore address for method pointer */
372 mov 1*8(sp),v0 /* restore return value */
374 RESTORE_ARGUMENT_REGISTERS(3)
376 add $((3+ARG_CNT)*8+sizestackframeinfo),sp /* remove stack frame */
378 test v0,v0 /* check for exception */
379 je L_asm_call_jit_compiler_exception
381 test itmp3,itmp3 /* is address == 0 (asm_calljavamethod*/
384 mov v0,(itmp3) /* and now save the new pointer */
387 jmp *v0 /* ...and now call the new method */
389 L_asm_call_jit_compiler_exception:
390 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
391 call builtin_asm_get_exceptionptrptr@PLT
392 mov v0,itmp2 /* v0 == xptr */
394 lea _no_threads_exceptionptr(%rip),itmp2
396 mov (itmp2),xptr /* get the exception pointer */
397 movl $0,(itmp2) /* clear exception pointer */
399 pop xpc /* delete return address */
400 sub $5,xpc /* faulting address is ra - 5 */
401 jmp L_asm_handle_exception
404 /* asm_handle_exception ********************************************************
406 * This function handles an exception. It does not use the usual calling *
407 * conventions. The exception pointer is passed in REG_ITMP1 and the *
408 * pc from the exception raising position is passed in REG_ITMP2. It searches *
409 * the local exception table for a handler. If no one is found, it unwinds *
410 * stacks and continues searching the callers. *
412 *******************************************************************************/
414 asm_handle_nat_exception:
415 add $8,sp /* clear return address of native stub*/
417 asm_handle_exception:
418 L_asm_handle_exception: /* required for PIC code */
419 sub $((ARG_CNT+TMP_CNT)*8),sp /* create maybe-leaf stackframe */
421 SAVE_ARGUMENT_REGISTERS(0) /* we save arg and temp registers in */
422 SAVE_TEMPORARY_REGISTERS(ARG_CNT) /* case this is a leaf method */
424 mov $((ARG_CNT+TMP_CNT)*8),a3 /* prepare a3 for handle_exception */
425 mov $1,t0 /* set maybe-leaf flag */
427 L_asm_handle_exception_stack_loop:
429 mov xptr,0*8(sp) /* save exception pointer */
430 mov xpc,1*8(sp) /* save exception pc */
431 add sp,a3 /* calculate Java sp into a3... */
433 mov a3,3*8(sp) /* ...and save it */
434 mov t0,4*8(sp) /* save maybe-leaf flag */
436 mov xpc,a0 /* exception pc */
437 call codegen_findmethod@PLT
438 mov v0,2*8(sp) /* save data segment pointer */
440 mov 0*8(sp),a0 /* pass exception pointer */
441 mov 1*8(sp),a1 /* pass exception pc */
442 mov v0,a2 /* pass data segment pointer */
443 mov 3*8(sp),a3 /* pass Java stack pointer */
444 call exceptions_handle_exception@PLT
447 jz L_asm_handle_exception_not_catched
449 mov v0,xpc /* move handlerpc into xpc */
450 mov 0*8(sp),xptr /* restore exception pointer */
451 mov 4*8(sp),t0 /* get maybe-leaf flag */
452 add $(6*8),sp /* free stack frame */
454 test t0,t0 /* test for maybe-leaf flag */
455 jz L_asm_handle_exception_no_leaf
457 RESTORE_ARGUMENT_REGISTERS(0) /* if this is a leaf method, we have */
458 RESTORE_TEMPORARY_REGISTERS(ARG_CNT)/* to restore arg and temp registers */
460 add $((ARG_CNT+TMP_CNT)*8),sp /* remove maybe-leaf stackframe */
462 L_asm_handle_exception_no_leaf:
463 jmp *xpc /* jump to the handler */
465 L_asm_handle_exception_not_catched:
466 mov 0*8(sp),xptr /* restore exception pointer */
467 mov 2*8(sp),itmp3 /* restore data segment pointer */
468 mov 4*8(sp),t0 /* get maybe-leaf flag */
472 jz L_asm_handle_exception_no_leaf_stack
474 add $((ARG_CNT+TMP_CNT)*8),sp /* remove maybe-leaf stackframe */
475 xor t0,t0 /* clear the isleaf flags */
477 L_asm_handle_exception_no_leaf_stack:
478 mov FrameSize(itmp3),itmp2l /* get frame size */
479 add sp,itmp2 /* pointer to save area */
481 mov IntSave(itmp3),a0l /* a0l = saved int register count */
504 shl $3,a0l /* multiply by 8 bytes */
509 mov FltSave(itmp3),a0l /* a0l = saved flt register count */
522 movq -5*8(itmp2),%xmm11
524 movq -4*8(itmp2),%xmm12
526 movq -3*8(itmp2),%xmm13
528 movq -2*8(itmp2),%xmm14
530 movq -1*8(itmp2),%xmm15
534 mov FrameSize(itmp3),itmp2l /* get frame size */
535 add itmp2,sp /* unwind stack */
537 /* exception pointer is still set */
538 pop xpc /* the new xpc is return address */
539 sub $3,xpc /* subtract 3 bytes for call */
541 xor a3,a3 /* prepare a3 for handle_exception */
543 jmp L_asm_handle_exception_stack_loop
546 /* asm_wrapper_patcher *********************************************************
552 32 pointer to virtual java_objectheader
553 24 machine code (which is patched back later)
554 16 unresolved class/method/field reference
555 8 data segment displacement from load instructions
556 0 pointer to patcher function
559 *******************************************************************************/
562 push bp /* save base pointer */
563 mov sp,bp /* move actual sp to bp */
564 sub $((3+ARG_CNT+TMP_CNT)*8+sizestackframeinfo),sp
565 and $0xfffffffffffffff0,sp /* align sp to 16-byte (this is for */
566 /* leaf functions) */
568 SAVE_ARGUMENT_REGISTERS(3)
569 SAVE_TEMPORARY_REGISTERS(3+ARG_CNT)
571 mov itmp1,0*8(sp) /* save itmp1 and itmp2 */
572 mov itmp2,1*8(sp) /* can be used by some instructions */
574 mov sp,a0 /* create stackframe info */
575 add $((3+ARG_CNT+TMP_CNT)*8),a0
576 xor a1,a1 /* if pv is NULL, use findmethod */
577 mov bp,a2 /* pass java sp */
579 mov ((5+1)*8)(bp),a3 /* pass ra to java function */
580 mov a3,a4 /* xpc is equal to ra */
581 call stacktrace_create_extern_stackframeinfo@PLT
583 mov bp,a0 /* pass stack pointer */
584 add $((1+1)*8),a0 /* skip function pointer */
585 mov 1*8(bp),itmp3 /* get function pointer */
586 call *itmp3 /* call the patcher function */
587 mov v0,2*8(sp) /* save return value */
589 mov sp,a0 /* remove stackframe info */
590 add $((3+ARG_CNT+TMP_CNT)*8),a0
591 call stacktrace_remove_stackframeinfo@PLT
593 RESTORE_ARGUMENT_REGISTERS(3)
594 RESTORE_TEMPORARY_REGISTERS(3+ARG_CNT)
596 mov 0*8(sp),itmp1 /* restore itmp1 and itmp2 */
597 mov 1*8(sp),itmp2 /* can be used by some instructions */
598 mov 2*8(sp),itmp3 /* restore return value */
600 mov bp,sp /* restore original sp */
601 pop bp /* restore bp */
602 add $(5*8),sp /* remove patcher stackframe, keep ra */
604 test itmp3,itmp3 /* exception thrown? */
605 jz L_asm_wrapper_patcher_exception
606 ret /* call new patched code */
608 L_asm_wrapper_patcher_exception:
609 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
610 call builtin_asm_get_exceptionptrptr@PLT
611 mov v0,itmp2 /* v0 == xptr */
613 mov _no_threads_exceptionptr,itmp2
615 mov (itmp2),xptr /* get the exception pointer */
616 movl $0,(itmp2) /* clear exception pointer */
618 pop xpc /* get and remove return address */
619 jmp L_asm_handle_exception
622 /* asm_replacement_out *********************************************************
624 This code is jumped to from the replacement-out stubs that are executed
625 when a thread reaches an activated replacement point.
627 The purpose of asm_replacement_out is to read out the parts of the
628 execution state that cannot be accessed from C code, store this state,
629 and then call the C function replace_me.
632 8 start of stack inside method to replace
633 0 rplpoint * info on the replacement point that was reached
635 *******************************************************************************/
637 /* some room to accomodate changes of the stack frame size during replacement */
638 /* XXX we should find a cleaner solution here */
639 #define REPLACEMENT_ROOM 512
642 /* create stack frame */
643 sub $(sizeexecutionstate + REPLACEMENT_ROOM),sp
645 /* save registers in execution state */
646 mov %rax,(RAX*8+offes_intregs)(sp)
647 mov %rbx,(RBX*8+offes_intregs)(sp)
648 mov %rcx,(RCX*8+offes_intregs)(sp)
649 mov %rdx,(RDX*8+offes_intregs)(sp)
650 mov %rsi,(RSI*8+offes_intregs)(sp)
651 mov %rdi,(RDI*8+offes_intregs)(sp)
652 mov %rbp,(RBP*8+offes_intregs)(sp)
653 movq $0 ,(RSP*8+offes_intregs)(sp) /* not used */
654 mov %r8 ,(R8 *8+offes_intregs)(sp)
655 mov %r9 ,(R9 *8+offes_intregs)(sp)
656 mov %r10,(R10*8+offes_intregs)(sp)
657 mov %r11,(R11*8+offes_intregs)(sp)
658 mov %r12,(R12*8+offes_intregs)(sp)
659 mov %r13,(R13*8+offes_intregs)(sp)
660 mov %r14,(R14*8+offes_intregs)(sp)
661 mov %r15,(R15*8+offes_intregs)(sp)
663 movq %xmm0 ,(XMM0 *8+offes_fltregs)(sp)
664 movq %xmm1 ,(XMM1 *8+offes_fltregs)(sp)
665 movq %xmm2 ,(XMM2 *8+offes_fltregs)(sp)
666 movq %xmm3 ,(XMM3 *8+offes_fltregs)(sp)
667 movq %xmm4 ,(XMM4 *8+offes_fltregs)(sp)
668 movq %xmm5 ,(XMM5 *8+offes_fltregs)(sp)
669 movq %xmm6 ,(XMM6 *8+offes_fltregs)(sp)
670 movq %xmm7 ,(XMM7 *8+offes_fltregs)(sp)
671 movq %xmm8 ,(XMM8 *8+offes_fltregs)(sp)
672 movq %xmm9 ,(XMM9 *8+offes_fltregs)(sp)
673 movq %xmm10,(XMM10*8+offes_fltregs)(sp)
674 movq %xmm11,(XMM11*8+offes_fltregs)(sp)
675 movq %xmm12,(XMM12*8+offes_fltregs)(sp)
676 movq %xmm13,(XMM13*8+offes_fltregs)(sp)
677 movq %xmm14,(XMM14*8+offes_fltregs)(sp)
678 movq %xmm15,(XMM15*8+offes_fltregs)(sp)
680 /* calculate sp of method */
682 add $(sizeexecutionstate + REPLACEMENT_ROOM + 8),itmp1
683 mov itmp1,(offes_sp)(sp)
685 /* call replace_me */
686 mov -8(itmp1),a0 /* rplpoint * */
687 mov sp,a1 /* arg1: execution state */
688 call replace_me@PLT /* call C function replace_me */
689 call abort@PLT /* NEVER REACHED */
691 /* asm_replacement_in **********************************************************
693 This code writes the given execution state and jumps to the replacement
696 This function never returns!
699 void asm_replacement_in(executionstate *es);
701 *******************************************************************************/
704 mov a0,%rbp /* executionstate *es */
707 mov (offes_sp)(%rbp),%rsp
709 /* store address of new code */
710 push (offes_pc)(%rbp)
712 /* copy registers from execution state */
713 movq (XMM0 *8+offes_fltregs)(%rbp),%xmm0
714 movq (XMM1 *8+offes_fltregs)(%rbp),%xmm1
715 movq (XMM2 *8+offes_fltregs)(%rbp),%xmm2
716 movq (XMM3 *8+offes_fltregs)(%rbp),%xmm3
717 movq (XMM4 *8+offes_fltregs)(%rbp),%xmm4
718 movq (XMM5 *8+offes_fltregs)(%rbp),%xmm5
719 movq (XMM6 *8+offes_fltregs)(%rbp),%xmm6
720 movq (XMM7 *8+offes_fltregs)(%rbp),%xmm7
721 movq (XMM8 *8+offes_fltregs)(%rbp),%xmm8
722 movq (XMM9 *8+offes_fltregs)(%rbp),%xmm9
723 movq (XMM10*8+offes_fltregs)(%rbp),%xmm10
724 movq (XMM11*8+offes_fltregs)(%rbp),%xmm11
725 movq (XMM12*8+offes_fltregs)(%rbp),%xmm12
726 movq (XMM13*8+offes_fltregs)(%rbp),%xmm13
727 movq (XMM14*8+offes_fltregs)(%rbp),%xmm14
728 movq (XMM15*8+offes_fltregs)(%rbp),%xmm15
730 mov (RAX*8+offes_intregs)(%rbp),%rax
731 mov (RBX*8+offes_intregs)(%rbp),%rbx
732 mov (RCX*8+offes_intregs)(%rbp),%rcx
733 mov (RDX*8+offes_intregs)(%rbp),%rdx
734 mov (RSI*8+offes_intregs)(%rbp),%rsi
735 mov (RDI*8+offes_intregs)(%rbp),%rdi
736 mov (R8 *8+offes_intregs)(%rbp),%r8
737 mov (R9 *8+offes_intregs)(%rbp),%r9
738 mov (R10*8+offes_intregs)(%rbp),%r10
739 mov (R11*8+offes_intregs)(%rbp),%r11
740 mov (R12*8+offes_intregs)(%rbp),%r12
741 mov (R13*8+offes_intregs)(%rbp),%r13
742 mov (R14*8+offes_intregs)(%rbp),%r14
743 mov (R15*8+offes_intregs)(%rbp),%r15
745 mov (RBP*8+offes_intregs)(%rbp),%rbp
747 /* jump to new code */
750 /* asm_builtin_x2x *************************************************************
752 * Wrapper functions for float to int corner cases *
754 *******************************************************************************/
759 SAVE_ARGUMENT_REGISTERS(0)
764 RESTORE_ARGUMENT_REGISTERS(0)
773 SAVE_ARGUMENT_REGISTERS(0)
778 RESTORE_ARGUMENT_REGISTERS(0)
787 SAVE_ARGUMENT_REGISTERS(0)
792 RESTORE_ARGUMENT_REGISTERS(0)
801 SAVE_ARGUMENT_REGISTERS(0)
806 RESTORE_ARGUMENT_REGISTERS(0)
812 /******************* function asm_initialize_thread_stack **********************
814 * initialized a thread stack *
815 * (to)->restorePoint = asm_initialize_thread_stack((u1*)(func), (to)->stackEnd)*
817 *******************************************************************************/
819 asm_initialize_thread_stack:
830 mov %rdi,6*8(%rsi) /* save (u1*) (func) */
831 mov %rsi,%rax /* return restorepoint in %rax */
835 /******************* function asm_perform_threadswitch *************************
837 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
839 * performs a threadswitch *
841 *******************************************************************************/
843 asm_perform_threadswitch:
844 sub $(7*8),%rsp /* allocate stack frame */
853 mov 7*8(%rsp),%rax /* save current return address */
856 mov %rsp,(%rdi) /* first argument **from */
857 mov %rsp,(%rdx) /* third argument **stackTop */
859 mov (%rsi),%rsp /* load new stack pointer */
868 mov 6*8(%rsp),%rax /* restore return address */
869 add $(7*8),%rsp /* free stack frame */
874 /********************* function asm_switchstackandcall *************************
876 * int asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
879 * Switches to a new stack, calls a function and switches back. *
880 * a0 (%rdi) new stack pointer *
881 * a1 (%rsi) function pointer *
882 * a2 (%rdx) pointer to variable where stack top should be stored *
883 * a3 (%rcx) pointer to user data, is passed to the function *
885 *******************************************************************************/
887 asm_switchstackandcall:
888 sub $(1*8),%rsp /* keep stack 16-byte aligned */
889 sub $16,%rdi /* allocate new stack */
891 mov 8(%rsp),%rax /* save return address on new stack */
893 mov %rsp,8(%rdi) /* save old stack pointer on new stack*/
894 mov %rsp,(%rdx) /* save old stack pointer to variable */
896 mov %rdi,%rsp /* switch to new stack */
898 mov %rcx,%rdi /* pass pointer */
899 call *%rsi /* and call function */
901 mov (%rsp),%r10 /* load return address */
902 mov 8(%rsp),%rsp /* switch to old stack */
903 add $(1*8),%rsp /* free stack space */
904 mov %r10,(%rsp) /* write return adress */
908 asm_getclassvalues_atomic:
911 movl offbaseval(a0),itmp1l
912 movl offdiffval(a0),itmp2l
913 movl offbaseval(a1),itmp3l
915 movl itmp1l,offcast_super_baseval(a2)
916 movl itmp2l,offcast_super_diffval(a2)
917 movl itmp3l,offcast_sub_baseval(a2)
922 asm_criticalsections:
923 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
931 /* Disable exec-stacks, required for Gentoo ***********************************/
933 #if defined(__GCC__) && defined(__ELF__)
934 .section .note.GNU-stack,"",@progbits
939 * These are local overrides for various environment variables in Emacs.
940 * Please do not remove this and leave it at the end of the file, where
941 * Emacs will automagically detect them.
942 * ---------------------------------------------------------------------
945 * indent-tabs-mode: t
949 * vim:noexpandtab:sw=4:ts=4: