]> Cypherpunks repositories - gostls13.git/commitdiff
gc: avoid unsafe in defn of package runtime
authorRuss Cox <rsc@golang.org>
Mon, 19 Dec 2011 20:52:15 +0000 (15:52 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 19 Dec 2011 20:52:15 +0000 (15:52 -0500)
Keeps -u tracking simple.

R=ken2
CC=golang-dev
https://golang.org/cl/5495094

src/cmd/gc/builtin.c.boot
src/cmd/gc/runtime.go
src/cmd/gc/subr.c
src/cmd/gc/walk.c

index f2c81b71e5f834e3caef3cfbfc9654871f7a1133..23d36964a909b0387c2371fc315cd0d37a536f41 100644 (file)
@@ -1,7 +1,6 @@
 char *runtimeimport =
        "package runtime\n"
        "import runtime \"runtime\"\n"
-       "import unsafe \"unsafe\"\n"
        "func @\"\".new(@\"\".typ *byte) *any\n"
        "func @\"\".panicindex()\n"
        "func @\"\".panicslice()\n"
@@ -91,12 +90,12 @@ char *runtimeimport =
        "func @\"\".sliceslice(@\"\".old []any, @\"\".lb uint64, @\"\".hb uint64, @\"\".width uint64) []any\n"
        "func @\"\".slicearray(@\"\".old *any, @\"\".nel uint64, @\"\".lb uint64, @\"\".hb uint64, @\"\".width uint64) []any\n"
        "func @\"\".closure()\n"
-       "func @\"\".memequal(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
-       "func @\"\".memequal8(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
-       "func @\"\".memequal16(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
-       "func @\"\".memequal32(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
-       "func @\"\".memequal64(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
-       "func @\"\".memequal128(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
+       "func @\"\".memequal(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
+       "func @\"\".memequal8(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
+       "func @\"\".memequal16(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
+       "func @\"\".memequal32(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
+       "func @\"\".memequal64(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
+       "func @\"\".memequal128(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
        "func @\"\".int64div(? int64, ? int64) int64\n"
        "func @\"\".uint64div(? uint64, ? uint64) uint64\n"
        "func @\"\".int64mod(? int64, ? int64) int64\n"
index b53c124981a721f80506799405040bfb4f372721..2d9e423214715961c83b931fa59e3e49f50b1908 100644 (file)
@@ -8,8 +8,6 @@
 
 package PACKAGE
 
-import "unsafe"
-
 // emitted by compiler, not referred to by go programs
 
 func new(typ *byte) *any
@@ -123,12 +121,12 @@ func slicearray(old *any, nel uint64, lb uint64, hb uint64, width uint64) (ary [
 
 func closure() // has args, but compiler fills in
 
-func memequal(eq *bool, size uintptr, x, y unsafe.Pointer)
-func memequal8(eq *bool, size uintptr, x, y unsafe.Pointer)
-func memequal16(eq *bool, size uintptr, x, y unsafe.Pointer)
-func memequal32(eq *bool, size uintptr, x, y unsafe.Pointer)
-func memequal64(eq *bool, size uintptr, x, y unsafe.Pointer)
-func memequal128(eq *bool, size uintptr, x, y unsafe.Pointer)
+func memequal(eq *bool, size uintptr, x, y *any)
+func memequal8(eq *bool, size uintptr, x, y *any)
+func memequal16(eq *bool, size uintptr, x, y *any)
+func memequal32(eq *bool, size uintptr, x, y *any)
+func memequal64(eq *bool, size uintptr, x, y *any)
+func memequal128(eq *bool, size uintptr, x, y *any)
 
 // only used on 32-bit
 func int64div(int64, int64) int64
index d95036204b5bede83f64b6052ab66717becafdab..07f97da2de073f725e34d70f199c3ff3ec99dcdf 100644 (file)
@@ -2636,20 +2636,27 @@ eqfield(Node *p, Node *q, Node *field, Node *eq)
 }
 
 static Node*
-eqmemfunc(vlong size)
+eqmemfunc(vlong size, Type *type)
 {
        char buf[30];
+       Node *fn;
 
        switch(size) {
+       default:
+               fn = syslook("memequal", 1);
+               break;
        case 1:
        case 2:
        case 4:
        case 8:
        case 16:
                snprint(buf, sizeof buf, "memequal%d", (int)size*8);
-               return syslook(buf, 0);
+               fn = syslook(buf, 1);
+               break;
        }
-       return syslook("memequal", 0);
+       argtype(fn, type);
+       argtype(fn, type);
+       return fn;
 }
 
 // Return node for
@@ -2663,12 +2670,14 @@ eqmem(Node *p, Node *q, Node *field, vlong size, Node *eq)
        nx->etype = 1;  // does not escape
        ny = nod(OADDR, nod(OXDOT, q, field), N);
        ny->etype = 1;  // does not escape
+       typecheck(&nx, Erv);
+       typecheck(&ny, Erv);
 
-       call = nod(OCALL, eqmemfunc(size), N);
+       call = nod(OCALL, eqmemfunc(size, nx->type->type), N);
        call->list = list(call->list, eq);
        call->list = list(call->list, nodintconst(size));
-       call->list = list(call->list, conv(nx, types[TUNSAFEPTR]));
-       call->list = list(call->list, conv(ny, types[TUNSAFEPTR]));
+       call->list = list(call->list, nx);
+       call->list = list(call->list, ny);
 
        nif = nod(OIF, N, N);
        nif->ninit = list(nif->ninit, call);
index f94a937b11325d76e888209c1dad169074f4825f..68bd01cda070c8eb959c544d00951a5b06424406 100644 (file)
@@ -2408,8 +2408,12 @@ eqfor(Type *t)
        if(a != AMEM && a != -1)
                fatal("eqfor %T", t);
 
-       if(a == AMEM)
-               return syslook("memequal", 0);
+       if(a == AMEM) {
+               n = syslook("memequal", 1);
+               argtype(n, t);
+               argtype(n, t);
+               return n;
+       }
 
        sym = typesymprefix(".eq", t);
        n = newname(sym);
@@ -2417,8 +2421,8 @@ eqfor(Type *t)
        ntype = nod(OTFUNC, N, N);
        ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(ptrto(types[TBOOL]))));
        ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(types[TUINTPTR])));
-       ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(types[TUNSAFEPTR])));
-       ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(types[TUNSAFEPTR])));
+       ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(ptrto(t))));
+       ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(ptrto(t))));
        typecheck(&ntype, Etype);
        n->type = ntype->type;
        return n;
@@ -2536,8 +2540,8 @@ walkcompare(Node **np, NodeList **init)
        a->etype = 1;  // does not escape
        call->list = list(call->list, a);
        call->list = list(call->list, nodintconst(t->width));
-       call->list = list(call->list, conv(l, types[TUNSAFEPTR]));
-       call->list = list(call->list, conv(r, types[TUNSAFEPTR]));
+       call->list = list(call->list, l);
+       call->list = list(call->list, r);
        typecheck(&call, Etop);
        walkstmt(&call);
        *init = list(*init, call);