]> Cypherpunks repositories - gostls13.git/commitdiff
gc: pass FlagNoPointers to runtime.new
authorDmitriy Vyukov <dvyukov@google.com>
Thu, 13 Oct 2011 08:06:55 +0000 (11:06 +0300)
committerDmitriy Vyukov <dvyukov@google.com>
Thu, 13 Oct 2011 08:06:55 +0000 (11:06 +0300)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5151043

src/cmd/gc/builtin.c.boot
src/cmd/gc/runtime.go
src/cmd/gc/walk.c
src/pkg/runtime/malloc.goc

index fdfe3dce9a4cf5cdaf00fc7bc789736b87cd77f1..745791eb03f9851b4d6bf1073b01ed6b7332aab7 100644 (file)
@@ -1,7 +1,7 @@
 char *runtimeimport =
        "package runtime\n"
        "import runtime \"runtime\"\n"
-       "func @\"\".new (? int32) *any\n"
+       "func @\"\".new (typ *uint8) *any\n"
        "func @\"\".panicindex ()\n"
        "func @\"\".panicslice ()\n"
        "func @\"\".throwreturn ()\n"
index 2461af2fc147c9dc6e51d69925450f1ac26356a2..d45542b7293dd2d9d0fa14a434fd190a253154e0 100644 (file)
@@ -10,7 +10,7 @@ package PACKAGE
 
 // emitted by compiler, not referred to by go programs
 
-func new(int32) *any
+func new(typ *byte) *any
 func panicindex()
 func panicslice()
 func throwreturn()
index f551e3dbc0979720e066503845f1618934c74ad6..8dec4956bc777c9ae1c096f58f2a735a0d83a21f 100644 (file)
@@ -1686,7 +1686,7 @@ callnew(Type *t)
        dowidth(t);
        fn = syslook("new", 1);
        argtype(fn, t);
-       return mkcall1(fn, ptrto(t), nil, nodintconst(t->width));
+       return mkcall1(fn, ptrto(t), nil, typename(t));
 }
 
 static Node*
index a22b0e737d7c7840a95f58f0850e23a2b394f8a0..b7991d03a565b0927689a52c03bcd1f31d7f02f1 100644 (file)
@@ -393,8 +393,10 @@ runtime·mal(uintptr n)
        return runtime·mallocgc(n, 0, 1, 1);
 }
 
-func new(n uint32) (ret *uint8) {
-       ret = runtime·mal(n);
+func new(typ *Type) (ret *uint8) {
+       uint32 flag = typ->kind&KindNoPointers ? FlagNoPointers : 0;
+       ret = runtime·mallocgc(typ->size, flag, 1, 1);
+       FLUSH(&ret);
 }
 
 void*