go build -gcflags -S .
在汇编代码中,我写了很多类似于以下的行:
PCDATA $2, $1
这是什么意思?在汇编快速指南中,它声明:
但没有太多细节。FUNCDATA和PCDATA指令包含垃圾收集器使用的信息;它们由编译器引入
Russ Cox的文章“Go 1.2运行时符号信息”提到:FUNCDATA和PCDATA指令包含垃圾收集器使用的信息;它们由编译器引入。
Similarly, the pseudo-instruction
PCDATA $3, $45
declares that the value with index 3 associated with the current program counter is 45. Each of the pcdata indexes (PCDATA $1, PCDATA $2, and so on) encodes to a separate pc-value table. Just as with funcdata, the index allows the definition of multiple kinds of pcdata for a given function, and there will be a registry for those indexes too.
At run time, the runtime can, from a Func, retrieve the funcdata with a given index or the pcdata with a given index at a given program counter. A pcdata stream may produce an int32 interpreted by reference to corresponding data retrieved as a funcdata pointer.
The struct Func is followed immediately in memory by npcdata int32s giving the offsets to the pcdata tables; if nfuncdata > 0, the npcdata int32s are followed immediately by a possible int32 gap for alignment and then nfuncdata uintptrs giving the funcdata values. If pcsp, pcfile, pcln, or any of the pcdata offsets is zero, that table is considered missing, and all PCs take value -1.