Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1251)

Side by Side Diff: src/pkg/runtime/chan.c

Issue 10136043: code review 10136043: runtime: refactor mallocgc (Closed)
Patch Set: diff -r 654ca7de0282 https://dvyukov%40google.com@code.google.com/p/go/ Created 11 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/runtime/hashmap.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include "runtime.h" 5 #include "runtime.h"
6 #include "arch_GOARCH.h" 6 #include "arch_GOARCH.h"
7 #include "type.h" 7 #include "type.h"
8 #include "race.h" 8 #include "race.h"
9 #include "malloc.h" 9 #include "malloc.h"
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // compiler checks this but be safe. 100 // compiler checks this but be safe.
101 if(elem->size >= (1<<16)) 101 if(elem->size >= (1<<16))
102 runtime·throw("makechan: invalid channel element type"); 102 runtime·throw("makechan: invalid channel element type");
103 if((sizeof(*c)%MAXALIGN) != 0 || elem->align > MAXALIGN) 103 if((sizeof(*c)%MAXALIGN) != 0 || elem->align > MAXALIGN)
104 runtime·throw("makechan: bad alignment"); 104 runtime·throw("makechan: bad alignment");
105 105
106 if(hint < 0 || (intgo)hint != hint || (elem->size > 0 && hint > MaxMem / elem->size)) 106 if(hint < 0 || (intgo)hint != hint || (elem->size > 0 && hint > MaxMem / elem->size))
107 runtime·panicstring("makechan: size out of range"); 107 runtime·panicstring("makechan: size out of range");
108 108
109 // allocate memory in one call 109 // allocate memory in one call
110 » c = (Hchan*)runtime·mal(sizeof(*c) + hint*elem->size); 110 » c = (Hchan*)runtime·mallocgc(sizeof(*c) + hint*elem->size, (uintptr)t | TypeInfo_Chan, 0);
111 c->elemsize = elem->size; 111 c->elemsize = elem->size;
112 c->elemalg = elem->alg; 112 c->elemalg = elem->alg;
113 c->dataqsiz = hint; 113 c->dataqsiz = hint;
114 runtime·settype(c, (uintptr)t | TypeInfo_Chan);
115 114
116 if(debug) 115 if(debug)
117 runtime·printf("makechan: chan=%p; elemsize=%D; elemalg=%p; data qsiz=%D\n", 116 runtime·printf("makechan: chan=%p; elemsize=%D; elemalg=%p; data qsiz=%D\n",
118 c, (int64)elem->size, elem->alg, (int64)c->dataqsiz); 117 c, (int64)elem->size, elem->alg, (int64)c->dataqsiz);
119 118
120 return c; 119 return c;
121 } 120 }
122 121
123 // For reflect 122 // For reflect
124 // func makechan(typ *ChanType, size uint64) (chan) 123 // func makechan(typ *ChanType, size uint64) (chan)
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 } 1356 }
1358 1357
1359 static void 1358 static void
1360 racesync(Hchan *c, SudoG *sg) 1359 racesync(Hchan *c, SudoG *sg)
1361 { 1360 {
1362 runtime·racerelease(chanbuf(c, 0)); 1361 runtime·racerelease(chanbuf(c, 0));
1363 runtime·raceacquireg(sg->g, chanbuf(c, 0)); 1362 runtime·raceacquireg(sg->g, chanbuf(c, 0));
1364 runtime·racereleaseg(sg->g, chanbuf(c, 0)); 1363 runtime·racereleaseg(sg->g, chanbuf(c, 0));
1365 runtime·raceacquire(chanbuf(c, 0)); 1364 runtime·raceacquire(chanbuf(c, 0));
1366 } 1365 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/runtime/hashmap.c » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b