-
Notifications
You must be signed in to change notification settings - Fork 5
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
multi support go1.16 go1.17 go1.18 #43
Open
visualfc
wants to merge
466
commits into
master
Choose a base branch
from
multiver
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 gopherjs/gopherjs#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. gopherjs/gopherjs#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 gopherjs/gopherjs#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 support
Mainly I'd like to advertise the user survey more broadly to folks who are not following us in Twitter or Slack, but also list a few other ways to contribute to the project while I'm at it.
Add "Help us make GopherJS better" section into the README.
React Native has process object but it doesn't contain argv.
The main motivation for this change is to improve the performance of len() on maps. Previously, len() would compile to javascript that called `Object.keys().length`. This iterates the whole map to get its length. Using the benchmarks added in this commit, on a map with 10000 elements: ``` BenchmarkMapLen 9886 115719 ns/op ``` Now, len() just calls to javascript Map API, Map.size, which now as fast as calling len() on a slice. ``` BenchmarkMapLen 1000000000 0.5100 ns/op ``` This pull request contains changes to the compiler, prelude and standard library necessary to utilize the new API. However, when externalizing maps, they are still converted into objects to maintain backwards compatibility.
Use a Javascript Map for Go Maps. Improves performance of len() calls by orders of magnitude. 🗺️
GopherJS gained support for building code in module mode in 2021 (see PR #1042), and it itself didn't have problems being built in module mode since much earlier. Recently, it started getting semver tags that are recognized in module mode like `v1.17.2` and `v1.18.0-beta1` (see issue #847). Start suggesting the `go install` command to install its latest release in the README. (It remains possible to get the latest development version with something like `go install github.com/gopherjs/gopherjs@HEAD`, or one of the pre-release versions from `go list -m -versions` such as `go install github.com/gopherjs/gopherjs@v1.18.0-beta1`.) While here, also update to the new shorter Go website domain and latest Go 1.18 point release.
README: suggest go install for installing
Previously we would pass an empty slice, which is against the Go spec: > If f is invoked with no actual arguments for p, the value passed to p > is nil. Source: https://go.dev/ref/spec#Passing_arguments_to_..._parameters Fixes gopherjs/gopherjs#1147
Pass nil slice when variadic arguments are omitted after regular args.
The natives package has a blank import of the vfsgen package so that it stays included in go.mod (otherwise go mod tidy considers it as unused and removes it). Copy that mechanism here. Place it under a file with a "generate" build constraint so it doesn't get included in a normal gopherjs build, since it's only needed during code generation.
It's now possible to use the new embed package in the standard library to simplify the implementation of natives.FS and reduce its dependence on packages outside the standard library. This also drops support for the gopherjsdev tag where the natives could be read directly from disk without regenerating and rebuilding the gopherjs binary. That mode is less helpful now that file changes can be picked up just by rebuilding (without regenerating). It also can't be made to work reliably in module mode since module mode doesn't have the concept of a system-wide always-present workspace like GOPATH mode had. One-off occasional needs can probably be better served by temporary local code changes instead.
build: support go:embed
compiler/prelude: fix array type size
…157) * compiler/natives/src/reflect: fix valueIntrface check struct copy Fixed gopherjs/gopherjs#1156
compiler: support `go:linkname` directive for methods This is similar to what the upstream compiler supports. This functionality is inherently unsafe, but can be useful for some certain libraries like [reflectx](https://github.com/goplusjs/reflectx/blob/main/name_js.go#L17). The first argument of the function will act as a receiver of the linked method. As long as underlying typed for the first arguments match, they will be converted at runtime, which allows linking to methods of unexported types. However, types of the other arguments are not converted, nor the signature is verified to match the linked method.
…t uncommonType for compatible go reflect
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.