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 /* | 5 /* |
6 * basic types | 6 * basic types |
7 */ | 7 */ |
8 typedef signed char int8; | 8 typedef signed char int8; |
9 typedef unsigned char uint8; | 9 typedef unsigned char uint8; |
10 typedef signed short int16; | 10 typedef signed short int16; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 */ | 53 */ |
54 typedef uint8 bool; | 54 typedef uint8 bool; |
55 typedef uint8 byte; | 55 typedef uint8 byte; |
56 typedef struct Func Func; | 56 typedef struct Func Func; |
57 typedef struct G G; | 57 typedef struct G G; |
58 typedef struct Gobuf Gobuf; | 58 typedef struct Gobuf Gobuf; |
59 typedef struct SudoG SudoG; | 59 typedef struct SudoG SudoG; |
60 typedef struct Mutex Mutex; | 60 typedef struct Mutex Mutex; |
61 typedef struct M M; | 61 typedef struct M M; |
62 typedef struct P P; | 62 typedef struct P P; |
| 63 typedef struct SchedT SchedT; |
63 typedef struct Note Note; | 64 typedef struct Note Note; |
64 typedef struct Slice Slice; | 65 typedef struct Slice Slice; |
65 typedef struct String String; | 66 typedef struct String String; |
66 typedef struct FuncVal FuncVal; | 67 typedef struct FuncVal FuncVal; |
67 typedef struct SigTab SigTab; | 68 typedef struct SigTab SigTab; |
68 typedef struct MCache MCache; | 69 typedef struct MCache MCache; |
69 typedef struct FixAlloc FixAlloc; | 70 typedef struct FixAlloc FixAlloc; |
70 typedef struct Iface Iface; | 71 typedef struct Iface Iface; |
71 typedef struct Itab Itab; | 72 typedef struct Itab Itab; |
72 typedef struct InterfaceType InterfaceType; | 73 typedef struct InterfaceType InterfaceType; |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 427 |
427 byte pad[64]; | 428 byte pad[64]; |
428 }; | 429 }; |
429 | 430 |
430 enum { | 431 enum { |
431 // The max value of GOMAXPROCS. | 432 // The max value of GOMAXPROCS. |
432 // There are no fundamental restrictions on the value. | 433 // There are no fundamental restrictions on the value. |
433 MaxGomaxprocs = 1<<8, | 434 MaxGomaxprocs = 1<<8, |
434 }; | 435 }; |
435 | 436 |
| 437 struct SchedT |
| 438 { |
| 439 Mutex lock; |
| 440 |
| 441 uint64 goidgen; |
| 442 |
| 443 M* midle; // idle m's waiting for work |
| 444 int32 nmidle; // number of idle m's waiting for work |
| 445 int32 nmidlelocked; // number of locked m's waiting for work |
| 446 int32 mcount; // number of m's that have been created |
| 447 int32 maxmcount; // maximum number of m's allowed (or die) |
| 448 |
| 449 P* pidle; // idle P's |
| 450 uint32 npidle; |
| 451 uint32 nmspinning; |
| 452 |
| 453 // Global runnable queue. |
| 454 G* runqhead; |
| 455 G* runqtail; |
| 456 int32 runqsize; |
| 457 |
| 458 // Global cache of dead G's. |
| 459 Mutex gflock; |
| 460 G* gfree; |
| 461 int32 ngfree; |
| 462 |
| 463 uint32 gcwaiting; // gc is waiting to run |
| 464 int32 stopwait; |
| 465 Note stopnote; |
| 466 uint32 sysmonwait; |
| 467 Note sysmonnote; |
| 468 uint64 lastpoll; |
| 469 |
| 470 int32 profilehz; // cpu profiling rate |
| 471 }; |
| 472 |
436 // The m->locked word holds two pieces of state counting active calls to LockOST
hread/lockOSThread. | 473 // The m->locked word holds two pieces of state counting active calls to LockOST
hread/lockOSThread. |
437 // The low bit (LockExternal) is a boolean reporting whether any LockOSThread ca
ll is active. | 474 // The low bit (LockExternal) is a boolean reporting whether any LockOSThread ca
ll is active. |
438 // External locks are not recursive; a second lock is silently ignored. | 475 // External locks are not recursive; a second lock is silently ignored. |
439 // The upper bits of m->lockedcount record the nesting depth of calls to lockOST
hread | 476 // The upper bits of m->lockedcount record the nesting depth of calls to lockOST
hread |
440 // (counting up by LockInternal), popped by unlockOSThread (counting down by Loc
kInternal). | 477 // (counting up by LockInternal), popped by unlockOSThread (counting down by Loc
kInternal). |
441 // Internal locks can be recursive. For instance, a lock for cgo can occur while
the main | 478 // Internal locks can be recursive. For instance, a lock for cgo can occur while
the main |
442 // goroutine is holding the lock during the initialization phase. | 479 // goroutine is holding the lock during the initialization phase. |
443 enum | 480 enum |
444 { | 481 { |
445 LockExternal = 1, | 482 LockExternal = 1, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 bool runtime·stopg(G*); | 668 bool runtime·stopg(G*); |
632 void runtime·restartg(G*); | 669 void runtime·restartg(G*); |
633 void runtime·gcphasework(G*); | 670 void runtime·gcphasework(G*); |
634 | 671 |
635 /* | 672 /* |
636 * deferred subroutine calls | 673 * deferred subroutine calls |
637 */ | 674 */ |
638 struct Defer | 675 struct Defer |
639 { | 676 { |
640 int32 siz; | 677 int32 siz; |
641 » bool» special;» // not part of defer frame | 678 » bool» started; |
642 uintptr argp; // where args were copied from | 679 uintptr argp; // where args were copied from |
643 uintptr pc; | 680 uintptr pc; |
644 FuncVal* fn; | 681 FuncVal* fn; |
| 682 Panic* panic; // panic that is running defer |
645 Defer* link; | 683 Defer* link; |
646 void* args[1]; // padded to actual size | |
647 }; | 684 }; |
648 | 685 |
649 // argp used in Defer structs when there is no argp. | 686 // argp used in Defer structs when there is no argp. |
650 #define NoArgs ((uintptr)-1) | 687 #define NoArgs ((uintptr)-1) |
651 | 688 |
652 /* | 689 /* |
653 * panics | 690 * panics |
654 */ | 691 */ |
655 struct Panic | 692 struct Panic |
656 { | 693 { |
657 void* argp; // pointer to arguments of deferred call run during pani
c; cannot move - known to liblink | 694 void* argp; // pointer to arguments of deferred call run during pani
c; cannot move - known to liblink |
658 Eface arg; // argument to panic | 695 Eface arg; // argument to panic |
659 Panic* link; // link to earlier panic | 696 Panic* link; // link to earlier panic |
660 Defer* defer; // current executing defer | |
661 bool recovered; // whether this panic is over | 697 bool recovered; // whether this panic is over |
662 bool aborted; // the panic was aborted | 698 bool aborted; // the panic was aborted |
663 }; | 699 }; |
664 | 700 |
665 /* | 701 /* |
666 * stack traces | 702 * stack traces |
667 */ | 703 */ |
668 typedef struct Stkframe Stkframe; | 704 typedef struct Stkframe Stkframe; |
669 typedef struct BitVector BitVector; | 705 typedef struct BitVector BitVector; |
670 struct Stkframe | 706 struct Stkframe |
(...skipping 19 matching lines...) Expand all Loading... |
690 enum | 726 enum |
691 { | 727 { |
692 // The maximum number of frames we print for a traceback | 728 // The maximum number of frames we print for a traceback |
693 TracebackMaxFrames = 100, | 729 TracebackMaxFrames = 100, |
694 }; | 730 }; |
695 | 731 |
696 /* | 732 /* |
697 * external data | 733 * external data |
698 */ | 734 */ |
699 extern String runtime·emptystring; | 735 extern String runtime·emptystring; |
700 extern uintptr runtime·zerobase; | |
701 extern G** runtime·allg; | 736 extern G** runtime·allg; |
702 extern Slice runtime·allgs; // []*G | 737 extern Slice runtime·allgs; // []*G |
703 extern uintptr runtime·allglen; | 738 extern uintptr runtime·allglen; |
704 extern G* runtime·lastg; | 739 extern G* runtime·lastg; |
705 extern M* runtime·allm; | 740 extern M* runtime·allm; |
706 extern P* runtime·allp[MaxGomaxprocs+1]; | 741 extern P* runtime·allp[MaxGomaxprocs+1]; |
707 extern int32 runtime·gomaxprocs; | 742 extern int32 runtime·gomaxprocs; |
708 extern uint32 runtime·needextram; | 743 extern uint32 runtime·needextram; |
709 extern uint32 runtime·panicking; | 744 extern uint32 runtime·panicking; |
710 extern int8* runtime·goos; | 745 extern int8* runtime·goos; |
711 extern int32 runtime·ncpu; | 746 extern int32 runtime·ncpu; |
712 extern bool runtime·iscgo; | 747 extern bool runtime·iscgo; |
713 extern void (*runtime·sysargs)(int32, uint8**); | 748 extern void (*runtime·sysargs)(int32, uint8**); |
714 extern uintptr runtime·maxstring; | 749 extern uintptr runtime·maxstring; |
715 extern uint32 runtime·cpuid_ecx; | 750 extern uint32 runtime·cpuid_ecx; |
716 extern uint32 runtime·cpuid_edx; | 751 extern uint32 runtime·cpuid_edx; |
717 extern DebugVars runtime·debug; | 752 extern DebugVars runtime·debug; |
718 extern uintptr runtime·maxstacksize; | 753 extern uintptr runtime·maxstacksize; |
719 extern Note runtime·signote; | 754 extern Note runtime·signote; |
720 extern ForceGCState runtime·forcegc; | 755 extern ForceGCState runtime·forcegc; |
| 756 extern SchedT runtime·sched; |
| 757 extern int32 runtime·newprocs; |
721 | 758 |
722 /* | 759 /* |
723 * common functions and data | 760 * common functions and data |
724 */ | 761 */ |
725 int32 runtime·strcmp(byte*, byte*); | 762 int32 runtime·strcmp(byte*, byte*); |
726 int32 runtime·strncmp(byte*, byte*, uintptr); | 763 int32 runtime·strncmp(byte*, byte*, uintptr); |
727 byte* runtime·strstr(byte*, byte*); | 764 byte* runtime·strstr(byte*, byte*); |
728 intgo runtime·findnull(byte*); | 765 intgo runtime·findnull(byte*); |
729 intgo runtime·findnullw(uint16*); | 766 intgo runtime·findnullw(uint16*); |
730 void runtime·dump(byte*, int32); | 767 void runtime·dump(byte*, int32); |
(...skipping 29 matching lines...) Expand all Loading... |
760 | 797 |
761 void runtime·gogo(Gobuf*); | 798 void runtime·gogo(Gobuf*); |
762 void runtime·gostartcall(Gobuf*, void(*)(void), void*); | 799 void runtime·gostartcall(Gobuf*, void(*)(void), void*); |
763 void runtime·gostartcallfn(Gobuf*, FuncVal*); | 800 void runtime·gostartcallfn(Gobuf*, FuncVal*); |
764 void runtime·gosave(Gobuf*); | 801 void runtime·gosave(Gobuf*); |
765 void runtime·goargs(void); | 802 void runtime·goargs(void); |
766 void runtime·goenvs(void); | 803 void runtime·goenvs(void); |
767 void runtime·goenvs_unix(void); | 804 void runtime·goenvs_unix(void); |
768 void* runtime·getu(void); | 805 void* runtime·getu(void); |
769 void runtime·throw(int8*); | 806 void runtime·throw(int8*); |
770 void runtime·panicstring(int8*); | |
771 bool runtime·canpanic(G*); | 807 bool runtime·canpanic(G*); |
772 void runtime·prints(int8*); | 808 void runtime·prints(int8*); |
773 void runtime·printf(int8*, ...); | 809 void runtime·printf(int8*, ...); |
774 void runtime·snprintf(byte*, int32, int8*, ...); | 810 void runtime·snprintf(byte*, int32, int8*, ...); |
775 byte* runtime·mchr(byte*, byte, byte*); | 811 byte* runtime·mchr(byte*, byte, byte*); |
776 int32 runtime·mcmp(byte*, byte*, uintptr); | 812 int32 runtime·mcmp(byte*, byte*, uintptr); |
777 void runtime·memmove(void*, void*, uintptr); | 813 void runtime·memmove(void*, void*, uintptr); |
778 String runtime·catstring(String, String); | 814 String runtime·catstring(String, String); |
779 String runtime·gostring(byte*); | 815 String runtime·gostring(byte*); |
780 Slice runtime·makeStringSlice(intgo); | 816 Slice runtime·makeStringSlice(intgo); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 void runtime·gopanic(Eface); | 1056 void runtime·gopanic(Eface); |
1021 void runtime·panicindex(void); | 1057 void runtime·panicindex(void); |
1022 void runtime·panicslice(void); | 1058 void runtime·panicslice(void); |
1023 void runtime·panicdivide(void); | 1059 void runtime·panicdivide(void); |
1024 | 1060 |
1025 /* | 1061 /* |
1026 * runtime c-called (but written in Go) | 1062 * runtime c-called (but written in Go) |
1027 */ | 1063 */ |
1028 void runtime·printany(Eface); | 1064 void runtime·printany(Eface); |
1029 void runtime·newTypeAssertionError(String*, String*, String*, String*, Eface*
); | 1065 void runtime·newTypeAssertionError(String*, String*, String*, String*, Eface*
); |
1030 void runtime·newErrorString(String, Eface*); | |
1031 void runtime·newErrorCString(int8*, Eface*); | |
1032 void runtime·fadd64c(uint64, uint64, uint64*); | 1066 void runtime·fadd64c(uint64, uint64, uint64*); |
1033 void runtime·fsub64c(uint64, uint64, uint64*); | 1067 void runtime·fsub64c(uint64, uint64, uint64*); |
1034 void runtime·fmul64c(uint64, uint64, uint64*); | 1068 void runtime·fmul64c(uint64, uint64, uint64*); |
1035 void runtime·fdiv64c(uint64, uint64, uint64*); | 1069 void runtime·fdiv64c(uint64, uint64, uint64*); |
1036 void runtime·fneg64c(uint64, uint64*); | 1070 void runtime·fneg64c(uint64, uint64*); |
1037 void runtime·f32to64c(uint32, uint64*); | 1071 void runtime·f32to64c(uint32, uint64*); |
1038 void runtime·f64to32c(uint64, uint32*); | 1072 void runtime·f64to32c(uint64, uint32*); |
1039 void runtime·fcmp64c(uint64, uint64, int32*, bool*); | 1073 void runtime·fcmp64c(uint64, uint64, int32*, bool*); |
1040 void runtime·fintto64c(int64, uint64*); | 1074 void runtime·fintto64c(int64, uint64*); |
1041 void runtime·f64tointc(uint64, int64*, bool*); | 1075 void runtime·f64tointc(uint64, int64*, bool*); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 extern float64 runtime·neginf; | 1109 extern float64 runtime·neginf; |
1076 extern uint64 ·nan; | 1110 extern uint64 ·nan; |
1077 extern uint64 ·posinf; | 1111 extern uint64 ·posinf; |
1078 extern uint64 ·neginf; | 1112 extern uint64 ·neginf; |
1079 #define ISNAN(f) ((f) != (f)) | 1113 #define ISNAN(f) ((f) != (f)) |
1080 | 1114 |
1081 enum | 1115 enum |
1082 { | 1116 { |
1083 UseSpanType = 1, | 1117 UseSpanType = 1, |
1084 }; | 1118 }; |
LEFT | RIGHT |