Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ff06e8a
noun: fix validation, refcounts, and results in lagoon jets
sigilante Jul 7, 2026
77d508b
linter: init commit, file-level annotation
dozreg-toplud Jul 8, 2026
bbdfffe
linter: ifdef
dozreg-toplud Jul 8, 2026
95dbd76
jets: refcount fixes caught by a linter
dozreg-toplud Jul 8, 2026
3bf8a6d
linter: change grammar
dozreg-toplud Jul 8, 2026
fdefb51
linter: annotations
dozreg-toplud Jul 8, 2026
ca25705
jets: refcount fix
dozreg-toplud Jul 9, 2026
b5462df
linter: annotations, fixes
dozreg-toplud Jul 9, 2026
2ffeec4
jets: slaw fix
dozreg-toplud Jul 9, 2026
ee2afec
jets: fix slaw, loss
dozreg-toplud Jul 9, 2026
feaa216
jets: cleanup
dozreg-toplud Jul 9, 2026
ca6d99f
build: remove linter zig build step
dozreg-toplud Jul 9, 2026
8abe4f3
linter: annotations, fixes
dozreg-toplud Jul 9, 2026
ea20dad
jets: revert shax
dozreg-toplud Jul 22, 2026
2a2f573
linter: rust impl
dozreg-toplud Jul 30, 2026
701c2a8
linter: thread pool
dozreg-toplud Jul 30, 2026
91a9c36
linter: own abstract interp impl WIP
dozreg-toplud Jul 30, 2026
a0f4cb7
linter: formatting
dozreg-toplud Jul 30, 2026
4c69399
linter: wip
dozreg-toplud Aug 2, 2026
4ef1bb8
linter: wip
dozreg-toplud Aug 3, 2026
7ccf7ae
linter: wip
dozreg-toplud Aug 4, 2026
079e026
Merge branch 'ml/fix-compile-commands' into dozreg/refcount-check
dozreg-toplud Aug 6, 2026
fa35c16
linter: rewrite
dozreg-toplud Aug 6, 2026
9448aca
u3: refcount annotation fixes
dozreg-toplud Aug 6, 2026
9c5c451
linter: stricter UE defence
dozreg-toplud Aug 6, 2026
ff5b07d
jets: count references before slamming
dozreg-toplud Aug 6, 2026
0fef940
Merge branch 'sigilante/lagoon-check-fixes' into dozreg/refcount-check
dozreg-toplud Aug 6, 2026
5952447
linter: direct atom usage checks, fixes
dozreg-toplud Aug 6, 2026
e53400a
jets: refcount fixes, annotations
dozreg-toplud Aug 6, 2026
d854c96
linter: cleanup, readme
dozreg-toplud Aug 7, 2026
a67ba10
linter: clearer custom file annotation
dozreg-toplud Aug 7, 2026
e180c52
linter: precompiled headers
dozreg-toplud Aug 7, 2026
fff64b8
linter: u3_noun slot tracking, jet fixes
dozreg-toplud Aug 7, 2026
868d14e
Merge branch 'develop' into dozreg/refcount-check
dozreg-toplud Aug 7, 2026
8a021f5
Merge branch 'dozreg/deps-urls' into dozreg/refcount-check
dozreg-toplud Aug 7, 2026
1b4fc4b
linter: extend checks to pkg/vere
dozreg-toplud Aug 8, 2026
a0812e0
linter: lent product is always direct
dozreg-toplud Aug 8, 2026
fc28ae7
linter: more annotations, fixes
dozreg-toplud Aug 8, 2026
7830a5b
linter: assert refcount protocol for _mars_do_boot, undo "fix"
dozreg-toplud Aug 8, 2026
a3d88b3
Merge branch 'dozreg/deps-urls' into dozreg/refcount-check
dozreg-toplud Aug 8, 2026
ab29b66
linter: CI job
dozreg-toplud Aug 8, 2026
6839d2e
linter: CI job remove caching
dozreg-toplud Aug 8, 2026
3912275
linter: pin ibclang version
dozreg-toplud Aug 8, 2026
41c541b
lord: remove unnecessary u3z's
dozreg-toplud Aug 9, 2026
8fc16c4
jets: simplify code
dozreg-toplud Aug 9, 2026
4769b8f
linter: exclude data blobs, expand pch
dozreg-toplud Aug 9, 2026
4e40360
linter: polish, better annotations
dozreg-toplud Aug 12, 2026
bb89581
Merge branch 'develop' into dozreg/refcount-check
dozreg-toplud Aug 12, 2026
198cf03
linter: fix CI paths
dozreg-toplud Aug 12, 2026
ff5331c
linter: c3_l/c3_m might be indirect
dozreg-toplud Aug 12, 2026
e3fe85d
vere: use a struct instead of a cell for window size
dozreg-toplud Aug 12, 2026
ce3fb68
u3: naming convention
dozreg-toplud Aug 12, 2026
9de1ede
linter: track weakness
dozreg-toplud Aug 13, 2026
e6282b9
u3: refine u3_weak usage
dozreg-toplud Aug 13, 2026
1f25946
linter: join better, join more in loops
dozreg-toplud Aug 13, 2026
1de0409
linter: better ternary handling
dozreg-toplud Aug 13, 2026
1b19745
u3: fix u3_none bugs
dozreg-toplud Aug 13, 2026
f829694
linter: check non-noun functions too
dozreg-toplud Aug 13, 2026
3838d45
linter: fixes
dozreg-toplud Aug 13, 2026
82d80d5
u3: refcount annotations
dozreg-toplud Aug 13, 2026
fc428e9
u3: various fixes
dozreg-toplud Aug 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/refcount.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Refcount lint

