---
eip: 2315
label: EIP-2315
title: Simple Subroutines for the EVM
status: Withdrawn
type: Standards Track
category: Core
created: 2019-10-17
requires: 3540, 3670, 4200
official: https://eips.ethereum.org/EIPS/eip-2315
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2315.md
canonical: https://eips.huatuo.xyz/eip-2315/
lang: en
tldr: A withdrawn proposal to give the EVM real subroutines (RJUMPSUB/RETURNSUB with a separate return stack) so code could be validated and compiled statically; its ideas were absorbed into the EOF proposals.
tags: [evm, opcodes, control-flow, eof, withdrawn]
---

# EIP-2315: Simple Subroutines for the EVM

> Two opcodes for efficient, safe, and static subroutines.

**TL;DR:** A withdrawn proposal to give the EVM real subroutines (RJUMPSUB/RETURNSUB with a separate return stack) so code could be validated and compiled statically; its ideas were absorbed into the EOF proposals.

## What problem does it solve?

The EVM has no "call a function and come back" instruction. Compilers fake subroutines with the dynamic `JUMP` opcode: they push a return address on the data stack, jump into the function body, and later `JUMP` back to whatever address is on the stack. This wastes gas and bytes, mixes return addresses in with ordinary data, and, worst of all, means a jump can go to any `JUMPDEST` in the code. Tools that want to analyse or compile EVM bytecode then face a potential "path explosion" when following control flow, which is a denial-of-service risk for validation at deploy time.

EIP-2315 proposed a small, conventional fix: static jumps plus a call/return pair, with a dedicated return stack, so control flow is known before the code ever runs.

## How it works

The final version of the proposal adds two opcodes and builds on the static jumps from [EIP-4200](/eip-4200/):

| Opcode | Byte | Behaviour |
| --- | --- | --- |
| `RJUMPSUB offset` | `0x5f` | Push `PC + 3` onto the return stack, then jump to `PC + offset` (2-byte signed immediate) |
| `RETURNSUB` | `0x5e` | Pop the return stack into `PC` |

The return stack is internal to the client: EVM code cannot read or overwrite it, so return addresses can't be corrupted.

Together with the EOF container ([EIP-3540](/eip-3540/)) and code validation ([EIP-3670](/eip-3670/)), the proposal requires code to be checked once at creation time:

- `JUMP` and `JUMPI` are invalid in this code; only relative jumps with constant targets are allowed.
- No jump may land in immediate data or outside its code section.
- The data stack height at any given `PC` must be the same on every path that reaches it, and never exceed 1024.

Those rules guarantee there is no stack underflow, every call to a subroutine sees the same number of inputs and outputs, and validation and compilation run in roughly linear time.

## Sample code

Illustrative bytecode for calling a "double the top of stack" subroutine (offsets are relative to the `RJUMPSUB` itself):

```text
PUSH1 0x05        ; argument
RJUMPSUB +4       ; call DOUBLE, return address = next instruction
STOP

DOUBLE:
DUP1
ADD               ; x + x
RETURNSUB         ; back to the caller
```

Compare the legacy pattern it replaces, which pushes the return address as ordinary data and needs a dynamic `JUMP`:

```text
PUSH1 ret  PUSH1 0x05  PUSH1 double  JUMP
ret:    JUMPDEST STOP
double: JUMPDEST DUP1 ADD SWAP1 JUMP
```

## Things to know

- **Status: Withdrawn.** The withdrawal reason given is that it was superseded by the EOF proposals. Function calls in EOF were later specified as `CALLF`/`RETF` in [EIP-4750](/eip-4750/).
- Earlier drafts of EIP-2315 (with different opcode semantics) were considered for the Berlin upgrade but were removed before it shipped, so these opcodes never went live on mainnet.
- The byte `0x5f` was later assigned to `PUSH0`, so the opcode numbers in this spec are historical only.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-2315
