Compare commits

...

2 Commits
main ... ascii

Author SHA1 Message Date
ccb3edb0ec Update rust/kcl-lib/src/execution/memory.rs
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
2025-03-28 21:01:24 -07:00
252050468d ascii art diagram
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-28 14:30:45 -07:00

View File

@ -201,6 +201,35 @@
//! check safety, it is not ever used for any decision. In any case, modifying the env storage is
//! must be safe if the env is in either state, so even if the transition happens at the same time
//! as the storage modification, it is ok.
//!
//! Here is an ascii art diagram of the memory system:
//!
//! +----------------------------+
//! | ProgramMemory |
//! |----------------------------|
//! | Envs: |
//! | |
//! | [ Env 1 ] |
//! | - Vars: { "a" = 10 } |
//! | - Epoch: 1 |
//! | - Owner ID: 0 | <- read-only
//! | |
//! | [ Env 2 ] |
//! | - Vars: { "b" = a } |
//! | - Epoch: 2 |
//! | - Owner ID: 42 | <- owned by Stack 42
//! | |
//! +-------------^--------------+
//! |
//! | shared, immutable OR
//! | uniquely owned mutable reference
//! +---------+---------+
//! | Stack 42 |
//! |-------------------|
//! | stack_id: 42 |
//! | env_stack: [2] |
//! | epoch: 2 |
//! +-------------------+
use std::{
cell::UnsafeCell,