Skip to content

Runtime boundary

What the interpreter has to provide below Base: 93 intrinsics and 63 builtins in julia 1.12.6, 896 ccall sites by target, regex and FFT. The counts.

Status: planned (milestones M3 to M5); M3 is in progress. This page counts what Julia’s Base asks of its runtime, and says which fleet library is meant to answer each part. Of it, only the type system is implemented so far: the core package (v0.3.0) holds Julia’s type objects, apply_type and subtyping.

Intrinsics: 93 in julia 1.12.6

julia 1.12.6, the release the port follows, has 93 intrinsics. The breakdown below is the bibliography’s, counted on julia 1.15-DEV sources, which have 94: 81 ADD_I, 12 ALIAS and 1 ADD_HIDDEN in src/intrinsics.h. By group (1.15-DEV):

GroupCount
wrap (bitcast)1
arithmetic17
fast arithmetic (aliases)7
comparisons15
bitwise11
conversion9
checked arithmetic10
functions (abs_float, copysign_float, sqrt_llvm, …)9
pointer arithmetic2
pointer access2
pointer atomics6
C interface (cglobal, llvmcall)2
CPU tests (have_fma, cpu_supports)2
hidden (cglobal_auto)1

All except llvmcall and the pointer group map to Go in a few lines each, with math/bits and math. Int128 needs a two-word type, and Float16 and BFloat16 are converted in software. muladd_float is computed as a fused multiply-add, and that choice is documented. pointerref, pointerset and the atomics work on the Go-side byte storage of Memory and Ref: there is no raw address space. llvmcall is not supported: Base has 0 llvmcall( sites.

Builtins: 63 in julia 1.12.6

julia 1.12.6 has 63 builtins; the bibliography counted 83 on julia 1.15-DEV sources. From src/builtin_proto.h: getfield, setfield!, isa, ===, <:, apply_type, _apply_iterate, invoke, memorynew, the twelve memoryref*, the fourteen *global*, _structtype, _typebody! and the rest. Each is one Go function.

ccall and @ccall in base/: 896 call sites in 202 files

856 ccall and 40 @ccall, plus 24 cglobal(. By target:

TargetSitesGo implementation
Julia runtime jl_*, ios_*524 (387 unique names)is the Go runtime: reflection, IdDict, strings, files, GC; no-ops or errors for compiler, precompile and CPU-feature calls
libc and OS symbols88Go os, syscall and time; memcpy and friends on Go slices; malloc and free on a Go arena
MPFR81 static, plus 29 generatedgo-bignum’s bigfloat and math/big.Float; mpfr_asprintf and mpfr_snprintf need a Go formatter
libuv uv_*78Go os, os/exec, net and time.Timer; the event loop becomes goroutines that wake the scheduler
GMP40 named, plus 3 interpolatedmath/big.Int and big.Rat, following GMP’s truncating, floor and ceiling rounding for quotients; go-bignum for factorial and binomial
other dynamic (pointer, @static, interpolated)7resolved case by case
PCRE218see Regex below
utf8proc15Go unicode and golang.org/x/text/unicode/norm; width and grapheme tables generated from the Unicode version pinned by utf8proc
Windows-only and macOS libproc13not on WebAssembly; GOOS=windows later
libm0nothing: Base’s elementary functions are written in Julia over intrinsics, so results are bit-identical by construction

The standard libraries read (Random, Dates, Printf, Statistics) have 14 sites: 7 on libdSFMT in Random (the MersenneTwister generator; the default Xoshiro is pure Julia), 3 on MPFR (mpfr_snprintf in Printf, two mpfr_sub_* in Random), 1 on libuv in Dates, and 1 on the runtime. Statistics has 0.

LinearAlgebra: 194 sites

182 call BLAS or LAPACK through libblastrampoline, inside loops over element types (blas.jl 38, lapack.jl 144: 105 distinct callee expressions), 9 sites over 8 lbt_* names, and 3 sysctlbyname. The mapping is to implement the Fortran BLAS and LAPACK interface of each routine family as Go functions over go-ndarray’s linalg (LU, QR, Cholesky, SVD, Eig, Eigh and least squares exist there), on the column-major Memory{Float64} buffer a Julia Matrix owns, without copying. Families go-ndarray lacks (generalized Schur, banded and tridiagonal factorisations, Bunch-Kaufman) are missing kernels to add to go-ndarray, not to the VM.

Regex

base/regex.jl has PCRE2 semantics. The fleet’s engine is go-ruby-regexp, a pure-Go backtracking VM reimplementing Onigmo. PCRE2 and Onigmo differ in syntax corners (\K, (*VERB)s, callouts, variable-length lookbehind, \h, option letters). The plan is a PCRE2 syntax front end that compiles to the same VM, with test/regex.jl as the oracle and the 18 pcre2_* names implemented on it. If the VM cannot take a construct, the interpreter raises Julia’s ErrorException("PCRE compilation error: …") rather than match differently.

FFT

Julia’s Base and standard library have no FFT (no FFTW in base/, stdlib/ or deps/; FFTW.jl is a registry package). A go-julia-fftw package presenting the FFTW.jl and AbstractFFTs.jl API over go-fft is the port, and it is not part of the VM.

Naming of the packages around the VM

The plan’s naming mirrors go-embedded-ruby: go-embedded-julia/julia for the VM, with docs, the landing and brand; go-julia-<package> organisations for ports of Julia packages that are not part of the image’s standard library (FFTW, SparseArrays, DataFrames, Distributions, SpecialFunctions); and go-scikit/julia for the go-scikit bindings. A go-julia-* package is Julia code run by the VM plus Go kernels imported from the go-scikit libraries, never a second Go implementation of the same algorithm.

Created on by tannevaled

Modified on by tannevaled