Skip to content

refactor: use constants from kernel::memory module directly#2766

Open
giwaov wants to merge 1 commit into0xMiden:mainfrom
giwaov:refactor/use-memory-constants-2415
Open

refactor: use constants from kernel::memory module directly#2766
giwaov wants to merge 1 commit into0xMiden:mainfrom
giwaov:refactor/use-memory-constants-2415

Conversation

@giwaov
Copy link
Copy Markdown
Contributor

@giwaov giwaov commented Apr 14, 2026

Description

Replaces 16 simple push-constant procedures in memory.masm with direct constant imports, following the pattern established in #2221.

Each replaced procedure simply pushes a constant onto the stack:

pub proc get_foo_ptr
    push.FOO_PTR
end

These are now replaced at call sites with:

use $kernel::memory::FOO_PTR
# ...
push.FOO_PTR

This removes unnecessary procedure call overhead while keeping the code clear and direct.

Replaced procedures (16 total)

Procedure Constant
get_input_vault_root_ptr INPUT_VAULT_ROOT_PTR
get_output_vault_root_ptr OUTPUT_VAULT_ROOT_PTR
get_tx_script_root_ptr TX_SCRIPT_ROOT_PTR
get_block_data_ptr BLOCK_DATA_SECTION_OFFSET
get_partial_blockchain_ptr PARTIAL_BLOCKCHAIN_PTR
get_partial_blockchain_peaks_ptr PARTIAL_BLOCKCHAIN_PEAKS_PTR
get_native_account_data_ptr NATIVE_ACCOUNT_DATA_PTR
get_account_data_length ACCOUNT_DATA_LENGTH
get_max_foreign_account_ptr MAX_FOREIGN_ACCOUNT_PTR
get_account_delta_fungible_asset_ptr ACCOUNT_DELTA_FUNGIBLE_ASSET_PTR
get_account_delta_non_fungible_asset_ptr ACCOUNT_DELTA_NON_FUNGIBLE_ASSET_PTR
get_output_note_data_offset OUTPUT_NOTE_SECTION_OFFSET
get_kernel_procedures_ptr KERNEL_PROCEDURES_PTR
get_link_map_region_start_ptr LINK_MAP_REGION_START_PTR
get_link_map_region_end_ptr LINK_MAP_REGION_END_PTR
get_link_map_entry_size LINK_MAP_ENTRY_SIZE

Files changed (10)

  • memory.masm: Removed 16 push-constant procedures and their doc comments. Updated 2 internal callers (get_native_account_active_storage_slots_ptr, get_native_account_initial_storage_slots_ptr) to use push.NATIVE_ACCOUNT_DATA_PTR directly.
  • account_delta.masm: 10 replacements (fungible + non-fungible delta ptrs)
  • faucet.masm: 4 replacements (input vault root ptr)
  • prologue.masm: 5 replacements (kernel procs, block data, partial blockchain, input vault)
  • account.masm: 4 replacements (native account data, account data length, max foreign account)
  • link_map.masm: 3 replacements (region start/end, entry size)
  • epilogue.masm: 2 replacements (output note section offset, output vault root)
  • api.masm: 1 replacement (kernel procedures ptr)
  • main.masm: 1 replacement (tx script root ptr)
  • tx_script_main.masm: 1 replacement (tx script root ptr)

Closes #2415

Replace 16 simple push-constant procedures in memory.masm with direct
constant imports using use \::memory::CONSTANT_NAME and
push.CONSTANT_NAME at call sites.

This removes unnecessary procedure call overhead for procedures that
simply push a constant value onto the stack.

Replaced procedures:
- get_input_vault_root_ptr -> INPUT_VAULT_ROOT_PTR
- get_output_vault_root_ptr -> OUTPUT_VAULT_ROOT_PTR
- get_tx_script_root_ptr -> TX_SCRIPT_ROOT_PTR
- get_block_data_ptr -> BLOCK_DATA_SECTION_OFFSET
- get_partial_blockchain_ptr -> PARTIAL_BLOCKCHAIN_PTR
- get_partial_blockchain_peaks_ptr -> PARTIAL_BLOCKCHAIN_PEAKS_PTR
- get_native_account_data_ptr -> NATIVE_ACCOUNT_DATA_PTR
- get_account_data_length -> ACCOUNT_DATA_LENGTH
- get_max_foreign_account_ptr -> MAX_FOREIGN_ACCOUNT_PTR
- get_account_delta_fungible_asset_ptr -> ACCOUNT_DELTA_FUNGIBLE_ASSET_PTR
- get_account_delta_non_fungible_asset_ptr -> ACCOUNT_DELTA_NON_FUNGIBLE_ASSET_PTR
- get_output_note_data_offset -> OUTPUT_NOTE_SECTION_OFFSET
- get_kernel_procedures_ptr -> KERNEL_PROCEDURES_PTR
- get_link_map_region_start_ptr -> LINK_MAP_REGION_START_PTR
- get_link_map_region_end_ptr -> LINK_MAP_REGION_END_PTR
- get_link_map_entry_size -> LINK_MAP_ENTRY_SIZE

Closes 0xMiden#2415
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