Skip to content

Commit 7e9c7ba

Browse files
committed
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
1 parent 311f6ab commit 7e9c7ba

File tree

1 file changed

+7
-0
lines changed
  • compiler/natives/src/runtime/debug

1 file changed

+7
-0
lines changed

compiler/natives/src/runtime/debug/debug.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,12 @@
33
package debug
44

55
func setGCPercent(int32) int32 {
6+
// Not implemented. Return initial setting.
67
return 100
78
}
9+
10+
func setMaxStack(bytes int) int {
11+
// Not implemented. Return initial setting.
12+
// The initial setting is 1 GB on 64-bit systems, 250 MB on 32-bit systems.
13+
return 250000000
14+
}

0 commit comments

Comments
 (0)