Source file src/runtime/export_wasmx_test.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build wasm || wasm32
     6  
     7  package runtime
     8  
     9  var SysReserveAlignedSbrk = sysReserveAlignedSbrk
    10  
    11  // GCAssistUpdatesLimiter must be called with GC disabled. On WebAssembly
    12  // there is no sysmon to update the limiter between setup and the assist.
    13  func GCAssistUpdatesLimiter() bool {
    14  	gcCPULimiter.update(nanotime())
    15  	fill := gcCPULimiter.bucket.fill
    16  	enabled := gcCPULimiter.enabled.Load()
    17  	lastUpdate := gcCPULimiter.lastUpdate.Load()
    18  	defer func() {
    19  		gcCPULimiter.bucket.fill = fill
    20  		gcCPULimiter.enabled.Store(enabled)
    21  		gcCPULimiter.lastUpdate.Store(lastUpdate)
    22  	}()
    23  	before := nanotime() - gcCPULimiterUpdatePeriod - 1
    24  	gcCPULimiter.bucket.fill = gcCPULimiter.bucket.capacity
    25  	gcCPULimiter.lastUpdate.Store(before)
    26  	gcCPULimiter.enabled.Store(true)
    27  	gp := getg()
    28  	debt := gp.gcAssistBytes
    29  	gp.gcAssistBytes = 0
    30  	gcAssistAlloc(gp)
    31  	gp.gcAssistBytes = debt
    32  	return gcCPULimiter.lastUpdate.Load() != before && !gcCPULimiter.limiting()
    33  }
    34  

View as plain text