PauseQuantiles []time.Duration
}
-// Implemented in package runtime.
-func readGCStats(*[]time.Duration)
-func enableGC(bool) bool
-func setGCPercent(int) int
-func freeOSMemory()
-func setMaxStack(int) int
-func setMaxThreads(int) int
-
// ReadGCStats reads statistics about garbage collection into stats.
// The number of entries in the pause history is system-dependent;
// stats.Pause slice will be reused if large enough, reallocated otherwise.
// at startup, or 100 if the variable is not set.
// A negative percentage disables garbage collection.
func SetGCPercent(percent int) int {
- old := setGCPercent(percent)
+ old := setGCPercent(int32(percent))
runtime.GC()
- return old
+ return int(old)
}
// FreeOSMemory forces a garbage collection followed by an
// that the runtime trigger only a panic, not a crash.
// SetPanicOnFault applies only to the current goroutine.
// It returns the previous setting.
-func SetPanicOnFault(enabled bool) bool
+func SetPanicOnFault(enabled bool) bool {
+ return setPanicOnFault(enabled)
+}
// WriteHeapDump writes a description of the heap and the objects in
// it to the given file descriptor.
--- /dev/null
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package debug
+
+import (
+ "time"
+)
+
+// Uses assembly to call corresponding runtime-internal functions.
+func setMaxStack(int) int
+func setGCPercent(int32) int32
+func setPanicOnFault(bool) bool
+func setMaxThreads(int) int
+
+// Implemented in package runtime.
+func readGCStats(*[]time.Duration)
+func enableGC(bool) bool
+func freeOSMemory()
--- /dev/null
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "textflag.h"
+
+#ifdef GOARCH_arm
+#define JMP B
+#endif
+
+TEXT ·setMaxStack(SB),NOSPLIT,$0-0
+ JMP runtime·setMaxStack(SB)
+
+TEXT ·setGCPercent(SB),NOSPLIT,$0-0
+ JMP runtime·setGCPercent(SB)
+
+TEXT ·setPanicOnFault(SB),NOSPLIT,$0-0
+ JMP runtime·setPanicOnFault(SB)
+
+TEXT ·setMaxThreads(SB),NOSPLIT,$0-0
+ JMP runtime·setMaxThreads(SB)
void runtime·gc_g_ptr(Eface*);
void runtime·gc_itab_ptr(Eface*);
-int32 runtime·setgcpercent(int32);
+void runtime·setgcpercent_m(void);
// Value we use to mark dead pointers when GODEBUG=gcdead=1.
#define PoisonGC ((uintptr)0xf969696969696969ULL)
pauses->len = n+3;
}
-int32
-runtime·setgcpercent(int32 in) {
+void
+runtime·setgcpercent_m(void) {
+ int32 in;
int32 out;
+ in = (int32)(intptr)g->m->scalararg[0];
+
runtime·lock(&runtime·mheap.lock);
out = runtime·gcpercent;
if(in < 0)
in = -1;
runtime·gcpercent = in;
runtime·unlock(&runtime·mheap.lock);
- return out;
+
+ g->m->scalararg[0] = (uintptr)(intptr)out;
}
static void
(runtime·externalthreadhandlerp != 0 && f->entry == runtime·externalthreadhandlerp);
}
-int32
-runtime·setmaxthreads(int32 in)
+void
+runtime·setmaxthreads_m(void)
{
+ int32 in;
int32 out;
+ in = g->m->scalararg[0];
+
runtime·lock(&runtime·sched.lock);
out = runtime·sched.maxmcount;
runtime·sched.maxmcount = in;
checkmcount();
runtime·unlock(&runtime·sched.lock);
- return out;
+
+ g->m->scalararg[0] = out;
}
static int8 experiment[] = GOEXPERIMENT; // defined in zaexperiment.h
--- /dev/null
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package runtime
+
+func setMaxStack(in int) (out int) {
+ out = int(maxstacksize)
+ maxstacksize = uint(in)
+ return out
+}
+
+func setGCPercent(in int32) (out int32) {
+ mp := acquirem()
+ mp.scalararg[0] = uint(int(in))
+ onM(&setgcpercent_m)
+ out = int32(int(mp.scalararg[0]))
+ releasem(mp)
+ return out
+}
+
+func setPanicOnFault(newb bool) (old bool) {
+ new := uint8(0)
+ if newb {
+ new = 1
+ }
+
+ mp := acquirem()
+ old = mp.curg.paniconfault == 1
+ mp.curg.paniconfault = new
+ releasem(mp)
+ return old
+}
+
+func setMaxThreads(in int) (out int) {
+ mp := acquirem()
+ mp.scalararg[0] = uint(in)
+ onM(&setmaxthreads_m)
+ out = int(mp.scalararg[0])
+ releasem(mp)
+ return out
+}
+++ /dev/null
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package runtime∕debug
-#include "runtime.h"
-#include "arch_GOARCH.h"
-#include "malloc.h"
-#include "stack.h"
-
-func setMaxStack(in int) (out int) {
- out = runtime·maxstacksize;
- runtime·maxstacksize = in;
-}
-
-func setGCPercent(in int) (out int) {
- out = runtime·setgcpercent(in);
-}
-
-func setMaxThreads(in int) (out int) {
- out = runtime·setmaxthreads(in);
-}
-
-func SetPanicOnFault(enabled bool) (old bool) {
- old = g->paniconfault;
- g->paniconfault = enabled;
-}
void runtime·parsedebugvars(void);
void _rt0_go(void);
void* runtime·funcdata(Func*, int32);
-int32 runtime·setmaxthreads(int32);
+void runtime·setmaxthreads_m(void);
G* runtime·timejump(void);
void runtime·iterate_itabs(void (*callback)(Itab*));
void runtime·iterate_finq(void (*callback)(FuncVal*, byte*, uintptr, Type*, PtrType*));
unrollgcprog_m,
unrollgcproginplace_m,
gosched_m,
+ setgcpercent_m,
+ setmaxthreads_m,
ready_m,
park_m,
blockevent_m,