LEFT | RIGHT |
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 return c; | 222 return c; |
223 } | 223 } |
224 | 224 |
225 int32 runtime·sizeof_C_MStats = sizeof(MStats); | 225 int32 runtime·sizeof_C_MStats = sizeof(MStats); |
226 | 226 |
227 #define MaxArena32 (2U<<30) | 227 #define MaxArena32 (2U<<30) |
228 | 228 |
229 void | 229 void |
230 runtime·mallocinit(void) | 230 runtime·mallocinit(void) |
231 { | 231 { |
232 » byte *p, *q; | 232 » byte *p; |
233 uintptr arena_size, bitmap_size; | 233 uintptr arena_size, bitmap_size; |
234 extern byte end[]; | 234 extern byte end[]; |
235 | 235 |
236 runtime·InitSizes(); | 236 runtime·InitSizes(); |
237 | 237 |
238 // Set up the allocation arena, a contiguous area of memory where | 238 // Set up the allocation arena, a contiguous area of memory where |
239 // allocated data will be found. The arena begins with a bitmap large | 239 // allocated data will be found. The arena begins with a bitmap large |
240 // enough to hold 4 bits per allocated word. | 240 // enough to hold 4 bits per allocated word. |
241 if(sizeof(void*) == 8) { | 241 if(sizeof(void*) == 8) { |
242 // On a 64-bit machine, allocate from a single contiguous reserv
ation. | 242 // On a 64-bit machine, allocate from a single contiguous reserv
ation. |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 } | 470 } |
471 nret = (nret + sizeof(void*)-1) & ~(sizeof(void*)-1); | 471 nret = (nret + sizeof(void*)-1) & ~(sizeof(void*)-1); |
472 | 472 |
473 if(runtime·getfinalizer(obj.data, 0)) { | 473 if(runtime·getfinalizer(obj.data, 0)) { |
474 runtime·printf("runtime.SetFinalizer: finalizer already
set"); | 474 runtime·printf("runtime.SetFinalizer: finalizer already
set"); |
475 goto throw; | 475 goto throw; |
476 } | 476 } |
477 } | 477 } |
478 runtime·addfinalizer(obj.data, finalizer.data, nret); | 478 runtime·addfinalizer(obj.data, finalizer.data, nret); |
479 } | 479 } |
LEFT | RIGHT |