aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2017-01-14 00:05:42 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-01-14 00:05:42 +0000
commitc2047754c300b68c05d65faa8dc2925fe67b71b4 (patch)
treee183ae81a1f48a02945cb6de463a70c5be1b06f6 /libgo/runtime
parent829afb8f05602bb31c9c597b24df7377fed4f059 (diff)
downloadgcc-c2047754c300b68c05d65faa8dc2925fe67b71b4.zip
gcc-c2047754c300b68c05d65faa8dc2925fe67b71b4.tar.gz
gcc-c2047754c300b68c05d65faa8dc2925fe67b71b4.tar.bz2
libgo: update to Go 1.8 release candidate 1
Compiler changes: * Change map assignment to use mapassign and assign value directly. * Change string iteration to use decoderune, faster for ASCII strings. * Change makeslice to take int, and use makeslice64 for larger values. * Add new noverflow field to hmap struct used for maps. Unresolved problems, to be fixed later: * Commented out test in go/types/sizes_test.go that doesn't compile. * Commented out reflect.TestStructOf test for padding after zero-sized field. Reviewed-on: https://go-review.googlesource.com/35231 gotools/: Updates for Go 1.8rc1. * Makefile.am (go_cmd_go_files): Add bug.go. (s-zdefaultcc): Write defaultPkgConfig. * Makefile.in: Rebuild. From-SVN: r244456
Diffstat (limited to 'libgo/runtime')
-rw-r--r--libgo/runtime/go-construct-map.c11
-rw-r--r--libgo/runtime/go-fieldtrack.c12
-rw-r--r--libgo/runtime/go-memclr.c6
-rw-r--r--libgo/runtime/malloc.goc2
-rw-r--r--libgo/runtime/mcache.c2
-rw-r--r--libgo/runtime/mgc0.c35
-rw-r--r--libgo/runtime/parfor.c2
-rw-r--r--libgo/runtime/proc.c60
-rw-r--r--libgo/runtime/runtime.h8
-rw-r--r--libgo/runtime/runtime_c.c6
10 files changed, 63 insertions, 81 deletions
diff --git a/libgo/runtime/go-construct-map.c b/libgo/runtime/go-construct-map.c
index c1a8bb7..9a48d57 100644
--- a/libgo/runtime/go-construct-map.c
+++ b/libgo/runtime/go-construct-map.c
@@ -9,14 +9,15 @@
#include <stdlib.h>
#include "runtime.h"
+#include "go-type.h"
extern void *makemap (const struct __go_map_type *, int64_t hint,
void *, void *)
__asm__ (GOSYM_PREFIX "runtime.makemap");
-extern void mapassign1 (const struct __go_map_type *, void *hmap,
- const void *key, const void *val)
- __asm__ (GOSYM_PREFIX "runtime.mapassign1");
+extern void *mapassign (const struct __go_map_type *, void *hmap,
+ const void *key)
+ __asm__ (GOSYM_PREFIX "runtime.mapassign");
void *
__go_construct_map (const struct __go_map_type *type,
@@ -26,13 +27,15 @@ __go_construct_map (const struct __go_map_type *type,
void *ret;
const unsigned char *entries;
uintptr_t i;
+ void *p;
ret = makemap(type, (int64_t) count, NULL, NULL);
entries = (const unsigned char *) ventries;
for (i = 0; i < count; ++i)
{
- mapassign1 (type, ret, entries, entries + val_offset);
+ p = mapassign (type, ret, entries);
+ typedmemmove (type->__val_type, p, entries + val_offset);
entries += entry_size;
}
diff --git a/libgo/runtime/go-fieldtrack.c b/libgo/runtime/go-fieldtrack.c
index 2b3ac32..c4f27ef 100644
--- a/libgo/runtime/go-fieldtrack.c
+++ b/libgo/runtime/go-fieldtrack.c
@@ -33,9 +33,9 @@ extern const char _edata[] __attribute__ ((weak));
extern const char __edata[] __attribute__ ((weak));
extern const char __bss_start[] __attribute__ ((weak));
-extern void mapassign1 (const struct __go_map_type *, void *hmap,
- const void *key, const void *val)
- __asm__ (GOSYM_PREFIX "runtime.mapassign1");
+extern void *mapassign (const struct __go_map_type *, void *hmap,
+ const void *key)
+ __asm__ (GOSYM_PREFIX "runtime.mapassign");
// The type descriptor for map[string] bool. */
extern const char __go_td_MN6_string__N4_bool[] __attribute__ ((weak));
@@ -95,12 +95,12 @@ runtime_Fieldtrack (void *m)
if (__builtin_memchr (q1, '\0', q2 - q1) == NULL)
{
String s;
- _Bool b;
+ void *p;
s.str = (const byte *) q1;
s.len = q2 - q1;
- b = 1;
- mapassign1((const void*) __go_td_MN6_string__N4_bool, m, &s, &b);
+ p = mapassign((const void*) __go_td_MN6_string__N4_bool, m, &s);
+ *(_Bool*)p = 1;
}
p = q2;
diff --git a/libgo/runtime/go-memclr.c b/libgo/runtime/go-memclr.c
index de6f39a..e478b65 100644
--- a/libgo/runtime/go-memclr.c
+++ b/libgo/runtime/go-memclr.c
@@ -6,11 +6,11 @@
#include "runtime.h"
-void memclr(void *, uintptr)
- __asm__ (GOSYM_PREFIX "runtime.memclr");
+void memclrNoHeapPointers(void *, uintptr)
+ __asm__ (GOSYM_PREFIX "runtime.memclrNoHeapPointers");
void
-memclr (void *p1, uintptr len)
+memclrNoHeapPointers (void *p1, uintptr len)
{
__builtin_memset (p1, 0, len);
}
diff --git a/libgo/runtime/malloc.goc b/libgo/runtime/malloc.goc
index 9874312..232210f 100644
--- a/libgo/runtime/malloc.goc
+++ b/libgo/runtime/malloc.goc
@@ -296,7 +296,7 @@ runtime_profilealloc(void *v, uintptr size)
// If you change this, also change allocmcache.
if(rate > 0x3fffffff) // make 2*rate not overflow
rate = 0x3fffffff;
- next = runtime_fastrand1() % (2*rate);
+ next = runtime_fastrand() % (2*rate);
// Subtract the "remainder" of the current allocation.
// Otherwise objects that are close in size to sampling rate
// will be under-sampled, because we consistently discard this remainder.
diff --git a/libgo/runtime/mcache.c b/libgo/runtime/mcache.c
index 4396271..46684bc 100644
--- a/libgo/runtime/mcache.c
+++ b/libgo/runtime/mcache.c
@@ -35,7 +35,7 @@ runtime_allocmcache(void)
if(rate > 0x3fffffff) // make 2*rate not overflow
rate = 0x3fffffff;
if(rate != 0)
- c->next_sample = runtime_fastrand1() % (2*rate);
+ c->next_sample = runtime_fastrand() % (2*rate);
return c;
}
diff --git a/libgo/runtime/mgc0.c b/libgo/runtime/mgc0.c
index 1fc86dc..fc54241 100644
--- a/libgo/runtime/mgc0.c
+++ b/libgo/runtime/mgc0.c
@@ -2730,38 +2730,3 @@ runtime_MHeap_MapBits(MHeap *h)
runtime_SysMap(h->arena_start - n, n - h->bitmap_mapped, h->arena_reserved, &mstats()->gc_sys);
h->bitmap_mapped = n;
}
-
-// typedmemmove copies a value of type t to dst from src.
-
-extern void typedmemmove(const Type* td, void *dst, const void *src)
- __asm__ (GOSYM_PREFIX "reflect.typedmemmove");
-
-void
-typedmemmove(const Type* td, void *dst, const void *src)
-{
- runtime_memmove(dst, src, td->__size);
-}
-
-// typedslicecopy copies a slice of elemType values from src to dst,
-// returning the number of elements copied.
-
-extern intgo typedslicecopy(const Type* elem, Slice dst, Slice src)
- __asm__ (GOSYM_PREFIX "reflect.typedslicecopy");
-
-intgo
-typedslicecopy(const Type* elem, Slice dst, Slice src)
-{
- intgo n;
- void *dstp;
- void *srcp;
-
- n = dst.__count;
- if (n > src.__count)
- n = src.__count;
- if (n == 0)
- return 0;
- dstp = dst.__values;
- srcp = src.__values;
- memmove(dstp, srcp, (uintptr_t)n * elem->__size);
- return n;
-}
diff --git a/libgo/runtime/parfor.c b/libgo/runtime/parfor.c
index c2f10b9..b49826f 100644
--- a/libgo/runtime/parfor.c
+++ b/libgo/runtime/parfor.c
@@ -126,7 +126,7 @@ runtime_parfordo(ParFor *desc)
goto exit;
}
// Choose a random victim for stealing.
- victim = runtime_fastrand1() % (desc->nthr-1);
+ victim = runtime_fastrand() % (desc->nthr-1);
if(victim >= tid)
victim++;
victimpos = &desc->thr[victim].pos;
diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c
index 90ff352..0ed7ebe 100644
--- a/libgo/runtime/proc.c
+++ b/libgo/runtime/proc.c
@@ -253,6 +253,7 @@ kickoff(void)
fn = (void (*)(void*))(g->entry);
param = g->param;
+ g->entry = nil;
g->param = nil;
fn(param);
runtime_goexit1();
@@ -391,6 +392,8 @@ static bool exitsyscallfast(void);
extern void setncpu(int32)
__asm__(GOSYM_PREFIX "runtime.setncpu");
+extern void setpagesize(uintptr_t)
+ __asm__(GOSYM_PREFIX "runtime.setpagesize");
extern void allgadd(G*)
__asm__(GOSYM_PREFIX "runtime.allgadd");
extern void mcommoninit(M*)
@@ -456,6 +459,7 @@ runtime_schedinit(void)
Eface i;
setncpu(runtime_ncpu);
+ setpagesize(getpagesize());
runtime_sched = runtime_getsched();
m = &runtime_m0;
@@ -646,15 +650,17 @@ void*
runtime_mstart(void* mp)
{
M *m;
+ G *gp;
m = (M*)mp;
g = m->g0;
g->m = m;
+ gp = g;
initcontext();
- g->entry = nil;
- g->param = nil;
+ gp->entry = nil;
+ gp->param = nil;
// Record top of stack for use by mcall.
// Once we call schedule we're never coming back,
@@ -662,19 +668,24 @@ runtime_mstart(void* mp)
#ifdef USING_SPLIT_STACK
__splitstack_getcontext(&g->stackcontext[0]);
#else
- g->gcinitialsp = &mp;
+ gp->gcinitialsp = &mp;
// Setting gcstacksize to 0 is a marker meaning that gcinitialsp
// is the top of the stack, not the bottom.
- g->gcstacksize = 0;
- g->gcnextsp = &mp;
+ gp->gcstacksize = 0;
+ gp->gcnextsp = &mp;
#endif
- getcontext(ucontext_arg(&g->context[0]));
+ getcontext(ucontext_arg(&gp->context[0]));
+
+ if(gp->traceback != nil)
+ gtraceback(gp);
- if(g->entry != nil) {
+ if(gp->entry != nil) {
// Got here from mcall.
- void (*pfn)(G*) = (void (*)(G*))g->entry;
- G* gp = (G*)g->param;
- pfn(gp);
+ void (*pfn)(G*) = (void (*)(G*))gp->entry;
+ G* gp1 = (G*)gp->param;
+ gp->entry = nil;
+ gp->param = nil;
+ pfn(gp1);
*(int*)0x21 = 0x21;
}
runtime_minit();
@@ -767,27 +778,31 @@ void
setGContext()
{
int val;
+ G *gp;
initcontext();
- g->entry = nil;
- g->param = nil;
+ gp = g;
+ gp->entry = nil;
+ gp->param = nil;
#ifdef USING_SPLIT_STACK
- __splitstack_getcontext(&g->stackcontext[0]);
+ __splitstack_getcontext(&gp->stackcontext[0]);
val = 0;
__splitstack_block_signals(&val, nil);
#else
- g->gcinitialsp = &val;
- g->gcstack = nil;
- g->gcstacksize = 0;
- g->gcnextsp = &val;
+ gp->gcinitialsp = &val;
+ gp->gcstack = nil;
+ gp->gcstacksize = 0;
+ gp->gcnextsp = &val;
#endif
- getcontext(ucontext_arg(&g->context[0]));
+ getcontext(ucontext_arg(&gp->context[0]));
- if(g->entry != nil) {
+ if(gp->entry != nil) {
// Got here from mcall.
- void (*pfn)(G*) = (void (*)(G*))g->entry;
- G* gp = (G*)g->param;
- pfn(gp);
+ void (*pfn)(G*) = (void (*)(G*))gp->entry;
+ G* gp1 = (G*)gp->param;
+ gp->entry = nil;
+ gp->param = nil;
+ pfn(gp1);
*(int*)0x22 = 0x22;
}
}
@@ -1392,6 +1407,7 @@ __go_go(void (*fn)(void*), void* arg)
runtime_throw("bad spsize in __go_go");
newg->gcnextsp = sp;
#endif
+ newg->traceback = nil;
} else {
uintptr malsize;
diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h
index 57d2b96..5fd1155 100644
--- a/libgo/runtime/runtime.h
+++ b/libgo/runtime/runtime.h
@@ -314,7 +314,7 @@ void runtime_mallocinit(void);
void runtime_mprofinit(void);
#define runtime_getcallersp(p) __builtin_frame_address(0)
void runtime_mcall(void(*)(G*));
-uint32 runtime_fastrand1(void) __asm__ (GOSYM_PREFIX "runtime.fastrand1");
+uint32 runtime_fastrand(void) __asm__ (GOSYM_PREFIX "runtime.fastrand");
int32 runtime_timediv(int64, int32, int32*)
__asm__ (GOSYM_PREFIX "runtime.timediv");
int32 runtime_round2(int32 x); // round x up to a power of 2.
@@ -506,10 +506,6 @@ void runtime_newErrorCString(const char*, Eface*)
/*
* wrapped for go users
*/
-void runtime_semacquire(uint32 volatile *, bool)
- __asm__ (GOSYM_PREFIX "runtime.semacquire");
-void runtime_semrelease(uint32 volatile *)
- __asm__ (GOSYM_PREFIX "runtime.semrelease");
void runtime_procyield(uint32)
__asm__(GOSYM_PREFIX "runtime.procyield");
void runtime_osyield(void)
@@ -596,3 +592,5 @@ extern void makeMainInitDone(void)
__asm__ (GOSYM_PREFIX "runtime.makeMainInitDone");
extern void closeMainInitDone(void)
__asm__ (GOSYM_PREFIX "runtime.closeMainInitDone");
+extern void typedmemmove(const Type *, void *, const void *)
+ __asm__ (GOSYM_PREFIX "runtime.typedmemmove");
diff --git a/libgo/runtime/runtime_c.c b/libgo/runtime/runtime_c.c
index 1358804..9883e0a 100644
--- a/libgo/runtime/runtime_c.c
+++ b/libgo/runtime/runtime_c.c
@@ -58,7 +58,7 @@ runtime_atoi(const byte *p, intgo len)
}
uint32
-runtime_fastrand1(void)
+runtime_fastrand(void)
{
M *m;
uint32 x;
@@ -88,9 +88,9 @@ runtime_cputicks(void)
asm volatile(".insn s,0xb27c0000,%0" /* stckf */ : "+Q" (clock) : : "cc" );
return (int64)clock;
#else
- // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand1().
+ // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- // TODO: need more entropy to better seed fastrand1.
+ // TODO: need more entropy to better seed fastrand.
return runtime_nanotime();
#endif
}