diff options
| author | Russ Cox <rsc@golang.org> | 2014-12-30 13:59:55 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2015-01-06 00:28:31 +0000 |
| commit | df027aceb970a2e9dcafb6e79f8581efb2f30c86 (patch) | |
| tree | 081f9fdc55e56f739de4b6e6f32c3f03f979d6fc /src/runtime/asm_amd64.s | |
| parent | 813386f200e2cc15a05c8e641227e3cadffffc0d (diff) | |
| download | go-df027aceb970a2e9dcafb6e79f8581efb2f30c86.tar.xz | |
reflect: add write barriers
Use typedmemmove, typedslicecopy, and adjust reflect.call
to execute the necessary write barriers.
Found with GODEBUG=wbshadow=2 mode.
Eventually that will run automatically, but right now
it still detects other missing write barriers.
Change-Id: Iec5b5b0c1be5589295e28e5228e37f1a92e07742
Reviewed-on: https://go-review.googlesource.com/2312
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/asm_amd64.s')
| -rw-r--r-- | src/runtime/asm_amd64.s | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index 5a94e11e5d..3e8ccca512 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -318,7 +318,7 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0 JMP runtime·morestack(SB) // reflectcall: call a function with the given argument list -// func call(f *FuncVal, arg *byte, argsize, retoffset uint32). +// func call(argtype *_type, f *FuncVal, arg *byte, argsize, retoffset uint32). // we don't have variable-sized frames, so we use a small number // of constant-sized-frame functions to encode a few bits of size in the pc. // Caution: ugly multiline assembly macros in your future! @@ -333,9 +333,10 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0 TEXT reflect·call(SB), NOSPLIT, $0-0 JMP ·reflectcall(SB) -TEXT ·reflectcall(SB), NOSPLIT, $0-24 - MOVLQZX argsize+16(FP), CX - DISPATCH(runtime·call16, 16) +TEXT ·reflectcall(SB), NOSPLIT, $0-32 + MOVLQZX argsize+24(FP), CX + // NOTE(rsc): No call16, because CALLFN needs four words + // of argument space to invoke callwritebarrier. DISPATCH(runtime·call32, 32) DISPATCH(runtime·call64, 64) DISPATCH(runtime·call128, 128) @@ -366,29 +367,38 @@ TEXT ·reflectcall(SB), NOSPLIT, $0-24 JMP AX #define CALLFN(NAME,MAXSIZE) \ -TEXT NAME(SB), WRAPPER, $MAXSIZE-24; \ +TEXT NAME(SB), WRAPPER, $MAXSIZE-32; \ NO_LOCAL_POINTERS; \ /* copy arguments to stack */ \ - MOVQ argptr+8(FP), SI; \ - MOVLQZX argsize+16(FP), CX; \ + MOVQ argptr+16(FP), SI; \ + MOVLQZX argsize+24(FP), CX; \ MOVQ SP, DI; \ REP;MOVSB; \ /* call function */ \ - MOVQ f+0(FP), DX; \ + MOVQ f+8(FP), DX; \ PCDATA $PCDATA_StackMapIndex, $0; \ CALL (DX); \ /* copy return values back */ \ - MOVQ argptr+8(FP), DI; \ - MOVLQZX argsize+16(FP), CX; \ - MOVLQZX retoffset+20(FP), BX; \ + MOVQ argptr+16(FP), DI; \ + MOVLQZX argsize+24(FP), CX; \ + MOVLQZX retoffset+28(FP), BX; \ MOVQ SP, SI; \ ADDQ BX, DI; \ ADDQ BX, SI; \ SUBQ BX, CX; \ REP;MOVSB; \ + /* execute write barrier updates */ \ + MOVQ argtype+0(FP), DX; \ + MOVQ argptr+16(FP), DI; \ + MOVLQZX argsize+24(FP), CX; \ + MOVLQZX retoffset+28(FP), BX; \ + MOVQ DX, 0(SP); \ + MOVQ DI, 8(SP); \ + MOVQ CX, 16(SP); \ + MOVQ BX, 24(SP); \ + CALL runtime·callwritebarrier(SB); \ RET -CALLFN(·call16, 16) CALLFN(·call32, 32) CALLFN(·call64, 64) CALLFN(·call128, 128) |
