Commit 25f6b02a authored by Russ Cox's avatar Russ Cox

cmd/cc, runtime: convert C compilers to use Go calling convention

To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.

This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]

By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.

This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.

Some functions, like seek and nsec on Plan 9, needed to be rewritten.

Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.

Tested on:
        darwin/386
        darwin/amd64
        linux/arm
        linux/386
        linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.

LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
parent 0a7c7ac8
...@@ -46,7 +46,7 @@ _cgen(Node *n, Node *nn, int inrel) ...@@ -46,7 +46,7 @@ _cgen(Node *n, Node *nn, int inrel)
} }
if(n == Z || n->type == T) if(n == Z || n->type == T)
return; return;
if(typesuv[n->type->etype]) { if(typesuv[n->type->etype] && (n->op != OFUNC || nn != Z)) {
sugen(n, nn, n->type->width); sugen(n, nn, n->type->width);
return; return;
} }
...@@ -75,7 +75,7 @@ _cgen(Node *n, Node *nn, int inrel) ...@@ -75,7 +75,7 @@ _cgen(Node *n, Node *nn, int inrel)
if(r != Z && r->complex >= FNX) if(r != Z && r->complex >= FNX)
switch(o) { switch(o) {
default: default:
regret(&nod, r); regret(&nod, r, 0, 0);
cgen(r, &nod); cgen(r, &nod);
regsalloc(&nod1, r); regsalloc(&nod1, r);
...@@ -107,7 +107,7 @@ _cgen(Node *n, Node *nn, int inrel) ...@@ -107,7 +107,7 @@ _cgen(Node *n, Node *nn, int inrel)
if(l->addable >= INDEXED && l->complex < FNX) { if(l->addable >= INDEXED && l->complex < FNX) {
if(nn != Z || r->addable < INDEXED) { if(nn != Z || r->addable < INDEXED) {
if(r->complex >= FNX && nn == Z) if(r->complex >= FNX && nn == Z)
regret(&nod, r); regret(&nod, r, 0, 0);
else else
regalloc(&nod, r, nn); regalloc(&nod, r, nn);
cgen(r, &nod); cgen(r, &nod);
...@@ -348,7 +348,7 @@ _cgen(Node *n, Node *nn, int inrel) ...@@ -348,7 +348,7 @@ _cgen(Node *n, Node *nn, int inrel)
if(l->op != OIND) if(l->op != OIND)
diag(n, "bad function call"); diag(n, "bad function call");
regret(&nod, l->left); regret(&nod, l->left, 0, 0);
cgen(l->left, &nod); cgen(l->left, &nod);
regsalloc(&nod1, l->left); regsalloc(&nod1, l->left);
gopcode(OAS, &nod, Z, &nod1); gopcode(OAS, &nod, Z, &nod1);
...@@ -377,11 +377,11 @@ _cgen(Node *n, Node *nn, int inrel) ...@@ -377,11 +377,11 @@ _cgen(Node *n, Node *nn, int inrel)
if(REGARG >= 0) if(REGARG >= 0)
if(o != reg[REGARG]) if(o != reg[REGARG])
reg[REGARG]--; reg[REGARG]--;
if(nn != Z) { regret(&nod, n, l->type, 1);
regret(&nod, n); if(nn != Z)
gopcode(OAS, &nod, Z, nn); gmove(&nod, nn);
if(nod.op == OREGISTER)
regfree(&nod); regfree(&nod);
}
break; break;
case OIND: case OIND:
...@@ -823,7 +823,7 @@ boolgen(Node *n, int true, Node *nn) ...@@ -823,7 +823,7 @@ boolgen(Node *n, int true, Node *nn)
if(true) if(true)
o = comrel[relindex(o)]; o = comrel[relindex(o)];
if(l->complex >= FNX && r->complex >= FNX) { if(l->complex >= FNX && r->complex >= FNX) {
regret(&nod, r); regret(&nod, r, 0, 0);
cgenrel(r, &nod); cgenrel(r, &nod);
regsalloc(&nod1, r); regsalloc(&nod1, r);
gopcode(OAS, &nod, Z, &nod1); gopcode(OAS, &nod, Z, &nod1);
...@@ -957,7 +957,7 @@ sugen(Node *n, Node *nn, int32 w) ...@@ -957,7 +957,7 @@ sugen(Node *n, Node *nn, int32 w)
if(nn != Z && side(nn)) { if(nn != Z && side(nn)) {
nod1 = *n; nod1 = *n;
nod1.type = typ(TIND, n->type); nod1.type = typ(TIND, n->type);
regret(&nod2, &nod1); regret(&nod2, &nod1, 0, 0);
lcgen(nn, &nod2); lcgen(nn, &nod2);
regsalloc(&nod0, &nod1); regsalloc(&nod0, &nod1);
gopcode(OAS, &nod2, Z, &nod0); gopcode(OAS, &nod2, Z, &nod0);
...@@ -1036,6 +1036,20 @@ sugen(Node *n, Node *nn, int32 w) ...@@ -1036,6 +1036,20 @@ sugen(Node *n, Node *nn, int32 w)
break; break;
case OFUNC: case OFUNC:
if(!hasdotdotdot(n->left->type)) {
cgen(n, Z);
if(nn != Z) {
curarg -= n->type->width;
regret(&nod1, n, n->left->type, 1);
if(nn->complex >= FNX) {
regsalloc(&nod2, n);
cgen(&nod1, &nod2);
nod1 = nod2;
}
cgen(&nod1, nn);
}
break;
}
if(nn == Z) { if(nn == Z) {
sugen(n, nodrat, w); sugen(n, nodrat, w);
break; break;
......
...@@ -210,7 +210,7 @@ void usedset(Node*, int); ...@@ -210,7 +210,7 @@ void usedset(Node*, int);
void xcom(Node*); void xcom(Node*);
int bcomplex(Node*, Node*); int bcomplex(Node*, Node*);
Prog* gtext(Sym*, int32); Prog* gtext(Sym*, int32);
vlong argsize(void); vlong argsize(int);
/* /*
* cgen.c * cgen.c
...@@ -236,7 +236,7 @@ Node* nodconst(int32); ...@@ -236,7 +236,7 @@ Node* nodconst(int32);
Node* nod32const(vlong); Node* nod32const(vlong);
Node* nodfconst(double); Node* nodfconst(double);
void nodreg(Node*, Node*, int); void nodreg(Node*, Node*, int);
void regret(Node*, Node*); void regret(Node*, Node*, Type*, int);
int tmpreg(void); int tmpreg(void);
void regalloc(Node*, Node*, Node*); void regalloc(Node*, Node*, Node*);
void regfree(Node*); void regfree(Node*);
......
...@@ -36,7 +36,7 @@ gtext(Sym *s, int32 stkoff) ...@@ -36,7 +36,7 @@ gtext(Sym *s, int32 stkoff)
{ {
int32 a; int32 a;
a = argsize(); a = argsize(1);
if((textflag & NOSPLIT) != 0 && stkoff >= 128) if((textflag & NOSPLIT) != 0 && stkoff >= 128)
yyerror("stack frame too large for NOSPLIT function"); yyerror("stack frame too large for NOSPLIT function");
......
...@@ -274,15 +274,43 @@ nodreg(Node *n, Node *nn, int reg) ...@@ -274,15 +274,43 @@ nodreg(Node *n, Node *nn, int reg)
} }
void void
regret(Node *n, Node *nn) regret(Node *n, Node *nn, Type *t, int mode)
{ {
int r; int r;
if(mode == 0 || hasdotdotdot(t) || nn->type->width == 0) {
r = REGRET; r = REGRET;
if(typefd[nn->type->etype]) if(typefd[nn->type->etype])
r = FREGRET+NREG; r = FREGRET+NREG;
nodreg(n, nn, r); nodreg(n, nn, r);
reg[r]++; reg[r]++;
return;
}
if(mode == 1) {
// fetch returned value after call.
// already called gargs, so curarg is set.
curarg = (curarg+3) & ~3;
regaalloc(n, nn);
return;
}
if(mode == 2) {
// store value to be returned.
// must compute arg offset.
if(t->etype != TFUNC)
fatal(Z, "bad regret func %T", t);
*n = *nn;
n->op = ONAME;
n->class = CPARAM;
n->sym = slookup(".ret");
n->complex = nodret->complex;
n->xoffset = argsize(0);
n->addable = 20;
return;
}
fatal(Z, "bad regret");
} }
int int
......
...@@ -51,7 +51,7 @@ cgen(Node *n, Node *nn) ...@@ -51,7 +51,7 @@ cgen(Node *n, Node *nn)
} }
if(n == Z || n->type == T) if(n == Z || n->type == T)
return; return;
if(typesu[n->type->etype]) { if(typesu[n->type->etype] && (n->op != OFUNC || nn != Z)) {
sugen(n, nn, n->type->width); sugen(n, nn, n->type->width);
return; return;
} }
...@@ -88,7 +88,7 @@ cgen(Node *n, Node *nn) ...@@ -88,7 +88,7 @@ cgen(Node *n, Node *nn)
if(cond(o) && typesu[l->type->etype]) if(cond(o) && typesu[l->type->etype])
break; break;
regret(&nod, r); regret(&nod, r, 0, 0);
cgen(r, &nod); cgen(r, &nod);
regsalloc(&nod1, r); regsalloc(&nod1, r);
...@@ -135,7 +135,7 @@ cgen(Node *n, Node *nn) ...@@ -135,7 +135,7 @@ cgen(Node *n, Node *nn)
if(!hardleft) { if(!hardleft) {
if(nn != Z || r->addable < INDEXED || hardconst(r)) { if(nn != Z || r->addable < INDEXED || hardconst(r)) {
if(r->complex >= FNX && nn == Z) if(r->complex >= FNX && nn == Z)
regret(&nod, r); regret(&nod, r, 0, 0);
else else
regalloc(&nod, r, nn); regalloc(&nod, r, nn);
cgen(r, &nod); cgen(r, &nod);
...@@ -929,7 +929,7 @@ cgen(Node *n, Node *nn) ...@@ -929,7 +929,7 @@ cgen(Node *n, Node *nn)
if(l->op != OIND) if(l->op != OIND)
diag(n, "bad function call"); diag(n, "bad function call");
regret(&nod, l->left); regret(&nod, l->left, 0, 0);
cgen(l->left, &nod); cgen(l->left, &nod);
regsalloc(&nod1, l->left); regsalloc(&nod1, l->left);
gmove(&nod, &nod1); gmove(&nod, &nod1);
...@@ -956,11 +956,13 @@ cgen(Node *n, Node *nn) ...@@ -956,11 +956,13 @@ cgen(Node *n, Node *nn)
gpcdata(PCDATA_ArgSize, -1); gpcdata(PCDATA_ArgSize, -1);
if(REGARG >= 0 && reg[REGARG]) if(REGARG >= 0 && reg[REGARG])
reg[REGARG]--; reg[REGARG]--;
if(nn != Z) { regret(&nod, n, l->type, 1); // update maxarg if nothing else
regret(&nod, n); gpcdata(PCDATA_ArgSize, curarg);
gpcdata(PCDATA_ArgSize, -1);
if(nn != Z)
gmove(&nod, nn); gmove(&nod, nn);
if(nod.op == OREGISTER)
regfree(&nod); regfree(&nod);
}
break; break;
case OIND: case OIND:
...@@ -1382,7 +1384,7 @@ boolgen(Node *n, int true, Node *nn) ...@@ -1382,7 +1384,7 @@ boolgen(Node *n, int true, Node *nn)
if(true) if(true)
o = comrel[relindex(o)]; o = comrel[relindex(o)];
if(l->complex >= FNX && r->complex >= FNX) { if(l->complex >= FNX && r->complex >= FNX) {
regret(&nod, r); regret(&nod, r, 0, 0);
cgen(r, &nod); cgen(r, &nod);
regsalloc(&nod1, r); regsalloc(&nod1, r);
gmove(&nod, &nod1); gmove(&nod, &nod1);
...@@ -1535,7 +1537,7 @@ sugen(Node *n, Node *nn, int32 w) ...@@ -1535,7 +1537,7 @@ sugen(Node *n, Node *nn, int32 w)
if(nn != Z && side(nn)) { if(nn != Z && side(nn)) {
nod1 = *n; nod1 = *n;
nod1.type = typ(TIND, n->type); nod1.type = typ(TIND, n->type);
regret(&nod2, &nod1); regret(&nod2, &nod1, 0, 0);
lcgen(nn, &nod2); lcgen(nn, &nod2);
regsalloc(&nod0, &nod1); regsalloc(&nod0, &nod1);
cgen(&nod2, &nod0); cgen(&nod2, &nod0);
...@@ -1617,6 +1619,20 @@ sugen(Node *n, Node *nn, int32 w) ...@@ -1617,6 +1619,20 @@ sugen(Node *n, Node *nn, int32 w)
break; break;
case OFUNC: case OFUNC:
if(!hasdotdotdot(n->left->type)) {
cgen(n, Z);
if(nn != Z) {
curarg -= n->type->width;
regret(&nod1, n, n->left->type, 1);
if(nn->complex >= FNX) {
regsalloc(&nod2, n);
cgen(&nod1, &nod2);
nod1 = nod2;
}
cgen(&nod1, nn);
}
break;
}
if(nn == Z) { if(nn == Z) {
sugen(n, nodrat, w); sugen(n, nodrat, w);
break; break;
......
...@@ -210,7 +210,7 @@ void xcom(Node*); ...@@ -210,7 +210,7 @@ void xcom(Node*);
void indx(Node*); void indx(Node*);
int bcomplex(Node*, Node*); int bcomplex(Node*, Node*);
Prog* gtext(Sym*, int32); Prog* gtext(Sym*, int32);
vlong argsize(void); vlong argsize(int);
/* /*
* cgen.c * cgen.c
...@@ -239,7 +239,7 @@ Node* nodfconst(double); ...@@ -239,7 +239,7 @@ Node* nodfconst(double);
Node* nodgconst(vlong, Type*); Node* nodgconst(vlong, Type*);
int nodreg(Node*, Node*, int); int nodreg(Node*, Node*, int);
int isreg(Node*, int); int isreg(Node*, int);
void regret(Node*, Node*); void regret(Node*, Node*, Type*, int);
void regalloc(Node*, Node*, Node*); void regalloc(Node*, Node*, Node*);
void regfree(Node*); void regfree(Node*);
void regialloc(Node*, Node*, Node*); void regialloc(Node*, Node*, Node*);
......
...@@ -36,7 +36,7 @@ gtext(Sym *s, int32 stkoff) ...@@ -36,7 +36,7 @@ gtext(Sym *s, int32 stkoff)
{ {
vlong v; vlong v;
v = ((uvlong)argsize() << 32) | (stkoff & 0xffffffff); v = ((uvlong)argsize(1) << 32) | (stkoff & 0xffffffff);
if((textflag & NOSPLIT) && stkoff >= 128) if((textflag & NOSPLIT) && stkoff >= 128)
yyerror("stack frame too large for NOSPLIT function"); yyerror("stack frame too large for NOSPLIT function");
......
...@@ -351,15 +351,43 @@ nodreg(Node *n, Node *nn, int r) ...@@ -351,15 +351,43 @@ nodreg(Node *n, Node *nn, int r)
} }
void void
regret(Node *n, Node *nn) regret(Node *n, Node *nn, Type *t, int mode)
{ {
int r; int r;
if(mode == 0 || hasdotdotdot(t) || nn->type->width == 0) {
r = REGRET; r = REGRET;
if(typefd[nn->type->etype]) if(typefd[nn->type->etype])
r = FREGRET; r = FREGRET;
nodreg(n, nn, r); nodreg(n, nn, r);
reg[r]++; reg[r]++;
return;
}
if(mode == 1) {
// fetch returned value after call.
// already called gargs, so curarg is set.
curarg = (curarg+7) & ~7;
regaalloc(n, nn);
return;
}
if(mode == 2) {
// store value to be returned.
// must compute arg offset.
if(t->etype != TFUNC)
fatal(Z, "bad regret func %T", t);
*n = *nn;
n->op = ONAME;
n->class = CPARAM;
n->sym = slookup(".ret");
n->complex = nodret->complex;
n->addable = 20;
n->xoffset = argsize(0);
return;
}
fatal(Z, "bad regret");
} }
void void
......
...@@ -49,7 +49,7 @@ cgen(Node *n, Node *nn) ...@@ -49,7 +49,7 @@ cgen(Node *n, Node *nn)
} }
if(n == Z || n->type == T) if(n == Z || n->type == T)
return; return;
if(typesuv[n->type->etype]) { if(typesuv[n->type->etype] && (n->op != OFUNC || nn != Z)) {
sugen(n, nn, n->type->width); sugen(n, nn, n->type->width);
return; return;
} }
...@@ -86,7 +86,7 @@ cgen(Node *n, Node *nn) ...@@ -86,7 +86,7 @@ cgen(Node *n, Node *nn)
if(cond(o) && typesuv[l->type->etype]) if(cond(o) && typesuv[l->type->etype])
break; break;
regret(&nod, r); regret(&nod, r, 0, 0);
cgen(r, &nod); cgen(r, &nod);
regsalloc(&nod1, r); regsalloc(&nod1, r);
...@@ -147,7 +147,7 @@ cgen(Node *n, Node *nn) ...@@ -147,7 +147,7 @@ cgen(Node *n, Node *nn)
if(!hardleft) { if(!hardleft) {
if(nn != Z || r->addable < INDEXED) { if(nn != Z || r->addable < INDEXED) {
if(r->complex >= FNX && nn == Z) if(r->complex >= FNX && nn == Z)
regret(&nod, r); regret(&nod, r, 0, 0);
else else
regalloc(&nod, r, nn); regalloc(&nod, r, nn);
cgen(r, &nod); cgen(r, &nod);
...@@ -922,7 +922,7 @@ cgen(Node *n, Node *nn) ...@@ -922,7 +922,7 @@ cgen(Node *n, Node *nn)
if(l->op != OIND) if(l->op != OIND)
diag(n, "bad function call"); diag(n, "bad function call");
regret(&nod, l->left); regret(&nod, l->left, 0, 0);
cgen(l->left, &nod); cgen(l->left, &nod);
regsalloc(&nod1, l->left); regsalloc(&nod1, l->left);
gmove(&nod, &nod1); gmove(&nod, &nod1);
...@@ -949,12 +949,12 @@ cgen(Node *n, Node *nn) ...@@ -949,12 +949,12 @@ cgen(Node *n, Node *nn)
gpcdata(PCDATA_ArgSize, -1); gpcdata(PCDATA_ArgSize, -1);
if(REGARG >= 0 && reg[REGARG]) if(REGARG >= 0 && reg[REGARG])
reg[REGARG]--; reg[REGARG]--;
if(nn != Z) { regret(&nod, n, l->type, 1); // update maxarg if nothing else
regret(&nod, n); if(nn != Z)
gmove(&nod, nn); gmove(&nod, nn);
if(nod.op == OREGISTER)
regfree(&nod); regfree(&nod);
} else if(nn == Z && hasdotdotdot(l->type) && typefd[n->type->etype])
if(typefd[n->type->etype])
gins(AFMOVDP, &fregnode0, &fregnode0); gins(AFMOVDP, &fregnode0, &fregnode0);
break; break;
...@@ -1374,7 +1374,7 @@ boolgen(Node *n, int true, Node *nn) ...@@ -1374,7 +1374,7 @@ boolgen(Node *n, int true, Node *nn)
if(true) if(true)
o = comrel[relindex(o)]; o = comrel[relindex(o)];
if(l->complex >= FNX && r->complex >= FNX) { if(l->complex >= FNX && r->complex >= FNX) {
regret(&nod, r); regret(&nod, r, 0, 0);
cgen(r, &nod); cgen(r, &nod);
regsalloc(&nod1, r); regsalloc(&nod1, r);
gmove(&nod, &nod1); gmove(&nod, &nod1);
...@@ -1567,7 +1567,7 @@ sugen(Node *n, Node *nn, int32 w) ...@@ -1567,7 +1567,7 @@ sugen(Node *n, Node *nn, int32 w)
if(nn != Z && side(nn)) { if(nn != Z && side(nn)) {
nod1 = *n; nod1 = *n;
nod1.type = typ(TIND, n->type); nod1.type = typ(TIND, n->type);
regret(&nod2, &nod1); regret(&nod2, &nod1, 0, 0);
lcgen(nn, &nod2); lcgen(nn, &nod2);
regsalloc(&nod0, &nod1); regsalloc(&nod0, &nod1);
cgen(&nod2, &nod0); cgen(&nod2, &nod0);
...@@ -1649,6 +1649,20 @@ sugen(Node *n, Node *nn, int32 w) ...@@ -1649,6 +1649,20 @@ sugen(Node *n, Node *nn, int32 w)
break; break;
case OFUNC: case OFUNC:
if(!hasdotdotdot(n->left->type)) {
cgen(n, Z);
if(nn != Z) {
curarg -= n->type->width;
regret(&nod1, n, n->left->type, 1);
if(nn->complex >= FNX) {
regsalloc(&nod2, n);
cgen(&nod1, &nod2);
nod1 = nod2;
}
cgen(&nod1, nn);
}
break;
}
if(nn == Z) { if(nn == Z) {
sugen(n, nodrat, w); sugen(n, nodrat, w);
break; break;
......
...@@ -210,7 +210,7 @@ void xcom(Node*); ...@@ -210,7 +210,7 @@ void xcom(Node*);
void indx(Node*); void indx(Node*);
int bcomplex(Node*, Node*); int bcomplex(Node*, Node*);
Prog* gtext(Sym*, int32); Prog* gtext(Sym*, int32);
vlong argsize(void); vlong argsize(int);
/* /*
* cgen.c * cgen.c
...@@ -244,7 +244,7 @@ Node* nodconst(int32); ...@@ -244,7 +244,7 @@ Node* nodconst(int32);
Node* nodfconst(double); Node* nodfconst(double);
int nodreg(Node*, Node*, int); int nodreg(Node*, Node*, int);
int isreg(Node*, int); int isreg(Node*, int);
void regret(Node*, Node*); void regret(Node*, Node*, Type*, int);
void regalloc(Node*, Node*, Node*); void regalloc(Node*, Node*, Node*);
void regfree(Node*); void regfree(Node*);
void regialloc(Node*, Node*, Node*); void regialloc(Node*, Node*, Node*);
......
...@@ -35,7 +35,7 @@ gtext(Sym *s, int32 stkoff) ...@@ -35,7 +35,7 @@ gtext(Sym *s, int32 stkoff)
{ {
int32 a; int32 a;
a = argsize(); a = argsize(1);
if((textflag & NOSPLIT) != 0 && stkoff >= 128) if((textflag & NOSPLIT) != 0 && stkoff >= 128)
yyerror("stack frame too large for NOSPLIT function"); yyerror("stack frame too large for NOSPLIT function");
......
...@@ -311,15 +311,43 @@ nodreg(Node *n, Node *nn, int r) ...@@ -311,15 +311,43 @@ nodreg(Node *n, Node *nn, int r)
} }
void void
regret(Node *n, Node *nn) regret(Node *n, Node *nn, Type *t, int mode)
{ {
int r; int r;
if(mode == 0 || hasdotdotdot(t) || nn->type->width == 0) {
r = REGRET; r = REGRET;
if(typefd[nn->type->etype]) if(typefd[nn->type->etype])
r = FREGRET; r = FREGRET;
nodreg(n, nn, r); nodreg(n, nn, r);
reg[r]++; reg[r]++;
return;
}
if(mode == 1) {
// fetch returned value after call.
// already called gargs, so curarg is set.
curarg = (curarg+3) & ~3;
regaalloc(n, nn);
return;
}
if(mode == 2) {
// store value to be returned.
// must compute arg offset.
if(t->etype != TFUNC)
fatal(Z, "bad regret func %T", t);
*n = *nn;
n->op = ONAME;
n->class = CPARAM;
n->sym = slookup(".retx");
n->complex = 0;
n->addable = 20;
n->xoffset = argsize(0);
return;
}
fatal(Z, "bad regret");
} }
void void
......
...@@ -385,6 +385,7 @@ func (w *Walker) parseFile(dir, file string) (*ast.File, error) { ...@@ -385,6 +385,7 @@ func (w *Walker) parseFile(dir, file string) (*ast.File, error) {
" mcache struct{}; bucket struct{}; sudog struct{}; g struct{};" + " mcache struct{}; bucket struct{}; sudog struct{}; g struct{};" +
" hchan struct{}; chantype struct{}; waitq struct{};" + " hchan struct{}; chantype struct{}; waitq struct{};" +
" note struct{}; wincallbackcontext struct{};" + " note struct{}; wincallbackcontext struct{};" +
" gobuf struct{}; funcval struct{};" +
"); " + "); " +
"const ( cb_max = 2000 )" "const ( cb_max = 2000 )"
f, err = parser.ParseFile(fset, filename, src, 0) f, err = parser.ParseFile(fset, filename, src, 0)
......
...@@ -794,7 +794,7 @@ void xcom(Node*); ...@@ -794,7 +794,7 @@ void xcom(Node*);
int32 exreg(Type*); int32 exreg(Type*);
int32 align(int32, Type*, int, int32*); int32 align(int32, Type*, int, int32*);
int32 maxround(int32, int32); int32 maxround(int32, int32);
int hasdotdotdot(void); int hasdotdotdot(Type*);
void linkarchinit(void); void linkarchinit(void);
extern schar ewidth[]; extern schar ewidth[];
......
...@@ -697,6 +697,7 @@ argmark(Node *n, int pass) ...@@ -697,6 +697,7 @@ argmark(Node *n, int pass)
{ {
Type *t; Type *t;
if(hasdotdotdot(thisfn->link))
autoffset = align(0, thisfn->link, Aarg0, nil); autoffset = align(0, thisfn->link, Aarg0, nil);
stkoff = 0; stkoff = 0;
for(; n->left != Z; n = n->left) { for(; n->left != Z; n = n->left) {
......
...@@ -56,24 +56,24 @@ makefuncdatasym(char *namefmt, int64 funcdatakind) ...@@ -56,24 +56,24 @@ makefuncdatasym(char *namefmt, int64 funcdatakind)
} }
int int
hasdotdotdot(void) hasdotdotdot(Type *t)
{ {
Type *t; for(t=t->down; t!=T; t=t->down)
for(t=thisfn->down; t!=T; t=t->down)
if(t->etype == TDOT) if(t->etype == TDOT)
return 1; return 1;
return 0; return 0;
} }
vlong vlong
argsize(void) argsize(int doret)
{ {
Type *t; Type *t;
int32 s; int32 s;
//print("t=%T\n", thisfn); //print("t=%T\n", thisfn);
s = align(0, thisfn->link, Aarg0, nil); s = 0;
if(hasdotdotdot(thisfn))
s = align(s, thisfn->link, Aarg0, nil);
for(t=thisfn->down; t!=T; t=t->down) { for(t=thisfn->down; t!=T; t=t->down) {
switch(t->etype) { switch(t->etype) {
case TVOID: case TVOID:
...@@ -93,6 +93,14 @@ argsize(void) ...@@ -93,6 +93,14 @@ argsize(void)
s = (s+7) & ~7; s = (s+7) & ~7;
else else
s = (s+3) & ~3; s = (s+3) & ~3;
if(doret && thisfn->link->etype != TVOID) {
s = align(s, thisfn->link, Aarg1, nil);
s = align(s, thisfn->link, Aarg2, nil);
if(thechar == '6')
s = (s+7) & ~7;
else
s = (s+3) & ~3;
}
return s; return s;
} }
...@@ -129,7 +137,7 @@ codgen(Node *n, Node *nn) ...@@ -129,7 +137,7 @@ codgen(Node *n, Node *nn)
* generate funcdata symbol for this function. * generate funcdata symbol for this function.
* data is filled in at the end of codgen(). * data is filled in at the end of codgen().
*/ */
isvarargs = hasdotdotdot(); isvarargs = hasdotdotdot(thisfn);
gcargs = nil; gcargs = nil;
if(!isvarargs) if(!isvarargs)
gcargs = makefuncdatasym("gcargs·%d", FUNCDATA_ArgsPointerMaps); gcargs = makefuncdatasym("gcargs·%d", FUNCDATA_ArgsPointerMaps);
...@@ -212,7 +220,7 @@ supgen(Node *n) ...@@ -212,7 +220,7 @@ supgen(Node *n)
void void
gen(Node *n) gen(Node *n)
{ {
Node *l, nod; Node *l, nod, nod1;
Prog *sp, *spc, *spb; Prog *sp, *spc, *spb;
Case *cn; Case *cn;
long sbc, scc; long sbc, scc;
...@@ -273,14 +281,26 @@ loop: ...@@ -273,14 +281,26 @@ loop:
gbranch(ORETURN); gbranch(ORETURN);
break; break;
} }
if(typecmplx[n->type->etype] && !hasdotdotdot(thisfn)) {
regret(&nod, n, thisfn, 2);
sugen(l, &nod, n->type->width);
noretval(3);
gbranch(ORETURN);
break;
}
if(typecmplx[n->type->etype]) { if(typecmplx[n->type->etype]) {
sugen(l, nodret, n->type->width); sugen(l, nodret, n->type->width);
noretval(3); noretval(3);
gbranch(ORETURN); gbranch(ORETURN);
break; break;
} }
regret(&nod, n); regret(&nod1, n, thisfn, 2);
nod = nod1;
if(nod.op != OREGISTER)
regalloc(&nod, n, Z);
cgen(l, &nod); cgen(l, &nod);
if(nod1.op != OREGISTER)
gmove(&nod, &nod1);
regfree(&nod); regfree(&nod);
if(typefd[n->type->etype]) if(typefd[n->type->etype])
noretval(1); noretval(1);
...@@ -729,8 +749,10 @@ dumpgcargs(Type *fn, Sym *sym) ...@@ -729,8 +749,10 @@ dumpgcargs(Type *fn, Sym *sym)
symoffset = 0; symoffset = 0;
gextern(sym, nodconst(1), symoffset, 4); gextern(sym, nodconst(1), symoffset, 4);
symoffset += 4; symoffset += 4;
argbytes = (argsize() + ewidth[TIND] - 1); argbytes = (argsize(1) + ewidth[TIND] - 1);
bv = bvalloc((argbytes / ewidth[TIND]) * BitsPerPointer); bv = bvalloc((argbytes / ewidth[TIND]) * BitsPerPointer);
argoffset = 0;
if(hasdotdotdot(thisfn))
argoffset = align(0, fn->link, Aarg0, nil); argoffset = align(0, fn->link, Aarg0, nil);
if(argoffset > 0) { if(argoffset > 0) {
// The C calling convention returns structs by copying them to a // The C calling convention returns structs by copying them to a
......
...@@ -43,6 +43,9 @@ var use_aeshash bool ...@@ -43,6 +43,9 @@ var use_aeshash bool
// in asm_*.s // in asm_*.s
func aeshash(p unsafe.Pointer, s, h uintptr) uintptr func aeshash(p unsafe.Pointer, s, h uintptr) uintptr
func aeshash32(p unsafe.Pointer, s, h uintptr) uintptr
func aeshash64(p unsafe.Pointer, s, h uintptr) uintptr
func aeshashstr(p unsafe.Pointer, s, h uintptr) uintptr
func memhash(p unsafe.Pointer, s, h uintptr) uintptr { func memhash(p unsafe.Pointer, s, h uintptr) uintptr {
if !nacl && use_aeshash { if !nacl && use_aeshash {
......
...@@ -134,8 +134,8 @@ TEXT runtime·asminit(SB),NOSPLIT,$0-0 ...@@ -134,8 +134,8 @@ TEXT runtime·asminit(SB),NOSPLIT,$0-0
// void gosave(Gobuf*) // void gosave(Gobuf*)
// save state in Gobuf; setjmp // save state in Gobuf; setjmp
TEXT runtime·gosave(SB), NOSPLIT, $0-4 TEXT runtime·gosave(SB), NOSPLIT, $0-4
MOVL 4(SP), AX // gobuf MOVL buf+0(FP), AX // gobuf
LEAL 4(SP), BX // caller's SP LEAL buf+0(FP), BX // caller's SP
MOVL BX, gobuf_sp(AX) MOVL BX, gobuf_sp(AX)
MOVL 0(SP), BX // caller's PC MOVL 0(SP), BX // caller's PC
MOVL BX, gobuf_pc(AX) MOVL BX, gobuf_pc(AX)
...@@ -149,7 +149,7 @@ TEXT runtime·gosave(SB), NOSPLIT, $0-4 ...@@ -149,7 +149,7 @@ TEXT runtime·gosave(SB), NOSPLIT, $0-4
// void gogo(Gobuf*) // void gogo(Gobuf*)
// restore state from Gobuf; longjmp // restore state from Gobuf; longjmp
TEXT runtime·gogo(SB), NOSPLIT, $0-4 TEXT runtime·gogo(SB), NOSPLIT, $0-4
MOVL 4(SP), BX // gobuf MOVL buf+0(FP), BX // gobuf
MOVL gobuf_g(BX), DX MOVL gobuf_g(BX), DX
MOVL 0(DX), CX // make sure g != nil MOVL 0(DX), CX // make sure g != nil
get_tls(CX) get_tls(CX)
...@@ -174,7 +174,7 @@ TEXT runtime·mcall(SB), NOSPLIT, $0-4 ...@@ -174,7 +174,7 @@ TEXT runtime·mcall(SB), NOSPLIT, $0-4
MOVL g(CX), AX // save state in g->sched MOVL g(CX), AX // save state in g->sched
MOVL 0(SP), BX // caller's PC MOVL 0(SP), BX // caller's PC
MOVL BX, (g_sched+gobuf_pc)(AX) MOVL BX, (g_sched+gobuf_pc)(AX)
LEAL 4(SP), BX // caller's SP LEAL fn+0(FP), BX // caller's SP
MOVL BX, (g_sched+gobuf_sp)(AX) MOVL BX, (g_sched+gobuf_sp)(AX)
MOVL AX, (g_sched+gobuf_g)(AX) MOVL AX, (g_sched+gobuf_g)(AX)
...@@ -318,7 +318,7 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-12 ...@@ -318,7 +318,7 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-12
// restore when returning from f. // restore when returning from f.
MOVL 0(SP), AX // our caller's PC MOVL 0(SP), AX // our caller's PC
MOVL AX, (m_morebuf+gobuf_pc)(BX) MOVL AX, (m_morebuf+gobuf_pc)(BX)
LEAL 4(SP), AX // our caller's SP LEAL fv+0(FP), AX // our caller's SP
MOVL AX, (m_morebuf+gobuf_sp)(BX) MOVL AX, (m_morebuf+gobuf_sp)(BX)
MOVL g(CX), AX MOVL g(CX), AX
MOVL AX, (m_morebuf+gobuf_g)(BX) MOVL AX, (m_morebuf+gobuf_g)(BX)
...@@ -334,9 +334,9 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-12 ...@@ -334,9 +334,9 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-12
// If it turns out that f needs a larger frame than // If it turns out that f needs a larger frame than
// the default stack, f's usual stack growth prolog will // the default stack, f's usual stack growth prolog will
// allocate a new segment (and recopy the arguments). // allocate a new segment (and recopy the arguments).
MOVL 4(SP), AX // fn MOVL fv+0(FP), AX // fn
MOVL 8(SP), DX // arg frame MOVL addr+4(FP), DX // arg frame
MOVL 12(SP), CX // arg size MOVL size+8(FP), CX // arg size
MOVL AX, m_cret(BX) // f's PC MOVL AX, m_cret(BX) // f's PC
MOVL DX, m_moreargp(BX) // f's argument pointer MOVL DX, m_moreargp(BX) // f's argument pointer
...@@ -481,7 +481,6 @@ TEXT runtime·lessstack(SB), NOSPLIT, $0-0 ...@@ -481,7 +481,6 @@ TEXT runtime·lessstack(SB), NOSPLIT, $0-0
MOVL $0, 0x1004 // crash if oldstack returns MOVL $0, 0x1004 // crash if oldstack returns
RET RET
// bool cas(int32 *val, int32 old, int32 new) // bool cas(int32 *val, int32 old, int32 new)
// Atomically: // Atomically:
// if(*val == old){ // if(*val == old){
...@@ -489,16 +488,18 @@ TEXT runtime·lessstack(SB), NOSPLIT, $0-0 ...@@ -489,16 +488,18 @@ TEXT runtime·lessstack(SB), NOSPLIT, $0-0
// return 1; // return 1;
// }else // }else
// return 0; // return 0;
TEXT runtime·cas(SB), NOSPLIT, $0-12 TEXT runtime·cas(SB), NOSPLIT, $0-13
MOVL 4(SP), BX MOVL ptr+0(FP), BX
MOVL 8(SP), AX MOVL old+4(FP), AX
MOVL 12(SP), CX MOVL new+8(FP), CX
LOCK LOCK
CMPXCHGL CX, 0(BX) CMPXCHGL CX, 0(BX)
JZ 3(PC) JZ 4(PC)
MOVL $0, AX MOVL $0, AX
MOVB AX, ret+12(FP)
RET RET
MOVL $1, AX MOVL $1, AX
MOVB AX, ret+12(FP)
RET RET
// bool runtime·cas64(uint64 *val, uint64 old, uint64 new) // bool runtime·cas64(uint64 *val, uint64 old, uint64 new)
...@@ -509,19 +510,21 @@ TEXT runtime·cas(SB), NOSPLIT, $0-12 ...@@ -509,19 +510,21 @@ TEXT runtime·cas(SB), NOSPLIT, $0-12
// } else { // } else {
// return 0; // return 0;
// } // }
TEXT runtime·cas64(SB), NOSPLIT, $0-20 TEXT runtime·cas64(SB), NOSPLIT, $0-21
MOVL 4(SP), BP MOVL ptr+0(FP), BP
MOVL 8(SP), AX MOVL old_lo+4(FP), AX
MOVL 12(SP), DX MOVL old_hi+8(FP), DX
MOVL 16(SP), BX MOVL new_lo+12(FP), BX
MOVL 20(SP), CX MOVL new_hi+16(FP), CX
LOCK LOCK
CMPXCHG8B 0(BP) CMPXCHG8B 0(BP)
JNZ cas64_fail JNZ cas64_fail
MOVL $1, AX MOVL $1, AX
MOVB AX, ret+20(FP)
RET RET
cas64_fail: cas64_fail:
MOVL $0, AX MOVL $0, AX
MOVB AX, ret+20(FP)
RET RET
// bool casp(void **p, void *old, void *new) // bool casp(void **p, void *old, void *new)
...@@ -531,45 +534,50 @@ cas64_fail: ...@@ -531,45 +534,50 @@ cas64_fail:
// return 1; // return 1;
// }else // }else
// return 0; // return 0;
TEXT runtime·casp(SB), NOSPLIT, $0-12 TEXT runtime·casp(SB), NOSPLIT, $0-13
MOVL 4(SP), BX MOVL ptr+0(FP), BX
MOVL 8(SP), AX MOVL old+4(FP), AX
MOVL 12(SP), CX MOVL new+8(FP), CX
LOCK LOCK
CMPXCHGL CX, 0(BX) CMPXCHGL CX, 0(BX)
JZ 3(PC) JZ 4(PC)
MOVL $0, AX MOVL $0, AX
MOVB AX, ret+12(FP)
RET RET
MOVL $1, AX MOVL $1, AX
MOVB AX, ret+12(FP)
RET RET
// uint32 xadd(uint32 volatile *val, int32 delta) // uint32 xadd(uint32 volatile *val, int32 delta)
// Atomically: // Atomically:
// *val += delta; // *val += delta;
// return *val; // return *val;
TEXT runtime·xadd(SB), NOSPLIT, $0-8 TEXT runtime·xadd(SB), NOSPLIT, $0-12
MOVL 4(SP), BX MOVL ptr+0(FP), BX
MOVL 8(SP), AX MOVL delta+4(FP), AX
MOVL AX, CX MOVL AX, CX
LOCK LOCK
XADDL AX, 0(BX) XADDL AX, 0(BX)
ADDL CX, AX ADDL CX, AX
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·xchg(SB), NOSPLIT, $0-8 TEXT runtime·xchg(SB), NOSPLIT, $0-12
MOVL 4(SP), BX MOVL ptr+0(FP), BX
MOVL 8(SP), AX MOVL new+4(FP), AX
XCHGL AX, 0(BX) XCHGL AX, 0(BX)
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·xchgp(SB), NOSPLIT, $0-8 TEXT runtime·xchgp(SB), NOSPLIT, $0-12
MOVL 4(SP), BX MOVL ptr+0(FP), BX
MOVL 8(SP), AX MOVL new+4(FP), AX
XCHGL AX, 0(BX) XCHGL AX, 0(BX)
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·procyield(SB),NOSPLIT,$0-0 TEXT runtime·procyield(SB),NOSPLIT,$0-0
MOVL 4(SP), AX MOVL cycles+0(FP), AX
again: again:
PAUSE PAUSE
SUBL $1, AX SUBL $1, AX
...@@ -577,23 +585,21 @@ again: ...@@ -577,23 +585,21 @@ again:
RET RET
TEXT runtime·atomicstorep(SB), NOSPLIT, $0-8 TEXT runtime·atomicstorep(SB), NOSPLIT, $0-8
MOVL 4(SP), BX MOVL ptr+0(FP), BX
MOVL 8(SP), AX MOVL val+4(FP), AX
XCHGL AX, 0(BX) XCHGL AX, 0(BX)
RET RET
TEXT runtime·atomicstore(SB), NOSPLIT, $0-8 TEXT runtime·atomicstore(SB), NOSPLIT, $0-8
MOVL 4(SP), BX MOVL ptr+0(FP), BX
MOVL 8(SP), AX MOVL val+4(FP), AX
XCHGL AX, 0(BX) XCHGL AX, 0(BX)
RET RET
// uint64 atomicload64(uint64 volatile* addr); // uint64 atomicload64(uint64 volatile* addr);
// so actually TEXT runtime·atomicload64(SB), NOSPLIT, $0-12
// void atomicload64(uint64 *res, uint64 volatile *addr); MOVL ptr+0(FP), AX
TEXT runtime·atomicload64(SB), NOSPLIT, $0-8 LEAL ret_lo+4(FP), BX
MOVL 4(SP), BX
MOVL 8(SP), AX
// MOVQ (%EAX), %MM0 // MOVQ (%EAX), %MM0
BYTE $0x0f; BYTE $0x6f; BYTE $0x00 BYTE $0x0f; BYTE $0x6f; BYTE $0x00
// MOVQ %MM0, 0(%EBX) // MOVQ %MM0, 0(%EBX)
...@@ -604,7 +610,7 @@ TEXT runtime·atomicload64(SB), NOSPLIT, $0-8 ...@@ -604,7 +610,7 @@ TEXT runtime·atomicload64(SB), NOSPLIT, $0-8
// void runtime·atomicstore64(uint64 volatile* addr, uint64 v); // void runtime·atomicstore64(uint64 volatile* addr, uint64 v);
TEXT runtime·atomicstore64(SB), NOSPLIT, $0-12 TEXT runtime·atomicstore64(SB), NOSPLIT, $0-12
MOVL 4(SP), AX MOVL ptr+0(FP), AX
// MOVQ and EMMS were introduced on the Pentium MMX. // MOVQ and EMMS were introduced on the Pentium MMX.
// MOVQ 0x8(%ESP), %MM0 // MOVQ 0x8(%ESP), %MM0
BYTE $0x0f; BYTE $0x6f; BYTE $0x44; BYTE $0x24; BYTE $0x08 BYTE $0x0f; BYTE $0x6f; BYTE $0x44; BYTE $0x24; BYTE $0x08
...@@ -620,7 +626,7 @@ TEXT runtime·atomicstore64(SB), NOSPLIT, $0-12 ...@@ -620,7 +626,7 @@ TEXT runtime·atomicstore64(SB), NOSPLIT, $0-12
RET RET
// void runtime·atomicor8(byte volatile*, byte); // void runtime·atomicor8(byte volatile*, byte);
TEXT runtime·atomicor8(SB), NOSPLIT, $0-8 TEXT runtime·atomicor8(SB), NOSPLIT, $0-5
MOVL ptr+0(FP), AX MOVL ptr+0(FP), AX
MOVB val+4(FP), BX MOVB val+4(FP), BX
LOCK LOCK
...@@ -633,8 +639,8 @@ TEXT runtime·atomicor8(SB), NOSPLIT, $0-8 ...@@ -633,8 +639,8 @@ TEXT runtime·atomicor8(SB), NOSPLIT, $0-8
// 2. sub 5 bytes from the callers return // 2. sub 5 bytes from the callers return
// 3. jmp to the argument // 3. jmp to the argument
TEXT runtime·jmpdefer(SB), NOSPLIT, $0-8 TEXT runtime·jmpdefer(SB), NOSPLIT, $0-8
MOVL 4(SP), DX // fn MOVL fv+0(FP), DX // fn
MOVL 8(SP), BX // caller sp MOVL argp+4(FP), BX // caller sp
LEAL -4(BX), SP // caller sp after CALL LEAL -4(BX), SP // caller sp after CALL
SUBL $5, (SP) // return to CALL again SUBL $5, (SP) // return to CALL again
MOVL 0(DX), BX MOVL 0(DX), BX
...@@ -804,7 +810,7 @@ havem: ...@@ -804,7 +810,7 @@ havem:
RET RET
// void setg(G*); set g. for use by needm. // void setg(G*); set g. for use by needm.
TEXT runtime·setg(SB), NOSPLIT, $0-8 TEXT runtime·setg(SB), NOSPLIT, $0-4
MOVL gg+0(FP), BX MOVL gg+0(FP), BX
#ifdef GOOS_windows #ifdef GOOS_windows
CMPL BX, $0 CMPL BX, $0
...@@ -839,9 +845,10 @@ TEXT runtime·stackcheck(SB), NOSPLIT, $0-0 ...@@ -839,9 +845,10 @@ TEXT runtime·stackcheck(SB), NOSPLIT, $0-0
INT $3 INT $3
RET RET
TEXT runtime·getcallerpc(SB),NOSPLIT,$0-4 TEXT runtime·getcallerpc(SB),NOSPLIT,$0-8
MOVL x+0(FP),AX // addr of first arg MOVL argp+0(FP),AX // addr of first arg
MOVL -4(AX),AX // get calling pc MOVL -4(AX),AX // get calling pc
MOVL AX, ret+4(FP)
RET RET
TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-8 TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-8
...@@ -851,13 +858,14 @@ TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-8 ...@@ -851,13 +858,14 @@ TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-8
RET RET
TEXT runtime·setcallerpc(SB),NOSPLIT,$0-8 TEXT runtime·setcallerpc(SB),NOSPLIT,$0-8
MOVL x+0(FP),AX // addr of first arg MOVL argp+0(FP),AX // addr of first arg
MOVL x+4(FP), BX MOVL pc+4(FP), BX
MOVL BX, -4(AX) // set calling pc MOVL BX, -4(AX) // set calling pc
RET RET
TEXT runtime·getcallersp(SB), NOSPLIT, $0-4 TEXT runtime·getcallersp(SB), NOSPLIT, $0-8
MOVL sp+0(FP), AX MOVL argp+0(FP), AX
MOVL AX, ret+4(FP)
RET RET
// func gogetcallersp(p unsafe.Pointer) uintptr // func gogetcallersp(p unsafe.Pointer) uintptr
...@@ -868,11 +876,10 @@ TEXT runtime·gogetcallersp(SB),NOSPLIT,$0-8 ...@@ -868,11 +876,10 @@ TEXT runtime·gogetcallersp(SB),NOSPLIT,$0-8
// int64 runtime·cputicks(void), so really // int64 runtime·cputicks(void), so really
// void runtime·cputicks(int64 *ticks) // void runtime·cputicks(int64 *ticks)
TEXT runtime·cputicks(SB),NOSPLIT,$0-4 TEXT runtime·cputicks(SB),NOSPLIT,$0-8
RDTSC RDTSC
MOVL ret+0(FP), DI MOVL AX, ret_lo+0(FP)
MOVL AX, 0(DI) MOVL DX, ret_hi+4(FP)
MOVL DX, 4(DI)
RET RET
TEXT runtime·gocputicks(SB),NOSPLIT,$0-8 TEXT runtime·gocputicks(SB),NOSPLIT,$0-8
...@@ -976,7 +983,7 @@ finalize: ...@@ -976,7 +983,7 @@ finalize:
AESENC X2, X0 AESENC X2, X0
AESENC X3, X0 AESENC X3, X0
AESENC X2, X0 AESENC X2, X0
MOVL X0, res+12(FP) MOVL X0, ret+12(FP)
RET RET
TEXT runtime·aeshash32(SB),NOSPLIT,$0-16 TEXT runtime·aeshash32(SB),NOSPLIT,$0-16
...@@ -987,7 +994,7 @@ TEXT runtime·aeshash32(SB),NOSPLIT,$0-16 ...@@ -987,7 +994,7 @@ TEXT runtime·aeshash32(SB),NOSPLIT,$0-16
AESENC runtime·aeskeysched+0(SB), X0 AESENC runtime·aeskeysched+0(SB), X0
AESENC runtime·aeskeysched+16(SB), X0 AESENC runtime·aeskeysched+16(SB), X0
AESENC runtime·aeskeysched+0(SB), X0 AESENC runtime·aeskeysched+0(SB), X0
MOVL X0, res+12(FP) MOVL X0, ret+12(FP)
RET RET
TEXT runtime·aeshash64(SB),NOSPLIT,$0-16 TEXT runtime·aeshash64(SB),NOSPLIT,$0-16
...@@ -998,7 +1005,7 @@ TEXT runtime·aeshash64(SB),NOSPLIT,$0-16 ...@@ -998,7 +1005,7 @@ TEXT runtime·aeshash64(SB),NOSPLIT,$0-16
AESENC runtime·aeskeysched+0(SB), X0 AESENC runtime·aeskeysched+0(SB), X0
AESENC runtime·aeskeysched+16(SB), X0 AESENC runtime·aeskeysched+16(SB), X0
AESENC runtime·aeskeysched+0(SB), X0 AESENC runtime·aeskeysched+0(SB), X0
MOVL X0, res+12(FP) MOVL X0, ret+12(FP)
RET RET
// simple mask to get rid of data in the high part of the register. // simple mask to get rid of data in the high part of the register.
...@@ -1309,12 +1316,12 @@ equal: ...@@ -1309,12 +1316,12 @@ equal:
RET RET
TEXT runtime·cmpstring(SB),NOSPLIT,$0-20 TEXT runtime·cmpstring(SB),NOSPLIT,$0-20
MOVL s1+0(FP), SI MOVL s1_base+0(FP), SI
MOVL s1+4(FP), BX MOVL s1_len+4(FP), BX
MOVL s2+8(FP), DI MOVL s2_base+8(FP), DI
MOVL s2+12(FP), DX MOVL s2_len+12(FP), DX
CALL runtime·cmpbody(SB) CALL runtime·cmpbody(SB)
MOVL AX, res+16(FP) MOVL AX, ret+16(FP)
RET RET
TEXT bytes·Compare(SB),NOSPLIT,$0-28 TEXT bytes·Compare(SB),NOSPLIT,$0-28
...@@ -1323,7 +1330,7 @@ TEXT bytes·Compare(SB),NOSPLIT,$0-28 ...@@ -1323,7 +1330,7 @@ TEXT bytes·Compare(SB),NOSPLIT,$0-28
MOVL s2+12(FP), DI MOVL s2+12(FP), DI
MOVL s2+16(FP), DX MOVL s2+16(FP), DX
CALL runtime·cmpbody(SB) CALL runtime·cmpbody(SB)
MOVL AX, res+24(FP) MOVL AX, ret+24(FP)
RET RET
TEXT bytes·IndexByte(SB),NOSPLIT,$0 TEXT bytes·IndexByte(SB),NOSPLIT,$0
......
...@@ -125,8 +125,8 @@ TEXT runtime·asminit(SB),NOSPLIT,$0-0 ...@@ -125,8 +125,8 @@ TEXT runtime·asminit(SB),NOSPLIT,$0-0
// void gosave(Gobuf*) // void gosave(Gobuf*)
// save state in Gobuf; setjmp // save state in Gobuf; setjmp
TEXT runtime·gosave(SB), NOSPLIT, $0-8 TEXT runtime·gosave(SB), NOSPLIT, $0-8
MOVQ 8(SP), AX // gobuf MOVQ buf+0(FP), AX // gobuf
LEAQ 8(SP), BX // caller's SP LEAQ buf+0(FP), BX // caller's SP
MOVQ BX, gobuf_sp(AX) MOVQ BX, gobuf_sp(AX)
MOVQ 0(SP), BX // caller's PC MOVQ 0(SP), BX // caller's PC
MOVQ BX, gobuf_pc(AX) MOVQ BX, gobuf_pc(AX)
...@@ -140,7 +140,7 @@ TEXT runtime·gosave(SB), NOSPLIT, $0-8 ...@@ -140,7 +140,7 @@ TEXT runtime·gosave(SB), NOSPLIT, $0-8
// void gogo(Gobuf*) // void gogo(Gobuf*)
// restore state from Gobuf; longjmp // restore state from Gobuf; longjmp
TEXT runtime·gogo(SB), NOSPLIT, $0-8 TEXT runtime·gogo(SB), NOSPLIT, $0-8
MOVQ 8(SP), BX // gobuf MOVQ buf+0(FP), BX // gobuf
MOVQ gobuf_g(BX), DX MOVQ gobuf_g(BX), DX
MOVQ 0(DX), CX // make sure g != nil MOVQ 0(DX), CX // make sure g != nil
get_tls(CX) get_tls(CX)
...@@ -165,7 +165,7 @@ TEXT runtime·mcall(SB), NOSPLIT, $0-8 ...@@ -165,7 +165,7 @@ TEXT runtime·mcall(SB), NOSPLIT, $0-8
MOVQ g(CX), AX // save state in g->sched MOVQ g(CX), AX // save state in g->sched
MOVQ 0(SP), BX // caller's PC MOVQ 0(SP), BX // caller's PC
MOVQ BX, (g_sched+gobuf_pc)(AX) MOVQ BX, (g_sched+gobuf_pc)(AX)
LEAQ 8(SP), BX // caller's SP LEAQ fn+0(FP), BX // caller's SP
MOVQ BX, (g_sched+gobuf_sp)(AX) MOVQ BX, (g_sched+gobuf_sp)(AX)
MOVQ AX, (g_sched+gobuf_g)(AX) MOVQ AX, (g_sched+gobuf_g)(AX)
...@@ -297,7 +297,7 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-20 ...@@ -297,7 +297,7 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-20
// restore when returning from f. // restore when returning from f.
MOVQ 0(SP), AX // our caller's PC MOVQ 0(SP), AX // our caller's PC
MOVQ AX, (m_morebuf+gobuf_pc)(BX) MOVQ AX, (m_morebuf+gobuf_pc)(BX)
LEAQ 8(SP), AX // our caller's SP LEAQ fv+0(FP), AX // our caller's SP
MOVQ AX, (m_morebuf+gobuf_sp)(BX) MOVQ AX, (m_morebuf+gobuf_sp)(BX)
MOVQ g(CX), AX MOVQ g(CX), AX
MOVQ AX, (m_morebuf+gobuf_g)(BX) MOVQ AX, (m_morebuf+gobuf_g)(BX)
...@@ -314,9 +314,9 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-20 ...@@ -314,9 +314,9 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-20
// If it turns out that f needs a larger frame than // If it turns out that f needs a larger frame than
// the default stack, f's usual stack growth prolog will // the default stack, f's usual stack growth prolog will
// allocate a new segment (and recopy the arguments). // allocate a new segment (and recopy the arguments).
MOVQ 8(SP), AX // fn MOVQ fv+0(FP), AX // fn
MOVQ 16(SP), DX // arg frame MOVQ addr+8(FP), DX // arg frame
MOVL 24(SP), CX // arg size MOVL size+16(FP), CX // arg size
MOVQ AX, m_cret(BX) // f's PC MOVQ AX, m_cret(BX) // f's PC
MOVQ DX, m_moreargp(BX) // argument frame pointer MOVQ DX, m_moreargp(BX) // argument frame pointer
...@@ -584,16 +584,18 @@ TEXT runtime·morestack48_noctxt(SB),NOSPLIT,$0 ...@@ -584,16 +584,18 @@ TEXT runtime·morestack48_noctxt(SB),NOSPLIT,$0
// return 1; // return 1;
// } else // } else
// return 0; // return 0;
TEXT runtime·cas(SB), NOSPLIT, $0-16 TEXT runtime·cas(SB), NOSPLIT, $0-17
MOVQ 8(SP), BX MOVQ ptr+0(FP), BX
MOVL 16(SP), AX MOVL old+8(FP), AX
MOVL 20(SP), CX MOVL new+12(FP), CX
LOCK LOCK
CMPXCHGL CX, 0(BX) CMPXCHGL CX, 0(BX)
JZ 3(PC) JZ 4(PC)
MOVL $0, AX MOVL $0, AX
MOVB AX, ret+16(FP)
RET RET
MOVL $1, AX MOVL $1, AX
MOVB AX, ret+16(FP)
RET RET
// bool runtime·cas64(uint64 *val, uint64 old, uint64 new) // bool runtime·cas64(uint64 *val, uint64 old, uint64 new)
...@@ -604,17 +606,19 @@ TEXT runtime·cas(SB), NOSPLIT, $0-16 ...@@ -604,17 +606,19 @@ TEXT runtime·cas(SB), NOSPLIT, $0-16
// } else { // } else {
// return 0; // return 0;
// } // }
TEXT runtime·cas64(SB), NOSPLIT, $0-24 TEXT runtime·cas64(SB), NOSPLIT, $0-25
MOVQ 8(SP), BX MOVQ ptr+0(FP), BX
MOVQ 16(SP), AX MOVQ old+8(FP), AX
MOVQ 24(SP), CX MOVQ new+16(FP), CX
LOCK LOCK
CMPXCHGQ CX, 0(BX) CMPXCHGQ CX, 0(BX)
JNZ cas64_fail JNZ cas64_fail
MOVL $1, AX MOVL $1, AX
MOVB AX, ret+24(FP)
RET RET
cas64_fail: cas64_fail:
MOVL $0, AX MOVL $0, AX
MOVB AX, ret+24(FP)
RET RET
// bool casp(void **val, void *old, void *new) // bool casp(void **val, void *old, void *new)
...@@ -624,60 +628,67 @@ cas64_fail: ...@@ -624,60 +628,67 @@ cas64_fail:
// return 1; // return 1;
// } else // } else
// return 0; // return 0;
TEXT runtime·casp(SB), NOSPLIT, $0-24 TEXT runtime·casp(SB), NOSPLIT, $0-25
MOVQ 8(SP), BX MOVQ ptr+0(FP), BX
MOVQ 16(SP), AX MOVQ old+8(FP), AX
MOVQ 24(SP), CX MOVQ new+16(FP), CX
LOCK LOCK
CMPXCHGQ CX, 0(BX) CMPXCHGQ CX, 0(BX)
JZ 3(PC) JZ 4(PC)
MOVL $0, AX MOVL $0, AX
MOVB AX, ret+24(FP)
RET RET
MOVL $1, AX MOVL $1, AX
MOVB AX, ret+24(FP)
RET RET
// uint32 xadd(uint32 volatile *val, int32 delta) // uint32 xadd(uint32 volatile *val, int32 delta)
// Atomically: // Atomically:
// *val += delta; // *val += delta;
// return *val; // return *val;
TEXT runtime·xadd(SB), NOSPLIT, $0-12 TEXT runtime·xadd(SB), NOSPLIT, $0-20
MOVQ 8(SP), BX MOVQ ptr+0(FP), BX
MOVL 16(SP), AX MOVL delta+8(FP), AX
MOVL AX, CX MOVL AX, CX
LOCK LOCK
XADDL AX, 0(BX) XADDL AX, 0(BX)
ADDL CX, AX ADDL CX, AX
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·xadd64(SB), NOSPLIT, $0-16 TEXT runtime·xadd64(SB), NOSPLIT, $0-24
MOVQ 8(SP), BX MOVQ ptr+0(FP), BX
MOVQ 16(SP), AX MOVQ delta+8(FP), AX
MOVQ AX, CX MOVQ AX, CX
LOCK LOCK
XADDQ AX, 0(BX) XADDQ AX, 0(BX)
ADDQ CX, AX ADDQ CX, AX
MOVQ AX, ret+16(FP)
RET RET
TEXT runtime·xchg(SB), NOSPLIT, $0-12 TEXT runtime·xchg(SB), NOSPLIT, $0-20
MOVQ 8(SP), BX MOVQ ptr+0(FP), BX
MOVL 16(SP), AX MOVL new+8(FP), AX
XCHGL AX, 0(BX) XCHGL AX, 0(BX)
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·xchg64(SB), NOSPLIT, $0-16 TEXT runtime·xchg64(SB), NOSPLIT, $0-24
MOVQ 8(SP), BX MOVQ ptr+0(FP), BX
MOVQ 16(SP), AX MOVQ new+8(FP), AX
XCHGQ AX, 0(BX) XCHGQ AX, 0(BX)
MOVQ AX, ret+16(FP)
RET RET
TEXT runtime·xchgp(SB), NOSPLIT, $0-16 TEXT runtime·xchgp(SB), NOSPLIT, $0-24
MOVQ 8(SP), BX MOVQ ptr+0(FP), BX
MOVQ 16(SP), AX MOVQ new+8(FP), AX
XCHGQ AX, 0(BX) XCHGQ AX, 0(BX)
MOVQ AX, ret+16(FP)
RET RET
TEXT runtime·procyield(SB),NOSPLIT,$0-0 TEXT runtime·procyield(SB),NOSPLIT,$0-0
MOVL 8(SP), AX MOVL cycles+0(FP), AX
again: again:
PAUSE PAUSE
SUBL $1, AX SUBL $1, AX
...@@ -685,25 +696,25 @@ again: ...@@ -685,25 +696,25 @@ again:
RET RET
TEXT runtime·atomicstorep(SB), NOSPLIT, $0-16 TEXT runtime·atomicstorep(SB), NOSPLIT, $0-16
MOVQ 8(SP), BX MOVQ ptr+0(FP), BX
MOVQ 16(SP), AX MOVQ val+8(FP), AX
XCHGQ AX, 0(BX) XCHGQ AX, 0(BX)
RET RET
TEXT runtime·atomicstore(SB), NOSPLIT, $0-12 TEXT runtime·atomicstore(SB), NOSPLIT, $0-12
MOVQ 8(SP), BX MOVQ ptr+0(FP), BX
MOVL 16(SP), AX MOVL val+8(FP), AX
XCHGL AX, 0(BX) XCHGL AX, 0(BX)
RET RET
TEXT runtime·atomicstore64(SB), NOSPLIT, $0-16 TEXT runtime·atomicstore64(SB), NOSPLIT, $0-16
MOVQ 8(SP), BX MOVQ ptr+0(FP), BX
MOVQ 16(SP), AX MOVQ val+8(FP), AX
XCHGQ AX, 0(BX) XCHGQ AX, 0(BX)
RET RET
// void runtime·atomicor8(byte volatile*, byte); // void runtime·atomicor8(byte volatile*, byte);
TEXT runtime·atomicor8(SB), NOSPLIT, $0-16 TEXT runtime·atomicor8(SB), NOSPLIT, $0-9
MOVQ ptr+0(FP), AX MOVQ ptr+0(FP), AX
MOVB val+8(FP), BX MOVB val+8(FP), BX
LOCK LOCK
...@@ -716,8 +727,8 @@ TEXT runtime·atomicor8(SB), NOSPLIT, $0-16 ...@@ -716,8 +727,8 @@ TEXT runtime·atomicor8(SB), NOSPLIT, $0-16
// 2. sub 5 bytes from the callers return // 2. sub 5 bytes from the callers return
// 3. jmp to the argument // 3. jmp to the argument
TEXT runtime·jmpdefer(SB), NOSPLIT, $0-16 TEXT runtime·jmpdefer(SB), NOSPLIT, $0-16
MOVQ 8(SP), DX // fn MOVQ fv+0(FP), DX // fn
MOVQ 16(SP), BX // caller sp MOVQ argp+8(FP), BX // caller sp
LEAQ -8(BX), SP // caller sp after CALL LEAQ -8(BX), SP // caller sp after CALL
SUBQ $5, (SP) // return to CALL again SUBQ $5, (SP) // return to CALL again
MOVQ 0(DX), BX MOVQ 0(DX), BX
...@@ -891,7 +902,7 @@ havem: ...@@ -891,7 +902,7 @@ havem:
RET RET
// void setg(G*); set g. for use by needm. // void setg(G*); set g. for use by needm.
TEXT runtime·setg(SB), NOSPLIT, $0-16 TEXT runtime·setg(SB), NOSPLIT, $0-8
MOVQ gg+0(FP), BX MOVQ gg+0(FP), BX
#ifdef GOOS_windows #ifdef GOOS_windows
CMPQ BX, $0 CMPQ BX, $0
...@@ -925,9 +936,10 @@ TEXT runtime·stackcheck(SB), NOSPLIT, $0-0 ...@@ -925,9 +936,10 @@ TEXT runtime·stackcheck(SB), NOSPLIT, $0-0
INT $3 INT $3
RET RET
TEXT runtime·getcallerpc(SB),NOSPLIT,$0-8 TEXT runtime·getcallerpc(SB),NOSPLIT,$0-16
MOVQ x+0(FP),AX // addr of first arg MOVQ argp+0(FP),AX // addr of first arg
MOVQ -8(AX),AX // get calling pc MOVQ -8(AX),AX // get calling pc
MOVQ AX, ret+8(FP)
RET RET
TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-16 TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-16
...@@ -937,13 +949,14 @@ TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-16 ...@@ -937,13 +949,14 @@ TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-16
RET RET
TEXT runtime·setcallerpc(SB),NOSPLIT,$0-16 TEXT runtime·setcallerpc(SB),NOSPLIT,$0-16
MOVQ x+0(FP),AX // addr of first arg MOVQ argp+0(FP),AX // addr of first arg
MOVQ x+8(FP), BX MOVQ pc+8(FP), BX
MOVQ BX, -8(AX) // set calling pc MOVQ BX, -8(AX) // set calling pc
RET RET
TEXT runtime·getcallersp(SB),NOSPLIT,$0-8 TEXT runtime·getcallersp(SB),NOSPLIT,$0-16
MOVQ sp+0(FP), AX MOVQ argp+0(FP), AX
MOVQ AX, ret+8(FP)
RET RET
// func gogetcallersp(p unsafe.Pointer) uintptr // func gogetcallersp(p unsafe.Pointer) uintptr
...@@ -957,6 +970,7 @@ TEXT runtime·cputicks(SB),NOSPLIT,$0-0 ...@@ -957,6 +970,7 @@ TEXT runtime·cputicks(SB),NOSPLIT,$0-0
RDTSC RDTSC
SHLQ $32, DX SHLQ $32, DX
ADDQ DX, AX ADDQ DX, AX
MOVQ AX, ret+0(FP)
RET RET
TEXT runtime·gocputicks(SB),NOSPLIT,$0-8 TEXT runtime·gocputicks(SB),NOSPLIT,$0-8
...@@ -1057,7 +1071,7 @@ TEXT runtime·aeshash32(SB),NOSPLIT,$0-32 ...@@ -1057,7 +1071,7 @@ TEXT runtime·aeshash32(SB),NOSPLIT,$0-32
AESENC runtime·aeskeysched+0(SB), X0 AESENC runtime·aeskeysched+0(SB), X0
AESENC runtime·aeskeysched+16(SB), X0 AESENC runtime·aeskeysched+16(SB), X0
AESENC runtime·aeskeysched+0(SB), X0 AESENC runtime·aeskeysched+0(SB), X0
MOVQ X0, res+24(FP) MOVQ X0, ret+24(FP)
RET RET
TEXT runtime·aeshash64(SB),NOSPLIT,$0-32 TEXT runtime·aeshash64(SB),NOSPLIT,$0-32
...@@ -1068,7 +1082,7 @@ TEXT runtime·aeshash64(SB),NOSPLIT,$0-32 ...@@ -1068,7 +1082,7 @@ TEXT runtime·aeshash64(SB),NOSPLIT,$0-32
AESENC runtime·aeskeysched+0(SB), X0 AESENC runtime·aeskeysched+0(SB), X0
AESENC runtime·aeskeysched+16(SB), X0 AESENC runtime·aeskeysched+16(SB), X0
AESENC runtime·aeskeysched+0(SB), X0 AESENC runtime·aeskeysched+0(SB), X0
MOVQ X0, res+24(FP) MOVQ X0, ret+24(FP)
RET RET
// simple mask to get rid of data in the high part of the register. // simple mask to get rid of data in the high part of the register.
...@@ -1266,12 +1280,12 @@ equal: ...@@ -1266,12 +1280,12 @@ equal:
RET RET
TEXT runtime·cmpstring(SB),NOSPLIT,$0-40 TEXT runtime·cmpstring(SB),NOSPLIT,$0-40
MOVQ s1+0(FP), SI MOVQ s1_base+0(FP), SI
MOVQ s1+8(FP), BX MOVQ s1_len+8(FP), BX
MOVQ s2+16(FP), DI MOVQ s2_base+16(FP), DI
MOVQ s2+24(FP), DX MOVQ s2_len+24(FP), DX
CALL runtime·cmpbody(SB) CALL runtime·cmpbody(SB)
MOVQ AX, res+32(FP) MOVQ AX, ret+32(FP)
RET RET
TEXT bytes·Compare(SB),NOSPLIT,$0-56 TEXT bytes·Compare(SB),NOSPLIT,$0-56
......
...@@ -103,8 +103,8 @@ TEXT runtime·asminit(SB),NOSPLIT,$0-0 ...@@ -103,8 +103,8 @@ TEXT runtime·asminit(SB),NOSPLIT,$0-0
// void gosave(Gobuf*) // void gosave(Gobuf*)
// save state in Gobuf; setjmp // save state in Gobuf; setjmp
TEXT runtime·gosave(SB), NOSPLIT, $0-4 TEXT runtime·gosave(SB), NOSPLIT, $0-4
MOVL b+0(FP), AX // gobuf MOVL buf+0(FP), AX // gobuf
LEAL b+0(FP), BX // caller's SP LEAL buf+0(FP), BX // caller's SP
MOVL BX, gobuf_sp(AX) MOVL BX, gobuf_sp(AX)
MOVL 0(SP), BX // caller's PC MOVL 0(SP), BX // caller's PC
MOVL BX, gobuf_pc(AX) MOVL BX, gobuf_pc(AX)
...@@ -118,7 +118,7 @@ TEXT runtime·gosave(SB), NOSPLIT, $0-4 ...@@ -118,7 +118,7 @@ TEXT runtime·gosave(SB), NOSPLIT, $0-4
// void gogo(Gobuf*) // void gogo(Gobuf*)
// restore state from Gobuf; longjmp // restore state from Gobuf; longjmp
TEXT runtime·gogo(SB), NOSPLIT, $0-4 TEXT runtime·gogo(SB), NOSPLIT, $0-4
MOVL b+0(FP), BX // gobuf MOVL buf+0(FP), BX // gobuf
MOVL gobuf_g(BX), DX MOVL gobuf_g(BX), DX
MOVL 0(DX), CX // make sure g != nil MOVL 0(DX), CX // make sure g != nil
get_tls(CX) get_tls(CX)
...@@ -266,7 +266,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$0-0 ...@@ -266,7 +266,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$0-0
// with the desired args running the desired function. // with the desired args running the desired function.
// //
// func call(fn *byte, arg *byte, argsize uint32). // func call(fn *byte, arg *byte, argsize uint32).
TEXT runtime·newstackcall(SB), NOSPLIT, $0-20 TEXT runtime·newstackcall(SB), NOSPLIT, $0-12
get_tls(CX) get_tls(CX)
MOVL g(CX), BX MOVL g(CX), BX
MOVL g_m(BX), BX MOVL g_m(BX), BX
...@@ -275,7 +275,7 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-20 ...@@ -275,7 +275,7 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-20
// restore when returning from f. // restore when returning from f.
MOVL 0(SP), AX // our caller's PC MOVL 0(SP), AX // our caller's PC
MOVL AX, (m_morebuf+gobuf_pc)(BX) MOVL AX, (m_morebuf+gobuf_pc)(BX)
LEAL 8(SP), AX // our caller's SP LEAL addr+4(FP), AX // our caller's SP
MOVL AX, (m_morebuf+gobuf_sp)(BX) MOVL AX, (m_morebuf+gobuf_sp)(BX)
MOVL g(CX), AX MOVL g(CX), AX
MOVL AX, (m_morebuf+gobuf_g)(BX) MOVL AX, (m_morebuf+gobuf_g)(BX)
...@@ -292,9 +292,9 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-20 ...@@ -292,9 +292,9 @@ TEXT runtime·newstackcall(SB), NOSPLIT, $0-20
// If it turns out that f needs a larger frame than // If it turns out that f needs a larger frame than
// the default stack, f's usual stack growth prolog will // the default stack, f's usual stack growth prolog will
// allocate a new segment (and recopy the arguments). // allocate a new segment (and recopy the arguments).
MOVL 8(SP), AX // fn MOVL fv+0(FP), AX // fn
MOVL 12(SP), DX // arg frame MOVL addr+4(FP), DX // arg frame
MOVL 16(SP), CX // arg size MOVL size+8(FP), CX // arg size
MOVQ AX, m_cret(BX) // f's PC MOVQ AX, m_cret(BX) // f's PC
MOVL DX, m_moreargp(BX) // argument frame pointer MOVL DX, m_moreargp(BX) // argument frame pointer
...@@ -548,16 +548,18 @@ TEXT runtime·morestack48_noctxt(SB),NOSPLIT,$0 ...@@ -548,16 +548,18 @@ TEXT runtime·morestack48_noctxt(SB),NOSPLIT,$0
// return 1; // return 1;
// } else // } else
// return 0; // return 0;
TEXT runtime·cas(SB), NOSPLIT, $0-12 TEXT runtime·cas(SB), NOSPLIT, $0-17
MOVL val+0(FP), BX MOVL ptr+0(FP), BX
MOVL old+4(FP), AX MOVL old+4(FP), AX
MOVL new+8(FP), CX MOVL new+8(FP), CX
LOCK LOCK
CMPXCHGL CX, 0(BX) CMPXCHGL CX, 0(BX)
JZ 3(PC) JZ 4(PC)
MOVL $0, AX MOVL $0, AX
MOVB AX, ret+16(FP)
RET RET
MOVL $1, AX MOVL $1, AX
MOVB AX, ret+16(FP)
RET RET
// bool runtime·cas64(uint64 *val, uint64 old, uint64 new) // bool runtime·cas64(uint64 *val, uint64 old, uint64 new)
...@@ -568,17 +570,19 @@ TEXT runtime·cas(SB), NOSPLIT, $0-12 ...@@ -568,17 +570,19 @@ TEXT runtime·cas(SB), NOSPLIT, $0-12
// } else { // } else {
// return 0; // return 0;
// } // }
TEXT runtime·cas64(SB), NOSPLIT, $0-24 TEXT runtime·cas64(SB), NOSPLIT, $0-25
MOVL val+0(FP), BX MOVL ptr+0(FP), BX
MOVQ old+8(FP), AX MOVQ old+8(FP), AX
MOVQ new+16(FP), CX MOVQ new+16(FP), CX
LOCK LOCK
CMPXCHGQ CX, 0(BX) CMPXCHGQ CX, 0(BX)
JNZ cas64_fail JNZ cas64_fail
MOVL $1, AX MOVL $1, AX
MOVB AX, ret+24(FP)
RET RET
cas64_fail: cas64_fail:
MOVL $0, AX MOVL $0, AX
MOVB AX, ret+24(FP)
RET RET
// bool casp(void **val, void *old, void *new) // bool casp(void **val, void *old, void *new)
...@@ -588,54 +592,60 @@ cas64_fail: ...@@ -588,54 +592,60 @@ cas64_fail:
// return 1; // return 1;
// } else // } else
// return 0; // return 0;
TEXT runtime·casp(SB), NOSPLIT, $0-12 TEXT runtime·casp(SB), NOSPLIT, $0-17
MOVL val+0(FP), BX MOVL ptr+0(FP), BX
MOVL old+4(FP), AX MOVL old+4(FP), AX
MOVL new+8(FP), CX MOVL new+8(FP), CX
LOCK LOCK
CMPXCHGL CX, 0(BX) CMPXCHGL CX, 0(BX)
JZ 3(PC) JZ 4(PC)
MOVL $0, AX MOVL $0, AX
MOVB AX, ret+16(FP)
RET RET
MOVL $1, AX MOVL $1, AX
MOVB AX, ret+16(FP)
RET RET
// uint32 xadd(uint32 volatile *val, int32 delta) // uint32 xadd(uint32 volatile *val, int32 delta)
// Atomically: // Atomically:
// *val += delta; // *val += delta;
// return *val; // return *val;
TEXT runtime·xadd(SB), NOSPLIT, $0-8 TEXT runtime·xadd(SB), NOSPLIT, $0-12
MOVL val+0(FP), BX MOVL ptr+0(FP), BX
MOVL delta+4(FP), AX MOVL delta+4(FP), AX
MOVL AX, CX MOVL AX, CX
LOCK LOCK
XADDL AX, 0(BX) XADDL AX, 0(BX)
ADDL CX, AX ADDL CX, AX
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·xadd64(SB), NOSPLIT, $0-16 TEXT runtime·xadd64(SB), NOSPLIT, $0-24
MOVL val+0(FP), BX MOVL ptr+0(FP), BX
MOVQ delta+8(FP), AX MOVQ delta+8(FP), AX
MOVQ AX, CX MOVQ AX, CX
LOCK LOCK
XADDQ AX, 0(BX) XADDQ AX, 0(BX)
ADDQ CX, AX ADDQ CX, AX
MOVQ AX, ret+16(FP)
RET RET
TEXT runtime·xchg(SB), NOSPLIT, $0-8 TEXT runtime·xchg(SB), NOSPLIT, $0-12
MOVL val+0(FP), BX MOVL ptr+0(FP), BX
MOVL new+4(FP), AX MOVL new+4(FP), AX
XCHGL AX, 0(BX) XCHGL AX, 0(BX)
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·xchg64(SB), NOSPLIT, $0-16 TEXT runtime·xchg64(SB), NOSPLIT, $0-24
MOVL val+0(FP), BX MOVL ptr+0(FP), BX
MOVQ new+8(FP), AX MOVQ new+8(FP), AX
XCHGQ AX, 0(BX) XCHGQ AX, 0(BX)
MOVQ AX, ret+16(FP)
RET RET
TEXT runtime·procyield(SB),NOSPLIT,$0-0 TEXT runtime·procyield(SB),NOSPLIT,$0-0
MOVL val+0(FP), AX MOVL cycles+0(FP), AX
again: again:
PAUSE PAUSE
SUBL $1, AX SUBL $1, AX
...@@ -661,7 +671,7 @@ TEXT runtime·atomicstore64(SB), NOSPLIT, $0-16 ...@@ -661,7 +671,7 @@ TEXT runtime·atomicstore64(SB), NOSPLIT, $0-16
RET RET
// void runtime·atomicor8(byte volatile*, byte); // void runtime·atomicor8(byte volatile*, byte);
TEXT runtime·atomicor8(SB), NOSPLIT, $0-8 TEXT runtime·atomicor8(SB), NOSPLIT, $0-5
MOVL ptr+0(FP), BX MOVL ptr+0(FP), BX
MOVB val+4(FP), AX MOVB val+4(FP), AX
LOCK LOCK
...@@ -673,9 +683,9 @@ TEXT runtime·atomicor8(SB), NOSPLIT, $0-8 ...@@ -673,9 +683,9 @@ TEXT runtime·atomicor8(SB), NOSPLIT, $0-8
// 1. pop the caller // 1. pop the caller
// 2. sub 5 bytes from the callers return // 2. sub 5 bytes from the callers return
// 3. jmp to the argument // 3. jmp to the argument
TEXT runtime·jmpdefer(SB), NOSPLIT, $0-16 TEXT runtime·jmpdefer(SB), NOSPLIT, $0-8
MOVL fn+0(FP), DX MOVL fv+0(FP), DX
MOVL callersp+4(FP), BX MOVL argp+4(FP), BX
LEAL -8(BX), SP // caller sp after CALL LEAL -8(BX), SP // caller sp after CALL
SUBL $5, (SP) // return to CALL again SUBL $5, (SP) // return to CALL again
MOVL 0(DX), BX MOVL 0(DX), BX
...@@ -695,7 +705,7 @@ TEXT runtime·cgocallback(SB),NOSPLIT,$0-12 ...@@ -695,7 +705,7 @@ TEXT runtime·cgocallback(SB),NOSPLIT,$0-12
// void setg(G*); set g. for use by needm. // void setg(G*); set g. for use by needm.
// Not implemented. // Not implemented.
TEXT runtime·setg(SB), NOSPLIT, $0-8 TEXT runtime·setg(SB), NOSPLIT, $0-4
MOVL 0, AX MOVL 0, AX
RET RET
...@@ -726,9 +736,10 @@ TEXT runtime·memclr(SB),NOSPLIT,$0-8 ...@@ -726,9 +736,10 @@ TEXT runtime·memclr(SB),NOSPLIT,$0-8
STOSB STOSB
RET RET
TEXT runtime·getcallerpc(SB),NOSPLIT,$0-8 TEXT runtime·getcallerpc(SB),NOSPLIT,$0-12
MOVL x+0(FP),AX // addr of first arg MOVL argp+0(FP),AX // addr of first arg
MOVL -8(AX),AX // get calling pc MOVL -8(AX),AX // get calling pc
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-12 TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-12
...@@ -737,14 +748,15 @@ TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-12 ...@@ -737,14 +748,15 @@ TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-12
MOVL AX, ret+8(FP) MOVL AX, ret+8(FP)
RET RET
TEXT runtime·setcallerpc(SB),NOSPLIT,$0-16 TEXT runtime·setcallerpc(SB),NOSPLIT,$0-8
MOVL x+0(FP),AX // addr of first arg MOVL argp+0(FP),AX // addr of first arg
MOVL pc+4(FP), BX // pc to set MOVL pc+4(FP), BX // pc to set
MOVQ BX, -8(AX) // set calling pc MOVQ BX, -8(AX) // set calling pc
RET RET
TEXT runtime·getcallersp(SB),NOSPLIT,$0-8 TEXT runtime·getcallersp(SB),NOSPLIT,$0-12
MOVL sp+0(FP), AX MOVL argp+0(FP), AX
MOVL AX, ret+8(FP)
RET RET
// func gogetcallersp(p unsafe.Pointer) uintptr // func gogetcallersp(p unsafe.Pointer) uintptr
...@@ -758,6 +770,7 @@ TEXT runtime·cputicks(SB),NOSPLIT,$0-0 ...@@ -758,6 +770,7 @@ TEXT runtime·cputicks(SB),NOSPLIT,$0-0
RDTSC RDTSC
SHLQ $32, DX SHLQ $32, DX
ADDQ DX, AX ADDQ DX, AX
MOVQ AX, ret+0(FP)
RET RET
TEXT runtime·gocputicks(SB),NOSPLIT,$0-8 TEXT runtime·gocputicks(SB),NOSPLIT,$0-8
...@@ -784,16 +797,20 @@ GLOBL runtime·tls0(SB), $64 ...@@ -784,16 +797,20 @@ GLOBL runtime·tls0(SB), $64
// write the implementations. Can copy and adjust the ones // write the implementations. Can copy and adjust the ones
// in asm_amd64.s when the time comes. // in asm_amd64.s when the time comes.
TEXT runtime·aeshash(SB),NOSPLIT,$0-24 TEXT runtime·aeshash(SB),NOSPLIT,$0-20
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·aeshashstr(SB),NOSPLIT,$0-24 TEXT runtime·aeshashstr(SB),NOSPLIT,$0-20
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·aeshash32(SB),NOSPLIT,$0-24 TEXT runtime·aeshash32(SB),NOSPLIT,$0-20
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·aeshash64(SB),NOSPLIT,$0-24 TEXT runtime·aeshash64(SB),NOSPLIT,$0-20
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·memeq(SB),NOSPLIT,$0-17 TEXT runtime·memeq(SB),NOSPLIT,$0-17
...@@ -925,12 +942,12 @@ equal: ...@@ -925,12 +942,12 @@ equal:
RET RET
TEXT runtime·cmpstring(SB),NOSPLIT,$0-20 TEXT runtime·cmpstring(SB),NOSPLIT,$0-20
MOVL s1+0(FP), SI MOVL s1_base+0(FP), SI
MOVL s1+4(FP), BX MOVL s1_len+4(FP), BX
MOVL s2+8(FP), DI MOVL s2_base+8(FP), DI
MOVL s2+12(FP), DX MOVL s2_len+12(FP), DX
CALL runtime·cmpbody(SB) CALL runtime·cmpbody(SB)
MOVL AX, res+16(FP) MOVL AX, ret+16(FP)
RET RET
TEXT bytes·Compare(SB),NOSPLIT,$0-28 TEXT bytes·Compare(SB),NOSPLIT,$0-28
......
...@@ -468,7 +468,7 @@ TEXT runtime·lessstack(SB), NOSPLIT, $-4-0 ...@@ -468,7 +468,7 @@ TEXT runtime·lessstack(SB), NOSPLIT, $-4-0
TEXT runtime·jmpdefer(SB), NOSPLIT, $0-8 TEXT runtime·jmpdefer(SB), NOSPLIT, $0-8
MOVW 0(SP), LR MOVW 0(SP), LR
MOVW $-4(LR), LR // BL deferreturn MOVW $-4(LR), LR // BL deferreturn
MOVW fn+0(FP), R7 MOVW fv+0(FP), R7
MOVW argp+4(FP), SP MOVW argp+4(FP), SP
MOVW $-4(SP), SP // SP is 4 below argp, due to saved LR MOVW $-4(SP), SP // SP is 4 below argp, due to saved LR
MOVW 0(R7), R1 MOVW 0(R7), R1
...@@ -579,9 +579,6 @@ havem: ...@@ -579,9 +579,6 @@ havem:
// the earlier calls. // the earlier calls.
// //
// In the new goroutine, -8(SP) and -4(SP) are unused. // In the new goroutine, -8(SP) and -4(SP) are unused.
MOVW fn+4(FP), R0
MOVW frame+8(FP), R1
MOVW framesize+12(FP), R2
MOVW m_curg(R8), g MOVW m_curg(R8), g
MOVW (g_sched+gobuf_sp)(g), R4 // prepare stack as R4 MOVW (g_sched+gobuf_sp)(g), R4 // prepare stack as R4
MOVW (g_sched+gobuf_pc)(g), R5 MOVW (g_sched+gobuf_pc)(g), R5
...@@ -616,7 +613,7 @@ havem: ...@@ -616,7 +613,7 @@ havem:
RET RET
// void setg(G*); set g. for use by needm. // void setg(G*); set g. for use by needm.
TEXT runtime·setg(SB), NOSPLIT, $0-8 TEXT runtime·setg(SB), NOSPLIT, $0-4
MOVW gg+0(FP), g MOVW gg+0(FP), g
// Save g to thread-local storage. // Save g to thread-local storage.
...@@ -628,6 +625,7 @@ TEXT runtime·setg(SB), NOSPLIT, $0-8 ...@@ -628,6 +625,7 @@ TEXT runtime·setg(SB), NOSPLIT, $0-8
TEXT runtime·getcallerpc(SB),NOSPLIT,$-4-4 TEXT runtime·getcallerpc(SB),NOSPLIT,$-4-4
MOVW 0(SP), R0 MOVW 0(SP), R0
MOVW R0, ret+4(FP)
RET RET
TEXT runtime·gogetcallerpc(SB),NOSPLIT,$-4-8 TEXT runtime·gogetcallerpc(SB),NOSPLIT,$-4-8
...@@ -635,13 +633,14 @@ TEXT runtime·gogetcallerpc(SB),NOSPLIT,$-4-8 ...@@ -635,13 +633,14 @@ TEXT runtime·gogetcallerpc(SB),NOSPLIT,$-4-8
RET RET
TEXT runtime·setcallerpc(SB),NOSPLIT,$-4-8 TEXT runtime·setcallerpc(SB),NOSPLIT,$-4-8
MOVW x+4(FP), R0 MOVW pc+4(FP), R0
MOVW R0, 0(SP) MOVW R0, 0(SP)
RET RET
TEXT runtime·getcallersp(SB),NOSPLIT,$-4-4 TEXT runtime·getcallersp(SB),NOSPLIT,$-4-4
MOVW 0(FP), R0 MOVW 0(FP), R0
MOVW $-4(R0), R0 MOVW $-4(R0), R0
MOVW R0, ret+4(FP)
RET RET
// func gogetcallersp(p unsafe.Pointer) uintptr // func gogetcallersp(p unsafe.Pointer) uintptr
...@@ -658,12 +657,6 @@ TEXT runtime·abort(SB),NOSPLIT,$-4-0 ...@@ -658,12 +657,6 @@ TEXT runtime·abort(SB),NOSPLIT,$-4-0
MOVW $0, R0 MOVW $0, R0
MOVW (R0), R1 MOVW (R0), R1
TEXT runtime·gocputicks(SB),NOSPLIT,$4-8
MOVW $ret_lo+0(FP), R0
MOVW R0, 4(R13)
BL runtime·cputicks(SB)
RET
// bool armcas(int32 *val, int32 old, int32 new) // bool armcas(int32 *val, int32 old, int32 new)
// Atomically: // Atomically:
// if(*val == old){ // if(*val == old){
...@@ -1264,3 +1257,7 @@ TEXT runtime·fastrand2(SB), NOSPLIT, $-4-4 ...@@ -1264,3 +1257,7 @@ TEXT runtime·fastrand2(SB), NOSPLIT, $-4-4
MOVW R0, m_fastrand(R1) MOVW R0, m_fastrand(R1)
MOVW R0, ret+0(FP) MOVW R0, ret+0(FP)
RET RET
TEXT runtime·gocputicks(SB), NOSPLIT, $0
B runtime·cputicks(SB)
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
// void runtime·memclr(void*, uintptr) // void runtime·memclr(void*, uintptr)
TEXT runtime·memclr(SB),NOSPLIT,$0-16 TEXT runtime·memclr(SB),NOSPLIT,$0-16
MOVQ addr+0(FP), DI MOVQ ptr+0(FP), DI
MOVQ count+8(FP), CX MOVQ n+8(FP), CX
MOVQ CX, BX MOVQ CX, BX
ANDQ $7, BX ANDQ $7, BX
SHRQ $3, CX SHRQ $3, CX
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
TEXT runtime·memmove(SB), NOSPLIT, $0-12 TEXT runtime·memmove(SB), NOSPLIT, $0-12
MOVL to+0(FP), DI MOVL to+0(FP), DI
MOVL fr+4(FP), SI MOVL from+4(FP), SI
MOVL n+8(FP), BX MOVL n+8(FP), BX
CMPL SI, DI CMPL SI, DI
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
TEXT runtime·memmove(SB), NOSPLIT, $0-12 TEXT runtime·memmove(SB), NOSPLIT, $0-12
MOVL to+0(FP), DI MOVL to+0(FP), DI
MOVL fr+4(FP), SI MOVL from+4(FP), SI
MOVL n+8(FP), BX MOVL n+8(FP), BX
// REP instructions have a high startup cost, so we handle small sizes // REP instructions have a high startup cost, so we handle small sizes
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
TEXT runtime·memmove(SB), NOSPLIT, $0-24 TEXT runtime·memmove(SB), NOSPLIT, $0-24
MOVQ to+0(FP), DI MOVQ to+0(FP), DI
MOVQ fr+8(FP), SI MOVQ from+8(FP), SI
MOVQ n+16(FP), BX MOVQ n+16(FP), BX
// REP instructions have a high startup cost, so we handle small sizes // REP instructions have a high startup cost, so we handle small sizes
......
// 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
import "unsafe"
func bsdthread_create(stk, mm, gg, fn unsafe.Pointer) int32
func bsdthread_register() int32
func mach_msg_trap(h unsafe.Pointer, op int32, send_size, rcv_size, rcv_name, timeout, notify uint32) int32
func mach_reply_port() uint32
func mach_task_self() uint32
func mach_thread_self() uint32
func sysctl(mib *uint32, miblen uint32, out *byte, size *uintptr, dst *byte, ndst uintptr) int32
func sigprocmask(sig int32, new, old unsafe.Pointer)
func sigaction(mode uint32, new, old unsafe.Pointer)
func sigaltstack(new, old unsafe.Pointer)
func sigtramp()
func setitimer(mode int32, new, old unsafe.Pointer)
func kqueue() int32
func kevent(fd int32, ev1 unsafe.Pointer, nev1 int32, ev2 unsafe.Pointer, nev2 int32, ts unsafe.Pointer) int32
func closeonexec(fd int32)
func mach_semaphore_wait(sema uint32) int32
func mach_semaphore_timedwait(sema, sec, nsec uint32) int32
func mach_semaphore_signal(sema uint32) int32
func mach_semaphore_signal_all(sema uint32) int32
// 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
import "unsafe"
func lwp_create(param unsafe.Pointer) int32
func sigaltstack(new, old unsafe.Pointer)
func sigaction(sig int32, new, old unsafe.Pointer)
func sigprocmask(new, old unsafe.Pointer)
func setitimer(mode int32, new, old unsafe.Pointer)
func sysctl(mib *uint32, miblen uint32, out *byte, size *uintptr, dst *byte, ndst uintptr) int32
func getrlimit(kind int32, limit unsafe.Pointer) int32
func raise(sig int32)
func kqueue() int32
func kevent(fd int32, ev1 unsafe.Pointer, nev1 int32, ev2 unsafe.Pointer, nev2 int32, ts unsafe.Pointer) int32
func closeonexec(fd int32)
func sys_umtx_sleep(addr unsafe.Pointer, val, timeout int32) int32
func sys_umtx_wakeup(addr unsafe.Pointer, val int32) int32
// 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
import "unsafe"
func thr_new(param unsafe.Pointer, size int32)
func sigaltstack(new, old unsafe.Pointer)
func sigaction(sig int32, new, old unsafe.Pointer)
func sigprocmask(new, old unsafe.Pointer)
func setitimer(mode int32, new, old unsafe.Pointer)
func sysctl(mib *uint32, miblen uint32, out *byte, size *uintptr, dst *byte, ndst uintptr) int32
func getrlimit(kind int32, limit unsafe.Pointer) int32
func raise(sig int32)
func kqueue() int32
func kevent(fd int32, ev1 unsafe.Pointer, nev1 int32, ev2 unsafe.Pointer, nev2 int32, ts unsafe.Pointer) int32
func closeonexec(fd int32)
func sys_umtx_op(addr unsafe.Pointer, mode int32, val uint32, ptr2, ts unsafe.Pointer) int32
// 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
import "unsafe"
func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32
func clone(flags int32, stk, mm, gg, fn unsafe.Pointer) int32
func rt_sigaction(sig uintptr, new, old unsafe.Pointer, size uintptr) int32
func sigaltstack(new, old unsafe.Pointer)
func setitimer(mode int32, new, old unsafe.Pointer)
func rtsigprocmask(sig int32, new, old unsafe.Pointer, size int32)
func getrlimit(kind int32, limit unsafe.Pointer) int32
func raise(sig int32)
func epollcreate(size int32) int32
func epollcreate1(flags int32) int32
func epollctl(epfd, op, fd int32, ev unsafe.Pointer) int32
func epollwait(epfd int32, ev unsafe.Pointer, nev, timeout int32) int32
func closeonexec(fd int32)
func sched_getaffinity(pid, len uintptr, buf *uintptr) int32
// 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
import "unsafe"
func nacl_exception_stack(p unsafe.Pointer, size int32) int32
func nacl_exception_handler(fn, arg unsafe.Pointer) int32
func nacl_sem_create(flag int32) int32
func nacl_sem_wait(sem int32) int32
func nacl_sem_post(sem int32) int32
func nacl_mutex_create(flag int32) int32
func nacl_mutex_lock(mutex int32) int32
func nacl_mutex_trylock(mutex int32) int32
func nacl_mutex_unlock(mutex int32) int32
func nacl_cond_create(flag int32) int32
func nacl_cond_wait(cond, n int32) int32
func nacl_cond_signal(cond int32) int32
func nacl_cond_broadcast(cond int32) int32
func nacl_cond_timed_wait_abs(cond, lock int32, ts unsafe.Pointer)
func nacl_thread_create(fn, stk, tls, xx unsafe.Pointer) int32
func nacl_nanosleep(ts, extra unsafe.Pointer) int32
// 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
import "unsafe"
func setitimer(mode int32, new, old unsafe.Pointer)
func sigaction(sig int32, new, old unsafe.Pointer)
func sigaltstack(new, old unsafe.Pointer)
func sigprocmask(mode int32, new, old unsafe.Pointer)
func sysctl(mib *uint32, miblen uint32, out *byte, size *uintptr, dst *byte, ndst uintptr) int32
func lwp_tramp()
func raise(sig int32)
func kqueue() int32
func kevent(fd int32, ev1 unsafe.Pointer, nev1 int32, ev2 unsafe.Pointer, nev2 int32, ts unsafe.Pointer) int32
func closeonexec(fd int32)
func getcontext(ctxt unsafe.Pointer)
func lwp_create(ctxt unsafe.Pointer, flags uintptr, lwpid unsafe.Pointer) int32
func lwp_park(abstime unsafe.Pointer, unpark int32, hint, unparkhint unsafe.Pointer) int32
func lwp_unpark(lwp int32, hint unsafe.Pointer) int32
func lwp_self() int32
// 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
import "unsafe"
func setitimer(mode int32, new, old unsafe.Pointer)
func sigaction(sig int32, new, old unsafe.Pointer)
func sigaltstack(new, old unsafe.Pointer)
func sigprocmask(mode int32, new uint32) uint32
func sysctl(mib *uint32, miblen uint32, out *byte, size *uintptr, dst *byte, ndst uintptr) int32
func raise(sig int32)
func kqueue() int32
func kevent(fd int32, ev1 unsafe.Pointer, nev1 int32, ev2 unsafe.Pointer, nev2 int32, ts unsafe.Pointer) int32
func closeonexec(fd int32)
func tfork(param unsafe.Pointer, psize uintptr, mm, gg, fn unsafe.Pointer) int64
func thrsleep(ident unsafe.Pointer, clock_id int32, tsp, lock, abort unsafe.Pointer) int32
func thrwakeup(ident unsafe.Pointer, n int32) int32
// 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
import "unsafe"
func pread(fd int32, buf unsafe.Pointer, nbytes int32, offset int64) int32
func pwrite(fd int32, buf unsafe.Pointer, nbytes int32, offset int64) int32
func seek(fd int32, offset int64, whence int32) int64
func exits(msg *byte)
func brk_(addr unsafe.Pointer) uintptr
func sleep(ms int32) int32
func rfork(flags int32, stk, mm, gg, fn unsafe.Pointer) int32
func plan9_semacquire(addr *uint32, block int32) int32
func plan9_tsemacquire(addr *uint32, ms int32) int32
func plan9_semrelease(addr *uint32, count int32) int32
func notify(fn unsafe.Pointer) int32
func noted(mode int32) int32
func nsec(*int64) int64
func sigtramp(ureg, msg unsafe.Pointer)
func setfpmasks()
func errstr() string
// 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
import "unsafe"
func setitimer(mode int32, new, old unsafe.Pointer)
func sigaction(sig int32, new, old unsafe.Pointer)
func sigaltstack(new, old unsafe.Pointer)
func sigprocmask(mode int32, new, old unsafe.Pointer)
func sysctl(mib *uint32, miblen uint32, out *byte, size *uintptr, dst *byte, ndst uintptr) int32
func getrlimit(kind int32, limit unsafe.Pointer)
func asmsysvicall6(fn unsafe.Pointer)
func miniterrno(fn unsafe.Pointer)
func raise(sig int32)
func getcontext(ctxt unsafe.Pointer)
func tstart_sysvicall(mm unsafe.Pointer) uint32
func nanotime1() int64
func usleep1(usec uint32)
func osyield1()
// 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
import "unsafe"
func asmstdcall(fn unsafe.Pointer)
func getlasterror() uint32
func setlasterror(err uint32)
func usleep1(usec uint32)
...@@ -218,3 +218,48 @@ func exitsyscall() ...@@ -218,3 +218,48 @@ func exitsyscall()
func traceback(pc, sp, lr uintptr, gp *g) func traceback(pc, sp, lr uintptr, gp *g)
func tracebackothers(gp *g) func tracebackothers(gp *g)
func cgocallback(fn, frame unsafe.Pointer, framesize uintptr)
func gogo(buf *gobuf)
func gosave(buf *gobuf)
func open(name *byte, mode, perm int32) int32
func read(fd int32, p unsafe.Pointer, n int32) int32
func write(fd uintptr, p unsafe.Pointer, n int32) int32
func close(fd int32) int32
func mincore(addr unsafe.Pointer, n uintptr, dst *byte) int32
func jmpdefer(fv *funcval, argp unsafe.Pointer)
func exit1(code int32)
func asminit()
func getcallersp(argp unsafe.Pointer) uintptr
func cas(ptr *uint32, old, new uint32) bool
func cas64(ptr *uint64, old, new uint64) bool
func casp(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool
func xadd(ptr *uint32, delta int32) uint32
func xadd64(ptr *uint64, delta int64) uint64
func xchg(ptr *uint32, new uint32) uint32
func xchg64(ptr *uint64, new uint64) uint64
func xchgp(ptr *unsafe.Pointer, new unsafe.Pointer) unsafe.Pointer
func atomicstore(ptr *uint32, val uint32)
func atomicstore64(ptr *uint64, val uint64)
func atomicstorep(ptr *unsafe.Pointer, val unsafe.Pointer)
func atomicload(ptr *uint32) uint32
func atomicload64(ptr *uint64) uint64
func atomicloadp(ptr *unsafe.Pointer) unsafe.Pointer
func atomicor8(ptr *uint8, val uint8)
func setg(gg *g)
func exit(code int32)
func breakpoint()
func asmcgocall(fn, arg unsafe.Pointer)
func nanotime() int64
func usleep(usec uint32)
func cputicks() int64
func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) unsafe.Pointer
func munmap(addr unsafe.Pointer, n uintptr)
func madvise(addr unsafe.Pointer, n uintptr, flags int32)
func setcallerpc(argp unsafe.Pointer, pc uintptr)
func getcallerpc(argp unsafe.Pointer) uintptr
func newstackcall(fv *funcval, addr unsafe.Pointer, size uint32)
func procyield(cycles uint32)
func osyield()
func cgocallback_gofunc(fv *funcval, frame unsafe.Pointer, framesize uintptr)
func cmpstring(s1, s2 string) int
...@@ -28,21 +28,25 @@ TEXT runtime·exit1(SB),NOSPLIT,$0 ...@@ -28,21 +28,25 @@ TEXT runtime·exit1(SB),NOSPLIT,$0
TEXT runtime·open(SB),NOSPLIT,$0 TEXT runtime·open(SB),NOSPLIT,$0
MOVL $5, AX MOVL $5, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$0 TEXT runtime·close(SB),NOSPLIT,$0
MOVL $6, AX MOVL $6, AX
INT $0x80 INT $0x80
MOVL AX, ret+4(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$0 TEXT runtime·read(SB),NOSPLIT,$0
MOVL $3, AX MOVL $3, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$0 TEXT runtime·write(SB),NOSPLIT,$0
MOVL $4, AX MOVL $4, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·raise(SB),NOSPLIT,$16 TEXT runtime·raise(SB),NOSPLIT,$16
...@@ -59,6 +63,7 @@ TEXT runtime·raise(SB),NOSPLIT,$16 ...@@ -59,6 +63,7 @@ TEXT runtime·raise(SB),NOSPLIT,$16
TEXT runtime·mmap(SB),NOSPLIT,$0 TEXT runtime·mmap(SB),NOSPLIT,$0
MOVL $197, AX MOVL $197, AX
INT $0x80 INT $0x80
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·madvise(SB),NOSPLIT,$0 TEXT runtime·madvise(SB),NOSPLIT,$0
...@@ -206,9 +211,8 @@ TEXT time·now(SB),NOSPLIT,$0 ...@@ -206,9 +211,8 @@ TEXT time·now(SB),NOSPLIT,$0
// void nanotime(int64 *nsec) // void nanotime(int64 *nsec)
TEXT runtime·nanotime(SB),NOSPLIT,$0 TEXT runtime·nanotime(SB),NOSPLIT,$0
CALL runtime·now(SB) CALL runtime·now(SB)
MOVL ret+0(FP), DI MOVL AX, ret_lo+0(FP)
MOVL AX, 0(DI) MOVL DX, ret_hi+4(FP)
MOVL DX, 4(DI)
RET RET
TEXT runtime·sigprocmask(SB),NOSPLIT,$0 TEXT runtime·sigprocmask(SB),NOSPLIT,$0
...@@ -315,7 +319,7 @@ TEXT runtime·usleep(SB),NOSPLIT,$32 ...@@ -315,7 +319,7 @@ TEXT runtime·usleep(SB),NOSPLIT,$32
TEXT runtime·bsdthread_create(SB),NOSPLIT,$32 TEXT runtime·bsdthread_create(SB),NOSPLIT,$32
MOVL $360, AX MOVL $360, AX
// 0(SP) is where the caller PC would be; kernel skips it // 0(SP) is where the caller PC would be; kernel skips it
MOVL func+12(FP), BX MOVL fn+12(FP), BX
MOVL BX, 4(SP) // func MOVL BX, 4(SP) // func
MOVL mm+4(FP), BX MOVL mm+4(FP), BX
MOVL BX, 8(SP) // arg MOVL BX, 8(SP) // arg
...@@ -325,10 +329,12 @@ TEXT runtime·bsdthread_create(SB),NOSPLIT,$32 ...@@ -325,10 +329,12 @@ TEXT runtime·bsdthread_create(SB),NOSPLIT,$32
MOVL BX, 16(SP) // pthread MOVL BX, 16(SP) // pthread
MOVL $0x1000000, 20(SP) // flags = PTHREAD_START_CUSTOM MOVL $0x1000000, 20(SP) // flags = PTHREAD_START_CUSTOM
INT $0x80 INT $0x80
JAE 3(PC) JAE 4(PC)
NEGL AX NEGL AX
MOVL AX, ret+16(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+16(FP)
RET RET
// The thread that bsdthread_create creates starts executing here, // The thread that bsdthread_create creates starts executing here,
...@@ -382,10 +388,12 @@ TEXT runtime·bsdthread_register(SB),NOSPLIT,$40 ...@@ -382,10 +388,12 @@ TEXT runtime·bsdthread_register(SB),NOSPLIT,$40
MOVL $0, 20(SP) // targetconc_ptr MOVL $0, 20(SP) // targetconc_ptr
MOVL $0, 24(SP) // dispatchqueue_offset MOVL $0, 24(SP) // dispatchqueue_offset
INT $0x80 INT $0x80
JAE 3(PC) JAE 4(PC)
NEGL AX NEGL AX
MOVL AX, ret+0(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+0(FP)
RET RET
// Invoke Mach system call. // Invoke Mach system call.
...@@ -408,16 +416,19 @@ TEXT runtime·sysenter(SB),NOSPLIT,$0 ...@@ -408,16 +416,19 @@ TEXT runtime·sysenter(SB),NOSPLIT,$0
TEXT runtime·mach_msg_trap(SB),NOSPLIT,$0 TEXT runtime·mach_msg_trap(SB),NOSPLIT,$0
MOVL $-31, AX MOVL $-31, AX
CALL runtime·sysenter(SB) CALL runtime·sysenter(SB)
MOVL AX, ret+28(FP)
RET RET
TEXT runtime·mach_reply_port(SB),NOSPLIT,$0 TEXT runtime·mach_reply_port(SB),NOSPLIT,$0
MOVL $-26, AX MOVL $-26, AX
CALL runtime·sysenter(SB) CALL runtime·sysenter(SB)
MOVL AX, ret+0(FP)
RET RET
TEXT runtime·mach_task_self(SB),NOSPLIT,$0 TEXT runtime·mach_task_self(SB),NOSPLIT,$0
MOVL $-28, AX MOVL $-28, AX
CALL runtime·sysenter(SB) CALL runtime·sysenter(SB)
MOVL AX, ret+0(FP)
RET RET
// Mach provides trap versions of the semaphore ops, // Mach provides trap versions of the semaphore ops,
...@@ -427,24 +438,28 @@ TEXT runtime·mach_task_self(SB),NOSPLIT,$0 ...@@ -427,24 +438,28 @@ TEXT runtime·mach_task_self(SB),NOSPLIT,$0
TEXT runtime·mach_semaphore_wait(SB),NOSPLIT,$0 TEXT runtime·mach_semaphore_wait(SB),NOSPLIT,$0
MOVL $-36, AX MOVL $-36, AX
CALL runtime·sysenter(SB) CALL runtime·sysenter(SB)
MOVL AX, ret+4(FP)
RET RET
// uint32 mach_semaphore_timedwait(uint32, uint32, uint32) // uint32 mach_semaphore_timedwait(uint32, uint32, uint32)
TEXT runtime·mach_semaphore_timedwait(SB),NOSPLIT,$0 TEXT runtime·mach_semaphore_timedwait(SB),NOSPLIT,$0
MOVL $-38, AX MOVL $-38, AX
CALL runtime·sysenter(SB) CALL runtime·sysenter(SB)
MOVL AX, ret+12(FP)
RET RET
// uint32 mach_semaphore_signal(uint32) // uint32 mach_semaphore_signal(uint32)
TEXT runtime·mach_semaphore_signal(SB),NOSPLIT,$0 TEXT runtime·mach_semaphore_signal(SB),NOSPLIT,$0
MOVL $-33, AX MOVL $-33, AX
CALL runtime·sysenter(SB) CALL runtime·sysenter(SB)
MOVL AX, ret+4(FP)
RET RET
// uint32 mach_semaphore_signal_all(uint32) // uint32 mach_semaphore_signal_all(uint32)
TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0 TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0
MOVL $-34, AX MOVL $-34, AX
CALL runtime·sysenter(SB) CALL runtime·sysenter(SB)
MOVL AX, ret+4(FP)
RET RET
// setldt(int entry, int address, int limit) // setldt(int entry, int address, int limit)
...@@ -486,10 +501,12 @@ TEXT runtime·setldt(SB),NOSPLIT,$32 ...@@ -486,10 +501,12 @@ TEXT runtime·setldt(SB),NOSPLIT,$32
TEXT runtime·sysctl(SB),NOSPLIT,$0 TEXT runtime·sysctl(SB),NOSPLIT,$0
MOVL $202, AX MOVL $202, AX
INT $0x80 INT $0x80
JAE 3(PC) JAE 4(PC)
NEGL AX NEGL AX
MOVL AX, ret+24(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+24(FP)
RET RET
// int32 runtime·kqueue(void); // int32 runtime·kqueue(void);
...@@ -498,6 +515,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0 ...@@ -498,6 +515,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout); // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout);
...@@ -506,6 +524,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0 ...@@ -506,6 +524,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+24(FP)
RET RET
// int32 runtime·closeonexec(int32 fd); // int32 runtime·closeonexec(int32 fd);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
// Exit the entire program (like C exit) // Exit the entire program (like C exit)
TEXT runtime·exit(SB),NOSPLIT,$0 TEXT runtime·exit(SB),NOSPLIT,$0
MOVL 8(SP), DI // arg 1 exit status MOVL code+0(FP), DI // arg 1 exit status
MOVL $(0x2000000+1), AX // syscall entry MOVL $(0x2000000+1), AX // syscall entry
SYSCALL SYSCALL
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
...@@ -25,40 +25,44 @@ TEXT runtime·exit(SB),NOSPLIT,$0 ...@@ -25,40 +25,44 @@ TEXT runtime·exit(SB),NOSPLIT,$0
// Exit this OS thread (like pthread_exit, which eventually // Exit this OS thread (like pthread_exit, which eventually
// calls __bsdthread_terminate). // calls __bsdthread_terminate).
TEXT runtime·exit1(SB),NOSPLIT,$0 TEXT runtime·exit1(SB),NOSPLIT,$0
MOVL 8(SP), DI // arg 1 exit status MOVL code+0(FP), DI // arg 1 exit status
MOVL $(0x2000000+361), AX // syscall entry MOVL $(0x2000000+361), AX // syscall entry
SYSCALL SYSCALL
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
RET RET
TEXT runtime·open(SB),NOSPLIT,$0 TEXT runtime·open(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 pathname MOVQ name+0(FP), DI // arg 1 pathname
MOVL 16(SP), SI // arg 2 flags MOVL mode+8(FP), SI // arg 2 flags
MOVL 20(SP), DX // arg 3 mode MOVL perm+12(FP), DX // arg 3 mode
MOVL $(0x2000000+5), AX // syscall entry MOVL $(0x2000000+5), AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$0 TEXT runtime·close(SB),NOSPLIT,$0
MOVL 8(SP), DI // arg 1 fd MOVL fd+0(FP), DI // arg 1 fd
MOVL $(0x2000000+6), AX // syscall entry MOVL $(0x2000000+6), AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$0 TEXT runtime·read(SB),NOSPLIT,$0
MOVL 8(SP), DI // arg 1 fd MOVL fd+0(FP), DI // arg 1 fd
MOVQ 16(SP), SI // arg 2 buf MOVQ p+8(FP), SI // arg 2 buf
MOVL 24(SP), DX // arg 3 count MOVL n+16(FP), DX // arg 3 count
MOVL $(0x2000000+3), AX // syscall entry MOVL $(0x2000000+3), AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$0 TEXT runtime·write(SB),NOSPLIT,$0
MOVL 8(SP), DI // arg 1 fd MOVQ fd+0(FP), DI // arg 1 fd
MOVQ 16(SP), SI // arg 2 buf MOVQ p+8(FP), SI // arg 2 buf
MOVL 24(SP), DX // arg 3 count MOVL n+16(FP), DX // arg 3 count
MOVL $(0x2000000+4), AX // syscall entry MOVL $(0x2000000+4), AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·raise(SB),NOSPLIT,$24 TEXT runtime·raise(SB),NOSPLIT,$24
...@@ -72,17 +76,17 @@ TEXT runtime·raise(SB),NOSPLIT,$24 ...@@ -72,17 +76,17 @@ TEXT runtime·raise(SB),NOSPLIT,$24
RET RET
TEXT runtime·setitimer(SB), NOSPLIT, $0 TEXT runtime·setitimer(SB), NOSPLIT, $0
MOVL 8(SP), DI MOVL mode+0(FP), DI
MOVQ 16(SP), SI MOVQ new+8(FP), SI
MOVQ 24(SP), DX MOVQ old+16(FP), DX
MOVL $(0x2000000+83), AX // syscall entry MOVL $(0x2000000+83), AX // syscall entry
SYSCALL SYSCALL
RET RET
TEXT runtime·madvise(SB), NOSPLIT, $0 TEXT runtime·madvise(SB), NOSPLIT, $0
MOVQ 8(SP), DI // arg 1 addr MOVQ addr+0(FP), DI // arg 1 addr
MOVQ 16(SP), SI // arg 2 len MOVQ n+8(FP), SI // arg 2 len
MOVL 24(SP), DX // arg 3 advice MOVL flags+16(FP), DX // arg 3 advice
MOVL $(0x2000000+75), AX // syscall entry madvise MOVL $(0x2000000+75), AX // syscall entry madvise
SYSCALL SYSCALL
// ignore failure - maybe pages are locked // ignore failure - maybe pages are locked
...@@ -99,8 +103,7 @@ TEXT runtime·madvise(SB), NOSPLIT, $0 ...@@ -99,8 +103,7 @@ TEXT runtime·madvise(SB), NOSPLIT, $0
#define gtod_ns_base 0x70 #define gtod_ns_base 0x70
#define gtod_sec_base 0x78 #define gtod_sec_base 0x78
// int64 nanotime(void) TEXT nanotime<>(SB), NOSPLIT, $32
TEXT runtime·nanotime(SB), NOSPLIT, $32
MOVQ $0x7fffffe00000, BP /* comm page base */ MOVQ $0x7fffffe00000, BP /* comm page base */
// Loop trying to take a consistent snapshot // Loop trying to take a consistent snapshot
// of the time parameters. // of the time parameters.
...@@ -149,9 +152,14 @@ systime: ...@@ -149,9 +152,14 @@ systime:
ADDQ DX, AX ADDQ DX, AX
RET RET
TEXT runtime·nanotime(SB),NOSPLIT,$0-8
CALL nanotime<>(SB)
MOVQ AX, ret+0(FP)
RET
// func now() (sec int64, nsec int32) // func now() (sec int64, nsec int32)
TEXT time·now(SB),NOSPLIT,$0 TEXT time·now(SB),NOSPLIT,$8
CALL runtime·nanotime(SB) CALL nanotime<>(SB)
// generated code for // generated code for
// func f(x uint64) (uint64, uint64) { return x/1000000000, x%100000000 } // func f(x uint64) (uint64, uint64) { return x/1000000000, x%100000000 }
...@@ -169,9 +177,9 @@ TEXT time·now(SB),NOSPLIT,$0 ...@@ -169,9 +177,9 @@ TEXT time·now(SB),NOSPLIT,$0
RET RET
TEXT runtime·sigprocmask(SB),NOSPLIT,$0 TEXT runtime·sigprocmask(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL sig+0(FP), DI
MOVQ 16(SP), SI MOVQ new+8(FP), SI
MOVQ 24(SP), DX MOVQ old+16(FP), DX
MOVL $(0x2000000+329), AX // pthread_sigmask (on OS X, sigprocmask==entire process) MOVL $(0x2000000+329), AX // pthread_sigmask (on OS X, sigprocmask==entire process)
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
...@@ -179,11 +187,11 @@ TEXT runtime·sigprocmask(SB),NOSPLIT,$0 ...@@ -179,11 +187,11 @@ TEXT runtime·sigprocmask(SB),NOSPLIT,$0
RET RET
TEXT runtime·sigaction(SB),NOSPLIT,$0 TEXT runtime·sigaction(SB),NOSPLIT,$0
MOVL 8(SP), DI // arg 1 sig MOVL mode+0(FP), DI // arg 1 sig
MOVQ 16(SP), SI // arg 2 act MOVQ new+8(FP), SI // arg 2 act
MOVQ 24(SP), DX // arg 3 oact MOVQ old+16(FP), DX // arg 3 oact
MOVQ 24(SP), CX // arg 3 oact MOVQ old+16(FP), CX // arg 3 oact
MOVQ 24(SP), R10 // arg 3 oact MOVQ old+16(FP), R10 // arg 3 oact
MOVL $(0x2000000+46), AX // syscall entry MOVL $(0x2000000+46), AX // syscall entry
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
...@@ -234,19 +242,20 @@ sigtramp_ret: ...@@ -234,19 +242,20 @@ sigtramp_ret:
INT $3 // not reached INT $3 // not reached
TEXT runtime·mmap(SB),NOSPLIT,$0 TEXT runtime·mmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 addr MOVQ addr+0(FP), DI // arg 1 addr
MOVQ 16(SP), SI // arg 2 len MOVQ n+8(FP), SI // arg 2 len
MOVL 24(SP), DX // arg 3 prot MOVL prot+16(FP), DX // arg 3 prot
MOVL 28(SP), R10 // arg 4 flags MOVL flags+20(FP), R10 // arg 4 flags
MOVL 32(SP), R8 // arg 5 fid MOVL fd+24(FP), R8 // arg 5 fid
MOVL 36(SP), R9 // arg 6 offset MOVL off+28(FP), R9 // arg 6 offset
MOVL $(0x2000000+197), AX // syscall entry MOVL $(0x2000000+197), AX // syscall entry
SYSCALL SYSCALL
MOVQ AX, ret+32(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$0 TEXT runtime·munmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 addr MOVQ addr+0(FP), DI // arg 1 addr
MOVQ 16(SP), SI // arg 2 len MOVQ n+8(FP), SI // arg 2 len
MOVL $(0x2000000+73), AX // syscall entry MOVL $(0x2000000+73), AX // syscall entry
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
...@@ -293,10 +302,12 @@ TEXT runtime·bsdthread_create(SB),NOSPLIT,$0 ...@@ -293,10 +302,12 @@ TEXT runtime·bsdthread_create(SB),NOSPLIT,$0
MOVQ $0, R9 // paranoia MOVQ $0, R9 // paranoia
MOVQ $(0x2000000+360), AX // bsdthread_create MOVQ $(0x2000000+360), AX // bsdthread_create
SYSCALL SYSCALL
JCC 3(PC) JCC 4(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+32(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+32(FP)
RET RET
// The thread that bsdthread_create creates starts executing here, // The thread that bsdthread_create creates starts executing here,
...@@ -346,42 +357,48 @@ TEXT runtime·bsdthread_register(SB),NOSPLIT,$0 ...@@ -346,42 +357,48 @@ TEXT runtime·bsdthread_register(SB),NOSPLIT,$0
MOVQ $0, R9 // dispatchqueue_offset MOVQ $0, R9 // dispatchqueue_offset
MOVQ $(0x2000000+366), AX // bsdthread_register MOVQ $(0x2000000+366), AX // bsdthread_register
SYSCALL SYSCALL
JCC 3(PC) JCC 4(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+0(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+0(FP)
RET RET
// Mach system calls use 0x1000000 instead of the BSD's 0x2000000. // Mach system calls use 0x1000000 instead of the BSD's 0x2000000.
// uint32 mach_msg_trap(void*, uint32, uint32, uint32, uint32, uint32, uint32) // uint32 mach_msg_trap(void*, uint32, uint32, uint32, uint32, uint32, uint32)
TEXT runtime·mach_msg_trap(SB),NOSPLIT,$0 TEXT runtime·mach_msg_trap(SB),NOSPLIT,$0
MOVQ 8(SP), DI MOVQ h+0(FP), DI
MOVL 16(SP), SI MOVL op+8(FP), SI
MOVL 20(SP), DX MOVL send_size+12(FP), DX
MOVL 24(SP), R10 MOVL rcv_size+16(FP), R10
MOVL 28(SP), R8 MOVL rcv_name+20(FP), R8
MOVL 32(SP), R9 MOVL timeout+24(FP), R9
MOVL 36(SP), R11 MOVL notify+28(FP), R11
PUSHQ R11 // seventh arg, on stack PUSHQ R11 // seventh arg, on stack
MOVL $(0x1000000+31), AX // mach_msg_trap MOVL $(0x1000000+31), AX // mach_msg_trap
SYSCALL SYSCALL
POPQ R11 POPQ R11
MOVL AX, ret+32(FP)
RET RET
TEXT runtime·mach_task_self(SB),NOSPLIT,$0 TEXT runtime·mach_task_self(SB),NOSPLIT,$0
MOVL $(0x1000000+28), AX // task_self_trap MOVL $(0x1000000+28), AX // task_self_trap
SYSCALL SYSCALL
MOVL AX, ret+0(FP)
RET RET
TEXT runtime·mach_thread_self(SB),NOSPLIT,$0 TEXT runtime·mach_thread_self(SB),NOSPLIT,$0
MOVL $(0x1000000+27), AX // thread_self_trap MOVL $(0x1000000+27), AX // thread_self_trap
SYSCALL SYSCALL
MOVL AX, ret+0(FP)
RET RET
TEXT runtime·mach_reply_port(SB),NOSPLIT,$0 TEXT runtime·mach_reply_port(SB),NOSPLIT,$0
MOVL $(0x1000000+26), AX // mach_reply_port MOVL $(0x1000000+26), AX // mach_reply_port
SYSCALL SYSCALL
MOVL AX, ret+0(FP)
RET RET
// Mach provides trap versions of the semaphore ops, // Mach provides trap versions of the semaphore ops,
...@@ -389,32 +406,36 @@ TEXT runtime·mach_reply_port(SB),NOSPLIT,$0 ...@@ -389,32 +406,36 @@ TEXT runtime·mach_reply_port(SB),NOSPLIT,$0
// uint32 mach_semaphore_wait(uint32) // uint32 mach_semaphore_wait(uint32)
TEXT runtime·mach_semaphore_wait(SB),NOSPLIT,$0 TEXT runtime·mach_semaphore_wait(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL sema+0(FP), DI
MOVL $(0x1000000+36), AX // semaphore_wait_trap MOVL $(0x1000000+36), AX // semaphore_wait_trap
SYSCALL SYSCALL
MOVL AX, ret+8(FP)
RET RET
// uint32 mach_semaphore_timedwait(uint32, uint32, uint32) // uint32 mach_semaphore_timedwait(uint32, uint32, uint32)
TEXT runtime·mach_semaphore_timedwait(SB),NOSPLIT,$0 TEXT runtime·mach_semaphore_timedwait(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL sema+0(FP), DI
MOVL 12(SP), SI MOVL sec+4(FP), SI
MOVL 16(SP), DX MOVL nsec+8(FP), DX
MOVL $(0x1000000+38), AX // semaphore_timedwait_trap MOVL $(0x1000000+38), AX // semaphore_timedwait_trap
SYSCALL SYSCALL
MOVL AX, ret+16(FP)
RET RET
// uint32 mach_semaphore_signal(uint32) // uint32 mach_semaphore_signal(uint32)
TEXT runtime·mach_semaphore_signal(SB),NOSPLIT,$0 TEXT runtime·mach_semaphore_signal(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL sema+0(FP), DI
MOVL $(0x1000000+33), AX // semaphore_signal_trap MOVL $(0x1000000+33), AX // semaphore_signal_trap
SYSCALL SYSCALL
MOVL AX, ret+8(FP)
RET RET
// uint32 mach_semaphore_signal_all(uint32) // uint32 mach_semaphore_signal_all(uint32)
TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0 TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL sema+0(FP), DI
MOVL $(0x1000000+34), AX // semaphore_signal_all_trap MOVL $(0x1000000+34), AX // semaphore_signal_all_trap
SYSCALL SYSCALL
MOVL AX, ret+8(FP)
RET RET
// set tls base to DI // set tls base to DI
...@@ -431,18 +452,20 @@ TEXT runtime·settls(SB),NOSPLIT,$32 ...@@ -431,18 +452,20 @@ TEXT runtime·settls(SB),NOSPLIT,$32
RET RET
TEXT runtime·sysctl(SB),NOSPLIT,$0 TEXT runtime·sysctl(SB),NOSPLIT,$0
MOVQ 8(SP), DI MOVQ mib+0(FP), DI
MOVL 16(SP), SI MOVL miblen+8(FP), SI
MOVQ 24(SP), DX MOVQ out+16(FP), DX
MOVQ 32(SP), R10 MOVQ size+24(FP), R10
MOVQ 40(SP), R8 MOVQ dst+32(FP), R8
MOVQ 48(SP), R9 MOVQ ndst+40(FP), R9
MOVL $(0x2000000+202), AX // syscall entry MOVL $(0x2000000+202), AX // syscall entry
SYSCALL SYSCALL
JCC 3(PC) JCC 4(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+48(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+48(FP)
RET RET
// int32 runtime·kqueue(void); // int32 runtime·kqueue(void);
...@@ -454,25 +477,27 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0 ...@@ -454,25 +477,27 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout); // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout);
TEXT runtime·kevent(SB),NOSPLIT,$0 TEXT runtime·kevent(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL fd+0(FP), DI
MOVQ 16(SP), SI MOVQ ev1+8(FP), SI
MOVL 24(SP), DX MOVL nev1+16(FP), DX
MOVQ 32(SP), R10 MOVQ ev2+24(FP), R10
MOVL 40(SP), R8 MOVL nev2+32(FP), R8
MOVQ 48(SP), R9 MOVQ ts+40(FP), R9
MOVL $(0x2000000+363), AX MOVL $(0x2000000+363), AX
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+48(FP)
RET RET
// void runtime·closeonexec(int32 fd); // void runtime·closeonexec(int32 fd);
TEXT runtime·closeonexec(SB),NOSPLIT,$0 TEXT runtime·closeonexec(SB),NOSPLIT,$0
MOVL 8(SP), DI // fd MOVL fd+0(FP), DI // fd
MOVQ $2, SI // F_SETFD MOVQ $2, SI // F_SETFD
MOVQ $1, DX // FD_CLOEXEC MOVQ $1, DX // FD_CLOEXEC
MOVL $(0x2000000+92), AX // fcntl MOVL $(0x2000000+92), AX // fcntl
......
...@@ -14,6 +14,7 @@ TEXT runtime·sys_umtx_sleep(SB),NOSPLIT,$-4 ...@@ -14,6 +14,7 @@ TEXT runtime·sys_umtx_sleep(SB),NOSPLIT,$-4
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·sys_umtx_wakeup(SB),NOSPLIT,$-4 TEXT runtime·sys_umtx_wakeup(SB),NOSPLIT,$-4
...@@ -21,11 +22,13 @@ TEXT runtime·sys_umtx_wakeup(SB),NOSPLIT,$-4 ...@@ -21,11 +22,13 @@ TEXT runtime·sys_umtx_wakeup(SB),NOSPLIT,$-4
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·lwp_create(SB),NOSPLIT,$-4 TEXT runtime·lwp_create(SB),NOSPLIT,$-4
MOVL $495, AX // lwp_create MOVL $495, AX // lwp_create
INT $0x80 INT $0x80
MOVL AX, ret+4(FP)
RET RET
TEXT runtime·lwp_start(SB),NOSPLIT,$0 TEXT runtime·lwp_start(SB),NOSPLIT,$0
...@@ -81,26 +84,31 @@ TEXT runtime·exit1(SB),NOSPLIT,$16 ...@@ -81,26 +84,31 @@ TEXT runtime·exit1(SB),NOSPLIT,$16
TEXT runtime·open(SB),NOSPLIT,$-4 TEXT runtime·open(SB),NOSPLIT,$-4
MOVL $5, AX MOVL $5, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$-4 TEXT runtime·close(SB),NOSPLIT,$-4
MOVL $6, AX MOVL $6, AX
INT $0x80 INT $0x80
MOVL AX, ret+4(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$-4 TEXT runtime·read(SB),NOSPLIT,$-4
MOVL $3, AX MOVL $3, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$-4 TEXT runtime·write(SB),NOSPLIT,$-4
MOVL $4, AX MOVL $4, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·getrlimit(SB),NOSPLIT,$-4 TEXT runtime·getrlimit(SB),NOSPLIT,$-4
MOVL $194, AX MOVL $194, AX
INT $0x80 INT $0x80
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·raise(SB),NOSPLIT,$16 TEXT runtime·raise(SB),NOSPLIT,$16
...@@ -116,7 +124,7 @@ TEXT runtime·raise(SB),NOSPLIT,$16 ...@@ -116,7 +124,7 @@ TEXT runtime·raise(SB),NOSPLIT,$16
RET RET
TEXT runtime·mmap(SB),NOSPLIT,$36 TEXT runtime·mmap(SB),NOSPLIT,$36
LEAL arg0+0(FP), SI LEAL addr+0(FP), SI
LEAL 4(SP), DI LEAL 4(SP), DI
CLD CLD
MOVSL // arg 1 - addr MOVSL // arg 1 - addr
...@@ -131,6 +139,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$36 ...@@ -131,6 +139,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$36
STOSL STOSL
MOVL $197, AX // sys_mmap MOVL $197, AX // sys_mmap
INT $0x80 INT $0x80
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$-4 TEXT runtime·munmap(SB),NOSPLIT,$-4
...@@ -185,9 +194,8 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32 ...@@ -185,9 +194,8 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32
ADDL BX, AX ADDL BX, AX
ADCL $0, DX ADCL $0, DX
MOVL ret+0(FP), DI MOVL AX, ret_lo+0(FP)
MOVL AX, 0(DI) MOVL DX, ret_hi+4(FP)
MOVL DX, 4(DI)
RET RET
...@@ -302,7 +310,7 @@ TEXT runtime·settls(SB),NOSPLIT,$24 ...@@ -302,7 +310,7 @@ TEXT runtime·settls(SB),NOSPLIT,$24
RET RET
TEXT runtime·sysctl(SB),NOSPLIT,$28 TEXT runtime·sysctl(SB),NOSPLIT,$28
LEAL arg0+0(FP), SI LEAL mib+0(FP), SI
LEAL 4(SP), DI LEAL 4(SP), DI
CLD CLD
MOVSL // arg 1 - name MOVSL // arg 1 - name
...@@ -313,10 +321,12 @@ TEXT runtime·sysctl(SB),NOSPLIT,$28 ...@@ -313,10 +321,12 @@ TEXT runtime·sysctl(SB),NOSPLIT,$28
MOVSL // arg 6 - newlen MOVSL // arg 6 - newlen
MOVL $202, AX // sys___sysctl MOVL $202, AX // sys___sysctl
INT $0x80 INT $0x80
JCC 3(PC) JCC 4(PC)
NEGL AX NEGL AX
MOVL AX, ret+24(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·osyield(SB),NOSPLIT,$-4 TEXT runtime·osyield(SB),NOSPLIT,$-4
...@@ -327,9 +337,9 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4 ...@@ -327,9 +337,9 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4
TEXT runtime·sigprocmask(SB),NOSPLIT,$16 TEXT runtime·sigprocmask(SB),NOSPLIT,$16
MOVL $0, 0(SP) // syscall gap MOVL $0, 0(SP) // syscall gap
MOVL $3, 4(SP) // arg 1 - how (SIG_SETMASK) MOVL $3, 4(SP) // arg 1 - how (SIG_SETMASK)
MOVL args+0(FP), AX MOVL new+0(FP), AX
MOVL AX, 8(SP) // arg 2 - set MOVL AX, 8(SP) // arg 2 - set
MOVL args+4(FP), AX MOVL old+4(FP), AX
MOVL AX, 12(SP) // arg 3 - oset MOVL AX, 12(SP) // arg 3 - oset
MOVL $340, AX // sys_sigprocmask MOVL $340, AX // sys_sigprocmask
INT $0x80 INT $0x80
...@@ -343,6 +353,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0 ...@@ -343,6 +353,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout); // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout);
...@@ -351,6 +362,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0 ...@@ -351,6 +362,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+24(FP)
RET RET
// int32 runtime·closeonexec(int32 fd); // int32 runtime·closeonexec(int32 fd);
......
...@@ -10,28 +10,31 @@ ...@@ -10,28 +10,31 @@
#include "../../cmd/ld/textflag.h" #include "../../cmd/ld/textflag.h"
TEXT runtime·sys_umtx_sleep(SB),NOSPLIT,$0 TEXT runtime·sys_umtx_sleep(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 - ptr MOVQ addr+0(FP), DI // arg 1 - ptr
MOVL 16(SP), SI // arg 2 - value MOVL val+8(FP), SI // arg 2 - value
MOVL 20(SP), DX // arg 3 - timeout MOVL timeout+12(FP), DX // arg 3 - timeout
MOVL $469, AX // umtx_sleep MOVL $469, AX // umtx_sleep
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·sys_umtx_wakeup(SB),NOSPLIT,$0 TEXT runtime·sys_umtx_wakeup(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 - ptr MOVQ addr+0(FP), DI // arg 1 - ptr
MOVL 16(SP), SI // arg 2 - count MOVL val+8(FP), SI // arg 2 - count
MOVL $470, AX // umtx_wakeup MOVL $470, AX // umtx_wakeup
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·lwp_create(SB),NOSPLIT,$0 TEXT runtime·lwp_create(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 - params MOVQ param+0(FP), DI // arg 1 - params
MOVL $495, AX // lwp_create MOVL $495, AX // lwp_create
SYSCALL SYSCALL
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·lwp_start(SB),NOSPLIT,$0 TEXT runtime·lwp_start(SB),NOSPLIT,$0
...@@ -54,54 +57,59 @@ TEXT runtime·lwp_start(SB),NOSPLIT,$0 ...@@ -54,54 +57,59 @@ TEXT runtime·lwp_start(SB),NOSPLIT,$0
// Exit the entire program (like C exit) // Exit the entire program (like C exit)
TEXT runtime·exit(SB),NOSPLIT,$-8 TEXT runtime·exit(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 exit status MOVL code+0(FP), DI // arg 1 exit status
MOVL $1, AX MOVL $1, AX
SYSCALL SYSCALL
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
RET RET
TEXT runtime·exit1(SB),NOSPLIT,$-8 TEXT runtime·exit1(SB),NOSPLIT,$-8
MOVQ 8(SP), DI // arg 1 exit status MOVL code+0(FP), DI // arg 1 exit status
MOVL $431, AX MOVL $431, AX
SYSCALL SYSCALL
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
RET RET
TEXT runtime·open(SB),NOSPLIT,$-8 TEXT runtime·open(SB),NOSPLIT,$-8
MOVQ 8(SP), DI // arg 1 pathname MOVQ name+0(FP), DI // arg 1 pathname
MOVL 16(SP), SI // arg 2 flags MOVL mode+8(FP), SI // arg 2 flags
MOVL 20(SP), DX // arg 3 mode MOVL perm+12(FP), DX // arg 3 mode
MOVL $5, AX MOVL $5, AX
SYSCALL SYSCALL
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$-8 TEXT runtime·close(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 fd MOVL fd+0(FP), DI // arg 1 fd
MOVL $6, AX MOVL $6, AX
SYSCALL SYSCALL
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$-8 TEXT runtime·read(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 fd MOVL fd+0(FP), DI // arg 1 fd
MOVQ 16(SP), SI // arg 2 buf MOVQ p+8(FP), SI // arg 2 buf
MOVL 24(SP), DX // arg 3 count MOVL n+16(FP), DX // arg 3 count
MOVL $3, AX MOVL $3, AX
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$-8 TEXT runtime·write(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 fd MOVQ fd+0(FP), DI // arg 1 fd
MOVQ 16(SP), SI // arg 2 buf MOVQ p+8(FP), SI // arg 2 buf
MOVL 24(SP), DX // arg 3 count MOVL n+16(FP), DX // arg 3 count
MOVL $4, AX MOVL $4, AX
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·getrlimit(SB),NOSPLIT,$-8 TEXT runtime·getrlimit(SB),NOSPLIT,$-8
MOVL 8(SP), DI MOVL kind+0(FP), DI
MOVQ 16(SP), SI MOVQ limit+8(FP), SI
MOVL $194, AX MOVL $194, AX
SYSCALL SYSCALL
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·raise(SB),NOSPLIT,$16 TEXT runtime·raise(SB),NOSPLIT,$16
...@@ -115,9 +123,9 @@ TEXT runtime·raise(SB),NOSPLIT,$16 ...@@ -115,9 +123,9 @@ TEXT runtime·raise(SB),NOSPLIT,$16
RET RET
TEXT runtime·setitimer(SB), NOSPLIT, $-8 TEXT runtime·setitimer(SB), NOSPLIT, $-8
MOVL 8(SP), DI MOVL mode+0(FP), DI
MOVQ 16(SP), SI MOVQ new+8(FP), SI
MOVQ 24(SP), DX MOVQ old+16(FP), DX
MOVL $83, AX MOVL $83, AX
SYSCALL SYSCALL
RET RET
...@@ -148,12 +156,13 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32 ...@@ -148,12 +156,13 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32
// return nsec in AX // return nsec in AX
IMULQ $1000000000, AX IMULQ $1000000000, AX
ADDQ DX, AX ADDQ DX, AX
MOVQ AX, ret+0(FP)
RET RET
TEXT runtime·sigaction(SB),NOSPLIT,$-8 TEXT runtime·sigaction(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 sig MOVL sig+0(FP), DI // arg 1 sig
MOVQ 16(SP), SI // arg 2 act MOVQ new+8(FP), SI // arg 2 act
MOVQ 24(SP), DX // arg 3 oact MOVQ old+16(FP), DX // arg 3 oact
MOVL $342, AX MOVL $342, AX
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
...@@ -194,23 +203,24 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$64 ...@@ -194,23 +203,24 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$64
RET RET
TEXT runtime·mmap(SB),NOSPLIT,$0 TEXT runtime·mmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 - addr MOVQ addr+0(FP), DI // arg 1 - addr
MOVQ 16(SP), SI // arg 2 - len MOVQ n+8(FP), SI // arg 2 - len
MOVL 24(SP), DX // arg 3 - prot MOVL prot+16(FP), DX // arg 3 - prot
MOVL 28(SP), R10 // arg 4 - flags MOVL flags+20(FP), R10 // arg 4 - flags
MOVL 32(SP), R8 // arg 5 - fd MOVL fd+24(FP), R8 // arg 5 - fd
MOVL 36(SP), R9 MOVL off+28(FP), R9
SUBQ $16, SP SUBQ $16, SP
MOVQ R9, 8(SP) // arg 7 - offset (passed on stack) MOVQ R9, 8(SP) // arg 7 - offset (passed on stack)
MOVQ $0, R9 // arg 6 - pad MOVQ $0, R9 // arg 6 - pad
MOVL $197, AX MOVL $197, AX
SYSCALL SYSCALL
ADDQ $16, SP ADDQ $16, SP
MOVQ AX, ret+32(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$0 TEXT runtime·munmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 addr MOVQ addr+0(FP), DI // arg 1 addr
MOVQ 16(SP), SI // arg 2 len MOVQ n+8(FP), SI // arg 2 len
MOVL $73, AX MOVL $73, AX
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
...@@ -218,9 +228,9 @@ TEXT runtime·munmap(SB),NOSPLIT,$0 ...@@ -218,9 +228,9 @@ TEXT runtime·munmap(SB),NOSPLIT,$0
RET RET
TEXT runtime·madvise(SB),NOSPLIT,$0 TEXT runtime·madvise(SB),NOSPLIT,$0
MOVQ 8(SP), DI MOVQ addr+0(FP), DI
MOVQ 16(SP), SI MOVQ n+8(FP), SI
MOVQ 24(SP), DX MOVL flags+16(FP), DX
MOVQ $75, AX // madvise MOVQ $75, AX // madvise
SYSCALL SYSCALL
// ignore failure - maybe pages are locked // ignore failure - maybe pages are locked
...@@ -266,18 +276,20 @@ TEXT runtime·settls(SB),NOSPLIT,$16 ...@@ -266,18 +276,20 @@ TEXT runtime·settls(SB),NOSPLIT,$16
RET RET
TEXT runtime·sysctl(SB),NOSPLIT,$0 TEXT runtime·sysctl(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 - name MOVQ mib+0(FP), DI // arg 1 - name
MOVL 16(SP), SI // arg 2 - namelen MOVL miblen+8(FP), SI // arg 2 - namelen
MOVQ 24(SP), DX // arg 3 - oldp MOVQ out+16(FP), DX // arg 3 - oldp
MOVQ 32(SP), R10 // arg 4 - oldlenp MOVQ size+24(FP), R10 // arg 4 - oldlenp
MOVQ 40(SP), R8 // arg 5 - newp MOVQ dst+32(FP), R8 // arg 5 - newp
MOVQ 48(SP), R9 // arg 6 - newlen MOVQ ndst+40(FP), R9 // arg 6 - newlen
MOVQ $202, AX // sys___sysctl MOVQ $202, AX // sys___sysctl
SYSCALL SYSCALL
JCC 3(PC) JCC 4(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+48(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+48(FP)
RET RET
TEXT runtime·osyield(SB),NOSPLIT,$-4 TEXT runtime·osyield(SB),NOSPLIT,$-4
...@@ -287,8 +299,8 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4 ...@@ -287,8 +299,8 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4
TEXT runtime·sigprocmask(SB),NOSPLIT,$0 TEXT runtime·sigprocmask(SB),NOSPLIT,$0
MOVL $3, DI // arg 1 - how (SIG_SETMASK) MOVL $3, DI // arg 1 - how (SIG_SETMASK)
MOVQ 8(SP), SI // arg 2 - set MOVQ new+0(FP), SI // arg 2 - set
MOVQ 16(SP), DX // arg 3 - oset MOVQ old+8(FP), DX // arg 3 - oset
MOVL $340, AX // sys_sigprocmask MOVL $340, AX // sys_sigprocmask
SYSCALL SYSCALL
JAE 2(PC) JAE 2(PC)
...@@ -304,25 +316,27 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0 ...@@ -304,25 +316,27 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout); // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout);
TEXT runtime·kevent(SB),NOSPLIT,$0 TEXT runtime·kevent(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL fd+0(FP), DI
MOVQ 16(SP), SI MOVQ ev1+8(FP), SI
MOVL 24(SP), DX MOVL nev1+16(FP), DX
MOVQ 32(SP), R10 MOVQ ev2+24(FP), R10
MOVL 40(SP), R8 MOVL nev2+32(FP), R8
MOVQ 48(SP), R9 MOVQ ts+40(FP), R9
MOVL $363, AX MOVL $363, AX
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+48(FP)
RET RET
// void runtime·closeonexec(int32 fd); // void runtime·closeonexec(int32 fd);
TEXT runtime·closeonexec(SB),NOSPLIT,$0 TEXT runtime·closeonexec(SB),NOSPLIT,$0
MOVL 8(SP), DI // fd MOVL fd+0(FP), DI // fd
MOVQ $2, SI // F_SETFD MOVQ $2, SI // F_SETFD
MOVQ $1, DX // FD_CLOEXEC MOVQ $1, DX // FD_CLOEXEC
MOVL $92, AX // fcntl MOVL $92, AX // fcntl
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
TEXT runtime·sys_umtx_op(SB),NOSPLIT,$-4 TEXT runtime·sys_umtx_op(SB),NOSPLIT,$-4
MOVL $454, AX MOVL $454, AX
INT $0x80 INT $0x80
MOVL AX, ret+20(FP)
RET RET
TEXT runtime·thr_new(SB),NOSPLIT,$-4 TEXT runtime·thr_new(SB),NOSPLIT,$-4
...@@ -60,26 +61,31 @@ TEXT runtime·exit1(SB),NOSPLIT,$-4 ...@@ -60,26 +61,31 @@ TEXT runtime·exit1(SB),NOSPLIT,$-4
TEXT runtime·open(SB),NOSPLIT,$-4 TEXT runtime·open(SB),NOSPLIT,$-4
MOVL $5, AX MOVL $5, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$-4 TEXT runtime·close(SB),NOSPLIT,$-4
MOVL $6, AX MOVL $6, AX
INT $0x80 INT $0x80
MOVL AX, ret+4(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$-4 TEXT runtime·read(SB),NOSPLIT,$-4
MOVL $3, AX MOVL $3, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$-4 TEXT runtime·write(SB),NOSPLIT,$-4
MOVL $4, AX MOVL $4, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·getrlimit(SB),NOSPLIT,$-4 TEXT runtime·getrlimit(SB),NOSPLIT,$-4
MOVL $194, AX MOVL $194, AX
INT $0x80 INT $0x80
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·raise(SB),NOSPLIT,$16 TEXT runtime·raise(SB),NOSPLIT,$16
...@@ -98,7 +104,7 @@ TEXT runtime·raise(SB),NOSPLIT,$16 ...@@ -98,7 +104,7 @@ TEXT runtime·raise(SB),NOSPLIT,$16
RET RET
TEXT runtime·mmap(SB),NOSPLIT,$32 TEXT runtime·mmap(SB),NOSPLIT,$32
LEAL arg0+0(FP), SI LEAL addr+0(FP), SI
LEAL 4(SP), DI LEAL 4(SP), DI
CLD CLD
MOVSL MOVSL
...@@ -111,6 +117,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$32 ...@@ -111,6 +117,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$32
STOSL STOSL
MOVL $477, AX MOVL $477, AX
INT $0x80 INT $0x80
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$-4 TEXT runtime·munmap(SB),NOSPLIT,$-4
...@@ -167,9 +174,8 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32 ...@@ -167,9 +174,8 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32
ADDL BX, AX ADDL BX, AX
ADCL $0, DX ADCL $0, DX
MOVL ret+0(FP), DI MOVL AX, ret_lo+0(FP)
MOVL AX, 0(DI) MOVL DX, ret_hi+4(FP)
MOVL DX, 4(DI)
RET RET
...@@ -314,7 +320,7 @@ TEXT runtime·i386_set_ldt(SB),NOSPLIT,$16 ...@@ -314,7 +320,7 @@ TEXT runtime·i386_set_ldt(SB),NOSPLIT,$16
RET RET
TEXT runtime·sysctl(SB),NOSPLIT,$28 TEXT runtime·sysctl(SB),NOSPLIT,$28
LEAL arg0+0(FP), SI LEAL mib+0(FP), SI
LEAL 4(SP), DI LEAL 4(SP), DI
CLD CLD
MOVSL // arg 1 - name MOVSL // arg 1 - name
...@@ -325,10 +331,12 @@ TEXT runtime·sysctl(SB),NOSPLIT,$28 ...@@ -325,10 +331,12 @@ TEXT runtime·sysctl(SB),NOSPLIT,$28
MOVSL // arg 6 - newlen MOVSL // arg 6 - newlen
MOVL $202, AX // sys___sysctl MOVL $202, AX // sys___sysctl
INT $0x80 INT $0x80
JAE 3(PC) JAE 4(PC)
NEGL AX NEGL AX
MOVL AX, ret+24(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·osyield(SB),NOSPLIT,$-4 TEXT runtime·osyield(SB),NOSPLIT,$-4
...@@ -339,9 +347,9 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4 ...@@ -339,9 +347,9 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4
TEXT runtime·sigprocmask(SB),NOSPLIT,$16 TEXT runtime·sigprocmask(SB),NOSPLIT,$16
MOVL $0, 0(SP) // syscall gap MOVL $0, 0(SP) // syscall gap
MOVL $3, 4(SP) // arg 1 - how (SIG_SETMASK) MOVL $3, 4(SP) // arg 1 - how (SIG_SETMASK)
MOVL args+0(FP), AX MOVL new+0(FP), AX
MOVL AX, 8(SP) // arg 2 - set MOVL AX, 8(SP) // arg 2 - set
MOVL args+4(FP), AX MOVL old+4(FP), AX
MOVL AX, 12(SP) // arg 3 - oset MOVL AX, 12(SP) // arg 3 - oset
MOVL $340, AX // sys_sigprocmask MOVL $340, AX // sys_sigprocmask
INT $0x80 INT $0x80
...@@ -355,6 +363,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0 ...@@ -355,6 +363,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout); // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout);
...@@ -363,6 +372,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0 ...@@ -363,6 +372,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+24(FP)
RET RET
// int32 runtime·closeonexec(int32 fd); // int32 runtime·closeonexec(int32 fd);
......
...@@ -35,18 +35,19 @@ ...@@ -35,18 +35,19 @@
#define SYSCALL MOVQ R10, CX; INT $0x80 #define SYSCALL MOVQ R10, CX; INT $0x80
TEXT runtime·sys_umtx_op(SB),NOSPLIT,$0 TEXT runtime·sys_umtx_op(SB),NOSPLIT,$0
MOVQ 8(SP), DI MOVQ addr+0(FP), DI
MOVL 16(SP), SI MOVL mode+8(FP), SI
MOVL 20(SP), DX MOVL val+12(FP), DX
MOVQ 24(SP), R10 MOVQ ptr2+16(FP), R10
MOVQ 32(SP), R8 MOVQ ts+24(FP), R8
MOVL $454, AX MOVL $454, AX
SYSCALL SYSCALL
MOVL AX, ret+32(FP)
RET RET
TEXT runtime·thr_new(SB),NOSPLIT,$0 TEXT runtime·thr_new(SB),NOSPLIT,$0
MOVQ 8(SP), DI MOVQ param+0(FP), DI
MOVQ 16(SP), SI MOVL size+8(FP), SI
MOVL $455, AX MOVL $455, AX
SYSCALL SYSCALL
RET RET
...@@ -71,54 +72,59 @@ TEXT runtime·thr_start(SB),NOSPLIT,$0 ...@@ -71,54 +72,59 @@ TEXT runtime·thr_start(SB),NOSPLIT,$0
// Exit the entire program (like C exit) // Exit the entire program (like C exit)
TEXT runtime·exit(SB),NOSPLIT,$-8 TEXT runtime·exit(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 exit status MOVL code+0(FP), DI // arg 1 exit status
MOVL $1, AX MOVL $1, AX
SYSCALL SYSCALL
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
RET RET
TEXT runtime·exit1(SB),NOSPLIT,$-8 TEXT runtime·exit1(SB),NOSPLIT,$-8
MOVQ 8(SP), DI // arg 1 exit status MOVL code+0(FP), DI // arg 1 exit status
MOVL $431, AX MOVL $431, AX
SYSCALL SYSCALL
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
RET RET
TEXT runtime·open(SB),NOSPLIT,$-8 TEXT runtime·open(SB),NOSPLIT,$-8
MOVQ 8(SP), DI // arg 1 pathname MOVQ name+0(FP), DI // arg 1 pathname
MOVL 16(SP), SI // arg 2 flags MOVL mode+8(FP), SI // arg 2 flags
MOVL 20(SP), DX // arg 3 mode MOVL perm+12(FP), DX // arg 3 mode
MOVL $5, AX MOVL $5, AX
SYSCALL SYSCALL
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$-8 TEXT runtime·close(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 fd MOVL fd+0(FP), DI // arg 1 fd
MOVL $6, AX MOVL $6, AX
SYSCALL SYSCALL
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$-8 TEXT runtime·read(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 fd MOVL fd+0(FP), DI // arg 1 fd
MOVQ 16(SP), SI // arg 2 buf MOVQ p+8(FP), SI // arg 2 buf
MOVL 24(SP), DX // arg 3 count MOVL n+16(FP), DX // arg 3 count
MOVL $3, AX MOVL $3, AX
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$-8 TEXT runtime·write(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 fd MOVQ fd+0(FP), DI // arg 1 fd
MOVQ 16(SP), SI // arg 2 buf MOVQ p+8(FP), SI // arg 2 buf
MOVL 24(SP), DX // arg 3 count MOVL n+16(FP), DX // arg 3 count
MOVL $4, AX MOVL $4, AX
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·getrlimit(SB),NOSPLIT,$-8 TEXT runtime·getrlimit(SB),NOSPLIT,$-8
MOVL 8(SP), DI MOVL kind+0(FP), DI
MOVQ 16(SP), SI MOVQ limit+8(FP), SI
MOVL $194, AX MOVL $194, AX
SYSCALL SYSCALL
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·raise(SB),NOSPLIT,$16 TEXT runtime·raise(SB),NOSPLIT,$16
...@@ -134,9 +140,9 @@ TEXT runtime·raise(SB),NOSPLIT,$16 ...@@ -134,9 +140,9 @@ TEXT runtime·raise(SB),NOSPLIT,$16
RET RET
TEXT runtime·setitimer(SB), NOSPLIT, $-8 TEXT runtime·setitimer(SB), NOSPLIT, $-8
MOVL 8(SP), DI MOVL mode+0(FP), DI
MOVQ 16(SP), SI MOVQ new+8(FP), SI
MOVQ 24(SP), DX MOVQ old+16(FP), DX
MOVL $83, AX MOVL $83, AX
SYSCALL SYSCALL
RET RET
...@@ -169,12 +175,13 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32 ...@@ -169,12 +175,13 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32
// return nsec in AX // return nsec in AX
IMULQ $1000000000, AX IMULQ $1000000000, AX
ADDQ DX, AX ADDQ DX, AX
MOVQ AX, ret+0(FP)
RET RET
TEXT runtime·sigaction(SB),NOSPLIT,$-8 TEXT runtime·sigaction(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 sig MOVL sig+0(FP), DI // arg 1 sig
MOVQ 16(SP), SI // arg 2 act MOVQ new+8(FP), SI // arg 2 act
MOVQ 24(SP), DX // arg 3 oact MOVQ old+16(FP), DX // arg 3 oact
MOVL $416, AX MOVL $416, AX
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
...@@ -215,19 +222,20 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$64 ...@@ -215,19 +222,20 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$64
RET RET
TEXT runtime·mmap(SB),NOSPLIT,$0 TEXT runtime·mmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 addr MOVQ addr+0(FP), DI // arg 1 addr
MOVQ 16(SP), SI // arg 2 len MOVQ n+8(FP), SI // arg 2 len
MOVL 24(SP), DX // arg 3 prot MOVL prot+16(FP), DX // arg 3 prot
MOVL 28(SP), R10 // arg 4 flags MOVL flags+20(FP), R10 // arg 4 flags
MOVL 32(SP), R8 // arg 5 fid MOVL fd+24(FP), R8 // arg 5 fid
MOVL 36(SP), R9 // arg 6 offset MOVL off+28(FP), R9 // arg 6 offset
MOVL $477, AX MOVL $477, AX
SYSCALL SYSCALL
MOVQ AX, ret+32(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$0 TEXT runtime·munmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 addr MOVQ addr+0(FP), DI // arg 1 addr
MOVQ 16(SP), SI // arg 2 len MOVQ n+8(FP), SI // arg 2 len
MOVL $73, AX MOVL $73, AX
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
...@@ -235,9 +243,9 @@ TEXT runtime·munmap(SB),NOSPLIT,$0 ...@@ -235,9 +243,9 @@ TEXT runtime·munmap(SB),NOSPLIT,$0
RET RET
TEXT runtime·madvise(SB),NOSPLIT,$0 TEXT runtime·madvise(SB),NOSPLIT,$0
MOVQ 8(SP), DI MOVQ addr+0(FP), DI
MOVQ 16(SP), SI MOVQ n+8(FP), SI
MOVQ 24(SP), DX MOVL flags+16(FP), DX
MOVQ $75, AX // madvise MOVQ $75, AX // madvise
SYSCALL SYSCALL
// ignore failure - maybe pages are locked // ignore failure - maybe pages are locked
...@@ -281,18 +289,20 @@ TEXT runtime·settls(SB),NOSPLIT,$8 ...@@ -281,18 +289,20 @@ TEXT runtime·settls(SB),NOSPLIT,$8
RET RET
TEXT runtime·sysctl(SB),NOSPLIT,$0 TEXT runtime·sysctl(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 - name MOVQ mib+0(FP), DI // arg 1 - name
MOVL 16(SP), SI // arg 2 - namelen MOVL miblen+8(FP), SI // arg 2 - namelen
MOVQ 24(SP), DX // arg 3 - oldp MOVQ out+16(FP), DX // arg 3 - oldp
MOVQ 32(SP), R10 // arg 4 - oldlenp MOVQ size+24(FP), R10 // arg 4 - oldlenp
MOVQ 40(SP), R8 // arg 5 - newp MOVQ dst+32(FP), R8 // arg 5 - newp
MOVQ 48(SP), R9 // arg 6 - newlen MOVQ ndst+40(FP), R9 // arg 6 - newlen
MOVQ $202, AX // sys___sysctl MOVQ $202, AX // sys___sysctl
SYSCALL SYSCALL
JCC 3(PC) JCC 4(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+48(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+48(FP)
RET RET
TEXT runtime·osyield(SB),NOSPLIT,$-4 TEXT runtime·osyield(SB),NOSPLIT,$-4
...@@ -302,8 +312,8 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4 ...@@ -302,8 +312,8 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4
TEXT runtime·sigprocmask(SB),NOSPLIT,$0 TEXT runtime·sigprocmask(SB),NOSPLIT,$0
MOVL $3, DI // arg 1 - how (SIG_SETMASK) MOVL $3, DI // arg 1 - how (SIG_SETMASK)
MOVQ 8(SP), SI // arg 2 - set MOVQ new+0(FP), SI // arg 2 - set
MOVQ 16(SP), DX // arg 3 - oset MOVQ old+8(FP), DX // arg 3 - oset
MOVL $340, AX // sys_sigprocmask MOVL $340, AX // sys_sigprocmask
SYSCALL SYSCALL
JAE 2(PC) JAE 2(PC)
...@@ -319,25 +329,27 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0 ...@@ -319,25 +329,27 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout); // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout);
TEXT runtime·kevent(SB),NOSPLIT,$0 TEXT runtime·kevent(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL fd+0(FP), DI
MOVQ 16(SP), SI MOVQ ev1+8(FP), SI
MOVL 24(SP), DX MOVL nev1+16(FP), DX
MOVQ 32(SP), R10 MOVQ ev2+24(FP), R10
MOVL 40(SP), R8 MOVL nev2+32(FP), R8
MOVQ 48(SP), R9 MOVQ ts+40(FP), R9
MOVL $363, AX MOVL $363, AX
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+48(FP)
RET RET
// void runtime·closeonexec(int32 fd); // void runtime·closeonexec(int32 fd);
TEXT runtime·closeonexec(SB),NOSPLIT,$0 TEXT runtime·closeonexec(SB),NOSPLIT,$0
MOVL 8(SP), DI // fd MOVL fd+0(FP), DI // fd
MOVQ $2, SI // F_SETFD MOVQ $2, SI // F_SETFD
MOVQ $1, DX // FD_CLOEXEC MOVQ $1, DX // FD_CLOEXEC
MOVL $92, AX // fcntl MOVL $92, AX // fcntl
......
...@@ -48,6 +48,7 @@ TEXT runtime·sys_umtx_op(SB),NOSPLIT,$0 ...@@ -48,6 +48,7 @@ TEXT runtime·sys_umtx_op(SB),NOSPLIT,$0
SWI $0 SWI $0
SUB $20, R13 SUB $20, R13
// BCS error // BCS error
MOVW R0, ret+20(FP)
RET RET
TEXT runtime·thr_new(SB),NOSPLIT,$0 TEXT runtime·thr_new(SB),NOSPLIT,$0
...@@ -91,6 +92,7 @@ TEXT runtime·open(SB),NOSPLIT,$-8 ...@@ -91,6 +92,7 @@ TEXT runtime·open(SB),NOSPLIT,$-8
MOVW 8(FP), R2 // arg 3 perm MOVW 8(FP), R2 // arg 3 perm
MOVW $SYS_open, R7 MOVW $SYS_open, R7
SWI $0 SWI $0
MOVW R0, ret+12(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$-8 TEXT runtime·read(SB),NOSPLIT,$-8
...@@ -99,6 +101,7 @@ TEXT runtime·read(SB),NOSPLIT,$-8 ...@@ -99,6 +101,7 @@ TEXT runtime·read(SB),NOSPLIT,$-8
MOVW 8(FP), R2 // arg 3 count MOVW 8(FP), R2 // arg 3 count
MOVW $SYS_read, R7 MOVW $SYS_read, R7
SWI $0 SWI $0
MOVW R0, ret+12(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$-8 TEXT runtime·write(SB),NOSPLIT,$-8
...@@ -107,12 +110,14 @@ TEXT runtime·write(SB),NOSPLIT,$-8 ...@@ -107,12 +110,14 @@ TEXT runtime·write(SB),NOSPLIT,$-8
MOVW 8(FP), R2 // arg 3 count MOVW 8(FP), R2 // arg 3 count
MOVW $SYS_write, R7 MOVW $SYS_write, R7
SWI $0 SWI $0
MOVW R0, ret+12(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$-8 TEXT runtime·close(SB),NOSPLIT,$-8
MOVW 0(FP), R0 // arg 1 fd MOVW 0(FP), R0 // arg 1 fd
MOVW $SYS_close, R7 MOVW $SYS_close, R7
SWI $0 SWI $0
MOVW R0, ret+4(FP)
RET RET
TEXT runtime·getrlimit(SB),NOSPLIT,$-8 TEXT runtime·getrlimit(SB),NOSPLIT,$-8
...@@ -120,6 +125,7 @@ TEXT runtime·getrlimit(SB),NOSPLIT,$-8 ...@@ -120,6 +125,7 @@ TEXT runtime·getrlimit(SB),NOSPLIT,$-8
MOVW 4(FP), R1 MOVW 4(FP), R1
MOVW $SYS_getrlimit, R7 MOVW $SYS_getrlimit, R7
SWI $0 SWI $0
MOVW R0, ret+8(FP)
RET RET
TEXT runtime·raise(SB),NOSPLIT,$8 TEXT runtime·raise(SB),NOSPLIT,$8
...@@ -178,9 +184,8 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32 ...@@ -178,9 +184,8 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32
ADD.S R2, R0 ADD.S R2, R0
ADC R4, R1 ADC R4, R1
MOVW 0(FP), R3 MOVW R0, ret_lo+0(FP)
MOVW R0, 0(R3) MOVW R1, ret_hi+4(FP)
MOVW R1, 4(R3)
RET RET
TEXT runtime·sigaction(SB),NOSPLIT,$-8 TEXT runtime·sigaction(SB),NOSPLIT,$-8
...@@ -247,6 +252,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$16 ...@@ -247,6 +252,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$16
SWI $0 SWI $0
SUB $4, R13 SUB $4, R13
// TODO(dfc) error checking ? // TODO(dfc) error checking ?
MOVW R0, ret+24(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$0 TEXT runtime·munmap(SB),NOSPLIT,$0
...@@ -307,6 +313,7 @@ TEXT runtime·sysctl(SB),NOSPLIT,$0 ...@@ -307,6 +313,7 @@ TEXT runtime·sysctl(SB),NOSPLIT,$0
SWI $0 SWI $0
SUB.CS $0, R0, R0 SUB.CS $0, R0, R0
SUB $20, R13 SUB $20, R13
MOVW R0, ret+24(FP)
RET RET
TEXT runtime·osyield(SB),NOSPLIT,$-4 TEXT runtime·osyield(SB),NOSPLIT,$-4
...@@ -329,6 +336,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0 ...@@ -329,6 +336,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0
MOVW $SYS_kqueue, R7 MOVW $SYS_kqueue, R7
SWI $0 SWI $0
RSB.CS $0, R0 RSB.CS $0, R0
MOVW R0, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout) // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout)
...@@ -342,6 +350,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0 ...@@ -342,6 +350,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0
SWI $0 SWI $0
RSB.CS $0, R0 RSB.CS $0, R0
SUB $20, R13 SUB $20, R13
MOVW R0, ret+24(FP)
RET RET
// void runtime·closeonexec(int32 fd) // void runtime·closeonexec(int32 fd)
......
...@@ -11,53 +11,58 @@ ...@@ -11,53 +11,58 @@
TEXT runtime·exit(SB),NOSPLIT,$0 TEXT runtime·exit(SB),NOSPLIT,$0
MOVL $252, AX // syscall number MOVL $252, AX // syscall number
MOVL 4(SP), BX MOVL code+0(FP), BX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
INT $3 // not reached INT $3 // not reached
RET RET
TEXT runtime·exit1(SB),NOSPLIT,$0 TEXT runtime·exit1(SB),NOSPLIT,$0
MOVL $1, AX // exit - exit the current os thread MOVL $1, AX // exit - exit the current os thread
MOVL 4(SP), BX MOVL code+0(FP), BX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
INT $3 // not reached INT $3 // not reached
RET RET
TEXT runtime·open(SB),NOSPLIT,$0 TEXT runtime·open(SB),NOSPLIT,$0
MOVL $5, AX // syscall - open MOVL $5, AX // syscall - open
MOVL 4(SP), BX MOVL name+0(FP), BX
MOVL 8(SP), CX MOVL mode+4(FP), CX
MOVL 12(SP), DX MOVL perm+8(FP), DX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$0 TEXT runtime·close(SB),NOSPLIT,$0
MOVL $6, AX // syscall - close MOVL $6, AX // syscall - close
MOVL 4(SP), BX MOVL fd+0(FP), BX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+4(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$0 TEXT runtime·write(SB),NOSPLIT,$0
MOVL $4, AX // syscall - write MOVL $4, AX // syscall - write
MOVL 4(SP), BX MOVL fd+0(FP), BX
MOVL 8(SP), CX MOVL p+4(FP), CX
MOVL 12(SP), DX MOVL n+8(FP), DX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$0 TEXT runtime·read(SB),NOSPLIT,$0
MOVL $3, AX // syscall - read MOVL $3, AX // syscall - read
MOVL 4(SP), BX MOVL fd+0(FP), BX
MOVL 8(SP), CX MOVL p+4(FP), CX
MOVL 12(SP), DX MOVL n+8(FP), DX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·getrlimit(SB),NOSPLIT,$0 TEXT runtime·getrlimit(SB),NOSPLIT,$0
MOVL $191, AX // syscall - ugetrlimit MOVL $191, AX // syscall - ugetrlimit
MOVL 4(SP), BX MOVL kind+0(FP), BX
MOVL 8(SP), CX MOVL limit+4(FP), CX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·usleep(SB),NOSPLIT,$8 TEXT runtime·usleep(SB),NOSPLIT,$8
...@@ -87,20 +92,21 @@ TEXT runtime·raise(SB),NOSPLIT,$12 ...@@ -87,20 +92,21 @@ TEXT runtime·raise(SB),NOSPLIT,$12
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
RET RET
TEXT runtime·setitimer(SB),NOSPLIT,$0-24 TEXT runtime·setitimer(SB),NOSPLIT,$0-12
MOVL $104, AX // syscall - setitimer MOVL $104, AX // syscall - setitimer
MOVL 4(SP), BX MOVL mode+0(FP), BX
MOVL 8(SP), CX MOVL new+4(FP), CX
MOVL 12(SP), DX MOVL old+8(FP), DX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
RET RET
TEXT runtime·mincore(SB),NOSPLIT,$0-24 TEXT runtime·mincore(SB),NOSPLIT,$0-16
MOVL $218, AX // syscall - mincore MOVL $218, AX // syscall - mincore
MOVL 4(SP), BX MOVL addr+0(FP), BX
MOVL 8(SP), CX MOVL n+4(FP), CX
MOVL 12(SP), DX MOVL dst+8(FP), DX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+12(FP)
RET RET
// func now() (sec int64, nsec int32) // func now() (sec int64, nsec int32)
...@@ -137,17 +143,16 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32 ...@@ -137,17 +143,16 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32
ADDL BX, AX ADDL BX, AX
ADCL $0, DX ADCL $0, DX
MOVL ret+0(FP), DI MOVL AX, ret_lo+0(FP)
MOVL AX, 0(DI) MOVL DX, ret_hi+4(FP)
MOVL DX, 4(DI)
RET RET
TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0 TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0
MOVL $175, AX // syscall entry MOVL $175, AX // syscall entry
MOVL 4(SP), BX MOVL sig+0(FP), BX
MOVL 8(SP), CX MOVL new+4(FP), CX
MOVL 12(SP), DX MOVL old+8(FP), DX
MOVL 16(SP), SI MOVL size+12(FP), SI
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
CMPL AX, $0xfffff001 CMPL AX, $0xfffff001
JLS 2(PC) JLS 2(PC)
...@@ -156,11 +161,12 @@ TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0 ...@@ -156,11 +161,12 @@ TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0
TEXT runtime·rt_sigaction(SB),NOSPLIT,$0 TEXT runtime·rt_sigaction(SB),NOSPLIT,$0
MOVL $174, AX // syscall - rt_sigaction MOVL $174, AX // syscall - rt_sigaction
MOVL 4(SP), BX MOVL sig+0(FP), BX
MOVL 8(SP), CX MOVL new+4(FP), CX
MOVL 12(SP), DX MOVL old+8(FP), DX
MOVL 16(SP), SI MOVL size+12(FP), SI
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·sigtramp(SB),NOSPLIT,$44 TEXT runtime·sigtramp(SB),NOSPLIT,$44
...@@ -212,24 +218,25 @@ TEXT runtime·sigreturn(SB),NOSPLIT,$0 ...@@ -212,24 +218,25 @@ TEXT runtime·sigreturn(SB),NOSPLIT,$0
TEXT runtime·mmap(SB),NOSPLIT,$0 TEXT runtime·mmap(SB),NOSPLIT,$0
MOVL $192, AX // mmap2 MOVL $192, AX // mmap2
MOVL 4(SP), BX MOVL addr+0(FP), BX
MOVL 8(SP), CX MOVL n+4(FP), CX
MOVL 12(SP), DX MOVL prot+8(FP), DX
MOVL 16(SP), SI MOVL flags+12(FP), SI
MOVL 20(SP), DI MOVL fd+16(FP), DI
MOVL 24(SP), BP MOVL off+20(FP), BP
SHRL $12, BP SHRL $12, BP
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
CMPL AX, $0xfffff001 CMPL AX, $0xfffff001
JLS 3(PC) JLS 3(PC)
NOTL AX NOTL AX
INCL AX INCL AX
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$0 TEXT runtime·munmap(SB),NOSPLIT,$0
MOVL $91, AX // munmap MOVL $91, AX // munmap
MOVL 4(SP), BX MOVL addr+0(FP), BX
MOVL 8(SP), CX MOVL n+4(FP), CX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
CMPL AX, $0xfffff001 CMPL AX, $0xfffff001
JLS 2(PC) JLS 2(PC)
...@@ -238,9 +245,9 @@ TEXT runtime·munmap(SB),NOSPLIT,$0 ...@@ -238,9 +245,9 @@ TEXT runtime·munmap(SB),NOSPLIT,$0
TEXT runtime·madvise(SB),NOSPLIT,$0 TEXT runtime·madvise(SB),NOSPLIT,$0
MOVL $219, AX // madvise MOVL $219, AX // madvise
MOVL 4(SP), BX MOVL addr+0(FP), BX
MOVL 8(SP), CX MOVL n+4(FP), CX
MOVL 12(SP), DX MOVL flags+8(FP), DX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
// ignore failure - maybe pages are locked // ignore failure - maybe pages are locked
RET RET
...@@ -249,13 +256,14 @@ TEXT runtime·madvise(SB),NOSPLIT,$0 ...@@ -249,13 +256,14 @@ TEXT runtime·madvise(SB),NOSPLIT,$0
// struct timespec *timeout, int32 *uaddr2, int32 val2); // struct timespec *timeout, int32 *uaddr2, int32 val2);
TEXT runtime·futex(SB),NOSPLIT,$0 TEXT runtime·futex(SB),NOSPLIT,$0
MOVL $240, AX // futex MOVL $240, AX // futex
MOVL 4(SP), BX MOVL addr+0(FP), BX
MOVL 8(SP), CX MOVL op+4(FP), CX
MOVL 12(SP), DX MOVL val+8(FP), DX
MOVL 16(SP), SI MOVL ts+12(FP), SI
MOVL 20(SP), DI MOVL addr2+16(FP), DI
MOVL 24(SP), BP MOVL val3+20(FP), BP
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+24(FP)
RET RET
// int32 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void)); // int32 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void));
...@@ -284,11 +292,12 @@ TEXT runtime·clone(SB),NOSPLIT,$0 ...@@ -284,11 +292,12 @@ TEXT runtime·clone(SB),NOSPLIT,$0
// In parent, return. // In parent, return.
CMPL AX, $0 CMPL AX, $0
JEQ 2(PC) JEQ 3(PC)
MOVL AX, ret+20(FP)
RET RET
// Paranoia: check that SP is as we expect. // Paranoia: check that SP is as we expect.
MOVL 12(SP), BP MOVL mm+8(FP), BP
CMPL BP, $1234 CMPL BP, $1234
JEQ 2(PC) JEQ 2(PC)
INT $3 INT $3
...@@ -299,8 +308,8 @@ TEXT runtime·clone(SB),NOSPLIT,$0 ...@@ -299,8 +308,8 @@ TEXT runtime·clone(SB),NOSPLIT,$0
// In child on new stack. Reload registers (paranoia). // In child on new stack. Reload registers (paranoia).
MOVL 0(SP), BX // m MOVL 0(SP), BX // m
MOVL 4(SP), DX // g MOVL flags+0(FP), DX // g
MOVL 8(SP), SI // fn MOVL stk+4(FP), SI // fn
MOVL AX, m_procid(BX) // save tid as m->procid MOVL AX, m_procid(BX) // save tid as m->procid
...@@ -337,7 +346,6 @@ TEXT runtime·clone(SB),NOSPLIT,$0 ...@@ -337,7 +346,6 @@ TEXT runtime·clone(SB),NOSPLIT,$0
CALL SI // fn() CALL SI // fn()
CALL runtime·exit1(SB) CALL runtime·exit1(SB)
MOVL $0x1234, 0x1005 MOVL $0x1234, 0x1005
RET
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8 TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVL $186, AX // sigaltstack MOVL $186, AX // sigaltstack
...@@ -426,50 +434,55 @@ TEXT runtime·osyield(SB),NOSPLIT,$0 ...@@ -426,50 +434,55 @@ TEXT runtime·osyield(SB),NOSPLIT,$0
TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0
MOVL $242, AX // syscall - sched_getaffinity MOVL $242, AX // syscall - sched_getaffinity
MOVL 4(SP), BX MOVL pid+0(FP), BX
MOVL 8(SP), CX MOVL len+4(FP), CX
MOVL 12(SP), DX MOVL buf+8(FP), DX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+12(FP)
RET RET
// int32 runtime·epollcreate(int32 size); // int32 runtime·epollcreate(int32 size);
TEXT runtime·epollcreate(SB),NOSPLIT,$0 TEXT runtime·epollcreate(SB),NOSPLIT,$0
MOVL $254, AX MOVL $254, AX
MOVL 4(SP), BX MOVL size+0(FP), BX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+4(FP)
RET RET
// int32 runtime·epollcreate1(int32 flags); // int32 runtime·epollcreate1(int32 flags);
TEXT runtime·epollcreate1(SB),NOSPLIT,$0 TEXT runtime·epollcreate1(SB),NOSPLIT,$0
MOVL $329, AX MOVL $329, AX
MOVL 4(SP), BX MOVL flags+0(FP), BX
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+4(FP)
RET RET
// int32 runtime·epollctl(int32 epfd, int32 op, int32 fd, EpollEvent *ev); // int32 runtime·epollctl(int32 epfd, int32 op, int32 fd, EpollEvent *ev);
TEXT runtime·epollctl(SB),NOSPLIT,$0 TEXT runtime·epollctl(SB),NOSPLIT,$0
MOVL $255, AX MOVL $255, AX
MOVL 4(SP), BX MOVL epfd+0(FP), BX
MOVL 8(SP), CX MOVL op+4(FP), CX
MOVL 12(SP), DX MOVL fd+8(FP), DX
MOVL 16(SP), SI MOVL ev+12(FP), SI
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+16(FP)
RET RET
// int32 runtime·epollwait(int32 epfd, EpollEvent *ev, int32 nev, int32 timeout); // int32 runtime·epollwait(int32 epfd, EpollEvent *ev, int32 nev, int32 timeout);
TEXT runtime·epollwait(SB),NOSPLIT,$0 TEXT runtime·epollwait(SB),NOSPLIT,$0
MOVL $256, AX MOVL $256, AX
MOVL 4(SP), BX MOVL epfd+0(FP), BX
MOVL 8(SP), CX MOVL ev+4(FP), CX
MOVL 12(SP), DX MOVL nev+8(FP), DX
MOVL 16(SP), SI MOVL timeout+12(FP), SI
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
MOVL AX, ret+16(FP)
RET RET
// void runtime·closeonexec(int32 fd); // void runtime·closeonexec(int32 fd);
TEXT runtime·closeonexec(SB),NOSPLIT,$0 TEXT runtime·closeonexec(SB),NOSPLIT,$0
MOVL $55, AX // fcntl MOVL $55, AX // fcntl
MOVL 4(SP), BX // fd MOVL fd+0(FP), BX // fd
MOVL $2, CX // F_SETFD MOVL $2, CX // F_SETFD
MOVL $1, DX // FD_CLOEXEC MOVL $1, DX // FD_CLOEXEC
CALL *runtime·_vdso(SB) CALL *runtime·_vdso(SB)
......
...@@ -9,53 +9,58 @@ ...@@ -9,53 +9,58 @@
#include "zasm_GOOS_GOARCH.h" #include "zasm_GOOS_GOARCH.h"
#include "../../cmd/ld/textflag.h" #include "../../cmd/ld/textflag.h"
TEXT runtime·exit(SB),NOSPLIT,$0-8 TEXT runtime·exit(SB),NOSPLIT,$0-4
MOVL 8(SP), DI MOVL code+0(FP), DI
MOVL $231, AX // exitgroup - force all os threads to exit MOVL $231, AX // exitgroup - force all os threads to exit
SYSCALL SYSCALL
RET RET
TEXT runtime·exit1(SB),NOSPLIT,$0-8 TEXT runtime·exit1(SB),NOSPLIT,$0-4
MOVL 8(SP), DI MOVL code+0(FP), DI
MOVL $60, AX // exit - exit the current os thread MOVL $60, AX // exit - exit the current os thread
SYSCALL SYSCALL
RET RET
TEXT runtime·open(SB),NOSPLIT,$0-16 TEXT runtime·open(SB),NOSPLIT,$0-20
MOVQ 8(SP), DI MOVQ name+0(FP), DI
MOVL 16(SP), SI MOVL mode+8(FP), SI
MOVL 20(SP), DX MOVL perm+12(FP), DX
MOVL $2, AX // syscall entry MOVL $2, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$0-16 TEXT runtime·close(SB),NOSPLIT,$0-12
MOVL 8(SP), DI MOVL fd+0(FP), DI
MOVL $3, AX // syscall entry MOVL $3, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$0-24 TEXT runtime·write(SB),NOSPLIT,$0-28
MOVL 8(SP), DI MOVQ fd+0(FP), DI
MOVQ 16(SP), SI MOVQ p+8(FP), SI
MOVL 24(SP), DX MOVL n+16(FP), DX
MOVL $1, AX // syscall entry MOVL $1, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$0-24 TEXT runtime·read(SB),NOSPLIT,$0-28
MOVL 8(SP), DI MOVL fd+0(FP), DI
MOVQ 16(SP), SI MOVQ p+8(FP), SI
MOVL 24(SP), DX MOVL n+16(FP), DX
MOVL $0, AX // syscall entry MOVL $0, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·getrlimit(SB),NOSPLIT,$0-24 TEXT runtime·getrlimit(SB),NOSPLIT,$0-20
MOVL 8(SP), DI MOVL kind+0(FP), DI
MOVQ 16(SP), SI MOVQ limit+8(FP), SI
MOVL $97, AX // syscall entry MOVL $97, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·usleep(SB),NOSPLIT,$16 TEXT runtime·usleep(SB),NOSPLIT,$16
...@@ -86,19 +91,20 @@ TEXT runtime·raise(SB),NOSPLIT,$0 ...@@ -86,19 +91,20 @@ TEXT runtime·raise(SB),NOSPLIT,$0
RET RET
TEXT runtime·setitimer(SB),NOSPLIT,$0-24 TEXT runtime·setitimer(SB),NOSPLIT,$0-24
MOVL 8(SP), DI MOVL mode+0(FP), DI
MOVQ 16(SP), SI MOVQ new+8(FP), SI
MOVQ 24(SP), DX MOVQ old+16(FP), DX
MOVL $38, AX // syscall entry MOVL $38, AX // syscall entry
SYSCALL SYSCALL
RET RET
TEXT runtime·mincore(SB),NOSPLIT,$0-24 TEXT runtime·mincore(SB),NOSPLIT,$0-28
MOVQ 8(SP), DI MOVQ addr+0(FP), DI
MOVQ 16(SP), SI MOVQ n+8(FP), SI
MOVQ 24(SP), DX MOVQ dst+16(FP), DX
MOVL $27, AX // syscall entry MOVL $27, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
// func now() (sec int64, nsec int32) // func now() (sec int64, nsec int32)
...@@ -145,6 +151,7 @@ TEXT runtime·nanotime(SB),NOSPLIT,$16 ...@@ -145,6 +151,7 @@ TEXT runtime·nanotime(SB),NOSPLIT,$16
// return nsec in AX // return nsec in AX
IMULQ $1000000000, AX IMULQ $1000000000, AX
ADDQ DX, AX ADDQ DX, AX
MOVQ AX, ret+0(FP)
RET RET
fallback_gtod_nt: fallback_gtod_nt:
LEAQ 0(SP), DI LEAQ 0(SP), DI
...@@ -158,13 +165,14 @@ fallback_gtod_nt: ...@@ -158,13 +165,14 @@ fallback_gtod_nt:
// return nsec in AX // return nsec in AX
IMULQ $1000000000, AX IMULQ $1000000000, AX
ADDQ DX, AX ADDQ DX, AX
MOVQ AX, ret+0(FP)
RET RET
TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0-32 TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0-28
MOVL 8(SP), DI MOVL sig+0(FP), DI
MOVQ 16(SP), SI MOVQ new+8(FP), SI
MOVQ 24(SP), DX MOVQ old+16(FP), DX
MOVL 32(SP), R10 MOVL size+24(FP), R10
MOVL $14, AX // syscall entry MOVL $14, AX // syscall entry
SYSCALL SYSCALL
CMPQ AX, $0xfffffffffffff001 CMPQ AX, $0xfffffffffffff001
...@@ -172,13 +180,14 @@ TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0-32 ...@@ -172,13 +180,14 @@ TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0-32
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
RET RET
TEXT runtime·rt_sigaction(SB),NOSPLIT,$0-32 TEXT runtime·rt_sigaction(SB),NOSPLIT,$0-36
MOVL 8(SP), DI MOVQ sig+0(FP), DI
MOVQ 16(SP), SI MOVQ new+8(FP), SI
MOVQ 24(SP), DX MOVQ old+16(FP), DX
MOVQ 32(SP), R10 MOVQ size+24(FP), R10
MOVL $13, AX // syscall entry MOVL $13, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+32(FP)
RET RET
TEXT runtime·sigtramp(SB),NOSPLIT,$64 TEXT runtime·sigtramp(SB),NOSPLIT,$64
...@@ -220,12 +229,12 @@ TEXT runtime·sigreturn(SB),NOSPLIT,$0 ...@@ -220,12 +229,12 @@ TEXT runtime·sigreturn(SB),NOSPLIT,$0
INT $3 // not reached INT $3 // not reached
TEXT runtime·mmap(SB),NOSPLIT,$0 TEXT runtime·mmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI MOVQ addr+0(FP), DI
MOVQ 16(SP), SI MOVQ n+8(FP), SI
MOVL 24(SP), DX MOVL prot+16(FP), DX
MOVL 28(SP), R10 MOVL flags+20(FP), R10
MOVL 32(SP), R8 MOVL fd+24(FP), R8
MOVL 36(SP), R9 MOVL off+28(FP), R9
MOVL $9, AX // mmap MOVL $9, AX // mmap
SYSCALL SYSCALL
...@@ -233,11 +242,12 @@ TEXT runtime·mmap(SB),NOSPLIT,$0 ...@@ -233,11 +242,12 @@ TEXT runtime·mmap(SB),NOSPLIT,$0
JLS 3(PC) JLS 3(PC)
NOTQ AX NOTQ AX
INCQ AX INCQ AX
MOVQ AX, ret+32(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$0 TEXT runtime·munmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI MOVQ addr+0(FP), DI
MOVQ 16(SP), SI MOVQ n+8(FP), SI
MOVQ $11, AX // munmap MOVQ $11, AX // munmap
SYSCALL SYSCALL
CMPQ AX, $0xfffffffffffff001 CMPQ AX, $0xfffffffffffff001
...@@ -246,9 +256,9 @@ TEXT runtime·munmap(SB),NOSPLIT,$0 ...@@ -246,9 +256,9 @@ TEXT runtime·munmap(SB),NOSPLIT,$0
RET RET
TEXT runtime·madvise(SB),NOSPLIT,$0 TEXT runtime·madvise(SB),NOSPLIT,$0
MOVQ 8(SP), DI MOVQ addr+0(FP), DI
MOVQ 16(SP), SI MOVQ n+8(FP), SI
MOVQ 24(SP), DX MOVL flags+16(FP), DX
MOVQ $28, AX // madvise MOVQ $28, AX // madvise
SYSCALL SYSCALL
// ignore failure - maybe pages are locked // ignore failure - maybe pages are locked
...@@ -257,17 +267,18 @@ TEXT runtime·madvise(SB),NOSPLIT,$0 ...@@ -257,17 +267,18 @@ TEXT runtime·madvise(SB),NOSPLIT,$0
// int64 futex(int32 *uaddr, int32 op, int32 val, // int64 futex(int32 *uaddr, int32 op, int32 val,
// struct timespec *timeout, int32 *uaddr2, int32 val2); // struct timespec *timeout, int32 *uaddr2, int32 val2);
TEXT runtime·futex(SB),NOSPLIT,$0 TEXT runtime·futex(SB),NOSPLIT,$0
MOVQ 8(SP), DI MOVQ addr+0(FP), DI
MOVL 16(SP), SI MOVL op+8(FP), SI
MOVL 20(SP), DX MOVL val+12(FP), DX
MOVQ 24(SP), R10 MOVQ ts+16(FP), R10
MOVQ 32(SP), R8 MOVQ addr2+24(FP), R8
MOVL 40(SP), R9 MOVL val3+32(FP), R9
MOVL $202, AX MOVL $202, AX
SYSCALL SYSCALL
MOVL AX, ret+40(FP)
RET RET
// int64 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void)); // int32 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void));
TEXT runtime·clone(SB),NOSPLIT,$0 TEXT runtime·clone(SB),NOSPLIT,$0
MOVL flags+8(SP), DI MOVL flags+8(SP), DI
MOVQ stack+16(SP), SI MOVQ stack+16(SP), SI
...@@ -283,7 +294,8 @@ TEXT runtime·clone(SB),NOSPLIT,$0 ...@@ -283,7 +294,8 @@ TEXT runtime·clone(SB),NOSPLIT,$0
// In parent, return. // In parent, return.
CMPQ AX, $0 CMPQ AX, $0
JEQ 2(PC) JEQ 3(PC)
MOVL AX, ret+40(FP)
RET RET
// In child, on new stack. // In child, on new stack.
...@@ -342,50 +354,55 @@ TEXT runtime·osyield(SB),NOSPLIT,$0 ...@@ -342,50 +354,55 @@ TEXT runtime·osyield(SB),NOSPLIT,$0
RET RET
TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0
MOVQ 8(SP), DI MOVQ pid+0(FP), DI
MOVL 16(SP), SI MOVQ len+8(FP), SI
MOVQ 24(SP), DX MOVQ buf+16(FP), DX
MOVL $204, AX // syscall entry MOVL $204, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
// int32 runtime·epollcreate(int32 size); // int32 runtime·epollcreate(int32 size);
TEXT runtime·epollcreate(SB),NOSPLIT,$0 TEXT runtime·epollcreate(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL size+0(FP), DI
MOVL $213, AX // syscall entry MOVL $213, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+8(FP)
RET RET
// int32 runtime·epollcreate1(int32 flags); // int32 runtime·epollcreate1(int32 flags);
TEXT runtime·epollcreate1(SB),NOSPLIT,$0 TEXT runtime·epollcreate1(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL flags+0(FP), DI
MOVL $291, AX // syscall entry MOVL $291, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+8(FP)
RET RET
// int32 runtime·epollctl(int32 epfd, int32 op, int32 fd, EpollEvent *ev); // int32 runtime·epollctl(int32 epfd, int32 op, int32 fd, EpollEvent *ev);
TEXT runtime·epollctl(SB),NOSPLIT,$0 TEXT runtime·epollctl(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL epfd+0(FP), DI
MOVL 12(SP), SI MOVL op+4(FP), SI
MOVL 16(SP), DX MOVL fd+8(FP), DX
MOVQ 24(SP), R10 MOVQ ev+16(FP), R10
MOVL $233, AX // syscall entry MOVL $233, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
// int32 runtime·epollwait(int32 epfd, EpollEvent *ev, int32 nev, int32 timeout); // int32 runtime·epollwait(int32 epfd, EpollEvent *ev, int32 nev, int32 timeout);
TEXT runtime·epollwait(SB),NOSPLIT,$0 TEXT runtime·epollwait(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL epfd+0(FP), DI
MOVQ 16(SP), SI MOVQ ev+8(FP), SI
MOVL 24(SP), DX MOVL nev+16(FP), DX
MOVL 28(SP), R10 MOVL timeout+20(FP), R10
MOVL $232, AX // syscall entry MOVL $232, AX // syscall entry
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
// void runtime·closeonexec(int32 fd); // void runtime·closeonexec(int32 fd);
TEXT runtime·closeonexec(SB),NOSPLIT,$0 TEXT runtime·closeonexec(SB),NOSPLIT,$0
MOVL 8(SP), DI // fd MOVL fd+0(FP), DI // fd
MOVQ $2, SI // F_SETFD MOVQ $2, SI // F_SETFD
MOVQ $1, DX // FD_CLOEXEC MOVQ $1, DX // FD_CLOEXEC
MOVL $72, AX // fcntl MOVL $72, AX // fcntl
......
...@@ -51,12 +51,14 @@ TEXT runtime·open(SB),NOSPLIT,$0 ...@@ -51,12 +51,14 @@ TEXT runtime·open(SB),NOSPLIT,$0
MOVW 8(FP), R2 MOVW 8(FP), R2
MOVW $SYS_open, R7 MOVW $SYS_open, R7
SWI $0 SWI $0
MOVW R0, ret+12(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$0 TEXT runtime·close(SB),NOSPLIT,$0
MOVW 0(FP), R0 MOVW 0(FP), R0
MOVW $SYS_close, R7 MOVW $SYS_close, R7
SWI $0 SWI $0
MOVW R0, ret+4(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$0 TEXT runtime·write(SB),NOSPLIT,$0
...@@ -65,6 +67,7 @@ TEXT runtime·write(SB),NOSPLIT,$0 ...@@ -65,6 +67,7 @@ TEXT runtime·write(SB),NOSPLIT,$0
MOVW 8(FP), R2 MOVW 8(FP), R2
MOVW $SYS_write, R7 MOVW $SYS_write, R7
SWI $0 SWI $0
MOVW R0, ret+12(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$0 TEXT runtime·read(SB),NOSPLIT,$0
...@@ -73,6 +76,7 @@ TEXT runtime·read(SB),NOSPLIT,$0 ...@@ -73,6 +76,7 @@ TEXT runtime·read(SB),NOSPLIT,$0
MOVW 8(FP), R2 MOVW 8(FP), R2
MOVW $SYS_read, R7 MOVW $SYS_read, R7
SWI $0 SWI $0
MOVW R0, ret+12(FP)
RET RET
TEXT runtime·getrlimit(SB),NOSPLIT,$0 TEXT runtime·getrlimit(SB),NOSPLIT,$0
...@@ -80,6 +84,7 @@ TEXT runtime·getrlimit(SB),NOSPLIT,$0 ...@@ -80,6 +84,7 @@ TEXT runtime·getrlimit(SB),NOSPLIT,$0
MOVW 4(FP), R1 MOVW 4(FP), R1
MOVW $SYS_ugetrlimit, R7 MOVW $SYS_ugetrlimit, R7
SWI $0 SWI $0
MOVW R0, ret+8(FP)
RET RET
TEXT runtime·exit(SB),NOSPLIT,$-4 TEXT runtime·exit(SB),NOSPLIT,$-4
...@@ -119,6 +124,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$0 ...@@ -119,6 +124,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$0
MOVW $0xfffff001, R6 MOVW $0xfffff001, R6
CMP R6, R0 CMP R6, R0
RSB.HI $0, R0 RSB.HI $0, R0
MOVW R0, ret+24(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$0 TEXT runtime·munmap(SB),NOSPLIT,$0
...@@ -155,6 +161,7 @@ TEXT runtime·mincore(SB),NOSPLIT,$0 ...@@ -155,6 +161,7 @@ TEXT runtime·mincore(SB),NOSPLIT,$0
MOVW 8(FP), R2 MOVW 8(FP), R2
MOVW $SYS_mincore, R7 MOVW $SYS_mincore, R7
SWI $0 SWI $0
MOVW R0, ret+12(FP)
RET RET
TEXT time·now(SB), NOSPLIT, $32 TEXT time·now(SB), NOSPLIT, $32
...@@ -172,8 +179,7 @@ TEXT time·now(SB), NOSPLIT, $32 ...@@ -172,8 +179,7 @@ TEXT time·now(SB), NOSPLIT, $32
MOVW R2, 8(FP) MOVW R2, 8(FP)
RET RET
// int64 nanotime(void) so really // int64 nanotime(void)
// void nanotime(int64 *nsec)
TEXT runtime·nanotime(SB),NOSPLIT,$32 TEXT runtime·nanotime(SB),NOSPLIT,$32
MOVW $1, R0 // CLOCK_MONOTONIC MOVW $1, R0 // CLOCK_MONOTONIC
MOVW $8(R13), R1 // timespec MOVW $8(R13), R1 // timespec
...@@ -189,9 +195,8 @@ TEXT runtime·nanotime(SB),NOSPLIT,$32 ...@@ -189,9 +195,8 @@ TEXT runtime·nanotime(SB),NOSPLIT,$32
ADD.S R2, R0 ADD.S R2, R0
ADC R4, R1 ADC R4, R1
MOVW 0(FP), R3 MOVW R0, ret_lo+0(FP)
MOVW R0, 0(R3) MOVW R1, ret_hi+4(FP)
MOVW R1, 4(R3)
RET RET
// int32 futex(int32 *uaddr, int32 op, int32 val, // int32 futex(int32 *uaddr, int32 op, int32 val,
...@@ -205,13 +210,14 @@ TEXT runtime·futex(SB),NOSPLIT,$0 ...@@ -205,13 +210,14 @@ TEXT runtime·futex(SB),NOSPLIT,$0
MOVW 24(SP), R5 MOVW 24(SP), R5
MOVW $SYS_futex, R7 MOVW $SYS_futex, R7
SWI $0 SWI $0
MOVW R0, ret+24(FP)
RET RET
// int32 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void)); // int32 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void));
TEXT runtime·clone(SB),NOSPLIT,$0 TEXT runtime·clone(SB),NOSPLIT,$0
MOVW flags+0(FP), R0 MOVW flags+0(FP), R0
MOVW stack+4(FP), R1 MOVW stk+4(FP), R1
MOVW $0, R2 // parent tid ptr MOVW $0, R2 // parent tid ptr
MOVW $0, R3 // tls_val MOVW $0, R3 // tls_val
MOVW $0, R4 // child tid ptr MOVW $0, R4 // child tid ptr
...@@ -234,7 +240,8 @@ TEXT runtime·clone(SB),NOSPLIT,$0 ...@@ -234,7 +240,8 @@ TEXT runtime·clone(SB),NOSPLIT,$0
// In parent, return. // In parent, return.
CMP $0, R0 CMP $0, R0
BEQ 2(PC) BEQ 3(PC)
MOVW R0, ret+20(FP)
RET RET
// Paranoia: check that SP is as we expect. Use R13 to avoid linker 'fixup' // Paranoia: check that SP is as we expect. Use R13 to avoid linker 'fixup'
...@@ -338,6 +345,7 @@ TEXT runtime·rt_sigaction(SB),NOSPLIT,$0 ...@@ -338,6 +345,7 @@ TEXT runtime·rt_sigaction(SB),NOSPLIT,$0
MOVW 12(FP), R3 MOVW 12(FP), R3
MOVW $SYS_rt_sigaction, R7 MOVW $SYS_rt_sigaction, R7
SWI $0 SWI $0
MOVW R0, ret+16(FP)
RET RET
TEXT runtime·usleep(SB),NOSPLIT,$12 TEXT runtime·usleep(SB),NOSPLIT,$12
...@@ -363,22 +371,24 @@ TEXT cas<>(SB),NOSPLIT,$0 ...@@ -363,22 +371,24 @@ TEXT cas<>(SB),NOSPLIT,$0
MOVW $0xffff0fc0, PC MOVW $0xffff0fc0, PC
TEXT runtime·cas(SB),NOSPLIT,$0 TEXT runtime·cas(SB),NOSPLIT,$0
MOVW valptr+0(FP), R2 MOVW ptr+0(FP), R2
MOVW old+4(FP), R0 MOVW old+4(FP), R0
casagain: casagain:
MOVW new+8(FP), R1 MOVW new+8(FP), R1
BL cas<>(SB) BL cas<>(SB)
BCC cascheck BCC cascheck
MOVW $1, R0 MOVW $1, R0
MOVB R0, ret+12(FP)
RET RET
cascheck: cascheck:
// Kernel lies; double-check. // Kernel lies; double-check.
MOVW valptr+0(FP), R2 MOVW ptr+0(FP), R2
MOVW old+4(FP), R0 MOVW old+4(FP), R0
MOVW 0(R2), R3 MOVW 0(R2), R3
CMP R0, R3 CMP R0, R3
BEQ casagain BEQ casagain
MOVW $0, R0 MOVW $0, R0
MOVB R0, ret+12(FP)
RET RET
TEXT runtime·casp(SB),NOSPLIT,$0 TEXT runtime·casp(SB),NOSPLIT,$0
...@@ -395,6 +405,7 @@ TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 ...@@ -395,6 +405,7 @@ TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0
MOVW 8(FP), R2 MOVW 8(FP), R2
MOVW $SYS_sched_getaffinity, R7 MOVW $SYS_sched_getaffinity, R7
SWI $0 SWI $0
MOVW R0, ret+12(FP)
RET RET
// int32 runtime·epollcreate(int32 size) // int32 runtime·epollcreate(int32 size)
...@@ -402,6 +413,7 @@ TEXT runtime·epollcreate(SB),NOSPLIT,$0 ...@@ -402,6 +413,7 @@ TEXT runtime·epollcreate(SB),NOSPLIT,$0
MOVW 0(FP), R0 MOVW 0(FP), R0
MOVW $SYS_epoll_create, R7 MOVW $SYS_epoll_create, R7
SWI $0 SWI $0
MOVW R0, ret+4(FP)
RET RET
// int32 runtime·epollcreate1(int32 flags) // int32 runtime·epollcreate1(int32 flags)
...@@ -409,6 +421,7 @@ TEXT runtime·epollcreate1(SB),NOSPLIT,$0 ...@@ -409,6 +421,7 @@ TEXT runtime·epollcreate1(SB),NOSPLIT,$0
MOVW 0(FP), R0 MOVW 0(FP), R0
MOVW $SYS_epoll_create1, R7 MOVW $SYS_epoll_create1, R7
SWI $0 SWI $0
MOVW R0, ret+4(FP)
RET RET
// int32 runtime·epollctl(int32 epfd, int32 op, int32 fd, EpollEvent *ev) // int32 runtime·epollctl(int32 epfd, int32 op, int32 fd, EpollEvent *ev)
...@@ -419,6 +432,7 @@ TEXT runtime·epollctl(SB),NOSPLIT,$0 ...@@ -419,6 +432,7 @@ TEXT runtime·epollctl(SB),NOSPLIT,$0
MOVW 12(FP), R3 MOVW 12(FP), R3
MOVW $SYS_epoll_ctl, R7 MOVW $SYS_epoll_ctl, R7
SWI $0 SWI $0
MOVW R0, ret+16(FP)
RET RET
// int32 runtime·epollwait(int32 epfd, EpollEvent *ev, int32 nev, int32 timeout) // int32 runtime·epollwait(int32 epfd, EpollEvent *ev, int32 nev, int32 timeout)
...@@ -429,6 +443,7 @@ TEXT runtime·epollwait(SB),NOSPLIT,$0 ...@@ -429,6 +443,7 @@ TEXT runtime·epollwait(SB),NOSPLIT,$0
MOVW 12(FP), R3 MOVW 12(FP), R3
MOVW $SYS_epoll_wait, R7 MOVW $SYS_epoll_wait, R7
SWI $0 SWI $0
MOVW R0, ret+16(FP)
RET RET
// void runtime·closeonexec(int32 fd) // void runtime·closeonexec(int32 fd)
......
...@@ -96,22 +96,23 @@ TEXT runtime·osyield(SB),NOSPLIT,$0 ...@@ -96,22 +96,23 @@ TEXT runtime·osyield(SB),NOSPLIT,$0
NACL_SYSJMP(SYS_sched_yield) NACL_SYSJMP(SYS_sched_yield)
TEXT runtime·mmap(SB),NOSPLIT,$32 TEXT runtime·mmap(SB),NOSPLIT,$32
MOVL arg1+0(FP), AX MOVL addr+0(FP), AX
MOVL AX, 0(SP) MOVL AX, 0(SP)
MOVL arg2+4(FP), AX MOVL n+4(FP), AX
MOVL AX, 4(SP) MOVL AX, 4(SP)
MOVL arg3+8(FP), AX MOVL prot+8(FP), AX
MOVL AX, 8(SP) MOVL AX, 8(SP)
MOVL arg4+12(FP), AX MOVL flags+12(FP), AX
MOVL AX, 12(SP) MOVL AX, 12(SP)
MOVL arg5+16(FP), AX MOVL fd+16(FP), AX
MOVL AX, 16(SP) MOVL AX, 16(SP)
MOVL arg6+20(FP), AX MOVL off+20(FP), AX
MOVL AX, 24(SP) MOVL AX, 24(SP)
MOVL $0, 28(SP) MOVL $0, 28(SP)
LEAL 24(SP), AX LEAL 24(SP), AX
MOVL AX, 20(SP) MOVL AX, 20(SP)
NACL_SYSCALL(SYS_mmap) NACL_SYSCALL(SYS_mmap)
MOVL AX, ret+24(FP)
RET RET
TEXT time·now(SB),NOSPLIT,$20 TEXT time·now(SB),NOSPLIT,$20
...@@ -150,9 +151,8 @@ TEXT runtime·nanotime(SB),NOSPLIT,$20 ...@@ -150,9 +151,8 @@ TEXT runtime·nanotime(SB),NOSPLIT,$20
ADDL BX, AX ADDL BX, AX
ADCL $0, DX ADCL $0, DX
MOVL ret+0(FP), DI MOVL AX, ret_lo+0(FP)
MOVL AX, 0(DI) MOVL DX, ret_hi+4(FP)
MOVL DX, 4(DI)
RET RET
TEXT runtime·setldt(SB),NOSPLIT,$8 TEXT runtime·setldt(SB),NOSPLIT,$8
......
...@@ -17,27 +17,27 @@ TEXT runtime·settls(SB),NOSPLIT,$0 ...@@ -17,27 +17,27 @@ TEXT runtime·settls(SB),NOSPLIT,$0
RET RET
TEXT runtime·exit(SB),NOSPLIT,$0 TEXT runtime·exit(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL code+0(FP), DI
NACL_SYSJMP(SYS_exit) NACL_SYSJMP(SYS_exit)
TEXT runtime·exit1(SB),NOSPLIT,$0 TEXT runtime·exit1(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL code+0(FP), DI
NACL_SYSJMP(SYS_thread_exit) NACL_SYSJMP(SYS_thread_exit)
TEXT runtime·open(SB),NOSPLIT,$0 TEXT runtime·open(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL name+0(FP), DI
MOVL arg2+4(FP), SI MOVL mode+4(FP), SI
MOVL arg3+8(FP), DX MOVL perm+8(FP), DX
NACL_SYSJMP(SYS_open) NACL_SYSJMP(SYS_open)
TEXT runtime·close(SB),NOSPLIT,$0 TEXT runtime·close(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL fd+0(FP), DI
NACL_SYSJMP(SYS_close) NACL_SYSJMP(SYS_close)
TEXT runtime·read(SB),NOSPLIT,$0 TEXT runtime·read(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL fd+0(FP), DI
MOVL arg2+4(FP), SI MOVL p+4(FP), SI
MOVL arg3+8(FP), DX MOVL n+8(FP), DX
NACL_SYSJMP(SYS_read) NACL_SYSJMP(SYS_read)
TEXT syscall·naclWrite(SB), NOSPLIT, $16-20 TEXT syscall·naclWrite(SB), NOSPLIT, $16-20
...@@ -51,13 +51,13 @@ TEXT syscall·naclWrite(SB), NOSPLIT, $16-20 ...@@ -51,13 +51,13 @@ TEXT syscall·naclWrite(SB), NOSPLIT, $16-20
MOVL AX, ret+16(FP) MOVL AX, ret+16(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$16-12 TEXT runtime·write(SB),NOSPLIT,$16-20
// If using fake time and writing to stdout or stderr, // If using fake time and writing to stdout or stderr,
// emit playback header before actual data. // emit playback header before actual data.
MOVQ runtime·timens(SB), AX MOVQ runtime·timens(SB), AX
CMPQ AX, $0 CMPQ AX, $0
JEQ write JEQ write
MOVL arg1+0(FP), DI MOVL fd+0(FP), DI
CMPL DI, $1 CMPL DI, $1
JEQ playback JEQ playback
CMPL DI, $2 CMPL DI, $2
...@@ -65,10 +65,11 @@ TEXT runtime·write(SB),NOSPLIT,$16-12 ...@@ -65,10 +65,11 @@ TEXT runtime·write(SB),NOSPLIT,$16-12
write: write:
// Ordinary write. // Ordinary write.
MOVL arg1+0(FP), DI MOVL fd+0(FP), DI
MOVL arg2+4(FP), SI MOVL p+4(FP), SI
MOVL arg3+8(FP), DX MOVL n+8(FP), DX
NACL_SYSCALL(SYS_write) NACL_SYSCALL(SYS_write)
MOVL AX, ret+16(FP)
RET RET
// Write with playback header. // Write with playback header.
...@@ -83,7 +84,7 @@ playback: ...@@ -83,7 +84,7 @@ playback:
MOVL $(('B'<<24) | ('P'<<16)), 0(SP) MOVL $(('B'<<24) | ('P'<<16)), 0(SP)
BSWAPQ AX BSWAPQ AX
MOVQ AX, 4(SP) MOVQ AX, 4(SP)
MOVL arg3+8(FP), DX MOVL n+8(FP), DX
BSWAPL DX BSWAPL DX
MOVL DX, 12(SP) MOVL DX, 12(SP)
MOVL $1, DI // standard output MOVL $1, DI // standard output
...@@ -93,81 +94,82 @@ playback: ...@@ -93,81 +94,82 @@ playback:
// Write actual data. // Write actual data.
MOVL $1, DI // standard output MOVL $1, DI // standard output
MOVL arg2+4(FP), SI MOVL p+4(FP), SI
MOVL arg3+8(FP), DX MOVL n+8(FP), DX
NACL_SYSCALL(SYS_write) NACL_SYSCALL(SYS_write)
// Unlock. // Unlock.
MOVL $0, runtime·writelock(SB) MOVL $0, runtime·writelock(SB)
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·nacl_exception_stack(SB),NOSPLIT,$0 TEXT runtime·nacl_exception_stack(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL p+0(FP), DI
MOVL arg2+4(FP), SI MOVL size+4(FP), SI
NACL_SYSJMP(SYS_exception_stack) NACL_SYSJMP(SYS_exception_stack)
TEXT runtime·nacl_exception_handler(SB),NOSPLIT,$0 TEXT runtime·nacl_exception_handler(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL fn+0(FP), DI
MOVL arg2+4(FP), SI MOVL arg+4(FP), SI
NACL_SYSJMP(SYS_exception_handler) NACL_SYSJMP(SYS_exception_handler)
TEXT runtime·nacl_sem_create(SB),NOSPLIT,$0 TEXT runtime·nacl_sem_create(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL flag+0(FP), DI
NACL_SYSJMP(SYS_sem_create) NACL_SYSJMP(SYS_sem_create)
TEXT runtime·nacl_sem_wait(SB),NOSPLIT,$0 TEXT runtime·nacl_sem_wait(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL sem+0(FP), DI
NACL_SYSJMP(SYS_sem_wait) NACL_SYSJMP(SYS_sem_wait)
TEXT runtime·nacl_sem_post(SB),NOSPLIT,$0 TEXT runtime·nacl_sem_post(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL sem+0(FP), DI
NACL_SYSJMP(SYS_sem_post) NACL_SYSJMP(SYS_sem_post)
TEXT runtime·nacl_mutex_create(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_create(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL flag+0(FP), DI
NACL_SYSJMP(SYS_mutex_create) NACL_SYSJMP(SYS_mutex_create)
TEXT runtime·nacl_mutex_lock(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_lock(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL mutex+0(FP), DI
NACL_SYSJMP(SYS_mutex_lock) NACL_SYSJMP(SYS_mutex_lock)
TEXT runtime·nacl_mutex_trylock(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_trylock(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL mutex+0(FP), DI
NACL_SYSJMP(SYS_mutex_trylock) NACL_SYSJMP(SYS_mutex_trylock)
TEXT runtime·nacl_mutex_unlock(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_unlock(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL mutex+0(FP), DI
NACL_SYSJMP(SYS_mutex_unlock) NACL_SYSJMP(SYS_mutex_unlock)
TEXT runtime·nacl_cond_create(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_create(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL flag+0(FP), DI
NACL_SYSJMP(SYS_cond_create) NACL_SYSJMP(SYS_cond_create)
TEXT runtime·nacl_cond_wait(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_wait(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL cond+0(FP), DI
MOVL arg2+4(FP), SI MOVL n+4(FP), SI
NACL_SYSJMP(SYS_cond_wait) NACL_SYSJMP(SYS_cond_wait)
TEXT runtime·nacl_cond_signal(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_signal(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL cond+0(FP), DI
NACL_SYSJMP(SYS_cond_signal) NACL_SYSJMP(SYS_cond_signal)
TEXT runtime·nacl_cond_broadcast(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_broadcast(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL cond+0(FP), DI
NACL_SYSJMP(SYS_cond_broadcast) NACL_SYSJMP(SYS_cond_broadcast)
TEXT runtime·nacl_cond_timed_wait_abs(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_timed_wait_abs(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL cond+0(FP), DI
MOVL arg2+4(FP), SI MOVL lock+4(FP), SI
MOVL arg3+8(FP), DX MOVL ts+8(FP), DX
NACL_SYSJMP(SYS_cond_timed_wait_abs) NACL_SYSJMP(SYS_cond_timed_wait_abs)
TEXT runtime·nacl_thread_create(SB),NOSPLIT,$0 TEXT runtime·nacl_thread_create(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL fn+0(FP), DI
MOVL arg2+4(FP), SI MOVL stk+4(FP), SI
MOVL arg3+8(FP), DX MOVL tls+8(FP), DX
MOVL arg4+12(FP), CX MOVL xx+12(FP), CX
NACL_SYSJMP(SYS_thread_create) NACL_SYSJMP(SYS_thread_create)
TEXT runtime·mstart_nacl(SB),NOSPLIT,$0 TEXT runtime·mstart_nacl(SB),NOSPLIT,$0
...@@ -177,26 +179,27 @@ TEXT runtime·mstart_nacl(SB),NOSPLIT,$0 ...@@ -177,26 +179,27 @@ TEXT runtime·mstart_nacl(SB),NOSPLIT,$0
JMP runtime·mstart(SB) JMP runtime·mstart(SB)
TEXT runtime·nacl_nanosleep(SB),NOSPLIT,$0 TEXT runtime·nacl_nanosleep(SB),NOSPLIT,$0
MOVL arg1+0(FP), DI MOVL ts+0(FP), DI
MOVL arg2+4(FP), SI MOVL extra+4(FP), SI
NACL_SYSJMP(SYS_nanosleep) NACL_SYSJMP(SYS_nanosleep)
TEXT runtime·osyield(SB),NOSPLIT,$0 TEXT runtime·osyield(SB),NOSPLIT,$0
NACL_SYSJMP(SYS_sched_yield) NACL_SYSJMP(SYS_sched_yield)
TEXT runtime·mmap(SB),NOSPLIT,$8 TEXT runtime·mmap(SB),NOSPLIT,$8
MOVL arg1+0(FP), DI MOVL addr+0(FP), DI
MOVL arg2+4(FP), SI MOVL n+4(FP), SI
MOVL arg3+8(FP), DX MOVL prot+8(FP), DX
MOVL arg4+12(FP), CX MOVL flags+12(FP), CX
MOVL arg5+16(FP), R8 MOVL fd+16(FP), R8
MOVL arg6+20(FP), AX MOVL off+20(FP), AX
MOVQ AX, 0(SP) MOVQ AX, 0(SP)
MOVL SP, R9 MOVL SP, R9
NACL_SYSCALL(SYS_mmap) NACL_SYSCALL(SYS_mmap)
CMPL AX, $-4095 CMPL AX, $-4095
JNA 2(PC) JNA 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+24(FP)
RET RET
TEXT time·now(SB),NOSPLIT,$16 TEXT time·now(SB),NOSPLIT,$16
...@@ -235,7 +238,8 @@ TEXT runtime·nacl_clock_gettime(SB),NOSPLIT,$0 ...@@ -235,7 +238,8 @@ TEXT runtime·nacl_clock_gettime(SB),NOSPLIT,$0
TEXT runtime·nanotime(SB),NOSPLIT,$16 TEXT runtime·nanotime(SB),NOSPLIT,$16
MOVQ runtime·timens(SB), AX MOVQ runtime·timens(SB), AX
CMPQ AX, $0 CMPQ AX, $0
JEQ 2(PC) JEQ 3(PC)
MOVQ AX, ret+0(FP)
RET RET
MOVL $0, DI // real time clock MOVL $0, DI // real time clock
LEAL 0(SP), AX LEAL 0(SP), AX
...@@ -248,6 +252,7 @@ TEXT runtime·nanotime(SB),NOSPLIT,$16 ...@@ -248,6 +252,7 @@ TEXT runtime·nanotime(SB),NOSPLIT,$16
// return nsec in AX // return nsec in AX
IMULQ $1000000000, AX IMULQ $1000000000, AX
ADDQ DX, AX ADDQ DX, AX
MOVQ AX, ret+0(FP)
RET RET
TEXT runtime·sigtramp(SB),NOSPLIT,$80 TEXT runtime·sigtramp(SB),NOSPLIT,$80
......
...@@ -13,27 +13,27 @@ ...@@ -13,27 +13,27 @@
MOVW $(0x10000 + ((code)<<5)), R8; B (R8) MOVW $(0x10000 + ((code)<<5)), R8; B (R8)
TEXT runtime·exit(SB),NOSPLIT,$0 TEXT runtime·exit(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW code+0(FP), R0
NACL_SYSJMP(SYS_exit) NACL_SYSJMP(SYS_exit)
TEXT runtime·exit1(SB),NOSPLIT,$0 TEXT runtime·exit1(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW code+0(FP), R0
NACL_SYSJMP(SYS_thread_exit) NACL_SYSJMP(SYS_thread_exit)
TEXT runtime·open(SB),NOSPLIT,$0 TEXT runtime·open(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW name+0(FP), R0
MOVW arg2+0(FP), R1 MOVW name+0(FP), R1
MOVW arg3+0(FP), R2 MOVW name+0(FP), R2
NACL_SYSJMP(SYS_open) NACL_SYSJMP(SYS_open)
TEXT runtime·close(SB),NOSPLIT,$0 TEXT runtime·close(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW fd+0(FP), R0
NACL_SYSJMP(SYS_close) NACL_SYSJMP(SYS_close)
TEXT runtime·read(SB),NOSPLIT,$0 TEXT runtime·read(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW fd+0(FP), R0
MOVW arg2+4(FP), R1 MOVW p+4(FP), R1
MOVW arg3+8(FP), R2 MOVW n+8(FP), R2
NACL_SYSJMP(SYS_read) NACL_SYSJMP(SYS_read)
// func naclWrite(fd int, b []byte) int // func naclWrite(fd int, b []byte) int
...@@ -46,77 +46,77 @@ TEXT syscall·naclWrite(SB),NOSPLIT,$0 ...@@ -46,77 +46,77 @@ TEXT syscall·naclWrite(SB),NOSPLIT,$0
RET RET
TEXT runtime·write(SB),NOSPLIT,$0 TEXT runtime·write(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW fd+0(FP), R0
MOVW arg2+4(FP), R1 MOVW p+4(FP), R1
MOVW arg3+8(FP), R2 MOVW n+8(FP), R2
NACL_SYSJMP(SYS_write) NACL_SYSJMP(SYS_write)
TEXT runtime·nacl_exception_stack(SB),NOSPLIT,$0 TEXT runtime·nacl_exception_stack(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW p+0(FP), R0
MOVW arg2+4(FP), R1 MOVW size+4(FP), R1
NACL_SYSJMP(SYS_exception_stack) NACL_SYSJMP(SYS_exception_stack)
TEXT runtime·nacl_exception_handler(SB),NOSPLIT,$0 TEXT runtime·nacl_exception_handler(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW fn+0(FP), R0
MOVW arg2+4(FP), R1 MOVW arg+4(FP), R1
NACL_SYSJMP(SYS_exception_handler) NACL_SYSJMP(SYS_exception_handler)
TEXT runtime·nacl_sem_create(SB),NOSPLIT,$0 TEXT runtime·nacl_sem_create(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW flag+0(FP), R0
NACL_SYSJMP(SYS_sem_create) NACL_SYSJMP(SYS_sem_create)
TEXT runtime·nacl_sem_wait(SB),NOSPLIT,$0 TEXT runtime·nacl_sem_wait(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW sem+0(FP), R0
NACL_SYSJMP(SYS_sem_wait) NACL_SYSJMP(SYS_sem_wait)
TEXT runtime·nacl_sem_post(SB),NOSPLIT,$0 TEXT runtime·nacl_sem_post(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW sem+0(FP), R0
NACL_SYSJMP(SYS_sem_post) NACL_SYSJMP(SYS_sem_post)
TEXT runtime·nacl_mutex_create(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_create(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW flag+0(FP), R0
NACL_SYSJMP(SYS_mutex_create) NACL_SYSJMP(SYS_mutex_create)
TEXT runtime·nacl_mutex_lock(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_lock(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW mutex+0(FP), R0
NACL_SYSJMP(SYS_mutex_lock) NACL_SYSJMP(SYS_mutex_lock)
TEXT runtime·nacl_mutex_trylock(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_trylock(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW mutex+0(FP), R0
NACL_SYSJMP(SYS_mutex_trylock) NACL_SYSJMP(SYS_mutex_trylock)
TEXT runtime·nacl_mutex_unlock(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_unlock(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW mutex+0(FP), R0
NACL_SYSJMP(SYS_mutex_unlock) NACL_SYSJMP(SYS_mutex_unlock)
TEXT runtime·nacl_cond_create(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_create(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW flag+0(FP), R0
NACL_SYSJMP(SYS_cond_create) NACL_SYSJMP(SYS_cond_create)
TEXT runtime·nacl_cond_wait(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_wait(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW cond+0(FP), R0
MOVW arg2+4(FP), R1 MOVW n+4(FP), R1
NACL_SYSJMP(SYS_cond_wait) NACL_SYSJMP(SYS_cond_wait)
TEXT runtime·nacl_cond_signal(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_signal(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW cond+0(FP), R0
NACL_SYSJMP(SYS_cond_signal) NACL_SYSJMP(SYS_cond_signal)
TEXT runtime·nacl_cond_broadcast(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_broadcast(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW cond+0(FP), R0
NACL_SYSJMP(SYS_cond_broadcast) NACL_SYSJMP(SYS_cond_broadcast)
TEXT runtime·nacl_cond_timed_wait_abs(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_timed_wait_abs(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW cond+0(FP), R0
MOVW arg2+4(FP), R1 MOVW lock+4(FP), R1
MOVW arg3+8(FP), R2 MOVW ts+8(FP), R2
NACL_SYSJMP(SYS_cond_timed_wait_abs) NACL_SYSJMP(SYS_cond_timed_wait_abs)
TEXT runtime·nacl_thread_create(SB),NOSPLIT,$0 TEXT runtime·nacl_thread_create(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW fn+0(FP), R0
MOVW arg2+4(FP), R1 MOVW stk+4(FP), R1
MOVW arg3+8(FP), R2 MOVW tls+8(FP), R2
MOVW arg4+12(FP), R3 MOVW xx+12(FP), R3
NACL_SYSJMP(SYS_thread_create) NACL_SYSJMP(SYS_thread_create)
TEXT runtime·mstart_nacl(SB),NOSPLIT,$0 TEXT runtime·mstart_nacl(SB),NOSPLIT,$0
...@@ -128,21 +128,21 @@ TEXT runtime·mstart_nacl(SB),NOSPLIT,$0 ...@@ -128,21 +128,21 @@ TEXT runtime·mstart_nacl(SB),NOSPLIT,$0
B runtime·mstart(SB) B runtime·mstart(SB)
TEXT runtime·nacl_nanosleep(SB),NOSPLIT,$0 TEXT runtime·nacl_nanosleep(SB),NOSPLIT,$0
MOVW arg1+0(FP), R0 MOVW ts+0(FP), R0
MOVW arg2+4(FP), R1 MOVW extra+4(FP), R1
NACL_SYSJMP(SYS_nanosleep) NACL_SYSJMP(SYS_nanosleep)
TEXT runtime·osyield(SB),NOSPLIT,$0 TEXT runtime·osyield(SB),NOSPLIT,$0
NACL_SYSJMP(SYS_sched_yield) NACL_SYSJMP(SYS_sched_yield)
TEXT runtime·mmap(SB),NOSPLIT,$8 TEXT runtime·mmap(SB),NOSPLIT,$8
MOVW arg1+0(FP), R0 MOVW addr+0(FP), R0
MOVW arg2+4(FP), R1 MOVW n+4(FP), R1
MOVW arg3+8(FP), R2 MOVW prot+8(FP), R2
MOVW arg4+12(FP), R3 MOVW flags+12(FP), R3
MOVW arg5+16(FP), R4 MOVW fd+16(FP), R4
// arg6:offset should be passed as a pointer (to int64) // arg6:offset should be passed as a pointer (to int64)
MOVW arg6+20(FP), R5 MOVW off+20(FP), R5
MOVW R5, 4(R13) MOVW R5, 4(R13)
MOVW $0, R6 MOVW $0, R6
MOVW R6, 8(R13) MOVW R6, 8(R13)
...@@ -152,6 +152,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$8 ...@@ -152,6 +152,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$8
MOVM.IA.W (R13), [R4, R5] MOVM.IA.W (R13), [R4, R5]
CMP $-4095, R0 CMP $-4095, R0
RSB.HI $0, R0 RSB.HI $0, R0
MOVW R0, ret+24(FP)
RET RET
TEXT time·now(SB),NOSPLIT,$16 TEXT time·now(SB),NOSPLIT,$16
...@@ -188,9 +189,8 @@ TEXT runtime·nanotime(SB),NOSPLIT,$16 ...@@ -188,9 +189,8 @@ TEXT runtime·nanotime(SB),NOSPLIT,$16
MOVW $0, R4 MOVW $0, R4
ADD.S R2, R0 ADD.S R2, R0
ADC R4, R1 ADC R4, R1
MOVW 0(FP), R2 MOVW R0, ret_lo+0(FP)
MOVW R0, 0(R2) MOVW R1, ret_hi+4(FP)
MOVW R1, 4(R2)
RET RET
TEXT runtime·sigtramp(SB),NOSPLIT,$80 TEXT runtime·sigtramp(SB),NOSPLIT,$80
......
...@@ -26,21 +26,25 @@ TEXT runtime·exit1(SB),NOSPLIT,$-4 ...@@ -26,21 +26,25 @@ TEXT runtime·exit1(SB),NOSPLIT,$-4
TEXT runtime·open(SB),NOSPLIT,$-4 TEXT runtime·open(SB),NOSPLIT,$-4
MOVL $5, AX MOVL $5, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$-4 TEXT runtime·close(SB),NOSPLIT,$-4
MOVL $6, AX MOVL $6, AX
INT $0x80 INT $0x80
MOVL AX, ret+4(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$-4 TEXT runtime·read(SB),NOSPLIT,$-4
MOVL $3, AX MOVL $3, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$-4 TEXT runtime·write(SB),NOSPLIT,$-4
MOVL $4, AX // sys_write MOVL $4, AX // sys_write
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·usleep(SB),NOSPLIT,$24 TEXT runtime·usleep(SB),NOSPLIT,$24
...@@ -74,7 +78,7 @@ TEXT runtime·raise(SB),NOSPLIT,$12 ...@@ -74,7 +78,7 @@ TEXT runtime·raise(SB),NOSPLIT,$12
RET RET
TEXT runtime·mmap(SB),NOSPLIT,$36 TEXT runtime·mmap(SB),NOSPLIT,$36
LEAL arg0+0(FP), SI LEAL addr+0(FP), SI
LEAL 4(SP), DI LEAL 4(SP), DI
CLD CLD
MOVSL // arg 1 - addr MOVSL // arg 1 - addr
...@@ -89,6 +93,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$36 ...@@ -89,6 +93,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$36
STOSL STOSL
MOVL $197, AX // sys_mmap MOVL $197, AX // sys_mmap
INT $0x80 INT $0x80
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$-4 TEXT runtime·munmap(SB),NOSPLIT,$-4
...@@ -146,9 +151,8 @@ TEXT runtime·nanotime(SB),NOSPLIT,$32 ...@@ -146,9 +151,8 @@ TEXT runtime·nanotime(SB),NOSPLIT,$32
ADDL BX, AX ADDL BX, AX
ADCL CX, DX // add high bits with carry ADCL CX, DX // add high bits with carry
MOVL ret+0(FP), DI MOVL AX, ret_lo+0(FP)
MOVL AX, 0(DI) MOVL DX, ret_hi+4(FP)
MOVL DX, 4(DI)
RET RET
TEXT runtime·getcontext(SB),NOSPLIT,$-4 TEXT runtime·getcontext(SB),NOSPLIT,$-4
...@@ -175,7 +179,7 @@ TEXT runtime·sigreturn_tramp(SB),NOSPLIT,$0 ...@@ -175,7 +179,7 @@ TEXT runtime·sigreturn_tramp(SB),NOSPLIT,$0
INT $0x80 INT $0x80
TEXT runtime·sigaction(SB),NOSPLIT,$24 TEXT runtime·sigaction(SB),NOSPLIT,$24
LEAL arg0+0(FP), SI LEAL sig+0(FP), SI
LEAL 4(SP), DI LEAL 4(SP), DI
CLD CLD
MOVSL // arg 1 - sig MOVSL // arg 1 - sig
...@@ -232,7 +236,7 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$44 ...@@ -232,7 +236,7 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$44
// int32 lwp_create(void *context, uintptr flags, void *lwpid); // int32 lwp_create(void *context, uintptr flags, void *lwpid);
TEXT runtime·lwp_create(SB),NOSPLIT,$16 TEXT runtime·lwp_create(SB),NOSPLIT,$16
MOVL $0, 0(SP) MOVL $0, 0(SP)
MOVL context+0(FP), AX MOVL ctxt+0(FP), AX
MOVL AX, 4(SP) // arg 1 - context MOVL AX, 4(SP) // arg 1 - context
MOVL flags+4(FP), AX MOVL flags+4(FP), AX
MOVL AX, 8(SP) // arg 2 - flags MOVL AX, 8(SP) // arg 2 - flags
...@@ -242,6 +246,7 @@ TEXT runtime·lwp_create(SB),NOSPLIT,$16 ...@@ -242,6 +246,7 @@ TEXT runtime·lwp_create(SB),NOSPLIT,$16
INT $0x80 INT $0x80
JCC 2(PC) JCC 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·lwp_tramp(SB),NOSPLIT,$0 TEXT runtime·lwp_tramp(SB),NOSPLIT,$0
...@@ -312,20 +317,23 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4 ...@@ -312,20 +317,23 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4
TEXT runtime·lwp_park(SB),NOSPLIT,$-4 TEXT runtime·lwp_park(SB),NOSPLIT,$-4
MOVL $434, AX // sys__lwp_park MOVL $434, AX // sys__lwp_park
INT $0x80 INT $0x80
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·lwp_unpark(SB),NOSPLIT,$-4 TEXT runtime·lwp_unpark(SB),NOSPLIT,$-4
MOVL $321, AX // sys__lwp_unpark MOVL $321, AX // sys__lwp_unpark
INT $0x80 INT $0x80
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·lwp_self(SB),NOSPLIT,$-4 TEXT runtime·lwp_self(SB),NOSPLIT,$-4
MOVL $311, AX // sys__lwp_self MOVL $311, AX // sys__lwp_self
INT $0x80 INT $0x80
MOVL AX, ret+0(FP)
RET RET
TEXT runtime·sysctl(SB),NOSPLIT,$28 TEXT runtime·sysctl(SB),NOSPLIT,$28
LEAL arg0+0(FP), SI LEAL mib+0(FP), SI
LEAL 4(SP), DI LEAL 4(SP), DI
CLD CLD
MOVSL // arg 1 - name MOVSL // arg 1 - name
...@@ -350,6 +358,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0 ...@@ -350,6 +358,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout) // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout)
...@@ -358,6 +367,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0 ...@@ -358,6 +367,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+24(FP)
RET RET
// int32 runtime·closeonexec(int32 fd) // int32 runtime·closeonexec(int32 fd)
......
...@@ -11,13 +11,14 @@ ...@@ -11,13 +11,14 @@
// int32 lwp_create(void *context, uintptr flags, void *lwpid) // int32 lwp_create(void *context, uintptr flags, void *lwpid)
TEXT runtime·lwp_create(SB),NOSPLIT,$0 TEXT runtime·lwp_create(SB),NOSPLIT,$0
MOVQ context+0(FP), DI MOVQ ctxt+0(FP), DI
MOVQ flags+8(FP), SI MOVQ flags+8(FP), SI
MOVQ lwpid+16(FP), DX MOVQ lwpid+16(FP), DX
MOVL $309, AX // sys__lwp_create MOVL $309, AX // sys__lwp_create
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·lwp_tramp(SB),NOSPLIT,$0 TEXT runtime·lwp_tramp(SB),NOSPLIT,$0
...@@ -46,29 +47,32 @@ TEXT runtime·osyield(SB),NOSPLIT,$0 ...@@ -46,29 +47,32 @@ TEXT runtime·osyield(SB),NOSPLIT,$0
RET RET
TEXT runtime·lwp_park(SB),NOSPLIT,$0 TEXT runtime·lwp_park(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 - abstime MOVQ abstime+0(FP), DI // arg 1 - abstime
MOVL 16(SP), SI // arg 2 - unpark MOVL unpark+8(FP), SI // arg 2 - unpark
MOVQ 24(SP), DX // arg 3 - hint MOVQ hint+16(FP), DX // arg 3 - hint
MOVQ 32(SP), R10 // arg 4 - unparkhint MOVQ unparkhint+24(FP), R10 // arg 4 - unparkhint
MOVL $434, AX // sys__lwp_park MOVL $434, AX // sys__lwp_park
SYSCALL SYSCALL
MOVL AX, ret+32(FP)
RET RET
TEXT runtime·lwp_unpark(SB),NOSPLIT,$0 TEXT runtime·lwp_unpark(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 - lwp MOVL lwp+0(FP), DI // arg 1 - lwp
MOVL 16(SP), SI // arg 2 - hint MOVQ hint+8(FP), SI // arg 2 - hint
MOVL $321, AX // sys__lwp_unpark MOVL $321, AX // sys__lwp_unpark
SYSCALL SYSCALL
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·lwp_self(SB),NOSPLIT,$0 TEXT runtime·lwp_self(SB),NOSPLIT,$0
MOVL $311, AX // sys__lwp_self MOVL $311, AX // sys__lwp_self
SYSCALL SYSCALL
MOVL AX, ret+0(FP)
RET RET
// Exit the entire program (like C exit) // Exit the entire program (like C exit)
TEXT runtime·exit(SB),NOSPLIT,$-8 TEXT runtime·exit(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 - exit status MOVL code+0(FP), DI // arg 1 - exit status
MOVL $1, AX // sys_exit MOVL $1, AX // sys_exit
SYSCALL SYSCALL
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
...@@ -81,33 +85,37 @@ TEXT runtime·exit1(SB),NOSPLIT,$-8 ...@@ -81,33 +85,37 @@ TEXT runtime·exit1(SB),NOSPLIT,$-8
RET RET
TEXT runtime·open(SB),NOSPLIT,$-8 TEXT runtime·open(SB),NOSPLIT,$-8
MOVQ 8(SP), DI // arg 1 pathname MOVQ name+0(FP), DI // arg 1 pathname
MOVL 16(SP), SI // arg 2 flags MOVL mode+8(FP), SI // arg 2 flags
MOVL 20(SP), DX // arg 3 mode MOVL perm+12(FP), DX // arg 3 mode
MOVL $5, AX MOVL $5, AX
SYSCALL SYSCALL
MOVL AX, ret+16(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$-8 TEXT runtime·close(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 fd MOVL fd+0(FP), DI // arg 1 fd
MOVL $6, AX MOVL $6, AX
SYSCALL SYSCALL
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$-8 TEXT runtime·read(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 fd MOVL fd+0(FP), DI // arg 1 fd
MOVQ 16(SP), SI // arg 2 buf MOVQ p+8(FP), SI // arg 2 buf
MOVL 24(SP), DX // arg 3 count MOVL n+16(FP), DX // arg 3 count
MOVL $3, AX MOVL $3, AX
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$-8 TEXT runtime·write(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 - fd MOVQ fd+0(FP), DI // arg 1 - fd
MOVQ 16(SP), SI // arg 2 - buf MOVQ p+8(FP), SI // arg 2 - buf
MOVL 24(SP), DX // arg 3 - nbyte MOVL n+16(FP), DX // arg 3 - nbyte
MOVL $4, AX // sys_write MOVL $4, AX // sys_write
SYSCALL SYSCALL
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·usleep(SB),NOSPLIT,$16 TEXT runtime·usleep(SB),NOSPLIT,$16
...@@ -136,9 +144,9 @@ TEXT runtime·raise(SB),NOSPLIT,$16 ...@@ -136,9 +144,9 @@ TEXT runtime·raise(SB),NOSPLIT,$16
RET RET
TEXT runtime·setitimer(SB),NOSPLIT,$-8 TEXT runtime·setitimer(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 - which MOVL mode+0(FP), DI // arg 1 - which
MOVQ 16(SP), SI // arg 2 - itv MOVQ new+8(FP), SI // arg 2 - itv
MOVQ 24(SP), DX // arg 3 - oitv MOVQ old+16(FP), DX // arg 3 - oitv
MOVL $425, AX // sys_setitimer MOVL $425, AX // sys_setitimer
SYSCALL SYSCALL
RET RET
...@@ -169,10 +177,11 @@ TEXT runtime·nanotime(SB),NOSPLIT,$32 ...@@ -169,10 +177,11 @@ TEXT runtime·nanotime(SB),NOSPLIT,$32
// return nsec in AX // return nsec in AX
IMULQ $1000000000, AX IMULQ $1000000000, AX
ADDQ DX, AX ADDQ DX, AX
MOVQ AX, ret+0(FP)
RET RET
TEXT runtime·getcontext(SB),NOSPLIT,$-8 TEXT runtime·getcontext(SB),NOSPLIT,$-8
MOVQ 8(SP), DI // arg 1 - context MOVQ ctxt+0(FP), DI // arg 1 - context
MOVL $307, AX // sys_getcontext MOVL $307, AX // sys_getcontext
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
...@@ -180,9 +189,9 @@ TEXT runtime·getcontext(SB),NOSPLIT,$-8 ...@@ -180,9 +189,9 @@ TEXT runtime·getcontext(SB),NOSPLIT,$-8
RET RET
TEXT runtime·sigprocmask(SB),NOSPLIT,$0 TEXT runtime·sigprocmask(SB),NOSPLIT,$0
MOVL 8(SP), DI // arg 1 - how MOVL mode+0(FP), DI // arg 1 - how
MOVQ 16(SP), SI // arg 2 - set MOVQ new+8(FP), SI // arg 2 - set
MOVQ 24(SP), DX // arg 3 - oset MOVQ old+16(FP), DX // arg 3 - oset
MOVL $293, AX // sys_sigprocmask MOVL $293, AX // sys_sigprocmask
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
...@@ -198,9 +207,9 @@ TEXT runtime·sigreturn_tramp(SB),NOSPLIT,$-8 ...@@ -198,9 +207,9 @@ TEXT runtime·sigreturn_tramp(SB),NOSPLIT,$-8
SYSCALL SYSCALL
TEXT runtime·sigaction(SB),NOSPLIT,$-8 TEXT runtime·sigaction(SB),NOSPLIT,$-8
MOVL 8(SP), DI // arg 1 - signum MOVL sig+0(FP), DI // arg 1 - signum
MOVQ 16(SP), SI // arg 2 - nsa MOVQ new+8(FP), SI // arg 2 - nsa
MOVQ 24(SP), DX // arg 3 - osa MOVQ old+16(FP), DX // arg 3 - osa
// arg 4 - tramp // arg 4 - tramp
LEAQ runtime·sigreturn_tramp(SB), R10 LEAQ runtime·sigreturn_tramp(SB), R10
MOVQ $2, R8 // arg 5 - vers MOVQ $2, R8 // arg 5 - vers
...@@ -244,23 +253,24 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$64 ...@@ -244,23 +253,24 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$64
RET RET
TEXT runtime·mmap(SB),NOSPLIT,$0 TEXT runtime·mmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 - addr MOVQ addr+0(FP), DI // arg 1 - addr
MOVQ 16(SP), SI // arg 2 - len MOVQ n+8(FP), SI // arg 2 - len
MOVL 24(SP), DX // arg 3 - prot MOVL prot+16(FP), DX // arg 3 - prot
MOVL 28(SP), R10 // arg 4 - flags MOVL flags+20(FP), R10 // arg 4 - flags
MOVL 32(SP), R8 // arg 5 - fd MOVL fd+24(FP), R8 // arg 5 - fd
MOVQ 36(SP), R9 MOVL off+28(FP), R9
SUBQ $16, SP SUBQ $16, SP
MOVQ R9, 8(SP) // arg 7 - offset (passed on stack) MOVQ R9, 8(SP) // arg 7 - offset (passed on stack)
MOVQ $0, R9 // arg 6 - pad MOVQ $0, R9 // arg 6 - pad
MOVL $197, AX // sys_mmap MOVL $197, AX // sys_mmap
SYSCALL SYSCALL
ADDQ $16, SP ADDQ $16, SP
MOVQ AX, ret+32(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$0 TEXT runtime·munmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 - addr MOVQ addr+0(FP), DI // arg 1 - addr
MOVQ 16(SP), SI // arg 2 - len MOVQ n+8(FP), SI // arg 2 - len
MOVL $73, AX // sys_munmap MOVL $73, AX // sys_munmap
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
...@@ -270,8 +280,8 @@ TEXT runtime·munmap(SB),NOSPLIT,$0 ...@@ -270,8 +280,8 @@ TEXT runtime·munmap(SB),NOSPLIT,$0
TEXT runtime·madvise(SB),NOSPLIT,$0 TEXT runtime·madvise(SB),NOSPLIT,$0
MOVQ addr+0(FP), DI // arg 1 - addr MOVQ addr+0(FP), DI // arg 1 - addr
MOVQ len+8(FP), SI // arg 2 - len MOVQ n+8(FP), SI // arg 2 - len
MOVQ behav+16(FP), DX // arg 3 - behav MOVL flags+16(FP), DX // arg 3 - behav
MOVQ $75, AX // sys_madvise MOVQ $75, AX // sys_madvise
SYSCALL SYSCALL
// ignore failure - maybe pages are locked // ignore failure - maybe pages are locked
...@@ -297,18 +307,20 @@ TEXT runtime·settls(SB),NOSPLIT,$8 ...@@ -297,18 +307,20 @@ TEXT runtime·settls(SB),NOSPLIT,$8
RET RET
TEXT runtime·sysctl(SB),NOSPLIT,$0 TEXT runtime·sysctl(SB),NOSPLIT,$0
MOVQ 8(SP), DI // arg 1 - name MOVQ mib+0(FP), DI // arg 1 - name
MOVL 16(SP), SI // arg 2 - namelen MOVL miblen+8(FP), SI // arg 2 - namelen
MOVQ 24(SP), DX // arg 3 - oldp MOVQ out+16(FP), DX // arg 3 - oldp
MOVQ 32(SP), R10 // arg 4 - oldlenp MOVQ size+24(FP), R10 // arg 4 - oldlenp
MOVQ 40(SP), R8 // arg 5 - newp MOVQ dst+32(FP), R8 // arg 5 - newp
MOVQ 48(SP), R9 // arg 6 - newlen MOVQ ndst+40(FP), R9 // arg 6 - newlen
MOVQ $202, AX // sys___sysctl MOVQ $202, AX // sys___sysctl
SYSCALL SYSCALL
JCC 3(PC) JCC 4(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+48(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+48(FP)
RET RET
// int32 runtime·kqueue(void) // int32 runtime·kqueue(void)
...@@ -318,25 +330,27 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0 ...@@ -318,25 +330,27 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout) // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout)
TEXT runtime·kevent(SB),NOSPLIT,$0 TEXT runtime·kevent(SB),NOSPLIT,$0
MOVL 8(SP), DI MOVL fd+0(FP), DI
MOVQ 16(SP), SI MOVQ ev1+8(FP), SI
MOVL 24(SP), DX MOVL nev1+16(FP), DX
MOVQ 32(SP), R10 MOVQ ev2+24(FP), R10
MOVL 40(SP), R8 MOVL nev2+32(FP), R8
MOVQ 48(SP), R9 MOVQ ts+40(FP), R9
MOVL $435, AX MOVL $435, AX
SYSCALL SYSCALL
JCC 2(PC) JCC 2(PC)
NEGQ AX NEGQ AX
MOVL AX, ret+48(FP)
RET RET
// void runtime·closeonexec(int32 fd) // void runtime·closeonexec(int32 fd)
TEXT runtime·closeonexec(SB),NOSPLIT,$0 TEXT runtime·closeonexec(SB),NOSPLIT,$0
MOVL 8(SP), DI // fd MOVL fd+0(FP), DI // fd
MOVQ $2, SI // F_SETFD MOVQ $2, SI // F_SETFD
MOVQ $1, DX // FD_CLOEXEC MOVQ $1, DX // FD_CLOEXEC
MOVL $92, AX // fcntl MOVL $92, AX // fcntl
......
...@@ -28,11 +28,13 @@ TEXT runtime·open(SB),NOSPLIT,$-8 ...@@ -28,11 +28,13 @@ TEXT runtime·open(SB),NOSPLIT,$-8
MOVW 4(FP), R1 MOVW 4(FP), R1
MOVW 8(FP), R2 MOVW 8(FP), R2
SWI $0xa00005 SWI $0xa00005
MOVW R0, ret+12(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$-8 TEXT runtime·close(SB),NOSPLIT,$-8
MOVW 0(FP), R0 MOVW 0(FP), R0
SWI $0xa00006 SWI $0xa00006
MOVW R0, ret+4(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$-8 TEXT runtime·read(SB),NOSPLIT,$-8
...@@ -40,6 +42,7 @@ TEXT runtime·read(SB),NOSPLIT,$-8 ...@@ -40,6 +42,7 @@ TEXT runtime·read(SB),NOSPLIT,$-8
MOVW 4(FP), R1 MOVW 4(FP), R1
MOVW 8(FP), R2 MOVW 8(FP), R2
SWI $0xa00003 SWI $0xa00003
MOVW R0, ret+12(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$-4 TEXT runtime·write(SB),NOSPLIT,$-4
...@@ -47,14 +50,16 @@ TEXT runtime·write(SB),NOSPLIT,$-4 ...@@ -47,14 +50,16 @@ TEXT runtime·write(SB),NOSPLIT,$-4
MOVW 4(FP), R1 // arg 2 - buf MOVW 4(FP), R1 // arg 2 - buf
MOVW 8(FP), R2 // arg 3 - nbyte MOVW 8(FP), R2 // arg 3 - nbyte
SWI $0xa00004 // sys_write SWI $0xa00004 // sys_write
MOVW R0, ret+12(FP)
RET RET
// int32 lwp_create(void *context, uintptr flags, void *lwpid) // int32 lwp_create(void *context, uintptr flags, void *lwpid)
TEXT runtime·lwp_create(SB),NOSPLIT,$0 TEXT runtime·lwp_create(SB),NOSPLIT,$0
MOVW context+0(FP), R0 MOVW ctxt+0(FP), R0
MOVW flags+4(FP), R1 MOVW flags+4(FP), R1
MOVW lwpid+8(FP), R2 MOVW lwpid+8(FP), R2
SWI $0xa00135 // sys__lwp_create SWI $0xa00135 // sys__lwp_create
MOVW R0, ret+12(FP)
RET RET
TEXT runtime·osyield(SB),NOSPLIT,$0 TEXT runtime·osyield(SB),NOSPLIT,$0
...@@ -67,16 +72,19 @@ TEXT runtime·lwp_park(SB),NOSPLIT,$0 ...@@ -67,16 +72,19 @@ TEXT runtime·lwp_park(SB),NOSPLIT,$0
MOVW 8(FP), R2 // arg 3 - hint MOVW 8(FP), R2 // arg 3 - hint
MOVW 12(FP), R3 // arg 4 - unparkhint MOVW 12(FP), R3 // arg 4 - unparkhint
SWI $0xa001b2 // sys__lwp_park SWI $0xa001b2 // sys__lwp_park
MOVW R0, ret+16(FP)
RET RET
TEXT runtime·lwp_unpark(SB),NOSPLIT,$0 TEXT runtime·lwp_unpark(SB),NOSPLIT,$0
MOVW 0(FP), R0 // arg 1 - lwp MOVW 0(FP), R0 // arg 1 - lwp
MOVW 4(FP), R1 // arg 2 - hint MOVW 4(FP), R1 // arg 2 - hint
SWI $0xa00141 // sys__lwp_unpark SWI $0xa00141 // sys__lwp_unpark
MOVW R0, ret+8(FP)
RET RET
TEXT runtime·lwp_self(SB),NOSPLIT,$0 TEXT runtime·lwp_self(SB),NOSPLIT,$0
SWI $0xa00137 // sys__lwp_self SWI $0xa00137 // sys__lwp_self
MOVW R0, ret+0(FP)
RET RET
TEXT runtime·lwp_tramp(SB),NOSPLIT,$0 TEXT runtime·lwp_tramp(SB),NOSPLIT,$0
...@@ -153,9 +161,8 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32 ...@@ -153,9 +161,8 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32
ADD.S R2, R0 ADD.S R2, R0
ADC R4, R1 ADC R4, R1
MOVW 0(FP), R3 MOVW R0, ret_lo+0(FP)
MOVW R0, 0(R3) MOVW R1, ret_hi+4(FP)
MOVW R1, 4(R3)
RET RET
TEXT runtime·getcontext(SB),NOSPLIT,$-4 TEXT runtime·getcontext(SB),NOSPLIT,$-4
...@@ -249,6 +256,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$12 ...@@ -249,6 +256,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$12
ADD $4, R13 // pass arg 5 and arg 6 on stack ADD $4, R13 // pass arg 5 and arg 6 on stack
SWI $0xa000c5 // sys_mmap SWI $0xa000c5 // sys_mmap
SUB $4, R13 SUB $4, R13
MOVW R0, ret+24(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$0 TEXT runtime·munmap(SB),NOSPLIT,$0
...@@ -287,12 +295,14 @@ TEXT runtime·sysctl(SB),NOSPLIT,$8 ...@@ -287,12 +295,14 @@ TEXT runtime·sysctl(SB),NOSPLIT,$8
ADD $4, R13 // pass arg 5 and 6 on stack ADD $4, R13 // pass arg 5 and 6 on stack
SWI $0xa000ca // sys___sysctl SWI $0xa000ca // sys___sysctl
SUB $4, R13 SUB $4, R13
MOVW R0, ret+24(FP)
RET RET
// int32 runtime·kqueue(void) // int32 runtime·kqueue(void)
TEXT runtime·kqueue(SB),NOSPLIT,$0 TEXT runtime·kqueue(SB),NOSPLIT,$0
SWI $0xa00158 // sys_kqueue SWI $0xa00158 // sys_kqueue
RSB.CS $0, R0 RSB.CS $0, R0
MOVW R0, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout) // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout)
...@@ -309,6 +319,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$8 ...@@ -309,6 +319,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$8
SWI $0xa001b3 // sys___kevent50 SWI $0xa001b3 // sys___kevent50
RSB.CS $0, R0 RSB.CS $0, R0
SUB $4, R13 SUB $4, R13
MOVW R0, ret+24(FP)
RET RET
// void runtime·closeonexec(int32 fd) // void runtime·closeonexec(int32 fd)
......
...@@ -30,21 +30,25 @@ TEXT runtime·exit1(SB),NOSPLIT,$8 ...@@ -30,21 +30,25 @@ TEXT runtime·exit1(SB),NOSPLIT,$8
TEXT runtime·open(SB),NOSPLIT,$-4 TEXT runtime·open(SB),NOSPLIT,$-4
MOVL $5, AX MOVL $5, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$-4 TEXT runtime·close(SB),NOSPLIT,$-4
MOVL $6, AX MOVL $6, AX
INT $0x80 INT $0x80
MOVL AX, ret+4(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$-4 TEXT runtime·read(SB),NOSPLIT,$-4
MOVL $3, AX MOVL $3, AX
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$-4 TEXT runtime·write(SB),NOSPLIT,$-4
MOVL $4, AX // sys_write MOVL $4, AX // sys_write
INT $0x80 INT $0x80
MOVL AX, ret+12(FP)
RET RET
TEXT runtime·usleep(SB),NOSPLIT,$24 TEXT runtime·usleep(SB),NOSPLIT,$24
...@@ -78,7 +82,7 @@ TEXT runtime·raise(SB),NOSPLIT,$12 ...@@ -78,7 +82,7 @@ TEXT runtime·raise(SB),NOSPLIT,$12
RET RET
TEXT runtime·mmap(SB),NOSPLIT,$36 TEXT runtime·mmap(SB),NOSPLIT,$36
LEAL arg0+0(FP), SI LEAL addr+0(FP), SI
LEAL 4(SP), DI LEAL 4(SP), DI
CLD CLD
MOVSL // arg 1 - addr MOVSL // arg 1 - addr
...@@ -93,6 +97,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$36 ...@@ -93,6 +97,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$36
STOSL STOSL
MOVL $197, AX // sys_mmap MOVL $197, AX // sys_mmap
INT $0x80 INT $0x80
MOVL AX, ret+24(FP)
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$-4 TEXT runtime·munmap(SB),NOSPLIT,$-4
...@@ -151,9 +156,8 @@ TEXT runtime·nanotime(SB),NOSPLIT,$32 ...@@ -151,9 +156,8 @@ TEXT runtime·nanotime(SB),NOSPLIT,$32
ADDL BX, AX ADDL BX, AX
ADCL CX, DX // add high bits with carry ADCL CX, DX // add high bits with carry
MOVL ret+0(FP), DI MOVL AX, ret_lo+0(FP)
MOVL AX, 0(DI) MOVL DX, ret_hi+4(FP)
MOVL DX, 4(DI)
RET RET
TEXT runtime·sigaction(SB),NOSPLIT,$-4 TEXT runtime·sigaction(SB),NOSPLIT,$-4
...@@ -168,7 +172,7 @@ TEXT runtime·sigprocmask(SB),NOSPLIT,$-4 ...@@ -168,7 +172,7 @@ TEXT runtime·sigprocmask(SB),NOSPLIT,$-4
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
MOVL AX, oset+0(FP) MOVL AX, ret+8(FP)
RET RET
TEXT runtime·sigtramp(SB),NOSPLIT,$44 TEXT runtime·sigtramp(SB),NOSPLIT,$44
...@@ -222,22 +226,22 @@ sigtramp_ret: ...@@ -222,22 +226,22 @@ sigtramp_ret:
TEXT runtime·tfork(SB),NOSPLIT,$12 TEXT runtime·tfork(SB),NOSPLIT,$12
// Copy mp, gp and fn from the parent stack onto the child stack. // Copy mp, gp and fn from the parent stack onto the child stack.
MOVL params+4(FP), AX MOVL psize+4(FP), AX
MOVL 8(AX), CX // tf_stack MOVL 8(AX), CX // tf_stack
SUBL $16, CX SUBL $16, CX
MOVL CX, 8(AX) MOVL CX, 8(AX)
MOVL mm+12(FP), SI MOVL mm+8(FP), SI
MOVL SI, 0(CX) MOVL SI, 0(CX)
MOVL gg+16(FP), SI MOVL gg+12(FP), SI
MOVL SI, 4(CX) MOVL SI, 4(CX)
MOVL fn+20(FP), SI MOVL fn+16(FP), SI
MOVL SI, 8(CX) MOVL SI, 8(CX)
MOVL $1234, 12(CX) MOVL $1234, 12(CX)
MOVL $0, 0(SP) // syscall gap MOVL $0, 0(SP) // syscall gap
MOVL params+4(FP), AX MOVL param+0(FP), AX
MOVL AX, 4(SP) // arg 1 - param MOVL AX, 4(SP) // arg 1 - param
MOVL psize+8(FP), AX MOVL psize+4(FP), AX
MOVL AX, 8(SP) // arg 2 - psize MOVL AX, 8(SP) // arg 2 - psize
MOVL $8, AX // sys___tfork MOVL $8, AX // sys___tfork
INT $0x80 INT $0x80
...@@ -245,15 +249,15 @@ TEXT runtime·tfork(SB),NOSPLIT,$12 ...@@ -245,15 +249,15 @@ TEXT runtime·tfork(SB),NOSPLIT,$12
// Return if tfork syscall failed. // Return if tfork syscall failed.
JCC 5(PC) JCC 5(PC)
NEGL AX NEGL AX
MOVL ret+0(FP), DX MOVL AX, ret_lo+20(FP)
MOVL AX, 0(DX) MOVL $-1, ret_hi+24(FP)
RET RET
// In parent, return. // In parent, return.
CMPL AX, $0 CMPL AX, $0
JEQ 4(PC) JEQ 4(PC)
MOVL ret+0(FP), DX MOVL AX, ret_lo+20(FP)
MOVL AX, 0(DX) MOVL $0, ret_hi+24(FP)
RET RET
// Paranoia: check that SP is as we expect. // Paranoia: check that SP is as we expect.
...@@ -333,15 +337,17 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4 ...@@ -333,15 +337,17 @@ TEXT runtime·osyield(SB),NOSPLIT,$-4
TEXT runtime·thrsleep(SB),NOSPLIT,$-4 TEXT runtime·thrsleep(SB),NOSPLIT,$-4
MOVL $94, AX // sys___thrsleep MOVL $94, AX // sys___thrsleep
INT $0x80 INT $0x80
MOVL AX, ret+20(FP)
RET RET
TEXT runtime·thrwakeup(SB),NOSPLIT,$-4 TEXT runtime·thrwakeup(SB),NOSPLIT,$-4
MOVL $301, AX // sys___thrwakeup MOVL $301, AX // sys___thrwakeup
INT $0x80 INT $0x80
MOVL AX, ret+8(FP)
RET RET
TEXT runtime·sysctl(SB),NOSPLIT,$28 TEXT runtime·sysctl(SB),NOSPLIT,$28
LEAL arg0+0(FP), SI LEAL mib+0(FP), SI
LEAL 4(SP), DI LEAL 4(SP), DI
CLD CLD
MOVSL // arg 1 - name MOVSL // arg 1 - name
...@@ -352,10 +358,12 @@ TEXT runtime·sysctl(SB),NOSPLIT,$28 ...@@ -352,10 +358,12 @@ TEXT runtime·sysctl(SB),NOSPLIT,$28
MOVSL // arg 6 - newlen MOVSL // arg 6 - newlen
MOVL $202, AX // sys___sysctl MOVL $202, AX // sys___sysctl
INT $0x80 INT $0x80
JCC 3(PC) JCC 4(PC)
NEGL AX NEGL AX
MOVL AX, ret+24(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+24(FP)
RET RET
// int32 runtime·kqueue(void); // int32 runtime·kqueue(void);
...@@ -364,6 +372,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0 ...@@ -364,6 +372,7 @@ TEXT runtime·kqueue(SB),NOSPLIT,$0
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout); // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout);
...@@ -372,6 +381,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0 ...@@ -372,6 +381,7 @@ TEXT runtime·kevent(SB),NOSPLIT,$0
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
NEGL AX NEGL AX
MOVL AX, ret+24(FP)
RET RET
// int32 runtime·closeonexec(int32 fd); // int32 runtime·closeonexec(int32 fd);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -44,6 +44,7 @@ TEXT runtime·nanotime1(SB),NOSPLIT,$0 ...@@ -44,6 +44,7 @@ TEXT runtime·nanotime1(SB),NOSPLIT,$0
IMULQ $1000000000, AX // multiply into nanoseconds IMULQ $1000000000, AX // multiply into nanoseconds
ADDQ 8(SP), AX // tv_nsec, offset should be stable. ADDQ 8(SP), AX // tv_nsec, offset should be stable.
ADDQ $64, SP ADDQ $64, SP
MOVQ AX, ret+0(FP)
RET RET
// pipe(3c) wrapper that returns fds in AX, DX. // pipe(3c) wrapper that returns fds in AX, DX.
...@@ -137,6 +138,7 @@ TEXT runtime·tstart_sysvicall(SB),NOSPLIT,$0 ...@@ -137,6 +138,7 @@ TEXT runtime·tstart_sysvicall(SB),NOSPLIT,$0
CALL runtime·mstart(SB) CALL runtime·mstart(SB)
XORL AX, AX // return 0 == success XORL AX, AX // return 0 == success
MOVL AX, ret+8(FP)
RET RET
// Careful, this is called by __sighndlr, a libc function. We must preserve // Careful, this is called by __sighndlr, a libc function. We must preserve
...@@ -274,7 +276,7 @@ exit: ...@@ -274,7 +276,7 @@ exit:
// Called from runtime·usleep (Go). Can be called on Go stack, on OS stack, // Called from runtime·usleep (Go). Can be called on Go stack, on OS stack,
// can also be called in cgo callback path without a g->m. // can also be called in cgo callback path without a g->m.
TEXT runtime·usleep1(SB),NOSPLIT,$0 TEXT runtime·usleep1(SB),NOSPLIT,$0
MOVL us+0(FP), DI MOVL usec+0(FP), DI
MOVQ $runtime·usleep2(SB), AX // to hide from 6l MOVQ $runtime·usleep2(SB), AX // to hide from 6l
// Execute call on m->g0. // Execute call on m->g0.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment