* libgo patch committed: Remove race detector calls
@ 2014-12-23 20:40 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2014-12-23 20:40 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 462 bytes --]
The gc Go compiler supports a race detector, and some of the support
for that has been copied into libgo. It is useless there because
gccgo does not support a race detector, and the calls are normally
optimized away. However, this does not occur when the library is
built without optimization. This patch by Chris Manghane removes the
useless race calls from libgo. Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu. Committed to mainline.
Ian
[-- Attachment #2: foo.txt --]
[-- Type: text/plain, Size: 9939 bytes --]
diff -r 6cbef7b5f57b libgo/runtime/chan.goc
--- a/libgo/runtime/chan.goc Tue Dec 23 10:38:47 2014 -0800
+++ b/libgo/runtime/chan.goc Tue Dec 23 12:30:58 2014 -0800
@@ -6,7 +6,6 @@
#include "runtime.h"
#include "arch.h"
#include "go-type.h"
-#include "race.h"
#include "malloc.h"
#include "chan.h"
@@ -15,7 +14,6 @@
static void dequeueg(WaitQ*);
static SudoG* dequeue(WaitQ*);
static void enqueue(WaitQ*, SudoG*);
-static void racesync(Hchan*, SudoG*);
static Hchan*
makechan(ChanType *t, int64 hint)
@@ -82,6 +80,7 @@
static bool
chansend(ChanType *t, Hchan *c, byte *ep, bool block, void *pc)
{
+ USED(pc);
SudoG *sg;
SudoG mysg;
G* gp;
@@ -90,9 +89,6 @@
g = runtime_g();
- if(raceenabled)
- runtime_racereadobjectpc(ep, t->__element_type, runtime_getcallerpc(&t), chansend);
-
if(c == nil) {
USED(t);
if(!block)
@@ -116,8 +112,6 @@
}
runtime_lock(c);
- if(raceenabled)
- runtime_racereadpc(c, pc, chansend);
if(c->closed)
goto closed;
@@ -126,8 +120,6 @@
sg = dequeue(&c->recvq);
if(sg != nil) {
- if(raceenabled)
- racesync(c, sg);
runtime_unlock(c);
gp = sg->g;
@@ -183,11 +175,6 @@
goto asynch;
}
- if(raceenabled) {
- runtime_raceacquire(chanbuf(c, c->sendx));
- runtime_racerelease(chanbuf(c, c->sendx));
- }
-
runtime_memmove(chanbuf(c, c->sendx), ep, c->elemsize);
if(++c->sendx == c->dataqsiz)
c->sendx = 0;
@@ -225,8 +212,6 @@
if(runtime_gcwaiting())
runtime_gosched();
- // raceenabled: don't need to check ep, as it is always on the stack.
-
if(debug)
runtime_printf("chanrecv: chan=%p\n", c);
@@ -256,8 +241,6 @@
sg = dequeue(&c->sendq);
if(sg != nil) {
- if(raceenabled)
- racesync(c, sg);
runtime_unlock(c);
if(ep != nil)
@@ -319,11 +302,6 @@
goto asynch;
}
- if(raceenabled) {
- runtime_raceacquire(chanbuf(c, c->recvx));
- runtime_racerelease(chanbuf(c, c->recvx));
- }
-
if(ep != nil)
runtime_memmove(ep, chanbuf(c, c->recvx), c->elemsize);
runtime_memclr(chanbuf(c, c->recvx), c->elemsize);
@@ -352,8 +330,6 @@
runtime_memclr(ep, c->elemsize);
if(received != nil)
*received = false;
- if(raceenabled)
- runtime_raceacquire(c);
runtime_unlock(c);
if(mysg.releasetime > 0)
runtime_blockevent(mysg.releasetime - t0, 2);
@@ -789,8 +765,6 @@
break;
case CaseSend:
- if(raceenabled)
- runtime_racereadpc(c, runtime_selectgo, chansend);
if(c->closed)
goto sclose;
if(c->dataqsiz > 0) {
@@ -874,24 +848,11 @@
*cas->receivedp = true;
}
- if(raceenabled) {
- if(cas->kind == CaseRecv && cas->sg.elem != nil)
- runtime_racewriteobjectpc(cas->sg.elem, c->elemtype, selectgo, chanrecv);
- else if(cas->kind == CaseSend)
- runtime_racereadobjectpc(cas->sg.elem, c->elemtype, selectgo, chansend);
- }
-
selunlock(sel);
goto retc;
asyncrecv:
// can receive from buffer
- if(raceenabled) {
- if(cas->sg.elem != nil)
- runtime_racewriteobjectpc(cas->sg.elem, c->elemtype, selectgo, chanrecv);
- runtime_raceacquire(chanbuf(c, c->recvx));
- runtime_racerelease(chanbuf(c, c->recvx));
- }
if(cas->receivedp != nil)
*cas->receivedp = true;
if(cas->sg.elem != nil)
@@ -914,11 +875,6 @@
asyncsend:
// can send to buffer
- if(raceenabled) {
- runtime_raceacquire(chanbuf(c, c->sendx));
- runtime_racerelease(chanbuf(c, c->sendx));
- runtime_racereadobjectpc(cas->sg.elem, c->elemtype, selectgo, chansend);
- }
runtime_memmove(chanbuf(c, c->sendx), cas->sg.elem, c->elemsize);
if(++c->sendx == c->dataqsiz)
c->sendx = 0;
@@ -937,11 +893,6 @@
syncrecv:
// can receive from sleeping sender (sg)
- if(raceenabled) {
- if(cas->sg.elem != nil)
- runtime_racewriteobjectpc(cas->sg.elem, c->elemtype, selectgo, chanrecv);
- racesync(c, sg);
- }
selunlock(sel);
if(debug)
runtime_printf("syncrecv: sel=%p c=%p o=%d\n", sel, c, o);
@@ -963,16 +914,10 @@
*cas->receivedp = false;
if(cas->sg.elem != nil)
runtime_memclr(cas->sg.elem, c->elemsize);
- if(raceenabled)
- runtime_raceacquire(c);
goto retc;
syncsend:
// can send to sleeping receiver (sg)
- if(raceenabled) {
- runtime_racereadobjectpc(cas->sg.elem, c->elemtype, selectgo, chansend);
- racesync(c, sg);
- }
selunlock(sel);
if(debug)
runtime_printf("syncsend: sel=%p c=%p o=%d\n", sel, c, o);
@@ -1062,6 +1007,7 @@
static void
closechan(Hchan *c, void *pc)
{
+ USED(pc);
SudoG *sg;
G* gp;
@@ -1076,12 +1022,6 @@
runtime_unlock(c);
runtime_panicstring("close of closed channel");
}
-
- if(raceenabled) {
- runtime_racewritepc(c, pc, runtime_closechan);
- runtime_racerelease(c);
- }
-
c->closed = true;
// release all readers
@@ -1194,12 +1134,3 @@
q->last->link = sgp;
q->last = sgp;
}
-
-static void
-racesync(Hchan *c, SudoG *sg)
-{
- runtime_racerelease(chanbuf(c, 0));
- runtime_raceacquireg(sg->g, chanbuf(c, 0));
- runtime_racereleaseg(sg->g, chanbuf(c, 0));
- runtime_raceacquire(chanbuf(c, 0));
-}
diff -r 6cbef7b5f57b libgo/runtime/malloc.goc
--- a/libgo/runtime/malloc.goc Tue Dec 23 10:38:47 2014 -0800
+++ b/libgo/runtime/malloc.goc Tue Dec 23 12:30:58 2014 -0800
@@ -16,7 +16,6 @@
#include "malloc.h"
#include "interface.h"
#include "go-type.h"
-#include "race.h"
// Map gccgo field names to gc field names.
// Eface aka __go_empty_interface.
@@ -249,9 +248,6 @@
if(UseSpanType && !(flag & FlagNoScan) && typ != 0)
settype(s, v, typ);
- if(raceenabled)
- runtime_racemalloc(v, size);
-
if(runtime_debug.allocfreetrace)
runtime_tracealloc(v, size, typ);
@@ -697,8 +693,6 @@
h->arena_used += n;
runtime_MHeap_MapBits(h);
runtime_MHeap_MapSpans(h);
- if(raceenabled)
- runtime_racemapshadow(p, n);
if(((uintptr)p & (PageSize-1)) != 0)
runtime_throw("misrounded allocation in MHeap_SysAlloc");
@@ -732,8 +726,6 @@
h->arena_end = p_end;
runtime_MHeap_MapBits(h);
runtime_MHeap_MapSpans(h);
- if(raceenabled)
- runtime_racemapshadow(p, n);
}
if(((uintptr)p & (PageSize-1)) != 0)
diff -r 6cbef7b5f57b libgo/runtime/mgc0.c
--- a/libgo/runtime/mgc0.c Tue Dec 23 10:38:47 2014 -0800
+++ b/libgo/runtime/mgc0.c Tue Dec 23 12:30:58 2014 -0800
@@ -57,7 +57,6 @@
#include "malloc.h"
#include "mgc0.h"
#include "chan.h"
-#include "race.h"
#include "go-type.h"
// Map gccgo field names to gc field names.
@@ -2507,8 +2506,6 @@
continue;
}
runtime_unlock(&finlock);
- if(raceenabled)
- runtime_racefingo();
for(; fb; fb=next) {
next = fb->next;
for(i=0; i<(uint32)fb->cnt; i++) {
diff -r 6cbef7b5f57b libgo/runtime/proc.c
--- a/libgo/runtime/proc.c Tue Dec 23 10:38:47 2014 -0800
+++ b/libgo/runtime/proc.c Tue Dec 23 12:30:58 2014 -0800
@@ -18,7 +18,6 @@
#include "arch.h"
#include "defs.h"
#include "malloc.h"
-#include "race.h"
#include "go-type.h"
#include "go-defer.h"
@@ -462,9 +461,6 @@
// Can not enable GC until all roots are registered.
// mstats.enablegc = 1;
-
- // if(raceenabled)
- // g->racectx = runtime_raceinit();
}
extern void main_init(void) __asm__ (GOSYM_PREFIX "__go_init_main");
@@ -528,8 +524,6 @@
mstats.enablegc = 1;
main_main();
- if(raceenabled)
- runtime_racefini();
// Make racy client program work: if panicking on
// another goroutine at the same time as main returns,
@@ -1848,8 +1842,6 @@
{
if(g->status != Grunning)
runtime_throw("bad g status");
- if(raceenabled)
- runtime_racegoend();
runtime_mcall(goexit0);
}
diff -r 6cbef7b5f57b libgo/runtime/race.h
--- a/libgo/runtime/race.h Tue Dec 23 10:38:47 2014 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Definitions related to data race detection.
-
-#ifdef RACE
-enum { raceenabled = 1 };
-#else
-enum { raceenabled = 0 };
-#endif
-
-// Initialize race detection subsystem.
-uintptr runtime_raceinit(void);
-// Finalize race detection subsystem, does not return.
-void runtime_racefini(void);
-
-void runtime_racemapshadow(void *addr, uintptr size);
-void runtime_racemalloc(void *p, uintptr sz);
-uintptr runtime_racegostart(void *pc);
-void runtime_racegoend(void);
-void runtime_racewritepc(void *addr, void *callpc, void *pc);
-void runtime_racereadpc(void *addr, void *callpc, void *pc);
-void runtime_racewriterangepc(void *addr, uintptr sz, void *callpc, void *pc);
-void runtime_racereadrangepc(void *addr, uintptr sz, void *callpc, void *pc);
-void runtime_racereadobjectpc(void *addr, const Type *t, void *callpc, void *pc);
-void runtime_racewriteobjectpc(void *addr, const Type *t, void *callpc, void *pc);
-void runtime_racefingo(void);
-void runtime_raceacquire(void *addr);
-void runtime_raceacquireg(G *gp, void *addr);
-void runtime_racerelease(void *addr);
-void runtime_racereleaseg(G *gp, void *addr);
-void runtime_racereleasemerge(void *addr);
-void runtime_racereleasemergeg(G *gp, void *addr);
diff -r 6cbef7b5f57b libgo/runtime/string.goc
--- a/libgo/runtime/string.goc Tue Dec 23 10:38:47 2014 -0800
+++ b/libgo/runtime/string.goc Tue Dec 23 12:30:58 2014 -0800
@@ -7,7 +7,6 @@
#include "arch.h"
#include "malloc.h"
#include "go-string.h"
-#include "race.h"
#define charntorune(pv, str, len) __go_get_rune(str, len, pv)
diff -r 6cbef7b5f57b libgo/runtime/time.goc
--- a/libgo/runtime/time.goc Tue Dec 23 10:38:47 2014 -0800
+++ b/libgo/runtime/time.goc Tue Dec 23 12:30:58 2014 -0800
@@ -12,7 +12,6 @@
#include "defs.h"
#include "arch.h"
#include "malloc.h"
-#include "race.h"
enum {
debug = 0,
@@ -42,8 +41,6 @@
// startTimer adds t to the timer heap.
func startTimer(t *Timer) {
- if(raceenabled)
- runtime_racerelease(t);
runtime_addtimer(t);
}
@@ -237,8 +234,6 @@
f = (void*)t->fv->fn;
arg = t->arg;
runtime_unlock(&timers);
- if(raceenabled)
- runtime_raceacquire(t);
__go_set_closure(fv);
f(now, arg);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-12-23 20:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-23 20:40 libgo patch committed: Remove race detector calls Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).