Repository navigation
Windows heap: realloc keeps contents; rc: interface counts changed inline; README vs Rust - #807
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The rest of #806, which was merged before these three commits reached it.
Windows heap: the resize keeps its block's contents. LLVM's
reallochasallockind("realloc"), but ours also haduninitialized. Withnoaliason the result, LLVM then read the grown block's old elements as undef (00array_spliceb[0]and 4 more tests, 0xC0000409). The fix makes realloc Realloc-only, so its result can safely benoalias.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-rcit always calls the descriptor. On the ray tracer, rc goes from 110 to 96 ms. New test00rc_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