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

Delta Between Two Patch Sets: src/pkg/runtime/malloc.goc

Issue 6297047: code review 6297047: runtime: use uintptr where possible in malloc stats (Closed)
Left Patch Set: diff -r b720fc58b147 https://go.googlecode.com/hg/ Created 11 years, 9 months ago
Right Patch Set: diff -r f33da81baac2 https://go.googlecode.com/hg/ Created 11 years, 9 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/malloc.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 // See malloc.h for overview. 5 // See malloc.h for overview.
6 // 6 //
7 // TODO(rsc): double-check stats. 7 // TODO(rsc): double-check stats.
8 8
9 package runtime 9 package runtime
10 #include "runtime.h" 10 #include "runtime.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 runtime·throw("out of memory"); 66 runtime·throw("out of memory");
67 size = npages<<PageShift; 67 size = npages<<PageShift;
68 c->local_alloc += size; 68 c->local_alloc += size;
69 c->local_total_alloc += size; 69 c->local_total_alloc += size;
70 v = (void*)(s->start << PageShift); 70 v = (void*)(s->start << PageShift);
71 71
72 // setup for mark sweep 72 // setup for mark sweep
73 runtime·markspan(v, 0, 0, true); 73 runtime·markspan(v, 0, 0, true);
74 } 74 }
75 75
76 » if (sizeof(void*) == 4 && c->local_total_alloc >(1<<30)) { 76 » if (sizeof(void*) == 4 && c->local_total_alloc >= (1<<30)) {
77 // purge cache stats to prevent overflow 77 // purge cache stats to prevent overflow
78 runtime·lock(&runtime·mheap); 78 runtime·lock(&runtime·mheap);
79 runtime·purgecachedstats(m); 79 runtime·purgecachedstats(m);
80 runtime·unlock(&runtime·mheap); 80 runtime·unlock(&runtime·mheap);
81 } 81 }
82 82
83 if(!(flag & FlagNoGC)) 83 if(!(flag & FlagNoGC))
84 runtime·markallocated(v, size, (flag&FlagNoPointers) != 0); 84 runtime·markallocated(v, size, (flag&FlagNoPointers) != 0);
85 85
86 m->mallocing = 0; 86 m->mallocing = 0;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 int32 173 int32
174 runtime·mlookup(void *v, byte **base, uintptr *size, MSpan **sp) 174 runtime·mlookup(void *v, byte **base, uintptr *size, MSpan **sp)
175 { 175 {
176 uintptr n, i; 176 uintptr n, i;
177 byte *p; 177 byte *p;
178 MSpan *s; 178 MSpan *s;
179 179
180 m->mcache->local_nlookup++; 180 m->mcache->local_nlookup++;
181 if (sizeof(void*) == 4 && m->mcache->local_nlookup >= (1<<30)) {
182 // purge cache stats to prevent overflow
183 runtime·lock(&runtime·mheap);
184 runtime·purgecachedstats(m);
185 runtime·unlock(&runtime·mheap);
186 }
187
181 s = runtime·MHeap_LookupMaybe(&runtime·mheap, v); 188 s = runtime·MHeap_LookupMaybe(&runtime·mheap, v);
182 if(sp) 189 if(sp)
183 *sp = s; 190 *sp = s;
184 if(s == nil) { 191 if(s == nil) {
185 runtime·checkfreed(v, 1); 192 runtime·checkfreed(v, 1);
186 if(base) 193 if(base)
187 *base = nil; 194 *base = nil;
188 if(size) 195 if(size)
189 *size = 0; 196 *size = 0;
190 return 0; 197 return 0;
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 runtime·printf("runtime.SetFinalizer: finalizer already set\n"); 535 runtime·printf("runtime.SetFinalizer: finalizer already set\n");
529 goto throw; 536 goto throw;
530 } 537 }
531 return; 538 return;
532 539
533 badfunc: 540 badfunc:
534 runtime·printf("runtime.SetFinalizer: second argument is %S, not func(%S )\n", *finalizer.type->string, *obj.type->string); 541 runtime·printf("runtime.SetFinalizer: second argument is %S, not func(%S )\n", *finalizer.type->string, *obj.type->string);
535 throw: 542 throw:
536 runtime·throw("runtime.SetFinalizer"); 543 runtime·throw("runtime.SetFinalizer");
537 } 544 }
LEFTRIGHT

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