mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: get rid of other Go->C calls in test exports.
testSchedLocal* tests need to malloc now because their stack frames are too big to fit on the G0 stack. LGTM=iant R=golang-codereviews, iant, khr CC=golang-codereviews https://golang.org/cl/133660043
This commit is contained in:
parent
0e19a3d6d0
commit
dbed4e9b4f
7 changed files with 49 additions and 44 deletions
|
|
@ -10,20 +10,6 @@
|
||||||
|
|
||||||
typedef char bool;
|
typedef char bool;
|
||||||
|
|
||||||
bool runtime·lockedOSThread(void);
|
|
||||||
|
|
||||||
static void
|
|
||||||
FLUSH(void*)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
·LockedOSThread(bool b)
|
|
||||||
{
|
|
||||||
b = runtime·lockedOSThread();
|
|
||||||
FLUSH(&b);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is what a cgo-compiled stub declaration looks like.
|
// This is what a cgo-compiled stub declaration looks like.
|
||||||
void
|
void
|
||||||
·Issue7695(struct{void *y[8*sizeof(void*)];}p)
|
·Issue7695(struct{void *y[8*sizeof(void*)];}p)
|
||||||
|
|
|
||||||
16
misc/cgo/test/backdoor/thunk.s
Normal file
16
misc/cgo/test/backdoor/thunk.s
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// Assembly to get into package runtime without using exported symbols.
|
||||||
|
|
||||||
|
// +build amd64 amd64p32 arm 386
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
#ifdef GOARCH_arm
|
||||||
|
#define JMP B
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEXT ·LockedOSThread(SB),NOSPLIT,$0-0
|
||||||
|
JMP runtime·lockedOSThread(SB)
|
||||||
|
|
@ -18,7 +18,7 @@ var Fcmp64 = fcmp64
|
||||||
var Fintto64 = fintto64
|
var Fintto64 = fintto64
|
||||||
var F64toint = f64toint
|
var F64toint = f64toint
|
||||||
|
|
||||||
func lockedOSThread() bool
|
// in asm_*.s
|
||||||
func stackguard() (sp, limit uintptr)
|
func stackguard() (sp, limit uintptr)
|
||||||
|
|
||||||
var Entersyscall = entersyscall
|
var Entersyscall = entersyscall
|
||||||
|
|
@ -127,9 +127,12 @@ func GCMask(x interface{}) (ret []byte) {
|
||||||
|
|
||||||
func testSchedLocalQueue()
|
func testSchedLocalQueue()
|
||||||
func testSchedLocalQueueSteal()
|
func testSchedLocalQueueSteal()
|
||||||
|
func RunSchedLocalQueueTest() {
|
||||||
var TestSchedLocalQueue1 = testSchedLocalQueue
|
onM(testSchedLocalQueue)
|
||||||
var TestSchedLocalQueueSteal1 = testSchedLocalQueueSteal
|
}
|
||||||
|
func RunSchedLocalQueueStealTest() {
|
||||||
|
onM(testSchedLocalQueueSteal)
|
||||||
|
}
|
||||||
|
|
||||||
var HaveGoodHash = haveGoodHash
|
var HaveGoodHash = haveGoodHash
|
||||||
var StringHash = stringHash
|
var StringHash = stringHash
|
||||||
|
|
|
||||||
|
|
@ -2594,12 +2594,6 @@ badunlockOSThread(void)
|
||||||
runtime·throw("runtime: internal error: misuse of lockOSThread/unlockOSThread");
|
runtime·throw("runtime: internal error: misuse of lockOSThread/unlockOSThread");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
runtime·lockedOSThread(void)
|
|
||||||
{
|
|
||||||
return g->lockedm != nil && g->m->lockedg != nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma textflag NOSPLIT
|
#pragma textflag NOSPLIT
|
||||||
int32
|
int32
|
||||||
runtime·gcount(void)
|
runtime·gcount(void)
|
||||||
|
|
@ -3552,24 +3546,25 @@ runqsteal(P *p, P *p2)
|
||||||
void
|
void
|
||||||
runtime·testSchedLocalQueue(void)
|
runtime·testSchedLocalQueue(void)
|
||||||
{
|
{
|
||||||
P p;
|
P *p;
|
||||||
G gs[nelem(p.runq)];
|
G *gs;
|
||||||
int32 i, j;
|
int32 i, j;
|
||||||
|
|
||||||
runtime·memclr((byte*)&p, sizeof(p));
|
p = (P*)runtime·mallocgc(sizeof(*p), nil, FlagNoScan);
|
||||||
|
gs = (G*)runtime·mallocgc(nelem(p->runq)*sizeof(*gs), nil, FlagNoScan);
|
||||||
|
|
||||||
for(i = 0; i < nelem(gs); i++) {
|
for(i = 0; i < nelem(p->runq); i++) {
|
||||||
if(runqget(&p) != nil)
|
if(runqget(p) != nil)
|
||||||
runtime·throw("runq is not empty initially");
|
runtime·throw("runq is not empty initially");
|
||||||
for(j = 0; j < i; j++)
|
for(j = 0; j < i; j++)
|
||||||
runqput(&p, &gs[i]);
|
runqput(p, &gs[i]);
|
||||||
for(j = 0; j < i; j++) {
|
for(j = 0; j < i; j++) {
|
||||||
if(runqget(&p) != &gs[i]) {
|
if(runqget(p) != &gs[i]) {
|
||||||
runtime·printf("bad element at iter %d/%d\n", i, j);
|
runtime·printf("bad element at iter %d/%d\n", i, j);
|
||||||
runtime·throw("bad element");
|
runtime·throw("bad element");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(runqget(&p) != nil)
|
if(runqget(p) != nil)
|
||||||
runtime·throw("runq is not empty afterwards");
|
runtime·throw("runq is not empty afterwards");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3577,29 +3572,30 @@ runtime·testSchedLocalQueue(void)
|
||||||
void
|
void
|
||||||
runtime·testSchedLocalQueueSteal(void)
|
runtime·testSchedLocalQueueSteal(void)
|
||||||
{
|
{
|
||||||
P p1, p2;
|
P *p1, *p2;
|
||||||
G gs[nelem(p1.runq)], *gp;
|
G *gs, *gp;
|
||||||
int32 i, j, s;
|
int32 i, j, s;
|
||||||
|
|
||||||
runtime·memclr((byte*)&p1, sizeof(p1));
|
p1 = (P*)runtime·mallocgc(sizeof(*p1), nil, FlagNoScan);
|
||||||
runtime·memclr((byte*)&p2, sizeof(p2));
|
p2 = (P*)runtime·mallocgc(sizeof(*p2), nil, FlagNoScan);
|
||||||
|
gs = (G*)runtime·mallocgc(nelem(p1->runq)*sizeof(*gs), nil, FlagNoScan);
|
||||||
|
|
||||||
for(i = 0; i < nelem(gs); i++) {
|
for(i = 0; i < nelem(p1->runq); i++) {
|
||||||
for(j = 0; j < i; j++) {
|
for(j = 0; j < i; j++) {
|
||||||
gs[j].sig = 0;
|
gs[j].sig = 0;
|
||||||
runqput(&p1, &gs[j]);
|
runqput(p1, &gs[j]);
|
||||||
}
|
}
|
||||||
gp = runqsteal(&p2, &p1);
|
gp = runqsteal(p2, p1);
|
||||||
s = 0;
|
s = 0;
|
||||||
if(gp) {
|
if(gp) {
|
||||||
s++;
|
s++;
|
||||||
gp->sig++;
|
gp->sig++;
|
||||||
}
|
}
|
||||||
while(gp = runqget(&p2)) {
|
while(gp = runqget(p2)) {
|
||||||
s++;
|
s++;
|
||||||
gp->sig++;
|
gp->sig++;
|
||||||
}
|
}
|
||||||
while(gp = runqget(&p1))
|
while(gp = runqget(p1))
|
||||||
gp->sig++;
|
gp->sig++;
|
||||||
for(j = 0; j < i; j++) {
|
for(j = 0; j < i; j++) {
|
||||||
if(gs[j].sig != 1) {
|
if(gs[j].sig != 1) {
|
||||||
|
|
|
||||||
|
|
@ -100,3 +100,8 @@ func badmcall(fn func(*g)) {
|
||||||
func badmcall2(fn func(*g)) {
|
func badmcall2(fn func(*g)) {
|
||||||
gothrow("runtime: mcall function returned")
|
gothrow("runtime: mcall function returned")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func lockedOSThread() bool {
|
||||||
|
gp := getg()
|
||||||
|
return gp.lockedm != nil && gp.m.lockedg != nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -366,11 +366,11 @@ func nonleaf(stop chan int) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSchedLocalQueue(t *testing.T) {
|
func TestSchedLocalQueue(t *testing.T) {
|
||||||
runtime.TestSchedLocalQueue1()
|
runtime.RunSchedLocalQueueTest()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSchedLocalQueueSteal(t *testing.T) {
|
func TestSchedLocalQueueSteal(t *testing.T) {
|
||||||
runtime.TestSchedLocalQueueSteal1()
|
runtime.RunSchedLocalQueueStealTest()
|
||||||
}
|
}
|
||||||
|
|
||||||
func benchmarkStackGrowth(b *testing.B, rec int) {
|
func benchmarkStackGrowth(b *testing.B, rec int) {
|
||||||
|
|
|
||||||
|
|
@ -1060,7 +1060,6 @@ void runtime·procyield(uint32);
|
||||||
void runtime·osyield(void);
|
void runtime·osyield(void);
|
||||||
void runtime·lockOSThread(void);
|
void runtime·lockOSThread(void);
|
||||||
void runtime·unlockOSThread(void);
|
void runtime·unlockOSThread(void);
|
||||||
bool runtime·lockedOSThread(void);
|
|
||||||
|
|
||||||
bool runtime·showframe(Func*, G*);
|
bool runtime·showframe(Func*, G*);
|
||||||
void runtime·printcreatedby(G*);
|
void runtime·printcreatedby(G*);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue