Permalink
Browse files

compiler/natives/src/{runtime,sync}: Add stub for SetMutexProfileFrac…

…tion, implement runtime_SemacquireMutex.

SetMutexProfileFraction was added in Go 1.8, and needs to be explicitly
added to "runtime" package in GopherJS, because GopherJS doesn't inherit
most of upstream .go files of "runtime" package.

Document that it's not supported at this time.

Implement runtime_SemacquireMutex with same code as runtime_Semacquire.

Fixes many build errors.

Fixes net/rpc/jsonrpc tests:

	$ gopherjs test net/rpc/jsonrpc

	/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:1414
	          throw new Error(msg);
	                ^
	Error: runtime error: native function not implemented: sync.runtime_SemacquireMutex
	    at $callDeferred (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:1414:17)
	    at $panic (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:1453:3)
	    at $throwRuntimeError (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/runtime.go:31:4)
	    at $packages.sync.runtime_SemacquireMutex (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:3109:3)
	    at $packages.sync.Mutex.ptr.Lock (/sync/mutex.go:87:5)
	    at $packages.net/rpc.Server.ptr.sendResponse (/net/rpc/server.go:365:3)
	    at $packages.net/rpc.service.ptr.call (/net/rpc/server.go:394:3)
	    at f (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:52:21)
	    at $goroutine (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:1473:19)
	    at Timeout.$runScheduled [as _onTimeout] (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:1514:7)
	    at tryOnTimeout (timers.js:224:11)
	    at Timer.listOnTimeout (timers.js:198:5)
	FAIL	net/rpc/jsonrpc	1.813s
  • Loading branch information...
1 parent 4a9226b commit e6dec359a968274aa1bfa905b3b50fd5327874c2 @shurcooL shurcooL committed Dec 13, 2016
Showing with 11 additions and 1 deletion.
  1. +5 −0 compiler/natives/src/runtime/runtime.go
  2. +5 −0 compiler/natives/src/sync/sync.go
  3. +1 −1 doc/packages.md
@@ -164,6 +164,11 @@ var MemProfileRate int = 512 * 1024
func SetBlockProfileRate(rate int) {
}
+func SetMutexProfileFraction(rate int) int {
+ // TODO: Investigate this. If it's possible to implement, consider doing so, otherwise remove this comment.
+ return 0
+}
+
func Stack(buf []byte, all bool) int {
s := js.Global.Get("Error").New().Get("stack")
if s == js.Undefined {
@@ -13,6 +13,11 @@ func runtime_Semacquire(s *uint32) {
*s--
}
+// SemacquireMutex is like Semacquire, but for profiling contended Mutexes.
+// Mutex profiling is not supported, so just use the same implementation.
+// TODO: Investigate this. If it's possible to implement, consider doing so, otherwise remove this comment.
+var runtime_SemacquireMutex = runtime_Semacquire
+
func runtime_Semrelease(s *uint32) {
*s++
View
@@ -128,7 +128,7 @@ path | ✅ yes |
reflect | ✅ yes | except StructOf (pending)
regexp | ✅ yes |
-- syntax | ✅ yes |
-runtime | ☑️ partially |
+runtime | ☑️ partially | SetMutexProfileFraction unsupported
-- cgo | ❌ no |
-- debug | ❌ no |
-- pprof | ❌ no |

0 comments on commit e6dec35

Please sign in to comment.