diff options
author | Russ Cox <rsc@golang.org> | 2014-09-08 00:08:51 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-09-08 00:08:51 -0400 |
commit | c007ce824d9a4fccb148f9204e04c23ed2984b71 (patch) | |
tree | 7dcac257114ef5c446be5b7b68c27dea230b7c09 /src/runtime/race.go | |
parent | 220a6de47eced55956eb8af8d643d4f5b67fd634 (diff) | |
download | go-git-c007ce824d9a4fccb148f9204e04c23ed2984b71.tar.gz |
build: move package sources from src/pkg to src
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
Diffstat (limited to 'src/runtime/race.go')
-rw-r--r-- | src/runtime/race.go | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/src/runtime/race.go b/src/runtime/race.go new file mode 100644 index 0000000000..c7573517dc --- /dev/null +++ b/src/runtime/race.go @@ -0,0 +1,125 @@ +// 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. + +// +build race + +// Public race detection API, present iff build with -race. + +package runtime + +import ( + "unsafe" +) + +// RaceDisable disables handling of race events in the current goroutine. +func RaceDisable() + +// RaceEnable re-enables handling of race events in the current goroutine. +func RaceEnable() + +func RaceAcquire(addr unsafe.Pointer) +func RaceRelease(addr unsafe.Pointer) +func RaceReleaseMerge(addr unsafe.Pointer) + +func RaceRead(addr unsafe.Pointer) +func RaceWrite(addr unsafe.Pointer) +func RaceReadRange(addr unsafe.Pointer, len int) +func RaceWriteRange(addr unsafe.Pointer, len int) + +func RaceSemacquire(s *uint32) +func RaceSemrelease(s *uint32) + +// private interface for the runtime +const raceenabled = true + +func raceReadObjectPC(t *_type, addr unsafe.Pointer, callerpc, pc uintptr) { + kind := t.kind & kindMask + if kind == kindArray || kind == kindStruct { + // for composite objects we have to read every address + // because a write might happen to any subobject. + racereadrangepc(addr, t.size, callerpc, pc) + } else { + // for non-composite objects we can read just the start + // address, as any write must write the first byte. + racereadpc(addr, callerpc, pc) + } +} + +func raceWriteObjectPC(t *_type, addr unsafe.Pointer, callerpc, pc uintptr) { + kind := t.kind & kindMask + if kind == kindArray || kind == kindStruct { + // for composite objects we have to write every address + // because a write might happen to any subobject. + racewriterangepc(addr, t.size, callerpc, pc) + } else { + // for non-composite objects we can write just the start + // address, as any write must write the first byte. + racewritepc(addr, callerpc, pc) + } +} + +//go:noescape +func racereadpc(addr unsafe.Pointer, callpc, pc uintptr) + +//go:noescape +func racewritepc(addr unsafe.Pointer, callpc, pc uintptr) + +//go:noescape +func racereadrangepc(addr unsafe.Pointer, len uintptr, callpc, pc uintptr) + +//go:noescape +func racewriterangepc(addr unsafe.Pointer, len uintptr, callpc, pc uintptr) + +//go:noescape +func raceacquire(addr unsafe.Pointer) + +//go:noescape +func racerelease(addr unsafe.Pointer) + +//go:noescape +func raceacquireg(gp *g, addr unsafe.Pointer) + +//go:noescape +func racereleaseg(gp *g, addr unsafe.Pointer) + +func racefingo() + +//go:noescape +func racemalloc(p unsafe.Pointer, size uintptr) + +//go:noescape +func racereleasemerge(addr unsafe.Pointer) + +type symbolizeContext struct { + pc uintptr + fn *byte + file *byte + line uintptr + off uintptr + res uintptr +} + +var qq = [...]byte{'?', '?', 0} +var dash = [...]byte{'-', 0} + +// Callback from C into Go, runs on g0. +func racesymbolize(ctx *symbolizeContext) { + f := findfunc(ctx.pc) + if f == nil { + ctx.fn = &qq[0] + ctx.file = &dash[0] + ctx.line = 0 + ctx.off = ctx.pc + ctx.res = 1 + return + } + + ctx.fn = funcname(f) + var file string + ctx.line = uintptr(funcline(f, ctx.pc, &file)) + ctx.file = &bytes(file)[0] // assume NUL-terminated + ctx.off = ctx.pc - f.entry + ctx.res = 1 + return +} |