<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 8.7 安全點分析 ## 回收的安全點 什么時候才能進行搶占呢?如何才能區分該搶占信號是運行時發出的還是用戶代碼發出的呢? TODO: TODO: 解釋執行棧映射補充寄存器映射,中斷信號 SIGURG ``` // wantAsyncPreempt 返回異步搶占是否被 gp 請求 func wantAsyncPreempt(gp *g) bool { // 同時檢查 G 和 P return (gp.preempt || gp.m.p != 0 &amp;&amp; gp.m.p.ptr().preempt) &amp;&amp; readgstatus(gp)&amp;^_Gscan == _Grunning } ``` 什么時候才是安全的異步搶占點呢? TODO: ``` func isAsyncSafePoint(gp *g, pc, sp, lr uintptr) bool { mp := gp.m // Only user Gs can have safe-points. We check this first // because it's extremely common that we'll catch mp in the // scheduler processing this G preemption. if mp.curg != gp { return false } // Check M state. if mp.p == 0|| !canPreemptM(mp) { return false } // Check stack space. if sp &lt; gp.stack.lo || sp-gp.stack.lo &lt; asyncPreemptStack { return false } // Check if PC is an unsafe-point. f := findfunc(pc) if !f.valid() { // Not Go code. return false } ... smi := pcdatavalue(f, _PCDATA_RegMapIndex, pc, nil) if smi == -2 { // Unsafe-point marked by compiler. This includes // atomic sequences (e.g., write barrier) and nosplit // functions (except at calls). return false } if fd := funcdata(f, _FUNCDATA_LocalsPointerMaps); fd == nil || fd == unsafe.Pointer(&amp;no_pointers_stackmap) { // This is assembly code. Don't assume it's // well-formed. We identify assembly code by // checking that it has either no stack map, or // no_pointers_stackmap, which is the stack map // for ones marked as NO_LOCAL_POINTERS. // // TODO: Are there cases that are safe but don't have a // locals pointer map, like empty frame functions? return false } if hasPrefix(funcname(f), "runtime.") || hasPrefix(funcname(f), "runtime/internal/") || hasPrefix(funcname(f), "reflect.") { // For now we never async preempt the runtime or // anything closely tied to the runtime. Known issues // include: various points in the scheduler ("don't // preempt between here and here"), much of the defer // implementation (untyped info on stack), bulk write // barriers (write barrier check), // reflect.{makeFuncStub,methodValueCall}. // // TODO(austin): We should improve this, or opt things // in incrementally. return false } return true } ``` #### 其他搶占觸發點 TODO: 一些 GC 的處理, suspendG preemptStop 會在什么時候被設置為搶占呢?GC。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看