Open lukaszcz opened 7 months ago
In Cairo Assembly we can "assign" through a pointer dereference only a memory-stored value, e.g., [[fp + 4]] = [ap - 1]
. Because the Alloc
hint returns a pointer stored at [ap]
instead of just using ap
as the pointer, assigning the tag and every constant number and pointer dereferencing argument requires using up a memory word and an execution step to transfer it to [ap]
first.
Hence, it makes sense to use Alloc
only when no more than 3 arguments are constants or constructor field references.
This also depends on the relative "cost" of executing different instructions (calls and rets versus assignments).
Use the
Alloc
hint instead of callingjuvix_get_regs
to fetchap
. This would save the call/ret instructions and four words of memory on each allocation.