在基于栈的虚拟机中实现 NaN 拳击

2作者: tracyspacy6 个月前
## 我的实现 我使用 64 位布局: - 位 63-51:安静 NaN 签名 (0x7FFC...) - 位 50-18:32 位有效载荷(整数、字符串池索引等) - 位 17-3:未使用 / (15 位) - 位 2-0:3 位类型标签 因此,我可以使用 5 种带标签的类型:`TRUE_VAL`、`FALSE_VAL`、`STRING_VAL`、`CALLDATA_VAL`、`U32_VAL` 这是为我正在构建的特定领域虚拟机,用于可编程任务管理(类似于“待办事项应用的 Vim”——具有可编写脚本行为的小核心)。该虚拟机是基于栈的,具有: - 字符串池和指令池(索引存储为 NaN-boxed 值) - 用于任务指令执行的调用栈 代码在这里:https://github.com/tracyspacy/spacydo/blob/main/src/values.rs
查看原文
## My Implementation<p>I&#x27;m using a 64-bit layout:<p>- Bits 63-51: Quiet NaN signature (0x7FFC...)<p>- Bits 50-18: 32-bit payload (integers, string pool indices, etc.)<p>- Bits 17-3: Unused&#x2F; (15 bits)<p>- Bits 2-0: 3-bit type tag<p>So it allows me to have 5 tagged types: `TRUE_VAL`, `FALSE_VAL`, `STRING_VAL`, `CALLDATA_VAL`, `U32_VAL`<p>This is for a domain-specific VM I&#x27;m building for programmable task management (think &quot;Vim for todo apps&quot; - small core with scriptable behaviors). The VM is stack-based with:<p>- String pooling &amp; instructions pooling (indices stored as NaN-boxed values) - Call stack for task instructions execution.<p>code is here : https:&#x2F;&#x2F;github.com&#x2F;tracyspacy&#x2F;spacydo&#x2F;blob&#x2F;main&#x2F;src&#x2F;values.rs