Skip to content

support Go1.27 generic concrete method - #2395

Merged
1 commit merged into
xgo-dev:mainfrom
visualfc:concrete_method
Aug 29, 2026
Merged

support Go1.27 generic concrete method#2395
1 commit merged into
xgo-dev:mainfrom
visualfc:concrete_method

Conversation

@visualfc

Copy link
Copy Markdown
Collaborator

No description provided.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: skip generic methods in method-set processing

This is a small, focused change adding guards to skip uninstantiated generic methods when iterating method sets (compiling methods, building itab/ABI interface method tables, collecting runtime-caller targets) and appending a type-arg suffix for instantiated generic method symbols in funcName.

Correctness: Sound. TypeParams() != nil is the correct idiom here — for *types.Signature/*types.Func it is non-nil only for uninstantiated generics, and this matches the codebase convention documented in ssa/decl.go:239 and the existing precedent guard at cl/compile.go:2456. (The tp != nil && tp.Len() > 0 form in ssa/di.go is for *types.Named, a different case — no need to align.)

Safety/Performance: The .Type().(*types.Signature) assertions operate on values guaranteed to be signatures (method-set selections and *types.Func), so they cannot panic. Guards run before the expensive MethodValue resolution, so they are net-positive at compile time. No issues found.

Only findings — low-priority consistency: The new skip guards are silent, while the analogous precedent in the same file (cl/compile.go:2456) carries an explanatory comment. Adding a one-line rationale at each new guard would match local style and prevent a future reader from mistaking the continue for an accidental early-out. See inline comments.

Comment thread cl/compile.go Outdated
Comment thread cl/instr.go Outdated
Comment thread cl/import.go Outdated
Comment thread cl/instr.go Outdated
Comment thread ssa/abitype.go Outdated
@github-actions

github-actions Bot commented Aug 23, 2026

Copy link
Copy Markdown

LLGo baseline benchmarks

f51283ace161 | workflow run | long-term charts

Program measurements

Platform Workload File size vs base Text size vs base Build vs base Run vs base
Linux cprintf 19432 B 0 B / +0.0% 387 B 0 B / +0.0% 281.761 ms -8.029 ms / -2.8% (better) 1.080 ms -942 ns / -0.1% (better)
Linux cprintf-lto 19264 B 0 B / +0.0% 368 B 0 B / +0.0% 278.041 ms -10.7 ms / -3.7% (better) 1.075 ms +1.342 us / +0.1% (worse)
Linux fmtprintf 1652216 B 0 B / +0.0% 501874 B 0 B / +0.0% 2.070 s -79.24 ms / -3.7% (better) 2.823 ms -87.51 us / -3.0% (better)
Linux fmtprintf-lto 1524168 B 0 B / +0.0% 460334 B 0 B / +0.0% 7.153 s -15.87 ms / -0.2% (better) 2.744 ms -49.66 us / -1.8% (better)
Linux println 62264 B 0 B / +0.0% 15286 B 0 B / +0.0% 287.799 ms -1.051 ms / -0.4% (better) 1.372 ms +27.18 us / +2.0% (worse)
Linux println-lto 54096 B 0 B / +0.0% 12914 B 0 B / +0.0% 422.247 ms +231.2 us / +0.1% (worse) 1.358 ms -14.52 us / -1.1% (better)
macOS cprintf 84480 B 0 B / +0.0% 16669 B 0 B / +0.0% 398.455 ms +18.65 ms / +4.9% (worse) 3.017 ms -2.114 ms / -41.2% (better)
macOS cprintf-lto 100704 B 0 B / +0.0% 16649 B 0 B / +0.0% 404.474 ms -26.23 ms / -6.1% (better) 2.712 ms -679.2 us / -20.0% (better)
macOS fmtprintf 1512800 B 0 B / +0.0% 882816 B 0 B / +0.0% 2.079 s +80.57 ms / +4.0% (worse) 5.752 ms -370.2 us / -6.0% (better)
macOS fmtprintf-lto 1208464 B 0 B / +0.0% 875856 B 0 B / +0.0% 5.951 s +326.1 ms / +5.8% (worse) 6.638 ms +707 us / +11.9% (worse)
macOS println 114784 B 0 B / +0.0% 35101 B 0 B / +0.0% 360.508 ms +4.135 ms / +1.2% (worse) 3.349 ms +108.4 us / +3.3% (worse)
macOS println-lto 118656 B 0 B / +0.0% 32753 B 0 B / +0.0% 517.851 ms -26.68 ms / -4.9% (better) 3.315 ms -2.481 ms / -42.8% (better)
Windows cprintf 120320 B 0 B / +0.0% 65787 B 0 B / +0.0% 767.061 ms +3.168 ms / +0.4% (worse) 3.402 ms -21.3 us / -0.6% (better)
Windows cprintf-lto 119808 B 0 B / +0.0% 65707 B 0 B / +0.0% 816.259 ms +29.02 ms / +3.7% (worse) 3.002 ms -398.9 us / -11.7% (better)
Windows fmtprintf 1608192 B 0 B / +0.0% 687254 B 0 B / +0.0% 3.526 s +7.686 ms / +0.2% (worse) 8.002 ms +204.9 us / +2.6% (worse)
Windows fmtprintf-lto 1650176 B 0 B / +0.0% 685718 B 0 B / +0.0% 9.196 s -79.97 ms / -0.9% (better) 8.733 ms +240.8 us / +2.8% (worse)
Windows println 194560 B 0 B / +0.0% 120534 B 0 B / +0.0% 776.801 ms +8.456 ms / +1.1% (worse) 6.564 ms +138.9 us / +2.2% (worse)
Windows println-lto 190976 B 0 B / +0.0% 117590 B 0 B / +0.0% 992.604 ms +5.234 ms / +0.5% (worse) 6.520 ms +170.2 us / +2.7% (worse)
Core language and compiler benchmarks
Platform Benchmark ns/op vs base
Linux BenchmarkLookupPCRandom 9.494 ns/op -0.013 ns/op / -0.1% (better)
Linux BenchmarkMergeCompilerFlags 112.600 ns/op +0.1 ns/op / +0.1% (worse)
Linux BenchmarkMergeLinkerFlags 74.320 ns/op +0.76 ns/op / +1.0% (worse)
Linux BenchmarkChannelBuffered 30.540 ns/op -2.55 ns/op / -7.7% (better)
Linux BenchmarkChannelHandoff 19107 ns/op +191 ns/op / +1.0% (worse)
Linux BenchmarkDefer 36.600 ns/op -0.8 ns/op / -2.1% (better)
Linux BenchmarkDirectCall 1.364 ns/op 0 ns/op / +0.0%
Linux BenchmarkGlobalRead 1.637 ns/op 0 ns/op / +0.0%
Linux BenchmarkGlobalWrite 2.176 ns/op +0.001 ns/op / +0.04598% (worse)
Linux BenchmarkGoroutine 24796 ns/op -3844 ns/op / -13.4% (better)
Linux BenchmarkInterfaceCall 6.550 ns/op +0.002 ns/op / +0.03054% (worse)
Linux BenchmarkRuntimeGetG 1.365 ns/op +0.001 ns/op / +0.1% (worse)
macOS BenchmarkLookupPCRandom 11.830 ns/op -0.23 ns/op / -1.9% (better)
macOS BenchmarkMergeCompilerFlags 127.100 ns/op -1.2 ns/op / -0.9% (better)
macOS BenchmarkMergeLinkerFlags 75.470 ns/op +1.79 ns/op / +2.4% (worse)
macOS BenchmarkChannelBuffered 24.810 ns/op -0.59 ns/op / -2.3% (better)
macOS BenchmarkChannelHandoff 8775 ns/op -1122 ns/op / -11.3% (better)
macOS BenchmarkDefer 34.060 ns/op -1 ns/op / -2.9% (better)
macOS BenchmarkDirectCall 1.087 ns/op +0.01 ns/op / +0.9% (worse)
macOS BenchmarkGlobalRead 1.083 ns/op -0.031 ns/op / -2.8% (better)
macOS BenchmarkGlobalWrite 1.152 ns/op +0.03 ns/op / +2.7% (worse)
macOS BenchmarkGoroutine 24548 ns/op -4805 ns/op / -16.4% (better)
macOS BenchmarkInterfaceCall 4.668 ns/op -0.138 ns/op / -2.9% (better)
macOS BenchmarkRuntimeGetG 2.136 ns/op -0.106 ns/op / -4.7% (better)
Windows BenchmarkLookupPCRandom 16.150 ns/op +0.18 ns/op / +1.1% (worse)
Windows BenchmarkMergeCompilerFlags 579 ns/op -11.6 ns/op / -2.0% (better)
Windows BenchmarkMergeLinkerFlags 510.600 ns/op -5.3 ns/op / -1.0% (better)
Windows BenchmarkChannelBuffered 34.760 ns/op -1.9 ns/op / -5.2% (better)
Windows BenchmarkChannelHandoff 882.900 ns/op -93 ns/op / -9.5% (better)
Windows BenchmarkDefer 54.780 ns/op -0.29 ns/op / -0.5% (better)
Windows BenchmarkDirectCall 1.551 ns/op +0.004 ns/op / +0.3% (worse)
Windows BenchmarkGlobalRead 1.856 ns/op -0.004 ns/op / -0.2% (better)
Windows BenchmarkGlobalWrite 2.447 ns/op -0.004 ns/op / -0.2% (better)
Windows BenchmarkGoroutine 91525 ns/op -438 ns/op / -0.5% (better)
Windows BenchmarkInterfaceCall 9.298 ns/op -0.006 ns/op / -0.1% (better)
Windows BenchmarkRuntimeGetG 2.790 ns/op +0.001 ns/op / +0.03586% (worse)

Compared with 3cae0b85150d measured in the same runner job.

@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 15.38462% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cl/import.go 0.00% 2 Missing and 1 partial ⚠️
cl/compile.go 0.00% 1 Missing and 1 partial ⚠️
cl/instr.go 50.00% 1 Missing and 1 partial ⚠️
internal/genmethod/types.go 0.00% 2 Missing ⚠️
ssa/abitype.go 0.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@visualfc
visualfc force-pushed the concrete_method branch 2 times, most recently from 23e02c6 to b94798b Compare August 23, 2026 02:50
@xushiwei xushiwei closed this pull request by merging all changes into xgo-dev:main in 96fe356 Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants