llgo: fix tflag for named#86
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies rtype_llgo.go by updating how t.TFlag is manipulated in setTypeName and SetUnderlying, removing GC-related functions (gcEnable, gcDisable) and their usage in setMethodSet, and adding the DirectIfaceData linkname function. The review feedback suggests removing commented-out code in SetUnderlying rather than leaving it inline.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| } | ||
| rt.Size_ = ort.Size_ | ||
| rt.TFlag |= tflagUncommon | tflagExtraStar | tflagNamed | ||
| rt.TFlag |= tflagUncommon /*| tflagExtraStar*/ | tflagNamed |
There was a problem hiding this comment.
Review summary
Targeted fix to tflag handling for named types in the llgo build, plus removal of the GC suppression around method-set mutation and a new DirectIfaceData linkname. The tflagExtraStar fix in setTypeName looks correct. A few points worth addressing before merge — see inline comments. Highlights:
SetUnderlyingonly stops settingtflagExtraStar, whilesetTypeNameactively clears it. If the bit is already set onrt.TFlag(e.g. it is copied fromort.TFlaginnewTypeatrtype_llgo.go:281),SetUnderlyingwill leave a stale star bit set, so the fix is incomplete there.DirectIfaceDatais declared via//go:linknamebut never called anywhere in the repository — dead code as it stands.- Commented-out
/*| tflagExtraStar*/is left inline (also raised by gemini-code-assist); express the intent in code rather than a comment.
Question (not blocking)
The removal of gcDisable() / defer gcEnable() around the method-table mutation loop in setMethodSet (previously rtype_llgo.go:428-429) drops GC suppression while pointer fields of the live method table are written one at a time via unsafe pointers. Under llgo's conservative (Boehm) GC, was this verified safe — i.e. is there no longer a window where a GC cycle could observe a partially-written method entry? A short note in the commit/PR description on why this is now safe would help future readers, since there is no replacement synchronization.
| } | ||
| rt.Size_ = ort.Size_ | ||
| rt.TFlag |= tflagUncommon | tflagExtraStar | tflagNamed | ||
| rt.TFlag |= tflagUncommon /*| tflagExtraStar*/ | tflagNamed |
There was a problem hiding this comment.
Two concerns on this line:
- Incomplete vs.
setTypeName.setTypeNamenow actively clears the bit (t.TFlag = (t.TFlag & ^tflagExtraStar) | tflagNamed), but here you only stop setting it. Ifrt.TFlagalready hastflagExtraStarset — e.g. it was OR-ed in fromort.TFlaginnewTypeatrtype_llgo.go:281— the star bit survivesSetUnderlying, producing a wrongString()/Name()for the type. To mirrorsetTypeNameand be robust, clear it explicitly:
rt.TFlag = (rt.TFlag | tflagUncommon | tflagNamed) & ^tflagExtraStar- Commented-out code.
/*| tflagExtraStar*/leaves intent ambiguous (temporary? permanent?). Prefer removing it and adding a one-line comment explaining why the llgo build omitstflagExtraStarhere. (Also raised by gemini-code-assist in this thread.)
| return | ||
| } | ||
|
|
||
| //go:linkname DirectIfaceData github.com/goplus/llgo/runtime/internal/runtime.DirectIfaceData |
There was a problem hiding this comment.
DirectIfaceData is declared here via //go:linkname but has no caller anywhere in the repository (git grep DirectIfaceData returns only this declaration). As it stands this is dead code. If it is scaffolding for a follow-up change, consider adding it in the same commit that uses it, or add a brief comment explaining its purpose; otherwise it is liable to confuse future readers since it looks like a deliberately exposed symbol with no consumer.
No description provided.