How to define a function in the structure pointer in an assembly?

For example:

// dummy.go type dummy struct { p uintptr } func (d dummy) Get(i int) uint64 //func (d *dummy) Get(i int) uint64 //no way to define *dummy in assembly 

func (d dummy) Get can be defined as:

 // dummy_amd64.s #include "textflag.h" TEXT ·dummy·Get(SB),NOSPLIT,$0 MOVQ $42, 24(SP) RET 

I tried

 TEXT "".(*dummy).Get+0(SB),4,$0-24 //output from 6g -S TEXT ""·(*dummy)·Get+0(SB),4,$0 TEXT ·*dummy·Get(SB),NOSPLIT,$0 //and TEXT ·(*dummy)·Get(SB),NOSPLIT,$0 

They all give me the same error:

syntax error, last name: "".

I am sure that I am missing something obvious, but I cannot understand it.

+7
assembly go
source share
1 answer

This is not possible for the current toolchain. Context explained in issue 4978

Please note that there is a simple patch to enable this feature, but only a few people use it.

You can write a regular build function (i.e. not a method) and implement a call to the Go method for this build function. But the extra call will not be optimized by the compiler.

A possible workaround for this problem would be to implement some support to combine the build functions in Go code, which will bring more benefits. I understand that this has been discussed in the past, but not yet planned.

+3
source share

All Articles