on:
pull_request:
paths:
- 'build.zig'
- 'build.zig.zon'
- 'ext/**'
- '!ext/**.md'
- 'pkg/**'
- 'tools/refcount-check/**'
- '.github/workflows/refcount.yml'

jobs:
refcount:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v3

- uses: mlugg/setup-zig@v2
with:
version: 0.15.2
# 8GB cache limit chosen at random
cache-size-limit: 8192

# the checker loads libclang at runtime; pin the major version the
# @Refcount annotations are validated against. libclang 18 anchors
# macro-expanded operator cursors differently, defeating the
# checker's macro-origin exemption (false [strange expression]
# findings on u3a_to_ptr-style word punning)
- name: Install libclang 19
run: |
sudo apt-get update
if ! sudo apt-get install -y --no-install-recommends libclang-19-dev; then
wget -qO /tmp/llvm.sh https://apt.llvm.org/llvm.sh
sudo bash /tmp/llvm.sh 19
sudo apt-get install -y --no-install-recommends libclang-19-dev
fi

# independent tasks: cargo does not need the compile db, only the
# lint run does. wait for both before failing so neither is orphaned
- name: Generate compile_commands.json, build refcount-check
run: |
zig build -Dgenerate-commands --summary all &
zig_pid=$!
cargo build --manifest-path tools/refcount-check/Cargo.toml &
cargo_pid=$!
zig_rc=0; cargo_rc=0
wait "$zig_pid" || zig_rc=$?
wait "$cargo_pid" || cargo_rc=$?
[ "$zig_rc" -eq 0 ] && [ "$cargo_rc" -eq 0 ]

- name: Run selftest
run: |
./tools/refcount-check/target/debug/refcount-check \
--selftest \
--libclang /usr/lib/llvm-19/lib/libclang.so

- name: Run refcount lint
run: |
./tools/refcount-check/target/debug/refcount-check \
--libclang /usr/lib/llvm-19/lib/libclang.so
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ GPATH
GRTAGS
GTAGS

# Tools
tools/__pycache__

# Fake ships.
/zod
/nec
Expand Down
7 changes: 7 additions & 0 deletions pkg/noun/allocate.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// @file
/// @Refcount: all functions are custom unless asserted otherwise
/// -- implements or sits below the refcount machinery.

#include "allocate.h"

Expand Down Expand Up @@ -468,6 +470,7 @@ _me_wash_south(u3_noun dog)
}

/* u3a_wash(): wash all lazy mugs. RETAIN.
** @Refcount: retains arguments
*/
void
u3a_wash(u3_noun som)
Expand Down Expand Up @@ -1207,6 +1210,7 @@ u3a_mark_rptr(void* ptr_v)
}

/* u3a_mark_noun(): mark a noun for gc. Produce size.
** @Refcount: retains arguments
*/
c3_w
u3a_mark_noun(u3_noun som)
Expand Down Expand Up @@ -1567,6 +1571,7 @@ _ca_prof_mark(u3_noun som)
}

/* u3a_prof(): mark/measure/print memory profile. RETAIN.
** @Refcount: retains arguments
*/
u3m_quac*
u3a_prof(FILE* fil_u, u3_noun mas)
Expand Down Expand Up @@ -2015,6 +2020,7 @@ _ca_detect(u3p(u3h_root) har_p, u3_noun fum, u3_noun som, c3_d axe_d)
/* u3a_detect(): for debugging, check if (som) is referenced from (fum).
**
** (som) and (fum) are both RETAINED.
** @Refcount: retains arguments
*/
c3_d
u3a_detect(u3_noun fum, u3_noun som)
Expand Down Expand Up @@ -2110,6 +2116,7 @@ u3a_walk_fore(u3_noun a,
}

