• Kirill Smelkov's avatar
    tracing/runtime: Add support for Go1.14 (preliminary) · 5f6ae15b
    Kirill Smelkov authored
    Generate g for ~ Go 1.14beta1 (go1.14beta1-10-g5c6f42773c)
    Compared to Go1.13 there are several changed to g, _defer and timer
    related to:
    
    - non-cooperative preemption (https://golang.org/issue/10958, https://golang.org/issue/24543);
    - inlined defers (https://golang.org/issue/14939, https://golang.org/issue/34481);
    - timers rework to be integrated with network poller (https://golang.org/issue/6239, https://golang.org/issue/27707):
    
    Regenerated files stay without changes for Go1.13 and previous releases.
    
    ---- 8< ----
    diff --git a/zruntime_g_go1.13.go b/zruntime_g_go1.14.go
    index 76851fd..19cebae 100644
    --- a/zruntime_g_go1.13.go
    +++ b/zruntime_g_go1.14.go
    @@ -1,6 +1,6 @@
     // Code generated by g_typedef; DO NOT EDIT.
    
    -// +build go1.13,!go1.14
    +// +build go1.14,!go1.15
    
     package xruntime
    
    @@ -32,12 +32,25 @@ type g struct {
     	schedlink    guintptr
     	waitsince    int64      // approx time when the g become blocked
     	waitreason   waitReason // if status==Gwaiting
    +
     	preempt       bool // preemption signal, duplicates stackguard0 = stackpreempt
    +	preemptStop   bool // transition to _Gpreempted on preemption; otherwise, just deschedule
    +	preemptShrink bool // shrink stack at synchronous safe point
    +
    +	// asyncSafePoint is set if g is stopped at an asynchronous
    +	// safe point. This means there are frames on the stack
    +	// without precise pointer information.
    +	asyncSafePoint bool
    +
     	paniconfault bool // panic (instead of crash) on unexpected fault address
    -	preemptscan    bool       // preempted g does scan for gc
     	gcscandone   bool // g has scanned stack; protected by _Gscan bit in status
    -	gcscanvalid    bool       // false at start of gc cycle, true if G has not run since last scan; TODO: remove?
     	throwsplit   bool // must not split stack
    +	// activeStackChans indicates that there are unlocked channels
    +	// pointing into this goroutine's stack. If true, stack
    +	// copying needs to acquire channel locks to protect these
    +	// areas of the stack.
    +	activeStackChans bool
    +
     	raceignore     int8     // ignore race detection events
     	sysblocktraced bool     // StartTrace has emitted EvGoInSyscall about this goroutine
     	sysexitticks   int64    // cputicks when syscall has returned (for tracing)
    @@ -76,18 +89,37 @@ type _panic struct {
     	argp      unsafe.Pointer // pointer to arguments of deferred call run during panic; cannot move - known to liblink
     	arg       interface{}    // argument to panic
     	link      *_panic        // link to earlier panic
    +	pc        uintptr        // where to return to in runtime if this panic is bypassed
    +	sp        unsafe.Pointer // where to return to in runtime if this panic is bypassed
     	recovered bool           // whether this panic is over
     	aborted   bool           // the panic was aborted
    +	goexit    bool
     }
     type _defer struct {
     	siz     int32 // includes both arguments and results
     	started bool
     	heap    bool
    +	// openDefer indicates that this _defer is for a frame with open-coded
    +	// defers. We have only one defer record for the entire frame (which may
    +	// currently have 0, 1, or more defers active).
    +	openDefer bool
     	sp        uintptr  // sp at time of defer
    -	pc      uintptr
    -	fn      *funcval
    +	pc        uintptr  // pc at time of defer
    +	fn        *funcval // can be nil for open-coded defers
     	_panic    *_panic  // panic that is running defer
     	link      *_defer
    +
    +	// If openDefer is true, the fields below record values about the stack
    +	// frame and associated function that has the open-coded defer(s). sp
    +	// above will be the sp for the frame, and pc will be address of the
    +	// deferreturn call in the function.
    +	fd   unsafe.Pointer // funcdata for the function associated with the frame
    +	varp uintptr        // value of varp for the stack frame
    +	// framepc is the current pc associated with the stack frame. Together,
    +	// with sp above (which is the sp associated with the stack frame),
    +	// framepc/sp can be used as pc/sp pair to continue a stack trace via
    +	// gentraceback().
    +	framepc uintptr
     }
     type gobuf struct {
     	// The offsets of sp, pc, and g are known to (hard-coded in) libmach.
    @@ -114,8 +146,10 @@ type funcval struct {
     	fn uintptr
     }
     type timer struct {
    -	tb *timersBucket // the bucket the timer lives in
    -	i  int           // heap index
    +	// If this timer is on a heap, which P's heap it is on.
    +	// puintptr rather than *p to match uintptr in the versions
    +	// of this struct defined in other packages.
    +	pp puintptr
    
     	// Timer wakes up at when, and then at when+period, ... (period > 0 only)
     	// each time calling f(arg, now) in the timer goroutine, so f must be
    @@ -125,6 +159,12 @@ type timer struct {
     	f      func(interface{}, uintptr)
     	arg    interface{}
     	seq    uintptr
    +
    +	// What to set the when field to in timerModifiedXX status.
    +	nextwhen int64
    +
    +	// The status field holds one of the values below.
    +	status uint32
     }
     type guintptr uintptr
     type puintptr uintptr
    5f6ae15b
zruntime_g_go1.14.go 7.48 KB