Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/cmd/cgo/internal/testplugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,14 @@ func TestIssue75102(t *testing.T) {
goCmd(t, "build", "-o", "issue75102.exe", "./issue75102/main.go")
run(t, "./issue75102.exe")
}

func TestIssue81303(t *testing.T) {
// Issue 81303: the itab copies of a plugin must not hide the itabs
// of the host for the same interface/type pairs.
globalSkip(t)
goCmd(t, "build", "-buildmode=plugin", "-o", "issue81303p1.so", "./issue81303/plugin1.go")
goCmd(t, "build", "-buildmode=plugin", "-o", "issue81303p2.so", "./issue81303/plugin2.go")
goCmd(t, "build", "-buildmode=plugin", "-o", "issue81303p3.so", "./issue81303/plugin3.go")
goCmd(t, "build", "-o", "issue81303.exe", "./issue81303/main.go")
run(t, "./issue81303.exe")
}
39 changes: 39 additions & 0 deletions src/cmd/cgo/internal/testplugin/testdata/issue81303/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Issue 81303: a plugin has its own copies of the itabs of the host.
// The runtime added these copies to the itab table as second entries
// for the same interface/type pairs. After the table grew, a lookup
// could return the copy from the plugin. A type switch compares the
// itab with the itab of the host, so it took the default case.
//
// Each plugin imports package p, which uses go/ast, so each plugin
// adds a copy of every go/ast itab of the host. The host walks a
// syntax tree before and after each plugin loads. The three plugins
// are the same because plugin.Open loads a plugin path only once.

package main

import (
"log"
"plugin"

"testplugin/issue81303/p"
)

func main() {
p.Walk()
for _, name := range []string{"issue81303p1.so", "issue81303p2.so", "issue81303p3.so"} {
pl, err := plugin.Open(name)
if err != nil {
log.Fatal(err)
}
f, err := pl.Lookup("F")
if err != nil {
log.Fatal(err)
}
f.(func())()
p.Walk()
}
}
48 changes: 48 additions & 0 deletions src/cmd/cgo/internal/testplugin/testdata/issue81303/p/p.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package p

import (
"go/ast"
"go/parser"
"go/token"
"log"
)

const src = `package p

import "fmt"

type T struct{ x int }

func (t *T) M(n int) (r int) {
defer func() { r++ }()
go fmt.Println(n)
if n > 0 {
r = n
} else {
r = -n
}
for i := 0; i < n; i++ {
r += t.x
}
switch v := any(n).(type) {
case int:
r = v
}
return
}
`

// Walk parses src and walks the syntax tree. ast.Walk converts each
// node to ast.Node, which looks up the itab in the itab table, and
// then compares that itab with the itab of the host in a type switch.
func Walk() {
f, err := parser.ParseFile(token.NewFileSet(), "src.go", src, parser.SkipObjectResolution)
if err != nil {
log.Fatal(err)
}
ast.Inspect(f, func(ast.Node) bool { return true })
}
11 changes: 11 additions & 0 deletions src/cmd/cgo/internal/testplugin/testdata/issue81303/plugin1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import "testplugin/issue81303/p"

func main() {}

func F() { p.Walk() }
11 changes: 11 additions & 0 deletions src/cmd/cgo/internal/testplugin/testdata/issue81303/plugin2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import "testplugin/issue81303/p"

func main() {}

func F() { p.Walk() }
11 changes: 11 additions & 0 deletions src/cmd/cgo/internal/testplugin/testdata/issue81303/plugin3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import "testplugin/issue81303/p"

func main() {}

