mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
compiler: avoid bitcast when replacing a method call with a direct call
A bitcast was inserted when the receiver of the call wasn't a *i8. This is a pretty common case, and did not play well with goroutines. Avoid this bitcast by changing each call to a direct call, after unpacking the receiver type from the *i8 parameter. This might also fix some undefined behavior in the resulting program, as it is technically not allowed to call a function with a different signature (even if the signature is compatible).
This commit is contained in:
committed by
Ron Evans
parent
387e1340bf
commit
99da328453
Vendored
+16
@@ -21,6 +21,10 @@ func main() {
|
||||
go nowait()
|
||||
time.Sleep(time.Millisecond)
|
||||
println("done with non-blocking goroutine")
|
||||
|
||||
var printer Printer
|
||||
printer = &myPrinter{}
|
||||
printer.Print()
|
||||
}
|
||||
|
||||
func sub() {
|
||||
@@ -38,3 +42,15 @@ func wait() {
|
||||
func nowait() {
|
||||
println("non-blocking goroutine")
|
||||
}
|
||||
|
||||
type Printer interface {
|
||||
Print()
|
||||
}
|
||||
|
||||
type myPrinter struct{
|
||||
}
|
||||
|
||||
func (i *myPrinter) Print() {
|
||||
time.Sleep(time.Millisecond)
|
||||
println("async interface method call")
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -9,3 +9,4 @@ wait:
|
||||
end waiting
|
||||
non-blocking goroutine
|
||||
done with non-blocking goroutine
|
||||
async interface method call
|
||||
|
||||
Reference in New Issue
Block a user