]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/6g, cmd/8g: switch to DX for indirect call block
authorRuss Cox <rsc@golang.org>
Fri, 22 Feb 2013 15:47:54 +0000 (10:47 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 22 Feb 2013 15:47:54 +0000 (10:47 -0500)
runtime: add context argument to gogocall

Too many other things use AX, and at least one
(stack zeroing) cannot be moved onto a different
register. Use the less special DX instead.

Preparation for step 2 of http://golang.org/s/go11func.
Nothing interesting here, just split out so that we can
see it's correct before moving on.

R=ken2
CC=golang-dev
https://golang.org/cl/7395050

src/cmd/6g/ggen.c
src/cmd/8g/ggen.c
src/cmd/8l/pass.c
src/pkg/runtime/asm_386.s
src/pkg/runtime/asm_amd64.s
src/pkg/runtime/asm_arm.s
src/pkg/runtime/runtime.h
src/pkg/runtime/stack.c

index c9a60c2fa2981ee33f7dc30a58443f9a80a5b44a..2f93acdfcb6b315349331fe995b1389afde31b9a 100644 (file)
@@ -77,7 +77,7 @@ ginscall(Node *f, int proc)
                                gins(AUNDEF, N, N);
                        break;
                }
-               nodreg(&reg, types[tptr], D_AX);
+               nodreg(&reg, types[tptr], D_DX);
                nodreg(&r1, types[tptr], D_BX);
                gmove(f, &reg);
                reg.op = OINDREG;
index 1738c881a73428914493fa25d52dab80c9d31094..b0a1624e5ec88f151bc6d29bfdd8074b88ef6973 100644 (file)
@@ -120,7 +120,7 @@ ginscall(Node *f, int proc)
                                gins(AUNDEF, N, N);
                        break;
                }
-               nodreg(&reg, types[tptr], D_AX);
+               nodreg(&reg, types[tptr], D_DX);
                nodreg(&r1, types[tptr], D_BX);
                gmove(f, &reg);
                reg.op = OINDREG;
index 03292a5b3f8cbf99642bb89f8bce7de759a9f84c..14dd3e0dc1b318f16f4e3b84b782eb4e27770441 100644 (file)
@@ -539,9 +539,9 @@ dostkoff(void)
                                q = p;
                        }
 
-                       p = appendp(p); // save frame size in DX
+                       p = appendp(p); // save frame size in DI
                        p->as = AMOVL;
-                       p->to.type = D_DX;
+                       p->to.type = D_DI;
                        p->from.type = D_CONST;
 
                        // If we ask for more stack, we'll get a minimum of StackMin bytes.
index 4d8cb1a9667657a59f9308cbecfdcf0ac1bd6807..1e4727427811df56e3246b421551cadcb3477820 100644 (file)
@@ -134,16 +134,17 @@ TEXT runtime·gogo(SB), 7, $0
        MOVL    gobuf_pc(BX), BX
        JMP     BX
 
-// void gogocall(Gobuf*, void (*fn)(void))
+// void gogocall(Gobuf*, void (*fn)(void), uintptr r0)
 // restore state from Gobuf but then call fn.
 // (call fn, returning to state in Gobuf)
 TEXT runtime·gogocall(SB), 7, $0
+       MOVL    12(SP), DX      // context
        MOVL    8(SP), AX               // fn
        MOVL    4(SP), BX               // gobuf
-       MOVL    gobuf_g(BX), DX
+       MOVL    gobuf_g(BX), DI
        get_tls(CX)
-       MOVL    DX, g(CX)
-       MOVL    0(DX), CX               // make sure g != nil
+       MOVL    DI, g(CX)
+       MOVL    0(DI), CX               // make sure g != nil
        MOVL    gobuf_sp(BX), SP        // restore SP
        MOVL    gobuf_pc(BX), BX
        PUSHL   BX
@@ -154,16 +155,16 @@ TEXT runtime·gogocall(SB), 7, $0
 // restore state from Gobuf but then call fn.
 // (call fn, returning to state in Gobuf)
 TEXT runtime·gogocallfn(SB), 7, $0
-       MOVL    8(SP), AX               // fn
+       MOVL    8(SP), DX               // fn
        MOVL    4(SP), BX               // gobuf
