From fd725bc7fdd609a3fcd295966922fb4f5f37f7b9 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 3 Nov 2023 11:13:58 +0300 Subject: docs(users/tazjin): add graph explaining tvix-eval Value structure Change-Id: I436aeba6da6a0d5096452529d7dd0be11a466e8f Reviewed-on: https://cl.tvl.fyi/c/depot/+/9905 Reviewed-by: tazjin Tested-by: BuildkiteCI Autosubmit: tazjin --- users/tazjin/tvix-eval-value.d2 | 98 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 users/tazjin/tvix-eval-value.d2 (limited to 'users/tazjin') diff --git a/users/tazjin/tvix-eval-value.d2 b/users/tazjin/tvix-eval-value.d2 new file mode 100644 index 000000000000..dad2dbcef2cb --- /dev/null +++ b/users/tazjin/tvix-eval-value.d2 @@ -0,0 +1,98 @@ +# D2 diagram of tvix-eval's `Value` type. +# +# can be rendered at https://play.d2lang.com/ +# +# colours have meanings: +# +# yellow: recurses +# orange: heap allocation +# red: refcount +# +# this intentionally does *not* include some internal variants + +Value -> Null +Value -> Bool +Value -> Integer +Value -> Float + +Box*.style.fill: "lightsalmon" +Rc*.style.fill: "salmon" +Vec\<*.style.fill: "salmon" + +Value -> String -> NixString -> "Box" + +Value -> Path -> "Box" -> PathBuf +PathBuf.style.fill: "lightsalmon" + +# attribute sets are kinda complicated +Value -> Attrs -> "Box" -> NixAttrs +NixAttrs -> Empty +NixAttrs -> KV +KV.style.fill: "LemonChiffon" +KV -> Value +KV -> Value +NixAttrs -> Map +Map -> "OrdMap" -> "MapEntry" +"OrdMap".style.fill: "lightsalmon" +"MapEntry".style.fill: "salmon" +"MapEntry".style.multiple: true +"MapEntry" -> NixString +"MapEntry" -> Value +"MapEntry".style.stroke-width: 15 +"MapEntry".style.stroke: "lemonchiffon" + +Value -> List -> NixList -> "Rc>" +"Rc>" -> "VecEntry" -> Value +"VecEntry".style.multiple: true +"VecEntry".style.fill: "salmon" +"VecEntry".style.stroke-width: 15 +"VecEntry".style.stroke: "lemonchiffon" + +# closures + +Value -> Closure -> "Rc" -> Closure +Closure -> "Rc" -> Lambda + +Lambda -> Chunk +Lambda -> SmolStr: sometimes allocates +SmolStr.style.fill: "lightsalmon" +Lambda -> usize +Lambda -> "Option" -> Formals + +Formals -> "HashMap" -> "MapEntry" +"HashMap".style.fill: "lightsalmon" +"MapEntry".style.fill: "salmon" +"MapEntry".style.multiple: true +"MapEntry" -> NixString + +Closure -> "Rc" -> Upvalues + +Upvalues -> "Vec" +"Vec" -> Value +"Vec".style.stroke-width: 15 +"Vec".style.stroke: "lemonchiffon" +Upvalues -> "Option>" +"Option>" -> Value +"Option>".style.fill: "lightsalmon" +"Option>".style.stroke-width: 15 +"Option>".style.stroke: "lemonchiffon" + +Value -> Blueprint -> "Rc" + +# builtins + +Value -> Builtin -> "Box" -> BuiltinRepr +BuiltinRepr -> "Rc" +BuiltinRepr -> "Vec" + +# thunks + +Value -> Thunk -> "Rc>" -> ThunkRepr +ThunkRepr -> Suspended +Suspended -> "Rc" +Suspended -> "Rc" + +ThunkRepr -> Native -> "Box Result>" +ThunkRepr -> Blackhole +ThunkRepr -> Evaluated -> Value +Evaluated.style.fill: "lemonchiffon" -- cgit 1.4.1