Commit 87f2208b authored by Rob Pike's avatar Rob Pike

rename runtime internals to have modern names (array->slice etc)

R=rsc
DELTA=444  (179 added, 177 deleted, 88 changed)
OCL=33847
CL=33849
parent 67815ef6
...@@ -186,7 +186,9 @@ dowidth(Type *t) ...@@ -186,7 +186,9 @@ dowidth(Type *t)
case TFORW: // should have been filled in case TFORW: // should have been filled in
case TANY: case TANY:
// dummy type; should be replaced before use. // dummy type; should be replaced before use.
fatal("dowidth any"); if(!debug['A'])
fatal("dowidth any");
w = 1; // anything will do
break; break;
case TSTRING: case TSTRING:
if(sizeof_String == 0) if(sizeof_String == 0)
......
...@@ -13,7 +13,7 @@ char *sysimport = ...@@ -13,7 +13,7 @@ char *sysimport =
"func sys.printpointer (? any)\n" "func sys.printpointer (? any)\n"
"func sys.printiface (? any)\n" "func sys.printiface (? any)\n"
"func sys.printeface (? any)\n" "func sys.printeface (? any)\n"
"func sys.printarray (? any)\n" "func sys.printslice (? any)\n"
"func sys.printnl ()\n" "func sys.printnl ()\n"
"func sys.printsp ()\n" "func sys.printsp ()\n"
"func sys.catstring (? string, ? string) (? string)\n" "func sys.catstring (? string, ? string) (? string)\n"
...@@ -21,8 +21,8 @@ char *sysimport = ...@@ -21,8 +21,8 @@ char *sysimport =
"func sys.slicestring (? string, ? int, ? int) (? string)\n" "func sys.slicestring (? string, ? int, ? int) (? string)\n"
"func sys.indexstring (? string, ? int) (? uint8)\n" "func sys.indexstring (? string, ? int) (? uint8)\n"
"func sys.intstring (? int64) (? string)\n" "func sys.intstring (? int64) (? string)\n"
"func sys.arraystring (? []uint8) (? string)\n" "func sys.slicebytetostring (? []uint8) (? string)\n"
"func sys.arraystringi (? []int) (? string)\n" "func sys.sliceinttostring (? []int) (? string)\n"
"func sys.stringiter (? string, ? int) (? int)\n" "func sys.stringiter (? string, ? int) (? int)\n"
"func sys.stringiter2 (? string, ? int) (retk int, retv int)\n" "func sys.stringiter2 (? string, ? int) (retk int, retv int)\n"
"func sys.ifaceI2E (iface any) (ret any)\n" "func sys.ifaceI2E (iface any) (ret any)\n"
...@@ -41,7 +41,7 @@ char *sysimport = ...@@ -41,7 +41,7 @@ char *sysimport =
"func sys.efaceeq (i1 any, i2 any) (ret bool)\n" "func sys.efaceeq (i1 any, i2 any) (ret bool)\n"
"func sys.ifacethash (i1 any) (ret uint32)\n" "func sys.ifacethash (i1 any) (ret uint32)\n"
"func sys.efacethash (i1 any) (ret uint32)\n" "func sys.efacethash (i1 any) (ret uint32)\n"
"func sys.newmap (keysize int, valsize int, keyalg int, valalg int, hint int) (hmap map[any] any)\n" "func sys.makemap (keysize int, valsize int, keyalg int, valalg int, hint int) (hmap map[any] any)\n"
"func sys.mapaccess1 (hmap map[any] any, key any) (val any)\n" "func sys.mapaccess1 (hmap map[any] any, key any) (val any)\n"
"func sys.mapaccess2 (hmap map[any] any, key any) (val any, pres bool)\n" "func sys.mapaccess2 (hmap map[any] any, key any) (val any, pres bool)\n"
"func sys.mapassign1 (hmap map[any] any, key any, val any)\n" "func sys.mapassign1 (hmap map[any] any, key any, val any)\n"
...@@ -50,7 +50,7 @@ char *sysimport = ...@@ -50,7 +50,7 @@ char *sysimport =
"func sys.mapiternext (hiter *any)\n" "func sys.mapiternext (hiter *any)\n"
"func sys.mapiter1 (hiter *any) (key any)\n" "func sys.mapiter1 (hiter *any) (key any)\n"
"func sys.mapiter2 (hiter *any) (key any, val any)\n" "func sys.mapiter2 (hiter *any) (key any, val any)\n"
"func sys.newchan (elemsize int, elemalg int, hint int) (hchan chan any)\n" "func sys.makechan (elemsize int, elemalg int, hint int) (hchan chan any)\n"
"func sys.chanrecv1 (hchan <-chan any) (elem any)\n" "func sys.chanrecv1 (hchan <-chan any) (elem any)\n"
"func sys.chanrecv2 (hchan <-chan any) (elem any, pres bool)\n" "func sys.chanrecv2 (hchan <-chan any) (elem any, pres bool)\n"
"func sys.chansend1 (hchan chan<- any, elem any)\n" "func sys.chansend1 (hchan chan<- any, elem any)\n"
...@@ -62,10 +62,10 @@ char *sysimport = ...@@ -62,10 +62,10 @@ char *sysimport =
"func sys.selectrecv (sel *uint8, hchan <-chan any, elem *any) (selected bool)\n" "func sys.selectrecv (sel *uint8, hchan <-chan any, elem *any) (selected bool)\n"
"func sys.selectdefault (sel *uint8) (selected bool)\n" "func sys.selectdefault (sel *uint8) (selected bool)\n"
"func sys.selectgo (sel *uint8)\n" "func sys.selectgo (sel *uint8)\n"
"func sys.newarray (nel int, cap int, width int) (ary []any)\n" "func sys.makeslice (nel int, cap int, width int) (ary []any)\n"
"func sys.arraysliced (old []any, lb int, hb int, width int) (ary []any)\n" "func sys.sliceslice (old []any, lb int, hb int, width int) (ary []any)\n"
"func sys.arrayslices (old *any, nel int, lb int, hb int, width int) (ary []any)\n" "func sys.slicearray (old *any, nel int, lb int, hb int, width int) (ary []any)\n"
"func sys.arrays2d (old *any, nel int) (ary []any)\n" "func sys.arraytoslice (old *any, nel int) (ary []any)\n"
"func sys.closure ()\n" "func sys.closure ()\n"
"func sys.int64div (? int64, ? int64) (? int64)\n" "func sys.int64div (? int64, ? int64) (? int64)\n"
"func sys.uint64div (? uint64, ? uint64) (? uint64)\n" "func sys.uint64div (? uint64, ? uint64) (? uint64)\n"
......
...@@ -146,8 +146,8 @@ slicerewrite(Node *n) ...@@ -146,8 +146,8 @@ slicerewrite(Node *n)
while(n->op == OCONVNOP) while(n->op == OCONVNOP)
n = n->left; n = n->left;
// call to newarray - find nel argument // call to makeslice - find nel argument
nel = findarg(n, "nel", "newarray"); nel = findarg(n, "nel", "makeslice");
if(nel == N || !isslice(n->type)) if(nel == N || !isslice(n->type))
goto no; goto no;
...@@ -177,8 +177,8 @@ maprewrite(Node *n) ...@@ -177,8 +177,8 @@ maprewrite(Node *n)
Type *ta, *tb; Type *ta, *tb;
Node *a; Node *a;
// call to newarray - find nel argument // call to makemap - find len argument
nel = findarg(n, "hint", "newmap"); nel = findarg(n, "hint", "makemap");
if(nel == N) if(nel == N)
goto no; goto no;
ta = n->type; ta = n->type;
...@@ -371,7 +371,7 @@ sli: ...@@ -371,7 +371,7 @@ sli:
if(r->op != OAS && r->op != OEMPTY) if(r->op != OAS && r->op != OEMPTY)
continue; continue;
// first usage "nam = (newarray CALL args)" // first usage "nam = (makeslice CALL args)"
if(r->right != N && sametmp(r->left, nam)) { if(r->right != N && sametmp(r->left, nam)) {
w = slicerewrite(r->right); w = slicerewrite(r->right);
if(w == N) if(w == N)
...@@ -427,7 +427,7 @@ return; ...@@ -427,7 +427,7 @@ return;
if(r->op != OAS && r->op != OEMPTY) if(r->op != OAS && r->op != OEMPTY)
continue; continue;
// first usage "nam = (newmap CALL args)" // first usage "nam = (makemap CALL args)"
if(r->right != N && sametmp(r->left, nam)) { if(r->right != N && sametmp(r->left, nam)) {
w = maprewrite(r->right); w = maprewrite(r->right);
if(w == N) if(w == N)
......
...@@ -20,7 +20,7 @@ func printstring(string); ...@@ -20,7 +20,7 @@ func printstring(string);
func printpointer(any); func printpointer(any);
func printiface(any); func printiface(any);
func printeface(any); func printeface(any);
func printarray(any); func printslice(any);
func printnl(); func printnl();
func printsp(); func printsp();
...@@ -29,8 +29,8 @@ func cmpstring(string, string) int; ...@@ -29,8 +29,8 @@ func cmpstring(string, string) int;
func slicestring(string, int, int) string; func slicestring(string, int, int) string;
func indexstring(string, int) byte; func indexstring(string, int) byte;
func intstring(int64) string; func intstring(int64) string;
func arraystring([]byte) string; func slicebytetostring([]byte) string;
func arraystringi([]int) string; func sliceinttostring([]int) string;
func stringiter(string, int) int; func stringiter(string, int) int;
func stringiter2(string, int) (retk int, retv int); func stringiter2(string, int) (retk int, retv int);
...@@ -51,7 +51,7 @@ func efaceeq(i1 any, i2 any) (ret bool); ...@@ -51,7 +51,7 @@ func efaceeq(i1 any, i2 any) (ret bool);
func ifacethash(i1 any) (ret uint32); func ifacethash(i1 any) (ret uint32);
func efacethash(i1 any) (ret uint32); func efacethash(i1 any) (ret uint32);
func newmap(keysize int, valsize int, func makemap(keysize int, valsize int,
keyalg int, valalg int, keyalg int, valalg int,
hint int) (hmap map[any]any); hint int) (hmap map[any]any);
func mapaccess1(hmap map[any]any, key any) (val any); func mapaccess1(hmap map[any]any, key any) (val any);
...@@ -63,7 +63,7 @@ func mapiternext(hiter *any); ...@@ -63,7 +63,7 @@ func mapiternext(hiter *any);
func mapiter1(hiter *any) (key any); func mapiter1(hiter *any) (key any);
func mapiter2(hiter *any) (key any, val any); func mapiter2(hiter *any) (key any, val any);
func newchan(elemsize int, elemalg int, hint int) (hchan chan any); func makechan(elemsize int, elemalg int, hint int) (hchan chan any);
func chanrecv1(hchan <-chan any) (elem any); func chanrecv1(hchan <-chan any) (elem any);
func chanrecv2(hchan <-chan any) (elem any, pres bool); func chanrecv2(hchan <-chan any) (elem any, pres bool);
func chansend1(hchan chan<- any, elem any); func chansend1(hchan chan<- any, elem any);
...@@ -77,10 +77,10 @@ func selectrecv(sel *byte, hchan <-chan any, elem *any) (selected bool); ...@@ -77,10 +77,10 @@ func selectrecv(sel *byte, hchan <-chan any, elem *any) (selected bool);
func selectdefault(sel *byte) (selected bool); func selectdefault(sel *byte) (selected bool);
func selectgo(sel *byte); func selectgo(sel *byte);
func newarray(nel int, cap int, width int) (ary []any); func makeslice(nel int, cap int, width int) (ary []any);
func arraysliced(old []any, lb int, hb int, width int) (ary []any); func sliceslice(old []any, lb int, hb int, width int) (ary []any);
func arrayslices(old *any, nel int, lb int, hb int, width int) (ary []any); func slicearray(old *any, nel int, lb int, hb int, width int) (ary []any);
func arrays2d(old *any, nel int) (ary []any); func arraytoslice(old *any, nel int) (ary []any);
func closure(); // has args, but compiler fills in func closure(); // has args, but compiler fills in
......
...@@ -773,9 +773,9 @@ walkexpr(Node **np, NodeList **init) ...@@ -773,9 +773,9 @@ walkexpr(Node **np, NodeList **init)
walkexpr(&n->right->left, init); walkexpr(&n->right->left, init);
walkexpr(&n->right->right, init); walkexpr(&n->right->right, init);
// dynamic slice // dynamic slice
// arraysliced(old []any, lb int, hb int, width int) (ary []any) // sliceslice(old []any, lb int, hb int, width int) (ary []any)
t = n->type; t = n->type;
fn = syslook("arraysliced", 1); fn = syslook("sliceslice", 1);
argtype(fn, t->type); // any-1 argtype(fn, t->type); // any-1
argtype(fn, t->type); // any-2 argtype(fn, t->type); // any-2
n = mkcall1(fn, t, init, n = mkcall1(fn, t, init,
...@@ -790,9 +790,9 @@ walkexpr(Node **np, NodeList **init) ...@@ -790,9 +790,9 @@ walkexpr(Node **np, NodeList **init)
walkexpr(&n->right->left, init); walkexpr(&n->right->left, init);
walkexpr(&n->right->right, init); walkexpr(&n->right->right, init);
// static slice // static slice
// arrayslices(old *any, nel int, lb int, hb int, width int) (ary []any) // slicearray(old *any, nel int, lb int, hb int, width int) (ary []any)
t = n->type; t = n->type;
fn = syslook("arrayslices", 1); fn = syslook("slicearray", 1);
argtype(fn, n->left->type); // any-1 argtype(fn, n->left->type); // any-1
argtype(fn, t->type); // any-2 argtype(fn, t->type); // any-2
n = mkcall1(fn, t, init, n = mkcall1(fn, t, init,
...@@ -897,7 +897,7 @@ walkexpr(Node **np, NodeList **init) ...@@ -897,7 +897,7 @@ walkexpr(Node **np, NodeList **init)
goto ret; goto ret;
case OMAKECHAN: case OMAKECHAN:
n = mkcall1(chanfn("newchan", 1, n->type), n->type, init, n = mkcall1(chanfn("makechan", 1, n->type), n->type, init,
nodintconst(n->type->type->width), nodintconst(n->type->type->width),
nodintconst(algtype(n->type->type)), nodintconst(algtype(n->type->type)),
conv(n->left, types[TINT])); conv(n->left, types[TINT]));
...@@ -906,7 +906,7 @@ walkexpr(Node **np, NodeList **init) ...@@ -906,7 +906,7 @@ walkexpr(Node **np, NodeList **init)
case OMAKEMAP: case OMAKEMAP:
t = n->type; t = n->type;
fn = syslook("newmap", 1); fn = syslook("makemap", 1);
argtype(fn, t->down); // any-1 argtype(fn, t->down); // any-1
argtype(fn, t->type); // any-2 argtype(fn, t->type); // any-2
...@@ -919,9 +919,9 @@ walkexpr(Node **np, NodeList **init) ...@@ -919,9 +919,9 @@ walkexpr(Node **np, NodeList **init)
goto ret; goto ret;
case OMAKESLICE: case OMAKESLICE:
// newarray(nel int, max int, width int) (ary []any) // makeslice(nel int, max int, width int) (ary []any)
t = n->type; t = n->type;
fn = syslook("newarray", 1); fn = syslook("makeslice", 1);
argtype(fn, t->type); // any-1 argtype(fn, t->type); // any-1
n = mkcall1(fn, n->type, nil, n = mkcall1(fn, n->type, nil,
conv(n->left, types[TINT]), conv(n->left, types[TINT]),
...@@ -935,13 +935,13 @@ walkexpr(Node **np, NodeList **init) ...@@ -935,13 +935,13 @@ walkexpr(Node **np, NodeList **init)
goto ret; goto ret;
case OARRAYBYTESTR: case OARRAYBYTESTR:
// arraystring([]byte) string; // slicebytetostring([]byte) string;
n = mkcall("arraystring", n->type, init, n->left); n = mkcall("slicebytetostring", n->type, init, n->left);
goto ret; goto ret;
case OARRAYRUNESTR: case OARRAYRUNESTR:
// arraystring([]byte) string; // sliceinttostring([]byte) string;
n = mkcall("arraystringi", n->type, init, n->left); n = mkcall("sliceinttostring", n->type, init, n->left);
goto ret; goto ret;
case OCMPIFACE: case OCMPIFACE:
...@@ -988,8 +988,8 @@ walkexpr(Node **np, NodeList **init) ...@@ -988,8 +988,8 @@ walkexpr(Node **np, NodeList **init)
goto ret; goto ret;
case OCONVSLICE: case OCONVSLICE:
// arrays2d(old *any, nel int) (ary []any) // arraytoslice(old *any, nel int) (ary []any)
fn = syslook("arrays2d", 1); fn = syslook("arraytoslice", 1);
argtype(fn, n->left->type->type); // any-1 argtype(fn, n->left->type->type); // any-1
argtype(fn, n->type->type); // any-2 argtype(fn, n->type->type); // any-2
n = mkcall1(fn, n->type, init, n->left, nodintconst(n->left->type->type->bound)); n = mkcall1(fn, n->type, init, n->left, nodintconst(n->left->type->type->bound));
...@@ -1490,7 +1490,7 @@ walkprint(Node *nn, NodeList **init) ...@@ -1490,7 +1490,7 @@ walkprint(Node *nn, NodeList **init)
on = syslook("printpointer", 1); on = syslook("printpointer", 1);
argtype(on, n->type); // any-1 argtype(on, n->type); // any-1
} else if(isslice(n->type)) { } else if(isslice(n->type)) {
on = syslook("printarray", 1); on = syslook("printslice", 1);
argtype(on, n->type); // any-1 argtype(on, n->type); // any-1
} else if(isint[et]) { } else if(isint[et]) {
if(et == TUINT64) if(et == TUINT64)
......
...@@ -35,7 +35,6 @@ OFILES_arm=\ ...@@ -35,7 +35,6 @@ OFILES_arm=\
vlrt.$O\ vlrt.$O\
OFILES=\ OFILES=\
array.$O\
asm.$O\ asm.$O\
cgocall.$O\ cgocall.$O\
chan.$O\ chan.$O\
...@@ -60,6 +59,7 @@ OFILES=\ ...@@ -60,6 +59,7 @@ OFILES=\
rt0.$O\ rt0.$O\
sema.$O\ sema.$O\
signal.$O\ signal.$O\
slice.$O\
string.$O\ string.$O\
symtab.$O\ symtab.$O\
sys.$O\ sys.$O\
......
...@@ -45,7 +45,7 @@ enum { ...@@ -45,7 +45,7 @@ enum {
Uint, Uint,
Uintptr, Uintptr,
String, String,
Array, Slice,
}; };
static struct { static struct {
...@@ -61,7 +61,7 @@ static struct { ...@@ -61,7 +61,7 @@ static struct {
"uint", 4, "uint", 4,
"uintptr", 4, "uintptr", 4,
"String", 8, "String", 8,
"Array", 12, "Slice", 12,
/* fixed size */ /* fixed size */
"float32", 4, "float32", 4,
...@@ -710,7 +710,7 @@ main(int argc, char **argv) ...@@ -710,7 +710,7 @@ main(int argc, char **argv)
if(goarch != NULL && strcmp(goarch, "amd64") == 0) { if(goarch != NULL && strcmp(goarch, "amd64") == 0) {
type_table[Uintptr].size = 8; type_table[Uintptr].size = 8;
type_table[String].size = 16; type_table[String].size = 16;
type_table[Array].size = 8+4+4; type_table[Slice].size = 8+4+4;
structround = 8; structround = 8;
} }
} }
......
...@@ -95,7 +95,7 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint) ...@@ -95,7 +95,7 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint)
if(elemalg >= nelem(algarray)) { if(elemalg >= nelem(algarray)) {
printf("chan(alg=%d)\n", elemalg); printf("chan(alg=%d)\n", elemalg);
throw("sys·newchan: unsupported elem type"); throw("sys·makechan: unsupported elem type");
} }
c = mal(sizeof(*c)); c = mal(sizeof(*c));
...@@ -124,7 +124,7 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint) ...@@ -124,7 +124,7 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint)
} }
if(debug) { if(debug) {
prints("newchan: chan="); prints("makechan: chan=");
sys·printpointer(c); sys·printpointer(c);
prints("; elemsize="); prints("; elemsize=");
sys·printint(elemsize); sys·printint(elemsize);
...@@ -138,9 +138,9 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint) ...@@ -138,9 +138,9 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint)
return c; return c;
} }
// newchan(elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any); // makechan(elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any);
void void
sys·newchan(uint32 elemsize, uint32 elemalg, uint32 hint, Hchan *ret) sys·makechan(uint32 elemsize, uint32 elemalg, uint32 hint, Hchan *ret)
{ {
ret = makechan(elemsize, elemalg, hint); ret = makechan(elemsize, elemalg, hint);
FLUSH(&ret); FLUSH(&ret);
......
...@@ -664,7 +664,7 @@ donothing(uint32 s, void *a, void *b) ...@@ -664,7 +664,7 @@ donothing(uint32 s, void *a, void *b)
static int32 debug = 0; static int32 debug = 0;
// newmap(keysize uint32, valsize uint32, // makemap(keysize uint32, valsize uint32,
// keyalg uint32, valalg uint32, // keyalg uint32, valalg uint32,
// hint uint32) (hmap *map[any]any); // hint uint32) (hmap *map[any]any);
Hmap* Hmap*
...@@ -675,12 +675,12 @@ makemap(uint32 keysize, uint32 valsize, ...@@ -675,12 +675,12 @@ makemap(uint32 keysize, uint32 valsize,
if(keyalg >= nelem(algarray) || algarray[keyalg].hash == nohash) { if(keyalg >= nelem(algarray) || algarray[keyalg].hash == nohash) {
printf("map(keyalg=%d)\n", keyalg); printf("map(keyalg=%d)\n", keyalg);
throw("sys·newmap: unsupported map key type"); throw("sys·makemap: unsupported map key type");
} }
if(valalg >= nelem(algarray)) { if(valalg >= nelem(algarray)) {
printf("map(valalg=%d)\n", valalg); printf("map(valalg=%d)\n", valalg);
throw("sys·newmap: unsupported map value type"); throw("sys·makemap: unsupported map value type");
} }
h = mal(sizeof(*h)); h = mal(sizeof(*h));
...@@ -720,18 +720,18 @@ makemap(uint32 keysize, uint32 valsize, ...@@ -720,18 +720,18 @@ makemap(uint32 keysize, uint32 valsize,
h->po2 = rnd(h->vo2+valsize, 1); h->po2 = rnd(h->vo2+valsize, 1);
if(debug) { if(debug) {
printf("newmap: map=%p; keysize=%d; valsize=%d; keyalg=%d; valalg=%d; offsets=%d,%d; %d,%d,%d; %d,%d,%d\n", printf("makemap: map=%p; keysize=%d; valsize=%d; keyalg=%d; valalg=%d; offsets=%d,%d; %d,%d,%d; %d,%d,%d\n",
h, keysize, valsize, keyalg, valalg, h->ko0, h->vo0, h->ko1, h->vo1, h->po1, h->ko2, h->vo2, h->po2); h, keysize, valsize, keyalg, valalg, h->ko0, h->vo0, h->ko1, h->vo1, h->po1, h->ko2, h->vo2, h->po2);
} }
return h; return h;
} }
// newmap(keysize uint32, valsize uint32, // makemap(keysize uint32, valsize uint32,
// keyalg uint32, valalg uint32, // keyalg uint32, valalg uint32,
// hint uint32) (hmap *map[any]any); // hint uint32) (hmap *map[any]any);
void void
sys·newmap(uint32 keysize, uint32 valsize, sys·makemap(uint32 keysize, uint32 valsize,
uint32 keyalg, uint32 valalg, uint32 hint, uint32 keyalg, uint32 valalg, uint32 hint,
Hmap *ret) Hmap *ret)
{ {
......
...@@ -45,7 +45,7 @@ itab(InterfaceType *inter, Type *type, int32 canfail) ...@@ -45,7 +45,7 @@ itab(InterfaceType *inter, Type *type, int32 canfail)
Itab *m; Itab *m;
UncommonType *x; UncommonType *x;
if(inter->mhdr.nel == 0) if(inter->mhdr.len == 0)
throw("internal error - misuse of itab"); throw("internal error - misuse of itab");
// easy case // easy case
...@@ -90,7 +90,7 @@ itab(InterfaceType *inter, Type *type, int32 canfail) ...@@ -90,7 +90,7 @@ itab(InterfaceType *inter, Type *type, int32 canfail)
} }
} }
ni = inter->mhdr.nel; ni = inter->mhdr.len;
m = malloc(sizeof(*m) + ni*sizeof m->fun[0]); m = malloc(sizeof(*m) + ni*sizeof m->fun[0]);
m->inter = inter; m->inter = inter;
m->type = type; m->type = type;
...@@ -100,9 +100,9 @@ search: ...@@ -100,9 +100,9 @@ search:
// so can iterate over both in lock step; // so can iterate over both in lock step;
// the loop is O(ni+nt) not O(ni*nt). // the loop is O(ni+nt) not O(ni*nt).
i = inter->m; i = inter->m;
ei = i + inter->mhdr.nel; ei = i + inter->mhdr.len;
t = x->m; t = x->m;
et = t + x->mhdr.nel; et = t + x->mhdr.len;
for(; i < ei; i++) { for(; i < ei; i++) {
ihash = i->hash; ihash = i->hash;
iname = i->name; iname = i->name;
......
...@@ -87,7 +87,7 @@ func setiface(typ *byte, x *byte, ret *byte) { ...@@ -87,7 +87,7 @@ func setiface(typ *byte, x *byte, ret *byte) {
InterfaceType *t; InterfaceType *t;
t = (InterfaceType*)gettype(typ); t = (InterfaceType*)gettype(typ);
if(t->mhdr.nel == 0) { if(t->mhdr.len == 0) {
// already an empty interface // already an empty interface
*(Eface*)ret = *(Eface*)x; *(Eface*)ret = *(Eface*)x;
return; return;
......
...@@ -142,8 +142,8 @@ rnd(uint32 n, uint32 m) ...@@ -142,8 +142,8 @@ rnd(uint32 n, uint32 m)
static int32 argc; static int32 argc;
static uint8** argv; static uint8** argv;
Array os·Args; Slice os·Args;
Array os·Envs; Slice os·Envs;
void void
args(int32 c, uint8 **v) args(int32 c, uint8 **v)
...@@ -168,13 +168,13 @@ goargs(void) ...@@ -168,13 +168,13 @@ goargs(void)
for(i=0; i<argc; i++) for(i=0; i<argc; i++)
gargv[i] = gostring(argv[i]); gargv[i] = gostring(argv[i]);
os·Args.array = (byte*)gargv; os·Args.array = (byte*)gargv;
os·Args.nel = argc; os·Args.len = argc;
os·Args.cap = argc; os·Args.cap = argc;
for(i=0; i<envc; i++) for(i=0; i<envc; i++)
genvv[i] = gostring(argv[argc+1+i]); genvv[i] = gostring(argv[argc+1+i]);
os·Envs.array = (byte*)genvv; os·Envs.array = (byte*)genvv;
os·Envs.nel = envc; os·Envs.len = envc;
os·Envs.cap = envc; os·Envs.cap = envc;
} }
...@@ -189,7 +189,7 @@ getenv(int8 *s) ...@@ -189,7 +189,7 @@ getenv(int8 *s)
bs = (byte*)s; bs = (byte*)s;
len = findnull(bs); len = findnull(bs);
envv = (String*)os·Envs.array; envv = (String*)os·Envs.array;
envc = os·Envs.nel; envc = os·Envs.len;
for(i=0; i<envc; i++){ for(i=0; i<envc; i++){
if(envv[i].len <= len) if(envv[i].len <= len)
continue; continue;
......
...@@ -42,7 +42,6 @@ typedef uint32 uintptr; ...@@ -42,7 +42,6 @@ typedef uint32 uintptr;
typedef uint8 bool; typedef uint8 bool;
typedef uint8 byte; typedef uint8 byte;
typedef struct Alg Alg; typedef struct Alg Alg;
typedef struct Array Array;
typedef struct Func Func; typedef struct Func Func;
typedef struct G G; typedef struct G G;
typedef struct Gobuf Gobuf; typedef struct Gobuf Gobuf;
...@@ -50,6 +49,7 @@ typedef struct Lock Lock; ...@@ -50,6 +49,7 @@ typedef struct Lock Lock;
typedef struct M M; typedef struct M M;
typedef struct Mem Mem; typedef struct Mem Mem;
typedef union Note Note; typedef union Note Note;
typedef struct Slice Slice;
typedef struct Stktop Stktop; typedef struct Stktop Stktop;
typedef struct String String; typedef struct String String;
typedef struct Usema Usema; typedef struct Usema Usema;
...@@ -140,10 +140,10 @@ struct Eface ...@@ -140,10 +140,10 @@ struct Eface
void* data; void* data;
}; };
struct Array struct Slice
{ // must not move anything { // must not move anything
byte* array; // actual data byte* array; // actual data
uint32 nel; // number of elements uint32 len; // number of elements
uint32 cap; // allocated number of elements uint32 cap; // allocated number of elements
}; };
struct Gobuf struct Gobuf
...@@ -252,7 +252,7 @@ struct Func ...@@ -252,7 +252,7 @@ struct Func
String src; // src file name String src; // src file name
uint64 entry; // entry pc uint64 entry; // entry pc
int64 frame; // stack frame size int64 frame; // stack frame size
Array pcln; // pc/ln tab for this func Slice pcln; // pc/ln tab for this func
int64 pc0; // starting pc, ln for table int64 pc0; // starting pc, ln for table
int32 ln0; int32 ln0;
int32 args; // number of 32-bit in/out args int32 args; // number of 32-bit in/out args
...@@ -426,7 +426,7 @@ void notewakeup(Note*); ...@@ -426,7 +426,7 @@ void notewakeup(Note*);
#define sys_memclr sys·memclr #define sys_memclr sys·memclr
#define sys_getcallerpc sys·getcallerpc #define sys_getcallerpc sys·getcallerpc
#define sys_mmap sys·mmap #define sys_mmap sys·mmap
#define sys_printarray sys·printarray #define sys_printslice sys·printslice
#define sys_printbool sys·printbool #define sys_printbool sys·printbool
#define sys_printfloat sys·printfloat #define sys_printfloat sys·printfloat
#define sys_printhex sys·printhex #define sys_printhex sys·printhex
...@@ -461,7 +461,7 @@ void sys_printpc(void*); ...@@ -461,7 +461,7 @@ void sys_printpc(void*);
void sys_printpointer(void*); void sys_printpointer(void*);
void sys_printuint(uint64); void sys_printuint(uint64);
void sys_printhex(uint64); void sys_printhex(uint64);
void sys_printarray(Array); void sys_printslice(Slice);
/* /*
* wrapped for go users * wrapped for go users
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
static int32 debug = 0; static int32 debug = 0;
// newarray(nel int, cap int, width int) (ary []any); // makeslice(nel int, cap int, width int) (ary []any);
void void
sys·newarray(uint32 nel, uint32 cap, uint32 width, Array ret) sys·makeslice(uint32 nel, uint32 cap, uint32 width, Slice ret)
{ {
uint64 size; uint64 size;
...@@ -16,21 +16,21 @@ sys·newarray(uint32 nel, uint32 cap, uint32 width, Array ret) ...@@ -16,21 +16,21 @@ sys·newarray(uint32 nel, uint32 cap, uint32 width, Array ret)
cap = nel; cap = nel;
size = cap*width; size = cap*width;
ret.nel = nel; ret.len = nel;
ret.cap = cap; ret.cap = cap;
ret.array = mal(size); ret.array = mal(size);
FLUSH(&ret); FLUSH(&ret);
if(debug) { if(debug) {
prints("newarray: nel="); prints("makeslice: nel=");
sys·printint(nel); sys·printint(nel);
prints("; cap="); prints("; cap=");
sys·printint(cap); sys·printint(cap);
prints("; width="); prints("; width=");
sys·printint(width); sys·printint(width);
prints("; ret="); prints("; ret=");
sys·printarray(ret); sys·printslice(ret);
prints("\n"); prints("\n");
} }
} }
...@@ -48,15 +48,15 @@ throwslice(uint32 lb, uint32 hb, uint32 n) ...@@ -48,15 +48,15 @@ throwslice(uint32 lb, uint32 hb, uint32 n)
throw("array slice"); throw("array slice");
} }
// arraysliced(old []any, lb int, hb int, width int) (ary []any); // sliceslice(old []any, lb int, hb int, width int) (ary []any);
void void
sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret) sys·sliceslice(Slice old, uint32 lb, uint32 hb, uint32 width, Slice ret)
{ {
if(hb > old.cap || lb > hb) { if(hb > old.cap || lb > hb) {
if(debug) { if(debug) {
prints("sys·arraysliced: old="); prints("sys·sliceslice: old=");
sys·printarray(old); sys·printslice(old);
prints("; lb="); prints("; lb=");
sys·printint(lb); sys·printint(lb);
prints("; hb="); prints("; hb=");
...@@ -66,7 +66,7 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret) ...@@ -66,7 +66,7 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
prints("\n"); prints("\n");
prints("oldarray: nel="); prints("oldarray: nel=");
sys·printint(old.nel); sys·printint(old.len);
prints("; cap="); prints("; cap=");
sys·printint(old.cap); sys·printint(old.cap);
prints("\n"); prints("\n");
...@@ -75,15 +75,15 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret) ...@@ -75,15 +75,15 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
} }
// new array is inside old array // new array is inside old array
ret.nel = hb-lb; ret.len = hb-lb;
ret.cap = old.cap - lb; ret.cap = old.cap - lb;
ret.array = old.array + lb*width; ret.array = old.array + lb*width;
FLUSH(&ret); FLUSH(&ret);
if(debug) { if(debug) {
prints("sys·arraysliced: old="); prints("sys·sliceslice: old=");
sys·printarray(old); sys·printslice(old);
prints("; lb="); prints("; lb=");
sys·printint(lb); sys·printint(lb);
prints("; hb="); prints("; hb=");
...@@ -91,19 +91,19 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret) ...@@ -91,19 +91,19 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
prints("; width="); prints("; width=");
sys·printint(width); sys·printint(width);
prints("; ret="); prints("; ret=");
sys·printarray(ret); sys·printslice(ret);
prints("\n"); prints("\n");
} }
} }
// arrayslices(old *any, nel int, lb int, hb int, width int) (ary []any); // slicearray(old *any, nel int, lb int, hb int, width int) (ary []any);
void void
sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Array ret) sys·slicearray(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Slice ret)
{ {
if(hb > nel || lb > hb) { if(hb > nel || lb > hb) {
if(debug) { if(debug) {
prints("sys·arrayslices: old="); prints("sys·slicearray: old=");
sys·printpointer(old); sys·printpointer(old);
prints("; nel="); prints("; nel=");
sys·printint(nel); sys·printint(nel);
...@@ -119,14 +119,14 @@ sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Arra ...@@ -119,14 +119,14 @@ sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Arra
} }
// new array is inside old array // new array is inside old array
ret.nel = hb-lb; ret.len = hb-lb;
ret.cap = nel-lb; ret.cap = nel-lb;
ret.array = old + lb*width; ret.array = old + lb*width;
FLUSH(&ret); FLUSH(&ret);
if(debug) { if(debug) {
prints("sys·arrayslices: old="); prints("sys·slicearray: old=");
sys·printpointer(old); sys·printpointer(old);
prints("; nel="); prints("; nel=");
sys·printint(nel); sys·printint(nel);
...@@ -137,37 +137,37 @@ sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Arra ...@@ -137,37 +137,37 @@ sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Arra
prints("; width="); prints("; width=");
sys·printint(width); sys·printint(width);
prints("; ret="); prints("; ret=");
sys·printarray(ret); sys·printslice(ret);
prints("\n"); prints("\n");
} }
} }
// arrays2d(old *any, nel int) (ary []any) // arraytoslice(old *any, nel int) (ary []any)
void void
sys·arrays2d(byte* old, uint32 nel, Array ret) sys·arraytoslice(byte* old, uint32 nel, Slice ret)
{ {
// new dope to old array // new dope to old array
ret.nel = nel; ret.len = nel;
ret.cap = nel; ret.cap = nel;
ret.array = old; ret.array = old;
FLUSH(&ret); FLUSH(&ret);
if(debug) { if(debug) {
prints("sys·arrays2d: old="); prints("sys·slicearrayp: old=");
sys·printpointer(old); sys·printpointer(old);
prints("; ret="); prints("; ret=");
sys·printarray(ret); sys·printslice(ret);
prints("\n"); prints("\n");
} }
} }
void void
sys·printarray(Array a) sys·printslice(Slice a)
{ {
prints("["); prints("[");
sys·printint(a.nel); sys·printint(a.len);
prints("/"); prints("/");
sys·printint(a.cap); sys·printint(a.cap);
prints("]"); prints("]");
......
...@@ -157,26 +157,26 @@ func intstring(v int64) (s String) { ...@@ -157,26 +157,26 @@ func intstring(v int64) (s String) {
s.len = runetochar(s.str, v); s.len = runetochar(s.str, v);
} }
func arraystring(b Array) (s String) { func slicebytetostring(b Slice) (s String) {
s = gostringsize(b.nel); s = gostringsize(b.len);
mcpy(s.str, b.array, s.len); mcpy(s.str, b.array, s.len);
} }
func arraystringi(b Array) (s String) { func sliceinttostring(b Slice) (s String) {
int32 siz1, siz2, i; int32 siz1, siz2, i;
int32 *a; int32 *a;
byte dum[8]; byte dum[8];
a = (int32*)b.array; a = (int32*)b.array;
siz1 = 0; siz1 = 0;
for(i=0; i<b.nel; i++) { for(i=0; i<b.len; i++) {
siz1 += runetochar(dum, a[i]); siz1 += runetochar(dum, a[i]);
} }
s = gostringsize(siz1+4); s = gostringsize(siz1+4);
siz2 = 0; siz2 = 0;
for(i=0; i<b.nel; i++) { for(i=0; i<b.len; i++) {
// check for race // check for race
if(siz2 >= siz1) if(siz2 >= siz1)
break; break;
......
...@@ -27,23 +27,23 @@ ...@@ -27,23 +27,23 @@
// Return a pointer to a byte array containing the symbol table segment. // Return a pointer to a byte array containing the symbol table segment.
void void
sys·symdat(Array *symtab, Array *pclntab) sys·symdat(Slice *symtab, Slice *pclntab)
{ {
Array *a; Slice *a;
int32 *v; int32 *v;
v = SYMCOUNTS; v = SYMCOUNTS;
a = mal(sizeof *a); a = mal(sizeof *a);
a->nel = v[0]; a->len = v[0];
a->cap = a->nel; a->cap = a->len;
a->array = SYMDATA; a->array = SYMDATA;
symtab = a; symtab = a;
FLUSH(&symtab); FLUSH(&symtab);
a = mal(sizeof *a); a = mal(sizeof *a);
a->nel = v[1]; a->len = v[1];
a->cap = a->nel; a->cap = a->len;
a->array = SYMDATA + v[0]; a->array = SYMDATA + v[0];
pclntab = a; pclntab = a;
FLUSH(&pclntab); FLUSH(&pclntab);
...@@ -274,8 +274,8 @@ splitpcln(void) ...@@ -274,8 +274,8 @@ splitpcln(void)
line = 0; line = 0;
for(; p < ep; p++) { for(; p < ep; p++) {
if(f < ef && pc > (f+1)->entry) { if(f < ef && pc > (f+1)->entry) {
f->pcln.nel = p - f->pcln.array; f->pcln.len = p - f->pcln.array;
f->pcln.cap = f->pcln.nel; f->pcln.cap = f->pcln.len;
f++; f++;
f->pcln.array = p; f->pcln.array = p;
f->pc0 = pc; f->pc0 = pc;
...@@ -295,8 +295,8 @@ splitpcln(void) ...@@ -295,8 +295,8 @@ splitpcln(void)
pc += PcQuant; pc += PcQuant;
} }
if(f < ef) { if(f < ef) {
f->pcln.nel = p - f->pcln.array; f->pcln.len = p - f->pcln.array;
f->pcln.cap = f->pcln.nel; f->pcln.cap = f->pcln.len;
} }
} }
...@@ -311,7 +311,7 @@ funcline(Func *f, uint64 targetpc) ...@@ -311,7 +311,7 @@ funcline(Func *f, uint64 targetpc)
int32 line; int32 line;
p = f->pcln.array; p = f->pcln.array;
ep = p + f->pcln.nel; ep = p + f->pcln.len;
pc = f->pc0; pc = f->pc0;
line = f->ln0; line = f->ln0;
for(; p < ep && pc <= targetpc; p++) { for(; p < ep && pc <= targetpc; p++) {
......
...@@ -39,7 +39,7 @@ struct UncommonType ...@@ -39,7 +39,7 @@ struct UncommonType
{ {
String *name; String *name;
String *pkgPath; String *pkgPath;
Array mhdr; Slice mhdr;
Method m[]; Method m[];
}; };
...@@ -62,7 +62,7 @@ struct IMethod ...@@ -62,7 +62,7 @@ struct IMethod
struct InterfaceType struct InterfaceType
{ {
Type; Type;
Array mhdr; Slice mhdr;
IMethod m[]; IMethod m[];
}; };
......
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