🌐 AI搜索 & 代理 主页
Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
061c27b
Target Go 1.11 Beta 1, update version to GopherJS 1.11-wip.
dmitshur Jun 26, 2018
7c756a8
natives/internal/cpu: Define CacheLineSize constant for GOARCH=js.
dmitshur Jun 27, 2018
6bf01c0
natives/internal/syscall/unix: Define randomTrap; override IsNonblock.
dmitshur Jun 27, 2018
97c17c2
natives/syscall: Implement rawSyscallNoError, unsetenv_c.
dmitshur Jun 29, 2018
a8a9c4e
natives/sync: Update sync.WaitGroup fields.
dmitshur Jun 27, 2018
f2b3fe5
natives/unicode: Update signature of to.
dmitshur Jun 27, 2018
9f7f458
natives/testing: Update frameSkip signature and implementation.
dmitshur Jun 27, 2018
3c29284
natives/reflect: Use 'embedded' rather than 'anonymous'.
dmitshur Jun 27, 2018
884657e
natives/reflect: Sort exported methods first; add xcount to uncommonT…
dmitshur Jun 27, 2018
e29d711
natives/strings: Skip TestBuilderGrow.
dmitshur Jun 28, 2018
f6627b0
natives/math: Use Go implementation for extreme Ldexp inputs.
dmitshur Jun 28, 2018
8e3982a
Target Go 1.11 Beta 2.
dvic Jul 21, 2018
ec05aba
natives/runtime: Add pkgpath method for _type. (#846)
egonelbre Aug 12, 2018
1205be0
Target Go 1.11 Beta 3.
dmitshur Aug 12, 2018
a23c7c0
Target Go 1.11 RC 1.
dmitshur Aug 18, 2018
64ad028
natives/crypto/internal/subtle: Implement for GopherJS.
dmitshur Aug 18, 2018
e0db4d4
tests: Triage test failures new to Go 1.11.
dmitshur Aug 20, 2018
f2f28a8
Target Go 1.11 RC 2.
dmitshur Aug 23, 2018
1f566be
natives/runtime: Update TypeAssertionError instantiation.
dmitshur Aug 23, 2018
da29940
natives/reflect: Skip new failing test.
dmitshur Aug 23, 2018
bf5bd66
Regenerate.
dmitshur Jun 29, 2018
e3b6673
Target Go 1.11 final.
dmitshur Aug 25, 2018
8b6e878
compiler: Bump version to GopherJS 1.11-1.
dmitshur Aug 25, 2018
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
Prev Previous commit
Next Next commit
natives/math: Use Go implementation for extreme Ldexp inputs.
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.
  • Loading branch information
dmitshur committed Aug 21, 2018
commit f6627b0e1b5a0e0113576cb2ce6de5d1b8241943
15 changes: 6 additions & 9 deletions compiler/natives/src/math/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,13 @@ func IsNaN(f float64) (is bool) {
}

func Ldexp(frac float64, exp int) float64 {
if frac == 0 {
return frac
if -1024 < exp && exp < 1024 { // Use Math.pow for small exp values where it's viable. For performance.
if frac == 0 {
return frac
}
return frac * math.Call("pow", 2, exp).Float()
}
if exp >= 1024 {
return frac * math.Call("pow", 2, 1023).Float() * math.Call("pow", 2, exp-1023).Float()
}
if exp <= -1024 {
return frac * math.Call("pow", 2, -1023).Float() * math.Call("pow", 2, exp+1023).Float()
}
return frac * math.Call("pow", 2, exp).Float()
return ldexp(frac, exp)
}

func Log(x float64) float64 {
Expand Down