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 // Malloc profiling. | 5 // Malloc profiling. |
6 // Patterned after tcmalloc's algorithms; shorter code. | 6 // Patterned after tcmalloc's algorithms; shorter code. |
7 | 7 |
8 package runtime | 8 package runtime |
9 #include "runtime.h" | 9 #include "runtime.h" |
10 #include "arch_GOARCH.h" | 10 #include "arch_GOARCH.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } | 440 } |
441 } | 441 } |
442 | 442 |
443 func Stack(b Slice, all bool) (n int) { | 443 func Stack(b Slice, all bool) (n int) { |
444 uintptr pc, sp; | 444 uintptr pc, sp; |
445 ········ | 445 ········ |
446 sp = runtime·getcallersp(&b); | 446 sp = runtime·getcallersp(&b); |
447 pc = (uintptr)runtime·getcallerpc(&b); | 447 pc = (uintptr)runtime·getcallerpc(&b); |
448 | 448 |
449 if(all) { | 449 if(all) { |
450 » » runtime·semacquire(&runtime·worldsema); | 450 » » runtime·semacquire(&runtime·worldsema, false); |
451 m->gcing = 1; | 451 m->gcing = 1; |
452 runtime·stoptheworld(); | 452 runtime·stoptheworld(); |
453 } | 453 } |
454 | 454 |
455 if(b.len == 0) | 455 if(b.len == 0) |
456 n = 0; | 456 n = 0; |
457 else{ | 457 else{ |
458 g->writebuf = (byte*)b.array; | 458 g->writebuf = (byte*)b.array; |
459 g->writenbuf = b.len; | 459 g->writenbuf = b.len; |
460 runtime·goroutineheader(g); | 460 runtime·goroutineheader(g); |
(...skipping 26 matching lines...) Expand all Loading... |
487 uintptr pc, sp; | 487 uintptr pc, sp; |
488 TRecord *r; | 488 TRecord *r; |
489 G *gp; | 489 G *gp; |
490 ········ | 490 ········ |
491 sp = runtime·getcallersp(&b); | 491 sp = runtime·getcallersp(&b); |
492 pc = (uintptr)runtime·getcallerpc(&b); | 492 pc = (uintptr)runtime·getcallerpc(&b); |
493 ········ | 493 ········ |
494 ok = false; | 494 ok = false; |
495 n = runtime·gcount(); | 495 n = runtime·gcount(); |
496 if(n <= b.len) { | 496 if(n <= b.len) { |
497 » » runtime·semacquire(&runtime·worldsema); | 497 » » runtime·semacquire(&runtime·worldsema, false); |
498 m->gcing = 1; | 498 m->gcing = 1; |
499 runtime·stoptheworld(); | 499 runtime·stoptheworld(); |
500 | 500 |
501 n = runtime·gcount(); | 501 n = runtime·gcount(); |
502 if(n <= b.len) { | 502 if(n <= b.len) { |
503 ok = true; | 503 ok = true; |
504 r = (TRecord*)b.array; | 504 r = (TRecord*)b.array; |
505 saveg(pc, sp, g, r++); | 505 saveg(pc, sp, g, r++); |
506 for(gp = runtime·allg; gp != nil; gp = gp->alllink) { | 506 for(gp = runtime·allg; gp != nil; gp = gp->alllink) { |
507 if(gp == g || gp->status == Gdead) | 507 if(gp == g || gp->status == Gdead) |
508 continue; | 508 continue; |
509 saveg(gp->sched.pc, gp->sched.sp, gp, r++); | 509 saveg(gp->sched.pc, gp->sched.sp, gp, r++); |
510 } | 510 } |
511 } | 511 } |
512 ········ | 512 ········ |
513 m->gcing = 0; | 513 m->gcing = 0; |
514 runtime·semrelease(&runtime·worldsema); | 514 runtime·semrelease(&runtime·worldsema); |
515 runtime·starttheworld(); | 515 runtime·starttheworld(); |
516 } | 516 } |
517 } | 517 } |
518 | 518 |
519 void | 519 void |
520 runtime·mprofinit(void) | 520 runtime·mprofinit(void) |
521 { | 521 { |
522 addrhash = runtime·persistentalloc((1<<AddrHashBits)*sizeof *addrhash, 0
); | 522 addrhash = runtime·persistentalloc((1<<AddrHashBits)*sizeof *addrhash, 0
); |
523 } | 523 } |
LEFT | RIGHT |