• Austin Clements's avatar
    runtime: simplify reflectcall write barriers · 79561a84
    Austin Clements authored
    Currently reflectcall has a subtle dance with write barriers where the
    assembly code copies the result values from the stack to the in-heap
    argument frame without write barriers and then calls into the runtime
    after the fact to invoke the necessary write barriers.
    
    For the hybrid barrier (and for ROC), we need to switch to a
    *pre*-write write barrier, which is very difficult to do with the
    current setup. We could tie ourselves in knots of subtle reasoning
    about why it's okay in this particular case to have a post-write write
    barrier, but this commit instead takes a different approach. Rather
    than making things more complex, this simplifies reflection calls so
    that the argument copy is done in Go using normal bulk write barriers.
    
    The one difficulty with this approach is that calling into Go requires
    putting arguments on the stack, but the call* functions "donate" their
    entire stack frame to the called function. We can get away with this
    now because the copy avoids using the stack and has copied the results
    out before we clobber the stack frame to call into the write barrier.
    The solution in this CL is to call another function, passing arguments
    in registers instead of on the stack, and let that other function
    reserve more stack space and setup the arguments for the runtime.
    
    This approach seemed to work out the best. I also tried making the
    call* functions reserve 32 extra bytes of frame for the write barrier
    arguments and adjust SP up by 32 bytes around the call. However, even
    with the necessary changes to the assembler to correct the spdelta
    table, the runtime was still having trouble with the frame layout (and
    the changes to the assembler caused many other things that do strange
    things with the SP to fail to assemble). The approach I took doesn't
    require any funny business with the SP.
    
    Updates #17503.
    
    Change-Id: Ie2bb0084b24d6cff38b5afb218b9e0534ad2119e
    Reviewed-on: https://go-review.googlesource.com/31655
    Run-TryBot: Austin Clements <austin@google.com>
    Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
    79561a84
Name
Last commit
Last update
..
all_test.go Loading commit data...
asm_386.s Loading commit data...
asm_amd64.s Loading commit data...
asm_amd64p32.s Loading commit data...
asm_arm.s Loading commit data...
asm_arm64.s Loading commit data...
asm_mips64x.s Loading commit data...
asm_ppc64x.s Loading commit data...
asm_s390x.s Loading commit data...
deepequal.go Loading commit data...
example_test.go Loading commit data...
export_test.go Loading commit data...
makefunc.go Loading commit data...
set_test.go Loading commit data...
swapper.go Loading commit data...
tostring_test.go Loading commit data...
type.go Loading commit data...
value.go Loading commit data...