reilabs / hieratika

Efforts to compile LLVM bytecode to run on top of the CairoVM and hence execute provably on Starknet
http://starknet.io
Apache License 2.0
2 stars 0 forks source link

Design the Memory Representation (Initial) #29

Open ktemkin opened 2 months ago

ktemkin commented 2 months ago

Description

LLVM’s assumption of R/W memory and registers does not fit with the memory model used by the Cairo VM. We can either take the SSA form and treat the target as an infinite-register machine, or we can emulate R/W memory directly.

For this initial design phase we want to do the bare minimum to get mostly-correct semantics as far as the LLVM IR expects. This task includes designing the assignment model and the semantics of the operations on pointers.

iamrecursion commented 3 weeks ago

To add a bit more information to this:

wzmuda commented 1 week ago

LLVM Memory Model Meeting Notes

How to perform pointer operations without compromising performance while adhering to the read-only Cairo memory model.

Based on @Eagle941's notes taken live during today's meeting.

Problem breakdown

Allocator for Stack Memory

Virtual to Physical Allocation

Allocator

MMU

LLVM Instructions

- Wojtek's comment: are we sure about this? I don't see them in the langref.

Allocation

TODO

  1. Develop our target descriptor and pass it to rustc.
  2. Ensure the compiler checks against the target descriptor.
  3. Write the expected memory interface for the compiler to use polyfills.
  4. Write the memory model.
  5. Handle overcommitting.
iamrecursion commented 2 days ago

Something that might be interesting is the cairo-riscv project's allocator, thanks to Ariel!