]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: call generated size-specialized malloc functions directly
authorMichael Matloob <matloob@golang.org>
Mon, 29 Sep 2025 21:26:49 +0000 (17:26 -0400)
committerMichael Matloob <matloob@golang.org>
Thu, 9 Oct 2025 21:59:40 +0000 (14:59 -0700)
commit19a30ea3f250f8d6258f3e08aa3561f1193fdd38
tree561da06a8d112056be9b831a248d6f8bd7edf006
parent80f3bb5516bb12233a15167bc8ba9d39cca5b535
cmd/compile: call generated size-specialized malloc functions directly

This change creates calls to size-specialized malloc functions instead
of calls to newObject when we know the size of the allocation at
compilation time. Most of it is a matter of calling the newObject
function (which will create calls to the size-specialized functions)
rather then the newObjectNonSpecialized function (which won't). In the
newHeapaddr, small, non-pointer case, we'll create a non specialized
newObject and transform that into the appropriate size-specialized
function when we produce the mallocgc in flushPendingHeapAllocations.

We have to update some of the rewrites in generic.rules to also apply to
the size-specialized functions when they apply to newObject.

The messiest thing is we have to adjust the offset we use to save the
memory profiler stack, because the depth of the call to profilealloc is
two frames fewer in the size-specialized malloc functions compared to
when newObject calls mallocgc. A bunch of tests have been adjusted to
account for that.

Change-Id: I6a6a6964c9037fb6719e392c4a498ed700b617d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/707856
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
16 files changed:
src/cmd/compile/internal/ir/symtab.go
src/cmd/compile/internal/ssa/_gen/generic.rules
src/cmd/compile/internal/ssa/rewrite.go
src/cmd/compile/internal/ssa/rewritegeneric.go
src/cmd/compile/internal/ssa/writebarrier.go
src/cmd/compile/internal/ssagen/ssa.go
src/cmd/dist/buildtool.go
src/runtime/mprof.go
src/runtime/pprof/mprof_test.go
src/runtime/pprof/pprof_test.go
test/codegen/strings.go
test/fixedbugs/issue15747.go
test/heapsampling.go
test/live.go
test/live_regabi.go
test/uintptrescapes2.go