Skip to content

feat(harden): alien-emit rethink — CFG dispatch lite + native MBA pads - #332

Merged
undivisible merged 2 commits into
masterfrom
feat/alien-emit-rethink
Sep 13, 2026
Merged

undivisible merged 2 commits into
masterfrom
feat/alien-emit-rethink

Conversation

@undivisible

@undivisible undivisible commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Deepens harden/anti-decomp beyond merged feat: harden + lean anti-decomp emit profiles #296 with lite CFG dispatch (while _pc < N state machine for eligible straight-line bodies; skips loops/try/match/throw; avoids Break because native lower treats it as a no-op).
  • Native alien shapes: rotating prologue variants, MBA constant materialization (^m, ±m, dual-mask), rotating junk pads wired before calls (junk_pad was previously unused).
  • Updates docs/emit-profiles.md honesty; refreshes objdump/nm smoke metrics (harden object 2689→3109 bytes). Ghidra headless section retained from prior run (this host lacked GHIDRA_INSTALL_DIR).

Test plan

  • cargo fmt (in-cli)
  • cargo test --lib harden_ / antidecomp / emit_profile / lower_simple_default_and_harden / core_opt::
  • bash scripts/ghidra-antidecomp-smoke.sh (objdump/nm; Ghidra skipped on this host)
  • CI: Self-host + JIT conformance + fmt

Do not merge until CI green and parent says so.


Note

Medium Risk
Harden-only IR restructuring and codegen shape changes can affect semantics or ABI if dispatch eligibility or no-op pads are wrong; default/lean paths are unchanged but harden output is larger and harder to debug.

Overview
Extends the harden emit profile with lite CFG dispatch on Core IR and rotating native anti-decomp shapes, plus doc/benchmark refresh.

IR (core_opt): After existing harden passes, eligible straight-line function bodies (≥3 stmts, no loops/Break/try/match/throw) are rewritten into a while _pc < N loop with chained if _pc == i states; large bodies are chunked (2 stmts per state when >8 stmts). Dispatcher exits by advancing _pc past N—not via Break, which native lower still treats as a no-op. A unit test asserts _pc + dispatcher loop appear under EmitProfile::Harden.

Native (antidecomp + x86_64_lower): A thread-local tick rotates three prologue variants, four MBA constant-load patterns for weird_materialize_rax, and four junk_pad sequences. junk_pad is now emitted immediately before every call (internal and extern) when harden is active—previously unused at the lowering site.

Docs: emit-profiles.md documents CFG dispatch limits and native rotation; ghidra-antidecomp-smoke.md metrics reflect a larger harden object (2689 → 3109 bytes) and note Ghidra headless was skipped on the regenerating host.

Reviewed by Cursor Bugbot for commit decb084. Configure here.

Beyond #296: wrap eligible straight-line bodies in while-_pc dispatchers,
rotate harden prologue/junk-pad/MBA constant shapes, and wire junk pads
before calls. Docs honesty updated; smoke objdump metrics refreshed.
@capy-ai

capy-ai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Capy couldn't review this pull request because Max's workspace is out of credits, add credits or enable auto-reload to resume automatic reviews.

Open in Capy

@cursor

cursor Bot commented Sep 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_b5449b70-908c-4381-b8be-85245c48103d)

@mergify

mergify Bot commented Sep 13, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@undivisible
undivisible merged commit 1c9a902 into master Sep 13, 2026
6 checks passed
@undivisible
undivisible deleted the feat/alien-emit-rethink branch September 13, 2026 10:04
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