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

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

Issue 56060043: code review 56060043: undo CL 45770044 / d795425bfa18 (Closed)
Left Patch Set: Created 11 years, 1 month ago
Right Patch Set: diff -r d795425bfa18 https://dvyukov%40google.com@code.google.com/p/go/ Created 11 years, 1 month 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:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/malloc.h ('k') | src/pkg/runtime/mem.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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"
11 #include "arch_GOARCH.h" 11 #include "arch_GOARCH.h"
12 #include "malloc.h" 12 #include "malloc.h"
13 #include "type.h" 13 #include "type.h"
14 #include "typekind.h" 14 #include "typekind.h"
15 #include "race.h" 15 #include "race.h"
16 #include "stack.h" 16 #include "stack.h"
17 #include "../../cmd/ld/textflag.h" 17 #include "../../cmd/ld/textflag.h"
18 18
19 // Mark mheap as 'no pointers', it does not contain interesting pointers but occ upies ~45K. 19 // Mark mheap as 'no pointers', it does not contain interesting pointers but occ upies ~45K.
20 #pragma dataflag NOPTR 20 #pragma dataflag NOPTR
21 MHeap runtime·mheap; 21 MHeap runtime·mheap;
22 MStats mstats;
23 22
24 int32 runtime·checking; 23 int32 runtime·checking;
25 24
26 extern MStats mstats; // defined in zruntime_def_$GOOS_$GOARCH.go 25 extern MStats mstats; // defined in zruntime_def_$GOOS_$GOARCH.go
27 26
28 extern volatile intgo runtime·MemProfileRate; 27 extern volatile intgo runtime·MemProfileRate;
29 28
30 // Allocate an object of at least size bytes. 29 // Allocate an object of at least size bytes.
31 // Small objects are allocated from the per-thread cache's free lists. 30 // Small objects are allocated from the per-thread cache's free lists.
32 // Large objects (> 32 kB) are allocated straight from the heap. 31 // Large objects (> 32 kB) are allocated straight from the heap.
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 h->largefree += c->local_largefree; 313 h->largefree += c->local_largefree;
315 c->local_largefree = 0; 314 c->local_largefree = 0;
316 h->nlargefree += c->local_nlargefree; 315 h->nlargefree += c->local_nlargefree;
317 c->local_nlargefree = 0; 316 c->local_nlargefree = 0;
318 for(i=0; i<nelem(c->local_nsmallfree); i++) { 317 for(i=0; i<nelem(c->local_nsmallfree); i++) {
319 h->nsmallfree[i] += c->local_nsmallfree[i]; 318 h->nsmallfree[i] += c->local_nsmallfree[i];
320 c->local_nsmallfree[i] = 0; 319 c->local_nsmallfree[i] = 0;
321 } 320 }
322 } 321 }
323 322
324 // Size of the trailing by_size array differs between Go and C, 323 uintptr runtime·sizeof_C_MStats = sizeof(MStats);
325 // NumSizeClasses was changed, but we can not change Go struct because of backwa rd compatibility.
326 // sizeof_C_MStats is what C thinks about size of Go struct.
327 uintptr runtime·sizeof_C_MStats = sizeof(MStats) - (NumSizeClasses - 61) * sizeo f(mstats.by_size[0]);
328 324
329 #define MaxArena32 (2U<<30) 325 #define MaxArena32 (2U<<30)
330 326
331 void 327 void
332 runtime·mallocinit(void) 328 runtime·mallocinit(void)
333 { 329 {
334 byte *p; 330 byte *p;
335 uintptr arena_size, bitmap_size, spans_size; 331 uintptr arena_size, bitmap_size, spans_size;
336 extern byte end[]; 332 extern byte end[];
337 byte *want; 333 byte *want;
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 // NOTE: asking to remove a finalizer when there currently isn't one set is OK. 802 // NOTE: asking to remove a finalizer when there currently isn't one set is OK.
807 runtime·removefinalizer(obj.data); 803 runtime·removefinalizer(obj.data);
808 } 804 }
809 return; 805 return;
810 806
811 badfunc: 807 badfunc:
812 runtime·printf("runtime.SetFinalizer: cannot pass %S to finalizer %S\n", *obj.type->string, *finalizer.type->string); 808 runtime·printf("runtime.SetFinalizer: cannot pass %S to finalizer %S\n", *obj.type->string, *finalizer.type->string);
813 throw: 809 throw:
814 runtime·throw("runtime.SetFinalizer"); 810 runtime·throw("runtime.SetFinalizer");
815 } 811 }
LEFTRIGHT

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