func F() { p.Walk() }
5 changes: 5 additions & 0 deletions src/cmd/compile/internal/arm64/simdssa_sve.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/cmd/compile/internal/ssa/_gen/simdARM64SVE.rules
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
(AndUint16s ...) => (ZANDD ...) // pureVreg
(AndUint32s ...) => (ZANDD ...) // pureVreg
(AndUint64s ...) => (ZANDD ...) // pureVreg
(AndNotInt8s ...) => (ZBICD ...) // pureVreg
(AndNotInt16s ...) => (ZBICD ...) // pureVreg
(AndNotInt32s ...) => (ZBICD ...) // pureVreg
(AndNotInt64s ...) => (ZBICD ...) // pureVreg
(AndNotUint8s ...) => (ZBICD ...) // pureVreg
(AndNotUint16s ...) => (ZBICD ...) // pureVreg
(AndNotUint32s ...) => (ZBICD ...) // pureVreg
(AndNotUint64s ...) => (ZBICD ...) // pureVreg
(OrInt8s ...) => (ZORRD ...) // pureVreg
(OrInt16s ...) => (ZORRD ...) // pureVreg
(OrInt32s ...) => (ZORRD ...) // pureVreg
Expand Down Expand Up @@ -129,6 +137,7 @@
(ZSELB (ZANDD x y) x mask) => (ZANDMergingB x y mask)
(ZSELB (ZANDD x y) y mask) => (ZANDMergingB y x mask)
(ZSELB (ZANDD x y) z mask) => (ZANDMergingPrefixedB z x y mask)
(ZSELB (ZBICD x y) x mask) => (ZBICMergingB x y mask)
(ZSELB (ZEORD x y) x mask) => (ZEORMergingB x y mask)
(ZSELB (ZEORD x y) y mask) => (ZEORMergingB y x mask)
(ZSELB (ZEORD x y) z mask) => (ZEORMergingPrefixedB z x y mask)
Expand All @@ -152,6 +161,7 @@
(ZSELD (ZANDD x y) x mask) => (ZANDMergingD x y mask)
(ZSELD (ZANDD x y) y mask) => (ZANDMergingD y x mask)
(ZSELD (ZANDD x y) z mask) => (ZANDMergingPrefixedD z x y mask)
(ZSELD (ZBICD x y) x mask) => (ZBICMergingD x y mask)
(ZSELD (ZEORD x y) x mask) => (ZEORMergingD x y mask)
(ZSELD (ZEORD x y) y mask) => (ZEORMergingD y x mask)
(ZSELD (ZEORD x y) z mask) => (ZEORMergingPrefixedD z x y mask)
Expand Down Expand Up @@ -182,6 +192,7 @@
(ZSELH (ZANDD x y) x mask) => (ZANDMergingH x y mask)
(ZSELH (ZANDD x y) y mask) => (ZANDMergingH y x mask)
(ZSELH (ZANDD x y) z mask) => (ZANDMergingPrefixedH z x y mask)
(ZSELH (ZBICD x y) x mask) => (ZBICMergingH x y mask)
(ZSELH (ZEORD x y) x mask) => (ZEORMergingH x y mask)
(ZSELH (ZEORD x y) y mask) => (ZEORMergingH y x mask)
(ZSELH (ZEORD x y) z mask) => (ZEORMergingPrefixedH z x y mask)
Expand All @@ -205,6 +216,7 @@
(ZSELS (ZANDD x y) x mask) => (ZANDMergingS x y mask)
(ZSELS (ZANDD x y) y mask) => (ZANDMergingS y x mask)
(ZSELS (ZANDD x y) z mask) => (ZANDMergingPrefixedS z x y mask)
(ZSELS (ZBICD x y) x mask) => (ZBICMergingS x y mask)
(ZSELS (ZEORD x y) x mask) => (ZEORMergingS x y mask)
(ZSELS (ZEORD x y) y mask) => (ZEORMergingS y x mask)
(ZSELS (ZEORD x y) z mask) => (ZEORMergingPrefixedS z x y mask)
Expand Down
5 changes: 5 additions & 0 deletions src/cmd/compile/internal/ssa/_gen/simdARM64SVEops.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/cmd/compile/internal/ssa/_gen/simdgenericOps.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading