Skip to content

[NativeAOT] How can I implement dynamic internal calls(or Qcall) in my custom NativeAOT runtime? #111143

Answered by AustinWise
TickThunder asked this question in Q&A
Discussion options

You must be logged in to vote

I hacked together a proof of concept. It shows one way of generating code of InternalCall methods. It is based on how IL is generated for P/Invoke calls:

AustinWise@56db902

There are lot of missing pieces:

  • There is only one hard-coded function, rather than supporting registering functions.
  • It currently assumes the platform default calling convention for native functions, which may or may not be right.
  • It does not implement caching when looking up the function
  • It does no marshalling of parameter types
  • The GC is always transitioned to preemptive mode when calling the native function

The last two are where this will start to get complicated. In the sample in the documention and other icall…

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
3 replies
@TickThunder
Comment options

@AustinWise
Comment options

@AustinWise
Comment options

Comment options

You must be logged in to vote
6 replies
@TickThunder
Comment options

@AustinWise
Comment options

@TickThunder
Comment options

@AustinWise
Comment options

@TickThunder
Comment options

Answer selected by TickThunder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants