{"eip":4573,"title":"Procedures for the EVM","description":"Introduces support for EVM Procedures.","authors":["Greg Colvin (@gcolvin)","Greg Colvin \u003cgreg@colvin.org\u003e"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2021-12-16","requires":[2315,3540,3670,3779,4200],"discussionsTo":"https://ethereum-magicians.org/t/eip-4573-named-procedures-for-evm-code-sections/7776","repo":"EIPs","label":"EIP-4573","officialUrl":"https://eips.ethereum.org/EIPS/eip-4573","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4573.md","url":"https://eips.huatuo.xyz/eip-4573/","tldr":{"en":"Proposed adding real procedures to the EVM, with declared inputs and outputs and automatically managed call frames in memory, so compilers get a structured, statically checkable calling convention.","ja":"EVM に本物のプロシージャを追加することを提案した。入力と出力を宣言し、メモリ上のコールフレームを自動管理することで、コンパイラに構造化された、静的に検査可能な呼び出し規約を提供する。","ko":"EVM에 진짜 프로시저를 추가하자고 제안했다. 입력과 출력을 선언하고 메모리의 호출 프레임을 자동으로 관리하여, 컴파일러에 구조화되고 정적으로 검사할 수 있는 호출 규약을 제공한다.","zh":"提议为 EVM 增加真正的过程（procedure），具有声明的输入和输出，并在内存中自动管理调用帧，让编译器获得结构化、可静态检查的调用约定。"},"tags":["evm","opcodes","eof","procedures","core"],"explainers":{"en":{"lang":"en","tldr":"Proposed adding real procedures to the EVM, with declared inputs and outputs and automatically managed call frames in memory, so compilers get a structured, statically checkable calling convention.","tags":["evm","opcodes","eof","procedures","core"],"related":[2315,3779,4200,615,4750],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-4573/","markdown":"## What problem does it solve?\n\nEVM bytecode has no structure: a \"function\" is just a region you `JUMP` into and out of, with no declared interface. Compilers have to invent their own calling conventions with dynamic jumps, and tools cannot easily check that code respects them. There is also no built-in way to allocate local variables per call; compilers juggle the 1024-item data stack or hand-manage memory.\n\nEIP-4573 proposes *procedures*: delimited blocks of code that can only be entered through a defined interface and that get their own frame of local memory, in the style of x86 `ENTER`/`LEAVE`.\n\n## How it works\n\nIt builds on the subroutines of [EIP-2315](/eip-2315/) (`JUMPSUB`/`RETURNSUB`), EOF code sections ([EIP-3540](/eip-3540/)) and the validation rules of [EIP-3779](/eip-3779/). Five instructions are added (opcode numbers were left unassigned):\n\n| Instruction | Role |\n| --- | --- |\n| `ENTERPROC` | Marks a procedure's entry; declares `n_inputs`, `n_outputs`, `n_locals` |\n| `LEAVEPROC` | Marks the procedure's end; frees its frame and returns |\n| `CALLPROC` | Calls procedure N in code section M (the only legal way in) |\n| `RETURNPROC` | Early return from the procedure |\n| `FRAMEADDRESS` | Pushes `FP + offset`, the address of a local in the current frame |\n\nLocals live on a **frame stack in memory** that starts at address 0 and grows downwards into negative (signed) addresses. The frame pointer `FP` moves down on each call and back up on return. Because frames are ordinary memory, locals can be read and written with `MLOAD`/`MSTORE`, which suits languages that take pointers to stack variables. Memory-expansion cost is adjusted to count words used both above and below 0.\n\nSafety comes from validation at deploy time: no nested procedures, no jumping into a procedure body from outside, and the declared input/output counts must be present on the stack.\n\n## Sample code\n\nStoring and loading a local variable in the current frame, from the spec:\n\n```\nPUSH 0xdada\nFRAMEADDRESS 32\nMSTORE          ; local at FP+32 = 0xdada\n\nFRAMEADDRESS 32\nMLOAD           ; push it back\n```\n\n## Things to know\n\n- Status: **Stagnant**. Opcodes were never assigned and it did not ship.\n- The author describes it as [EIP-615](/eip-615/) \"refined and refactored into bite-sized pieces\".\n- EVM Object Format work later took a different route to functions: code sections with `CALLF`/`RETF` in [EIP-4750](/eip-4750/), with static relative jumps from [EIP-4200](/eip-4200/).\n- The signed, downward-growing memory model would have been a notable change to how memory size and cost are tracked.\n"},"ja":{"lang":"ja","tldr":"EVM に本物のプロシージャを追加することを提案した。入力と出力を宣言し、メモリ上のコールフレームを自動管理することで、コンパイラに構造化された、静的に検査可能な呼び出し規約を提供する。","tags":["evm","opcodes","eof","procedures","core"],"related":[2315,3779,4200,615,4750],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-4573/","markdown":"## 何を解決するのか\n\nEVM バイトコードには構造がありません。「関数」とは出入りのために `JUMP` する領域にすぎず、宣言されたインターフェースもありません。コンパイラは動的ジャンプを使って独自の呼び出し規約を作り出す必要があり、ツールはコードがその規約を守っているかを簡単に検査できません。また、呼び出しごとにローカル変数を割り当てる組み込みの方法もなく、コンパイラは 1024 項目のデータスタックをやりくりするか、メモリを手作業で管理しています。\n\nEIP-4573 は*プロシージャ*を提案します。これは区切られたコードブロックで、定義されたインターフェースからしか入れず、x86 の `ENTER`/`LEAVE` のように、ローカルメモリの専用フレームを持ちます。\n\n## 仕組み\n\nこれは [EIP-2315](/eip-2315/) のサブルーチン（`JUMPSUB`/`RETURNSUB`）、EOF のコードセクション（[EIP-3540](/eip-3540/)）、[EIP-3779](/eip-3779/) の検証ルールを土台にしています。5 つの命令が追加されます（opcode 番号は未割り当てのままでした）。\n\n| 命令 | 役割 |\n| --- | --- |\n| `ENTERPROC` | プロシージャの入口を示し、`n_inputs`、`n_outputs`、`n_locals` を宣言する |\n| `LEAVEPROC` | プロシージャの終端を示し、フレームを解放して戻る |\n| `CALLPROC` | コードセクション M のプロシージャ N を呼び出す（唯一の正当な入り方） |\n| `RETURNPROC` | プロシージャからの早期リターン |\n| `FRAMEADDRESS` | `FP + offset`、つまり現在のフレーム内のローカル変数のアドレスをプッシュする |\n\nローカル変数は、アドレス 0 から始まり負の（符号付き）アドレスへ向かって下方向に伸びる、**メモリ上のフレームスタック**に置かれます。フレームポインタ `FP` は呼び出しのたびに下がり、リターンで元に戻ります。フレームは通常のメモリなので、ローカル変数は `MLOAD`/`MSTORE` で読み書きでき、スタック変数へのポインタを扱う言語に適しています。メモリ拡張のコストは、0 の上下の両方で使われたワード数を数えるように調整されます。\n\n安全性はデプロイ時の検証によって確保されます。プロシージャのネストは禁止、外部からプロシージャ本体へのジャンプは禁止で、宣言された入力数・出力数がスタックに存在していなければなりません。\n\n## サンプルコード\n\n仕様にある、現在のフレームでローカル変数を保存して読み出す例です。\n\n```\nPUSH 0xdada\nFRAMEADDRESS 32\nMSTORE          ; local at FP+32 = 0xdada\n\nFRAMEADDRESS 32\nMLOAD           ; push it back\n```\n\n## 知っておくべきこと\n\n- ステータス: **Stagnant**。opcode は割り当てられず、実装されませんでした。\n- 作者はこれを、[EIP-615](/eip-615/) を「小さな部品に洗練・再構成したもの」と説明しています。\n- その後の EVM Object Format の取り組みは、関数について別の道を選びました。[EIP-4750](/eip-4750/) の `CALLF`/`RETF` によるコードセクションと、[EIP-4200](/eip-4200/) の静的な相対ジャンプです。\n- 符号付きで下方向に伸びるメモリモデルは、メモリサイズとコストの追跡方法に大きな変更をもたらしたはずです。\n"},"ko":{"lang":"ko","tldr":"EVM에 진짜 프로시저를 추가하자고 제안했다. 입력과 출력을 선언하고 메모리의 호출 프레임을 자동으로 관리하여, 컴파일러에 구조화되고 정적으로 검사할 수 있는 호출 규약을 제공한다.","tags":["evm","opcodes","eof","procedures","core"],"related":[2315,3779,4200,615,4750],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-4573/","markdown":"## 어떤 문제를 해결하나요?\n\nEVM 바이트코드에는 구조가 없습니다. \"함수\"는 드나들기 위해 `JUMP`하는 영역일 뿐이며 선언된 인터페이스가 없습니다. 컴파일러는 동적 점프로 자기만의 호출 규약을 만들어야 하고, 도구는 코드가 그 규약을 지키는지 쉽게 검사할 수 없습니다. 호출마다 지역 변수를 할당하는 내장 방법도 없어서, 컴파일러는 1024개 항목의 데이터 스택을 돌려 쓰거나 메모리를 직접 관리합니다.\n\nEIP-4573은 *프로시저*를 제안합니다. 구획된 코드 블록으로, 정해진 인터페이스를 통해서만 진입할 수 있고, x86의 `ENTER`/`LEAVE`와 같은 방식으로 지역 메모리의 자체 프레임을 갖습니다.\n\n## 어떻게 동작하나요?\n\n이 제안은 [EIP-2315](/eip-2315/)의 서브루틴(`JUMPSUB`/`RETURNSUB`), EOF 코드 섹션([EIP-3540](/eip-3540/)), [EIP-3779](/eip-3779/)의 검증 규칙을 바탕으로 합니다. 명령어 5개가 추가됩니다(opcode 번호는 정해지지 않았습니다).\n\n| 명령어 | 역할 |\n| --- | --- |\n| `ENTERPROC` | 프로시저의 진입점을 표시하고 `n_inputs`, `n_outputs`, `n_locals`를 선언 |\n| `LEAVEPROC` | 프로시저의 끝을 표시하고 프레임을 해제한 뒤 반환 |\n| `CALLPROC` | 코드 섹션 M의 프로시저 N을 호출(유일하게 허용되는 진입 방법) |\n| `RETURNPROC` | 프로시저에서 조기 반환 |\n| `FRAMEADDRESS` | `FP + offset`, 즉 현재 프레임에 있는 지역 변수의 주소를 push |\n\n지역 변수는 **메모리 안의 프레임 스택**에 놓이며, 이 스택은 주소 0에서 시작해 음수(부호 있는) 주소 쪽으로 아래로 자랍니다. 프레임 포인터 `FP`는 호출할 때마다 내려가고 반환하면 다시 올라갑니다. 프레임은 일반 메모리이므로 지역 변수를 `MLOAD`/`MSTORE`로 읽고 쓸 수 있어, 스택 변수의 포인터를 사용하는 언어에 적합합니다. 메모리 확장 비용은 0의 위와 아래에서 사용된 워드 수를 모두 세도록 조정됩니다.\n\n안전성은 배포 시점의 검증에서 나옵니다. 프로시저 중첩 금지, 외부에서 프로시저 본문으로의 점프 금지, 선언된 입력/출력 개수가 스택에 존재해야 한다는 조건입니다.\n\n## 샘플 코드\n\n사양에 나온, 현재 프레임에 지역 변수를 저장하고 불러오는 예시입니다.\n\n```\nPUSH 0xdada\nFRAMEADDRESS 32\nMSTORE          ; local at FP+32 = 0xdada\n\nFRAMEADDRESS 32\nMLOAD           ; push it back\n```\n\n## 알아둘 점\n\n- 상태: **Stagnant**. opcode는 끝내 할당되지 않았고 출시되지 않았습니다.\n- 작성자는 이를 [EIP-615](/eip-615/)를 \"작은 조각으로 다듬고 재구성한 것\"이라고 설명합니다.\n- 이후 EVM Object Format 작업은 함수에 대해 다른 길을 택했습니다. [EIP-4750](/eip-4750/)의 `CALLF`/`RETF`를 쓰는 코드 섹션과 [EIP-4200](/eip-4200/)의 정적 상대 점프입니다.\n- 부호 있고 아래로 자라는 메모리 모델은 메모리 크기와 비용을 추적하는 방식에 상당한 변화를 가져왔을 것입니다.\n"},"zh":{"lang":"zh","tldr":"提议为 EVM 增加真正的过程（procedure），具有声明的输入和输出，并在内存中自动管理调用帧，让编译器获得结构化、可静态检查的调用约定。","tags":["evm","opcodes","eof","procedures","core"],"related":[2315,3779,4200,615,4750],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-4573/","markdown":"## 它解决什么问题？\n\nEVM 字节码没有结构：所谓\"函数\"只是一段你 `JUMP` 进出的区域，没有声明的接口。编译器只能用动态跳转自行发明调用约定，工具也很难检查代码是否遵守这些约定。此外也没有为每次调用分配局部变量的内置方式，编译器要么在 1024 项的数据栈上周旋，要么手动管理内存。\n\nEIP-4573 提出了*过程*：一段有边界的代码，只能通过定义好的接口进入，并拥有自己的局部内存帧，风格类似 x86 的 `ENTER`/`LEAVE`。\n\n## 它如何运作\n\n它建立在 [EIP-2315](/eip-2315/) 的子例程（`JUMPSUB`/`RETURNSUB`）、EOF 代码段（[EIP-3540](/eip-3540/)）以及 [EIP-3779](/eip-3779/) 的验证规则之上。共新增五条指令（opcode 编号未分配）：\n\n| 指令 | 作用 |\n| --- | --- |\n| `ENTERPROC` | 标记过程入口；声明 `n_inputs`、`n_outputs`、`n_locals` |\n| `LEAVEPROC` | 标记过程结束；释放其帧并返回 |\n| `CALLPROC` | 调用代码段 M 中的过程 N（唯一合法的进入方式） |\n| `RETURNPROC` | 从过程中提前返回 |\n| `FRAMEADDRESS` | 压入 `FP + offset`，即当前帧中某个局部变量的地址 |\n\n局部变量存放在**内存中的帧栈**里，帧栈从地址 0 开始，向下增长到负的（有符号）地址。帧指针 `FP` 每次调用时下移，返回时上移。由于帧就是普通内存，局部变量可以用 `MLOAD`/`MSTORE` 读写，适合需要获取栈变量指针的语言。内存扩展成本经过调整，会同时统计 0 上方和下方所使用的字数。\n\n安全性来自部署时的验证：不允许嵌套过程，不允许从外部跳入过程体，且声明的输入/输出数量必须存在于栈上。\n\n## 示例代码\n\n来自规范的示例：在当前帧中存储并加载一个局部变量。\n\n```\nPUSH 0xdada\nFRAMEADDRESS 32\nMSTORE          ; local at FP+32 = 0xdada\n\nFRAMEADDRESS 32\nMLOAD           ; push it back\n```\n\n## 需要注意\n\n- 状态：**Stagnant**。opcode 从未分配，也没有上线。\n- 作者将其描述为\"被精炼并重构为小块\"的 [EIP-615](/eip-615/)。\n- EVM 对象格式（EOF）的工作后来在函数问题上走了另一条路：[EIP-4750](/eip-4750/) 中带 `CALLF`/`RETF` 的代码段，以及 [EIP-4200](/eip-4200/) 的静态相对跳转。\n- 有符号、向下增长的内存模型会显著改变内存大小和成本的追踪方式。\n"}}}
