summaryrefslogtreecommitdiff
path: root/vendor/github.com/bytedance/sonic/internal/rt
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/bytedance/sonic/internal/rt')
-rw-r--r--vendor/github.com/bytedance/sonic/internal/rt/fastmem.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/vendor/github.com/bytedance/sonic/internal/rt/fastmem.go b/vendor/github.com/bytedance/sonic/internal/rt/fastmem.go
index 5bf80dd4e..e3bf0db91 100644
--- a/vendor/github.com/bytedance/sonic/internal/rt/fastmem.go
+++ b/vendor/github.com/bytedance/sonic/internal/rt/fastmem.go
@@ -109,4 +109,16 @@ func StrFrom(p unsafe.Pointer, n int64) (s string) {
(*GoString)(unsafe.Pointer(&s)).Ptr = p
(*GoString)(unsafe.Pointer(&s)).Len = int(n)
return
+}
+
+// NoEscape hides a pointer from escape analysis. NoEscape is
+// the identity function but escape analysis doesn't think the
+// output depends on the input. NoEscape is inlined and currently
+// compiles down to zero instructions.
+// USE CAREFULLY!
+//go:nosplit
+//goland:noinspection GoVetUnsafePointer
+func NoEscape(p unsafe.Pointer) unsafe.Pointer {
+ x := uintptr(p)
+ return unsafe.Pointer(x ^ 0)
} \ No newline at end of file