LEFT | RIGHT |
(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 // 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 | 532 |
533 static void | 533 static void |
534 addstackroots(G *gp) | 534 addstackroots(G *gp) |
535 { | 535 { |
536 M *mp; | 536 M *mp; |
537 int32 n; | 537 int32 n; |
538 Stktop *stk; | 538 Stktop *stk; |
539 byte *sp, *guard; | 539 byte *sp, *guard; |
540 | 540 |
541 stk = (Stktop*)gp->stackbase; | 541 stk = (Stktop*)gp->stackbase; |
542 » guard = gp->stackguard; | 542 » guard = (byte*)gp->stackguard; |
543 | 543 |
544 if(gp == g) { | 544 if(gp == g) { |
545 // Scanning our own stack: start at &gp. | 545 // Scanning our own stack: start at &gp. |
546 sp = (byte*)&gp; | 546 sp = (byte*)&gp; |
547 } else if((mp = gp->m) != nil && mp->helpgc) { | 547 } else if((mp = gp->m) != nil && mp->helpgc) { |
548 // gchelper's stack is in active use and has no interesting poin
ters. | 548 // gchelper's stack is in active use and has no interesting poin
ters. |
549 return; | 549 return; |
550 } else { | 550 } else { |
551 // Scanning another goroutine's stack. | 551 // Scanning another goroutine's stack. |
552 // The goroutine is usually asleep (the world is stopped). | 552 // The goroutine is usually asleep (the world is stopped). |
553 » » sp = gp->sched.sp; | 553 » » sp = (byte*)gp->sched.sp; |
554 | 554 |
555 // The exception is that if the goroutine is about to enter or m
ight | 555 // The exception is that if the goroutine is about to enter or m
ight |
556 // have just exited a system call, it may be executing code such | 556 // have just exited a system call, it may be executing code such |
557 // as schedlock and may have needed to start a new stack segment
. | 557 // as schedlock and may have needed to start a new stack segment
. |
558 // Use the stack segment and stack pointer at the time of | 558 // Use the stack segment and stack pointer at the time of |
559 // the system call instead, since that won't change underfoot. | 559 // the system call instead, since that won't change underfoot. |
560 » » if(gp->gcstack != nil) { | 560 » » if(gp->gcstack != (uintptr)nil) { |
561 stk = (Stktop*)gp->gcstack; | 561 stk = (Stktop*)gp->gcstack; |
562 » » » sp = gp->gcsp; | 562 » » » sp = (byte*)gp->gcsp; |
563 » » » guard = gp->gcguard; | 563 » » » guard = (byte*)gp->gcguard; |
564 } | 564 } |
565 } | 565 } |
566 | 566 |
567 n = 0; | 567 n = 0; |
568 while(stk) { | 568 while(stk) { |
569 if(sp < guard-StackGuard || (byte*)stk < sp) { | 569 if(sp < guard-StackGuard || (byte*)stk < sp) { |
570 runtime·printf("scanstack inconsistent: g%d#%d sp=%p not
in [%p,%p]\n", gp->goid, n, sp, guard-StackGuard, stk); | 570 runtime·printf("scanstack inconsistent: g%d#%d sp=%p not
in [%p,%p]\n", gp->goid, n, sp, guard-StackGuard, stk); |
571 runtime·throw("scanstack"); | 571 runtime·throw("scanstack"); |
572 } | 572 } |
573 addroot(sp, (byte*)stk - sp); | 573 addroot(sp, (byte*)stk - sp); |
574 » » sp = stk->gobuf.sp; | 574 » » sp = (byte*)stk->gobuf.sp; |
575 guard = stk->stackguard; | 575 guard = stk->stackguard; |
576 stk = (Stktop*)stk->stackbase; | 576 stk = (Stktop*)stk->stackbase; |
577 n++; | 577 n++; |
578 } | 578 } |
579 } | 579 } |
580 | 580 |
581 static void | 581 static void |
582 addfinroots(void *v) | 582 addfinroots(void *v) |
583 { | 583 { |
584 uintptr size; | 584 uintptr size; |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 uintptr n; | 1250 uintptr n; |
1251 | 1251 |
1252 n = (h->arena_used - h->arena_start) / wordsPerBitmapWord; | 1252 n = (h->arena_used - h->arena_start) / wordsPerBitmapWord; |
1253 n = (n+bitmapChunk-1) & ~(bitmapChunk-1); | 1253 n = (n+bitmapChunk-1) & ~(bitmapChunk-1); |
1254 if(h->bitmap_mapped >= n) | 1254 if(h->bitmap_mapped >= n) |
1255 return; | 1255 return; |
1256 | 1256 |
1257 runtime·SysMap(h->arena_start - n, n - h->bitmap_mapped); | 1257 runtime·SysMap(h->arena_start - n, n - h->bitmap_mapped); |
1258 h->bitmap_mapped = n; | 1258 h->bitmap_mapped = n; |
1259 } | 1259 } |
LEFT | RIGHT |