mirror of
https://github.com/golang/go
synced 2024-11-22 05:04:40 -07:00
cmd/compile, reflect: treat abi.NoEscape as cheap call
The abi.NoEscape function is introduced to replace all usages of noescape wrapper in the standard library. However, the last usage in reflect package is still present, because the inlining test failed if abi.NoEscape were used. The reason is that reflect.noescape is treated as a cheap call, while abi.NoEscape is not. By treating abi.NoEscape a cheap call, the last usage of noescape in reflect package can now be removed. Change-Id: I798079780129221a5a26cbcb18c95ee30855b784 Reviewed-on: https://go-review.googlesource.com/c/go/+/601275 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
deed521ea3
commit
b6efbd4efc
@ -460,10 +460,10 @@ opSwitch:
|
||||
case "panicrangestate":
|
||||
cheap = true
|
||||
}
|
||||
// Special case for reflect.noescape. It does just type
|
||||
// Special case for internal/abi.NoEscape. It does just type
|
||||
// conversions to appease the escape analysis, and doesn't
|
||||
// generate code.
|
||||
if types.ReflectSymName(name.Sym()) == "noescape" {
|
||||
if s := name.Sym(); s.Name == "NoEscape" && s.Pkg.Path == "internal/abi" {
|
||||
cheap = true
|
||||
}
|
||||
}
|
||||
|
@ -2677,7 +2677,7 @@ func (v Value) TrySend(x Value) bool {
|
||||
// Type returns v's type.
|
||||
func (v Value) Type() Type {
|
||||
if v.flag != 0 && v.flag&flagMethod == 0 {
|
||||
return (*rtype)(noescape(unsafe.Pointer(v.typ_))) // inline of toRType(v.typ()), for own inlining in inline test
|
||||
return (*rtype)(abi.NoEscape(unsafe.Pointer(v.typ_))) // inline of toRType(v.typ()), for own inlining in inline test
|
||||
}
|
||||
return v.typeSlow()
|
||||
}
|
||||
@ -4018,13 +4018,3 @@ func contentEscapes(x unsafe.Pointer) {
|
||||
escapes(*(*any)(x)) // the dereference may not always be safe, but never executed
|
||||
}
|
||||
}
|
||||
|
||||
// This is just a wrapper around abi.NoEscape. The inlining heuristics are
|
||||
// finnicky and for whatever reason treat the local call to noescape as much
|
||||
// lower cost with respect to the inliner budget. (That is, replacing calls to
|
||||
// noescape with abi.NoEscape will cause inlining tests to fail.)
|
||||
//
|
||||
//go:nosplit
|
||||
func noescape(p unsafe.Pointer) unsafe.Pointer {
|
||||
return abi.NoEscape(p)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user