The Asm.fif
in this directory is a next-gen TVM compiler edition that supports
two very special functions.
The first one is entry_point
and it is executed after SETCP 0
but before all
other logic with code dictionary is dispatched. It can be used to write inline code
inside the entry (top-level) code cell but requires special care to process and return
the provided arguments in the exact order. Also, some arguments may be undefined (such
as message value and full message for external message), and special care needs to
be taken not to accidentally invoke a stack underflow exception.
Also, when using entry_point
, and if it contains references, this may, in theory,
break calling other functions that are not inline
or inline_ref
, so special care
must be taken when defining function attributes.
N.B. There are no non-inline functions in this contract aside from getters, so this should not affect the code in any way. Moreover, I did some experiments, and it seems that TVM does not consider c3 a dictionary, but just executes it with method id on stack, so there should be no problems at all. (c3 cannot be used in any other way since it is cont)
The second one is entry_point_recv
, and it is executed with exactly the same params
as the entry_point
one, except that it is only executed when internal or external
message is received (that is, method id is 0 or -1). Also, it does not return anything
since all other cases are already dispatched using the default entry code, and it is
executed after the corresponding IFJMP
condition. Nevertheless, a special care still
needs to be taken not to use arguments that are not available for external message. Also,
when handling external message, extreaneous arguments MUST be carefully phased out using
a specially constructed ASM NOP
in a specific place, otherwise the compiler would attempt
to delete those arguments from stack before or after running actual code, therefore
crashing the contract.
This method should, in theory, not cause trubles with calling other functions since the
dictionary is in place at the first ref due to IFJMP
condition at the beginning.
Nevertheless, it is advised to write the function in a way that it would fit the root cell.
The same implications apply as to the entry_point
, since rearranging code and putting
the recv handler inside IFJMP
on the top actually saves considerable amount of gas!
No implications are actually relevant since DICTCALL
just pushes number to stack and calls c3.
The funcfiftlib compiler wasm is re-generated by using Asm.fif
from this directory
instead of the default library one. The patch-package
module automatically applies
corresponding patch from patches
directory to do this replacement. The pack-wasm
action is specifically used during this process to convert binary WASM to JS version.
Please pay attention that when switching branches the patches may not get applied,
especially if switching from main
to entrypoint
. Now the code will detect such
situation and that will result in an error with proper instructions what to do.
The reverse issue is not that important, because the assembler with added features assembles the code that does not use them exactly the same as the old one.