mirror of
https://github.com/golang/go
synced 2024-11-25 08:07:57 -07:00
gc: avoid unsafe in defn of package runtime
Keeps -u tracking simple. R=ken2 CC=golang-dev https://golang.org/cl/5495094
This commit is contained in:
parent
55889409f8
commit
1d0f93b4be
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user