/* u3a_string(): `a` as an on-loom c-string.
@Refcount: retains
*/
c3_c*
u3a_string(u3_atom a)
Expand Down
36 changes: 36 additions & 0 deletions pkg/noun/allocate.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
*/
# define u3a_crag_no (u3a_page - u3a_min_log)

# define u3a_direct_max 0x7fffffff

/* page table constants
*/
# define u3a_free_pg (u3p(u3a_crag))0
Expand Down Expand Up @@ -237,6 +239,27 @@ STATIC_ASSERT( u3a_vits <= u3a_min_log,

/** Macros. Should be better commented.
**/
# ifdef U3_REFCOUNT_LINT
/* Lint-mode declarations: the refcount checker parses with
** U3_REFCOUNT_LINT defined so that noun primitives appear as plain
** function calls in the AST instead of macro expansions. These
** declarations are never compiled or linked; they must stay
** semantically equivalent to the macros in the #else branch.
*/
c3_o u3a_is_cat(u3_noun som);
c3_o u3a_is_dog(u3_noun som);
c3_o u3a_is_pug(u3_noun som);
c3_o u3a_is_pom(u3_noun som);
c3_o u3a_is_atom(u3_noun som);
c3_o u3a_is_cell(u3_noun som);
# define u3ud(som) u3a_is_atom(som)
# define u3du(som) u3a_is_cell(som)

u3_noun u3a_h(u3_noun som); // @Refcount: retains arguments
u3_noun u3a_t(u3_noun som); // @Refcount: retains arguments
# define u3h(som) u3a_h(som)
# define u3t(som) u3a_t(som)
# else
/* u3a_is_cat(): yes if noun [som] is direct atom.
*/
# define u3a_is_cat(som) (((som) >> 31) ? c3n : c3y)
Expand Down Expand Up @@ -279,6 +302,7 @@ STATIC_ASSERT( u3a_vits <= u3a_min_log,
? ( ((u3a_cell *)u3a_to_ptr(som))->tel )\
: u3m_bail(c3__exit) )
# define u3t(som) u3a_t(som)
# endif

# define u3to(type, x) ((type *)u3a_into(x))
# define u3tn(type, x) (x) ? (type*)u3a_into(x) : (void*)NULL
Expand Down Expand Up @@ -646,10 +670,14 @@ u3a_post_info(u3_post);
*/
u3_weak
u3a_gain(u3_weak som);
# ifdef U3_REFCOUNT_LINT
# define u3k(som) u3a_gain(som)
# else
# define u3k(som) ({ \
u3_noun __som = som; \
( c3y == u3a_is_cat(__som) ) ? __som : u3a_gain(__som); \
})
# endif

/* u3a_take(): gain, copying juniors.
*/
Expand All @@ -665,12 +693,17 @@ u3a_post_info(u3_post);
*/
void
u3a_lose(u3_weak som);
# ifdef U3_REFCOUNT_LINT
# define u3z(som) u3a_lose(som)
# else
# define u3z(som) ({ \
u3_noun __som = som; \
( c3y == u3a_is_cat(__som) ) ? (void)0 : u3a_lose(__som); \
})
# endif

/* u3a_wash(): wash all lazy mugs in subtree. RETAIN.
** @Refcount: retains arguments
*/
void
u3a_wash(u3_noun som);
Expand Down Expand Up @@ -706,6 +739,7 @@ u3a_post_info(u3_post);
u3a_mark_rptr(void* ptr_v);

/* u3a_mark_noun(): mark a noun for gc. Produce size.
** @Refcount: retains arguments
*/
c3_w
u3a_mark_noun(u3_noun som);
Expand Down Expand Up @@ -825,6 +859,7 @@ u3a_dash(void);
u3a_print_memory_str(c3_c* str_c, c3_c* cap_c, c3_w wor_w);

/* u3a_prof(): mark/measure/print memory profile. RETAIN.
** @Refcount: retains arguments
*/
u3m_quac*
u3a_prof(FILE* fil_u, u3_noun mas);
Expand Down Expand Up @@ -861,6 +896,7 @@ u3a_dash(void);
c3_o (*cel_f)(u3_noun, void*));

/* u3a_string(): `a` as an on-loom c-string.
@Refcount: retains
*/
c3_c*
u3a_string(u3_atom a);
Expand Down
2 changes: 2 additions & 0 deletions pkg/noun/events.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! @file events.c
//! @Refcount: all functions are custom unless asserted otherwise
//! -- loom snapshotting sits below the refcount machinery.
//!
//! incremental, orthogonal, paginated loom snapshots
//!
Expand Down
Loading
Loading