From 787a6796f1551a2fadac0b046172cc899083b26c Mon Sep 17 00:00:00 2001 From: Andrei Maiboroda Date: Tue, 18 Jul 2023 13:01:42 +0200 Subject: [PATCH] Update EIP-6206: Add non-returning functions motivation --- EIPS/eip-6206.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/EIPS/eip-6206.md b/EIPS/eip-6206.md index 2111f4e9732a96..795a19a319b92b 100644 --- a/EIPS/eip-6206.md +++ b/EIPS/eip-6206.md @@ -21,6 +21,8 @@ Additionally the format of the type sections is extended to allow declaring sect It is common for functions to make a call at the end of the routine only to then return. `JUMPF` optimizes this behavior by changing code sections without needing to update the return stack. +Knowing at validation time that a function will never return control allows for `JUMPF` to such function to be treated similar to terminating instructions, where extra items may be left on the operand stack at execution termination. This provides opportunities for compilers to generate more optimal code, both in code size and in spent gas. It is particularly benefitial for small error handling helpers, that end execution with `REVERT`: they are commonly reused in multiple branches and extracting them into a helper function is efficient, when there is no need to pop extra stack items before `JUMPF` to such helper. + ## Specification ### Type section changes