Skip to content

Instantly share code, notes, and snippets.

@Keno
Created January 6, 2026 21:21
Show Gist options
  • Select an option

  • Save Keno/ddc921002a9c60effec58687dd15773d to your computer and use it in GitHub Desktop.

Select an option

Save Keno/ddc921002a9c60effec58687dd15773d to your computer and use it in GitHub Desktop.
primitive type AddrSpace{Backend} 8 end
const CPU = Core.bitcast(AddrSpace{Core}, 0x00)
recursive type (
# Core type metadata cycle
DataType, TypeName, MethodCache, MethodTable,
# Module/Binding cycle
Module, BindingPartition, Binding, GlobalRef,
# Memory/Array (GenericMemoryRef -> GenericMemory, Array -> GenericMemoryRef)
GenericMemory, GenericMemoryRef, Array,
# Method cycle
Method, MethodInstance, CodeInstance, DebugInfo,
# Self-referential
TypeMapEntry
)
abstract type Any end
# === Primitives (opaque, but referenced by others) ===
primitive type Symbol <: Any 0 end
mutable struct SimpleVector <: Any end
abstract type Type{T} <: Any end
# === Core type metadata cycle ===
# DataType <-> TypeName <-> MethodCache <-> MethodTable <-> Module
mutable struct DataType <: Any
const name::TypeName
const super::DataType
const parameters::SimpleVector
@atomic types::SimpleVector
@atomic instance::Any
@atomic layout::Any
const hash::Int32
flags::UInt16
end
mutable struct TypeName <: Any
const name::Symbol
const var"module"::Module
const singletonname::Symbol
const names::SimpleVector
const atomicfields::Any
const constfields::Any
wrapper::Type
Typeofwrapper::SimpleVector
cache::SimpleVector
@atomic linearcache::MethodCache
partial::Any
@atomic hash::Int
@atomic max_args::Int32
n_uninitialized::Int32
flags::UInt8
@atomic cache_entry_count::UInt8
@atomic max_methods::UInt8
@atomic constprop_heuristic::UInt8
end
mutable struct MethodCache <: Any
@atomic leafcache::GenericMemory{:not_atomic, Any, CPU}
@atomic cache::Any
@atomic reserved1::Any
@atomic reserved2::Int32
end
mutable struct MethodTable <: Any
@atomic defs::Any
cache::MethodCache
const name::Symbol
const var"module"::Module
const backedges::GenericMemory{:not_atomic, Any, CPU}
end
# === Module/Binding cycle ===
# Module <-> Binding <-> BindingPartition, GlobalRef
mutable struct Module <: Any end
mutable struct BindingPartition <: Any
const restriction::Any
@atomic min_world::UInt
@atomic max_world::UInt
@atomic next::Union{Nothing, BindingPartition}
const kind::UInt
end
mutable struct Binding <: Any
const globalref::GlobalRef
@atomic value::Any
@atomic partitions::BindingPartition
backedges::Any
@atomic flags::UInt8
end
struct GlobalRef <: Any
const mod::Module
const name::Symbol
const binding::Binding
end
# === Memory/Array cycle ===
# GenericMemory <-> GenericMemoryRef <-> Array
# (Referenced by MethodCache, MethodTable above)
abstract type AbstractArray{T, N} <: Any end
abstract type DenseArray{T, N} <: AbstractArray{T, N} end
mutable struct GenericMemory{isatomic, T, addrspace} <: DenseArray{T, 1}
const length::Int
const ptr::Ptr{Cvoid}
end
struct GenericMemoryRef{isatomic, T, addrspace} <: Any
ptr_or_offset::Ptr{Cvoid}
mem::GenericMemory{isatomic, T, addrspace}
end
mutable struct Array{T, N} <: DenseArray{T, N}
ref::GenericMemoryRef{:not_atomic, T, CPU}
size::NTuple{N, Int}
end
# === Method/MethodInstance/CodeInstance cycle ===
mutable struct Method <: Any
const name::Symbol
const var"module"::Module
const file::Symbol
const line::Int32
const primary_world::UInt
@atomic deleted_world::UInt
const sig::Type
@atomic specializations::Any
const slot_syms::String
const external_mt::Any
const source::Any
const debuginfo::DebugInfo
@atomic unspecialized::Union{Nothing, MethodInstance}
const generator::Any
const roots::Any
const root_blocks::Any
@atomic nroots_sysimg::Int32
const ccallable::Any
const invokes::Any
@atomic recursion_relation::Any
nargs::Int32
const called::Int32
const nospecialize::Int32
nkw::Int32
const isva::Bool
const is_for_opaque_closure::Bool
const nospecializeinfer::Bool
const constprop::UInt8
@atomic max_varargs::UInt8
@atomic purity::UInt16
end
mutable struct MethodInstance <: Any
def::Union{Method, Module}
specTypes::Any
sparam_vals::SimpleVector
@atomic backedges::Any
@atomic cache::CodeInstance
@atomic cache_with_orig::Any
@atomic precompiled::UInt8
end
mutable struct CodeInstance <: Any
const def::MethodInstance
const owner::Any
@atomic next::Union{Nothing, CodeInstance}
const min_world::UInt
@atomic max_world::UInt
@atomic rettype::Any
@atomic exctype::Any
rettype_const::Any
@atomic inferred::Any
@atomic edges::SimpleVector
@atomic debuginfo::DebugInfo
@atomic ipo_purity_bits::UInt32
@atomic purity_bits::UInt32
const isspecsig::UInt8
@atomic precompile::Bool
@atomic time_compile::UInt64
@atomic time_infer_total::UInt64
@atomic time_infer_self::UInt64
relocatability::UInt8
end
# === DebugInfo (self-referential, also referenced by Method/CodeInstance) ===
mutable struct DebugInfo <: Any
const def::Any
const linetable::Union{Nothing, DebugInfo}
const edges::SimpleVector
const codelocs::String
end
# === TypeMap (references Type, SimpleVector) ===
mutable struct TypeMapEntry <: Any
@atomic next::Union{Nothing, TypeMapEntry}
const sig::Type
const simplesig::Any
const guardsigs::SimpleVector
@atomic min_world::UInt
@atomic max_world::UInt
const func::Any
const isleafsig::Bool
const issimplesig::Bool
const va::Bool
end
end # recursive type (...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment