Skip to content

LATX: optimize stack updates and share helper stubs - #460

Open
y347812075 wants to merge 3 commits into
lat-opensource:masterfrom
y347812075:perf-wi-2237
Open

LATX: optimize stack updates and share helper stubs#460
y347812075 wants to merge 3 commits into
lat-opensource:masterfrom
y347812075:perf-wi-2237

Conversation

@y347812075

Copy link
Copy Markdown
Contributor

Summary / 变更说明

  • Track a pending guest stack-pointer delta while translating consecutive
    register/immediate PUSH and register POP instructions. Fold the delta into
    stack accesses, materialize it at stack-sensitive boundaries, and retain
    precise restore metadata for faults and signals.
  • Generate process-wide default and no-FP helper prologue/epilogue stubs and
    route compatible helper call sites through them. Preserve live address
    temporaries across the shared prologue and keep the original inline paths
    available with LATX_STATIC_HELPER=0.
  • Record the static-helper mode in AOT headers. Reject and regenerate AOT
    caches when the runtime mode changes, including normal and merged caches,
    so the rollback switch remains effective.

Validation / 验证

  • ninja -C build32 latx-i386
  • ninja -C build64 latx-x86_64 test-latx-aot-cache-reader
  • AOT unit tests: 4/4 passed.
  • test-static-helper-stubs.sh: passed.
  • test-static-helper-live-temp.sh: passed.
  • Real Python AOT lifecycle: cache mode 1 -> 0 -> 1, correct guest output
    after each transition and regenerated headers matched the selected mode.
  • Full latx-integration suite: 21 passed, 2 skipped; 3 existing
    environment-dependent failures remained (namespace/longjmp and static
    link memset).
  • scripts/checkpatch.pl --no-tree --strict: 0 errors for all three commits;
    the first two commits only report the generic MAINTAINERS warning for new
    integration test files, and the AOT fix reports 0 warnings.

Checklist / 检查项

  • I have read CONTRIBUTING.md. / 我已阅读 CONTRIBUTING.md
  • Every commit contains a DCO sign-off (git commit -s). /
    每个提交都包含 DCO 签署(git commit -s)。
  • I have included relevant build or test results, or explained why they
    are not applicable. /
    我已提供相关构建或测试结果,或说明了不适用的原因。

Track a pending stack pointer delta while lowering consecutive register or immediate PUSH and register POP instructions. Fold the delta into stack accesses and materialize it at stack-sensitive instructions and TB boundaries.

Store the pending delta in restore metadata so faults and signals expose the precise guest stack pointer. Keep the existing IR2 optimizer as a mutually exclusive compile-time rollback path.

Add x86_64 and i386 integration coverage for widths, stack aliases, helper boundaries, protected-page faults, signal context restore, file mappings, and legacy stack instructions.

Signed-off-by: yuerengan <y347812075@163.com>
Generate process-wide default and no-FP prologue and epilogue stubs for helpers that use common save and restore contracts. Prepare arguments and call the original helper between the stubs so argument registers do not require helper-specific handling.

Route full-state instruction helpers and no-FP SMC store helpers through the matching stubs. Preserve address temporaries that remain live across a shared prologue because its independent register allocator may reuse the same host register.

Keep FP80 conversion, return-register-sensitive paths, and every original inline SMC save and restore path as fallbacks when LATX_STATIC_HELPER=0. Relocate all four stub addresses for AOT and retain strict runtime and statistics switches.

Add integration coverage for live RIP-relative helper arguments, common and no-FP helper paths, asynchronous signals, self-modifying stores, guest state, option validation, and inline/static equivalence.

Signed-off-by: yuerengan <y347812075@163.com>
Record the LATX_STATIC_HELPER mode in every generated AOT header and reject cached code when the current runtime mode differs. This keeps the rollback switch effective for previously generated code and makes mode changes fall back to JIT regeneration.

Bump the AOT footer version so caches written before the new header field are never interpreted using padding data. Apply the same compatibility check to normal and merged AOT loads, and cover both mode transitions in the cache reader test.

Signed-off-by: yuerengan <y347812075@163.com>
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