]> Cypherpunks repositories - gostls13.git/log
gostls13.git
2 months agostrconv: delete divmod1e9
Russ Cox [Wed, 29 Oct 2025 17:38:37 +0000 (13:38 -0400)]
strconv: delete divmod1e9

The compiler is just as good now, even on 32-bit systems.

Change-Id: Ifee72c0e84a68703c0721a7a9f4ca5aa637ad5e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/716464
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2 months agoruntime: delete timediv
Russ Cox [Wed, 29 Oct 2025 17:37:52 +0000 (13:37 -0400)]
runtime: delete timediv

Now that the compiler handles constant 64-bit divisions
without function calls on 32-bit systems, we no longer need
to maintain and test a bad custom implementation of 64-bit division.

Change-Id: If28807ad4f86507267ae69bc8f0b09ec18e98b66
Reviewed-on: https://go-review.googlesource.com/c/go/+/716463
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2 months agostrconv: remove arch-specific decision in formatBase10
Russ Cox [Wed, 29 Oct 2025 16:09:18 +0000 (12:09 -0400)]
strconv: remove arch-specific decision in formatBase10

There is only one architecture-specific code segment left in formatBase10.
Remove it for simplicity.

The only affected system is ppc64le, which does add 10-20% to the
runtime, but that's a ppc64le problem, not a strconv problem.
Changing the "uint32" to "uint" makes ppc64le not slower anymore,
meaning that somehow uint32 divide-by-constant is slower than
uint divide-by-constant on ppc64le. If this minor slowdown matters,
it should be addressed by improving the generated code for
ppc64le division, not by complicating strconv.
Even though some percentages look big, the geomean is +6% and
the worst case slowdown is only about 6ns/call.

benchmark \ host                    local       s7  s7:GOARCH=386  linux-amd64  linux-386  linux-ppc64le
                                  vs base  vs base        vs base      vs base    vs base        vs base
AppendFloat/Decimal                     ~        ~         -0.75%            ~          ~              ~
AppendFloat/Float                       ~        ~              ~            ~          ~              ~
AppendFloat/Exp                         ~        ~              ~            ~          ~              ~
AppendFloat/NegExp                      ~        ~              ~            ~          ~              ~
AppendFloat/LongExp                     ~        ~              ~            ~          ~              ~
AppendFloat/Big                         ~        ~              ~            ~          ~              ~
AppendFloat/BinaryExp                   ~        ~              ~            ~     -2.92%        +10.31%
AppendFloat/32Integer                   ~        ~              ~            ~          ~              ~
AppendFloat/32ExactFraction             ~        ~         -0.43%            ~          ~              ~
AppendFloat/32Point                     ~        ~              ~            ~          ~              ~
AppendFloat/32Exp                       ~        ~              ~            ~          ~              ~
AppendFloat/32NegExp                    ~        ~              ~            ~          ~              ~
AppendFloat/32Shortest                  ~        ~              ~            ~          ~              ~
AppendFloat/32Fixed8Hard                ~        ~         -1.12%            ~     -4.19%         +5.39%
AppendFloat/32Fixed9Hard                ~        ~              ~            ~          ~        +12.09%
AppendFloat/64Fixed1                    ~        ~              ~            ~     -0.78%              ~
AppendFloat/64Fixed2                    ~        ~         +0.53%            ~     -0.74%              ~
AppendFloat/64Fixed3                    ~        ~              ~            ~     -0.82%              ~
AppendFloat/64Fixed4                    ~        ~              ~            ~     -0.63%         +2.55%
AppendFloat/64Fixed12                   ~        ~         +0.63%       -1.83%     -1.01%         +5.68%
AppendFloat/64Fixed16                   ~        ~         +0.63%            ~     -1.33%              ~
AppendFloat/64Fixed12Hard               ~        ~         +1.31%            ~     -0.34%         +4.43%
AppendFloat/64Fixed17Hard               ~        ~              ~            ~     -1.66%         +4.63%
AppendFloat/64Fixed18Hard               ~        ~              ~            ~          ~              ~
AppendFloat/Slowpath64                  ~        ~              ~            ~          ~              ~
AppendFloat/SlowpathDenormal64          ~        ~              ~            ~          ~              ~
AppendInt                               ~        ~              ~            ~     -0.77%        +11.06%
AppendUint                              ~        ~         +0.42%            ~     -1.35%         +7.27%
AppendIntSmall                          ~        ~              ~            ~          ~              ~
AppendUintVarlen/digits=1               ~        ~              ~            ~          ~              ~
AppendUintVarlen/digits=2               ~        ~              ~            ~          ~         +4.80%
AppendUintVarlen/digits=3               ~        ~         -1.61%            ~     -4.49%        +10.04%
AppendUintVarlen/digits=4               ~        ~         -2.09%            ~     -2.88%         +9.99%
AppendUintVarlen/digits=5               ~        ~         -3.97%            ~     -8.92%         +7.19%
AppendUintVarlen/digits=6               ~        ~         -3.88%            ~     -7.84%         +5.25%
AppendUintVarlen/digits=7               ~        ~         -2.93%            ~    -11.08%              ~
AppendUintVarlen/digits=8               ~        ~         -2.88%            ~    -10.09%        +10.74%
AppendUintVarlen/digits=9               ~        ~         -3.69%            ~    -10.98%        +11.56%
AppendUintVarlen/digits=10              ~        ~         +0.90%            ~     -1.09%        +34.49%
AppendUintVarlen/digits=11              ~        ~         +2.11%            ~     +0.72%        +20.63%
AppendUintVarlen/digits=12              ~        ~         +1.21%            ~     -2.26%        +27.38%
AppendUintVarlen/digits=13              ~        ~         +2.07%            ~     -2.13%        +15.37%
AppendUintVarlen/digits=14              ~        ~              ~            ~     -3.27%        +19.32%
AppendUintVarlen/digits=15              ~        ~         +0.56%            ~     -3.18%         +8.55%
AppendUintVarlen/digits=16              ~        ~              ~            ~     -4.31%        +15.69%
AppendUintVarlen/digits=17              ~        ~              ~            ~     -4.50%         +7.61%
AppendUintVarlen/digits=18              ~        ~              ~            ~     -5.54%        +12.74%
AppendUintVarlen/digits=19              ~        ~         +0.87%            ~     +0.41%        +13.82%
AppendUintVarlen/digits=20              ~        ~         +1.40%            ~     +0.82%        +15.80%

host: local
                                  │ e8ffcf3095c │            3c5742b667a             │
                                  │   sec/op    │   sec/op     vs base               │
AppendFloat/Decimal-12              21.04n ± 2%   21.10n ± 0%       ~ (p=0.542 n=20)
AppendFloat/Float-12                32.77n ± 1%   32.56n ± 0%       ~ (p=0.213 n=20)
AppendFloat/Exp-12                  32.42n ± 1%   32.42n ± 0%       ~ (p=0.995 n=20)
AppendFloat/NegExp-12               31.78n ± 2%   31.79n ± 2%       ~ (p=0.542 n=20)
AppendFloat/LongExp-12              31.54n ± 1%   31.45n ± 1%       ~ (p=0.507 n=20)
AppendFloat/Big-12                  33.75n ± 1%   33.59n ± 1%       ~ (p=0.597 n=20)
AppendFloat/BinaryExp-12            19.16n ± 1%   19.14n ± 1%       ~ (p=0.635 n=20)
AppendFloat/32Integer-12            21.59n ± 1%   21.63n ± 1%       ~ (p=0.569 n=20)
AppendFloat/32ExactFraction-12      31.12n ± 1%   31.17n ± 1%       ~ (p=0.337 n=20)
AppendFloat/32Point-12              31.11n ± 1%   31.13n ± 0%       ~ (p=0.899 n=20)
AppendFloat/32Exp-12                32.27n ± 0%   32.24n ± 1%       ~ (p=0.794 n=20)
AppendFloat/32NegExp-12             30.56n ± 1%   30.64n ± 1%       ~ (p=0.899 n=20)
AppendFloat/32Shortest-12           26.88n ± 0%   27.11n ± 1%       ~ (p=0.001 n=20)
AppendFloat/32Fixed8Hard-12         20.63n ± 1%   20.63n ± 0%       ~ (p=0.596 n=20)
AppendFloat/32Fixed9Hard-12         22.69n ± 1%   22.81n ± 1%       ~ (p=0.763 n=20)
AppendFloat/64Fixed1-12             18.65n ± 0%   18.73n ± 1%       ~ (p=0.112 n=20)
AppendFloat/64Fixed2-12             18.91n ± 1%   18.88n ± 0%       ~ (p=0.569 n=20)
AppendFloat/64Fixed3-12             18.73n ± 1%   18.60n ± 0%       ~ (p=0.003 n=20)
AppendFloat/64Fixed4-12             17.87n ± 3%   17.84n ± 1%       ~ (p=0.569 n=20)
AppendFloat/64Fixed12-12            28.18n ± 0%   28.30n ± 0%       ~ (p=0.010 n=20)
AppendFloat/64Fixed16-12            24.38n ± 1%   24.34n ± 1%       ~ (p=0.683 n=20)
AppendFloat/64Fixed12Hard-12        21.61n ± 0%   21.63n ± 1%       ~ (p=0.542 n=20)
AppendFloat/64Fixed17Hard-12        27.02n ± 1%   26.94n ± 0%       ~ (p=0.077 n=20)
AppendFloat/64Fixed18Hard-12        2.179µ ± 1%   2.189µ ± 1%       ~ (p=0.337 n=20)
AppendFloat/Slowpath64-12           29.93n ± 1%   30.01n ± 1%       ~ (p=0.402 n=20)
AppendFloat/SlowpathDenormal64-12   28.29n ± 1%   28.35n ± 0%       ~ (p=0.952 n=20)
AppendInt-12                        400.7n ± 1%   401.8n ± 1%       ~ (p=0.176 n=20)
AppendUint-12                       95.87n ± 1%   96.06n ± 1%       ~ (p=0.208 n=20)
AppendIntSmall-12                   3.450n ± 0%   3.455n ± 1%       ~ (p=0.203 n=20)
AppendUintVarlen/digits=1-12        3.150n ± 1%   3.175n ± 1%       ~ (p=0.147 n=20)
AppendUintVarlen/digits=2-12        2.654n ± 0%   2.667n ± 1%       ~ (p=0.003 n=20)
AppendUintVarlen/digits=3-12        5.044n ± 0%   5.069n ± 0%       ~ (p=0.026 n=20)
AppendUintVarlen/digits=4-12        5.046n ± 0%   5.047n ± 1%       ~ (p=0.408 n=20)
AppendUintVarlen/digits=5-12        5.851n ± 0%   5.860n ± 1%       ~ (p=0.132 n=20)
AppendUintVarlen/digits=6-12        6.118n ± 0%   6.120n ± 0%       ~ (p=0.888 n=20)
AppendUintVarlen/digits=7-12        7.333n ± 0%   7.334n ± 0%       ~ (p=0.588 n=20)
AppendUintVarlen/digits=8-12        7.312n ± 1%   7.322n ± 0%       ~ (p=0.805 n=20)
AppendUintVarlen/digits=9-12        7.832n ± 1%   7.838n ± 1%       ~ (p=0.465 n=20)
AppendUintVarlen/digits=10-12       8.606n ± 1%   8.602n ± 1%       ~ (p=0.974 n=20)
AppendUintVarlen/digits=11-12       8.908n ± 0%   8.899n ± 1%       ~ (p=0.931 n=20)
AppendUintVarlen/digits=12-12       9.178n ± 0%   9.118n ± 0%       ~ (p=0.007 n=20)
AppendUintVarlen/digits=13-12       9.398n ± 1%   9.405n ± 1%       ~ (p=0.888 n=20)
AppendUintVarlen/digits=14-12       10.24n ± 0%   10.22n ± 0%       ~ (p=0.154 n=20)
AppendUintVarlen/digits=15-12       10.50n ± 0%   10.48n ± 0%       ~ (p=0.692 n=20)
AppendUintVarlen/digits=16-12       11.66n ± 0%   11.75n ± 2%       ~ (p=0.087 n=20)
AppendUintVarlen/digits=17-12       11.65n ± 0%   11.72n ± 1%       ~ (p=0.079 n=20)
AppendUintVarlen/digits=18-12       12.38n ± 1%   12.42n ± 2%       ~ (p=0.035 n=20)
AppendUintVarlen/digits=19-12       13.59n ± 1%   13.60n ± 0%       ~ (p=0.673 n=20)
AppendUintVarlen/digits=20-12       13.85n ± 1%   13.84n ± 0%       ~ (p=0.634 n=20)
geomean                             17.99n        18.01n       +0.09%

host: s7
                                  │ e8ffcf3095c │            3c5742b667a             │
                                  │   sec/op    │   sec/op     vs base               │
AppendFloat/Decimal-32              22.24n ± 0%   22.20n ± 0%       ~ (p=0.143 n=20)
AppendFloat/Float-32                34.70n ± 0%   34.59n ± 0%       ~ (p=0.057 n=20)
AppendFloat/Exp-32                  34.85n ± 0%   34.77n ± 0%       ~ (p=0.051 n=20)
AppendFloat/NegExp-32               35.19n ± 0%   35.17n ± 0%       ~ (p=0.533 n=20)
AppendFloat/LongExp-32              36.80n ± 0%   36.78n ± 0%       ~ (p=0.941 n=20)
AppendFloat/Big-32                  38.63n ± 0%   38.71n ± 0%       ~ (p=0.143 n=20)
AppendFloat/BinaryExp-32            17.39n ± 0%   17.36n ± 0%       ~ (p=0.049 n=20)
AppendFloat/32Integer-32            22.29n ± 0%   22.23n ± 0%       ~ (p=0.068 n=20)
AppendFloat/32ExactFraction-32      33.52n ± 0%   33.44n ± 0%       ~ (p=0.058 n=20)
AppendFloat/32Point-32              32.96n ± 0%   32.93n ± 0%       ~ (p=0.256 n=20)
AppendFloat/32Exp-32                35.31n ± 0%   35.24n ± 0%       ~ (p=0.014 n=20)
AppendFloat/32NegExp-32             33.56n ± 0%   33.50n ± 0%       ~ (p=0.032 n=20)
AppendFloat/32Shortest-32           30.03n ± 0%   29.97n ± 0%       ~ (p=0.351 n=20)
AppendFloat/32Fixed8Hard-32         22.93n ± 0%   22.94n ± 0%       ~ (p=0.920 n=20)
AppendFloat/32Fixed9Hard-32         26.27n ± 0%   26.22n ± 0%       ~ (p=0.693 n=20)
AppendFloat/64Fixed1-32             21.15n ± 0%   21.09n ± 0%       ~ (p=0.006 n=20)
AppendFloat/64Fixed2-32             20.75n ± 0%   20.75n ± 0%       ~ (p=0.898 n=20)
AppendFloat/64Fixed3-32             21.29n ± 0%   21.28n ± 0%       ~ (p=0.524 n=20)
AppendFloat/64Fixed4-32             20.59n ± 0%   20.63n ± 0%       ~ (p=0.350 n=20)
AppendFloat/64Fixed12-32            32.53n ± 0%   32.51n ± 0%       ~ (p=0.804 n=20)
AppendFloat/64Fixed16-32            28.43n ± 0%   28.34n ± 0%       ~ (p=0.060 n=20)
AppendFloat/64Fixed12Hard-32        27.27n ± 0%   27.22n ± 0%       ~ (p=0.056 n=20)
AppendFloat/64Fixed17Hard-32        30.76n ± 0%   30.70n ± 0%       ~ (p=0.304 n=20)
AppendFloat/64Fixed18Hard-32        1.812µ ± 0%   1.806µ ± 1%       ~ (p=0.216 n=20)
AppendFloat/Slowpath64-32           35.48n ± 0%   35.43n ± 0%       ~ (p=0.129 n=20)
AppendFloat/SlowpathDenormal64-32   35.62n ± 0%   35.60n ± 0%       ~ (p=0.273 n=20)
AppendInt-32                        387.5n ± 0%   387.9n ± 0%       ~ (p=0.417 n=20)
AppendUint-32                       104.9n ± 0%   104.9n ± 0%       ~ (p=0.641 n=20)
AppendIntSmall-32                   3.329n ± 5%   3.489n ± 5%       ~ (p=0.723 n=20)
AppendUintVarlen/digits=1-32        2.396n ± 7%   2.398n ± 8%       ~ (p=0.409 n=20)
AppendUintVarlen/digits=2-32        2.399n ± 7%   2.315n ± 4%       ~ (p=0.386 n=20)
AppendUintVarlen/digits=3-32        5.516n ± 0%   5.506n ± 0%       ~ (p=0.026 n=20)
AppendUintVarlen/digits=4-32        5.515n ± 0%   5.510n ± 0%       ~ (p=0.291 n=20)
AppendUintVarlen/digits=5-32        5.748n ± 1%   5.731n ± 0%       ~ (p=0.014 n=20)
AppendUintVarlen/digits=6-32        5.873n ± 0%   5.853n ± 0%       ~ (p=0.011 n=20)
AppendUintVarlen/digits=7-32        6.460n ± 0%   6.444n ± 0%       ~ (p=0.041 n=20)
AppendUintVarlen/digits=8-32        6.457n ± 0%   6.446n ± 0%       ~ (p=0.047 n=20)
AppendUintVarlen/digits=9-32        7.377n ± 0%   7.373n ± 0%       ~ (p=0.569 n=20)
AppendUintVarlen/digits=10-32       8.496n ± 0%   8.492n ± 0%       ~ (p=0.525 n=20)
AppendUintVarlen/digits=11-32       8.674n ± 0%   8.653n ± 0%       ~ (p=0.060 n=20)
AppendUintVarlen/digits=12-32       9.416n ± 0%   9.386n ± 0%       ~ (p=0.035 n=20)
AppendUintVarlen/digits=13-32       9.621n ± 0%   9.594n ± 0%       ~ (p=0.069 n=20)
AppendUintVarlen/digits=14-32       10.34n ± 0%   10.35n ± 0%       ~ (p=0.332 n=20)
AppendUintVarlen/digits=15-32       10.48n ± 0%   10.52n ± 0%       ~ (p=0.196 n=20)
AppendUintVarlen/digits=16-32       11.27n ± 0%   11.27n ± 0%       ~ (p=0.445 n=20)
AppendUintVarlen/digits=17-32       11.50n ± 0%   11.48n ± 0%       ~ (p=0.283 n=20)
AppendUintVarlen/digits=18-32       12.15n ± 0%   12.18n ± 0%       ~ (p=0.414 n=20)
AppendUintVarlen/digits=19-32       13.42n ± 0%   13.42n ± 0%       ~ (p=0.782 n=20)
AppendUintVarlen/digits=20-32       13.70n ± 0%   13.71n ± 0%       ~ (p=0.540 n=20)
geomean                             18.71n        18.70n       -0.08%

host: s7:GOARCH=386
                                  │ e8ffcf3095c  │            3c5742b667a             │
                                  │    sec/op    │   sec/op     vs base               │
AppendFloat/Decimal-32               42.03n ± 0%   41.71n ± 1%  -0.75% (p=0.000 n=20)
AppendFloat/Float-32                 69.99n ± 0%   69.85n ± 0%       ~ (p=0.062 n=20)
AppendFloat/Exp-32                   73.07n ± 0%   73.13n ± 0%       ~ (p=0.240 n=20)
AppendFloat/NegExp-32                72.75n ± 0%   72.72n ± 0%       ~ (p=0.298 n=20)
AppendFloat/LongExp-32               74.20n ± 0%   74.13n ± 0%       ~ (p=0.952 n=20)
AppendFloat/Big-32                   82.88n ± 0%   82.91n ± 0%       ~ (p=0.909 n=20)
AppendFloat/BinaryExp-32             32.12n ± 0%   32.23n ± 0%       ~ (p=0.014 n=20)
AppendFloat/32Integer-32             41.18n ± 0%   41.15n ± 0%       ~ (p=0.212 n=20)
AppendFloat/32ExactFraction-32       62.65n ± 0%   62.38n ± 0%  -0.43% (p=0.000 n=20)
AppendFloat/32Point-32               59.98n ± 0%   59.82n ± 0%       ~ (p=0.109 n=20)
AppendFloat/32Exp-32                 72.62n ± 0%   72.69n ± 0%       ~ (p=0.417 n=20)
AppendFloat/32NegExp-32              62.36n ± 0%   62.49n ± 0%       ~ (p=0.578 n=20)
AppendFloat/32Shortest-32            58.03n ± 0%   57.95n ± 0%       ~ (p=0.615 n=20)
AppendFloat/32Fixed8Hard-32          36.75n ± 0%   36.34n ± 0%  -1.12% (p=0.000 n=20)
AppendFloat/32Fixed9Hard-32          53.83n ± 0%   53.96n ± 0%       ~ (p=0.126 n=20)
AppendFloat/64Fixed1-32              48.52n ± 0%   48.72n ± 0%       ~ (p=0.075 n=20)
AppendFloat/64Fixed2-32              46.50n ± 0%   46.74n ± 0%  +0.53% (p=0.000 n=20)
AppendFloat/64Fixed3-32              46.43n ± 0%   46.24n ± 1%       ~ (p=0.147 n=20)
AppendFloat/64Fixed4-32              42.52n ± 0%   42.69n ± 0%       ~ (p=0.038 n=20)
AppendFloat/64Fixed12-32             54.51n ± 1%   54.85n ± 0%  +0.63% (p=0.000 n=20)
AppendFloat/64Fixed16-32             52.61n ± 0%   52.94n ± 0%  +0.63% (p=0.000 n=20)
AppendFloat/64Fixed12Hard-32         50.78n ± 0%   51.45n ± 0%  +1.31% (p=0.000 n=20)
AppendFloat/64Fixed17Hard-32         59.91n ± 0%   59.91n ± 0%       ~ (p=0.713 n=20)
AppendFloat/64Fixed18Hard-32         3.984µ ± 1%   4.000µ ± 1%       ~ (p=0.569 n=20)
AppendFloat/Slowpath64-32            73.42n ± 0%   73.37n ± 0%       ~ (p=0.425 n=20)
AppendFloat/SlowpathDenormal64-32    73.27n ± 0%   73.36n ± 0%       ~ (p=0.298 n=20)
AppendInt-32                         1.036µ ± 1%   1.041µ ± 1%       ~ (p=0.024 n=20)
AppendUint-32                        261.1n ± 0%   262.1n ± 1%  +0.42% (p=0.000 n=20)
AppendIntSmall-32                    5.515n ± 0%   5.506n ± 0%       ~ (p=0.394 n=20)
AppendUintVarlen/digits=1-32         3.679n ± 0%   3.685n ± 0%       ~ (p=0.815 n=20)
AppendUintVarlen/digits=2-32         3.683n ± 0%   3.687n ± 0%       ~ (p=0.899 n=20)
AppendUintVarlen/digits=3-32         8.988n ± 2%   8.843n ± 1%  -1.61% (p=0.000 n=20)
AppendUintVarlen/digits=4-32         9.300n ± 1%   9.106n ± 1%  -2.09% (p=0.000 n=20)
AppendUintVarlen/digits=5-32        10.235n ± 1%   9.829n ± 1%  -3.97% (p=0.000 n=20)
AppendUintVarlen/digits=6-32         10.44n ± 1%   10.03n ± 0%  -3.88% (p=0.000 n=20)
AppendUintVarlen/digits=7-32         11.27n ± 1%   10.94n ± 1%  -2.93% (p=0.000 n=20)
AppendUintVarlen/digits=8-32         11.46n ± 1%   11.13n ± 1%  -2.88% (p=0.000 n=20)
AppendUintVarlen/digits=9-32         12.74n ± 0%   12.27n ± 1%  -3.69% (p=0.000 n=20)
AppendUintVarlen/digits=10-32        15.57n ± 0%   15.71n ± 1%  +0.90% (p=0.000 n=20)
AppendUintVarlen/digits=11-32        15.65n ± 1%   15.98n ± 0%  +2.11% (p=0.000 n=20)
AppendUintVarlen/digits=12-32        16.54n ± 0%   16.73n ± 0%  +1.21% (p=0.000 n=20)
AppendUintVarlen/digits=13-32        16.69n ± 0%   17.04n ± 0%  +2.07% (p=0.000 n=20)
AppendUintVarlen/digits=14-32        17.52n ± 1%   17.62n ± 0%       ~ (p=0.005 n=20)
AppendUintVarlen/digits=15-32        17.76n ± 0%   17.86n ± 0%  +0.56% (p=0.001 n=20)
AppendUintVarlen/digits=16-32        18.68n ± 1%   18.59n ± 0%       ~ (p=0.006 n=20)
AppendUintVarlen/digits=17-32        18.78n ± 1%   18.74n ± 0%       ~ (p=0.040 n=20)
AppendUintVarlen/digits=18-32        19.63n ± 1%   19.54n ± 0%       ~ (p=0.202 n=20)
AppendUintVarlen/digits=19-32        24.02n ± 1%   24.23n ± 1%  +0.87% (p=0.000 n=20)
AppendUintVarlen/digits=20-32        23.87n ± 1%   24.20n ± 1%  +1.40% (p=0.000 n=20)
geomean                              35.08n        35.00n       -0.21%

host: linux-amd64
                                  │ e8ffcf3095c │            3c5742b667a             │
                                  │   sec/op    │   sec/op     vs base               │
AppendFloat/Decimal-16              62.16n ± 1%   61.81n ± 0%       ~ (p=0.060 n=20)
AppendFloat/Float-16                91.66n ± 1%   91.22n ± 1%       ~ (p=0.606 n=20)
AppendFloat/Exp-16                  95.42n ± 2%   95.22n ± 1%       ~ (p=0.417 n=20)
AppendFloat/NegExp-16               96.88n ± 1%   95.89n ± 1%       ~ (p=0.185 n=20)
AppendFloat/LongExp-16              102.0n ± 1%   101.6n ± 1%       ~ (p=0.794 n=20)
AppendFloat/Big-16                  110.8n ± 1%   110.8n ± 1%       ~ (p=0.984 n=20)
AppendFloat/BinaryExp-16            46.33n ± 1%   46.19n ± 1%       ~ (p=0.723 n=20)
AppendFloat/32Integer-16            62.62n ± 2%   61.88n ± 1%       ~ (p=0.286 n=20)
AppendFloat/32ExactFraction-16      89.09n ± 3%   88.25n ± 2%       ~ (p=0.101 n=20)
AppendFloat/32Point-16              86.17n ± 1%   86.90n ± 1%       ~ (p=0.251 n=20)
AppendFloat/32Exp-16                101.7n ± 1%   101.2n ± 1%       ~ (p=0.379 n=20)
AppendFloat/32NegExp-16             92.17n ± 1%   92.81n ± 1%       ~ (p=0.165 n=20)
AppendFloat/32Shortest-16           82.38n ± 1%   82.89n ± 1%       ~ (p=0.185 n=20)
AppendFloat/32Fixed8Hard-16         60.32n ± 1%   60.41n ± 1%       ~ (p=0.337 n=20)
AppendFloat/32Fixed9Hard-16         69.58n ± 1%   69.22n ± 1%       ~ (p=0.794 n=20)
AppendFloat/64Fixed1-16             57.56n ± 1%   57.65n ± 1%       ~ (p=0.597 n=20)
AppendFloat/64Fixed2-16             55.84n ± 1%   55.54n ± 1%       ~ (p=0.059 n=20)
AppendFloat/64Fixed3-16             57.12n ± 2%   56.55n ± 1%       ~ (p=0.449 n=20)
AppendFloat/64Fixed4-16             55.38n ± 2%   54.50n ± 2%       ~ (p=0.010 n=20)
AppendFloat/64Fixed12-16            88.28n ± 1%   86.67n ± 1%  -1.83% (p=0.000 n=20)
AppendFloat/64Fixed16-16            73.41n ± 1%   73.56n ± 2%       ~ (p=0.794 n=20)
AppendFloat/64Fixed12Hard-16        72.08n ± 1%   71.71n ± 1%       ~ (p=0.116 n=20)
AppendFloat/64Fixed17Hard-16        79.78n ± 1%   79.78n ± 1%       ~ (p=0.224 n=20)
AppendFloat/64Fixed18Hard-16        4.720µ ± 1%   4.746µ ± 1%       ~ (p=0.877 n=20)
AppendFloat/Slowpath64-16           98.71n ± 1%   98.79n ± 1%       ~ (p=0.678 n=20)
AppendFloat/SlowpathDenormal64-16   97.58n ± 2%   98.16n ± 2%       ~ (p=0.862 n=20)
AppendInt-16                        1.185µ ± 1%   1.194µ ± 1%       ~ (p=0.457 n=20)
AppendUint-16                       292.6n ± 1%   293.9n ± 1%       ~ (p=0.351 n=20)
AppendIntSmall-16                   7.197n ± 1%   7.203n ± 1%       ~ (p=0.952 n=20)
AppendUintVarlen/digits=1-16        5.905n ± 1%   5.897n ± 2%       ~ (p=0.474 n=20)
AppendUintVarlen/digits=2-16        5.770n ± 1%   5.733n ± 1%       ~ (p=0.180 n=20)
AppendUintVarlen/digits=3-16        14.00n ± 2%   14.00n ± 1%       ~ (p=0.909 n=20)
AppendUintVarlen/digits=4-16        13.99n ± 1%   14.03n ± 1%       ~ (p=0.578 n=20)
AppendUintVarlen/digits=5-16        15.88n ± 2%   15.83n ± 1%       ~ (p=0.542 n=20)
AppendUintVarlen/digits=6-16        16.25n ± 1%   16.30n ± 1%       ~ (p=0.899 n=20)
AppendUintVarlen/digits=7-16        17.66n ± 1%   17.70n ± 1%       ~ (p=0.440 n=20)
AppendUintVarlen/digits=8-16        18.54n ± 1%   18.58n ± 2%       ~ (p=0.262 n=20)
AppendUintVarlen/digits=9-16        20.25n ± 2%   20.43n ± 1%       ~ (p=0.007 n=20)
AppendUintVarlen/digits=10-16       23.88n ± 1%   24.00n ± 1%       ~ (p=0.473 n=20)
AppendUintVarlen/digits=11-16       24.42n ± 1%   24.57n ± 2%       ~ (p=0.743 n=20)
AppendUintVarlen/digits=12-16       25.54n ± 2%   25.88n ± 1%       ~ (p=0.499 n=20)
AppendUintVarlen/digits=13-16       26.55n ± 1%   26.60n ± 1%       ~ (p=0.774 n=20)
AppendUintVarlen/digits=14-16       28.18n ± 1%   28.16n ± 1%       ~ (p=0.606 n=20)
AppendUintVarlen/digits=15-16       28.66n ± 1%   28.85n ± 0%       ~ (p=0.031 n=20)
AppendUintVarlen/digits=16-16       29.84n ± 1%   30.00n ± 1%       ~ (p=0.151 n=20)
AppendUintVarlen/digits=17-16       30.54n ± 1%   30.60n ± 1%       ~ (p=0.952 n=20)
AppendUintVarlen/digits=18-16       32.01n ± 1%   32.26n ± 2%       ~ (p=0.239 n=20)
AppendUintVarlen/digits=19-16       35.50n ± 1%   35.56n ± 1%       ~ (p=0.256 n=20)
AppendUintVarlen/digits=20-16       35.94n ± 1%   35.96n ± 1%       ~ (p=0.867 n=20)
geomean                             50.35n        50.35n       -0.01%

host: linux-386
                                  │ e8ffcf3095c │             3c5742b667a             │
                                  │   sec/op    │   sec/op     vs base                │
AppendFloat/Decimal-16              122.9n ± 0%   122.9n ± 0%        ~ (p=0.351 n=20)
AppendFloat/Float-16                226.7n ± 0%   227.1n ± 0%        ~ (p=0.003 n=20)
AppendFloat/Exp-16                  238.3n ± 0%   238.3n ± 0%        ~ (p=0.301 n=20)
AppendFloat/NegExp-16               239.2n ± 0%   239.5n ± 0%        ~ (p=0.015 n=20)
AppendFloat/LongExp-16              237.6n ± 0%   237.8n ± 0%        ~ (p=0.357 n=20)
AppendFloat/Big-16                  275.6n ± 0%   275.7n ± 0%        ~ (p=0.576 n=20)
AppendFloat/BinaryExp-16            90.33n ± 0%   87.69n ± 0%   -2.92% (p=0.000 n=20)
AppendFloat/32Integer-16            121.7n ± 0%   121.8n ± 0%        ~ (p=0.340 n=20)
AppendFloat/32ExactFraction-16      209.4n ± 0%   209.4n ± 0%        ~ (p=0.566 n=20)
AppendFloat/32Point-16              196.1n ± 0%   196.5n ± 0%        ~ (p=0.036 n=20)
AppendFloat/32Exp-16                246.3n ± 0%   246.4n ± 0%        ~ (p=0.407 n=20)
AppendFloat/32NegExp-16             205.4n ± 0%   205.4n ± 0%        ~ (p=0.221 n=20)
AppendFloat/32Shortest-16           187.8n ± 0%   187.8n ± 0%        ~ (p=0.671 n=20)
AppendFloat/32Fixed8Hard-16         112.3n ± 0%   107.6n ± 0%   -4.19% (p=0.000 n=20)
AppendFloat/32Fixed9Hard-16         182.3n ± 0%   182.1n ± 0%        ~ (p=0.098 n=20)
AppendFloat/64Fixed1-16             167.0n ± 0%   165.7n ± 0%   -0.78% (p=0.000 n=20)
AppendFloat/64Fixed2-16             161.9n ± 0%   160.7n ± 0%   -0.74% (p=0.000 n=20)
AppendFloat/64Fixed3-16             157.7n ± 0%   156.4n ± 0%   -0.82% (p=0.000 n=20)
AppendFloat/64Fixed4-16             134.4n ± 0%   133.5n ± 0%   -0.63% (p=0.000 n=20)
AppendFloat/64Fixed12-16            178.2n ± 0%   176.4n ± 0%   -1.01% (p=0.000 n=20)
AppendFloat/64Fixed16-16            168.7n ± 0%   166.4n ± 0%   -1.33% (p=0.000 n=20)
AppendFloat/64Fixed12Hard-16        162.8n ± 0%   162.2n ± 0%   -0.34% (p=0.000 n=20)
AppendFloat/64Fixed17Hard-16        201.9n ± 0%   198.6n ± 0%   -1.66% (p=0.000 n=20)
AppendFloat/64Fixed18Hard-16        14.45µ ± 0%   14.46µ ± 0%        ~ (p=0.189 n=20)
AppendFloat/Slowpath64-16           232.8n ± 0%   232.8n ± 0%        ~ (p=0.995 n=20)
AppendFloat/SlowpathDenormal64-16   229.0n ± 0%   228.9n ± 0%        ~ (p=0.605 n=20)
AppendInt-16                        3.123µ ± 0%   3.099µ ± 0%   -0.77% (p=0.000 n=20)
AppendUint-16                       832.0n ± 0%   820.8n ± 0%   -1.35% (p=0.000 n=20)
AppendIntSmall-16                   13.27n ± 0%   13.28n ± 0%        ~ (p=0.127 n=20)
AppendUintVarlen/digits=1-16        10.19n ± 0%   10.20n ± 0%        ~ (p=0.414 n=20)
AppendUintVarlen/digits=2-16        10.19n ± 0%   10.19n ± 0%        ~ (p=0.700 n=20)
AppendUintVarlen/digits=3-16        21.47n ± 0%   20.51n ± 0%   -4.49% (p=0.000 n=20)
AppendUintVarlen/digits=4-16        21.68n ± 0%   21.05n ± 0%   -2.88% (p=0.000 n=20)
AppendUintVarlen/digits=5-16        26.28n ± 0%   23.94n ± 0%   -8.92% (p=0.000 n=20)
AppendUintVarlen/digits=6-16        26.77n ± 0%   24.67n ± 0%   -7.84% (p=0.000 n=20)
AppendUintVarlen/digits=7-16        30.65n ± 0%   27.25n ± 0%  -11.08% (p=0.000 n=20)
AppendUintVarlen/digits=8-16        31.27n ± 0%   28.11n ± 0%  -10.09% (p=0.000 n=20)
AppendUintVarlen/digits=9-16        36.55n ± 0%   32.53n ± 0%  -10.98% (p=0.000 n=20)
AppendUintVarlen/digits=10-16       42.53n ± 0%   42.06n ± 0%   -1.09% (p=0.000 n=20)
AppendUintVarlen/digits=11-16       42.21n ± 0%   42.51n ± 0%   +0.72% (p=0.000 n=20)
AppendUintVarlen/digits=12-16       45.44n ± 0%   44.41n ± 0%   -2.26% (p=0.000 n=20)
AppendUintVarlen/digits=13-16       46.04n ± 0%   45.06n ± 0%   -2.13% (p=0.000 n=20)
AppendUintVarlen/digits=14-16       49.35n ± 0%   47.73n ± 0%   -3.27% (p=0.000 n=20)
AppendUintVarlen/digits=15-16       50.04n ± 0%   48.45n ± 0%   -3.18% (p=0.000 n=20)
AppendUintVarlen/digits=16-16       53.51n ± 0%   51.21n ± 0%   -4.31% (p=0.000 n=20)
AppendUintVarlen/digits=17-16       53.60n ± 0%   51.19n ± 0%   -4.50% (p=0.000 n=20)
AppendUintVarlen/digits=18-16       57.21n ± 0%   54.03n ± 0%   -5.54% (p=0.000 n=20)
AppendUintVarlen/digits=19-16       64.41n ± 0%   64.68n ± 0%   +0.41% (p=0.000 n=20)
AppendUintVarlen/digits=20-16       64.51n ± 0%   65.04n ± 0%   +0.82% (p=0.000 n=20)
geomean                             104.9n        102.8n        -2.02%

