rename runtime internals to have modern names (array->slice etc) R=rsc DELTA=444 (179 added, 177 deleted, 88 changed) OCL=33847 CL=33849
diff --git a/src/pkg/runtime/Makefile b/src/pkg/runtime/Makefile index 7356bd7..efd3f37 100644 --- a/src/pkg/runtime/Makefile +++ b/src/pkg/runtime/Makefile
@@ -35,7 +35,6 @@ vlrt.$O\ OFILES=\ - array.$O\ asm.$O\ cgocall.$O\ chan.$O\ @@ -60,6 +59,7 @@ rt0.$O\ sema.$O\ signal.$O\ + slice.$O\ string.$O\ symtab.$O\ sys.$O\
diff --git a/src/pkg/runtime/cgo2c.c b/src/pkg/runtime/cgo2c.c index e6c7634..3b452b7 100644 --- a/src/pkg/runtime/cgo2c.c +++ b/src/pkg/runtime/cgo2c.c
@@ -45,7 +45,7 @@ Uint, Uintptr, String, - Array, + Slice, }; static struct { @@ -61,7 +61,7 @@ "uint", 4, "uintptr", 4, "String", 8, - "Array", 12, + "Slice", 12, /* fixed size */ "float32", 4, @@ -710,7 +710,7 @@ if(goarch != NULL && strcmp(goarch, "amd64") == 0) { type_table[Uintptr].size = 8; type_table[String].size = 16; - type_table[Array].size = 8+4+4; + type_table[Slice].size = 8+4+4; structround = 8; } }
diff --git a/src/pkg/runtime/chan.c b/src/pkg/runtime/chan.c index c72ea1d..ceebebf 100644 --- a/src/pkg/runtime/chan.c +++ b/src/pkg/runtime/chan.c
@@ -95,7 +95,7 @@ if(elemalg >= nelem(algarray)) { printf("chan(alg=%d)\n", elemalg); - throw("sys·newchan: unsupported elem type"); + throw("sys·makechan: unsupported elem type"); } c = mal(sizeof(*c)); @@ -124,7 +124,7 @@ } if(debug) { - prints("newchan: chan="); + prints("makechan: chan="); sys·printpointer(c); prints("; elemsize="); sys·printint(elemsize); @@ -138,9 +138,9 @@ return c; } -// newchan(elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any); +// makechan(elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any); 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); FLUSH(&ret);
diff --git a/src/pkg/runtime/hashmap.c b/src/pkg/runtime/hashmap.c index 91be384..8c642d9 100644 --- a/src/pkg/runtime/hashmap.c +++ b/src/pkg/runtime/hashmap.c
@@ -664,7 +664,7 @@ static int32 debug = 0; -// newmap(keysize uint32, valsize uint32, +// makemap(keysize uint32, valsize uint32, // keyalg uint32, valalg uint32, // hint uint32) (hmap *map[any]any); Hmap* @@ -675,12 +675,12 @@ if(keyalg >= nelem(algarray) || algarray[keyalg].hash == nohash) { printf("map(keyalg=%d)\n", keyalg); - throw("sys·newmap: unsupported map key type"); + throw("sys·makemap: unsupported map key type"); } if(valalg >= nelem(algarray)) { printf("map(valalg=%d)\n", valalg); - throw("sys·newmap: unsupported map value type"); + throw("sys·makemap: unsupported map value type"); } h = mal(sizeof(*h)); @@ -720,18 +720,18 @@ h->po2 = rnd(h->vo2+valsize, 1); 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); } return h; } -// newmap(keysize uint32, valsize uint32, +// makemap(keysize uint32, valsize uint32, // keyalg uint32, valalg uint32, // hint uint32) (hmap *map[any]any); void -sys·newmap(uint32 keysize, uint32 valsize, +sys·makemap(uint32 keysize, uint32 valsize, uint32 keyalg, uint32 valalg, uint32 hint, Hmap *ret) {
diff --git a/src/pkg/runtime/iface.c b/src/pkg/runtime/iface.c index 63093ad..6bd2f93 100644 --- a/src/pkg/runtime/iface.c +++ b/src/pkg/runtime/iface.c
@@ -45,7 +45,7 @@ Itab *m; UncommonType *x; - if(inter->mhdr.nel == 0) + if(inter->mhdr.len == 0) throw("internal error - misuse of itab"); // easy case @@ -90,7 +90,7 @@ } } - ni = inter->mhdr.nel; + ni = inter->mhdr.len; m = malloc(sizeof(*m) + ni*sizeof m->fun[0]); m->inter = inter; m->type = type; @@ -100,9 +100,9 @@ // so can iterate over both in lock step; // the loop is O(ni+nt) not O(ni*nt). i = inter->m; - ei = i + inter->mhdr.nel; + ei = i + inter->mhdr.len; t = x->m; - et = t + x->mhdr.nel; + et = t + x->mhdr.len; for(; i < ei; i++) { ihash = i->hash; iname = i->name;
diff --git a/src/pkg/runtime/reflect.cgo b/src/pkg/runtime/reflect.cgo index af74662..016b9e9 100644 --- a/src/pkg/runtime/reflect.cgo +++ b/src/pkg/runtime/reflect.cgo
@@ -87,7 +87,7 @@ InterfaceType *t; t = (InterfaceType*)gettype(typ); - if(t->mhdr.nel == 0) { + if(t->mhdr.len == 0) { // already an empty interface *(Eface*)ret = *(Eface*)x; return;
diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c index c5ba3e6..50a94ec 100644 --- a/src/pkg/runtime/runtime.c +++ b/src/pkg/runtime/runtime.c
@@ -142,8 +142,8 @@ static int32 argc; static uint8** argv; -Array os·Args; -Array os·Envs; +Slice os·Args; +Slice os·Envs; void args(int32 c, uint8 **v) @@ -168,13 +168,13 @@ for(i=0; i<argc; i++) gargv[i] = gostring(argv[i]); os·Args.array = (byte*)gargv; - os·Args.nel = argc; + os·Args.len = argc; os·Args.cap = argc; for(i=0; i<envc; i++) genvv[i] = gostring(argv[argc+1+i]); os·Envs.array = (byte*)genvv; - os·Envs.nel = envc; + os·Envs.len = envc; os·Envs.cap = envc; } @@ -189,7 +189,7 @@ bs = (byte*)s; len = findnull(bs); envv = (String*)os·Envs.array; - envc = os·Envs.nel; + envc = os·Envs.len; for(i=0; i<envc; i++){ if(envv[i].len <= len) continue;
diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h index 48c98f2..c346c69 100644 --- a/src/pkg/runtime/runtime.h +++ b/src/pkg/runtime/runtime.h
@@ -42,7 +42,6 @@ typedef uint8 bool; typedef uint8 byte; typedef struct Alg Alg; -typedef struct Array Array; typedef struct Func Func; typedef struct G G; typedef struct Gobuf Gobuf; @@ -50,6 +49,7 @@ typedef struct M M; typedef struct Mem Mem; typedef union Note Note; +typedef struct Slice Slice; typedef struct Stktop Stktop; typedef struct String String; typedef struct Usema Usema; @@ -140,10 +140,10 @@ void* data; }; -struct Array +struct Slice { // must not move anything byte* array; // actual data - uint32 nel; // number of elements + uint32 len; // number of elements uint32 cap; // allocated number of elements }; struct Gobuf @@ -252,7 +252,7 @@ String src; // src file name uint64 entry; // entry pc 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 int32 ln0; int32 args; // number of 32-bit in/out args @@ -426,7 +426,7 @@ #define sys_memclr sys·memclr #define sys_getcallerpc sys·getcallerpc #define sys_mmap sys·mmap -#define sys_printarray sys·printarray +#define sys_printslice sys·printslice #define sys_printbool sys·printbool #define sys_printfloat sys·printfloat #define sys_printhex sys·printhex @@ -461,7 +461,7 @@ void sys_printpointer(void*); void sys_printuint(uint64); void sys_printhex(uint64); -void sys_printarray(Array); +void sys_printslice(Slice); /* * wrapped for go users
diff --git a/src/pkg/runtime/array.c b/src/pkg/runtime/slice.c similarity index 69% rename from src/pkg/runtime/array.c rename to src/pkg/runtime/slice.c index bbd57b03..d7a5a06 100644 --- a/src/pkg/runtime/array.c +++ b/src/pkg/runtime/slice.c
@@ -6,9 +6,9 @@ static int32 debug = 0; -// newarray(nel int, cap int, width int) (ary []any); +// makeslice(nel int, cap int, width int) (ary []any); void -sys·newarray(uint32 nel, uint32 cap, uint32 width, Array ret) +sys·makeslice(uint32 nel, uint32 cap, uint32 width, Slice ret) { uint64 size; @@ -16,21 +16,21 @@ cap = nel; size = cap*width; - ret.nel = nel; + ret.len = nel; ret.cap = cap; ret.array = mal(size); FLUSH(&ret); if(debug) { - prints("newarray: nel="); + prints("makeslice: nel="); sys·printint(nel); prints("; cap="); sys·printint(cap); prints("; width="); sys·printint(width); prints("; ret="); - sys·printarray(ret); + sys·printslice(ret); prints("\n"); } } @@ -48,15 +48,15 @@ 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 -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(debug) { - prints("sys·arraysliced: old="); - sys·printarray(old); + prints("sys·sliceslice: old="); + sys·printslice(old); prints("; lb="); sys·printint(lb); prints("; hb="); @@ -66,7 +66,7 @@ prints("\n"); prints("oldarray: nel="); - sys·printint(old.nel); + sys·printint(old.len); prints("; cap="); sys·printint(old.cap); prints("\n"); @@ -75,15 +75,15 @@ } // new array is inside old array - ret.nel = hb-lb; + ret.len = hb-lb; ret.cap = old.cap - lb; ret.array = old.array + lb*width; FLUSH(&ret); if(debug) { - prints("sys·arraysliced: old="); - sys·printarray(old); + prints("sys·sliceslice: old="); + sys·printslice(old); prints("; lb="); sys·printint(lb); prints("; hb="); @@ -91,19 +91,19 @@ prints("; width="); sys·printint(width); prints("; ret="); - sys·printarray(ret); + sys·printslice(ret); 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 -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(debug) { - prints("sys·arrayslices: old="); + prints("sys·slicearray: old="); sys·printpointer(old); prints("; nel="); sys·printint(nel); @@ -119,14 +119,14 @@ } // new array is inside old array - ret.nel = hb-lb; + ret.len = hb-lb; ret.cap = nel-lb; ret.array = old + lb*width; FLUSH(&ret); if(debug) { - prints("sys·arrayslices: old="); + prints("sys·slicearray: old="); sys·printpointer(old); prints("; nel="); sys·printint(nel); @@ -137,37 +137,37 @@ prints("; width="); sys·printint(width); prints("; ret="); - sys·printarray(ret); + sys·printslice(ret); prints("\n"); } } -// arrays2d(old *any, nel int) (ary []any) +// arraytoslice(old *any, nel int) (ary []any) void -sys·arrays2d(byte* old, uint32 nel, Array ret) +sys·arraytoslice(byte* old, uint32 nel, Slice ret) { // new dope to old array - ret.nel = nel; + ret.len = nel; ret.cap = nel; ret.array = old; FLUSH(&ret); if(debug) { - prints("sys·arrays2d: old="); + prints("sys·slicearrayp: old="); sys·printpointer(old); prints("; ret="); - sys·printarray(ret); + sys·printslice(ret); prints("\n"); } } void -sys·printarray(Array a) +sys·printslice(Slice a) { prints("["); - sys·printint(a.nel); + sys·printint(a.len); prints("/"); sys·printint(a.cap); prints("]");
diff --git a/src/pkg/runtime/string.cgo b/src/pkg/runtime/string.cgo index c91a750..3134cbb 100644 --- a/src/pkg/runtime/string.cgo +++ b/src/pkg/runtime/string.cgo
@@ -157,26 +157,26 @@ s.len = runetochar(s.str, v); } -func arraystring(b Array) (s String) { - s = gostringsize(b.nel); +func slicebytetostring(b Slice) (s String) { + s = gostringsize(b.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 *a; byte dum[8]; a = (int32*)b.array; siz1 = 0; - for(i=0; i<b.nel; i++) { + for(i=0; i<b.len; i++) { siz1 += runetochar(dum, a[i]); } s = gostringsize(siz1+4); siz2 = 0; - for(i=0; i<b.nel; i++) { + for(i=0; i<b.len; i++) { // check for race if(siz2 >= siz1) break;
diff --git a/src/pkg/runtime/symtab.c b/src/pkg/runtime/symtab.c index a03c165..9750162 100644 --- a/src/pkg/runtime/symtab.c +++ b/src/pkg/runtime/symtab.c
@@ -27,23 +27,23 @@ // Return a pointer to a byte array containing the symbol table segment. void -sys·symdat(Array *symtab, Array *pclntab) +sys·symdat(Slice *symtab, Slice *pclntab) { - Array *a; + Slice *a; int32 *v; v = SYMCOUNTS; a = mal(sizeof *a); - a->nel = v[0]; - a->cap = a->nel; + a->len = v[0]; + a->cap = a->len; a->array = SYMDATA; symtab = a; FLUSH(&symtab); a = mal(sizeof *a); - a->nel = v[1]; - a->cap = a->nel; + a->len = v[1]; + a->cap = a->len; a->array = SYMDATA + v[0]; pclntab = a; FLUSH(&pclntab); @@ -274,8 +274,8 @@ line = 0; for(; p < ep; p++) { if(f < ef && pc > (f+1)->entry) { - f->pcln.nel = p - f->pcln.array; - f->pcln.cap = f->pcln.nel; + f->pcln.len = p - f->pcln.array; + f->pcln.cap = f->pcln.len; f++; f->pcln.array = p; f->pc0 = pc; @@ -295,8 +295,8 @@ pc += PcQuant; } if(f < ef) { - f->pcln.nel = p - f->pcln.array; - f->pcln.cap = f->pcln.nel; + f->pcln.len = p - f->pcln.array; + f->pcln.cap = f->pcln.len; } } @@ -311,7 +311,7 @@ int32 line; p = f->pcln.array; - ep = p + f->pcln.nel; + ep = p + f->pcln.len; pc = f->pc0; line = f->ln0; for(; p < ep && pc <= targetpc; p++) {
diff --git a/src/pkg/runtime/type.h b/src/pkg/runtime/type.h index 10d0068..86e31ba 100644 --- a/src/pkg/runtime/type.h +++ b/src/pkg/runtime/type.h
@@ -39,7 +39,7 @@ { String *name; String *pkgPath; - Array mhdr; + Slice mhdr; Method m[]; }; @@ -62,7 +62,7 @@ struct InterfaceType { Type; - Array mhdr; + Slice mhdr; IMethod m[]; };