Left: | ||
Right: |
OLD | NEW |
---|---|
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 // Garbage collector. | 5 // Garbage collector. |
6 | 6 |
7 #include "runtime.h" | 7 #include "runtime.h" |
8 #include "arch_GOARCH.h" | 8 #include "arch_GOARCH.h" |
9 #include "malloc.h" | 9 #include "malloc.h" |
10 #include "stack.h" | 10 #include "stack.h" |
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1391 work.nroot++; | 1391 work.nroot++; |
1392 } | 1392 } |
1393 | 1393 |
1394 // Scan a stack frame. The doframe parameter is a signal that the previously | 1394 // Scan a stack frame. The doframe parameter is a signal that the previously |
1395 // scanned activation has an unknown argument size. When *doframe is true the | 1395 // scanned activation has an unknown argument size. When *doframe is true the |
1396 // current activation must have its entire frame scanned. Otherwise, only the | 1396 // current activation must have its entire frame scanned. Otherwise, only the |
1397 // locals need to be scanned. | 1397 // locals need to be scanned. |
1398 static void | 1398 static void |
1399 addframeroots(Func *f, byte*, byte *sp, void *doframe) | 1399 addframeroots(Func *f, byte*, byte *sp, void *doframe) |
1400 { | 1400 { |
1401 byte *fp, *ap; | |
1401 uintptr outs; | 1402 uintptr outs; |
1403 int32 i, j, rem; | |
1404 uint32 w, b; | |
1402 | 1405 |
1403 if(thechar == '5') | 1406 if(thechar == '5') |
1404 sp += sizeof(uintptr); | 1407 sp += sizeof(uintptr); |
1408 fp = sp + f->frame; | |
1405 if(f->locals == 0 || *(bool*)doframe == true) | 1409 if(f->locals == 0 || *(bool*)doframe == true) |
1410 // Scan the entire stack frame. | |
1406 addroot((Obj){sp, f->frame - sizeof(uintptr), 0}); | 1411 addroot((Obj){sp, f->frame - sizeof(uintptr), 0}); |
1407 else if(f->locals > 0) { | 1412 else if(f->locals > 0) { |
1413 // Scan the locals area. | |
1408 outs = f->frame - sizeof(uintptr) - f->locals; | 1414 outs = f->frame - sizeof(uintptr) - f->locals; |
1409 addroot((Obj){sp + outs, f->locals, 0}); | 1415 addroot((Obj){sp + outs, f->locals, 0}); |
1410 } | 1416 } |
1411 » if(f->args > 0) | 1417 » if(f->args > 0) { |
1412 » » addroot((Obj){sp + f->frame, f->args, 0}); | 1418 » » // Scan the arguments area. |
iant
2013/05/28 21:23:36
Should we have a check here that f->ptrs.len is la
cshapiro1
2013/05/29 00:29:20
These values are produced by the symbol table cons
| |
1419 » » if(f->ptrs.array != nil) { | |
1420 » » » ap = fp; | |
1421 » » » rem = f->args / sizeof(uintptr); | |
1422 » » » for(i = 0; i < f->ptrs.len; i++) { | |
1423 » » » » w = ((uint32*)f->ptrs.array)[i]; | |
1424 » » » » b = 1; | |
1425 » » » » for((j = (rem < 32) ? rem : 32); j > 0; j--) { | |
1426 » » » » » if(w & b) | |
1427 » » » » » » addroot((Obj){ap, sizeof(uintptr ), 0}); | |
1428 » » » » » b <<= 1; | |
1429 » » » » » ap += sizeof(uintptr); | |
1430 » » » » } | |
1431 » » » » rem -= 32; | |
1432 » » » } | |
1433 » » } else | |
1434 » » » addroot((Obj){fp, f->args, 0}); | |
1435 » } | |
1413 *(bool*)doframe = (f->args == ArgsSizeUnknown); | 1436 *(bool*)doframe = (f->args == ArgsSizeUnknown); |
1414 } | 1437 } |
1415 | 1438 |
1416 static void | 1439 static void |
1417 addstackroots(G *gp) | 1440 addstackroots(G *gp) |
1418 { | 1441 { |
1419 M *mp; | 1442 M *mp; |
1420 int32 n; | 1443 int32 n; |
1421 Stktop *stk; | 1444 Stktop *stk; |
1422 byte *sp, *guard, *pc; | 1445 byte *sp, *guard, *pc; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1462 // Otherwise, scan everything between the | 1485 // Otherwise, scan everything between the |
1463 // top and the bottom of the stack. | 1486 // top and the bottom of the stack. |
1464 if(f->args > 0) | 1487 if(f->args > 0) |
1465 addroot((Obj){sp, f->args, 0}); | 1488 addroot((Obj){sp, f->args, 0}); |
1466 else | 1489 else |
1467 addroot((Obj){sp, (byte*)stk - sp, 0});· | 1490 addroot((Obj){sp, (byte*)stk - sp, 0});· |
1468 }· | 1491 }· |
1469 return; | 1492 return; |
1470 } | 1493 } |
1471 } | 1494 } |
1472 » if (ScanStackByFrames) { | 1495 » if(ScanStackByFrames) { |
1473 USED(stk); | 1496 USED(stk); |
1474 USED(guard); | 1497 USED(guard); |
1475 doframe = false; | 1498 doframe = false; |
1476 runtime·gentraceback(pc, sp, nil, gp, 0, nil, 0x7fffffff, addfra meroots, &doframe); | 1499 runtime·gentraceback(pc, sp, nil, gp, 0, nil, 0x7fffffff, addfra meroots, &doframe); |
1477 } else { | 1500 } else { |
1478 USED(pc); | 1501 USED(pc); |
1479 n = 0; | 1502 n = 0; |
1480 while(stk) { | 1503 while(stk) { |
1481 if(sp < guard-StackGuard || (byte*)stk < sp) { | 1504 if(sp < guard-StackGuard || (byte*)stk < sp) { |
1482 runtime·printf("scanstack inconsistent: g%D#%d s p=%p not in [%p,%p]\n", gp->goid, n, sp, guard-StackGuard, stk); | 1505 runtime·printf("scanstack inconsistent: g%D#%d s p=%p not in [%p,%p]\n", gp->goid, n, sp, guard-StackGuard, stk); |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2403 uintptr n; | 2426 uintptr n; |
2404 | 2427 |
2405 n = (h->arena_used - h->arena_start) / wordsPerBitmapWord; | 2428 n = (h->arena_used - h->arena_start) / wordsPerBitmapWord; |
2406 n = (n+bitmapChunk-1) & ~(bitmapChunk-1); | 2429 n = (n+bitmapChunk-1) & ~(bitmapChunk-1); |
2407 if(h->bitmap_mapped >= n) | 2430 if(h->bitmap_mapped >= n) |
2408 return; | 2431 return; |
2409 | 2432 |
2410 runtime·SysMap(h->arena_start - n, n - h->bitmap_mapped); | 2433 runtime·SysMap(h->arena_start - n, n - h->bitmap_mapped); |
2411 h->bitmap_mapped = n; | 2434 h->bitmap_mapped = n; |
2412 } | 2435 } |
OLD | NEW |