-       MOVL    gobuf_g(BX), DX
+       MOVL    gobuf_g(BX), DI
        get_tls(CX)
-       MOVL    DX, g(CX)
-       MOVL    0(DX), CX               // make sure g != nil
+       MOVL    DI, g(CX)
+       MOVL    0(DI), CX               // make sure g != nil
        MOVL    gobuf_sp(BX), SP        // restore SP
        MOVL    gobuf_pc(BX), BX
        PUSHL   BX
-       MOVL    0(AX), BX
+       MOVL    0(DX), BX
        JMP     BX
        POPL    BX      // not reached
 
@@ -209,11 +210,13 @@ TEXT runtime·morestack(SB),7,$0
        CMPL    g(CX), SI
        JNE     2(PC)
        INT     $3
+       
+       MOVL    DX, m_cret(BX)
 
-       // frame size in DX
+       // frame size in DI
        // arg size in AX
        // Save in m.
-       MOVL    DX, m_moreframesize(BX)
+       MOVL    DI, m_moreframesize(BX)
        MOVL    AX, m_moreargsize(BX)
 
        // Called from f.
@@ -441,11 +444,11 @@ TEXT runtime·atomicstore64(SB), 7, $0
 // 2. sub 5 bytes from the callers return
 // 3. jmp to the argument
 TEXT runtime·jmpdefer(SB), 7, $0
-       MOVL    4(SP), AX       // fn
+       MOVL    4(SP), DX       // fn
        MOVL    8(SP), BX       // caller sp
        LEAL    -4(BX), SP      // caller sp after CALL
        SUBL    $5, (SP)        // return to CALL again
-       MOVL    0(AX), BX
+       MOVL    0(DX), BX
        JMP     BX      // but first run the deferred function
 
 // Dummy function to use in saved gobuf.PC,
index ea944e1dea5c4419a8f4e9df039342722a16a2db..ae8470708b457634dbc0085db2ca8fd473df220e 100644 (file)
@@ -121,16 +121,17 @@ TEXT runtime·gogo(SB), 7, $0
        MOVQ    gobuf_pc(BX), BX
        JMP     BX
 
-// void gogocall(Gobuf*, void (*fn)(void))
+// void gogocall(Gobuf*, void (*fn)(void), uintptr r0)
 // restore state from Gobuf but then call fn.
 // (call fn, returning to state in Gobuf)
 TEXT runtime·gogocall(SB), 7, $0
+       MOVQ    24(SP), DX      // context
        MOVQ    16(SP), AX              // fn
        MOVQ    8(SP), BX               // gobuf
-       MOVQ    gobuf_g(BX), DX
+       MOVQ    gobuf_g(BX), DI
        get_tls(CX)
-       MOVQ    DX, g(CX)
-       MOVQ    0(DX), CX       // make sure g != nil
+       MOVQ    DI, g(CX)
+       MOVQ    0(DI), CX       // make sure g != nil
        MOVQ    gobuf_sp(BX), SP        // restore SP
        MOVQ    gobuf_pc(BX), BX
        PUSHQ   BX
@@ -141,16 +142,16 @@ TEXT runtime·gogocall(SB), 7, $0
 // restore state from Gobuf but then call fn.
 // (call fn, returning to state in Gobuf)
 TEXT runtime·gogocallfn(SB), 7, $0
-       MOVQ    16(SP), AX              // fn
+       MOVQ    16(SP), DX              // fn
        MOVQ    8(SP), BX               // gobuf
-       MOVQ    gobuf_g(BX), DX
+       MOVQ    gobuf_g(BX), AX
        get_tls(CX)
-       MOVQ    DX, g(CX)
-       MOVQ    0(DX), CX       // make sure g != nil
+       MOVQ    AX, g(CX)
+       MOVQ    0(AX), CX       // make sure g != nil
        MOVQ    gobuf_sp(BX), SP        // restore SP
        MOVQ    gobuf_pc(BX), BX
        PUSHQ   BX
-       MOVQ    0(AX), BX
+       MOVQ    0(DX), BX
        JMP     BX
        POPQ    BX      // not reached
 
@@ -195,6 +196,8 @@ TEXT runtime·morestack(SB),7,$0
        CMPQ    g(CX), SI
        JNE     2(PC)
        INT     $3
