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).

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

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

	          throw new Error(msg);
	Error: runtime error: native function not implemented: runtime/debug.setMaxStack
	    at $callDeferred (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/
	    at $panic (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/
	    at $b (/testing/testing.go:622:5)
	    at $callDeferred (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/
	    at $panic (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/
	    at $throwRuntimeError (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/
	    at setMaxStack (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/
	    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/
	    at Timeout.$runScheduled [as _onTimeout] (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/
	    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.