summaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-09-11 13:46:58 -0700
committerKeith Randall <khr@golang.org>2014-09-11 13:46:58 -0700
commitccf42b15789beff3c355da0e1e6b71aedf1994d9 (patch)
tree05a99a7e69b9ff5ea5bd26e5fc0f382bb70f98eb /src/cmd
parent601b6c23d323ab059b6ea9d0a82d8e379ce8099e (diff)
downloadgo-ccf42b15789beff3c355da0e1e6b71aedf1994d9.tar.gz
runtime: get rid of copyable check - all G frames are copyable.
Just go ahead and do it, if something is wrong we'll throw. Also rip out cc-generated arg ptr maps, they are useless now. LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/133690045
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/cc/bv.c45
-rw-r--r--src/cmd/cc/cc.h6
-rw-r--r--src/cmd/cc/pgen.c163
3 files changed, 0 insertions, 214 deletions
diff --git a/src/cmd/cc/bv.c b/src/cmd/cc/bv.c
deleted file mode 100644
index db433de6a..000000000
--- a/src/cmd/cc/bv.c
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include <u.h>
-#include "cc.h"
-
-enum {
- WORDSIZE = sizeof(uint32),
- WORDBITS = 32,
-};
-
-uintptr
-bvsize(uintptr n)
-{
- return ((n + WORDBITS - 1) / WORDBITS) * WORDSIZE;
-}
-
-Bvec*
-bvalloc(int32 n)
-{
- Bvec *bv;
- uintptr nbytes;
-
- if(n < 0)
- fatal(Z, "bvalloc: initial size is negative\n");
- nbytes = sizeof(Bvec) + bvsize(n);
- bv = malloc(nbytes);
- if(bv == nil)
- fatal(Z, "bvalloc: malloc failed\n");
- memset(bv, 0, nbytes);
- bv->n = n;
- return bv;
-}
-
-void
-bvset(Bvec *bv, int32 i)
-{
- uint32 mask;
-
- if(i < 0 || i >= bv->n)
- fatal(Z, "bvset: index %d is out of bounds with length %d\n", i, bv->n);
- mask = 1UL << (i % WORDBITS);
- bv->b[i / WORDBITS] |= mask;
-}
diff --git a/src/cmd/cc/cc.h b/src/cmd/cc/cc.h
index 1dae5acd9..9530f5cf6 100644
--- a/src/cmd/cc/cc.h
+++ b/src/cmd/cc/cc.h
@@ -762,12 +762,6 @@ int beq(Bits, Bits);
int bset(Bits, uint);
/*
- * bv.c
- */
-Bvec* bvalloc(int32 n);
-void bvset(Bvec *bv, int32 i);
-
-/*
* dpchk.c
*/
void dpcheck(Node*);
diff --git a/src/cmd/cc/pgen.c b/src/cmd/cc/pgen.c
index 4265b1b5e..db9aae916 100644
--- a/src/cmd/cc/pgen.c
+++ b/src/cmd/cc/pgen.c
@@ -31,30 +31,6 @@
#include "gc.h"
#include "../../runtime/funcdata.h"
-enum { BitsPerPointer = 2 };
-
-static void dumpgcargs(Type *fn, Sym *sym);
-
-static Sym*
-makefuncdatasym(char *namefmt, int64 funcdatakind)
-{
- Node nod;
- Sym *sym;
- static int32 nsym;
- static char namebuf[40];
-
- snprint(namebuf, sizeof(namebuf), namefmt, nsym++);
- sym = slookup(namebuf);
- sym->class = CSTATIC;
- memset(&nod, 0, sizeof nod);
- nod.op = ONAME;
- nod.sym = sym;
- nod.class = CSTATIC;
- gins(AFUNCDATA, nodconst(funcdatakind), &nod);
- linksym(sym)->type = SRODATA;
- return sym;
-}
-
int
hasdotdotdot(Type *t)
{
@@ -109,9 +85,6 @@ codgen(Node *n, Node *nn)
{
Prog *sp;
Node *n1, nod, nod1;
- Sym *gcargs;
- Sym *gclocals;
- int isvarargs;
cursafe = 0;
curarg = 0;
@@ -135,16 +108,6 @@ codgen(Node *n, Node *nn)
sp = p;
/*
- * generate funcdata symbol for this function.
- * data is filled in at the end of codgen().
- */
- isvarargs = hasdotdotdot(thisfn);
- gcargs = nil;
- if(!isvarargs)
- gcargs = makefuncdatasym("gcargs·%d", FUNCDATA_ArgsPointerMaps);
- gclocals = makefuncdatasym("gclocals·%d", FUNCDATA_LocalsPointerMaps);
-
- /*
* isolate first argument
*/
if(REGARG >= 0) {
@@ -178,22 +141,6 @@ codgen(Node *n, Node *nn)
if(thechar=='6' || thechar=='7') /* [sic] */
maxargsafe = xround(maxargsafe, 8);
sp->to.offset += maxargsafe;
-
- if(!isvarargs)
- dumpgcargs(thisfn, gcargs);
-
- // TODO(rsc): "stkoff" is not right. It does not account for
- // the possibility of data stored in .safe variables.
- // Unfortunately those move up and down just like
- // the argument frame (and in fact dovetail with it)
- // so the number we need is not available or even
- // well-defined. Probably we need to make the safe
- // area its own section.
- // That said, we've been using stkoff for months
- // and nothing too terrible has happened.
- gextern(gclocals, nodconst(-stkoff), 0, 4); // locals
- gclocals->type = typ(0, T);
- gclocals->type->width = 4;
}
void
@@ -673,113 +620,3 @@ bcomplex(Node *n, Node *c)
boolgen(n, 1, Z);
return 0;
}
-
-// Updates the bitvector with a set bit for each pointer containing
-// value in the type description starting at offset.
-static void
-walktype1(Type *t, int32 offset, Bvec *bv, int param)
-{
- Type *t1;
- int32 o;
- int32 widthptr;
-
- widthptr = ewidth[TIND];
- switch(t->etype) {
- case TCHAR:
- case TUCHAR:
- case TSHORT:
- case TUSHORT:
- case TINT:
- case TUINT:
- case TLONG:
- case TULONG:
- case TVLONG:
- case TUVLONG:
- case TFLOAT:
- case TDOUBLE:
- // non-pointer types
- for(o = 0; o < t->width; o++)
- bvset(bv, ((offset + t->offset + o) / widthptr) * BitsPerPointer); // 1 = live scalar
- break;
-
- case TIND:
- pointer:
- // pointer types
- if((offset + t->offset) % widthptr != 0)
- yyerror("unaligned pointer");
- bvset(bv, ((offset + t->offset) / widthptr)*BitsPerPointer + 1); // 2 = live ptr
- break;
-
- case TARRAY:
- if(param) // unlike Go, C passes arrays by reference
- goto pointer;
- // array in struct or union is an actual array
- for(o = 0; o < t->width; o += t->link->width)
- walktype1(t->link, offset+o, bv, 0);
- break;
-
- case TSTRUCT:
- // build map recursively
- for(t1 = t->link; t1 != T; t1 = t1->down)
- walktype1(t1, offset, bv, 0);
- break;
-
- case TUNION:
- walktype1(t->link, offset, bv, 0);
- break;
-
- default:
- yyerror("can't handle arg type %s\n", tnames[t->etype]);
- }
-}
-
-// Compute a bit vector to describe the pointer containing locations
-// in the argument list. Adds the data to gcsym and returns the offset
-// of end of the bit vector.
-static void
-dumpgcargs(Type *fn, Sym *sym)
-{
- Bvec *bv;
- Type *t;
- int32 i;
- int32 argbytes;
- int32 symoffset, argoffset;
-
- // Dump the length of the bitmap array. This value is always one for
- // functions written in C.
- symoffset = 0;
- gextern(sym, nodconst(1), symoffset, 4);
- symoffset += 4;
- argbytes = (argsize(1) + ewidth[TIND] - 1);
- bv = bvalloc((argbytes / ewidth[TIND]) * BitsPerPointer);
- argoffset = 0;
- if(hasdotdotdot(thisfn))
- argoffset = align(0, fn->link, Aarg0, nil);
- if(argoffset > 0) {
- // The C calling convention returns structs by copying them to a
- // location pointed to by a hidden first argument. This first
- // argument is a pointer.
- if(argoffset != ewidth[TIND])
- yyerror("passbyptr arg not the right size");
- bvset(bv, 1); // 2 = live ptr
- }
- for(t = fn->down; t != T; t = t->down) {
- if(t->etype == TVOID)
- continue;
- argoffset = align(argoffset, t, Aarg1, nil);
- walktype1(t, argoffset, bv, 1);
- argoffset = align(argoffset, t, Aarg2, nil);
- }
- // Dump the length of the bitmap.
- gextern(sym, nodconst(bv->n), symoffset, 4);
- symoffset += 4;
- // Dump the words of the bitmap.
- for(i = 0; i < bv->n; i += 32) {
- gextern(sym, nodconst(bv->b[i/32]), symoffset, 4);
- symoffset += 4;
- }
- free(bv);
- // Finalize the gc symbol.
- sym->type = typ(0, T);
- sym->type->width = symoffset;
-}