+       
+       MOVQ    DX, m_cret(BX)
 
        // Called from f.
        // Set m->morebuf to f's caller.
@@ -471,11 +474,11 @@ TEXT runtime·atomicstore64(SB), 7, $0
 // 2. sub 5 bytes from the callers return
 // 3. jmp to the argument
 TEXT runtime·jmpdefer(SB), 7, $0
-       MOVQ    8(SP), AX       // fn
+       MOVQ    8(SP), DX       // fn
        MOVQ    16(SP), BX      // caller sp
        LEAQ    -8(BX), SP      // caller sp after CALL
        SUBQ    $5, (SP)        // return to CALL again
-       MOVQ    0(AX), BX
+       MOVQ    0(DX), BX
        JMP     BX      // but first run the deferred function
 
 // Dummy function to use in saved gobuf.PC,
index 0f6026cd1dc03fd19fbcf8098e7d1f035f976e81..dc2438cc045d808d516b998c2d1605acc74683ec 100644 (file)
@@ -112,19 +112,19 @@ TEXT runtime·gogo(SB), 7, $-4
        MOVW    gobuf_sp(R1), SP        // restore SP
        MOVW    gobuf_pc(R1), PC
 
-// void gogocall(Gobuf*, void (*fn)(void))
+// void gogocall(Gobuf*, void (*fn)(void), uintptr r0)
 // restore state from Gobuf but then call fn.
 // (call fn, returning to state in Gobuf)
 // using frame size $-4 means do not save LR on stack.
 TEXT runtime·gogocall(SB), 7, $-4
        MOVW    0(FP), R3               // gobuf
        MOVW    4(FP), R1               // fn
-       MOVW    8(FP), R2               // fp offset
        MOVW    gobuf_g(R3), g
        MOVW    0(g), R0                // make sure g != nil
        MOVW    cgo_save_gm(SB), R0
        CMP     $0, R0 // if in Cgo, we have to save g and m
        BL.NE   (R0) // this call will clobber R0
+       MOVW    8(FP), R0       // context
        MOVW    gobuf_sp(R3), SP        // restore SP
        MOVW    gobuf_pc(R3), LR
        MOVW    R1, PC
@@ -136,7 +136,6 @@ TEXT runtime·gogocall(SB), 7, $-4
 TEXT runtime·gogocallfn(SB), 7, $-4
        MOVW    0(FP), R3               // gobuf
        MOVW    4(FP), R1               // fn
-       MOVW    8(FP), R2               // fp offset
        MOVW    gobuf_g(R3), g
        MOVW    0(g), R0                // make sure g != nil
        MOVW    cgo_save_gm(SB), R0
@@ -189,6 +188,7 @@ TEXT runtime·morestack(SB),7,$-4
        BL.EQ   runtime·abort(SB)
 
        // Save in m.
+       MOVW    R0, m_cret(m) // function context
        MOVW    R1, m_moreframesize(m)
        MOVW    R2, m_moreargsize(m)
 
index e98f13b889477b15200f2c62f8b2762f557c1e25..24591995c83091a5359651020f405b6b2f5d70e3 100644 (file)
@@ -615,7 +615,7 @@ int32       runtime·charntorune(int32*, uint8*, int32);
 #define FLUSH(x)       USED(x)
 
 void   runtime·gogo(Gobuf*, uintptr);
-void   runtime·gogocall(Gobuf*, void(*)(void));
+void   runtime·gogocall(Gobuf*, void(*)(void), uintptr);
 void   runtime·gogocallfn(Gobuf*, FuncVal*);
 void   runtime·gosave(Gobuf*);
 void   runtime·lessstack(void);
index d1d5c8f3f96a49960cd91e6e8cbe5b41d1504540..d5cc3a73294c825a617a3a10fe593ae972eab0ec 100644 (file)
@@ -276,7 +276,7 @@ runtime·newstack(void)
        if(reflectcall)
                runtime·gogocallfn(&label, (FuncVal*)m->morepc);
        else
-               runtime·gogocall(&label, m->morepc);
+               runtime·gogocall(&label, m->morepc, m->cret);
 
        *(int32*)345 = 123;     // never return
 }