From f596312f499f58d608912f2bc38f6adf4825a3be Mon Sep 17 00:00:00 2001 From: Harry Kalogirou Date: Fri, 1 Dec 2023 18:29:57 +0200 Subject: [PATCH] Added some TODOS TODOS regarding the CFG<->deploy<->dynamic jump interactions --- vyper/venom/analysis.py | 14 +++++++++++--- vyper/venom/venom_to_assembly.py | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/vyper/venom/analysis.py b/vyper/venom/analysis.py index 0a5fdfe985..a369d31f28 100644 --- a/vyper/venom/analysis.py +++ b/vyper/venom/analysis.py @@ -19,6 +19,10 @@ def calculate_cfg(ctx: IRFunction) -> None: bb.cfg_out = OrderedSet() bb.out_vars = OrderedSet() + # TODO: This is a hack to support the old IR format + # where deploy is an instruction. Going directly to the new IR we should have just + # one entry for the contructor and one for the runtime core. These will be propertly + # linked in the CFG, and the deploy instruction will be removed completely. deploy_bb = None after_deploy_bb = None for i, bb in enumerate(ctx.basic_blocks): @@ -37,9 +41,13 @@ def calculate_cfg(ctx: IRFunction) -> None: else: entry_block = ctx.basic_blocks[0] - # Special case for the jump table of selector buckets - # and fallback. It will be generalized when the - # dispacher code is directly generated in Venom + # TODO: Special case for the jump table of selector buckets and fallback. + # It will be generalized when the dispacher code is directly generated in Venom. + # The when directly generating the dispatcher code from the AST we should be emitting + # a dynamic jmp instruction with all the posible targets (this in EOF this will be also + # a jump via jump table). This will remove the need for this special case, and will result + # in cleaner code for normalization just according to CFG, without the need to examine + # the block termination instructions. for bb in ctx.basic_blocks: if "selector_bucket_" in bb.label.value or bb.label.value == "fallback": bb.add_cfg_in(entry_block) diff --git a/vyper/venom/venom_to_assembly.py b/vyper/venom/venom_to_assembly.py index d0fe85f58d..f6ec45440a 100644 --- a/vyper/venom/venom_to_assembly.py +++ b/vyper/venom/venom_to_assembly.py @@ -71,7 +71,7 @@ ) -# REVIEW: "assembly" gets into the recursion due to how the original +# TODO: "assembly" gets into the recursion due to how the original # IR was structured recursively in regards with the deploy instruction. # There, recursing into the deploy instruction was by design, and # made it easier to make the assembly generated "recursive" (i.e.