Permalink
Browse files

compiler/natives/src/runtime/debug: Implement noop SetMaxStack.

Implementation is noop and does not change max stack, instead it always
returns the initial value. This is similar to SetGCPercent.

Package runtime/debug is not officially supported, so there are no hard
requirements for functionality here.

Use initial value for 32-bit value, which is 250 MB (but 250000000).
Source: https://github.com/golang/go/blob/ea7d9e6a52ca64c200dcc75621e75f209ceceace/src/runtime/proc.go#L113-L120.

Fixes new compress/flate test added in golang/go@9c3630f:

	$ gopherjs test --short --run='^TestMaxStackSize$' compress/flate
	--- FAIL: TestMaxStackSize (0.10s)

	/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1414
	          throw new Error(msg);
	                ^
	Error: runtime error: native function not implemented: runtime/debug.setMaxStack
	    at $callDeferred (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1414:17)
	    at $panic (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1453:3)
	    at $b (/testing/testing.go:622:5)
	    at $callDeferred (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1426:23)
	    at $panic (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1453:3)
	    at $throwRuntimeError (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/runtime.go:31:4)
	    at setMaxStack (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:25166:3)
	    at Object.SetMaxStack (/runtime/debug/garbage.go:116:3)
	    at TestMaxStackSize (/compress/flate/deflate_test.go:872:3)
	    at tRunner (/testing/testing.go:657:3)
	    at $goroutine (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1473:19)
	    at Timeout.$runScheduled [as _onTimeout] (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1514:7)
	    at ontimeout (timers.js:365:14)
	    at tryOnTimeout (timers.js:237:5)
	    at Timer.listOnTimeout (timers.js:207:5)
	FAIL    compress/flate  0.748s
  • Loading branch information...
1 parent ad3bc12 commit 0c82c68d735374d75554698f451692756997ad4a @shurcooL shurcooL committed Jan 19, 2017
Showing with 7 additions and 0 deletions.
  1. +7 −0 compiler/natives/src/runtime/debug/debug.go
@@ -3,5 +3,12 @@
package debug
func setGCPercent(int32) int32 {
+ // Not implemented. Return initial setting.
return 100
}
+
+func setMaxStack(bytes int) int {
+ // Not implemented. Return initial setting.
+ // The initial setting is 1 GB on 64-bit systems, 250 MB on 32-bit systems.
+ return 250000000
+}

0 comments on commit 0c82c68

Please sign in to comment.