• 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
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
cmd Loading commit data...
compress Loading commit data...
container Loading commit data...
context Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
internal Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
plugin Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
vendor/golang_org/x Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
androidtest.bash Loading commit data...
bootstrap.bash Loading commit data...
buildall.bash Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
cmp.bash Loading commit data...
iostest.bash Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
naclmake.bash Loading commit data...
nacltest.bash Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...