github.com/kitech/dl@v0.0.0-20201225001532-be4f4faa4070/asmcgocall/asmcgocall.go (about) 1 package asmcgocall 2 3 import ( 4 "unsafe" 5 ) 6 7 //go:linkname asmcgocall runtime.asmcgocall 8 //go:noescape 9 func asmcgocall(fn unsafe.Pointer, arg unsafe.Pointer) int32 10 11 // 这个最快,直接调用好了,而且是安全的,似乎可以用 12 // cgo直接调用大概60ns,这种方式调用在12ns(与system stack切换时间),go的调用2ns 13 // 只要 runtime.asmcgocall 还存在就可以用,与参数打包方式无关 14 // args &struct {p0 Type0, p1 Type1, ret Type} 15 func Asmcc(cfn unsafe.Pointer, args unsafe.Pointer) { 16 // pargs := args 17 asmcgocall(cfn, args) 18 }