* Merged in twisti-branch.
[cacao.git] / src / vm / jit / powerpc / asmpart.S
index 0406911ac2977602daaded57b3c9a4e1c9e41486..6b4dd2d6d777910d417a7ba6275c4b4a00eeaf09 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/jit/powerpc/asmpart.S - Java-C interface functions for PowerPC
                
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
    J. Wenninger, Institut f. Computersprachen - TU Wien
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Andreas Krall
-            Reinhard Grafl
-            Stefan Ring
-
-   Changes: Christian Thalinger
-            Edwin Steiner
-
-   $Id: asmpart.S 6147 2006-12-07 23:54:40Z edwin $
+   $Id: asmpart.S 7454 2007-03-05 15:40:48Z tbfg $
 
 */
 
@@ -60,6 +51,7 @@
        .globl asm_vm_call_method_double
 
        .globl asm_vm_call_method_exception_handler
+       .globl asm_vm_call_method_end
 
        .globl asm_call_jit_compiler
 
 
        .globl asm_patcher_wrapper
 
+#if defined(ENABLE_REPLACEMENT)
        .globl asm_replacement_out
        .globl asm_replacement_in
+#endif
 
        .globl asm_cacheflush
+
+       .globl asm_compare_and_swap
+       .globl asm_memory_barrier
+
        .globl asm_criticalsections
        .globl asm_getclassvalues_atomic
 
@@ -682,6 +680,8 @@ L_handle_fda12:
        b       L_register_copy
 #endif
 
+asm_vm_call_method_end:
+       nop
 
 /* asm_call_jit_compiler *******************************************************
 
@@ -1124,6 +1124,7 @@ L_asm_patcher_wrapper_exception:
        addi    sp,sp,8*4+LA_SIZE+(5+58)*4
        b       L_asm_handle_exception
 
+#if defined(ENABLE_REPLACEMENT)
 
 /* asm_replacement_out *********************************************************
 
@@ -1156,38 +1157,38 @@ asm_replacement_out:
        mflr    itmp3
 
        /* save registers in execution state */
-       stw     r0 ,( 0*8+4+offes_intregs)(sp)
-       stw     r1 ,( 1*8+4+offes_intregs)(sp)
-       stw     r2 ,( 2*8+4+offes_intregs)(sp)
-       stw     r3 ,( 3*8+4+offes_intregs)(sp)
-       stw     r4 ,( 4*8+4+offes_intregs)(sp)
-       stw     r5 ,( 5*8+4+offes_intregs)(sp)
-       stw     r6 ,( 6*8+4+offes_intregs)(sp)
-       stw     r7 ,( 7*8+4+offes_intregs)(sp)
-       stw     r8 ,( 8*8+4+offes_intregs)(sp)
-       stw     r9 ,( 9*8+4+offes_intregs)(sp)
-       stw     r10,(10*8+4+offes_intregs)(sp)
-       stw     r11,(11*8+4+offes_intregs)(sp)
-       stw     r12,(12*8+4+offes_intregs)(sp)
-       stw     r13,(13*8+4+offes_intregs)(sp)
-       stw     r14,(14*8+4+offes_intregs)(sp)
-       stw     r15,(15*8+4+offes_intregs)(sp)
-       stw     r16,(16*8+4+offes_intregs)(sp) /* link register stored as itmp3 */
-       stw     r17,(17*8+4+offes_intregs)(sp)
-       stw     r18,(18*8+4+offes_intregs)(sp)
-       stw     r19,(19*8+4+offes_intregs)(sp)
-       stw     r20,(20*8+4+offes_intregs)(sp)
-       stw     r21,(21*8+4+offes_intregs)(sp)
-       stw     r22,(22*8+4+offes_intregs)(sp)
-       stw     r23,(23*8+4+offes_intregs)(sp)
-       stw     r24,(24*8+4+offes_intregs)(sp)
-       stw     r25,(25*8+4+offes_intregs)(sp)
-       stw     r26,(26*8+4+offes_intregs)(sp)
-       stw     r27,(27*8+4+offes_intregs)(sp)
-       stw     r28,(28*8+4+offes_intregs)(sp)
-       stw     r29,(29*8+4+offes_intregs)(sp)
-       stw     r30,(30*8+4+offes_intregs)(sp)
-       stw     r31,(31*8+4+offes_intregs)(sp)
+       stw     r0 ,( 0*4+offes_intregs)(sp)
+       stw     r1 ,( 1*4+offes_intregs)(sp)
+       stw     r2 ,( 2*4+offes_intregs)(sp)
+       stw     r3 ,( 3*4+offes_intregs)(sp)
+       stw     r4 ,( 4*4+offes_intregs)(sp)
+       stw     r5 ,( 5*4+offes_intregs)(sp)
+       stw     r6 ,( 6*4+offes_intregs)(sp)
+       stw     r7 ,( 7*4+offes_intregs)(sp)
+       stw     r8 ,( 8*4+offes_intregs)(sp)
+       stw     r9 ,( 9*4+offes_intregs)(sp)
+       stw     r10,(10*4+offes_intregs)(sp)
+       stw     r11,(11*4+offes_intregs)(sp)
+       stw     r12,(12*4+offes_intregs)(sp)
+       stw     r13,(13*4+offes_intregs)(sp)
+       stw     r14,(14*4+offes_intregs)(sp)
+       stw     r15,(15*4+offes_intregs)(sp)
+       stw     r16,(16*4+offes_intregs)(sp) /* link register stored as itmp3 */
+       stw     r17,(17*4+offes_intregs)(sp)
+       stw     r18,(18*4+offes_intregs)(sp)
+       stw     r19,(19*4+offes_intregs)(sp)
+       stw     r20,(20*4+offes_intregs)(sp)
+       stw     r21,(21*4+offes_intregs)(sp)
+       stw     r22,(22*4+offes_intregs)(sp)
+       stw     r23,(23*4+offes_intregs)(sp)
+       stw     r24,(24*4+offes_intregs)(sp)
+       stw     r25,(25*4+offes_intregs)(sp)
+       stw     r26,(26*4+offes_intregs)(sp)
+       stw     r27,(27*4+offes_intregs)(sp)
+       stw     r28,(28*4+offes_intregs)(sp)
+       stw     r29,(29*4+offes_intregs)(sp)
+       stw     r30,(30*4+offes_intregs)(sp)
+       stw     r31,(31*4+offes_intregs)(sp)
        
        stfd    fr0 ,( 0*8+offes_fltregs)(sp)
        stfd    fr1 ,( 1*8+offes_fltregs)(sp)
