]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: preserve ctxt across moveMakeFuncArgPtrs
authorCherry Zhang <cherryyz@google.com>
Thu, 15 Apr 2021 15:19:30 +0000 (11:19 -0400)
committerCherry Zhang <cherryyz@google.com>
Fri, 16 Apr 2021 20:18:11 +0000 (20:18 +0000)
In makeFuncStub and methodValueCall, it stores ctxt (DX) as an
argument of moveMakeFuncArgPtrs, and assumes it does not change
by the call. This is not guaranteed, and it does happen if
-clobberdead compiler flag is used. Store it somewhere else and
reload after the call.

Change-Id: I9307e3cf94db4b38305ab35494088386dfcbaae8
Reviewed-on: https://go-review.googlesource.com/c/go/+/310409
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
src/reflect/asm_amd64.s

index 22d95f2a7e1ada44adcf9623138a2713d1026dc0..facf07516d8c2441058c7c032db482bd5a4d2c6b 100644 (file)
@@ -33,9 +33,12 @@ TEXT ·makeFuncStub<ABIInternal>(SB),(NOSPLIT|WRAPPER),$312
        // frame is specially handled in the runtime. See the comment above LOCAL_RETVALID.
        LEAQ    LOCAL_REGARGS(SP), R12
        CALL    runtime·spillArgs<ABIInternal>(SB)
+       MOVQ    DX, 24(SP) // outside of moveMakeFuncArgPtrs's arg area
        MOVQ    DX, 0(SP)
        MOVQ    R12, 8(SP)
        CALL    ·moveMakeFuncArgPtrs(SB)
+       MOVQ    24(SP), DX
+       MOVQ    DX, 0(SP)
        LEAQ    argframe+0(FP), CX
        MOVQ    CX, 8(SP)
        MOVB    $0, LOCAL_RETVALID(SP)
@@ -61,9 +64,12 @@ TEXT ·methodValueCall<ABIInternal>(SB),(NOSPLIT|WRAPPER),$312
        // frame is specially handled in the runtime. See the comment above LOCAL_RETVALID.
        LEAQ    LOCAL_REGARGS(SP), R12
        CALL    runtime·spillArgs<ABIInternal>(SB)
+       MOVQ    DX, 24(SP) // outside of moveMakeFuncArgPtrs's arg area
        MOVQ    DX, 0(SP)
        MOVQ    R12, 8(SP)
        CALL    ·moveMakeFuncArgPtrs(SB)
+       MOVQ    24(SP), DX
+       MOVQ    DX, 0(SP)
        LEAQ    argframe+0(FP), CX
        MOVQ    CX, 8(SP)
        MOVB    $0, LOCAL_RETVALID(SP)