Skip to content

Optimize assembly dynamic jump#1123

Open
fractasy wants to merge 2 commits into
pre-develop-1.0.0-betafrom
feature/optimize_dynamic_jump
Open

Optimize assembly dynamic jump#1123
fractasy wants to merge 2 commits into
pre-develop-1.0.0-betafrom
feature/optimize_dynamic_jump

Conversation

@fractasy

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes dynamic jump handling by removing low-address dynamic jump paths from the generated x86_64 assembly when the float feature is disabled, and by making ecall jump to a fixed ROM address (instead of reading MTVEC) in non-float builds.

Changes:

  • Make ecall use an immediate fixed handler address when float is disabled, avoiding a dynamic jump to low ROM.
  • Add non-float assertions to ensure the fixed ecall handler address matches the ROM layout.
  • Conditionally compile out low-address dynamic jump handling in the ROM-to-ASM generator when float is disabled.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
core/src/zisk_rom_2_asm.rs Gates the low-address dynamic jump detection/handling behind feature = "float" in generated assembly.
core/src/riscv2zisk_context.rs Introduces a fixed non-float ecall handler address and related ROM layout assertions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/zisk_rom_2_asm.rs
Comment thread core/src/zisk_rom_2_asm.rs
Comment thread core/src/riscv2zisk_context.rs
@github-actions

Copy link
Copy Markdown

🔄 ZisK Cycle Tracking

Emulator cost report (ziskemu -X) comparing this PR against the base branch.

Summary

Guest Steps Δ Steps Total Cost Δ Total Cost
bigint 21,804,156 ➖ 0.00% 2,619,815,141 ➖ 0.00%
bls12_381 12,198,746 ➖ 0.00% 1,794,646,219 ➖ 0.00%
bn254 14,383,640 ➖ 0.00% 2,011,674,785 ➖ 0.00%
diagnostic 157,427 ➖ 0.00% 308,677,138 ➖ 0.00%
hashes 3,113,302 ➖ 0.00% 775,398,414 ➖ 0.00%
secp256k1 331,059 ➖ 0.00% 340,269,702 ➖ 0.00%
secp256r1 4,753,751 ➖ 0.00% 1,235,696,962 ➖ 0.00%
uint256 17,197 ➖ 0.00% 295,350,149 ➖ 0.00%

Per-Guest Breakdown

bigint
Metric Base Branch Current PR Diff Diff (%)
Total Steps 21,804,156 21,804,156 0 0.00%
Main Cost 1,482,682,608 1,482,682,608 0 0.00%
Opcodes Cost 136,240,775 136,240,775 0 0.00%
Precompiles Cost 337,634,469 337,634,469 0 0.00%
Memory Cost 369,656,025 369,656,009 -16 -0.00%
Variable Cost 2,326,213,877 2,326,213,861 -16 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 2,619,815,157 2,619,815,141 -16 -0.00%
Frops Cost 146,372,744 146,372,744 0 0.00%
bls12_381
Metric Base Branch Current PR Diff Diff (%)
Total Steps 12,198,746 12,198,746 0 0.00%
Main Cost 829,514,728 829,514,728 0 0.00%
Opcodes Cost 24,425,993 24,426,018 25 0.00%
Precompiles Cost 354,113,051 354,113,051 0 0.00%
Memory Cost 292,991,158 292,991,142 -16 -0.00%
Variable Cost 1,501,044,930 1,501,044,939 9 0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 1,794,646,210 1,794,646,219 9 0.00%
Frops Cost 3,339,637 3,339,637 0 0.00%
bn254
Metric Base Branch Current PR Diff Diff (%)
Total Steps 14,383,640 14,383,640 0 0.00%
Main Cost 978,087,520 978,087,520 0 0.00%
Opcodes Cost 15,870,063 15,870,063 0 0.00%
Precompiles Cost 383,185,069 383,185,069 0 0.00%
Memory Cost 340,930,869 340,930,853 -16 -0.00%
Variable Cost 1,718,073,521 1,718,073,505 -16 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 2,011,674,801 2,011,674,785 -16 -0.00%
Frops Cost 3,154,155 3,154,155 0 0.00%
diagnostic
Metric Base Branch Current PR Diff Diff (%)
Total Steps 157,427 157,427 0 0.00%
Main Cost 10,705,036 10,705,036 0 0.00%
Opcodes Cost 3,241,635 3,241,635 0 0.00%
Precompiles Cost 340,369 340,369 0 0.00%
Memory Cost 788,834 788,818 -16 -0.00%
Variable Cost 15,075,874 15,075,858 -16 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 308,677,154 308,677,138 -16 -0.00%
Frops Cost 2,009,381 2,009,381 0 0.00%
hashes
Metric Base Branch Current PR Diff Diff (%)
Total Steps 3,113,302 3,113,302 0 0.00%
Main Cost 211,704,536 211,704,536 0 0.00%
Opcodes Cost 107,702,885 107,702,885 0 0.00%
Precompiles Cost 145,214,131 145,214,131 0 0.00%
Memory Cost 17,175,598 17,175,582 -16 -0.00%
Variable Cost 481,797,150 481,797,134 -16 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 775,398,430 775,398,414 -16 -0.00%
Frops Cost 9,851,420 9,851,420 0 0.00%
secp256k1
Metric Base Branch Current PR Diff Diff (%)
Total Steps 331,059 331,059 0 0.00%
Main Cost 22,512,012 22,512,012 0 0.00%
Opcodes Cost 4,082,616 4,082,616 0 0.00%
Precompiles Cost 14,211,324 14,211,324 0 0.00%
Memory Cost 5,862,486 5,862,470 -16 -0.00%
Variable Cost 46,668,438 46,668,422 -16 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 340,269,718 340,269,702 -16 -0.00%
Frops Cost 3,997,675 3,997,675 0 0.00%
secp256r1
Metric Base Branch Current PR Diff Diff (%)
Total Steps 4,753,751 4,753,751 0 0.00%
Main Cost 323,255,068 323,255,068 0 0.00%
Opcodes Cost 79,204,784 79,204,784 0 0.00%
Precompiles Cost 422,156,730 422,156,730 0 0.00%
Memory Cost 117,479,116 117,479,100 -16 -0.00%
Variable Cost 942,095,698 942,095,682 -16 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 1,235,696,978 1,235,696,962 -16 -0.00%
Frops Cost 72,520,183 72,520,183 0 0.00%
uint256
Metric Base Branch Current PR Diff Diff (%)
Total Steps 17,197 17,197 0 0.00%
Main Cost 1,169,396 1,169,396 0 0.00%
Opcodes Cost 86,970 86,970 0 0.00%
Precompiles Cost 241,540 241,540 0 0.00%
Memory Cost 250,979 250,963 -16 -0.01%
Variable Cost 1,748,885 1,748,869 -16 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 295,350,165 295,350,149 -16 -0.00%
Frops Cost 115,128 115,128 0 0.00%

🔴 increase (regression) · 🟢 decrease (improvement) · ➖ no change. STEPS and all COSTS are deterministic functions of (ELF, input).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants