]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: avoid using address as constant in amd64 assembly
authorRuss Cox <rsc@golang.org>
Tue, 12 Aug 2014 23:51:20 +0000 (19:51 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 12 Aug 2014 23:51:20 +0000 (19:51 -0400)
This allows changing the addressing mode for constant
global addresses to use pc-relative addressing.

LGTM=rminnich, iant
R=golang-codereviews, rminnich, iant
CC=golang-codereviews
https://golang.org/cl/129830043

src/pkg/runtime/asm_amd64.s

index 0fd21d179579634fe1c26b562b8af95f7759d2f3..d94df0bf8dd98bb37e489d9b01fc4b0fbf79affd 100644 (file)
@@ -92,7 +92,8 @@ ok:
        CALL    runtime·schedinit(SB)
 
        // create a new goroutine to start program
-       PUSHQ   $runtime·main·f(SB)           // entry
+       MOVQ    $runtime·main·f(SB), BP               // entry
+       PUSHQ   BP
        PUSHQ   $0                      // arg size
        ARGSIZE(16)
        CALL    runtime·newproc(SB)
@@ -209,7 +210,8 @@ TEXT runtime·onM(SB), NOSPLIT, $0-8
 
        // save our state in g->sched.  Pretend to
        // be switchtoM if the G stack is scanned.
-       MOVQ    $runtime·switchtoM(SB), (g_sched+gobuf_pc)(AX)
+       MOVQ    $runtime·switchtoM(SB), BP
+       MOVQ    BP, (g_sched+gobuf_pc)(AX)
        MOVQ    SP, (g_sched+gobuf_sp)(AX)
        MOVQ    AX, (g_sched+gobuf_g)(AX)
 
@@ -302,7 +304,8 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-20
        
        // Save our own state as the PC and SP to restore
        // if this goroutine needs to be restarted.
-       MOVQ    $runtime·newstackcall(SB), (g_sched+gobuf_pc)(AX)
+       MOVQ    $runtime·newstackcall(SB), BP
+       MOVQ    BP, (g_sched+gobuf_pc)(AX)
        MOVQ    SP, (g_sched+gobuf_sp)(AX)
 
        // Set up morestack arguments to call f on a new stack.
@@ -1002,7 +1005,8 @@ aessmall:
        // a page boundary, so we can load it directly.
        MOVOU   (AX), X1
        ADDQ    CX, CX
-       PAND    masks<>(SB)(CX*8), X1
+       MOVQ    $masks<>(SB), BP
+       PAND    (BP)(CX*8), X1
        JMP     partial
 highpartial:
        // address ends in 1111xxxx.  Might be up against
@@ -1010,7 +1014,8 @@ highpartial:
        // Then shift bytes down using pshufb.
        MOVOU   -16(AX)(CX*1), X1
        ADDQ    CX, CX
-       PSHUFB  shifts<>(SB)(CX*8), X1
+       MOVQ    $shifts<>(SB), BP
+       PSHUFB  (BP)(CX*8), X1
 partial:
        // incorporate partial block into hash
        AESENC  X3, X0