{"eip":615,"title":"Subroutines and Static Jumps for the EVM","description":"In the 21st century, on a blockchain circulating billions of ETH, formal specification and verification are an essential tool against loss. Yet the design of the EVM makes this unnecessarily difficult. Further, the design of the EVM makes near-linear-time compilation to machine code difficult.","authors":["Greg Colvin \u003cgreg@colvin.org\u003e","Brooklyn Zelenka (@expede)","Paweł Bylica (@chfast)","Christian Reitwiessner (@chriseth)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2016-12-10","discussionsTo":"https://ethereum-magicians.org/t/eip-615-subroutines-and-static-jumps-for-the-evm-last-call/3472","repo":"EIPs","label":"EIP-615","officialUrl":"https://eips.ethereum.org/EIPS/eip-615","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-615.md","url":"https://eips.huatuo.xyz/eip-615/","tldr":{"en":"A proposal to replace the EVM's dynamic jumps with static jumps, real subroutines and deploy-time validation, so EVM code becomes easier to analyze, verify and compile.","ja":"EVM の動的ジャンプを、静的ジャンプ、本物のサブルーチン、デプロイ時の検証に置き換える提案。EVM コードの解析・検証・コンパイルが容易になる。","ko":"EVM의 동적 점프를 정적 점프, 진짜 서브루틴, 배포 시점 검증으로 대체하자는 제안. EVM 코드를 분석, 검증, 컴파일하기 쉬워진다.","zh":"一项用静态跳转、真正的子程序和部署时验证来取代 EVM 动态跳转的提案，让 EVM 代码更易于分析、验证和编译。"},"tags":["evm","opcodes","subroutines","validation","core"],"explainers":{"en":{"lang":"en","tldr":"A proposal to replace the EVM's dynamic jumps with static jumps, real subroutines and deploy-time validation, so EVM code becomes easier to analyze, verify and compile.","tags":["evm","opcodes","subroutines","validation","core"],"related":[2315,3540,4750,7692,1702],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-615/","markdown":"## What problem does it solve?\n\nThe EVM has only one kind of jump: `JUMP` / `JUMPI` to an address taken from the **stack**. Compilers even use these dynamic jumps for function returns. Because a jump target can be any value computed at runtime, tools cannot easily work out the control flow of a contract. That makes these jobs hard or slow:\n\n- formal verification and static analysis for bugs,\n- compiling EVM bytecode to fast machine code,\n- proving ahead of time that code won't hit stack underflow or bad jumps.\n\nThe authors argue that analysis must run in near-linear (`n log n`) time, otherwise attackers can craft contracts that cause quadratic blow-ups in validators or optimizers.\n\n## How it works\n\nEIP-615 deprecates `JUMP` and `JUMPI` for new code and adds structured replacements that map closely to Wasm and CPU instructions:\n\n| New opcode | Purpose |\n| --- | --- |\n| `JUMPTO t` / `JUMPIF t` | Unconditional / conditional jump to an **immediate** target |\n| `JUMPV n, targets` | Jump table (switch) through an inline vector of targets |\n| `BEGINSUB n_args, n_results` | Marks a subroutine entry and its stack signature |\n| `JUMPSUB t` / `JUMPSUBV n, targets` | Call a subroutine, directly or through a table |\n| `RETURNSUB` | Return to the instruction after the call |\n| `GETLOCAL n` / `PUTLOCAL n` | Read and write frame-local stack slots |\n| `BEGINDATA` | Everything after this is data, not code |\n\nSubroutine calls use a separate return stack and frame pointer that the program cannot touch. New-style bytecode starts with a header (`\\0evm` plus a version) and is **validated at deploy time**. Code that could underflow the stack, jump to an invalid place or misuse subroutines is rejected before it reaches the chain. Only out-of-gas and stack overflow still need runtime checks. Mixing new and legacy code relies on account versioning ([EIP-1702](/eip-1702/)).\n\n## Sample code\n\nIllustrative assembly: a subroutine that adds two numbers, called with a static jump.\n\n```text\n; header: \"\\0evm\" + version\nBEGINSUB 0, 0          ; main routine\n  PUSH1 10\n  PUSH1 11\n  JUMPSUB add          ; immediate target, no dynamic jump\n  ; stack now holds 21\n  STOP\n\nadd:\nBEGINSUB 2, 1          ; takes 2 args, returns 1\n  ADD\n  RETURNSUB\n\nBEGINDATA              ; optional data section\n```\n\nCompare with legacy EVM, where the caller pushes a return address and the callee does `JUMP` to whatever is on the stack.\n\n## Things to know\n\n- This proposal is **Stagnant** and was never adopted. Current EVM bytecode still uses dynamic `JUMP` / `JUMPI`.\n- Its ideas continued in later proposals. [EIP-2315](/eip-2315/) (simple subroutines) is Withdrawn. The EVM Object Format family, including [EIP-3540](/eip-3540/), [EIP-4750](/eip-4750/) (functions) and the meta [EIP-7692](/eip-7692/), brought back deploy-time validation and real functions, and is also listed as Stagnant.\n- The opcode numbers and header format here are specific to this draft. Do not assume they match any later design.\n"},"ja":{"lang":"ja","tldr":"EVM の動的ジャンプを、静的ジャンプ、本物のサブルーチン、デプロイ時の検証に置き換える提案。EVM コードの解析・検証・コンパイルが容易になる。","tags":["evm","opcodes","subroutines","validation","core"],"related":[2315,3540,4750,7692,1702],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-615/","markdown":"## 何を解決するのか\n\nEVM にあるジャンプは 1 種類だけです。**スタック**から取り出したアドレスへの `JUMP` / `JUMPI` です。コンパイラは関数からのリターンにもこの動的ジャンプを使います。ジャンプ先は実行時に計算された任意の値になり得るため、ツールがコントラクトの制御フローを簡単に割り出すことはできません。そのため、次のような作業が困難か低速になります。\n\n- 形式検証とバグの静的解析\n- EVM バイトコードの高速なマシンコードへのコンパイル\n- コードがスタックアンダーフローや不正なジャンプに陥らないことの事前証明\n\n著者らは、解析はほぼ線形（`n log n`）の時間で実行できなければならないと主張しています。そうでなければ、攻撃者がバリデータやオプティマイザに二乗オーダーの負荷を生じさせるコントラクトを作れてしまうからです。\n\n## 仕組み\n\nEIP-615 は新しいコードでの `JUMP` と `JUMPI` を非推奨とし、Wasm や CPU の命令に近い構造化された代替命令を追加します。\n\n| 新しい opcode | 役割 |\n| --- | --- |\n| `JUMPTO t` / `JUMPIF t` | **即値**のジャンプ先への無条件 / 条件付きジャンプ |\n| `JUMPV n, targets` | インラインのジャンプ先ベクタによるジャンプテーブル（switch） |\n| `BEGINSUB n_args, n_results` | サブルーチンの入口とそのスタックシグネチャを示す |\n| `JUMPSUB t` / `JUMPSUBV n, targets` | サブルーチンを直接、またはテーブル経由で呼び出す |\n| `RETURNSUB` | 呼び出しの次の命令に戻る |\n| `GETLOCAL n` / `PUTLOCAL n` | フレームローカルなスタックスロットの読み書き |\n| `BEGINDATA` | これ以降はコードではなくデータ |\n\nサブルーチン呼び出しは、プログラムが触れない専用のリターンスタックとフレームポインタを使います。新方式のバイトコードはヘッダ（`\\0evm` とバージョン）で始まり、**デプロイ時に検証**されます。スタックアンダーフローを起こし得るコード、無効な場所へジャンプするコード、サブルーチンを誤用するコードは、チェーンに載る前に拒否されます。実行時チェックが必要なのは、ガス切れとスタックオーバーフローだけです。新旧のコードの混在はアカウントのバージョニング（[EIP-1702](/eip-1702/)）に依存します。\n\n## サンプルコード\n\n説明用のアセンブリ。2 つの数を足すサブルーチンを、静的ジャンプで呼び出します。\n\n```text\n; header: \"\\0evm\" + version\nBEGINSUB 0, 0          ; main routine\n  PUSH1 10\n  PUSH1 11\n  JUMPSUB add          ; immediate target, no dynamic jump\n  ; stack now holds 21\n  STOP\n\nadd:\nBEGINSUB 2, 1          ; takes 2 args, returns 1\n  ADD\n  RETURNSUB\n\nBEGINDATA              ; optional data section\n```\n\n従来の EVM では、呼び出し側がリターンアドレスをプッシュし、呼び出された側がスタック上の値へ `JUMP` します。これと比べてみてください。\n\n## 知っておくべきこと\n\n- この提案は **Stagnant** で、採用されたことはありません。現在の EVM バイトコードは今も動的な `JUMP` / `JUMPI` を使っています。\n- そのアイデアは後の提案に引き継がれました。[EIP-2315](/eip-2315/)（シンプルなサブルーチン）は Withdrawn です。[EIP-3540](/eip-3540/)、[EIP-4750](/eip-4750/)（関数）、メタ提案の [EIP-7692](/eip-7692/) を含む EVM Object Format 系の提案は、デプロイ時の検証と本物の関数を復活させましたが、こちらも Stagnant とされています。\n- ここにある opcode 番号とヘッダ形式は、このドラフト固有のものです。後の設計と一致すると思い込まないでください。\n"},"ko":{"lang":"ko","tldr":"EVM의 동적 점프를 정적 점프, 진짜 서브루틴, 배포 시점 검증으로 대체하자는 제안. EVM 코드를 분석, 검증, 컴파일하기 쉬워진다.","tags":["evm","opcodes","subroutines","validation","core"],"related":[2315,3540,4750,7692,1702],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-615/","markdown":"## 어떤 문제를 해결하나요?\n\nEVM에는 점프가 한 종류뿐입니다. **스택**에서 가져온 주소로 가는 `JUMP` / `JUMPI`입니다. 컴파일러는 함수 반환에도 이 동적 점프를 씁니다. 점프 대상이 런타임에 계산된 임의의 값일 수 있기 때문에, 도구가 컨트랙트의 제어 흐름을 쉽게 알아낼 수 없습니다. 그래서 다음 작업이 어렵거나 느려집니다.\n\n- 형식 검증과 버그를 찾는 정적 분석\n- EVM 바이트코드를 빠른 기계어로 컴파일하는 일\n- 코드가 스택 언더플로나 잘못된 점프에 걸리지 않음을 사전에 증명하는 일\n\n저자들은 분석이 거의 선형(`n log n`) 시간 안에 이루어져야 한다고 주장합니다. 그렇지 않으면 공격자가 검증기나 최적화기에서 이차 시간 폭증을 일으키는 컨트랙트를 만들 수 있기 때문입니다.\n\n## 어떻게 동작하나요?\n\nEIP-615는 새 코드에서 `JUMP`와 `JUMPI`를 폐기 예정으로 하고, Wasm과 CPU 명령어에 가깝게 대응하는 구조화된 대체 명령어를 추가합니다.\n\n| 새 opcode | 역할 |\n| --- | --- |\n| `JUMPTO t` / `JUMPIF t` | **즉시값** 대상으로의 무조건 / 조건부 점프 |\n| `JUMPV n, targets` | 인라인 대상 벡터를 통한 점프 테이블(switch) |\n| `BEGINSUB n_args, n_results` | 서브루틴 진입점과 스택 시그니처를 표시 |\n| `JUMPSUB t` / `JUMPSUBV n, targets` | 서브루틴을 직접 또는 테이블로 호출 |\n| `RETURNSUB` | 호출 다음 명령어로 복귀 |\n| `GETLOCAL n` / `PUTLOCAL n` | 프레임 로컬 스택 슬롯 읽기와 쓰기 |\n| `BEGINDATA` | 이후는 코드가 아니라 데이터 |\n\n서브루틴 호출은 프로그램이 건드릴 수 없는 별도의 리턴 스택과 프레임 포인터를 사용합니다. 새 방식의 바이트코드는 헤더(`\\0evm`과 버전)로 시작하며 **배포 시점에 검증**됩니다. 스택 언더플로를 일으키거나, 잘못된 위치로 점프하거나, 서브루틴을 잘못 쓸 수 있는 코드는 체인에 올라가기 전에 거부됩니다. 런타임 검사가 여전히 필요한 것은 가스 부족과 스택 오버플로뿐입니다. 새 코드와 기존 코드를 섞어 쓰려면 계정 버저닝([EIP-1702](/eip-1702/))에 의존합니다.\n\n## 샘플 코드\n\n설명용 어셈블리. 두 수를 더하는 서브루틴을 정적 점프로 호출합니다.\n\n```text\n; header: \"\\0evm\" + version\nBEGINSUB 0, 0          ; main routine\n  PUSH1 10\n  PUSH1 11\n  JUMPSUB add          ; immediate target, no dynamic jump\n  ; stack now holds 21\n  STOP\n\nadd:\nBEGINSUB 2, 1          ; takes 2 args, returns 1\n  ADD\n  RETURNSUB\n\nBEGINDATA              ; optional data section\n```\n\n호출자가 리턴 주소를 푸시하고 피호출자가 스택에 있는 값으로 `JUMP`하는 기존 EVM과 비교해 보세요.\n\n## 알아둘 점\n\n- 이 제안은 **Stagnant** 상태이며 채택된 적이 없습니다. 현재의 EVM 바이트코드는 여전히 동적 `JUMP` / `JUMPI`를 사용합니다.\n- 아이디어는 이후 제안들로 이어졌습니다. [EIP-2315](/eip-2315/)(단순 서브루틴)는 Withdrawn입니다. [EIP-3540](/eip-3540/), [EIP-4750](/eip-4750/)(함수), 메타 제안 [EIP-7692](/eip-7692/)를 포함한 EVM Object Format 계열은 배포 시점 검증과 진짜 함수를 다시 가져왔으며, 역시 Stagnant로 분류되어 있습니다.\n- 여기 나온 opcode 번호와 헤더 형식은 이 초안에만 해당합니다. 이후의 어떤 설계와도 일치한다고 가정하지 마세요.\n"},"zh":{"lang":"zh","tldr":"一项用静态跳转、真正的子程序和部署时验证来取代 EVM 动态跳转的提案，让 EVM 代码更易于分析、验证和编译。","tags":["evm","opcodes","subroutines","validation","core"],"related":[2315,3540,4750,7692,1702],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-615/","markdown":"## 它解决什么问题？\n\nEVM 只有一种跳转：跳到取自**栈**的地址的 `JUMP` / `JUMPI`。编译器甚至把这种动态跳转用于函数返回。由于跳转目标可以是运行时计算出的任意值，工具很难推断出合约的控制流。这使得下面这些工作变得困难或缓慢：\n\n- 形式化验证和用于查找漏洞的静态分析，\n- 把 EVM 字节码编译成高速的机器码，\n- 提前证明代码不会遇到栈下溢或非法跳转。\n\n作者认为，分析必须在接近线性（`n log n`）的时间内完成，否则攻击者可以构造合约，让验证器或优化器出现二次方级别的性能崩溃。\n\n## 它如何运作\n\nEIP-615 弃用新代码中的 `JUMP` 和 `JUMPI`，并加入与 Wasm 和 CPU 指令高度对应的结构化替代指令：\n\n| 新操作码 | 用途 |\n| --- | --- |\n| `JUMPTO t` / `JUMPIF t` | 无条件 / 有条件跳转到**立即数**目标 |\n| `JUMPV n, targets` | 通过内联目标向量实现的跳转表（switch） |\n| `BEGINSUB n_args, n_results` | 标记子程序入口及其栈签名 |\n| `JUMPSUB t` / `JUMPSUBV n, targets` | 直接或通过表调用子程序 |\n| `RETURNSUB` | 返回到调用之后的指令 |\n| `GETLOCAL n` / `PUTLOCAL n` | 读写帧局部的栈槽位 |\n| `BEGINDATA` | 此后的内容是数据，而不是代码 |\n\n子程序调用使用程序无法触及的独立返回栈和帧指针。新式字节码以头部（`\\0evm` 加版本号）开头，并在**部署时验证**。可能造成栈下溢、跳转到无效位置或误用子程序的代码，会在上链之前就被拒绝。只有 gas 耗尽和栈溢出仍需要运行时检查。新旧代码的混用依赖账户版本控制（[EIP-1702](/eip-1702/)）。\n\n## 示例代码\n\n示意性汇编：一个把两个数相加的子程序，通过静态跳转调用。\n\n```text\n; header: \"\\0evm\" + version\nBEGINSUB 0, 0          ; main routine\n  PUSH1 10\n  PUSH1 11\n  JUMPSUB add          ; immediate target, no dynamic jump\n  ; stack now holds 21\n  STOP\n\nadd:\nBEGINSUB 2, 1          ; takes 2 args, returns 1\n  ADD\n  RETURNSUB\n\nBEGINDATA              ; optional data section\n```\n\n可与旧版 EVM 对比：调用者压入返回地址，被调用者对栈上的任意值执行 `JUMP`。\n\n## 需要注意\n\n- 该提案处于 **Stagnant** 状态，从未被采纳。当前的 EVM 字节码仍然使用动态的 `JUMP` / `JUMPI`。\n- 它的想法在后来的提案中得以延续。[EIP-2315](/eip-2315/)（简单子程序）已被 Withdrawn。包括 [EIP-3540](/eip-3540/)、[EIP-4750](/eip-4750/)（函数）以及元提案 [EIP-7692](/eip-7692/) 在内的 EVM 对象格式系列，重新引入了部署时验证和真正的函数，同样被列为 Stagnant。\n- 这里的操作码编号和头部格式是该草案特有的。不要假定它们与任何后来的设计一致。\n"}}}
