aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
7 dayscrypto/tls: avoid atLeastReader and associated allocations.Daniel Morsing
Go 1.21 introduced bytes.Buffer.AvailableBuffer. This mechanism lets us write directly into a Buffer's backing memory while also implementing custom logic without going through interfaces. atLeastReader caused an allocation on every read. On workloads with very small reads, these allocations can add up to substantial overhead. By using Buffer.AvailableBytes(), we can avoid these allocations and an interface indirection in the Read fast path. Fixes #58249. Change-Id: Icf26ec1dd7ef88154c47356ef9c26a516a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/739980 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
7 dayscrypto/ed25519: use FIPS 140-3 GenerateKey and enforce fips140=onlyFilippo Valsorda
Fixes #77594 Change-Id: I2685931ec37d9beb99de2e0398ab6f456a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/745800 Auto-Submit: Filippo Valsorda <filippo@golang.org> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
7 dayscmd/go/internal/modload: disambiguate package and module loadersIan Alexander
Change the short name of the packageLoader variables to `pld` to allow for the module loader to use `ld` consistently. This change is part of the effort to rename the modload.State type to modload.Loader in order to better reflect its purpose. Change-Id: I73b072613190bcca841bcca16e9af6e60ecd99f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/763380 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
8 dayscmd/internal/testdir: do not fail fast when running asmcheckPaul Murphy
Print each error as they happen, and continue running. This is helpful if multiple targets fail using -all_codegen. Change-Id: Ifcb87a834662fbd4766e562ecf3ca278dcdc1af2 Reviewed-on: https://go-review.googlesource.com/c/go/+/761465 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org>
8 daysall: update to x/tools@b36d1d12a1a724eb9be6609c9789aec3d99e6030Mark Freeman
Change-Id: If1c8d07aa53c5444b815b922ff4e0c18649ab83c Reviewed-on: https://go-review.googlesource.com/c/go/+/763181 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
8 dayscmd/go: invalidate test cache when -coverpkg dependencies changeRyan Currah
When running tests with -cover and -coverpkg, the resulting coverage profile includes data from all packages specified in -coverpkg, not just the test package. Previously, the test cache key did not account for changes in these out-of-band covered packages, causing stale coverage profiles to be reused even when source files in covered packages were modified. Fix this by hashing the BuildActionIDs of the writeCoverMetaAct's dependencies (the compile actions for all covered packages) and incorporating that hash into the coverage profile cache key via cache.Subkey. The covMeta hash is now computed directly in tryCacheWithID by locating the "write coverage meta-data file" action among the run action's dependencies, keeping all cache logic in one place. When -coverpkg is used without -coverprofile, a sentinel cache entry is written so the cache can still detect when covered packages change. Fixes #74873 Change-Id: Ice84557789e325330759442689d0e28f871858bb GitHub-Last-Rev: 84aa5376f471704b0ee7be79ab33a1d5bba71c5a GitHub-Pull-Request: golang/go#74773 Reviewed-on: https://go-review.googlesource.com/c/go/+/690775 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
8 dayscmd/go/internal/modload: minor modernization fixesIan Alexander
* Add package comment. * Make octal literal explicit. * Simplify single var declaration. Change-Id: I3841ca538034c75098502b35b1a713a98e936efc Reviewed-on: https://go-review.googlesource.com/c/go/+/763360 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com>
8 dayscmd/compile: ensure result selects are in the block of a callkhr@golang.org
Without this CL, when compiling test/range4.go:func9, we get: b1: v1 = StaticLECall <runtime.deferrangefunc> mem = SelectN [1] v1 Defer v1 -> b2 b3 b2: v2 = SelectN [0] v1 That select in b2 should really live in b1. This doesn't cause a bug as far as I can tell, but it makes a check fail when when checkEnabled is set in the compiler. Change-Id: I8fe928fa8c376b81131ec712fc69d5fd39a1d4bb Reviewed-on: https://go-review.googlesource.com/c/go/+/747740 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
8 daysruntime: remove gopanicFP field from panic recordKeith Randall
We can use SP instead of FP for the single thing this was used for (finding the gopanic frame). Change-Id: Iad2b406705abc3cdb0dbcdd069f7f9a330509164 Reviewed-on: https://go-review.googlesource.com/c/go/+/738042 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
8 dayscmd/compile/testdata/script/issue77033.txt: make test panicAlex Brainman
The issue77033.txt script is executed by cmd/internal/script/scripttest/run.go program, that uses 60 seconds interrupt timeout. The timeout is implemented by calling os/exec.Cmd.Process.Signal(os.Interrupt) but that call is not implemented on Windows, and we get run.go:259: FAIL: testdata\script\issue77033.txt:2: go test -bench=Foo -pgo=default.pgo: exec: canceling Cmd: not supported by windows useless output when the test fails on Windows. This CL adds -timeout=30s to go test command, that will make test panic. Hopefully panic will provide more details about the failure. For #77485 Change-Id: I69839c59a28f48fea5d504a5038145ffd651aed2 Reviewed-on: https://go-review.googlesource.com/c/go/+/762980 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com>
8 dayscmd/compile: report error instead of ICE for oversized map elementgulmix
When a map element or key type is 2GB or larger, the compiler crashed with "internal compiler error: map elem too big" in reflectdata.ZeroAddr. Add a size check in types.CalcSize for TMAP, similar to the existing check for channel element types, so that oversized map elements are reported as a normal error before reaching ZeroAddr. Fixes #78355 Change-Id: I281a5f0ec7dda6dac084787859156d4409dc860c Reviewed-on: https://go-review.googlesource.com/c/go/+/760600 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
8 dayscmd/compile: optimize CondSelect to math on arm64 with inline register shiftsJorropo
Change-Id: I27696b1a5fa0593d9f36743efa3559a36d23ec4b Reviewed-on: https://go-review.googlesource.com/c/go/+/760844 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
8 dayscmd/compile: improve Mul to Left Shift rulesJorropo
- fix a bug where it wouldn't recognize 1<<63 as a power of two - remove the IsSigned check; there is no such thing as a signed Mul If the rule works for signed numbers it works for unsigned ones too. Even if the intermediary steps makes no sense, it ends up wrapping the right way around in the end. Change-Id: I86182762aec5eff784e2d9bc49ee028825fb9ea0 Reviewed-on: https://go-review.googlesource.com/c/go/+/760843 Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
8 daysruntime: save and restore fcsr0 registers in async preempt on loong64Guoqi Chen
Currently, all Op implementations on loong64 do not modify the FCSR (floating point control status register), but users can modify the FCSR for special floating point computing needs. FCSR is also saved and restored in the fpu context of the Linux kernel [1]. [1]: https://github.com/torvalds/linux/blob/master/arch/loongarch/kernel/fpu.S#L565C1-L566C1 Change-Id: I776e72dfcc1f027bfe8d22aa2eae453100a6ee1c Reviewed-on: https://go-review.googlesource.com/c/go/+/761720 Reviewed-by: Meidan Li <limeidan@loongson.cn> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
8 dayscmd/compile: add loop invariant code motionIlya Tocar
(I copied Ilya Tocar's CL 27656 and heavily modified it.) This adds an optimization that moves loop invariant computations out of the loop. For example: a:= ... for ... { b:= a + 15 // uses of b } Turns into a:= ... b:= a + 15 for ... { // uses of b } Change-Id: I36c8c7e2b3bc1c5e6b4b293bed3a76dc20d6c825 Reviewed-on: https://go-review.googlesource.com/c/go/+/697235 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
8 daysnet/mail: fix quadratic complexity in consumeCommentmohammadmseet-hue
consumeComment builds the comment string by repeated string concatenation inside a loop. Each concatenation copies the entire string built so far, making the function O(n^2) in the depth of nested comments. Replace the concatenation with a strings.Builder, which amortizes allocation by doubling its internal buffer. This reduces consumeComment from O(n^2) to O(n). This is the same bug class as the consumeDomainLiteral fix in CVE-2025-61725. Benchmark results (benchstat, 8 runs): name old time/op new time/op delta ConsumeComment/depth10 2.481us 1.838us -25.92% ConsumeComment/depth100 86.58us 6.498us -92.50% ConsumeComment/depth1000 7.963ms 52.82us -99.34% ConsumeComment/depth10000 897.8ms 521.3us -99.94% The quadratic cost becomes visible at depth 100 and dominant by depth 1000. At depth 10000, the fix is roughly 1700x faster. Change-Id: I3c927f02646fcab7bab167cb82fd46d3327d6d34 GitHub-Last-Rev: 7742dad716ee371766543f88e82bd163bd9d7ac2 GitHub-Pull-Request: golang/go#78393 Reviewed-on: https://go-review.googlesource.com/c/go/+/759940 Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
8 dayscmd/compile/internal/importer: consume generic methods in importerMark Freeman
Change-Id: Iac9428fe8d2fb3e6fde30940470bf5d3ac9751cb Reviewed-on: https://go-review.googlesource.com/c/go/+/763141 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Mark Freeman <markfreeman@google.com>
8 daysgo/internal/gcimporter: consume generic methods in gcimporterMark Freeman
Change-Id: I32af8f18da6c9c95d6fe6189d2f6735868667b3e Reviewed-on: https://go-review.googlesource.com/c/go/+/763120 Auto-Submit: Mark Freeman <markfreeman@google.com> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
8 dayscmd/compile: cleanup rules by canonicalizing sext(int(bool)) → zext(int(bool))Jorropo
Change-Id: Ic97f661c68180ff7adb9976fcc61279e1e1f04a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/760842 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
8 dayscmd/compile: extend condselect into math code to handle other constants than 1Jorropo
On amd64 along: if b { x += 1 } => x += b We can also implement constants 2 4 and 8: if b { x += 2 } => x += b * 2 This compiles to a displacement LEA. Change-Id: Ib00fcc5059acb0ebb346e056c4a656f164cc63df Reviewed-on: https://go-review.googlesource.com/c/go/+/760841 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
8 dayscmd/go/internal/workcmd: correct go.work file nameSean Liao
Fixes #51714 Change-Id: I0619b1ca6715bed85ccc066a83a449f66a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/762660 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
8 daysruntime: fix timespec definition on 32bits systemsJorropo
The nsec field of timespec is a C long even when using 64bits time on 32bits systems. This is because by timespec API if nsec never holds more than a second worth of nanoseconds. If it would theses would increment the sec field while the nsec field would get the amount of nanoseconds modulus a second. Fixes #77934 Change-Id: I9803998ba70123eb3b226379bd72b11cae972c38 Reviewed-on: https://go-review.googlesource.com/c/go/+/751341 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
8 daysnet/http: fix shadow var frameWeixie Cui
Change-Id: Ib03f65992b065e169fa6ccd08664336bec559c1d GitHub-Last-Rev: bd597d4325c713c53a9f22cb93892d90f393c6ac GitHub-Pull-Request: golang/go#78527 Reviewed-on: https://go-review.googlesource.com/c/go/+/762700 Reviewed-by: Nicholas Husin <nsh@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <husin@google.com>
9 daysmath/big: optimize writeMultiple to use StringWriter and ByteWriterJorropo
This overhauls writeMultiple to reduce allocations: - return early if called with a count of 0 rather than allocating a buffer - if writing one byte, which happens when padding, try io.ByteWriter - try io.StringWriter - fallback to io.Writer as currently done Unlike what is suggested in #71465 I did not used io.WriteString to avoid a regression where we would allocate the byte slice once per iteration of count. goos: linux goarch: amd64 pkg: math/big cpu: AMD Ryzen 5 3600 6-Core Processor │ /tmp/old │ /tmp/new │ │ sec/op │ sec/op vs base │ Format-12 70.45µ ± 1% 63.55µ ± 2% -9.80% (p=0.000 n=10) │ /tmp/old │ /tmp/new │ │ B/op │ B/op vs base │ Format-12 14.73Ki ± 0% 10.96Ki ± 0% -25.58% (p=0.000 n=10) │ /tmp/old │ /tmp/new │ │ allocs/op │ allocs/op vs base │ Format-12 1098.0 ± 0% 649.0 ± 0% -40.89% (p=0.000 n=10) Fixes #71465 Change-Id: I44565c540b2d73c8737ac9733687141b645d9856 Reviewed-on: https://go-review.googlesource.com/c/go/+/645215 Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
9 daystime: wrong Sign Cast in Time.UnmarshalBinary (V2 Format)cuiweixie
Fixes #78528 Change-Id: I8979a310dbf94b9710d3e8428480cb49a7308294 GitHub-Last-Rev: 3d7f5ef1491f15923add6ef556e387eb8d49bf3b GitHub-Pull-Request: golang/go#78518 Reviewed-on: https://go-review.googlesource.com/c/go/+/762480 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 daysos: use t.TempDir in root_test tempDirWithUnixSocketRunxi Yu
tempDirWithUnixSocket used os.MkdirTemp("", ""), while other paths in root consistency tests use t.TempDir(). If GOTMPDIR and the system temp dir are on different filesystems (such as during abuild), TestRootConsistencyRename and TestRootConsistencyLink may produce EXDEV. Fixes #78063 Change-Id: Ib81abec0876babf0cc0e2d9e53e34f051ddfbbc6 Reviewed-on: https://go-review.googlesource.com/c/go/+/754102 Auto-Submit: Sean Liao <sean@liao.dev> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
9 dayscmd/go/internal/script: add fuzz test for quoteArgsAbhinav Gupta
Adds a fuzz test for quoteArgs and fixes the bugs it found: handling of empty strings and strings containing "&" or "$". This is a copy of a similar change submitted to rsc.io/script: https://github.com/rsc/script/pull/10 Change-Id: I76e7fc89475e1c4e415f45f2c7ac4a87a7a659e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/566316 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
9 dayscmd/compile: unify DWARF variable generation and remove encodingDerek Parker
Refactor the DWARF variable generation in the compiler: 1. Replace the intermediate []byte location list encoding with a structured LocListEntry type. The old code packed SSA block/value IDs into pointer-sized integers, wrote them alongside DWARF4-format length-prefixed expressions, then re-read and decoded everything during final encoding. The new approach stores entries as {StartBlock, StartValue, EndBlock, EndValue, Expr} structs that PutLocationListDwarf4/5 directly encode into the appropriate format. This eliminates encodeValue, decodeValue, appendPtr, writePtr, readPtr, and SetupLocList, and removes the DWARF4 re-encoding in PutLocationListDwarf5. 2. Unify createDwarfVars into a single processing loop. The old code had three mutually exclusive paths (createSimpleVars, createABIVars, createComplexVars) selected by build mode, followed by a separate conservative-var loop. The new code uses one loop that tries createComplexVar first (when SSA debug info is available), then falls back to createSimpleVar. This removes createSimpleVars, createABIVars, and createComplexVars. 3. Extract createConservativeVar and shouldEmitDwarfVar as named functions, consolidating inline code and scattered filtering logic. 4. Fix createHeapDerefLocationList to return []LocListEntry instead of raw bytes, consistent with the new representation. Change-Id: If6fb755c22e398d7615dccaf33b1367828e6c47e Reviewed-on: https://go-review.googlesource.com/c/go/+/750920 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
9 dayscmd/compile: improve uint8/uint16 logical immediates on PPC64Jayanth Krishnamurthy jayanth.krishnamurthy@ibm.com
Logical ops on uint8/uint16 (AND/OR/XOR) with constants sometimes materialized the mask via MOVD (often as a negative immediate), even when the value fit in the UI-immediate range. This prevented the backend from selecting andi. / ori / xori forms. This CL makes: UI-immediate truncation is performed only at the use-site of logical-immediate ops, and only when the constant does not fit in the 8- or 16-bit unsigned domain (m != uint8(m) / m != uint16(m)). This avoids negative-mask materialization and enables correct emission of UI-form logical instructions. Arithmetic SI-immediate instructions (addi, subfic, etc.) and other use-patterns are unchanged. Codegen tests are added to ensure the expected andi./ori/xori patterns appear and that MOVD is not emitted for valid 8/16-bit masks. Change-Id: I9fcdf4498c4e984c7587814fb9019a75865c4a0d Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10,gotip-linux-ppc64_power8,gotip-linux-ppc64le_power8,gotip-linux-ppc64le_power9,gotip-linux-ppc64le_power10 Reviewed-on: https://go-review.googlesource.com/c/go/+/704015 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Paul Murphy <paumurph@redhat.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
11 dayscmd/internal/obj/riscv: add assembly support for Zihintpause extensionsQiu Weihong
Add support for the PAUSE instruction provided by the Zihintpause extension. Change-Id: If06cce4ca57137275f567b5fe29ef85517f381ef Reviewed-on: https://go-review.googlesource.com/c/go/+/710495 Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
11 dayscmd/compile: optimize switch statements using lookup tablesqmuntal
Switch statement containing integer constant cases and case bodies just returning a constant should be optimizable to a simpler and faster table lookup instead of a jump table. That is, a switch like this: switch x { case 0: return 10 case 1: return 20 case 2: return 30 case 3: return 40 default: return -1 } Could be optimized to this: var table = [4]int{10, 20, 30, 40} if uint(x) < 4 { return table[x] } return -1 The resulting code is smaller and faster, especially on platforms where jump tables are not supported. goos: windows goarch: arm64 pkg: cmd/compile/internal/test │ .\old.txt │ .\new.txt │ │ sec/op │ sec/op vs base │ SwitchLookup8Predictable-12 2.708n ± 6% 2.249n ± 5% -16.97% (p=0.000 n=10) SwitchLookup8Unpredictable-12 8.758n ± 7% 3.272n ± 4% -62.65% (p=0.000 n=10) SwitchLookup32Predictable-12 2.672n ± 5% 2.373n ± 6% -11.21% (p=0.000 n=10) SwitchLookup32Unpredictable-12 9.372n ± 7% 3.385n ± 6% -63.89% (p=0.000 n=10) geomean 4.937n 2.772n -43.84% Fixes #78203 Change-Id: I74fa3d77ef618412951b2e5c3cb6ebc760ce4ff1 Reviewed-on: https://go-review.googlesource.com/c/go/+/756340 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
11 dayscmd/compile/internal/noder: recognize generic method instantiationMark Freeman
This change slightly extends expression traversal to recognize explicit instantiation of generic methods. The relevant MethodVal and MethodExpr snippets are extracted into helper functions, since they are needed in two places. Change-Id: I85d49d89f2422fa4c2d09de28fb6552f171a2a1f Reviewed-on: https://go-review.googlesource.com/c/go/+/762560 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com>
11 dayscrypto/x509/pkix: avoid quadratic string concatenation in RDNSequence.StringNavtej
RDNSequence.String builds its result using repeated s += ... inside nested loops, leading to O(N²) time and memory complexity. A certificate with many Subject or Issuer RDN entries can therefore cause excessive CPU and memory usage when String is called. Switch to strings.Builder to construct the output, reducing complexity to O(N) without changing behavior. This follows the same approach used to fix CVE-2025-61729 (HostnameError.Error), which addressed the same quadratic concatenation pattern. Change-Id: Id44303b5732081de9f01d186bc2b8ac66349a650 GitHub-Last-Rev: b0706c20655d1a263c3a989b76c0c25796c900df GitHub-Pull-Request: golang/go#78265 Reviewed-on: https://go-review.googlesource.com/c/go/+/757680 Reviewed-by: Navtej Kathuria US <nkathuria@nvidia.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Mateusz Poliwczak <mpoliwczak34@gmail.com>
11 dayspath/filepath: document Dir behavior for Windows volume-only pathskovan
Clarify that on Windows, Dir("C:") returns "C:." (the current directory on drive C) rather than a root path. This is because Clean("") returns "." and Dir prepends the volume name. Fixes #77314 Change-Id: Idbc8ef5a4905e8587268428503a98a28c8c2f6e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/740902 Reviewed-by: Rob Pike <r@golang.org> TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Olivier Mengué <olivier.mengue@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
11 dayscmd/internal/obj/loong64: run go generateKeith Randall
"go generate" on this package seems to generate a diff. I have no idea whether this diff is reasonable or not. It looks kinda weird, but maybe? Or perhaps something is wrong with ../mkcnames.go. Change-Id: I3474bab3f6880ffc24c1cf6ec11958a1c9467909 Reviewed-on: https://go-review.googlesource.com/c/go/+/761680 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: Meidan Li <limeidan@loongson.cn> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
11 dayscmd/compile: extend all the cmov into math generic rules with their contraryJorropo
If the bool comes from a local operation this is foldable into the comparison. if a == b { } else { x++ } becomes: x += !(a == b) becomes: x += a != b If the bool is passed in or loaded rather than being locally computed this adds an extra XOR ^1 to invert it. But at worst it should make the math equal to the compute + CMP + CMOV which is a tie on modern CPUs which can execute CMOV on all int ALUs and a win on the cheaper or older ones which can't. Change-Id: Idd2566c7a3826ec432ebfbba7b3898aa0db4b812 Reviewed-on: https://go-review.googlesource.com/c/go/+/760922 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Junyang Shao <shaojunyang@google.com>
11 dayscmd/compile/internal/noder: omit wrapper functions for generic methodsMark Freeman
Emitting wrapper functions for generic methods is tricky for 2 reasons: 1. Existing downstream machinery expects that it can make certain assumptions about a method if it sees a wrapper function. We may violate those assumptions with generic method wrappers. 2. Signatures for generic methods are generic and hence cannot be encoded using w.typ. This has the slight downside of not using a statically computed wrapper for generic methods and instead dynamically computing the dictionary pointer. Thus, we miss out on a performance optimization for generic methods for now. Code that does not use generic methods is unaffected. Change-Id: I72c626ef0f807c0cb54d8cf040250de8177303cc Reviewed-on: https://go-review.googlesource.com/c/go/+/762382 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Mark Freeman <markfreeman@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
11 dayscmd/compile/internal/noder: set dict.receivers in writerMark Freeman
Change-Id: I9846b8086bacbc69e438a8e39e3e26c46316fb08 Reviewed-on: https://go-review.googlesource.com/c/go/+/762022 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Mark Freeman <markfreeman@google.com>
11 dayscmd/compile/internal/noder: offset type parameter indicesMark Freeman
When a writer goes to encode use of a type parameter, it only records an index because the writer knows all of the type parameters in scope for that object. The writer orders the type parameteres as implicits first, then receivers, then explicits actually on the object. Note that receivers *are* explicit type arguments, they're just inherited from the type. For instance, given: func (T[P]) m[Q, R any]() This has: - 0 implicits - 1 receiver - 2 explicits With this ordering, P is at 0, Q is at 1, and R is at 2. In contrast, inspecting TypeParam.index for Q yields 0, and for R yields 1; hence the offset is needed. Change-Id: If12f342e109fbc5935ba278f574ac2809c889335 Reviewed-on: https://go-review.googlesource.com/c/go/+/762021 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
11 dayscmd/compile/internal/noder: decode generic methods and pipe receiversMark Freeman
Change-Id: I7a66fba400a743f4ef2fb989cd8e74e955e22b0f Reviewed-on: https://go-review.googlesource.com/c/go/+/762020 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Mark Freeman <markfreeman@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
12 dayshash/maphash: add Hasher interface and ComparableHasher implAlan Donovan
Hasher is the standard interface for expressing custom hash functions and equivalence relations for arbitrary data types. This allows them to be used in hash-based collection types such as a hash table (CL 612217) or a Bloom filter (CL 740440). The ComparableHasher type is an implementation of the Hasher interface for comparable values that is consistent with their usual equivalence relation (==). Fixes #70471 Change-Id: Iaa42eb7017d9c4dab487ad6c842c68a81fa7d28a Reviewed-on: https://go-review.googlesource.com/c/go/+/657296 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Hongxiang Jiang <hxjiang@golang.org> Reviewed-by: Junyang Shao <shaojunyang@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> TryBot-Bypass: Alan Donovan <adonovan@google.com>
12 daysruntime: add sysUnreserve to undo sysReserveMichael Pratt
This is inspired by CL 724560 by Bobby Powers, particularly their great commit message. When using address sanitizer with leak detection, sysReserve registers memory regions with LSAN via lsanregisterrootregion. However, several code paths release this memory using sysFreeOS without first unregistering from LSAN. This leaves LSAN with stale root region entries pointing to memory that has been unmapped and may be reallocated for other purposes. This bug was latent until glibc 2.42, which changed pthread stack guard pages from mprotect(PROT_NONE) to madvise(MADV_GUARD_INSTALL). The difference matters because LSAN filters root region scanning by intersecting registered regions with readable mappings from /proc/self/maps: - mprotect(PROT_NONE) splits the VMA, creating a separate entry with ---p permissions. LSAN's IsReadable() check excludes it from scanning. - MADV_GUARD_INSTALL operates at the page table level without modifying the VMA. The region still appears as rw-p in /proc/self/maps, so LSAN includes it in the scan and crashes with SIGSEGV when accessing the guard pages. Address this by adding sysUnreserve to undo sysReserve. sysUnreserve unregisters the region from LSAN and frees the mapping. With the addition of sysUnreserve, we have complete coverage of LSAN unregister in the mem.go abstract: sysFree unregisters Ready memory. sysUnreserve unregisters Reserved memory. And there is no way to free Prepared memory at all (it must transition to Ready or Reserved first). The implementation of lsanunregisterrootregion [1] finds the region by exact match of start and end address. It therefore does not support splitting a region, and we must extend this requirement to sysUnreserve and sysFree. I am not completely confident that we always pass the full region to sysFree, but LSAN aborts if it can't find the region, so we must not be blatantly violating this. sysReserveAligned does need to unreserve a subset of a region, so it cannot use sysUnreserve directly. Rather than breaking the mem.go abstract, move sysReserveAligned into mem.go, adding it to the abstraction. We should not have any calls to sysFreeOS outside of the mem.go abstraction. That is now true with this CL. Fixes #74476. [1] https://github.com/llvm/llvm-project/blob/3e3e362648fa062038b90ccc21f46a09d6902288/compiler-rt/lib/lsan/lsan_common.cpp#L1157 Change-Id: I8c46a62154b2f23456ffd5086a7b91156a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/762381 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
12 daysruntime: clarify sysFree documentationMichael Pratt
sysFree decrements mappedReady since CL 393402, meaning it can only be used on Ready memory, not any memory as stated. The example uses are not relevant as those cases would not necessarily be Ready memory. The no-op note is meant to be relevant to sysReserveAligned, but that doesn't use sysFree anyway. Change-Id: I3aeb0e703b0a57202a01317e0904cd966a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/762380 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 daysall: add export linknames for assembly symbols accessed from other packageCherry Mui
For Go symbols accessed from other package via linkname or assembly, we have an export linkname from the definition side. We currently don't always have the linkname directive for assembly functions, for which external accesses are allowed. We may want to tighten up the restriction. So add export linknames for the ones that are needed. Change-Id: If664634c81580edd49086d916024f23f86871092 Reviewed-on: https://go-review.googlesource.com/c/go/+/749981 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
12 dayscmd/asm, cmd/go: pass -std to assembler for standard library packagesCherry Mui
For the compiler, we already pass -std when compiling the standard library. Do the same for the assembler. So the assembler and the linker can tell which objects are in the standard library. Change-Id: I35d28a4c72d32c344eda37a3ff407ea525ee5cea Reviewed-on: https://go-review.googlesource.com/c/go/+/761200 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com>
12 daysruntime: use asmcgocall_no_g in libInitMichael Pratt
libInit runs before rt0_go, which is where TLS setup occurs. Thus the contents of the TLS may not be defined, so the g lookup in asmcgocall is not safe. Concretely, android-386 c-shared builds crash without this change because asmcgocall reads an invalid non-zero g from the TLS. Move libInit to a file limited to GOARCH that support c-archive or c-shared so that only those require asmcgocall_no_g. In addition, loong64 and s390x need asmcgocall_no_g implementations. Fixes #78480. Cq-Include-Trybots: luci.golang.try:gotip-linux-loong64,gotip-linux-s390x Change-Id: I175e6d020339af89c9b576535d79c1e76a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/761541 Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
12 daysruntime: mention linknamestd in HACKING.mdCherry Mui
Change-Id: Icc89533e4cfc737bfee8b0c7a72006bdc79746c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/762280 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
13 dayshash/maphash: revert purego implementationAlan Donovan
This CL reverts the purego implementation added in CL 468795 and folds the runtime variant back into the main file. Purego means "no assembly"; it does not mean "no linkname". Henceforth this package will once again call runtime.memhash unconditionally. This was not a clean revert as there were a number of CLs since. The motivation for this change is to avoid the maphash -> crypto/rand dependency; see discussion on CL 657297. Change-Id: I54ce223c5b484710ce303cdec20049146df3f8bc Reviewed-on: https://go-review.googlesource.com/c/go/+/761260 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
13 daysio/fs: fix godoc to refer to the 'fsys' argOlivier Mengué
Fix godoc for package io/fs functions where 'fs' is mentioned instead of the 'fsys' argument. This allows to more clearly distinguish references to the methods of that argument from functions of the io/fs package. Change-Id: I18674940e59dcf4501f46ee48f94fc58948df28c Reviewed-on: https://go-review.googlesource.com/c/go/+/755480 Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Damien Neil <dneil@google.com>
13 dayscmd/compile/internal/noder: add encoding for generic methodsMark Freeman
We have not yet added the decoding on the reader side. Change-Id: Ic7f8dc51b6b9a2c214b402b1314ee84c0085c16a Reviewed-on: https://go-review.googlesource.com/c/go/+/761983 Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Mark Freeman <markfreeman@google.com>