[Lldb-commits] [lldb] [lldb] Introduce formatter bytecode version 2 ABI (PR #228589)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 2 14:53:53 PDT 2026
================
@@ -238,30 +240,40 @@ This is followed by one or more dictionary values that immediately follow each o
- Length of the program (ULEB128)
- The program bytecode
+### Calling conventions
+
+A record's version number (see [Embedding](#embedding)) also determines the calling convention of its methods. This includes how `self` (`this`) is represented.
+
+In **version 1** (legacy), `self` is a combination of the data stack after `@init` and `@update` run. Nothing constrains what shape `self` ends up in, it can be zero, one, or many values.
+
+In **version 2**, the runtime owns `self`, a `Dictionary` that starts out empty. The runtime passes the same `Dictionary` as the first argument to every method except `@summary`, followed by that method's own arguments (if any). Methods may modify `self` in place, and do not return it. The runtime keeps a reference, to ensure modifications are visible to subsequent method calls.
+
The possible function signatures are:
```{eval-rst}
-========= ========================= ==============================
-Signature Mnemonic Stack Effect
---------- ------------------------- ------------------------------
- 0x00 ``@summary`` ``(Object -> String)``
- 0x01 ``@init`` ``(Object -> Object+)``
- 0x02 ``@get_num_children`` ``(Object+ -> UInt)``
- 0x03 ``@get_child_index`` ``(Object+ String -> UInt)``
- 0x04 ``@get_child_at_index`` ``(Object+ UInt -> Object)``
- 0x05 ``@get_value`` ``(Object+ -> String)``
- 0x06 ``@update`` ``(Object+ -> Object+)``
-========= ========================= ==============================
+========= ========================= ============================================== ==============================================
+Signature Mnemonic Stack Effect (version 1) Stack Effect (version 2)
+--------- ------------------------- ---------------------------------------------- ----------------------------------------------
+ 0x00 ``@summary`` ``(Object -> String)`` ``(Object -> String)``
+ 0x01 ``@init`` ``(Object -> Object+)`` ``(Dictionary Object -> )``
----------------
adrian-prantl wrote:
Why doesn't init leave the (modified) Dictionary on the stack? In version 1 the idea was that init produces the global state (dubbed "Object+") that gets passed into all other functions.
https://github.com/llvm/llvm-project/pull/228589
More information about the lldb-commits
mailing list