From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6188 invoked from network); 12 Sep 2022 03:01:24 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 12 Sep 2022 03:01:24 -0000 Received: from mimir.eigenstate.org ([206.124.132.107]) by 9front; Sun Sep 11 22:59:51 -0400 2022 Received: from abbatoir.myfiosgateway.com (pool-74-108-56-137.nycmny.fios.verizon.net [74.108.56.137]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id b61815df (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9front@9front.org>; Sun, 11 Sep 2022 19:59:39 -0700 (PDT) Message-ID: <6AA8ABF35C2E1C92459083EDB2C920A9@eigenstate.org> To: 9front@9front.org Date: Sun, 11 Sep 2022 22:59:38 -0400 From: ori@eigenstate.org MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: proven mobile deep-learning TOR replication metadata full-stack-oriented controller Subject: [9front] draft: kill rathole ("non-interruptible temporary") Reply-To: 9front@9front.org Precedence: bulk Currently, kencc generates temporaries into a global rathole, rahter than putting them onto the stack; this means that any code with a 'non-interruptible temporary' not thread or note safe. this code takes a first pass at removing it from kencc, using 'regsalloc' to store them on the stack. There's no attempt at reuse, so there may be room for improvement, but given that we don't use so many temporaries this way, it seems acceptable to just leave them on the stack until the function exits. this has only been tested lightly, and hasn't built more than a few dozen lines of test code, so it's nowhere near ready to commit; it's just presented for comment. any thoughts on the approach? anything obvious I missed? diff f305820f8891305ad73afa67ed2585b69d4054d8 uncommitted --- a/6c/cgen.c +++ b/6c/cgen.c @@ -1016,17 +1016,14 @@ break; case ODOT: - sugen(l, nodrat, l->type->width); + regsalloc(&nod, l); + sugen(l, &nod, l->type->width); if(nn == Z) break; - warn(n, "non-interruptable temporary"); - nod = *nodrat; if(!r || r->op != OCONST) { diag(n, "DOT and no offset"); break; } - nod.xoffset += (long)r->vconst; - nod.type = n->type; cgen(&nod, nn); break; @@ -1409,9 +1406,6 @@ prtree(nn, "sugen lhs"); prtree(n, "sugen"); } - if(nn == nodrat) - if(w > nrathole) - nrathole = w; switch(n->op) { case OIND: if(nn == Z) { @@ -1427,18 +1421,15 @@ case ODOT: l = n->left; - sugen(l, nodrat, l->type->width); + regsalloc(&nod1, l); + sugen(l, &nod1, l->type->width); if(nn == Z) break; - warn(n, "non-interruptable temporary"); - nod1 = *nodrat; r = n->right; if(!r || r->op != OCONST) { diag(n, "DOT and no offset"); break; } - nod1.xoffset += (long)r->vconst; - nod1.type = n->type; sugen(&nod1, nn, w); break; @@ -1524,15 +1515,17 @@ break; } - sugen(n->right, nodrat, w); + regsalloc(&nod0, n->right); + sugen(n->right, &nod0, w); warn(n, "non-interruptable temporary"); - sugen(nodrat, n->left, w); - sugen(nodrat, nn, w); + sugen(&nod0, n->left, w); + sugen(&nod0, nn, w); break; case OFUNC: if(nn == Z) { - sugen(n, nodrat, w); + regsalloc(&nod0, n); + sugen(n, &nod0, w); break; } if(nn->op != OIND) { --- a/6c/gc.h +++ b/6c/gc.h @@ -144,10 +144,8 @@ EXTERN Prog* lastp; EXTERN long maxargsafe; EXTERN int mnstring; -EXTERN Node* nodrat; EXTERN Node* nodret; EXTERN Node* nodsafe; -EXTERN long nrathole; EXTERN long nstring; EXTERN Prog* p; EXTERN long pc; @@ -154,7 +152,6 @@ EXTERN Node lregnode; EXTERN Node qregnode; EXTERN char string[NSNAME]; -EXTERN Sym* symrathole; EXTERN Node znode; EXTERN Prog zprog; EXTERN int reg[D_NONE]; --- a/6c/swt.c +++ b/6c/swt.c @@ -350,7 +350,7 @@ char *n; ulong sig; - if(debug['T'] && t == D_EXTERN && s->sig != SIGDONE && s->type != types[TENUM] && s != symrathole){ + if(debug['T'] && t == D_EXTERN && s->sig != SIGDONE){ sig = sign(s); Bputc(b, ASIGNAME); Bputc(b, ASIGNAME>>8); --- a/6c/test.c +++ b/6c/test.c @@ -1,17 +1,22 @@ #include #include +typedef struct S S; + +struct S{ + int x; + int y; +}; + +S +fn(void) +{ + static int ncall; + return (S){1, ncall++}; +} + void main(void) { - uvlong a; - vlong b; - - a = 0xFFFFFFFF80000000; - b = 0xFFFFFFFF; - - - print("%ullX %llX, %ullX %ullX\n", a, b, (uvlong)0xffffffff); - exits(nil); + print("x: %d, y0:%d y1:%d y2: %d\n", fn().x, fn().y, fn().y, fn().y); } - --- a/6c/txt.c +++ b/6c/txt.c @@ -6,7 +6,6 @@ ginit(void) { int i; - Type *t; thechar = '6'; thestring = "amd64"; @@ -15,7 +14,6 @@ listinit(); nstring = 0; mnstring = 0; - nrathole = 0; pc = 0; breakpc = -1; continpc = -1; @@ -72,19 +70,6 @@ nodsafe->class = CAUTO; complex(nodsafe); - t = typ(TARRAY, types[TCHAR]); - symrathole = slookup(".rathole"); - symrathole->class = CGLOBL; - symrathole->type = t; - - nodrat = new(ONAME, Z, Z); - nodrat->sym = symrathole; - nodrat->type = types[TIND]; - nodrat->etype = TVOID; - nodrat->class = CGLOBL; - complex(nodrat); - nodrat->type = t; - nodret = new(ONAME, Z, Z); nodret->sym = slookup(".ret"); nodret->type = types[TIND]; @@ -126,7 +111,6 @@ while(mnstring) outstring("", 1L); symstring->type->width = nstring; - symrathole->type->width = nrathole; for(i=0; ilink) { if(s->type == T)