host: linux-ppc64le
                                 │ e8ffcf3095c │             3c5742b667a             │
                                 │   sec/op    │   sec/op     vs base                │
AppendFloat/Decimal-5              53.78n ± 1%   53.62n ± 1%        ~ (p=0.588 n=20)
AppendFloat/Float-5                76.29n ± 2%   75.77n ± 2%        ~ (p=0.402 n=20)
AppendFloat/Exp-5                  83.73n ± 0%   82.25n ± 2%        ~ (p=0.009 n=20)
AppendFloat/NegExp-5               84.22n ± 1%   83.15n ± 1%        ~ (p=0.031 n=20)
AppendFloat/LongExp-5              88.66n ± 1%   88.34n ± 1%        ~ (p=0.213 n=20)
AppendFloat/Big-5                  93.25n ± 0%   92.73n ± 1%        ~ (p=0.007 n=20)
AppendFloat/BinaryExp-5            40.69n ± 0%   44.88n ± 1%  +10.31% (p=0.000 n=20)
AppendFloat/32Integer-5            54.17n ± 0%   54.39n ± 1%        ~ (p=0.245 n=20)
AppendFloat/32ExactFraction-5      79.89n ± 1%   79.41n ± 1%        ~ (p=0.457 n=20)
AppendFloat/32Point-5              74.81n ± 1%   74.89n ± 0%        ~ (p=0.625 n=20)
AppendFloat/32Exp-5                85.59n ± 1%   85.42n ± 1%        ~ (p=0.331 n=20)
AppendFloat/32NegExp-5             82.74n ± 1%   82.22n ± 1%        ~ (p=0.025 n=20)
AppendFloat/32Shortest-5           69.72n ± 0%   69.79n ± 1%        ~ (p=0.625 n=20)
AppendFloat/32Fixed8Hard-5         54.60n ± 0%   57.54n ± 0%   +5.39% (p=0.000 n=20)
AppendFloat/32Fixed9Hard-5         58.49n ± 1%   65.56n ± 0%  +12.09% (p=0.000 n=20)
AppendFloat/64Fixed1-5             47.07n ± 1%   47.81n ± 1%        ~ (p=0.002 n=20)
AppendFloat/64Fixed2-5             47.88n ± 1%   48.52n ± 1%        ~ (p=0.007 n=20)
AppendFloat/64Fixed3-5             47.47n ± 1%   48.32n ± 1%        ~ (p=0.007 n=20)
AppendFloat/64Fixed4-5             45.12n ± 1%   46.26n ± 1%   +2.55% (p=0.000 n=20)
AppendFloat/64Fixed12-5            79.27n ± 0%   83.78n ± 1%   +5.68% (p=0.000 n=20)
AppendFloat/64Fixed16-5            69.28n ± 1%   70.69n ± 0%        ~ (p=0.001 n=20)
AppendFloat/64Fixed12Hard-5        65.42n ± 0%   68.31n ± 1%   +4.43% (p=0.000 n=20)
AppendFloat/64Fixed17Hard-5        73.89n ± 0%   77.30n ± 1%   +4.63% (p=0.000 n=20)
AppendFloat/64Fixed18Hard-5        5.163µ ± 1%   5.169µ ± 0%        ~ (p=0.733 n=20)
AppendFloat/Slowpath64-5           86.31n ± 1%   86.70n ± 2%        ~ (p=0.578 n=20)
AppendFloat/SlowpathDenormal64-5   83.10n ± 1%   82.97n ± 1%        ~ (p=0.218 n=20)
AppendInt-5                        1.013µ ± 1%   1.125µ ± 0%  +11.06% (p=0.000 n=20)
AppendUint-5                       268.2n ± 0%   287.7n ± 1%   +7.27% (p=0.000 n=20)
AppendIntSmall-5                   6.644n ± 3%   6.936n ± 2%        ~ (p=0.023 n=20)
AppendUintVarlen/digits=1-5        5.556n ± 4%   5.381n ± 3%        ~ (p=0.108 n=20)
AppendUintVarlen/digits=2-5        5.165n ± 1%   5.413n ± 1%   +4.80% (p=0.000 n=20)
AppendUintVarlen/digits=3-5        10.26n ± 1%   11.29n ± 2%  +10.04% (p=0.000 n=20)
AppendUintVarlen/digits=4-5        10.11n ± 1%   11.12n ± 1%   +9.99% (p=0.000 n=20)
AppendUintVarlen/digits=5-5        12.37n ± 2%   13.26n ± 1%   +7.19% (p=0.000 n=20)
AppendUintVarlen/digits=6-5        12.85n ± 3%   13.52n ± 1%   +5.25% (p=0.000 n=20)
AppendUintVarlen/digits=7-5        15.46n ± 7%   16.52n ± 1%        ~ (p=0.005 n=20)
AppendUintVarlen/digits=8-5        14.99n ± 1%   16.60n ± 1%  +10.74% (p=0.000 n=20)
AppendUintVarlen/digits=9-5        18.13n ± 1%   20.23n ± 1%  +11.56% (p=0.000 n=20)
AppendUintVarlen/digits=10-5       19.05n ± 3%   25.62n ± 1%  +34.49% (p=0.000 n=20)
AppendUintVarlen/digits=11-5       21.64n ± 2%   26.11n ± 1%  +20.63% (p=0.000 n=20)
AppendUintVarlen/digits=12-5       21.91n ± 1%   27.91n ± 0%  +27.38% (p=0.000 n=20)
AppendUintVarlen/digits=13-5       24.60n ± 1%   28.38n ± 1%  +15.37% (p=0.000 n=20)
AppendUintVarlen/digits=14-5       25.80n ± 1%   30.79n ± 0%  +19.32% (p=0.000 n=20)
AppendUintVarlen/digits=15-5       28.90n ± 1%   31.38n ± 3%   +8.55% (p=0.000 n=20)
AppendUintVarlen/digits=16-5       28.13n ± 2%   32.54n ± 0%  +15.69% (p=0.000 n=20)
AppendUintVarlen/digits=17-5       30.82n ± 1%   33.16n ± 1%   +7.61% (p=0.000 n=20)
AppendUintVarlen/digits=18-5       32.03n ± 0%   36.12n ± 1%  +12.74% (p=0.000 n=20)
AppendUintVarlen/digits=19-5       35.99n ± 3%   40.97n ± 1%  +13.82% (p=0.000 n=20)
AppendUintVarlen/digits=20-5       35.15n ± 1%   40.71n ± 0%  +15.80% (p=0.000 n=20)
geomean                            44.34n        47.15n        +6.34%

Change-Id: Ia6a3971a76f39d6187b10d6944071ee1c1b47316
Reviewed-on: https://go-review.googlesource.com/c/go/+/716462
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

2 months agoreflect: correct internal docs for uncommonType
Ian Lance Taylor [Sat, 25 Oct 2025 04:41:52 +0000 (21:41 -0700)]
reflect: correct internal docs for uncommonType

This updates the doc to reflect the change in CL 19790 from 2016.

Change-Id: I1017babf6660aa3b4929755e2eccbe3168b7860c
Reviewed-on: https://go-review.googlesource.com/c/go/+/714880
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

2 months agocmd/compile/internal/ssa: model right shift more precisely
Russ Cox [Wed, 29 Oct 2025 11:27:38 +0000 (07:27 -0400)]
cmd/compile/internal/ssa: model right shift more precisely

Prove currently checks for 0 sign bit extraction (x>>63) at the
end of the pass, but it is more general and more useful
(and not really more work) to model right shift during
value range tracking. This handles sign bit extraction (both 0 and -1)
but also makes the value ranges available for proving bounds checks.

'go build -a -gcflags=-d=ssa/prove/debug=1 std'
finds 105 new things to prove.
https://gist.github.com/rsc/8ac41176e53ed9c2f1a664fc668e8336

For example, the compiler now recognizes that this code in
strconv does not need to check the second shift for being ≥ 64.

msb := xHi >> 63
retMantissa := xHi >> (msb + 38)

nor does this code in regexp:

return b < utf8.RuneSelf && specialBytes[b%16]&(1<<(b/16)) != 0

This code in math no longer has a bounds check on the first index:

if 0 <= n && n <= 308 {
return pow10postab32[uint(n)/32] * pow10tab[uint(n)%32]
}

The diff shows one "lost" proof in ycbcr.go but it's not really lost:
the expression was folded to a constant instead, and that only shows
up with debug=2. A diff of that output is at
https://gist.github.com/rsc/9139ed46c6019ae007f5a1ba4bb3250f

Change-Id: I84087311e0a303f00e2820d957a6f8b29ee22519
Reviewed-on: https://go-review.googlesource.com/c/go/+/716140
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2 months agogo/token: fix a typo in a comment
Alexander F. Rødseth [Thu, 30 Oct 2025 13:46:44 +0000 (13:46 +0000)]
go/token: fix a typo in a comment

Fixes #75632

Change-Id: I71f891eb837147b6ff818ec4b2133c8c07091931
GitHub-Last-Rev: 3eeeea2dc28ef13eaef0fee7abf00ad418218f83
GitHub-Pull-Request: golang/go#76117
Reviewed-on: https://go-review.googlesource.com/c/go/+/716440
Reviewed-by: t hepudds <thepudds1460@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: t hepudds <thepudds1460@gmail.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>

2 months agostrconv: remove hand-written divide on 32-bit systems
Russ Cox [Tue, 28 Oct 2025 14:22:54 +0000 (10:22 -0400)]
strconv: remove hand-written divide on 32-bit systems

The compiler now generates code that is just as good.

host: s7:GOARCH=386
goos: linux
goarch: 386
pkg: strconv
cpu: AMD Ryzen 9 7950X 16-Core Processor
                                 │ 8d2b4ce71b3 │            d5524a1f38c             │
                                 │   sec/op    │   sec/op     vs base               │
AppendFloat/Decimal-4              43.91n ± 2%   44.23n ± 1%       ~ (p=0.654 n=20)
AppendFloat/Float-4                73.73n ± 0%   74.17n ± 1%       ~ (p=0.062 n=20)
AppendFloat/Exp-4                  77.33n ± 1%   77.11n ± 1%       ~ (p=0.234 n=20)
AppendFloat/NegExp-4               77.56n ± 1%   77.00n ± 1%       ~ (p=0.136 n=20)
AppendFloat/LongExp-4              79.01n ± 1%   79.62n ± 1%       ~ (p=0.213 n=20)
AppendFloat/Big-4                  88.02n ± 2%   88.88n ± 1%       ~ (p=0.159 n=20)
AppendFloat/BinaryExp-4            34.43n ± 1%   34.58n ± 1%       ~ (p=0.683 n=20)
AppendFloat/32Integer-4            44.05n ± 2%   43.74n ± 1%       ~ (p=0.055 n=20)
AppendFloat/32ExactFraction-4      66.55n ± 1%   66.62n ± 1%       ~ (p=0.753 n=20)
AppendFloat/32Point-4              64.01n ± 1%   63.39n ± 1%       ~ (p=0.032 n=20)
AppendFloat/32Exp-4                77.05n ± 1%   77.84n ± 1%       ~ (p=0.055 n=20)
AppendFloat/32NegExp-4             66.96n ± 1%   67.41n ± 1%       ~ (p=0.569 n=20)
AppendFloat/32Shortest-4           61.73n ± 1%   62.00n ± 1%       ~ (p=0.457 n=20)
AppendFloat/32Fixed8Hard-4         39.09n ± 1%   39.06n ± 1%       ~ (p=0.588 n=20)
AppendFloat/32Fixed9Hard-4         57.66n ± 0%   57.39n ± 1%       ~ (p=0.167 n=20)
AppendFloat/64Fixed1-4             52.52n ± 1%   52.45n ± 1%       ~ (p=0.867 n=20)
AppendFloat/64Fixed2-4             50.64n ± 1%   50.12n ± 4%       ~ (p=0.208 n=20)
AppendFloat/64Fixed3-4             49.54n ± 1%   50.84n ± 1%  +2.62% (p=0.000 n=20)
AppendFloat/64Fixed4-4             45.60n ± 1%   45.25n ± 1%       ~ (p=0.034 n=20)
AppendFloat/64Fixed12-4            57.70n ± 1%   57.70n ± 1%       ~ (p=0.394 n=20)
AppendFloat/64Fixed16-4            56.49n ± 1%   56.15n ± 1%       ~ (p=0.044 n=20)
AppendFloat/64Fixed12Hard-4        53.99n ± 1%   53.79n ± 1%       ~ (p=0.358 n=20)
AppendFloat/64Fixed17Hard-4        64.51n ± 1%   63.18n ± 1%  -2.06% (p=0.000 n=20)
AppendFloat/64Fixed18Hard-4        4.281µ ± 1%   4.294µ ± 1%       ~ (p=0.995 n=20)
AppendFloat/Slowpath64-4           77.94n ± 1%   78.66n ± 2%       ~ (p=0.136 n=20)
AppendFloat/SlowpathDenormal64-4   77.64n ± 1%   77.96n ± 1%       ~ (p=0.229 n=20)
AppendInt-4                        1.122µ ± 1%   1.116µ ± 1%       ~ (p=0.115 n=20)
AppendUint-4                       287.9n ± 1%   286.9n ± 1%       ~ (p=0.185 n=20)
AppendIntSmall-4                   5.845n ± 1%   5.819n ± 1%       ~ (p=0.516 n=20)
AppendUintVarlen/digits=1-4        3.924n ± 1%   3.905n ± 1%       ~ (p=0.317 n=20)
AppendUintVarlen/digits=2-4        3.909n ± 1%   3.940n ± 1%       ~ (p=0.995 n=20)
AppendUintVarlen/digits=3-4        9.543n ± 1%   9.567n ± 2%       ~ (p=0.606 n=20)
AppendUintVarlen/digits=4-4        9.710n ± 1%   9.748n ± 1%       ~ (p=0.602 n=20)
AppendUintVarlen/digits=5-4        10.84n ± 1%   10.88n ± 2%       ~ (p=0.425 n=20)
AppendUintVarlen/digits=6-4        11.06n ± 1%   11.06n ± 1%       ~ (p=0.506 n=20)
AppendUintVarlen/digits=7-4        11.97n ± 1%   12.05n ± 1%       ~ (p=0.218 n=20)
AppendUintVarlen/digits=8-4        12.27n ± 1%   12.32n ± 2%       ~ (p=0.358 n=20)
AppendUintVarlen/digits=9-4        13.57n ± 1%   13.57n ± 1%       ~ (p=0.952 n=20)
AppendUintVarlen/digits=10-4       16.88n ± 1%   16.52n ± 1%  -2.13% (p=0.000 n=20)
AppendUintVarlen/digits=11-4       16.83n ± 1%   16.72n ± 1%       ~ (p=0.012 n=20)
AppendUintVarlen/digits=12-4       17.93n ± 1%   17.63n ± 1%  -1.65% (p=0.000 n=20)
AppendUintVarlen/digits=13-4       18.38n ± 2%   17.80n ± 1%  -3.16% (p=0.000 n=20)
AppendUintVarlen/digits=14-4       19.20n ± 1%   18.65n ± 1%  -2.89% (p=0.000 n=20)
AppendUintVarlen/digits=15-4       19.41n ± 1%   18.85n ± 1%  -2.86% (p=0.000 n=20)
AppendUintVarlen/digits=16-4       20.33n ± 1%   19.79n ± 1%  -2.63% (p=0.000 n=20)
AppendUintVarlen/digits=17-4       20.32n ± 2%   19.79n ± 0%  -2.61% (p=0.000 n=20)
AppendUintVarlen/digits=18-4       21.09n ± 1%   20.84n ± 1%  -1.16% (p=0.000 n=20)
AppendUintVarlen/digits=19-4       25.68n ± 1%   25.24n ± 0%  -1.69% (p=0.000 n=20)
AppendUintVarlen/digits=20-4       25.42n ± 1%   25.15n ± 1%  -1.06% (p=0.000 n=20)
geomean                            37.54n        37.39n       -0.40%
%

Change-Id: I0dba26d1f6fbadc2a951dc0bbc8cf30d1391e10f
Reviewed-on: https://go-review.googlesource.com/c/go/+/716062
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2 months agocmd/compile: implement bits.Mul64 on 32-bit systems
Russ Cox [Mon, 27 Oct 2025 23:41:39 +0000 (19:41 -0400)]
cmd/compile: implement bits.Mul64 on 32-bit systems

This CL implements Mul64uhilo, Hmul64, Hmul64u, and Avg64u
on 32-bit systems, with the effect that constant division of both
int64s and uint64s can now be emitted directly in all cases,
and also that bits.Mul64 can be intrinsified on 32-bit systems.

Previously, constant division of uint64s by values 0 ≤ c ≤ 0xFFFF were
implemented as uint32 divisions by c and some fixup. After expanding
those smaller constant divisions, the code for i/999 required:

(386) 7 mul, 10 add, 2 sub, 3 rotate, 3 shift (104 bytes)
(arm) 7 mul, 9 add, 3 sub, 2 shift (104 bytes)
(mips) 7 mul, 10 add, 5 sub, 6 shift, 3 sgtu (176 bytes)

For that much code, we might as well use a full 64x64->128 multiply
that can be used for all divisors, not just small ones.
Having done that, the same i/999 now generates:

(386) 4 mul, 9 add, 2 sub, 2 or, 6 shift (112 bytes)
(arm) 4 mul, 8 add, 2 sub, 2 or, 3 shift (92 bytes)
(mips) 4 mul, 11 add, 3 sub, 6 shift, 8 sgtu, 4 or (196 bytes)

The size increase on 386 is due to a few extra register spills.
The size increase on mips is due to add-with-carry being hard.

The new approach is more general, letting us delete the old special case
and guarantee that all int64 and uint64 divisions by constants are
generated directly on 32-bit systems.

This especially speeds up code making heavy use of bits.Mul64 with
a constant argument, which happens in strconv and various crypto
packages. A few examples are benchmarked below.

pkg: cmd/compile/internal/test

benchmark \ host                      local  linux-amd64       s7  linux-386  s7:GOARCH=386
                                    vs base      vs base  vs base    vs base        vs base
DivconstI64                               ~            ~        ~    -49.66%        -21.02%
ModconstI64                               ~            ~        ~    -13.45%        +14.52%
DivisiblePow2constI64                     ~            ~        ~     +0.97%         -1.32%
DivisibleconstI64                         ~            ~        ~    -20.01%        -48.28%
DivisibleWDivconstI64                     ~            ~   -1.76%    -38.59%        -42.74%
DivconstU64/3                             ~            ~        ~    -13.82%         -4.09%
DivconstU64/5                             ~            ~        ~    -14.10%         -3.54%
DivconstU64/37                       -2.07%       -4.45%        ~    -19.60%         -9.55%
DivconstU64/1234567                       ~            ~        ~    -61.55%        -56.93%
ModconstU64                               ~            ~        ~     -6.25%              ~
DivisibleconstU64                         ~            ~        ~     -2.78%         -7.82%
DivisibleWDivconstU64                     ~            ~        ~     +4.23%         +2.56%

pkg: math/bits

benchmark \ host         s7  linux-amd64  linux-386  s7:GOARCH=386
                    vs base      vs base    vs base        vs base
Add                       ~            ~          ~              ~
Add32                +1.59%            ~          ~              ~
Add64                     ~            ~          ~              ~
Add64multiple             ~            ~          ~              ~
Sub                       ~            ~          ~              ~
Sub32                     ~            ~          ~              ~
Sub64                     ~            ~     -9.20%              ~
Sub64multiple             ~            ~          ~              ~
Mul                       ~            ~          ~              ~
Mul32                     ~            ~          ~              ~
Mul64                     ~            ~    -41.58%        -53.21%
Div                       ~            ~          ~              ~
Div32                     ~            ~          ~              ~
Div64                     ~            ~          ~              ~

pkg: strconv

benchmark \ host                       s7  linux-amd64  linux-386  s7:GOARCH=386
                                  vs base      vs base    vs base        vs base
ParseInt/Pos/7bit                       ~            ~    -11.08%         -6.75%
ParseInt/Pos/26bit                      ~            ~    -13.65%        -11.02%
ParseInt/Pos/31bit                      ~            ~    -14.65%         -9.71%
ParseInt/Pos/56bit                 -1.80%            ~    -17.97%        -10.78%
ParseInt/Pos/63bit                      ~            ~    -13.85%         -9.63%
ParseInt/Neg/7bit                       ~            ~    -12.14%         -7.26%
ParseInt/Neg/26bit                      ~            ~    -14.18%         -9.81%
ParseInt/Neg/31bit                      ~            ~    -14.51%         -9.02%
ParseInt/Neg/56bit                      ~            ~    -15.79%         -9.79%
ParseInt/Neg/63bit                      ~            ~    -15.68%        -11.07%
AppendFloat/Decimal                     ~            ~     -7.25%        -12.26%
AppendFloat/Float                       ~            ~    -15.96%        -19.45%
AppendFloat/Exp                         ~            ~    -13.96%        -17.76%
AppendFloat/NegExp                      ~            ~    -14.89%        -20.27%
AppendFloat/LongExp                     ~            ~    -12.68%        -17.97%
AppendFloat/Big                         ~            ~    -11.10%        -16.64%
AppendFloat/BinaryExp                   ~            ~          ~              ~
AppendFloat/32Integer                   ~            ~    -10.05%        -10.91%
AppendFloat/32ExactFraction             ~            ~     -8.93%        -13.00%
AppendFloat/32Point                     ~            ~    -10.36%        -14.89%
AppendFloat/32Exp                       ~            ~     -9.88%        -13.54%
AppendFloat/32NegExp                    ~            ~    -10.16%        -14.26%
AppendFloat/32Shortest                  ~            ~    -11.39%        -14.96%
AppendFloat/32Fixed8Hard                ~            ~          ~         -2.31%
AppendFloat/32Fixed9Hard                ~            ~          ~         -7.01%
AppendFloat/64Fixed1                    ~            ~     -2.83%         -8.23%
AppendFloat/64Fixed2                    ~            ~          ~         -7.94%
AppendFloat/64Fixed3                    ~            ~     -4.07%         -7.22%
AppendFloat/64Fixed4                    ~            ~     -7.24%         -7.62%
AppendFloat/64Fixed12                   ~            ~     -6.57%         -4.82%
AppendFloat/64Fixed16                   ~            ~     -4.00%         -5.81%
AppendFloat/64Fixed12Hard          -2.22%            ~     -4.07%         -6.35%
AppendFloat/64Fixed17Hard          -2.12%            ~          ~         -3.79%
AppendFloat/64Fixed18Hard          -1.89%            ~     +2.48%              ~
AppendFloat/Slowpath64             -1.85%            ~    -14.49%        -18.21%
AppendFloat/SlowpathDenormal64          ~            ~    -13.08%        -19.41%

pkg: crypto/internal/fips140/nistec/fiat

benchmark \ host         s7  linux-amd64  linux-386  s7:GOARCH=386
                    vs base      vs base    vs base        vs base
Mul/P224                  ~            ~    -29.95%        -39.60%
Mul/P384                  ~            ~    -37.11%        -63.33%
Mul/P521                  ~            ~    -26.62%        -12.42%
Square/P224          +1.46%            ~    -40.62%        -49.18%
Square/P384               ~            ~    -45.51%        -69.68%
Square/P521         +90.37%            ~    -25.26%        -11.23%

(The +90% is a separate problem and not real; that much variation
can be seen on that system by running the same binary from two
different files.)

pkg: crypto/internal/fips140/edwards25519

benchmark \ host                    s7  linux-amd64  linux-386  s7:GOARCH=386
                               vs base      vs base    vs base        vs base
EncodingDecoding                     ~            ~    -34.67%        -35.75%
ScalarBaseMult                       ~            ~    -31.25%        -30.29%
ScalarMult                           ~            ~    -33.45%        -32.54%
VarTimeDoubleScalarBaseMult          ~            ~    -33.78%        -33.68%

Change-Id: Id3c91d42cd01def6731b755e99f8f40c6ad1bb65
Reviewed-on: https://go-review.googlesource.com/c/go/+/716061
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 months agocrypto/internal/fips140/aes: fix CTR generator
Boris Nagaev [Wed, 22 Oct 2025 14:26:30 +0000 (14:26 +0000)]
crypto/internal/fips140/aes: fix CTR generator

Fixed two issues in AVO based generator of amd64 asm code.

1. Updated golang.org/x/tools dependency to prevent build issue in Go 1.25.

> golang.org/x/tools@v0.24.0/internal/tokeninternal/tokeninternal.go:64:9:
> invalid array length -delta * delta (constant -256 of type int64)

This error was caused by changes in layout of data structures in Go. Package
golang.org/x/tools has a mirror of that struct and a static assert that it
matches the Go's struct.

2. Changed the package name from crypto/aes to crypto/internal/fips140/aes.

This fixed run time error:

> ctr_amd64_asm.go:31: could not find function "ctrBlocks1Asm"
and other errors

Now the following works as expected:

$ cd src/crypto/internal/fips140/aes/_asm/ctr/
$ go generate

The command re-generates file "src/crypto/internal/fips140/aes/ctr_amd64.s".

Fixes #75972

Change-Id: I28e4c9ebb5bf72506a524e36a0c81a1b50367a84
GitHub-Last-Rev: afc9f506e50df6dc25fd285d5a597b0e5c93b5d9
GitHub-Pull-Request: golang/go#75973
Reviewed-on: https://go-review.googlesource.com/c/go/+/712920
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agogo/types, types: proceed with correct (invalid) type in case of a selector error
Robert Griesemer [Wed, 29 Oct 2025 22:22:14 +0000 (15:22 -0700)]
go/types, types: proceed with correct (invalid) type in case of a selector error

Fixes #76103.

Change-Id: Idc2f5d1d7aeb4a9b468e7c268e3bf5b85d1c3777
Reviewed-on: https://go-review.googlesource.com/c/go/+/716300
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>

2 months agostrconv: remove &0xFF trick in formatBase10
Russ Cox [Thu, 23 Oct 2025 13:42:37 +0000 (09:42 -0400)]
strconv: remove &0xFF trick in formatBase10

The compiler is now smart enough to remove the bounds check itself.

                              │ 731f809c971  │            48fabc7d33b             │
                              │    sec/op    │   sec/op     vs base               │
AppendUint-12                    98.69n ± 1%   95.81n ± 1%  -2.91% (p=0.000 n=20)
AppendUintVarlen/digits=1-12     3.119n ± 1%   3.099n ± 1%       ~ (p=0.743 n=20)
AppendUintVarlen/digits=2-12     2.654n ± 0%   2.653n ± 0%       ~ (p=0.825 n=20)
AppendUintVarlen/digits=3-12     5.042n ± 0%   5.055n ± 1%       ~ (p=0.005 n=20)
AppendUintVarlen/digits=4-12     5.062n ± 1%   5.044n ± 0%       ~ (p=0.011 n=20)
AppendUintVarlen/digits=5-12     5.863n ± 0%   5.908n ± 1%       ~ (p=0.075 n=20)
AppendUintVarlen/digits=6-12     6.137n ± 0%   6.117n ± 1%       ~ (p=0.857 n=20)
AppendUintVarlen/digits=7-12     7.367n ± 0%   7.366n ± 0%       ~ (p=0.784 n=20)
AppendUintVarlen/digits=8-12     7.369n ± 0%   7.381n ± 0%       ~ (p=0.159 n=20)
AppendUintVarlen/digits=9-12     7.795n ± 2%   7.749n ± 0%       ~ (p=0.180 n=20)
AppendUintVarlen/digits=10-12    9.208n ± 1%   8.661n ± 0%  -5.94% (p=0.000 n=20)
AppendUintVarlen/digits=11-12    9.479n ± 1%   8.984n ± 0%  -5.22% (p=0.000 n=20)
AppendUintVarlen/digits=12-12    9.784n ± 0%   9.229n ± 1%  -5.67% (p=0.000 n=20)
AppendUintVarlen/digits=13-12   10.035n ± 1%   9.504n ± 0%  -5.29% (p=0.000 n=20)
AppendUintVarlen/digits=14-12    10.89n ± 1%   10.35n ± 0%  -4.96% (p=0.000 n=20)
AppendUintVarlen/digits=15-12    11.12n ± 0%   10.61n ± 1%  -4.67% (p=0.000 n=20)
AppendUintVarlen/digits=16-12    12.29n ± 0%   11.85n ± 1%  -3.62% (p=0.000 n=20)
AppendUintVarlen/digits=17-12    12.32n ± 0%   11.85n ± 1%  -3.85% (p=0.000 n=20)
AppendUintVarlen/digits=18-12    12.80n ± 0%   12.32n ± 1%  -3.79% (p=0.000 n=20)
AppendUintVarlen/digits=19-12    14.62n ± 1%   13.71n ± 1%  -6.29% (p=0.000 n=20)
AppendUintVarlen/digits=20-12    14.83n ± 0%   13.93n ± 0%  -6.10% (p=0.000 n=20)
geomean                          9.102n        8.843n       -2.84%

Change-Id: Ic8c79b472d5c30dccc1d974b47647f6425618e00
Reviewed-on: https://go-review.googlesource.com/c/go/+/714161
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2 months agocmd/compile: make prove understand div, mod better
Russ Cox [Thu, 23 Oct 2025 02:22:51 +0000 (22:22 -0400)]
cmd/compile: make prove understand div, mod better

This CL introduces new divisible and divmod passes that rewrite
divisibility checks and div, mod, and mul. These happen after
prove, so that prove can make better sense of the code for
deriving bounds, and they must run before decompose, so that
64-bit ops can be lowered to 32-bit ops on 32-bit systems.
And then they need another generic pass as well, to optimize
the generated code before decomposing.

The three opt passes are "opt", "middle opt", and "late opt".
(Perhaps instead they should be "generic", "opt", and "late opt"?)

The "late opt" pass repeats the "middle opt" work on any new code
that has been generated in the interim.
There will not be new divs or mods, but there may be new muls.

The x%c==0 rewrite rules are much simpler now, since they can
match before divs have been rewritten. This has the effect of
applying them more consistently and making the rewrite rules
independent of the exact div rewrites.

Prove is also now charged with marking signed div/mod as
unsigned when the arguments call for it, allowing simpler
code to be emitted in various cases. For example,
t.Seconds()/2 and len(x)/2 are now recognized as unsigned,
meaning they compile to a simple shift (unsigned division),
avoiding the more complex fixup we need for signed values.

https://gist.github.com/rsc/99d9d3bd99cde87b6a1a390e3d85aa32
shows a diff of 'go build -a -gcflags=-d=ssa/prove/debug=1 std'
output before and after. "Proved Rsh64x64 shifts to zero" is replaced
by the higher-level "Proved Div64 is unsigned" (the shift was in the
signed expansion of div by constant), but otherwise prove is only
finding more things to prove.

One short example, in code that does x[i%len(x)]:

< runtime/mfinal.go:131:34: Proved Rsh64x64 shifts to zero
---
> runtime/mfinal.go:131:34: Proved Div64 is unsigned
> runtime/mfinal.go:131:38: Proved IsInBounds

A longer example:

< crypto/internal/fips140/sha3/shake.go:28:30: Proved Rsh64x64 shifts to zero
< crypto/internal/fips140/sha3/shake.go:38:27: Proved Rsh64x64 shifts to zero
< crypto/internal/fips140/sha3/shake.go:53:46: Proved Rsh64x64 shifts to zero
< crypto/internal/fips140/sha3/shake.go:55:46: Proved Rsh64x64 shifts to zero
---
> crypto/internal/fips140/sha3/shake.go:28:30: Proved Div64 is unsigned
> crypto/internal/fips140/sha3/shake.go:28:30: Proved IsInBounds
> crypto/internal/fips140/sha3/shake.go:28:30: Proved IsSliceInBounds
> crypto/internal/fips140/sha3/shake.go:38:27: Proved Div64 is unsigned
> crypto/internal/fips140/sha3/shake.go:45:7: Proved IsSliceInBounds
> crypto/internal/fips140/sha3/shake.go:46:4: Proved IsInBounds
> crypto/internal/fips140/sha3/shake.go:53:46: Proved Div64 is unsigned
> crypto/internal/fips140/sha3/shake.go:53:46: Proved IsInBounds
> crypto/internal/fips140/sha3/shake.go:53:46: Proved IsSliceInBounds
> crypto/internal/fips140/sha3/shake.go:55:46: Proved Div64 is unsigned
> crypto/internal/fips140/sha3/shake.go:55:46: Proved IsInBounds
> crypto/internal/fips140/sha3/shake.go:55:46: Proved IsSliceInBounds

These diffs are due to the smaller opt being better
and taking work away from prove:

< image/jpeg/dct.go:307:5: Proved IsInBounds
< image/jpeg/dct.go:308:5: Proved IsInBounds
...
< image/jpeg/dct.go:442:5: Proved IsInBounds

In the old opt, Mul by 8 was rewritten to Lsh by 3 early.
This CL delays that rule to help prove recognize mods,
but it also helps opt constant-fold the slice x[8*i:8*i+8:8*i+8].
Specifically, computing the length, opt can now do:

(Sub64 (Add (Mul 8 i) 8) (Add (Mul 8 i) 8)) ->
(Add 8 (Sub (Mul 8 i) (Mul 8 i))) ->
(Add 8 (Mul 8 (Sub i i))) ->
(Add 8 (Mul 8 0)) ->
(Add 8 0) ->
8

The key step is (Sub (Mul x y) (Mul x z)) -> (Mul x (Sub y z)),
Leaving the multiply as Mul enables using that step; the old
rewrite to Lsh blocked it, leaving prove to figure out the length
and then remove the bounds checks. But now opt can evaluate
the length down to a constant 8 and then constant-fold away
the bounds checks 0 < 8, 1 < 8, and so on. After that,
the compiler has nothing left to prove.

Benchmarks are noisy in general; I checked the assembly for the many
large increases below, and the vast majority are unchanged and
presumably hitting the caches differently in some way.

The divisibility optimizations were not reliably triggering before.
This leads to a very large improvement in some cases, like
DivisiblePow2constI64, DivisibleconstI64 on 64-bit systems
and DivisbleconstU64 on 32-bit systems.

Another way the divisibility optimizations were unreliable before
was incorrectly triggering for x/3, x%3 even though they are
written not to do that. There is a real but small slowdown
in the DivisibleWDivconst benchmarks on Mac because in the cases
used in the benchmark, it is still faster (on Mac) to do the
divisibility check than to remultiply.
This may be worth further study. Perhaps when there is no rotate
(meaning the divisor is odd), the divisibility optimization
should be enabled always. In any event, this CL makes it possible
to study that.

benchmark \ host                          s7  linux-amd64      mac  linux-arm64  linux-ppc64le  linux-386  s7:GOARCH=386  linux-arm
                                     vs base      vs base  vs base      vs base        vs base    vs base        vs base    vs base
LoadAdd                                    ~            ~        ~            ~              ~     -1.59%              ~          ~
ExtShift                                   ~            ~  -42.14%       +0.10%              ~     +1.44%         +5.66%     +8.50%
Modify                                     ~            ~        ~            ~              ~          ~              ~     -1.53%
MullImm                                    ~            ~        ~            ~              ~    +37.90%        -21.87%     +3.05%
ConstModify                                ~            ~        ~            ~        -49.14%          ~              ~          ~
BitSet                                     ~            ~        ~            ~        -15.86%    -14.57%         +6.44%     +0.06%
BitClear                                   ~            ~        ~            ~              ~     +1.78%         +3.50%     +0.06%
BitToggle                                  ~            ~        ~            ~              ~    -16.09%         +2.91%          ~
BitSetConst                                ~            ~        ~            ~              ~          ~              ~     -0.49%
BitClearConst                              ~            ~        ~            ~        -28.29%          ~              ~     -0.40%
BitToggleConst                             ~            ~        ~       +8.89%        -31.19%          ~              ~     -0.77%
MulNeg                                     ~            ~        ~            ~              ~          ~              ~          ~
Mul2Neg                                    ~            ~   -4.83%            ~              ~    -13.75%         -5.92%          ~
DivconstI64                                ~            ~        ~            ~              ~    -30.12%              ~     +0.50%
ModconstI64                                ~            ~   -9.94%       -4.63%              ~     +3.15%              ~     +5.32%
DivisiblePow2constI64                -34.49%      -12.58%        ~            ~        -12.25%          ~              ~          ~
DivisibleconstI64                    -24.69%      -25.06%   -0.40%       -2.27%        -42.61%     -3.31%              ~     +1.63%
DivisibleWDivconstI64                      ~            ~        ~            ~              ~    -17.55%              ~     -0.60%
DivconstU64/3                              ~            ~        ~            ~              ~     +1.51%              ~          ~
DivconstU64/5                              ~            ~        ~            ~              ~          ~              ~          ~
DivconstU64/37                             ~            ~   -0.18%            ~              ~     +2.70%              ~          ~
DivconstU64/1234567                        ~            ~        ~            ~              ~          ~              ~     +0.12%
ModconstU64                                ~            ~        ~       -0.24%              ~     -5.10%         -1.07%     -1.56%
DivisibleconstU64                          ~            ~        ~            ~              ~    -29.01%        -59.13%    -50.72%
DivisibleWDivconstU64                      ~            ~  -12.18%      -18.88%              ~     -5.50%         -3.91%     +5.17%
DivconstI32                                ~            ~   -0.48%            ~        -34.69%    +89.01%         -6.01%    -16.67%
ModconstI32                                ~       +2.95%   -0.33%            ~              ~     -2.98%         -5.40%     -8.30%
DivisiblePow2constI32                      ~            ~        ~            ~              ~          ~              ~    -16.22%
DivisibleconstI32                          ~            ~        ~            ~              ~    -37.27%        -47.75%    -25.03%
DivisibleWDivconstI32                -11.59%       +5.22%  -12.99%      -23.83%              ~    +45.95%         -7.03%    -10.01%
DivconstU32                                ~            ~        ~            ~              ~    +74.71%         +4.81%          ~
ModconstU32                                ~            ~   +0.53%       +0.18%              ~    +51.16%              ~          ~
DivisibleconstU32                          ~            ~        ~       -0.62%              ~     -4.25%              ~          ~
DivisibleWDivconstU32                 -2.77%       +5.56%  +11.12%       -5.15%              ~    +48.70%        +25.11%     -4.07%
DivconstI16                           -6.06%            ~   -0.33%       +0.22%              ~          ~         -9.68%     +5.47%
ModconstI16                                ~            ~   +4.44%       +2.82%              ~          ~              ~     +5.06%
DivisiblePow2constI16                      ~            ~        ~            ~              ~          ~              ~     -0.17%
DivisibleconstI16                          ~            ~   -0.23%            ~              ~          ~         +4.60%     +6.64%
DivisibleWDivconstI16                 -1.44%       -0.43%  +13.48%       -5.76%              ~     +1.62%        -23.15%     -9.06%
DivconstU16                           +1.61%            ~   -0.35%       -0.47%              ~          ~        +15.59%          ~
ModconstU16                                ~            ~        ~            ~              ~     -0.72%              ~    +14.23%
DivisibleconstU16                          ~            ~   -0.05%       +3.00%              ~          ~              ~     +5.06%
DivisibleWDivconstU16                +52.10%       +0.75%  +17.28%       +4.79%              ~    -37.39%         +5.28%     -9.06%
DivconstI8                                 ~            ~   -0.34%       -0.96%              ~          ~         -9.20%          ~
ModconstI8                            +2.29%            ~   +4.38%       +2.96%              ~          ~              ~          ~
DivisiblePow2constI8                       ~            ~        ~            ~              ~          ~              ~          ~
DivisibleconstI8                           ~            ~        ~            ~              ~          ~         +6.04%          ~
DivisibleWDivconstI8                 -26.44%       +1.69%  +17.03%       +4.05%              ~    +32.48%        -24.90%          ~
DivconstU8                            -4.50%      +14.06%   -0.28%            ~              ~          ~         +4.16%     +0.88%
ModconstU8                                 ~            ~  +25.84%       -0.64%              ~          ~              ~          ~
DivisibleconstU8                           ~            ~   -5.70%            ~              ~          ~              ~          ~
DivisibleWDivconstU8                 +49.55%       +9.07%        ~       +4.03%        +53.87%    -40.03%        +39.72%     -3.01%
Mul2                                       ~            ~        ~            ~              ~          ~              ~          ~
MulNeg2                                    ~            ~        ~            ~        -11.73%          ~              ~     -0.02%
EfaceInteger                               ~            ~        ~            ~              ~    +18.11%              ~     +2.53%
TypeAssert                           +33.90%       +2.86%        ~            ~              ~     -1.07%         -5.29%     -1.04%
Div64UnsignedSmall                         ~            ~        ~            ~              ~          ~              ~          ~
Div64Small                                 ~            ~        ~            ~              ~     -0.88%              ~     +2.39%
Div64SmallNegDivisor                       ~            ~        ~            ~              ~          ~              ~     +0.35%
Div64SmallNegDividend                      ~            ~        ~            ~              ~     -0.84%              ~     +3.57%
Div64SmallNegBoth                          ~            ~        ~            ~              ~     -0.86%              ~     +3.55%
Div64Unsigned                              ~            ~        ~            ~              ~          ~              ~     -0.11%
Div64                                      ~            ~        ~            ~              ~          ~              ~     +0.11%
Div64NegDivisor                            ~            ~        ~            ~              ~     -1.29%              ~          ~
Div64NegDividend                           ~            ~        ~            ~              ~     -1.44%              ~          ~
Div64NegBoth                               ~            ~        ~            ~              ~          ~              ~     +0.28%
Mod64UnsignedSmall                         ~            ~        ~            ~              ~     +0.48%              ~     +0.93%
Mod64Small                                 ~            ~        ~            ~              ~          ~              ~          ~
Mod64SmallNegDivisor                       ~            ~        ~            ~              ~          ~              ~     +1.44%
Mod64SmallNegDividend                      ~            ~        ~            ~              ~     +0.22%              ~     +1.37%
Mod64SmallNegBoth                          ~            ~        ~            ~              ~          ~              ~     -2.22%
Mod64Unsigned                              ~            ~        ~            ~              ~     -0.95%              ~     +0.11%
Mod64                                      ~            ~        ~            ~              ~          ~              ~          ~
Mod64NegDivisor                            ~            ~        ~            ~              ~          ~              ~     -0.02%
Mod64NegDividend                           ~            ~        ~            ~              ~          ~              ~          ~
Mod64NegBoth                               ~            ~        ~            ~              ~          ~              ~     -0.02%
MulconstI32/3                              ~            ~        ~      -25.00%              ~          ~              ~    +47.37%
MulconstI32/5                              ~            ~        ~      +33.28%              ~          ~              ~    +32.21%
MulconstI32/12                             ~            ~        ~       -2.13%              ~          ~              ~     -0.02%
MulconstI32/120                            ~            ~        ~       +2.93%              ~          ~              ~     -0.03%
MulconstI32/-120                           ~            ~        ~       -2.17%              ~          ~              ~     -0.03%
MulconstI32/65537                          ~            ~        ~            ~              ~          ~              ~     +0.03%
MulconstI32/65538                          ~            ~        ~            ~              ~    -33.38%              ~     +0.04%
MulconstI64/3                              ~            ~        ~      +33.35%              ~     -0.37%              ~     -0.13%
MulconstI64/5                              ~            ~        ~      -25.00%              ~     -0.34%              ~          ~
MulconstI64/12                             ~            ~        ~       +2.13%              ~    +11.62%              ~     +2.30%
MulconstI64/120                            ~            ~        ~       -1.98%              ~          ~              ~          ~
MulconstI64/-120                           ~            ~        ~       +0.75%              ~          ~              ~          ~
MulconstI64/65537                          ~            ~        ~            ~              ~     +5.61%              ~          ~
MulconstI64/65538                          ~            ~        ~            ~              ~     +5.25%              ~          ~
MulconstU32/3                              ~       +0.81%        ~      +33.39%              ~    +77.92%              ~    -32.31%
MulconstU32/5                              ~            ~        ~      -24.97%              ~    +77.92%              ~    -24.47%
MulconstU32/12                             ~            ~        ~       +2.06%              ~          ~              ~     +0.03%
MulconstU32/120                            ~            ~        ~       -2.74%              ~          ~              ~     +0.03%
MulconstU32/65537                          ~            ~        ~            ~              ~          ~              ~     +0.03%
MulconstU32/65538                          ~            ~        ~            ~              ~    -33.42%              ~     -0.03%
MulconstU64/3                              ~            ~        ~      +33.33%              ~     -0.28%              ~     +1.22%
MulconstU64/5                              ~            ~        ~      -25.00%              ~          ~              ~     -0.64%
MulconstU64/12                             ~            ~        ~       +2.30%              ~    +11.59%              ~     +0.14%
MulconstU64/120                            ~            ~        ~       -2.82%              ~          ~              ~     +0.04%
MulconstU64/65537                          ~       +0.37%        ~            ~              ~     +5.58%              ~          ~
MulconstU64/65538                          ~            ~        ~            ~              ~     +5.16%              ~          ~
ShiftArithmeticRight                       ~            ~        ~            ~              ~    -10.81%              ~     +0.31%
Switch8Predictable                   +14.69%            ~        ~            ~              ~    -24.85%              ~          ~
Switch8Unpredictable                       ~       -0.58%   -3.80%            ~              ~    -11.78%              ~     -0.79%
Switch32Predictable                  -10.33%      +17.89%        ~            ~              ~     +5.76%              ~          ~
Switch32Unpredictable                 -3.15%       +1.19%   +9.42%            ~              ~    -10.30%         -5.09%     +0.44%
SwitchStringPredictable              +70.88%      +20.48%        ~            ~              ~     +2.39%              ~     +0.31%
SwitchStringUnpredictable                  ~       +3.91%   -5.06%       -0.98%              ~     +0.61%         +2.03%          ~
SwitchTypePredictable               +146.58%       -1.10%        ~      -12.45%              ~     -0.46%         -3.81%          ~
SwitchTypeUnpredictable               +0.46%       -0.83%        ~       +4.18%              ~     +0.43%              ~     +0.62%
SwitchInterfaceTypePredictable       -13.41%      -10.13%  +11.03%            ~              ~     -4.38%              ~     +0.75%
SwitchInterfaceTypeUnpredictable      -6.37%       -2.14%        ~       -3.21%              ~     -4.20%              ~     +1.08%

Fixes #63110.
Fixes #75954.

Change-Id: I55a876f08c6c14f419ce1a8cbba2eaae6c6efbf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/714160
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agotest/codegen: simplify asmcheck pattern matching
Russ Cox [Mon, 27 Oct 2025 02:51:14 +0000 (22:51 -0400)]
test/codegen: simplify asmcheck pattern matching

Separate patterns in asmcheck by spaces instead of commas.
Many patterns end in comma (like "MOV [$]123,") so separating
patterns by comma is not great; they're already quoted, so spaces are fine.

Also replace all tabs in the assembly lines with spaces before matching.
Finally, replace \$ or \\$ with [$] as the matching idiom.
The effect of all these is to make the patterns look like:

      // amd64:"BSFQ" "ORQ [$]256"

instead of the old:

      // amd64:"BSFQ","ORQ\t\\$256"

Update all tests as well.

Change-Id: Ia39febe5d7f67ba115846422789e11b185d5c807
Reviewed-on: https://go-review.googlesource.com/c/go/+/716060
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2 months agoruntime: tweak example code for gorecover
Jes Cok [Wed, 29 Oct 2025 07:59:22 +0000 (07:59 +0000)]
runtime: tweak example code for gorecover

Change-Id: Ie545610fab008f7855bcb1a608f98e0c5109ec20
GitHub-Last-Rev: 66401b913ad8e85c1dc6c9c0e785f57d5dc5c47e
GitHub-Pull-Request: golang/go#76100
Reviewed-on: https://go-review.googlesource.com/c/go/+/716040
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2 months agocrypto/internal/fips140/bigmod: fix extendedGCD comment
Filippo Valsorda [Wed, 8 Oct 2025 11:43:08 +0000 (13:43 +0200)]
crypto/internal/fips140/bigmod: fix extendedGCD comment

Change-Id: I6a6a6964642991dc46929bfc47e411bb7563e425
Reviewed-on: https://go-review.googlesource.com/c/go/+/716080
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agoruntime: use internal/strconv
Russ Cox [Wed, 29 Oct 2025 02:00:26 +0000 (22:00 -0400)]
runtime: use internal/strconv

Runtime doing its own number formatting dates back to
when runtime was the bottom-most Go package.
Those days are long gone. Use internal/strconv to avoid
duplicating code and also to get better floating-point
formatting:

% go1.24.6 run x.go
+1.234568e+004
% go run x.go
12345.678
%

With accurate floating point it becomes necessary to
introduce separate printers for float32 vs float64 and
for complex64 vs complex128. Otherwise float32(93.7)
prints as 93.69999694824219.

Change-Id: I25ae3f09519342dc3d1dcabf4711651423e00128
Reviewed-on: https://go-review.googlesource.com/c/go/+/716002
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agointernal/itoa, internal/runtime/strconv: delete
Russ Cox [Wed, 29 Oct 2025 01:54:33 +0000 (21:54 -0400)]
internal/itoa, internal/runtime/strconv: delete

Replaced by internal/strconv.

Change-Id: I0656a9ad5075e60339e963fbae7d194d2f3e16be
Reviewed-on: https://go-review.googlesource.com/c/go/+/716001
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agostrconv: move all but Quote to internal/strconv
Russ Cox [Wed, 29 Oct 2025 01:41:40 +0000 (21:41 -0400)]
strconv: move all but Quote to internal/strconv

This will let low-level things depend on the canonical routines,
even for floating-point printing.

Change-Id: I31207dc6584ad90d4e365dbe6eaf20f8662ed22d
Reviewed-on: https://go-review.googlesource.com/c/go/+/716000
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agointernal/runtime/gc/scan: avoid memory destination on VPCOMPRESSQ
Michael Pratt [Mon, 27 Oct 2025 19:34:18 +0000 (15:34 -0400)]
internal/runtime/gc/scan: avoid memory destination on VPCOMPRESSQ

On AMD Genoa / Zen 4, VPCOMPRESSQ with a memory destination imposes a
severe performance penalty of another an order of magnitude compared to
a register destination.

We can trivially work around this penalty with a register destination
and an additional move to memory.

Benchmark results from:

$ go test -bench=BenchmarkScanSpanPacked/.*/.*/.*/.*/impl=Platform internal/runtime/gc/scan

I've only included the summarized geomean here because there are ~2500
unique test cases.

AMD Genoa (Zen 4):

cpu: AMD EPYC 9B14 96-Core Processor
         │      mem      │                 reg        │
         │    sec/op     │    sec/op     vs base      │
geomean     1.039µ         310.1n        -70.16%

         │      mem      │                  reg       │
         │      B/s      │      B/s        vs base    │
geomean    2.906Gi          10.99Gi        +278.27%

As expected, we see a massive performance improvement on Genoa.

AMD Turin (Zen 5):

cpu: AMD EPYC 9B45 128-Core Processor
         │      mem      │                 reg        │
         │    sec/op     │    sec/op      vs base     │
geomean     231.9n          237.3n         +2.32%

         │      mem       │                  reg      │
         │      B/s       │      B/s        vs base   │
geomean     14.79Gi          14.43Gi         -2.50%

On Turin there is a minor regression. This is primarily due to a fairly
large regression (~15%) in very small microbenchmark cases where the
entire memory fits in L1 cache. This regression disappears as memory
access slows down with larger memories. The latter should be more common
in real workloads.

Intel Sapphire Rapids:

cpu: Intel(R) Xeon(R) Platinum 8481C
         │      mem      │                 reg        │
         │    sec/op     │    sec/op      vs base     │
geomean     254.9n          246.8n         -3.18%

         │      mem       │                  reg      │
         │      B/s       │      B/s        vs base   │
geomean     13.65Gi          14.15Gi         +3.69%

On Sapphire Rapids there is a minor improvement. Here results are fairly
noisy. Most cases are a wash, but some are arbitrary 20% slower or 20%
faster for unclear reasons.

For #73581.

Change-Id: I6a6a636cfd294a0dcdc4f34c9ece1bc9a6e5e4c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/715362
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2 months agocmd/compile: extend ppc64 MADDLD to match const ADDconst & MULLDconst
Jorropo [Tue, 28 Oct 2025 09:11:03 +0000 (10:11 +0100)]
cmd/compile: extend ppc64 MADDLD to match const ADDconst & MULLDconst

Fixes #76084

I was focused on restoring the old behavior and fixing the failing
test/codegen/arithmetic.go:MergeMuls2 test.

It is probable this same bug hides elsewhere in this file.

Change-Id: I17f2ee6b97a1e33b8132648d9d750749d006f7e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/715560
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Paul Murphy <paumurph@redhat.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
2 months agocmd/compile: name change isDirect -> isDirectAndComparable
Keith Randall [Tue, 28 Oct 2025 17:07:48 +0000 (10:07 -0700)]
cmd/compile: name change isDirect -> isDirectAndComparable

Now that it also restricts to comparable types. Followon to CL 713840.

Change-Id: Idd975c3fd16fb51f55360f2fa0b89ab0bf1d00ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/715700
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/compile: don't optimize away a panicing interface comparison
Keith Randall [Wed, 22 Oct 2025 17:13:44 +0000 (10:13 -0700)]
cmd/compile: don't optimize away a panicing interface comparison

We can't do direct pointer comparisons if the type is not a
comparable type.

Fixes #76008

Change-Id: I1687acff21832d2c2e8f3b875e7b5ec125702ef3
Reviewed-on: https://go-review.googlesource.com/c/go/+/713840
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
2 months agocmd/compile: extend loong MOV*idx rules to match ADDshiftLLV
Jorropo [Tue, 28 Oct 2025 09:48:18 +0000 (10:48 +0100)]
cmd/compile: extend loong MOV*idx rules to match ADDshiftLLV

Fixes #76085

I was focused on restoring the old behavior and fixing the failing
test/codegen/floats.go:index* tests.

It is probable this same bug hides elsewhere in this file.

Change-Id: Ibb2cb2be5c7bbeb5eafa9705d998a67380f2b04c
Reviewed-on: https://go-review.googlesource.com/c/go/+/715580
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 months agoruntime: define PanicBounds in funcdata.h
Ian Lance Taylor [Mon, 27 Oct 2025 23:51:01 +0000 (16:51 -0700)]
runtime: define PanicBounds in funcdata.h

The comment in funcdata.h says that the constants must agree
with those in internal/abi/symtab.go. Make that so.

Change-Id: Ib64146bfb31fdecfc1cc6ae03ae746a1b4a4d22e
Reviewed-on: https://go-review.googlesource.com/c/go/+/715521
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

2 months agocrypto/internal/fips140test: collect 300M entropy samples for ESV
Filippo Valsorda [Tue, 28 Oct 2025 10:44:57 +0000 (11:44 +0100)]
crypto/internal/fips140test: collect 300M entropy samples for ESV

Change-Id: I6a6a69649df8f576df62e22c16db7813cde75224
Reviewed-on: https://go-review.googlesource.com/c/go/+/715401
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agoruntime: amend comments a bit
Jes Cok [Tue, 28 Oct 2025 10:59:33 +0000 (10:59 +0000)]
runtime: amend comments a bit

Change-Id: I3cabc57f6b8f803f966221f9583a5edb8828ca12
GitHub-Last-Rev: 57569ace50ab8ce3d39e17ddf25ad161dffcc19d
GitHub-Pull-Request: golang/go#76086
Reviewed-on: https://go-review.googlesource.com/c/go/+/715600
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2 months agoerrors: document that the target of Is must be comparable
Damien Neil [Mon, 27 Oct 2025 19:27:12 +0000 (12:27 -0700)]
errors: document that the target of Is must be comparable

If target is not comparable, then errors.Is(err, target) can panic.
(Put another way, if target == target panics, then Is can panic.)

Document that the target must be comparable.

For #74488

Change-Id: I694dc4c91a608b80f044f06dd1c6ac32b8e77c9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/715440
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Bypass: Damien Neil <dneil@google.com>

2 months agogo/types, types2: pull up package-level object sort to a separate phase
Mark Freeman [Mon, 27 Oct 2025 20:37:16 +0000 (16:37 -0400)]
go/types, types2: pull up package-level object sort to a separate phase

This step allows future additional phases to reuse the sorted object
list. Preparation for upcoming CLs.

Change-Id: I22eaffd5bbe39c7cc101c6d860011dc3cb98ce37
Reviewed-on: https://go-review.googlesource.com/c/go/+/715480
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>

2 months agogo/types, types2: reduce locks held at once in resolveUnderlying
Mark Freeman [Thu, 23 Oct 2025 20:48:00 +0000 (16:48 -0400)]
go/types, types2: reduce locks held at once in resolveUnderlying

There is no need to hold locks for the entire chain of Named types in
resolveUnderlying. This change moves the locking / unlocking right to
where t.underlying is set.

This change consolidates logic into resolveUnderlying where possible
and makes minor stylistic / documentation adjustments.

Change-Id: Ic5ec5a7e9a0da8bc34954bf456e4e23a28df296d
Reviewed-on: https://go-review.googlesource.com/c/go/+/714403
Reviewed-by: Michael Pratt <mpratt@google.com>
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>

2 months agocmd/compile: rewrite proved multiplies by 0 or 1 into CondSelect
Jorropo [Sun, 26 Oct 2025 17:38:00 +0000 (18:38 +0100)]
cmd/compile: rewrite proved multiplies by 0 or 1 into CondSelect

Updates #76056

Change-Id: I64fe631ab381c74f902f877392530d7cc91860ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/715044
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.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>

2 months agocmd/compile: move branchelim supported arches to Config
Jorropo [Sun, 26 Oct 2025 14:50:13 +0000 (15:50 +0100)]
cmd/compile: move branchelim supported arches to Config

Change-Id: I8d10399ba71e5fa97ead06a717fc972c806c0856
Reviewed-on: https://go-review.googlesource.com/c/go/+/715042
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>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 months agocrypto/subtle,cmd/compile: add intrinsics for ConstantTimeSelect and *Eq
Jorropo [Sun, 26 Oct 2025 21:19:30 +0000 (22:19 +0100)]
crypto/subtle,cmd/compile: add intrinsics for ConstantTimeSelect and *Eq

Targeting crypto/subtle rather than
crypto/internal/fips140/subtle after discussion with Filippo.

goos: linux
goarch: amd64
pkg: crypto/subtle
cpu: AMD Ryzen 5 3600 6-Core Processor
                        │ /tmp/old.logs │            /tmp/new.logs             │
                        │    sec/op     │    sec/op     vs base                │
ConstantTimeSelect-12      0.5246n ± 1%   0.5217n ± 2%        ~ (p=0.118 n=10)
ConstantTimeByteEq-12      1.0415n ± 1%   0.5202n ± 2%  -50.05% (p=0.000 n=10)
ConstantTimeEq-12          0.7813n ± 2%   0.7819n ± 0%        ~ (p=0.897 n=10)
ConstantTimeLessOrEq-12    1.0415n ± 3%   0.7813n ± 1%  -24.98% (p=0.000 n=10)
geomean                    0.8166n        0.6381n       -21.86%

The last three will become 1 lat-cycle (0.25ns) faster once #76066 is fixed.

The Select being that fast with the old code is really impressive.
I am pretty sure this happens because my CPU has BMI1&2 support and
a fusing unit able to translate non BMI code into BMI code.
This benchmark doesn't capture the CACHE gains from the shorter assembly.

It currently compiles as:
v17 = TESTQ <flags> v31 v31 // v != 0
v20 = CMOVQNE <int> v32 v33 v17 (y[int])

It is possible to remove the `TESTQ` by compiletime fusing it with the
compare in a pattern like this:
subtle.ConstantTimeSelect(subtle.ConstantTimeLessOrEq(left, right), right, left)

Saving 2 latency-cycles (1 with #76066 fixed).

Updates #76056

Change-Id: I61a1df99e97a1506f75dae13db529f43846d8f1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/715045
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2 months agocmd/compile: add generic rules to remove bool → int → bool roundtrips
Jorropo [Mon, 27 Oct 2025 12:05:41 +0000 (13:05 +0100)]
cmd/compile: add generic rules to remove bool → int → bool roundtrips

Change-Id: I8b0a3b64c89fe167d304f901a5d38470f35400ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/715200
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: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2 months agocmd/compile: do not Zext bools to 64bits in amd64 CMOV generation rules
Jorropo [Mon, 27 Oct 2025 17:20:44 +0000 (18:20 +0100)]
cmd/compile: do not Zext bools to 64bits in amd64 CMOV generation rules

Change-Id: I77b714ed767e50d13183f4307f65e47ca7577f9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/715380
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/compile: introduce bytesizeToConst to cleanup switches in prove
Jorropo [Sun, 26 Oct 2025 14:53:51 +0000 (15:53 +0100)]
cmd/compile: introduce bytesizeToConst to cleanup switches in prove

Change-Id: I32b45d9632a8131911cb9bd6eff075eb8312ccfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/715043
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
2 months agocmd/link: internal linking support for windows/arm64
qmuntal [Tue, 16 Sep 2025 16:00:10 +0000 (18:00 +0200)]
cmd/link: internal linking support for windows/arm64

The internal linker was missing some pieces to support windows/arm64.

Closes #75485

Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64
Change-Id: I5c18a47e63e09b8ae22c9b24832249b54f544b7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/704295
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 months agointernal/runtime/gc/scan: correct size class size check
Michael Pratt [Mon, 27 Oct 2025 20:17:31 +0000 (16:17 -0400)]
internal/runtime/gc/scan: correct size class size check

This check intends to skip size classes that are too big for scanSpan,
but it compares the size class index with a byte size. It must do the
conversion first.

For #73581.

Change-Id: I6a6a636c8d19fa3bf2a2b609870d67d33f47f66e
Reviewed-on: https://go-review.googlesource.com/c/go/+/715460
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 months agocmd/compile: add position info to sccp debug messages
Jorropo [Sat, 25 Oct 2025 20:08:59 +0000 (22:08 +0200)]
cmd/compile: add position info to sccp debug messages

Change-Id: Ic568dd3b2e3ebebb1b6aaa41ee78a12d4e8d3f06
Reviewed-on: https://go-review.googlesource.com/c/go/+/714221
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
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>
2 months agocmd/compile: teach prove about unsigned rounding-up divide
Jorropo [Sat, 25 Oct 2025 07:25:27 +0000 (09:25 +0200)]
cmd/compile: teach prove about unsigned rounding-up divide

Change-Id: Ia7b5242c723f83ba85d12e4ca64a19fbbd126016
Reviewed-on: https://go-review.googlesource.com/c/go/+/714622
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 months agocmd/compile: change !l.nonzero() into l.maybezero()
Jorropo [Sat, 25 Oct 2025 06:41:50 +0000 (08:41 +0200)]
cmd/compile: change !l.nonzero() into l.maybezero()

  if l.maybezero()
is easier to read than
  if !l.nonzero()

Change-Id: I1183b0c0dc51fa1eed26dfc7a5a996783806a991
Reviewed-on: https://go-review.googlesource.com/c/go/+/714621
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 months agocmd/compile: optimize Add64carry with unused carries into plain Add64
Jorropo [Mon, 10 Mar 2025 08:27:39 +0000 (09:27 +0100)]
cmd/compile: optimize Add64carry with unused carries into plain Add64

Change-Id: I8a63f567cfc574bb066ad6269eec6929760cb9c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/656338
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 months agocmd/compile: remove 68857 ModU flowLimit workaround in prove
Jorropo [Sat, 25 Oct 2025 16:38:23 +0000 (18:38 +0200)]
cmd/compile: remove 68857 ModU flowLimit workaround in prove

We can know this is correct because all the testcases added by CL 605156 are still passing.
Partial revert of CL 605156 (everything but the testcases).

Change-Id: I5d8daadb4cb35a9de29daaabc22baee642511fe0
Reviewed-on: https://go-review.googlesource.com/c/go/+/714941
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/compile: remove 68857 min & max flowLimit workaround in prove
Jorropo [Sat, 25 Oct 2025 13:34:02 +0000 (15:34 +0200)]
cmd/compile: remove 68857 min & max flowLimit workaround in prove

We can know this is correct because all the testcases added by CL 656157 are still passing.
Partial revert of CL 656157 (everything but the testcases).

Change-Id: I24931fa1affba7e9e92233b3de74ebade3d48a09
Reviewed-on: https://go-review.googlesource.com/c/go/+/714921
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/compile: use topo-sort in prove to correctly learn facts while walking once
Jorropo [Sat, 25 Oct 2025 15:00:18 +0000 (17:00 +0200)]
cmd/compile: use topo-sort in prove to correctly learn facts while walking once

Fixes #68857

Change-Id: Ideb359cc6f1550afb4c79f02d25a00d0ae5e5c50
Reviewed-on: https://go-review.googlesource.com/c/go/+/714920
Reviewed-by: Michael Knyszek <mknyszek@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: Keith Randall <khr@google.com>
2 months agoruntime: avoid bound check in freebsd binuptime
Cuong Manh Le [Mon, 27 Oct 2025 09:47:20 +0000 (16:47 +0700)]
runtime: avoid bound check in freebsd binuptime

Fixes #76062

Change-Id: I683c1232aaeac12b0b3688472bb277adb95ad542
Reviewed-on: https://go-review.googlesource.com/c/go/+/715180
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
2 months agocmd/internal/obj, cmd/asm: reclassify the offset of memory access operations on loong64
Xiaolin Zhao [Wed, 24 Sep 2025 09:21:40 +0000 (17:21 +0800)]
cmd/internal/obj, cmd/asm: reclassify the offset of memory access operations on loong64

This CL also fixes the encoding error of LL/SC[V] instruction and
adds the handling of offset greater than 16 bits in MOV{W/V}P instructions.

Change-Id: I7a8fab4b68a6839da81c5e59af1f42289d00ef61
Reviewed-on: https://go-review.googlesource.com/c/go/+/706435
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 months agocmd/go: remove global loader state variable
Ian Alexander [Fri, 10 Oct 2025 12:59:21 +0000 (08:59 -0400)]
cmd/go: remove global loader state variable

Prior commits have removed all dependencies on the global module
loader state variable, so it is now unnecessary and thus removed.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: Idaf033ee703a18ffd29e40fad80ef13c7b33dbec
Reviewed-on: https://go-review.googlesource.com/c/go/+/711139
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>
2 months agocmd/go: use local state for telemetry
Ian Alexander [Fri, 10 Oct 2025 12:52:30 +0000 (08:52 -0400)]
cmd/go: use local state for telemetry

This change adds a new loader state to satisfy the requirements for
the (currently unused) telemetry stats for the go command.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: I6d4e38c91e5413d7649dfc6301e3ba35ee36c9b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/711136
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>

2 months agocmd/go: use tagged switch
Ian Alexander [Mon, 27 Oct 2025 16:34:54 +0000 (12:34 -0400)]
cmd/go: use tagged switch

Minor modernization to use a tagged switch statement in lieu of
if-else chain.

Change-Id: I132d279d421b4a609403f85f9f1ddfc2605a5399
Reviewed-on: https://go-review.googlesource.com/c/go/+/715341
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2 months agocmd/go: increase stmt threshold on amd64
Ian Alexander [Mon, 27 Oct 2025 16:32:23 +0000 (12:32 -0400)]
cmd/go: increase stmt threshold on amd64

This change slightly increases the stmt threshold on the amd64
platform.

Change-Id: I87e39753b52d6d72f2cd77f1cb8015b1e550921a
Reviewed-on: https://go-review.googlesource.com/c/go/+/715340
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/go: removed unused code in toolchain.Exec
Ian Alexander [Wed, 1 Oct 2025 21:42:38 +0000 (17:42 -0400)]
cmd/go: removed unused code in toolchain.Exec

This change removes the unused module loader state in the function
`toolchain.Exec`.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: I8935f14447db4669457becc5a96db7f45132772f
Reviewed-on: https://go-review.googlesource.com/c/go/+/709980
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 months agogo/types, types2: clarify docs for resolveUnderlying
Mark Freeman [Thu, 23 Oct 2025 20:25:28 +0000 (16:25 -0400)]
go/types, types2: clarify docs for resolveUnderlying

The resolveUnderlying method only detects cycles among type names, where
no type literal or predeclared type can be found (which would yield an
underlying type).

Change-Id: I203f3856eaf63a8a9d317c22521755390f9c1023
Reviewed-on: https://go-review.googlesource.com/c/go/+/714402
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>

2 months agogo/types, types2: wrap Named.fromRHS into Named.rhs
Mark Freeman [Thu, 23 Oct 2025 16:15:21 +0000 (12:15 -0400)]
go/types, types2: wrap Named.fromRHS into Named.rhs

In debug mode, the Named.rhs method asserts that Named is in a state
with Named.fromRHS populated.

This caught a missing call to Named.unpack in validtype, which has been
added.

Change-Id: Id3f95f78f03d98a6efe87af6ac24f2ac2e285f96
Reviewed-on: https://go-review.googlesource.com/c/go/+/714242
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>

2 months agogo/types, types2: verify stateMask transitions in debug mode
Mark Freeman [Wed, 22 Oct 2025 18:04:09 +0000 (14:04 -0400)]
go/types, types2: verify stateMask transitions in debug mode

Recently, we've changed the representation of Named type state from
an integer to a bit mask, which is a bit more complicated. To make
sure we uphold state invariants, we are adding a verification step
on each state transition.

This uncovered a few places where we do not uphold the transition
invariants; those are patched in this CL.

Change-Id: I76569e4326b2d362d7a1f078641029ffb3dca531
Reviewed-on: https://go-review.googlesource.com/c/go/+/714241
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>

2 months agonet/url: further speed up escape and unescape
Julien Cretel [Mon, 27 Oct 2025 12:40:37 +0000 (12:40 +0000)]
net/url: further speed up escape and unescape

This change is a follow-up to CL 712200. It further simplifies and speeds up
functions escape and unescape.

Here are some benchmark results (no change to allocations):

goos: darwin
goarch: amd64
pkg: net/url
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
                    │ go/src/old  │             go/src/new             │
                    │   sec/op    │   sec/op     vs base               │
QueryEscape/#00-8     34.58n ± 1%   31.97n ± 1%  -7.55% (p=0.000 n=20)
QueryEscape/#01-8     92.92n ± 0%   94.63n ± 0%  +1.84% (p=0.000 n=20)
QueryEscape/#02-8     75.44n ± 0%   73.32n ± 0%  -2.80% (p=0.000 n=20)
QueryEscape/#03-8     143.4n ± 0%   136.6n ± 0%  -4.71% (p=0.000 n=20)
QueryEscape/#04-8     918.8n ± 1%   838.3n ± 0%  -8.76% (p=0.000 n=20)
PathEscape/#00-8      43.93n ± 0%   42.86n ± 0%  -2.44% (p=0.000 n=20)
PathEscape/#01-8      94.99n ± 0%   95.86n ± 0%  +0.91% (p=0.000 n=20)
PathEscape/#02-8      75.40n ± 1%   71.50n ± 1%  -5.18% (p=0.000 n=20)
PathEscape/#03-8      143.4n ± 0%   136.2n ± 0%  -4.99% (p=0.000 n=20)
PathEscape/#04-8      871.8n ± 0%   822.7n ± 0%  -5.63% (p=0.000 n=20)
QueryUnescape/#00-8   52.64n ± 1%   51.19n ± 0%  -2.75% (p=0.000 n=20)
QueryUnescape/#01-8   137.4n ± 1%   137.9n ± 1%       ~ (p=0.297 n=20)
QueryUnescape/#02-8   114.0n ± 0%   122.3n ± 1%  +7.24% (p=0.000 n=20)
QueryUnescape/#03-8   271.8n ± 0%   260.7n ± 1%  -4.08% (p=0.000 n=20)
QueryUnescape/#04-8   1.390µ ± 1%   1.355µ ± 0%  -2.52% (p=0.000 n=20)
PathUnescape/#00-8    52.45n ± 1%   53.03n ± 1%  +1.10% (p=0.008 n=20)
PathUnescape/#01-8    138.5n ± 1%   141.3n ± 0%  +2.06% (p=0.000 n=20)
PathUnescape/#02-8    114.0n ± 0%   121.5n ± 0%  +6.62% (p=0.000 n=20)
PathUnescape/#03-8    273.1n ± 1%   260.1n ± 0%  -4.76% (p=0.000 n=20)
PathUnescape/#04-8    1.431µ ± 1%   1.359µ ± 0%  -5.07% (p=0.000 n=20)
geomean               160.4n        156.9n       -2.14%

Updates #17860

Change-Id: If64ac3e9c62c41f672db06cfd7eab7357e934e6d
GitHub-Last-Rev: 1da047ac75f9a710baf75a45d105db4dc7b81810
GitHub-Pull-Request: golang/go#76048
Reviewed-on: https://go-review.googlesource.com/c/go/+/714900
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2 months agoruntime: remove unused cgoCheckUsingType function
Ian Lance Taylor [Fri, 24 Oct 2025 21:57:55 +0000 (14:57 -0700)]
runtime: remove unused cgoCheckUsingType function

The only calls to it were removed in CL 616255.

Change-Id: I6c6b01e2e98d54300b6323fd74ccc45fa1d433dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/714820
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

2 months agotime: rewrite IsZero method to use wall and ext fields
baycore [Mon, 27 Oct 2025 04:43:32 +0000 (04:43 +0000)]
time: rewrite IsZero method to use wall and ext fields

Using wall and ext fields will be more efficient.

Fixes #76001

Change-Id: If2b9f597562e0d0d3f8ab300556fa559926480a0
GitHub-Last-Rev: 4a91948413079047cb6c382ed29844f456f3064d
GitHub-Pull-Request: golang/go#76006
Reviewed-on: https://go-review.googlesource.com/c/go/+/713720
Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
2 months agocmd/go: reorder parameters so that context is first
Ian Alexander [Fri, 24 Oct 2025 20:41:38 +0000 (16:41 -0400)]
cmd/go: reorder parameters so that context is first

This change simply reorders parameters so that the context.Context is
the first, as per standard practice.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: I22d366fb2d2457f44d668409da3fe76fb87180cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/714780
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 months agosync: update comments for Once.done
Jes Cok [Sat, 25 Oct 2025 16:41:11 +0000 (16:41 +0000)]
sync: update comments for Once.done

Sync with CL 666895.

Change-Id: I49c4a7f88d87cee9c30a858facd3cd8348efdf94
GitHub-Last-Rev: 88ac1c9c4131aa3f5dfb9c7923e49e46808c409d
GitHub-Pull-Request: golang/go#76026
Reviewed-on: https://go-review.googlesource.com/c/go/+/714360
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2 months agoruntime: add GOEXPERIMENT=runtimefree
thepudds [Sat, 25 Oct 2025 04:49:45 +0000 (00:49 -0400)]
runtime: add GOEXPERIMENT=runtimefree

This CL is part of a series of CLs to triangulate between the runtime,
compiler, and standard library to reduce how much work the GC must do.

An overall design document is in CL 700255.

This CL stack implements a runtime.free within the runtime, and
then uses it via automatic calls inserted by the compiler when
the compiler proves it is safe to do so. In the future, we can
also consider possibly a limited set of explicit calls from certain
low-level portions of the standard library.

When called, runtime.free allows immediate reuse of memory
without waiting for a GC cycle. The goals include less overall
CPU usage by the GC, longer times between GC cycles
(with less overall time with the write barrier enabled),
and more cache-friendly allocations for user code.

Here, we just add the GOEXPERIMENT=runtimefree flag. It currently
defaults to on, but can be disabled with GOEXPERIMENT=noruntimefree.

The actual implementation starts in CL 673695.

Updates #74299

Change-Id: I2f1f04dbdca51f4aaa735fd65bb2719c298d922e
Reviewed-on: https://go-review.googlesource.com/c/go/+/700235
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/compile: use MOV(D|F) with const for Const(64|32)F on riscv64
Meng Zhuo [Fri, 12 Sep 2025 09:45:56 +0000 (17:45 +0800)]
cmd/compile: use MOV(D|F) with const for Const(64|32)F on riscv64

The original Const64F using: AUIPC + LD + FMVDX to load
float64 const, we can use AUIPC + FLD instead, same as Const32F.

Change-Id: I8ca0a0e90d820a26e69b74cd25df3cc662132bf7
Reviewed-on: https://go-review.googlesource.com/c/go/+/703215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 months agointernal/chacha8rand: provide vector implementation for riscv64
Meng Zhuo [Fri, 3 Oct 2025 10:36:01 +0000 (18:36 +0800)]
internal/chacha8rand: provide vector implementation for riscv64

Provide a vector implementation of chacha8rand for riscv64,
which improves performance.

goos: linux
goarch: riscv64
pkg: internal/chacha8rand
cpu: Spacemit(R) X60
      │ /root/chacha8.rand.old.log │     /root/chacha8.rand.new.log      │
      │           sec/op           │   sec/op     vs base                │
Block                  1.640µ ± 0%   1.294µ ± 0%  -21.10% (p=0.000 n=10)

      │ /root/chacha8.rand.old.log │      /root/chacha8.rand.new.log      │
      │            B/s             │     B/s       vs base                │
Block                 148.9Mi ± 0%   188.6Mi ± 0%  +26.72% (p=0.000 n=10)

Change-Id: I1e04c5c44e5ce0c78814a6a48c5ab65e4d758937
Reviewed-on: https://go-review.googlesource.com/c/go/+/710035
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/go: use local loader state in test
Ian Alexander [Fri, 10 Oct 2025 12:58:31 +0000 (08:58 -0400)]
cmd/go: use local loader state in test

This change converts the import test to use a local module loader
state variable, instead of the dependency on global state.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: I5687090c160bf64ce36356768f7cf74333fab724
Reviewed-on: https://go-review.googlesource.com/c/go/+/711138
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/go: remove loaderstate dependency
Ian Alexander [Fri, 24 Oct 2025 16:52:37 +0000 (12:52 -0400)]
cmd/go: remove loaderstate dependency

This change removes the dependency on the module loader state from the
`QueryMatchesMainModulesError.Error()` method.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: I47241587a0bf9b578931628f35ed3b936a0cb04a
Reviewed-on: https://go-review.googlesource.com/c/go/+/714700
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>
2 months agocmd/go: remove unused loader state
Ian Alexander [Fri, 10 Oct 2025 12:57:52 +0000 (08:57 -0400)]
cmd/go: remove unused loader state

This test file does not make any use of the module loader state.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: I198c76aef9d9a87ae1a2299230f8a06d7a87767a
Reviewed-on: https://go-review.googlesource.com/c/go/+/711137
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
2 months agocmd/go: remove temporary rf cleanup script
Ian Alexander [Wed, 8 Oct 2025 23:22:59 +0000 (19:22 -0400)]
cmd/go: remove temporary rf cleanup script

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: I9d2deebafbbb374de2a1f9bae99e9caf417313a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/709991
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>

2 months agocmd/compile: allow unaligned load/store on Wasm
Cherry Mui [Fri, 24 Oct 2025 19:06:41 +0000 (15:06 -0400)]
cmd/compile: allow unaligned load/store on Wasm

Wasm supports unaligned load/store instructions. Use them.

This speeds up map hashing slightly (among others):
goos: js
goarch: wasm
pkg: runtime
                     │   old.txt   │               new.txt               │
                     │   sec/op    │   sec/op     vs base                │
Hash5                  14.06n ± 2%   13.83n ± 5%        ~ (p=0.186 n=10)
Hash16                 17.52n ± 1%   17.04n ± 1%   -2.71% (p=0.000 n=10)
Hash64                 28.68n ± 1%   26.61n ± 1%   -7.18% (p=0.000 n=10)
Hash1024               271.4n ± 0%   243.6n ± 1%  -10.21% (p=0.000 n=10)
Hash65536              16.66µ ± 0%   15.74µ ± 1%   -5.49% (p=0.000 n=10)
HashStringSpeed        29.23n ± 1%   28.70n ± 1%   -1.83% (p=0.000 n=10)
HashBytesSpeed         46.11n ± 4%   45.17n ± 5%   -2.04% (p=0.008 n=10)
HashInt32Speed         20.39n ± 1%   20.24n ± 5%        ~ (p=0.239 n=10)
HashInt64Speed         20.81n ± 7%   20.58n ± 7%        ~ (p=0.238 n=10)
HashStringArraySpeed   76.65n ± 2%   73.72n ± 1%   -3.83% (p=0.000 n=10)
FastrandHashiter       87.65n ± 1%   87.58n ± 1%        ~ (p=0.725 n=10)
geomean                67.03n        64.75n        -3.40%

Change-Id: I7fd1817c74323f628f310393b0330a0a51ffa3a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/714720
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/go: use local state object in work.runBuild and work.runInstall
Ian Alexander [Fri, 10 Oct 2025 02:08:58 +0000 (22:08 -0400)]
cmd/go: use local state object in work.runBuild and work.runInstall

This commit modifies `runBuild` and `runInstall` to construct a new
modload.State object using the new constructor instead of the current
global `modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/work
rf '
  add build.go:/func runBuild\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runBuild://+0 moduleLoaderState := modload.NewState()
  add runInstall://+0 moduleLoaderState := modload.NewState()
  rm build.go:/var moduleLoaderState \*modload.State/
'

Change-Id: I1137e0b898a5bda8697dce8713f96f238ae8b76c
Reviewed-on: https://go-review.googlesource.com/c/go/+/711135
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>

2 months agoruntime: add ppc and s390 to 32 build constraints for gccgo
Jorropo [Thu, 23 Oct 2025 08:55:56 +0000 (10:55 +0200)]
runtime: add ppc and s390 to 32 build constraints for gccgo

Theses are not supported by the go compiler but it may helps porting to gccgo.

I have no idea if this change is correct, but it is weird that
os_linux32.go and os_linux64.go should have ppc & s390 but not all other
files gated to 32bits in the same package.

Change-Id: I0bb70cdb88c19096386320d02d546942263e009d
Reviewed-on: https://go-review.googlesource.com/c/go/+/714082
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 months agoruntime: add ppc and s390 to linux 32 bits syscall build constraints for gccgo
Jorropo [Thu, 23 Oct 2025 08:47:58 +0000 (10:47 +0200)]
runtime: add ppc and s390 to linux 32 bits syscall build constraints for gccgo

Theses are not supported by the go compiler but it may helps porting to gccgo.

This is similar to reverting CL 712740 however unlike reverting:
- it fixes the build tags so that 32 & 64 bits
  constraints are complement of each other
- it applies the same changes to os_linux_settime32.go and
  os_linux_settime64.go since the four files are the exact same
  fix of the same bug to different parts of the codebase.
  It does not make sense for them to be different.

Change-Id: I08cdcb07e837a5e06ee6f04b7868a4c57b07dd56
Reviewed-on: https://go-review.googlesource.com/c/go/+/714080
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/go: use local state object in `generate.runGenerate`
Ian Alexander [Fri, 10 Oct 2025 01:10:56 +0000 (21:10 -0400)]
cmd/go: use local state object in `generate.runGenerate`

This commit modifies `generate.runGenerate` to construct a new
modload.State object using the new constructor instead of the current
global `modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/generate
rf '
  add generate.go:/func runGenerate\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runGenerate://+0 moduleLoaderState := modload.NewState()
  rm generate.go:/var moduleLoaderState \*modload.State/
'

Change-Id: Iea9d662ba47657aa5daa70d32117cdf52fd02b7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/711132
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>

2 months agocmd/go: use local state object in `env.runEnv`
Ian Alexander [Fri, 10 Oct 2025 01:05:35 +0000 (21:05 -0400)]
cmd/go: use local state object in `env.runEnv`

This commit modifies `env.runEnv` to construct a new modload.State
object using the new constructor instead of the current global
`modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/envcmd
rf '
  add env.go:/func runEnv\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runEnv://+0 moduleLoaderState := modload.NewState()
  rm env.go:/var moduleLoaderState \*modload.State/
'

Change-Id: I1177df5d09a6ee642eade6cfa4278bb1629843a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/711131
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>

2 months agocmd/go: use local state object in `vet.runVet`
Ian Alexander [Fri, 10 Oct 2025 00:22:22 +0000 (20:22 -0400)]
cmd/go: use local state object in `vet.runVet`

This commit modifies `vet.runVet` to construct a new modload.State
object using the new constructor instead of the current global
`modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/vet
rf '
  add vet.go:/func run\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add run://+0 moduleLoaderState := modload.NewState()
  rm vet.go:/var moduleLoaderState \*modload.State/
'

Change-Id: I31c7f3ea8d301b9210f5afeb632afb5b53e93e46
Reviewed-on: https://go-review.googlesource.com/c/go/+/711130
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 months agocmd/go: use local state object in pkg `workcmd`
Ian Alexander [Thu, 9 Oct 2025 00:26:24 +0000 (20:26 -0400)]
cmd/go: use local state object in pkg `workcmd`

This commit modifies package `workcmd` to construct a new
modload.State object using the new constructor instead of the current
global `modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/workcmd
rf '
  inject modload.LoaderState runUse
  add sync.go:/func runSync\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runSync://+0 moduleLoaderState := modload.NewState()
  add runEditwork://+0 moduleLoaderState := modload.NewState()
  add runInit://+0 moduleLoaderState := modload.NewState()
  add runUse://+0 moduleLoaderState := modload.NewState()
  add runVendor://+0 moduleLoaderState := modload.NewState()
  rm sync.go:/var moduleLoaderState \*modload.State/
'

Change-Id: Iadc4ffd19d15f80a694285c86adfc01f0d26bac7
Reviewed-on: https://go-review.googlesource.com/c/go/+/711129
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>

2 months agocmd/go: use local state object in `tool.runTool`
Ian Alexander [Thu, 9 Oct 2025 00:23:24 +0000 (20:23 -0400)]
cmd/go: use local state object in `tool.runTool`

This commit modifies `tool.runTool` to construct a new modload.State
object using the new constructor instead of the current global
`modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/tool
rf '
  add tool.go:/func runTool\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runTool://+0 moduleLoaderState := modload.NewState()
  rm tool.go:/var moduleLoaderState \*modload.State/
'

Change-Id: I0aff1bc2b57d973c258510dc52fb877fa824355c
Reviewed-on: https://go-review.googlesource.com/c/go/+/711128
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 months agocmd/go: use local state object in `test.runTest`
Ian Alexander [Thu, 9 Oct 2025 00:21:59 +0000 (20:21 -0400)]
cmd/go: use local state object in `test.runTest`

This commit modifies `test.runTest` to construct a new modload.State
object using the new constructor instead of the current global
`modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/test
rf '
  add test.go:/func runTest\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runTest://+0 moduleLoaderState := modload.NewState()
  rm test.go:/var moduleLoaderState \*modload.State/
'

Change-Id: Ia387160f30818714ab578c5b78713e532cd394df
Reviewed-on: https://go-review.googlesource.com/c/go/+/711127
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
2 months agocmd/go: use local state object in `modget.runGet`
Ian Alexander [Thu, 9 Oct 2025 00:20:22 +0000 (20:20 -0400)]
cmd/go: use local state object in `modget.runGet`

This commit modifies `modget.runGet` to construct a new modload.State
object using the new constructor instead of the current global
`modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/modget
rf '
  add get.go:/func runGet\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runGet://+0 moduleLoaderState := modload.NewState()
  rm get.go:/var moduleLoaderState \*modload.State/
'

Change-Id: I977c3f57c00b60d383ffd2c2c0d7bc90813c7988
Reviewed-on: https://go-review.googlesource.com/c/go/+/711126
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
2 months agocmd/go: use local state object in pkg `modcmd`
Ian Alexander [Thu, 9 Oct 2025 00:03:54 +0000 (20:03 -0400)]
cmd/go: use local state object in pkg `modcmd`

This commit modifies `modcmd.runDownload` to construct a new
modload.State object using the new constructor instead of the current
global `modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/modcmd
rf '
  add download.go:/func runDownload\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runDownload://+0 moduleLoaderState := modload.NewState()
  add runEdit://+0 moduleLoaderState := modload.NewState()
  add runGraph://+0 moduleLoaderState := modload.NewState()
  add runInit://+0 moduleLoaderState := modload.NewState()
  add runTidy://+0 moduleLoaderState := modload.NewState()
  add runVendor://+0 moduleLoaderState := modload.NewState()
  add runVerify://+0 moduleLoaderState := modload.NewState()
  add runWhy://+0 moduleLoaderState := modload.NewState()
  rm download.go:/var moduleLoaderState \*modload.State/
'

Change-Id: Id69deba173032a4d6da228eae28e38bd87176db5
Reviewed-on: https://go-review.googlesource.com/c/go/+/711125
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/go: use local state object in `list.runList`
Ian Alexander [Thu, 9 Oct 2025 00:02:36 +0000 (20:02 -0400)]
cmd/go: use local state object in `list.runList`

This commit modifies `list.runList` to construct a new modload.State
object using the new constructor instead of the current global
`modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/list
rf '
  add list.go:/func runList\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runList://+0 moduleLoaderState := modload.NewState()
  rm list.go:/var moduleLoaderState \*modload.State/
'

Change-Id: I7f45205c1c946189eb05c6178d14ce74ae259547
Reviewed-on: https://go-review.googlesource.com/c/go/+/711124
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/go: use local state object in `bug.runBug`
Ian Alexander [Wed, 8 Oct 2025 23:56:51 +0000 (19:56 -0400)]
cmd/go: use local state object in `bug.runBug`

This commit modifies `bug.runBug` to construct a new modload.State
object using the new constructor instead of the current global
`modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/bug
rf '
  add bug.go:/func runBug\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runBug://+0 moduleLoaderState := modload.NewState()
  rm bug.go:/var moduleLoaderState \*modload.State/
'

Change-Id: Ic4f74d2127f667491136ee4bad4388b4d606821e
Reviewed-on: https://go-review.googlesource.com/c/go/+/711123
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
2 months agocmd/go: use local state object in `run.runRun`
Ian Alexander [Thu, 2 Oct 2025 16:52:26 +0000 (12:52 -0400)]
cmd/go: use local state object in `run.runRun`

This commit modifies `run.runRun` to construct a new modload.State
object using the new constructor instead of the current global
`modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/run
rf '
  add run.go:/func runRun\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runRun://+0 moduleLoaderState := modload.NewState()
  rm run.go:/var moduleLoaderState \*modload.State/
'

Change-Id: I76e56798b2e0d23a0fefe65d997740e3e411d99d
Reviewed-on: https://go-review.googlesource.com/c/go/+/711116
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>

2 months agocmd/go: add loaderstate as field on `mvsReqs`
Ian Alexander [Thu, 2 Oct 2025 19:31:10 +0000 (15:31 -0400)]
cmd/go: add loaderstate as field on `mvsReqs`

This change modifies the type `mvsReqs` to have an additional field to
store the current module loader state.  The field is used to break the
dependency on the global `modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: Id6bd96bc5de68bf327f9e78a778173634e1d15d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/711122
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>

2 months agocmd/go: make ImportMissingError work with local state
Ian Alexander [Fri, 3 Oct 2025 04:50:03 +0000 (00:50 -0400)]
cmd/go: make ImportMissingError work with local state

This change adds fields to the type `ImportMissingError` so
that the `Error()` method can be called without accessing the global
`LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: Ib313faeb27ae44e9ac68086313633ce742f596dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/711121
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>
2 months agodebug/pe: check for zdebug_gdb_scripts section in testDWARF
Cherry Mui [Fri, 24 Oct 2025 20:27:15 +0000 (16:27 -0400)]
debug/pe: check for zdebug_gdb_scripts section in testDWARF

The debug_gdb_scripts sectino may or may not be compressed. Check
for both.

For #76022.

Change-Id: I7541e0aa2b90f6b3b694e02d3dfa99f9019a9e5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/714461
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 months agoruntime: use 32-bit hash for maps on Wasm
Cherry Mui [Fri, 24 Oct 2025 16:04:44 +0000 (12:04 -0400)]
runtime: use 32-bit hash for maps on Wasm

Currently we use 64-bit hash calculations on Wasm. The 64-bit hash
calculation make intensive uses of 64x64->128 bit multiplications,
which on many 64-bit platforms are compiler intrinsics and can be
compiled to one or two instructions. This is not the case on Wasm,
so it is not very performant.

This CL makes it use 32-bit hashes on Wasm, just like other 32-bit
architectures. The 32-bit hash calculation only uses 32x32->64 bit
multiplications, which can be compiled efficiently on Wasm.

Using 32-bit hashes may increase the chance of collisions. But it
is the same as 32-bit architectures like 386. And our Wasm port
supports only 32-bit address space (like 386), so this is not too
bad.

Runtime Hash benchmark results
goos: js
goarch: wasm
pkg: runtime
                     │   0h.txt    │               1h.txt                │
                     │   sec/op    │   sec/op     vs base                │
Hash5                  20.45n ± 9%   14.06n ± 2%  -31.21% (p=0.000 n=10)
Hash16                 22.34n ± 7%   17.52n ± 1%  -21.62% (p=0.000 n=10)
Hash64                 47.47n ± 3%   28.68n ± 1%  -39.59% (p=0.000 n=10)
Hash1024               475.4n ± 1%   271.4n ± 0%  -42.92% (p=0.000 n=10)
Hash65536              28.42µ ± 1%   16.66µ ± 0%  -41.40% (p=0.000 n=10)
HashStringSpeed        40.07n ± 7%   29.23n ± 1%  -27.05% (p=0.000 n=10)
HashBytesSpeed         62.01n ± 3%   46.11n ± 4%  -25.64% (p=0.000 n=10)
HashInt32Speed         24.31n ± 2%   20.39n ± 1%  -16.13% (p=0.000 n=10)
HashInt64Speed         25.48n ± 7%   20.81n ± 7%  -18.29% (p=0.000 n=10)
HashStringArraySpeed   87.69n ± 4%   76.65n ± 2%  -12.58% (p=0.000 n=10)
FastrandHashiter       87.65n ± 1%   87.65n ± 1%        ~ (p=0.896 n=10)
geomean                90.82n        67.03n       -26.19%

Map benchmarks are too many to post here. The speedups are around
0-40%.

Change-Id: I2f7a68cfc446ab5a547fdb6a40aea07854516d51
Reviewed-on: https://go-review.googlesource.com/c/go/+/714600
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 months agoencoding/json/v2: fix typo in documentation about errors.AsType
Joe Tsai [Fri, 24 Oct 2025 17:55:48 +0000 (10:55 -0700)]
encoding/json/v2: fix typo in documentation about errors.AsType

CL 708495 mass migrated the stdlib to use errors.AsType.
It rewrote the documentation, but uses the non-pointer type
of SemanticError or SyntacticError, which is invalid since
the Error method is declared on the pointer receiver.

Also, call errors.AsType on a separate line for readability.

Change-Id: I2eaf59614e2b58aa4bc8669ab81ce64168c54f13
Reviewed-on: https://go-review.googlesource.com/c/go/+/714660
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocmd/link: remove pointless assignment in SetSymAlign
Ian Lance Taylor [Fri, 24 Oct 2025 00:25:52 +0000 (17:25 -0700)]
cmd/link: remove pointless assignment in SetSymAlign

This code path became useless after CL 231220.

Change-Id: I35c25368652eeb107350dcd9d1b283429ad3d5e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/714500
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 months agocrypto/x509: move constraint checking after chain building
Roland Shoemaker [Mon, 20 Oct 2025 18:04:38 +0000 (11:04 -0700)]
crypto/x509: move constraint checking after chain building

The standard approach to constraint checking involves checking the
constraints during chain building. This is typically done as most chain
building algorithms want to find a single chain. We don't do this, and
instead build every valid chain we can find. Because of this, we don't
_need_ to do constraint checking during the chain building stage, and
instead can defer it until we have built all of the potentially valid
chains (we already do this for EKU nesting and policy checking).

This allows us to limit the constraints we check to only chains issued
by trusted roots, which reduces the attack surface for constraint
checking, which is an annoyingly algorithmically complex process (for
now).

To maintain previous behavior, if we see an error during constraint
checking, and we end up with no valid chains, we return the first
constraint checking error, instead of a more verbose error indicating
if there were different problems during filtering. At some point we
probably should come up with a more unified error type for chain
building that can contain information about multiple failure modes.

Change-Id: I5780b3adce8538eb4c3b56ddec52f0723d39009e
Reviewed-on: https://go-review.googlesource.com/c/go/+/713240
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
2 months agoencoding/json/jsontext: avoid pinning application data in pools
Joe Tsai [Tue, 21 Oct 2025 22:11:32 +0000 (15:11 -0700)]
encoding/json/jsontext: avoid pinning application data in pools

Previously, we put a jsontext.Encoder (or Decoder)
back into a pool with minimal reset logic.
This was semantically safe since we always did a full reset
after obtaining an Encoder/Decoder back out of the pool.

However, this meant that so long as an Encoder/Decoder was
alive in the pool, any application data referenced by the coder
would be kept alive longer than necessary.
Explicitly, clear such fields so that application data
can be more aggressively garbage collected.

Performance:

name               old time/op    new time/op    delta
Unmarshal/Bool-32    52.0ns ± 3%    50.3ns ± 3%  -3.30%  (p=0.001 n=10+10)
Marshal/Bool-32      55.4ns ± 3%    54.4ns ± 2%  -1.75%  (p=0.006 n=10+9)

This only impacts the performance of discrete Marshal/Unmarshal calls.
For the simplest possible call (i.e., to marsha/unmarshal a bool),
there is a 1-2ns slow down. This is an appropriate slowdown
for an improvement in memory utilization.

Change-Id: I5e7d7827473773e53a9dcb3d7fe9052a75481e9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/713640
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Bypass: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Auto-Submit: Damien Neil <dneil@google.com>

2 months agoencoding/json/v2: use slices.Sort directly
Joe Tsai [Tue, 21 Oct 2025 17:39:15 +0000 (10:39 -0700)]
encoding/json/v2: use slices.Sort directly

This is semantically identical and just a cleanup.

Prior to #63397, JSON object names were sorted according to UTF-16
to match the semantic of RFC 8785, but there were a number of
objections in the discussion to using that as the sorting order.

In https://github.com/go-json-experiment/json/pull/121,
we switched to sorting by UTF-8, which matches the behavior
of v1 and avoids an option to toggle the behavior.
However, we should have deleted the stringSlice.Sort method
and just directly called slices.Sort.

From a principled perspective, both UTF-16 and UTF-8 are
reasonable ways to sort JSON object names.
RFC 8259 specifies that the entire JSON text is encoded as UTF-8.
However, the way JSON strings are encoded requires escaping
Unicode codepoints according to UTF-16 surragate halves
(a quirk of JavaScript inherited by JSON).
Thus, JSON is inconsistently both UTF-8 and UTF-16.

Change-Id: Id92b5cc20efe4201827e9d3fccf24ccf894d3e60
Reviewed-on: https://go-review.googlesource.com/c/go/+/713522
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Damien Neil <dneil@google.com>
2 months agocrypto/x509: simplify candidate chain filtering
Roland Shoemaker [Wed, 1 Oct 2025 15:57:00 +0000 (08:57 -0700)]
crypto/x509: simplify candidate chain filtering

Use slices.DeleteFunc to remove chains with invalid policies and
incompatible key usage, instead of iterating over the chains and
reconstructing the slice.

Change-Id: I8ad2bc1ac2469d0d18b2c090e3d4f702b1b577cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/708415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: David Chase <drchase@google.com>
2 months agocmd/go: refactor injection of modload.LoaderState
Ian Alexander [Tue, 7 Oct 2025 16:57:12 +0000 (12:57 -0400)]
cmd/go: refactor injection of modload.LoaderState

This change refactors the injection of the global
`modload.LoaderState` variable such that the injection can occur later
in the chain of function calls.  This allows us to keep the behavior
of the global PerPackageFlags (e.g. BuildGcFlags, etc) consistent and
avoid introducing a dependency on the module loader state there.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: I1a0cc07173a1804426392581ba8de4ae1e30cdef
Reviewed-on: https://go-review.googlesource.com/c/go/+/711115
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
2 months agocmd/go: make ErrNoModRoot work with local state
Ian Alexander [Fri, 3 Oct 2025 04:31:26 +0000 (00:31 -0400)]
cmd/go: make ErrNoModRoot work with local state

This change reworks the sentinel error value ErrNoModRoot and the type
noMainModulesError so that we can determine the appropriate error
message to display based on the loader state without depending on the
state directly.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: I64de433faca96ed90fad4c153766c50575a72157
Reviewed-on: https://go-review.googlesource.com/c/go/+/711120
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 months agocmd/go: add modload.State parameter to AllowedFunc
Ian Alexander [Fri, 3 Oct 2025 02:52:08 +0000 (22:52 -0400)]
cmd/go: add modload.State parameter to AllowedFunc

This change makes the following functions methods on the State:
  * CheckAllowed
  * CheckExclusions
  * CheckRetractions

Doing so allows us to reduce the use of the global state variable in
downstream function calls.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: I97147311d9de16ecac8c122c2b6bdde94bad9d8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/711119
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>

2 months agocmd/go: add loaderstate as field on `QueryMatchesMainModulesError`
Ian Alexander [Thu, 2 Oct 2025 20:56:19 +0000 (16:56 -0400)]
cmd/go: add loaderstate as field on `QueryMatchesMainModulesError`

This change modifies the type `QueryMatchesMainModulesError` to have
an additional field to store the current module loader state.  The
field is used to break the dependency on the global
`modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: Ia2066fab9f3ec4ffdd3d7393dacdf65c0fd35b92
Reviewed-on: https://go-review.googlesource.com/c/go/+/711118
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 months agocmd/go: remove module loader state from ccompile
Ian Alexander [Fri, 10 Oct 2025 02:38:37 +0000 (22:38 -0400)]
cmd/go: remove module loader state from ccompile

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: Iff90d83b440b39df3d598f5a999e270baa893e24
Reviewed-on: https://go-review.googlesource.com/c/go/+/711134
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
2 months agocmd/go: inject vendor dir into builder struct
Ian Alexander [Fri, 10 Oct 2025 01:01:05 +0000 (21:01 -0400)]
cmd/go: inject vendor dir into builder struct

This change adds a new field to the Builder struct to store a function
to retrieve the current vendor directory.  This allows us to delay the
determination of the vendor directory until later, which is currently
necessary to successful interaction with the module loader state.
This behavior will be changed in a future CL and the Builder field
will then be removed.

In addition, a new method to get the vendor dir from the module loader
state is added that will return the empty string instead of panicing.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: Ib0165edb9502d98ddfa986acf5579c1b746a026f
Reviewed-on: https://go-review.googlesource.com/c/go/+/711133
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

2 months agocrypto/pbkdf2: add missing error return value in example
Felix Stein [Thu, 23 Oct 2025 20:27:03 +0000 (20:27 +0000)]
crypto/pbkdf2: add missing error return value in example

This function returns two values, one was missing in the example.

Change-Id: I738597f959011260f666c29b7d3ffad8e5cdc473
GitHub-Last-Rev: 5d99e04f7e1168fd0627e965508181bdb9d1ac25
GitHub-Pull-Request: golang/go#76032
Reviewed-on: https://go-review.googlesource.com/c/go/+/714420
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
2 months agounique: fix inconsistent panic prefix in canonmap cleanup path
mohanson [Wed, 22 Oct 2025 02:37:49 +0000 (10:37 +0800)]
unique: fix inconsistent panic prefix in canonmap cleanup path

Other panic messages in the file use the "unique.canonMap"
prefix, but this one used "internal/sync.HashTrieMap",
looks like it was copied from the "internal/sync" package.

Change-Id: Ic3e85154eb5a593d41c19013d5696afed2178b7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/713660
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
2 months agogo/types, types2: rename Named.resolve to unpack
Mark Freeman [Mon, 20 Oct 2025 21:00:03 +0000 (17:00 -0400)]
go/types, types2: rename Named.resolve to unpack

Named.resolve normalizes a named type's representation so that type
operations have a uniform surface to work with, regardless of how
the type was created.

This often gives the type a heavier footprint, such as when filling
in a lazy-loaded type from UIR, or expanding the RHS of an
instantiated type.

For that reason, it seems more appropriate to call this "unpacking"
the type, as it hints to this heavier form. The term "resolving"
is used in many contexts, and generally suggests that we are
trying to figure out what a name means.

Change-Id: Ia733fd68656380b2be4f7433b7b971b7c1422783
Reviewed-on: https://go-review.googlesource.com/c/go/+/713285
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>