diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-06-10 20:35:14 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-06-10 20:35:14 +0000 |
commit | d480455f2ddc3b89d8547969be9cda939c41da56 (patch) | |
tree | 54d7572f8541793e7012b5446173670e5bea65f3 | |
parent | fa237d91e8cb88c7d228f0888ef5c1f3e8ad6d4a (diff) | |
download | gcc-d480455f2ddc3b89d8547969be9cda939c41da56.zip gcc-d480455f2ddc3b89d8547969be9cda939c41da56.tar.gz gcc-d480455f2ddc3b89d8547969be9cda939c41da56.tar.bz2 |
compiler: use gcWriteBarrier for pointer-shaped struct/array
If a struct/array is pointer-shaped (i.e. having a single field
that is pointer-shaped), we can use gcWriteBarrier instead of
typedmemmove for the write barrier.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/181539
From-SVN: r272130
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/wb.cc | 23 |
2 files changed, 16 insertions, 9 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index eae2756..05959f2 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -a32739aadf0c7a65fcd5d5b6d0a0d206bff24a4f +3f7dcb98df3ce1d4e02d0072fd21e70dc08351db The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/wb.cc b/gcc/go/gofrontend/wb.cc index 47cffee..c1d54e6 100644 --- a/gcc/go/gofrontend/wb.cc +++ b/gcc/go/gofrontend/wb.cc @@ -955,14 +955,21 @@ Gogo::assign_with_write_barrier(Function* function, Block* enclosing, // fallthrough case Type::TYPE_STRUCT: - { - // TODO: split assignments for small struct/array? - rhs = Expression::make_unary(OPERATOR_AND, rhs, loc); - rhs->unary_expression()->set_does_not_escape(); - call = Runtime::make_call(Runtime::TYPEDMEMMOVE, loc, 3, - Expression::make_type_descriptor(type, loc), - lhs, rhs); - } + if (type->is_direct_iface_type()) + { + rhs = Expression::unpack_direct_iface(rhs, loc); + rhs = Expression::make_unsafe_cast(uintptr_type, rhs, loc); + call = Runtime::make_call(Runtime::GCWRITEBARRIER, loc, 2, lhs, rhs); + } + else + { + // TODO: split assignments for small struct/array? + rhs = Expression::make_unary(OPERATOR_AND, rhs, loc); + rhs->unary_expression()->set_does_not_escape(); + call = Runtime::make_call(Runtime::TYPEDMEMMOVE, loc, 3, + Expression::make_type_descriptor(type, loc), + lhs, rhs); + } break; } |