Permalink
Commits on Aug 25, 2018
  1. Go 1.11 support (version bump to GopherJS 1.11-1). (#853)

    dmitshur committed Aug 25, 2018
    Merge pull request #853 from branch go1.11.
  2. compiler: Bump version to GopherJS 1.11-1.

    dmitshur committed Aug 25, 2018
    Resolves #836.
  3. Regenerate.

    dmitshur committed Jun 29, 2018
    Done with latest vfsgen, including change in shurcooL/vfsgen@02ddb05
    (there was a minor gofmt change for Go 1.11):
    
    	go generate ./...
  4. natives/reflect: Skip new failing test.

    dmitshur committed Aug 23, 2018
    This is a new testcase in Go 1.11, related to golang/go@9558ba2
    and golang/gofrontend@023c3d4. Resolving it requires further
    investigation. Skip the failing test for now with a TODO comment,
    because there may not be enough time to resolve it before the
    Go 1.11 release. It can be addressed after.
  5. natives/runtime: Update TypeAssertionError instantiation.

    dmitshur committed Aug 23, 2018
    In the relevant upstream change is golang/go@cda1947,
    fields of TypeAssertionError are changed from string to *_type.
    This change follows suit and updates the instantiation of the
    TypeAssertionError type in $assertType of compiler/prelude to
    use the new definition. This happens when a type assertion fails.
    
    Add test coverage for the runtime error string, since it wasn't
    covered before.
    
    Fixes fixedbugs/issue16130.go and fixedbugs/issue26094.go tests.
  6. natives/crypto/internal/subtle: Implement for GopherJS.

    dmitshur committed Aug 18, 2018
    Package crypto/internal/subtle is new to Go 1.11.
    It's a copy of golang.org/x/crypto/internal/subtle,
    added in golang/go@75d15a2.
    
    There are two implementations: one uses unsafe, another uses reflect.
    We can't use either because they both rely on pointer arithmetics,
    which GopherJS doesn't support.
    
    Create a custom impementation of AnyOverlap that makes use of
    GopherJS slice internals.
    
    Fixes crypto/des and crypto/rc4 tests.
Commits on Aug 21, 2018
  1. natives/math: Use Go implementation for extreme Ldexp inputs.

    dmitshur committed Jun 28, 2018
    In Go 1.11, there has been an improvement made to Ldexp for some
    extreme values. The previous Math.pow-using algorithm doesn't produce
    correct results. Use the Go implementation of ldexp for those values.
    
    Continue to use the current Math.pow approach for other inputs because
    it's much faster:
    
    	$ gopherjs test -v --run=none --bench=Ldexp math
    	BenchmarkLdexp 	2000000000	         0.44 ns/op
    
    Compared to using the Go implementation for all inputs, without the
    Math.pow fast path:
    
    	$ gopherjs test -v --run=none --bench=Ldexp math
    	BenchmarkLdexp 	 5000000	       203 ns/op
    
    Follows golang/go@4b265fb.
    Updates golang/go#23407.
  2. natives/strings: Skip TestBuilderGrow.

    dmitshur committed Jun 28, 2018
    The test has started relying on testing.AllocsPerRun and
    runtime.ReadMemStats in Go 1.11, which are not supported
    by GopherJS. Skip the test, just like TestBuilderAllocs.
    
    Fixes:
    
    	$ gopherjs test --short strings
    	--- FAIL: TestBuilderGrow (0.24s)
    	    test.992502099:29524: growLen=100: got 0 allocs during Write; want 1
    	    test.992502099:29524: growLen=1000: got 0 allocs during Write; want 1
    	    test.992502099:29524: growLen=10000: got 0 allocs during Write; want 1
    	    test.992502099:29524: growLen=100000: got 0 allocs during Write; want 1
    	FAIL
    	FAIL  strings     1.501s
  3. natives/reflect: Sort exported methods first; add xcount to uncommonT…

    dmitshur committed Jun 27, 2018
    …ype.
    
    What was previously an unused blank identifier field of type uint16 in
    Go 1.10 has become the xcount field in Go 1.11. Update our uncommonType
    to match.
    
    Also remove the unused uint32 field at the end. In normal Go, it's used
    for padding and to keep the struct size fixed size. GopherJS doesn't
    need that, because it doesn't support unsafe memory operations.
    
    Fixes:
    
    	$ gopherjs build reflect
    	reflect/type.go:2603:5: invalid operation: ut (variable of type *uncommonType) has no field or method xcount
    	reflect/type.go:643:7: invalid operation: t (variable of type *uncommonType) has no field or method xcount
    	reflect/type.go:646:88: invalid operation: t (variable of type *uncommonType) has no field or method xcount
    	reflect/type.go:646:97: invalid operation: t (variable of type *uncommonType) has no field or method xcount
    
    Follows golang/go@86a3389.
    Updates golang/go#22075.
  4. natives/reflect: Use 'embedded' rather than 'anonymous'.

    dmitshur committed Jun 27, 2018
    These have been renamed in Go 1.11. Update our code to match upstream.
    
    Fixes:
    
    	$ gopherjs build reflect
    	reflect/reflect.go:153:6: unknown field offsetAnon in struct literal
    	reflect/reflect.go:995:12: invalid operation: field (variable of type *structField) has no field or method anon
    
    Follows golang/go@47be3d4.
  5. natives/testing: Update frameSkip signature and implementation.

    dmitshur committed Jun 27, 2018
    The scope of frameSkip helper has changed in Go 1.11.
    Update the function signature and implementation to match.
    
    This change helps GopherJS with running tests.
  6. natives/unicode: Update signature of to.

    dmitshur committed Jun 27, 2018
    In Go 1.11, the responsibility of function to has been increased to
    additionally report whether caseRange contained a mapping for r.
    Update our modified copy of it to fix the build.
    
    Fixes:
    
    	$ gopherjs build unicode
    	unicode/letter.go:248:9: cannot assign 1 values to 2 variables
    	unicode/letter.go:305:20: cannot initialize 2 variables with 1 values
    	unicode/letter.go:296:20: cannot initialize 2 variables with 1 values
    	unicode/letter.go:287:20: cannot initialize 2 variables with 1 values
    
    Follows golang/go@05f8b44.
  7. natives/sync: Update sync.WaitGroup fields.

    dmitshur committed Jun 27, 2018
    sync.WaitGroup struct fields have changed in Go 1.11.
    Update to the new ones.
    
    Fixes:
    
    	$ gopherjs build sync
    	sync/waitgroup.go:34:49: cannot use &wg.state1[2] (value of type *byte) as *uint32 value in return statement
    	sync/waitgroup.go:36:52: cannot use &wg.state1[0] (value of type *byte) as *uint32 value in return statement
  8. natives/syscall: Implement rawSyscallNoError, unsetenv_c.

    dmitshur committed Jun 29, 2018
    Go 1.11 added the rawSyscallNoError wrapper function which is used
    for Linux syscalls that don't return an error and converted all
    applicable occurences of RawSyscall to use it instead.
    This change implements it for GopherJS on Linux.
    
    Also implement unsetenv_c, analogous to setenv_c, so that os.Unsetenv
    can be supported with Node.js, just like os.Setenv already was.
    
    Fixes:
    
    	$ GOOS=linux gopherjs test --short io
    	Error: runtime error: native function not implemented: syscall.rawSyscallNoError
    	FAIL	io	1.036s
    
    	$ goexec -compiler=gopherjs 'os.Unsetenv("TEST")'
    	Error: runtime error: native function not implemented: syscall.unsetenv_c
    
    Follows golang/go@36951a9.
    Updates golang/go#22924.
  9. natives/internal/syscall/unix: Define randomTrap; override IsNonblock.

    dmitshur committed Jun 27, 2018
    In Go 1.11, the internal/syscall/unix package is also imported by
    package os. It becomes a good idea to make it compile under GopherJS
    by providing mock implementations of GetRandom and IsNonblock functions,
    ones that don't try to make syscalls.
    
    Fixes:
    
    	$ GOOS=linux gopherjs build reflect
    	internal/syscall/unix/getrandom_linux.go:29:5: undeclared name: randomTrap
    	internal/syscall/unix/getrandom_linux.go:38:34: undeclared name: randomTrap
    
    	$ gopherjs test --short reflect
    
    	github.com/gopherjs/gopherjs/test.649712895:1412
    	          throw new Error(msg);
    	                ^
    	Error: runtime error: native function not implemented: internal/syscall/unix.syscall_fcntl
    	    at $callDeferred (github.com/gopherjs/gopherjs/test.649712895:1412:17)
    	    at $panic (github.com/gopherjs/gopherjs/test.649712895:1451:3)
    	    at throw$1 (github.com/gopherjs/gopherjs/runtime.go:221:3)
    	    at syscall_fcntl (github.com/gopherjs/gopherjs/test.649712895:10092:3)
    	    at Object.IsNonblock (/internal/syscall/unix/nonblocking.go:18:3)
    	    at NewFile (/os/file_unix.go:83:6)
    	    at Object.$init (github.com/gopherjs/gopherjs/test.649712895:11582:16)
    	    at $init (github.com/gopherjs/gopherjs/test.649712895:48713:11)
    	    at $goroutine (github.com/gopherjs/gopherjs/test.649712895:1471:19)
    	    at $runScheduled (github.com/gopherjs/gopherjs/test.649712895:1511:7)
    	    at $schedule (github.com/gopherjs/gopherjs/test.649712895:1527:5)
    	    at $go (github.com/gopherjs/gopherjs/test.649712895:1503:3)
    	    at Object.<anonymous> (github.com/gopherjs/gopherjs/test.649712895:48734:1)
    	    at Object.<anonymous> (github.com/gopherjs/gopherjs/test.649712895:48737:4)
    	    at Module._compile (internal/modules/cjs/loader.js:702:30)
    	    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    	    at Module.load (internal/modules/cjs/loader.js:612:32)
    	    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    	    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    	    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
    	    at startup (internal/bootstrap/node.js:238:19)
    	    at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)
    	FAIL	reflect	0.517s
  10. natives/internal/cpu: Define CacheLineSize constant for GOARCH=js.

    dmitshur committed Jun 27, 2018
    In Go 1.11, internal/cpu package is being used in more places
    (including runtime), so it's no longer viable to avoid importing it.
    Instead, fix the build by defining the CacheLineSize constant for js
    architecture.
    
    Set its value to 0 because it's not helpful in the context of GopherJS
    to set it to a larger value. Internal field alignment isn't a factor.
    
    Fixes:
    
    	$ gopherjs build runtime
    	internal/cpu/cpu.go:20:16: undeclared name: CacheLineSize
    	internal/cpu/cpu.go:37:16: undeclared name: CacheLineSize
    	internal/cpu/cpu.go:50:14: undeclared name: CacheLineSize
    	internal/cpu/cpu.go:62:14: undeclared name: CacheLineSize
    	internal/cpu/cpu.go:70:15: undeclared name: CacheLineSize
    	internal/cpu/cpu.go:95:15: undeclared name: CacheLineSize
    	internal/cpu/cpu.go:101:19: undeclared name: CacheLineSize
    	internal/cpu/cpu.go:118:19: undeclared name: CacheLineSize
