gcprog

package standard library
go1.27.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gcprog implements an encoder for packed GC pointer bitmaps, known as GC programs.

Program Format

The GC program encodes a sequence of 0 and 1 bits indicating scalar or pointer words in an object. The encoding is a simple Lempel-Ziv program, with codes to emit literal bits and to repeat the last n bits c times.

The possible codes are:

00000000: stop
0nnnnnnn: emit n bits copied from the next (n+7)/8 bytes, least significant bit first
10000000 n c: repeat the previous n bits c times; n, c are varints
1nnnnnnn c: repeat the previous n bits c times; c is a varint

The numbers n and c, when they follow a code, are encoded as varints using the same encoding as encoding/binary's Uvarint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

A Writer is an encoder for GC programs.

The typical use of a Writer is to call Init, maybe call Debug, make a sequence of Ptr, Advance, Repeat, and Append calls to describe the data type, and then finally call End.

func (*Writer) Debug

func (w *Writer) Debug(out io.Writer)

Debug causes the writer to print a debugging trace to out during future calls to methods like Ptr, Advance, and End. It also enables debugging checks during the encoding.

func (*Writer) End

func (w *Writer) End()

End marks the end of the program, writing any remaining bytes.

func (*Writer) Init

func (w *Writer) Init(writeByte func(byte))

Init initializes w to write a new GC program by calling writeByte for each byte in the program.

func (*Writer) Ptr

func (w *Writer) Ptr(index int64)

Ptr emits a 1 into the bit stream at the given bit index. that is, it records that the index'th word in the object memory is a pointer. Any bits between the current index and the new index are set to zero, meaning the corresponding words are scalars.

func (*Writer) Repeat

func (w *Writer) Repeat(n, c int64)

Repeat emits an instruction to repeat the description of the last n words c times (including the initial description, c+1 times in total).

func (*Writer) ZeroUntil

func (w *Writer) ZeroUntil(index int64)

ZeroUntil adds zeros to the bit stream until reaching the given index; that is, it records that the words from the most recent pointer until the index'th word are scalars. ZeroUntil is usually called in preparation for a call to Repeat, Append, or End.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL