locality

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 6 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 locality defines the source-level TLS and GLS declaration model. It intentionally has no dependency on LLGo's SSA or LLVM lowering layers.

Index

Constants

View Source
const (
	ThreadDirective    = "//llgointernal:tls"
	GoroutineDirective = "//llgointernal:gls"
	InitPrefix         = "__llgo_local_init_"
)

Variables

This section is empty.

Functions

func Directive

func Directive(kind Kind) string

Directive returns the source directive for kind.

func Prepare

func Prepare(fset *token.FileSet, pkgPath string, pkg *types.Package, typeInfo *types.Info, files []*ast.File, vars map[string]Info) (map[string]Info, error)

Prepare rewrites local package initializers into replayable synthetic functions and returns updated metadata. It is idempotent for repeated calls, including calls made by another compiler Program reusing the same syntax and types.Package objects.

func ValidateDoc

func ValidateDoc(fset *token.FileSet, doc *ast.CommentGroup) error

ValidateDoc rejects a locality directive outside a package-level var.

func ValidateFuncBody

func ValidateFuncBody(fset *token.FileSet, body *ast.BlockStmt) error

ValidateFuncBody rejects locality directives on declarations nested inside a function or function literal.

func ValidateNonPackageVar

func ValidateNonPackageVar(fset *token.FileSet, decl *ast.GenDecl) error

ValidateNonPackageVar rejects locality directives on declarations other than package-level vars, including grouped import/type/const specs.

func ValidatePrepared

func ValidatePrepared(pkgPath string, vars map[string]Info) error

ValidatePrepared verifies that every explicit local initializer was prepared before Go SSA construction.

Types

type Info

type Info struct {
	Locality       Kind
	HasInitializer bool
	InitFunc       string
	InitOrder      int
}

Info is the locality-specific part of a declaration's compiler metadata.

type Kind

type Kind uint8

Kind identifies the execution context that owns a package variable.

const (
	None Kind = iota
	Thread
	Goroutine
)

func FromDoc

func FromDoc(fset *token.FileSet, doc *ast.CommentGroup) (Kind, token.Pos, error)

FromDoc returns the locality directive attached to doc.

func Merge

func Merge(a, b Kind) (Kind, bool)

Merge combines declaration- and spec-level locality directives.

func Parse

func Parse(name string) (Kind, bool)

Parse converts the cache representation of a locality into a Kind.

func (Kind) String

func (kind Kind) String() string

type Variable

type Variable struct {
	Name string
	Info Info
}

Variable records locality metadata collected for one package variable.

func ScanPackageVar

func ScanPackageVar(fset *token.FileSet, decl *ast.GenDecl) ([]Variable, error)

ScanPackageVar validates and collects locality directives on a package-level var declaration.

Directories

Path Synopsis
Package layout plans the internal storage layout for one package's local variables.
Package layout plans the internal storage layout for one package's local variables.

Jump to

Keyboard shortcuts

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