]> Cypherpunks repositories - gostls13.git/commitdiff
move cas out, add dummy runcgo.
authorKai Backman <kaib@golang.org>
Tue, 6 Oct 2009 04:52:10 +0000 (21:52 -0700)
committerKai Backman <kaib@golang.org>
Tue, 6 Oct 2009 04:52:10 +0000 (21:52 -0700)
R=rsc
APPROVED=rsc
DELTA=73  (45 added, 28 deleted, 0 changed)
OCL=35363
CL=35366

src/pkg/runtime/Makefile
src/pkg/runtime/arm/asm.s
src/pkg/runtime/arm/cas.s [new file with mode: 0644]

index ab24a77654ef2bc7e0e713f20957eea928534e67..69ca22530d3730f0e3c65d61ac4fd0512d4a2a3c 100644 (file)
@@ -30,6 +30,7 @@ OFILES_386=\
 
 # arm-specific object files
 OFILES_arm=\
+       cas.$O\
        memset.$O\
        vlop.$O\
        vlrt.$O\
index 18e17be475a714eab48ed6b54690d1a2f9e085a9..07230e5d6b755ab166573251cd841085cd3e85f8 100644 (file)
@@ -213,47 +213,19 @@ TEXT sys·morestackx(SB), 7, $-4
        MOVW    $0, R1          // set frame size
        B       sys·morestack(SB)
 
-// bool cas(int32 *val, int32 old, int32 new)
-// Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     }else
-//             return 0;
-#define        LDREX(a,r)      WORD    $(0xe<<28|0x01900f9f | (a)<<16 | (r)<<12)
-#define        STREX(a,v,r)    WORD    $(0xe<<28|0x01800f90 | (a)<<16 | (r)<<12 | (v)<<0)
-
-TEXT   cas+0(SB),0,$12         /* r0 holds p */
-       MOVW    0(FP), R0
-       MOVW    ov+4(FP), R1
-       MOVW    nv+8(FP), R2
-spin:
-/*     LDREX   0(R0),R3        */
-       LDREX(0,3)
-       CMP.S   R3, R1
-       BNE     fail
-/*     STREX   0(R0),R2,R4     */
-       STREX(0,2,4)
-       CMP.S   $0, R4
-       BNE     spin
-       MOVW    $1, R0
-       RET
-fail:
-       MOVW    $0, R0
-       RET
 
 // void jmpdefer(fn, sp);
 // called from deferreturn.
-// 1. pop the caller
-// 2. sub 5 bytes from the callers return
-// 3. jmp to the argument
+// 1. grab stored LR for caller
+// 2. sub 4 bytes to get back to BL deferreturn
+// 3. B to fn
 TEXT jmpdefer(SB), 7, $0
-       BL      abort(SB)
-//     MOVL    4(SP), AX       // fn
-//     MOVL    8(SP), BX       // caller sp
-//     LEAL    -4(BX), SP      // caller sp after CALL
-//     SUBL    $5, (SP)        // return to CALL again
-//     JMP     AX      // but first run the deferred function
+       MOVW    0(SP), LR
+       MOVW    $-4(LR), LR     // BL deferreturn
+       MOVW    4(SP), R0               // fn
+       MOVW    8(SP), R1
+       MOVW    $-4(R1), SP     // correct for sp pointing to arg0, past stored lr
+       B               (R0)
 
 TEXT   sys·memclr(SB),7,$20
        MOVW    0(FP), R0
@@ -281,6 +253,22 @@ TEXT       sys·setcallerpc+0(SB),7,$0
 //     MOVL    BX, -4(AX)              // set calling pc
 //     RET
 
+// runcgo(void(*fn)(void*), void *arg)
+// Just call fn(arg), but first align the stack
+// appropriately for the gcc ABI.
+// TODO(kaib): figure out the arm-gcc ABI
+TEXT   runcgo(SB),7,$16
+       BL      abort(SB)
+//     MOVL    fn+0(FP), AX
+//     MOVL    arg+4(FP), BX
+//     MOVL    SP, CX
+//     ANDL    $~15, SP        // alignment for gcc ABI
+//     MOVL    CX, 4(SP)
+//     MOVL    BX, 0(SP)
+//     CALL    AX
+//     MOVL    4(SP), SP
+//     RET
+
 TEXT emptyfunc(SB),0,$0
        RET
 
diff --git a/src/pkg/runtime/arm/cas.s b/src/pkg/runtime/arm/cas.s
new file mode 100644 (file)
index 0000000..648fa40
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// bool cas(int32 *val, int32 old, int32 new)
+// Atomically:
+//     if(*val == old){
+//             *val = new;
+//             return 1;
+//     }else
+//             return 0;
+
+TEXT   cas+0(SB),0,$12
+       TODO