Commits on Aug 20, 2018
  1. compiler/prelude: Keep nil slice nil when slicing. (#852)

    dmitshur committed Aug 20, 2018
    According to the Go specification:
    
    > If the sliced operand of a valid slice expression is a nil slice,
    > the result is a nil slice.
    
    This behavior was not implemented and not caught previously.
    Slicing a nil slice would incorrectly make it an empty but non-nil slice.
    This change fixes that.
    
    The minified prelude was regenerated with:
    
    	go generate ./compiler/prelude
    
    Fixes #851.
Commits on Jun 28, 2018
Commits on Apr 24, 2018
  1. compiler: Bump version to GopherJS 1.10-4.

    dmitshur committed Apr 24, 2018
    This version uses a new package for export data. See PR #803.
Commits on Apr 21, 2018
  1. compiler: Bump version to GopherJS 1.10-3.

    dmitshur committed Apr 8, 2018
    This is the first version that supports GopherJS being vendored.
Commits on Apr 20, 2018
  1. tests: Add test that GopherJS can be vendored.

    dmitshur committed Apr 15, 2018
    Rely on runtime.GOARCH and t.Skip to skip tests that shouldn't be run
    with GopherJS. It's more clear and reliable than a file-wide build tag.
    
    Include stderr from gopherjsvendored_test.sh in output of TestGopherJSCanBeVendored.
    This is only to get get more information when it fails.
  2. Restore support for testing js package.

    dmitshur committed Apr 8, 2018
    The _test.go file needs to be accessed via the build context's file
    system interface.
    
    Take into account the fact that the js and nosync packages are now
    effectively virtual, and don't have a corresponding physical directory.
    Use current directory when running tests with Node.js, otherwise it
    would fail with "directory not exist" error.
  3. build, compiler/typesutil: Don't use vendor directory to resolve js, …

    dmitshur committed Apr 7, 2018
    …nosync.
    
    These core GopherJS packages are already embedded into the GopherJS
    build system via the gopherjspkg virtual filesystem. The gopherjspkg
    package can be safely vendored. Therefore, there's no need to try to
    use vendor directory to resolve those packages.
    
    This change makes it possible to use a vendored copy of GopherJS in a
    project, and use it to build any Go code.
    
    Fixes #415.
  4. build: Load js, nosync packages from gopherjspkg rather than GOPATH.

    dmitshur committed Apr 7, 2018
    The Go stdlib overrides (i.e., compiler/natives package) are already
    embedded into the GopherJS build system. This makes it possible for the
    gopherjs binary to access them even if the gopherjs repository is not
    present in GOPATH (e.g., because it was deleted, or because it's
    vendored).
    
    Doing that for natives but not the js, nosync packages makes little
    sense, since the gopherjs repository still needs to exist in GOPATH.
    
    This change fixes that. By embedding the core GopherJS packages
    analogously to natives, the gopherjs binary becomes more standalone.
    Now, it only requires GOROOT/src to contain the matching version of Go
    source code.
    
    Non-core GopherJS packages are not embedded (e.g., the GopherJS
    compiler itself). That means it needs to exist in GOPATH to be
    buildable (otherwise, the user gets a "cannot find package" error).
    This is expected just like with any other normal Go package.
    
    Fixes #462.
    Helps #415.
  5. compiler/gopherjspkg: Add package.

    dmitshur committed Apr 7, 2018
    This package embeds the core GopherJS packages (js, nosync).
    It's similar to how native overrides for stdlib are embedded
    in the compiler/natives package.
    
    Pick only files in /fs and /nosync, and no subdirectories (if any
    are added, they won't get included by default).
  6. build: Make fewer copies of NewBuildContext.

    dmitshur committed Apr 7, 2018
    Call NewBuildContext at the top of Import, ImportDir, and inside
    NewSession.
    
    Previously, it was called more often than necessary (instead of being
    preserved for entire build session).
    
    Pass build context by value to importWithSrcDir so it can be safely
    modified there, without the changes persisisting from one package
    to the next.
    
    The build context will need to be available in more places in an
    upcoming commit. Storing it in Session helps with that.
  7. Move js package tests into tests package.

    dmitshur committed Apr 20, 2018
    This way, all GopherJS-specific tests are in tests package, rather than
    having an arbitrary split. None of the package js tests were internal
    to the package.
    
    This helps a future change where the js package becomes embedded into
    the compiler. It makes it easier to add and modify GopherJS tests
    without having to regenerate the js package.
    
    Resolves #792.
Commits on Mar 17, 2018
  1. README: Document supported GOOS values. (#777)

    dmitshur committed Mar 17, 2018
    Add instructions for what people should do when building with GopherJS
    on unsupported platforms. Code generation works completely fine, but
    syscalls (e.g., for gopherjs run) will only work on supported platforms.
    
    Previously, this information was only in issues, people's heads, commit
    messages, etc. It should be documented in README to provide clarity.
    
    Rename "OS X" to "macOS", the current name of that operating system.
    Rearrange sections to place more relevant information first. Mention
    Linux before macOS consistently. Linux is placed first because it's open
    source and more freely available than the proprietary macOS, so it's
    easier to recommend it as an alternative.
    
    Resolves #770.
    Updates #776.
    Updates #688.