Skip to content

Add dedicated hostcall for inner PVM module compilation#530

Open
koute wants to merge 5 commits into
gavofyork:mainfrom
koute:main_compile_host_call
Open

Add dedicated hostcall for inner PVM module compilation#530
koute wants to merge 5 commits into
gavofyork:mainfrom
koute:main_compile_host_call

Conversation

@koute

@koute koute commented May 28, 2026

Copy link
Copy Markdown
Collaborator

This PR adds a dedicated hostcall to compile inner PVM modules.

  • The new compile hostcall which can compile a new PVM module from outer PVM's memory, or directly from a preimage in the database (this avoids the need to first fetch and copy the module's bytecode into the outer PVM's memory; it's essentially a historical_lookup + compiling from memory call merged into one)
  • machine now accepts a handle returned by the compile hostcalls (this makes it much cheaper to instantiate multiple VMs provided they use the same module)
  • expunge hostcall can now also destroy a compiled module handle, and accepts an extra argument which determines the type of handle that was passed
  • There's a maximum limit of 128 modules that can be kept in memory at the same time (this is subject to change if necessary)
  • The compiled modules are reference counted, so if there exists a live VM instance which uses a given PVM module then that module is also considered alive, even if it was expunged

Arguments to the compile hostcall are as follows:

  • φ7 (m) -> mode of operation, with 0 being from memory and 1 from a preimage
  • φ8 (p) -> pointer to the blob (memory mode) or a hash of the blob (preimage mode)
  • φ9 (l) -> length of the blob (memory mode) or maximum length of the blob used (preimage mode)
  • φ10 (f) -> offset in the blob (preimage mode only)
  • φ11 (i) -> service ID (preimage mode only)

Arguments to the expunge hostcall are:

  • φ7 (m) -> mode of operation, with 0 being an expunge of a VM instance, and 1 being an expunge of a program module
  • φ8 (n) -> handle to expunge

Rendered PDF.

@gavofyork

Copy link
Copy Markdown
Owner

There's no precedent on using multi-character subscripts in the $$\Omega$ formulations. I'd prefer to keep to single characters.

@gavofyork

Copy link
Copy Markdown
Owner

I also wonder how bad it would be to have the two compile_ variants be folded into a unified compile host-call? This is the convention thus far. I'd really like to keep the conceptual dictionary as minimal as possible.

@koute

koute commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

Sure, I'll change the subscripts to be single letter.

I can also try to unify both compile_ hostcalls into one, and we can see how it looks like.

If you'd like we could also unify expunge with drop by having only expunge, and pass the type of the handle as an argument.

@koute

koute commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

I've merged the two hostcalls into one. I've also merged drop into expunge while I was at it (let me know if you'd like them separate, in which case I can revert the change).

Also updated the PR description to describe the current state of the PR.

@koute koute changed the title Add dedicated hostcalls for inner PVM module compilation Add dedicated hostcall for inner PVM module compilation Jun 1, 2026
@gavofyork

Copy link
Copy Markdown
Owner

Yeah, looks good. Needs resolving...

@koute

koute commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator Author

Aligned with the newest changes on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants