This is the very first initial draft of how MoveVM can potentially support function pointer. We believe function pointer could be a very important corner stone of how interface should be implemented in the future.
In this implemetnation, we add three new opcodes and one more SignatureToken type:
GetFunctionPointer: Convert a FunctionHandle into a function pointer value on top of the stack
GetFunctionPointerGeneric: Convert a FunctionInstantiation into a function pointer value on top of the stack
CallFunctionPointer: Instruction to invoke the function pointer
Right now it has the following limitations:
No currying is allowed.
Only function with no acquire list can be obtained as function pointer to avoid reentrency issue and major refactor in our borrow semantics.
This implementation only passed compilation and is no way close to merging into main. The intention of this PR is just to assess the safety of this change and to collect usability feedbacks. I'll try to see how I can mod the IR to try the new feature out in the compiler
Motivation
This is the very first initial draft of how MoveVM can potentially support function pointer. We believe function pointer could be a very important corner stone of how interface should be implemented in the future.
In this implemetnation, we add three new opcodes and one more SignatureToken type:
FunctionHandle
into a function pointer value on top of the stackFunctionInstantiation
into a function pointer value on top of the stackRight now it has the following limitations:
Have you read the Contributing Guidelines on pull requests?
Yes.
Test Plan
This implementation only passed compilation and is no way close to merging into main. The intention of this PR is just to assess the safety of this change and to collect usability feedbacks. I'll try to see how I can mod the IR to try the new feature out in the compiler