-
Notifications
You must be signed in to change notification settings - Fork 6
icall: replace map with slice #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ jobs: | |
| Test-MacOS: | ||
| strategy: | ||
| matrix: | ||
| go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x, 1.24.x, 1.25.x, 1.26.x] | ||
| go-version: [1.21.x, 1.22.x, 1.23.x, 1.24.x, 1.25.x, 1.26.x] | ||
| runs-on: macos-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
@@ -29,7 +29,7 @@ jobs: | |
| Test-Linux: | ||
| strategy: | ||
| matrix: | ||
| go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x, 1.24.x, 1.25.x, 1.26.x] | ||
| go-version: [1.21.x, 1.22.x, 1.23.x, 1.24.x, 1.25.x, 1.26.x] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
@@ -51,7 +51,7 @@ jobs: | |
| Test-Windows: | ||
| strategy: | ||
| matrix: | ||
| go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x, 1.24.x, 1.25.x, 1.26.x] | ||
| go-version: [1.21.x, 1.22.x, 1.23.x, 1.24.x, 1.25.x, 1.26.x] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI breakage: Windows matrix not updated. Same issue as the Linux job above — still includes Go 1.18/1.19/1.20 which will fail to compile this module. |
||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| *.dll | ||
| *.so | ||
| *.dylib | ||
| .DS_Store | ||
|
|
||
| # Test binary, built with `go test -c` | ||
| *.test | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ Golang reflect package hack tools | |
|
|
||
| ### Go Version | ||
|
|
||
| - Go1.18 ~ Go1.26 | ||
| - Go1.21 ~ Go1.26 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The top-level Go version line is correctly updated, but the ABI table a few lines below still documents per-platform behaviour starting at Go 1.18 and Go 1.19 — both below the new minimum. Those rows will never apply to users of this module now. Consider removing or collapsing them. |
||
| - macOS Linux Windows WebAssembly | ||
|
|
||
| ### ABI | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| //go:build !go1.17 || (go1.17 && !go1.18 && !goexperiment.regabireflect) || (go1.18 && !go1.19 && !goexperiment.regabireflect && !amd64) || (go1.19 && !go1.20 && !goexperiment.regabiargs && !amd64 && !arm64 && !ppc64 && !ppc64le) || (go1.20 && !goexperiment.regabiargs && !amd64 && !arm64 && !ppc64 && !ppc64le && !riscv64) || (go1.22 && !goexperiment.regabiargs && !amd64 && !arm64 && !ppc64 && !ppc64le && !riscv64 && !loong64) | ||
| // +build !go1.17 go1.17,!go1.18,!goexperiment.regabireflect go1.18,!go1.19,!goexperiment.regabireflect,!amd64 go1.19,!go1.20,!goexperiment.regabiargs,!amd64,!arm64,!ppc64,!ppc64le go1.20,!goexperiment.regabiargs,!amd64,!arm64,!ppc64,!ppc64le,!riscv64 go1.22,!goexperiment.regabiargs,!amd64,!arm64,!ppc64,!ppc64le,!riscv64,!loong64 | ||
| //go:build !goexperiment.regabiargs && !amd64 && !arm64 && !ppc64 && !ppc64le && !riscv64 && !(go1.23 && loong64) | ||
| // +build !goexperiment.regabiargs | ||
| // +build !amd64 | ||
| // +build !arm64 | ||
| // +build !ppc64 | ||
| // +build !ppc64le | ||
| // +build !riscv64 | ||
| // +build !go1.23 !loong64 | ||
|
|
||
| package $pkgname | ||
|
|
||
|
|
@@ -13,12 +19,14 @@ import ( | |
| const capacity = $max_size | ||
|
|
||
| type provider struct { | ||
| used map[int]*abi.MethodInfo | ||
| used []*abi.MethodInfo | ||
| n int | ||
| } | ||
|
|
||
| func (p *provider) Insert(info *abi.MethodInfo) (ifn unsafe.Pointer, index int) { | ||
| for i := 0; i < capacity; i++ { | ||
| if _, ok := p.used[i]; !ok { | ||
| if p.used[i] == nil { | ||
| p.n++ | ||
| p.used[i] = info | ||
| fn := icall_array[i] | ||
| return unsafe.Pointer(reflect.ValueOf(fn).Pointer()), i | ||
|
Comment on lines
26
to
32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
@@ -28,30 +36,34 @@ func (p *provider) Insert(info *abi.MethodInfo) (ifn unsafe.Pointer, index int) | |
| } | ||
|
|
||
| func (p *provider) Available() int { | ||
| return capacity - len(p.used) | ||
| return capacity - p.n | ||
| } | ||
|
|
||
| func (p *provider) Remove(indexs []int) { | ||
| for _, n := range indexs { | ||
| delete(p.used, n) | ||
| if n < capacity && p.used[n] != nil { | ||
| p.used[n] = nil | ||
| p.n-- | ||
| } | ||
| } | ||
|
Comment on lines
43
to
48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current implementation of for _, n := range indexs {
if p.used[n] != nil {
p.used[n] = nil
p.n--
}
} |
||
| } | ||
|
|
||
| func (p *provider) Used() int { | ||
| return len(p.used) | ||
| return p.n | ||
| } | ||
|
|
||
| func (p *provider) Cap() int { | ||
| return len(icall_array) | ||
| return capacity | ||
| } | ||
|
|
||
| func (p *provider) Clear() { | ||
| p.used = make(map[int]*abi.MethodInfo) | ||
| clear(p.used) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| p.n = 0 | ||
| } | ||
|
|
||
| var ( | ||
| mp = &provider{ | ||
| used: make(map[int]*abi.MethodInfo), | ||
| used: make([]*abi.MethodInfo, capacity), | ||
| } | ||
| ) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| //go:build (go1.17 && goexperiment.regabireflect) || (go1.19 && goexperiment.regabiargs) || (go1.18 && amd64) || (go1.19 && arm64) || (go1.19 && ppc64) || (go1.19 && ppc64le) || (go1.20 && riscv64) || (go1.23 && loong64) | ||
| // +build go1.17,goexperiment.regabireflect go1.19,goexperiment.regabiargs go1.18,amd64 go1.19,arm64 go1.19,ppc64 go1.19,ppc64le go1.20,riscv64 go1.23,loong64 | ||
| //go:build goexperiment.regabiargs || amd64 || arm64 || ppc64 || ppc64le || riscv64 || (go1.23 && loong64) | ||
| // +build goexperiment.regabiargs amd64 arm64 ppc64 ppc64le riscv64 go1.23,loong64 | ||
|
|
||
| package $pkgname | ||
|
|
||
|
|
@@ -18,7 +18,8 @@ type methodUsed struct { | |
| } | ||
|
|
||
| type provider struct { | ||
| used map[int]*methodUsed | ||
| used []*methodUsed | ||
| n int | ||
| } | ||
|
|
||
| func i_x(c unsafe.Pointer, frame unsafe.Pointer, retValid *bool, r unsafe.Pointer, index int) { | ||
|
|
@@ -33,7 +34,7 @@ func unspillArgs() | |
| func (p *provider) Insert(info *abi.MethodInfo) (unsafe.Pointer, int) { | ||
| var index = -1 | ||
| for i := 0; i < capacity; i++ { | ||
| if _, ok := p.used[i]; !ok { | ||
| if p.used[i] == nil { | ||
| index = i | ||
| break | ||
| } | ||
|
|
@@ -74,35 +75,40 @@ func (p *provider) Insert(info *abi.MethodInfo) (unsafe.Pointer, int) { | |
| fun: fn, | ||
| ptr: (*struct{ typ, ptr unsafe.Pointer })(unsafe.Pointer(&fn)).ptr, | ||
| } | ||
| p.n++ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The counter |
||
| icall := icall_fn[index] | ||
| return unsafe.Pointer(reflect.ValueOf(icall).Pointer()), index | ||
| } | ||
|
|
||
| func (p *provider) Remove(indexs []int) { | ||
| for _, n := range indexs { | ||
| delete(p.used, n) | ||
| if n < capacity && p.used[n] != nil { | ||
| p.used[n] = nil | ||
| p.n-- | ||
| } | ||
| } | ||
|
Comment on lines
84
to
89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current implementation of for _, n := range indexs {
if p.used[n] != nil {
p.used[n] = nil
p.n--
}
}
Comment on lines
83
to
89
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
| } | ||
|
|
||
| func (p *provider) Available() int { | ||
| return capacity - len(p.used) | ||
| return capacity - p.n | ||
| } | ||
|
|
||
| func (p *provider) Used() int { | ||
| return len(p.used) | ||
| return p.n | ||
| } | ||
|
|
||
| func (p *provider) Cap() int { | ||
| return capacity | ||
| } | ||
|
|
||
| func (p *provider) Clear() { | ||
| p.used = make(map[int]*methodUsed) | ||
| clear(p.used) | ||
| p.n = 0 | ||
| } | ||
|
|
||
| var ( | ||
| mp = &provider{ | ||
| used: make(map[int]*methodUsed), | ||
| used: make([]*methodUsed, capacity), | ||
| } | ||
| ) | ||
|
|
||
|
|
||
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI breakage: Linux matrix not updated. This job still includes
1.18.x,1.19.x,1.20.x, butgo.modnow requires Go 1.21 andclear()(added in 1.21) is used throughout — these versions will fail at compile time. The MacOS matrix was updated in this PR but Linux (here) and Windows (line ~54) were not. Both should be updated to match:[1.21.x, 1.22.x, 1.23.x, 1.24.x, 1.25.x, 1.26.x].