Repository navigation
Replace TransposeDecoder switch with preserve_none tail calls and frameless handlers - #47
Draft
copybara-service[bot] wants to merge 1 commit into
Draft
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
copybara-service
Bot
force-pushed
the
test_1011404129
branch
from
November 2, 2026 01:34
c2a3fa1 to
bf13ecb
Compare
copybara-service
Bot
force-pushed
the
test_1011404129
branch
from
November 3, 2026 02:34
bf13ecb to
4353f7f
Compare
copybara-service
Bot
force-pushed
the
test_1011404129
branch
4 times, most recently
from
November 3, 2026 05:17
418c428 to
c2e660b
Compare
…meless handlers On 64-bit Clang x86-64 and AArch64 targets (`RIEGELI_TAILCALL`), replaces the central `HandleNode()` `switch` dispatch in `riegeli::TransposeDecoder::Decode` with 6-register `preserve_none` + `musttail` per-handler tail calls across 10 localized hunks (`+412 / -1` lines in `transpose_decoder.cc`, with zero edits to existing `DecodingState` callbacks or `MaskBuffer` overloads, and preserving the compact `16B`/`24B` `StateMachineNode` layout and untouched `HandleNode()` + `TransitionNode()` `switch` loop on 32-bit and non-`musttail` targets): 1. Under `#if RIEGELI_TAILCALL` (`defined(__clang__) && ABSL_HAVE_CPP_ATTRIBUTE(clang::musttail) && (defined(__aarch64__) || defined(__x86_64__)) && !defined(__ILP32__)`), aligns `StateMachineNode` to 32 bytes (`alignas(32)`, zero dead padding) by adding a direct `Callback` function pointer alongside `bool is_implicit : 1` and `CallbackType callback_type` (with `Context`'s 128-node inline buffer, `Context` uses ~4.1 KB on `Decode`'s stack). Other targets omit `Callback` and `alignas(32)`, keeping `StateMachineNode` at `8 + 2 * sizeof(void*)`. 2. Dispatches via `[[clang::preserve_none]]` + `[[clang::musttail]]` handlers (falling back to the standard calling convention + `[[clang::musttail]]` under AddressSanitizer and HWAddressSanitizer and on non-Linux targets), pinning `state`, `node`, `num_iters`, `transitions_cursor`, `transitions_limit`, and `dest` in registers across transitions, pairing frameless fast-path wrappers (`InvokeVarint`, `InvokeFixed`, `InvokeCopyTag`, `InvokeMessageStart`, `InvokeSubmessageStart`, `InvokeSubmessageEnd`, `InvokeSkippedSubmessageStart`, `InvokeSkippedSubmessageEnd`) with `ABSL_ATTRIBUTE_NOINLINE` cold/slow helpers and `InvokeSlowCallback`, and `#undef`ing all local `RIEGELI_*` macros at EOF. PiperOrigin-RevId: 1011404129
copybara-service
Bot
force-pushed
the
test_1011404129
branch
from
November 3, 2026 05:32
c2e660b to
d0097cd
Compare
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.
Replace TransposeDecoder switch with preserve_none tail calls and frameless handlers
On 64-bit Clang x86-64 and AArch64 targets (
RIEGELI_TAILCALL), replaces thecentral
HandleNode()switchdispatch inriegeli::TransposeDecoder::Decodewith 6-register
preserve_none+musttailper-handler tail calls across 10localized hunks (
+412 / -1lines intranspose_decoder.cc, with zero edits toexisting
DecodingStatecallbacks orMaskBufferoverloads, and preserving thecompact
16B/24BStateMachineNodelayout and untouchedHandleNode()+TransitionNode()switchloop on 32-bit and non-musttailtargets):#if RIEGELI_TAILCALL(defined(__clang__) && ABSL_HAVE_CPP_ATTRIBUTE(clang::musttail) && (defined(__aarch64__) || defined(__x86_64__)) && !defined(__ILP32__)), alignsStateMachineNodeto32 bytes (
alignas(32), zero dead padding) by adding a directCallbackfunction pointer alongside
bool is_implicit : 1andCallbackType callback_type(withContext's 128-node inline buffer,Contextuses ~4.1 KB onDecode's stack). Other targets omitCallbackand
alignas(32), keepingStateMachineNodeat8 + 2 * sizeof(void*).[[clang::preserve_none]]+[[clang::musttail]]handlers(falling back to the standard calling convention +
[[clang::musttail]]under AddressSanitizer and HWAddressSanitizer and on non-Linux targets),
pinning
state,node,num_iters,transitions_cursor,transitions_limit, anddestin registers across transitions, pairingframeless fast-path wrappers
(
InvokeVarint,InvokeFixed,InvokeCopyTag,InvokeMessageStart,InvokeSubmessageStart,InvokeSubmessageEnd,InvokeSkippedSubmessageStart,InvokeSkippedSubmessageEnd) withABSL_ATTRIBUTE_NOINLINEcold/slow helpers andInvokeSlowCallback, and#undefing all localRIEGELI_*macros at EOF.