Skip to content

Commit

Permalink
fix compile fail
Browse files Browse the repository at this point in the history
  • Loading branch information
qiulaidongfeng committed Dec 17, 2023
1 parent a441526 commit fba087a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cmd/compile/internal/walk/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"go/constant"
"go/token"
"internal/abi"
"strings"

"cmd/compile/internal/base"
Expand Down Expand Up @@ -321,7 +322,7 @@ func walkMakeMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
// Maximum key and elem size is 128 bytes, larger objects
// are stored with an indirection. So max bucket size is 2048+eps.
if !ir.IsConst(hint, constant.Int) ||
constant.Compare(hint.Val(), token.LEQ, constant.MakeInt64(reflectdata.BUCKETSIZE)) {
constant.Compare(hint.Val(), token.LEQ, constant.MakeInt64(abi.MapBucketCount)) {

// In case hint is larger than BUCKETSIZE runtime.makemap
// will allocate the buckets on the heap, see #20184
Expand All @@ -332,7 +333,7 @@ func walkMakeMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
// h.buckets = b
// }

nif := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OLE, hint, ir.NewInt(base.Pos, reflectdata.BUCKETSIZE)), nil, nil)
nif := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OLE, hint, ir.NewInt(base.Pos, abi.MapBucketCount)), nil, nil)
nif.Likely = true

// var bv bmap
Expand All @@ -347,7 +348,7 @@ func walkMakeMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
}
}

if ir.IsConst(hint, constant.Int) && constant.Compare(hint.Val(), token.LEQ, constant.MakeInt64(reflectdata.BUCKETSIZE)) {
if ir.IsConst(hint, constant.Int) && constant.Compare(hint.Val(), token.LEQ, constant.MakeInt64(abi.MapBucketCount)) {
// Handling make(map[any]any) and
// make(map[any]any, hint) where hint <= BUCKETSIZE
// special allows for faster map initialization and
Expand Down

0 comments on commit fba087a

Please sign in to comment.