mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: support valgrind (but not asan) in specialized malloc functions
We're adding this so that the compiler doesn't need to know about valgrind since it's just implemented using a build tag. Change-Id: I6a6a696452b0379caceca2ae4e49195016f7a90d Reviewed-on: https://go-review.googlesource.com/c/go/+/708296 Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Matloob <matloob@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
a7917eed70
commit
c54dc1418b
2 changed files with 333 additions and 0 deletions
|
|
@ -50,6 +50,8 @@ func mallocPanic(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
|||
panic("not defined for sizeclass")
|
||||
}
|
||||
|
||||
// WARNING: mallocStub does not do any work for sanitizers so callers need
|
||||
// to steer out of this codepath early if sanitizers are enabled.
|
||||
func mallocStub(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
||||
if doubleCheckMalloc {
|
||||
if gcphase == _GCmarktermination {
|
||||
|
|
@ -77,6 +79,13 @@ func mallocStub(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
|||
// Actually do the allocation.
|
||||
x, elemsize := inlinedMalloc(size, typ, needzero)
|
||||
|
||||
// Notify valgrind, if enabled.
|
||||
// To allow the compiler to not know about valgrind, we do valgrind instrumentation
|
||||
// unlike the other sanitizers.
|
||||
if valgrindenabled {
|
||||
valgrindMalloc(x, size)
|
||||
}
|
||||
|
||||
// Adjust our GC assist debt to account for internal fragmentation.
|
||||
if gcBlackenEnabled != 0 && elemsize != 0 {
|
||||
if assistG := getg().m.curg; assistG != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue