github.com/primecitizens/pcz/std@v0.2.1/runtime/todo.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  //go:build pcz
     5  
     6  package runtime
     7  
     8  import (
     9  	"github.com/primecitizens/pcz/std/core/arch"
    10  	"github.com/primecitizens/pcz/std/core/assert"
    11  )
    12  
    13  // TODO
    14  
    15  // TODO(alloc): standardize allocation size like go sizeclass?
    16  func roundupsize(sz uintptr) uintptr {
    17  	return sz
    18  }
    19  
    20  // bulkBarrierPreWriteSrcOnly is like bulkBarrierPreWrite but
    21  // does not execute write barriers for [dst, dst+size).
    22  //
    23  // In addition to the requirements of bulkBarrierPreWrite
    24  // callers need to ensure [dst, dst+size) is zeroed.
    25  //
    26  // This is used for special cases where e.g. dst was just
    27  // created and zeroed with malloc.
    28  //
    29  // See ${GOROOT}/src/runtime/mbitmap.go#func:bulkBarrierPreWriteSrcOnly
    30  //
    31  //go:nosplit
    32  func bulkBarrierPreWriteSrcOnly(dst, src, size uintptr) {
    33  	if (dst|src|size)&(arch.PtrSize-1) != 0 {
    34  		assert.Throw("bulkBarrierPreWrite:", "unaligned", "arguments")
    35  	}
    36  	if !writeBarrier.needed {
    37  		return
    38  	}
    39  
    40  	// TODO
    41  }
    42  
    43  // bulkBarrierPreWrite executes a write barrier
    44  // for every pointer slot in the memory range [src, src+size),
    45  // using pointer/scalar information from [dst, dst+size).
    46  // This executes the write barriers necessary before a memmove.
    47  // src, dst, and size must be pointer-aligned.
    48  // The range [dst, dst+size) must lie within a single object.
    49  // It does not perform the actual writes.
    50  //
    51  // As a special case, src == 0 indicates that this is being used for a
    52  // memclr. bulkBarrierPreWrite will pass 0 for the src of each write
    53  // barrier.
    54  //
    55  // Callers should call bulkBarrierPreWrite immediately before
    56  // calling memmove(dst, src, size). This function is marked nosplit
    57  // to avoid being preempted; the GC must not stop the goroutine
    58  // between the memmove and the execution of the barriers.
    59  // The caller is also responsible for cgo pointer checks if this
    60  // may be writing Go pointers into non-Go memory.
    61  //
    62  // The pointer bitmap is not maintained for allocations containing
    63  // no pointers at all; any caller of bulkBarrierPreWrite must first
    64  // make sure the underlying allocation contains pointers, usually
    65  // by checking typ.PtrBytes.
    66  //
    67  // Callers must perform cgo checks if goexperiment.CgoCheck2.
    68  //
    69  // See ${GOROOT}/src/runtime/mbitmap.go#func:bulkBarrierPreWrite
    70  //
    71  //go:nosplit
    72  func bulkBarrierPreWrite(dst, src, size uintptr) {
    73  	if (dst|src|size)&(arch.PtrSize-1) != 0 {
    74  		assert.Throw("bulkBarrierPreWrite:", "unaligned", "arguments")
    75  	}
    76  
    77  	if !writeBarrier.needed {
    78  		return
    79  	}
    80  
    81  	// TODO
    82  }