aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/malloc.goc
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2012-10-07 22:05:32 +0400
committerDmitriy Vyukov <dvyukov@google.com>2012-10-07 22:05:32 +0400
commit2f6cbc74f18542b0f79374a2210e420b9500218f (patch)
tree2eb9db49492159d678e2578750d10460897e2453 /src/pkg/runtime/malloc.goc
parentf82c59b6cf4cc50964c6068a704647db5a73c4fa (diff)
downloadgo-2f6cbc74f18542b0f79374a2210e420b9500218f.tar.xz
race: runtime changes
This is a part of a bigger change that adds data race detection feature: https://golang.org/cl/6456044 R=rsc CC=gobot, golang-dev https://golang.org/cl/6535050
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
-rw-r--r--src/pkg/runtime/malloc.goc19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc
index 7253db8f42..92bc4aa234 100644
--- a/src/pkg/runtime/malloc.goc
+++ b/src/pkg/runtime/malloc.goc
@@ -14,6 +14,7 @@ package runtime
#include "defs_GOOS_GOARCH.h"
#include "type.h"
#include "typekind.h"
+#include "race.h"
#pragma dataflag 16 /* mark mheap as 'no pointers', hiding from garbage collector */
MHeap runtime·mheap;
@@ -111,6 +112,11 @@ runtime·mallocgc(uintptr size, uint32 flag, int32 dogc, int32 zeroed)
if(dogc && mstats.heap_alloc >= mstats.next_gc)
runtime·gc(0);
+
+ if(raceenabled) {
+ runtime·racemalloc(v, size, m->racepc);
+ m->racepc = nil;
+ }
return v;
}
@@ -146,6 +152,9 @@ runtime·free(void *v)
}
prof = runtime·blockspecial(v);
+ if(raceenabled)
+ runtime·racefree(v);
+
// Find size class for v.
sizeclass = s->sizeclass;
c = m->mcache;
@@ -678,8 +687,14 @@ runtime·mal(uintptr n)
return runtime·mallocgc(n, 0, 1, 1);
}
-func new(typ *Type) (ret *uint8) {
- uint32 flag = typ->kind&KindNoPointers ? FlagNoPointers : 0;
+#pragma textflag 7
+void
+runtime·new(Type *typ, uint8 *ret)
+{
+ uint32 flag;
+
+ m->racepc = runtime·getcallerpc(&typ);
+ flag = typ->kind&KindNoPointers ? FlagNoPointers : 0;
ret = runtime·mallocgc(typ->size, flag, 1, 1);
if(UseSpanType && !flag) {