@@ -1284,38 +1285,38 @@ asm_replacement_in:
        lwz     pv,(offes_pv)(sp)
        
        /* copy registers from execution state */
-       lwz     r0 ,( 0*8+4+offes_intregs)(sp)
-       /* r1 is sp                         */
-       /* r2 is reserved                   */
-       lwz     a0 ,( 3*8+4+offes_intregs)(sp)
-       lwz     r4 ,( 4*8+4+offes_intregs)(sp)
-       lwz     r5 ,( 5*8+4+offes_intregs)(sp)
-       lwz     r6 ,( 6*8+4+offes_intregs)(sp)
-       lwz     r7 ,( 7*8+4+offes_intregs)(sp)
-       lwz     r8 ,( 8*8+4+offes_intregs)(sp)
-       lwz     r9 ,( 9*8+4+offes_intregs)(sp)
-       lwz     r10,(10*8+4+offes_intregs)(sp)
-       lwz     r11,(11*8+4+offes_intregs)(sp)
-       lwz     r12,(12*8+4+offes_intregs)(sp)
-       /* r13 is pv                        */
-       lwz     r14,(14*8+4+offes_intregs)(sp)
-       lwz     r15,(15*8+4+offes_intregs)(sp)
-       lwz     r16,(16*8+4+offes_intregs)(sp) /* itmp3, later to link register */
-       lwz     r17,(17*8+4+offes_intregs)(sp)
-       lwz     r18,(18*8+4+offes_intregs)(sp)
-       lwz     r19,(19*8+4+offes_intregs)(sp)
-       lwz     r20,(20*8+4+offes_intregs)(sp)
-       lwz     r21,(21*8+4+offes_intregs)(sp)
-       lwz     r22,(22*8+4+offes_intregs)(sp)
-       lwz     r23,(23*8+4+offes_intregs)(sp)
-       lwz     r24,(24*8+4+offes_intregs)(sp)
-       lwz     r25,(25*8+4+offes_intregs)(sp)
-       lwz     r26,(26*8+4+offes_intregs)(sp)
-       lwz     r27,(27*8+4+offes_intregs)(sp)
-       lwz     r28,(28*8+4+offes_intregs)(sp)
-       lwz     r29,(29*8+4+offes_intregs)(sp)
-       lwz     r30,(30*8+4+offes_intregs)(sp)
-       lwz     r31,(31*8+4+offes_intregs)(sp)
+       lwz     r0 ,( 0*4+offes_intregs)(sp)
+       /* r1 is sp                       */
+       /* r2 is reserved                 */
+       lwz     a0 ,( 3*4+offes_intregs)(sp)
+       lwz     r4 ,( 4*4+offes_intregs)(sp)
+       lwz     r5 ,( 5*4+offes_intregs)(sp)
+       lwz     r6 ,( 6*4+offes_intregs)(sp)
+       lwz     r7 ,( 7*4+offes_intregs)(sp)
+       lwz     r8 ,( 8*4+offes_intregs)(sp)
+       lwz     r9 ,( 9*4+offes_intregs)(sp)
+       lwz     r10,(10*4+offes_intregs)(sp)
+       lwz     r11,(11*4+offes_intregs)(sp)
+       lwz     r12,(12*4+offes_intregs)(sp)
+       /* r13 is pv                      */
+       lwz     r14,(14*4+offes_intregs)(sp)
+       lwz     r15,(15*4+offes_intregs)(sp)
+       lwz     r16,(16*4+offes_intregs)(sp) /* itmp3, later to link register */
+       lwz     r17,(17*4+offes_intregs)(sp)
+       lwz     r18,(18*4+offes_intregs)(sp)
+       lwz     r19,(19*4+offes_intregs)(sp)
+       lwz     r20,(20*4+offes_intregs)(sp)
+       lwz     r21,(21*4+offes_intregs)(sp)
+       lwz     r22,(22*4+offes_intregs)(sp)
+       lwz     r23,(23*4+offes_intregs)(sp)
+       lwz     r24,(24*4+offes_intregs)(sp)
+       lwz     r25,(25*4+offes_intregs)(sp)
+       lwz     r26,(26*4+offes_intregs)(sp)
+       lwz     r27,(27*4+offes_intregs)(sp)
+       lwz     r28,(28*4+offes_intregs)(sp)
+       lwz     r29,(29*4+offes_intregs)(sp)
+       lwz     r30,(30*4+offes_intregs)(sp)
+       lwz     r31,(31*4+offes_intregs)(sp)
        
        lfd     fr0 ,( 0*8+offes_fltregs)(sp)
        lfd     fr1 ,( 1*8+offes_fltregs)(sp)
@@ -1367,6 +1368,8 @@ asm_replacement_in:
        mtctr   itmp3
        bctr
 
+#endif /* defined(ENABLE_REPLACEMENT) */
+
 /*********************************************************************/
 
 asm_cacheflush:
@@ -1395,6 +1398,35 @@ asm_cacheflush:
        blr
 
 
+/* asm_compare_and_swap ********************************************************
+
+   XXX
+
+*******************************************************************************/
+
+asm_compare_and_swap:
+1:  lwarx   a6,r0,a0 
+       subf.   r0,a6,a1 
+       bne-    2f 
+       or      r0,a2,a2 
+       stwcx.  r0,r0,a0 
+       bne-    1b 
+2: 
+       mr      a0,a6
+       blr
+
+
+/* asm_memory_barrier **********************************************************
+
+   XXX
+
+*******************************************************************************/
+
+asm_memory_barrier:
+       sync
+       blr
+
+
 asm_getclassvalues_atomic:
 _crit_restart:
 _crit_begin:
@@ -1619,6 +1651,46 @@ L_replace_me$lazy_ptr:
        .indirect_symbol _replace_me
        .long dyld_stub_binding_helper
 
+
+.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
+       .align 2
+L_replace_build_execution_state$stub:
+       .indirect_symbol _replace_build_execution_state
+       mflr r0
+       bcl 20,31,L00$_replace_build_execution_state
+L00$_replace_build_execution_state:
+       mflr r11
+       addis r11,r11,ha16(L_replace_build_execution_state$lazy_ptr - L00$_replace_build_execution_state)
+       mtlr r0
+       lwzu r12,lo16(L_replace_build_execution_state$lazy_ptr - L00$_replace_build_execution_state)(r11)
+       mtctr r12
+       bctr
+.data
+.lazy_symbol_pointer
+L_replace_build_execution_state$lazy_ptr:
+       .indirect_symbol _replace_build_execution_state
+       .long dyld_stub_binding_helper
+
+
+.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
+       .align 2
+L_replace_free_safestack$stub:
+       .indirect_symbol _replace_free_safestack
+       mflr r0
+       bcl 20,31,L00$_replace_free_safestack
+L00$_replace_free_safestack:
+       mflr r11
+       addis r11,r11,ha16(L_replace_free_safestack$lazy_ptr - L00$_replace_free_safestack)
+       mtlr r0
+       lwzu r12,lo16(L_replace_free_safestack$lazy_ptr - L00$_replace_free_safestack)(r11)
+       mtctr r12
+       bctr
+.data
+.lazy_symbol_pointer
+L_replace_free_safestack$lazy_ptr:
+       .indirect_symbol _replace_free_safestack
+       .long dyld_stub_binding_helper
+
 #endif /* defined(__DARWIN__) */