xruntime

package module
v0.0.0-...-717632c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2021 License: MPL-2.0 Imports: 2 Imported by: 0

README

Go xruntime helper package

Caution!

This package based on the Go package "unsafe", therefore it cannot be used in Google App Engine apps!

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/

TODO
  • More tests
  • full api doc

© 2020-2021 Illirgway

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignSlice2StringUnsafe

func AssignSlice2StringUnsafe(b []byte) (s string)

func AssignString2SliceUnsafe

func AssignString2SliceUnsafe(sp *string) (b []byte)

SEE go api runtime slicebytetostringtmp

NOTE go compiler generate shortest code for `*string` arg type (at least for go1.13)

func AssignString2SliceUnsafeRough

func AssignString2SliceUnsafeRough(sp *string) []byte

shorter and better for inlining version of AssignString2SliceUnsafe, but without Cap explicit initialization (cap(result) is undefined garbage) should be used with additional care

NOTE go compiler generate shortest code for `*string` arg type (at least for go1.13)

func GetStringDataPointer

func GetStringDataPointer(sp *string) uintptr

inlined

func GetStringHeader

func GetStringHeader(sp *string) *reflect.StringHeader

from runtime/string.go:stringStructOf inlined

func NoEscape

func NoEscape(p unsafe.Pointer) unsafe.Pointer

Hides pointer from the compiler escape analysis The most dangerous function in file, SHOULD BE USED WITH EXTREME CAREFULLY

In fact it is copy of go src\runtime\stubs.go:noescape() under exported name

USAGE (*TypeT)(xruntime.NoEscape(unsafe.Pointer(&valueOfTypeT))) NOTE can't simply use go:linkname due to loss of inlining

inlined ~go:noescape

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL