Skip to content

Windows heap: realloc keeps contents; rc: interface counts changed inline; README vs Rust - #807

Merged
ASDAlexander77 merged 3 commits into
mainfrom
rc-interface-inline-count
Nov 10, 2026
Merged

ASDAlexander77 merged 3 commits into
mainfrom
rc-interface-inline-count

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

The rest of #806, which was merged before these three commits reached it.

Windows heap: the resize keeps its block's contents. LLVM's realloc has allockind("realloc"), but ours also had uninitialized. With noalias on the result, LLVM then read the grown block's old elements as undef (00array_splice b[0] and 4 more tests, 0xC0000409). The fix makes realloc Realloc-only, so its result can safely be noalias.

rc: an interface's count is changed inline. Class, object, string, any and Shared now share one retain routine, __tslang_retain_block_slot. When an interface's descriptor uses that routine, retain is an inline increment. Release is a plain decrement while the count is above 1; otherwise it calls the descriptor. With --atomic-rc it always calls the descriptor. On the ray tracer, rc goes from 110 to 96 ms. New test 00rc_interface_count_inline.ts, teeth-checked: a double decrement segfaults.

README: a performance comparison with Rust, a refreshed ray tracer table, and a Windows table for the numeric benchmark. Under own, tslang is on par with Rust on numeric array loops and about 1.35x Rust on the ray tracer. The benchmark READMEs get notes on the rc change.

ctest: 6943/6943 (Release). Fuzzer: 1220 programs, whose only rc failure is a known crash (seed 4487) that main has too.

🤖 Generated with Claude Code

ASDAlexander77 and others added 3 commits November 10, 2026 21:14
…sh pointer

__tslang_heap_realloc was declared allockind("realloc,uninitialized"); LLVM declares realloc
allockind("realloc") alone, since the block keeps its contents up to the old size. With the
result also noalias (as LLVM says of realloc, and now said of the helper) the wrong flag let LLVM
read a grown array's old elements as undefined: 00array_splice and four other array tests failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nces

An interface value is retained and released through the type descriptor its vtable names: vtable,
tag, descriptor, then an indirect call that LLVM can neither inline nor pair with its counterpart.
The ray tracer's Sphere.intersect retained its Intersection's `thing` that way on every hit, and
spilled the 80-byte result to the stack to give the routine an address.

Every type whose value references a block counted the plain way (class and object instances,
strings, any boxes, Shared<T>) now shares one retain routine. Under rc a retain through an interface
whose descriptor names it increments the count inline, and a release decrements inline when the
reference is not the last on a block only this thread holds; the last reference, shared and immortal
blocks and other kinds still call the descriptor's routine, given a slot of their own so the value
is not spilled. Ray tracer under rc: 110-114 ms -> 96 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 864dab4 into main Nov 10, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the rc-interface-inline-count branch November 10, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant