-
Notifications
You must be signed in to change notification settings - Fork 570
Go 1.17 support #1043
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
Go 1.17 support #1043
Conversation
e857b8a
to
f6f0eef
Compare
f8407a0
to
f6f0eef
Compare
Recent changes in the To reproduce:
This can be reproduces with a simple test case: func main() {
x := []int{}
t := reflect.TypeOf(x)
_ = reflect.New(t)
} |
4c3ccf5
to
d767a4d
Compare
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.
Looks good so far! 👍 I still haven't found time to look into the slice-to-array conversion, but I intend to do so this weekend, unless you get there first :)
import "testing" | ||
|
||
func TestScalarMultDistributesOverAdd(t *testing.T) { | ||
t.Skip("slow") // Times out, takes ~13 minutes |
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.
Not related to this PR per se, but thinking out loud. One reason I heard for people using GopherJS was access to the crypto library, and our crypto in incredibly slow. I did a little profiling and it seems to all boil down to math/big
being really slow with our implementation of slices. I couldn't think of an easy way to improve the situation, but these tests shall serve as additional motivation to try and optimize it further.
4e4fa4b
to
9a879c2
Compare
And slightly refactor CheckGoVersion to require less manual intervention for each version change.
Array pointers are the only kind of pointer considered a "wrapped", so they need to be handled appropriately. At runtime an array pointer is represented by a reference to the JavaScript native array object, so we only need to copy the reference and couple it with the desired Go type. It will be boxed into the new Go type if/when the compiler needs it down the road.
Upstream uses a conversion to unsafeheader.Slice, which isn't supported by GopherJS. Using Value.Len() is preferrable, since we already override it to provide compatibility. If/when golang/go#48346 gets into the stable release, this patch will no longer be necessary.
Complete support for slice-to-array conversion.
Since JavaScript runtime is single-threaded, there isn't much special logic to be done. However, it is important that all these functions never call anything potentially blocking to make sure the goroutine is not interrupted in a middle of an atomic operation.
sync/atomic: Implement new Swap and CompareAndSwap methods of Value.
This pulls in a few select functions from Go 1.16, which were optimized and thus made unsafe in Go 1.17. golang/go#47342 should render this change obsolete if/when implemented.
Get `hash/maphash` to work again
This package seems to be related to the new register-based ABI in Go 1.17, which is completely irrelevant for GopherJS.
The fix is two-fold: 1. `disableSplice` is initialized with `(*bool)(nil)` to work around #1060. 2. Skipped `TestSplicePipePool`, which relies in runtime features GopherJS doesn't support.
Fix standard library test failures in `internal` packages.
This fixes golang/go#44830 for GopherJS.
In the following example type T is *types.Named, not *types.Pointer, but the underlying type is: ```go type T *struct{ y int } var q T = &struct{ y int }{} q.y = 7 ``` The panic was detected by gorepo test `fixedbugs/issue23017.go`.
GopherJS breaks lhs expression evaluation order defined by the spec. Unfortunately, it's not easy to fix and would likely generate a lot more code for multi-assignments. An efficient fix would require writing some sort of analysis to determine if assignments are likely to influence each other, and at the moment I can't think of how such analysis would work. Without it we would have to create a whole bunch of extra temporary variables for any multi-assignment, which will likely lead to a significant increase in the artifact size. Considering nobody reported this issue so far, I'm inclined to punt on this issue for now. #1063 tracks this bug.
Resolve the two remaining gorepo test failures.
This change improves Go version detection for the provided GOROOT by falling back to `go version` command output if VERSION file doesn't exist (fixes #1018). If GOROOT-based version detection failed, it falls back further to the Go version from GopherJS release or a minor version in "go1.x" format. The detected value is then injected by the compiler into the generated JS file and picked up by the `runtime` package.
runtime: Version() returns Go version provided by the compiler.
This isn't really sufficient to test the implementation correctness perfectly, but it is a sufficient smoke test for GopherJS, and it cuts the test runtime substantially.
Un-skip a few tests from crypto libraries.
Go 1.17 is on the way!
This PR tracks progress toward adding Go 1.17 support to GopherJS.
TODO:
runtime.Version()
dynamically at compile time. This changed from 1.16 to 1.17 upstream, and is now handled by the linker in 1.17, which we don't have, so we need to invent a new solution.crypto/ed25519
package.hash/maphash
implementation to work without pointer arithmetic. Related: hash/maphash: Provide apurego
implementation golang/go#47342 (comment)math/big
to avoid constant overflow.reflect
(see Go 1.17 support #1043 (comment) for details)//go:build
lines are understood properlyfmt
examples are failing for 1.17fixedbugs/issue23017.go
causes a compiler panicOut of scope for this PR (but may be considered as part of future work):
gopherjs run