aboutsummaryrefslogtreecommitdiff
path: root/docs/implementation
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-06-13 18:29:09 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-06-13 18:29:12 -0400
commit8fadd33ba6ce06ac1cd8d119f4bbf39c1634420e (patch)
treeab2489b58a04263aa994dbcbfc5b4740c2cfba61 /docs/implementation
parent7e86736d2b312324658c496a85f8b517569c3cb4 (diff)
Update VM docs with fused merged-array instructions
Diffstat (limited to 'docs/implementation')
-rw-r--r--docs/implementation/vm.html32
1 files changed, 20 insertions, 12 deletions
diff --git a/docs/implementation/vm.html b/docs/implementation/vm.html
index 7a0093db..ba2e9c84 100644
--- a/docs/implementation/vm.html
+++ b/docs/implementation/vm.html
@@ -114,7 +114,7 @@
</tr>
<tr>
<td align="right">0B</td>
-<td>ARRO</td>
+<td>LSTO</td>
<td align="center">X</td>
<td align="right"></td>
<td align="left"><code><span class='Function'>N</span></code></td>
@@ -122,19 +122,27 @@
</tr>
<tr>
<td align="right">0C</td>
-<td>ARRM</td>
+<td>LSTM</td>
<td align="center">X</td>
<td align="right">0B</td>
<td align="left"><code><span class='Function'>N</span></code></td>
<td>Create length-<code><span class='Function'>N</span></code> reference list</td>
</tr>
<tr>
+<td align="right">0D</td>
+<td>ARMO</td>
+<td align="center">HR</td>
+<td align="right">0B</td>
+<td align="left"><code><span class='Function'>N</span></code></td>
+<td>Create length-<code><span class='Function'>N</span></code> merged array</td>
+</tr>
+<tr>
<td align="right">0E</td>
-<td>ARRH</td>
+<td>ARMM</td>
<td align="center">HR</td>
-<td align="right"></td>
-<td align="left"></td>
-<td>Merge top of stack (for <code><span class='Bracket'>[]</span></code>)</td>
+<td align="right">0D</td>
+<td align="left"><code><span class='Function'>N</span></code></td>
+<td>Create length-<code><span class='Function'>N</span></code> merged reference list</td>
</tr>
<tr>
<td align="right">10</td>
@@ -405,15 +413,15 @@
</tr>
<tr>
<td align="right">0B</td>
-<td>ARRO</td>
+<td>LSTO</td>
<td><code><span class='Value'>x0</span> <span class='Value'>…</span> <span class='Value'>xm</span> <span class='Gets'>→</span> <span class='Bracket'>⟨</span><span class='Value'>x0</span> <span class='Value'>…</span> <span class='Value'>xm</span><span class='Bracket'>⟩</span></code></td>
<td><code><span class='Function'>N</span></code> total variables (<code><span class='Value'>m</span><span class='Function'>=</span><span class='Value'>n</span><span class='Function'>-</span><span class='Number'>1</span></code>)</td>
</tr>
<tr>
<td align="right">0B</td>
-<td>ARRH</td>
-<td><code><span class='Value'>l</span> <span class='Gets'>→</span> <span class='Value'>a</span></code></td>
-<td>List to array</td>
+<td>ARMO</td>
+<td><code><span class='Value'>x0</span> <span class='Value'>…</span> <span class='Value'>xm</span> <span class='Gets'>→</span> <span class='Bracket'>[</span><span class='Value'>x0</span> <span class='Value'>…</span> <span class='Value'>xm</span><span class='Bracket'>]</span></code></td>
+<td></td>
</tr>
<tr>
<td align="right">10</td>
@@ -532,9 +540,9 @@
<p>When a block is pushed with <strong>DFND</strong>, an instance of the block is created, with its <em>parent frame</em> set to be the frame of the currently-executing block. Setting the parent frame when the block is first seen, instead of when it's evaluated, is what distinguishes lexical from dynamic scoping. If it's an immediate block, it's evaluated immediately, and otherwise it's pushed onto the stack. When the block is evaluated, its frame is initialized using any arguments passed to it, the next instruction's index is pushed onto the return stack, and execution moves to the first instruction in the block. When the RETN instruction is encountered, an index is popped from the return stack and execution returns to this location. As an alternative to maintaining an explicit return stack, a block can be implemented as a native function that creates a new execution stack and returns the value in it when the <strong>RETN</strong> instruction is reached. This approach uses the implementation language's call stack for the return stack.</p>
<p>Local variables are manipulated with the <strong>VARO</strong> (or <strong>VARU</strong>) and <strong>VARM</strong> instructions, which load the value of a variable and a reference to it (see the next section) respectively. These instructions reference variables by <em>frame depth</em> and <em>slot index</em>. The frame depth indicates in which frame the variable is found: the current frame has depth 0, its block's parent frame has depth 1, and so on. The slot index is an index within that frame.</p>
<p>Slots should be initialized with some indication they are not yet defined. The variable can be defined with SETN only if it hasn't been defined yet, and can be accessed with VARO or VARU or modified with SETU, SETM, or SETC only if it <em>has</em> been defined.</p>
-<h3 id="variable-references-arrm-arrh-varm-setn-setu-setm-setc"><a class="header" href="#variable-references-arrm-arrh-varm-setn-setu-setm-setc">Variable references: ARRM ARRH VARM SETN SETU SETM SETC</a></h3>
+<h3 id="variable-references-lstm-armm-varm-setn-setu-setm-setc"><a class="header" href="#variable-references-lstm-armm-varm-setn-setu-setm-setc">Variable references: LSTM ARMM VARM SETN SETU SETM SETC</a></h3>
<p>A <em>variable reference</em> indicates a particular frame slot in a way that's independent of the execution context. For example, it could be a pointer to the slot, or a reference to the frame along with the index of the slot. <strong>VARM</strong> pushes a variable reference to the stack.</p>
-<p>A <em>reference list</em> is a list of variable references or reference lists. It's created with the <strong>ARRM</strong> instruction. In the Javascript VM there's no difference between a reference list and an ordinary BQN list other than the contents. The <strong>ARRH</strong> instruction converts this to a <em>merged reference list</em>, which matches an array of rank 1 or more by splitting it into cells.</p>
+<p>A <em>reference list</em> is a list of variable references or reference lists. It's created with the <strong>LSTM</strong> instruction. In the Javascript VM there's no difference between a reference list and an ordinary BQN list other than the contents. The <strong>ARMM</strong> instruction makes a <em>merged reference list</em>, which matches an array of rank 1 or more by splitting it into cells.</p>
<p>The <strong>SETN</strong>, <strong>SETU</strong>, <strong>SETM</strong>, and <strong>SETC</strong> instructions set a value for a reference. If the reference is to a variable, they simply set its value. For a reference list, the value needs to be destructured. It must be a list of the same length, and each reference in the reference list is set to the corresponding element of the value list.</p>
<p><strong>SETM</strong> and <strong>SETC</strong> additionally need to get the current value of a reference. For a variable reference this is its current value (with an error if it's not defined yet); for a reference list it's a list of the values of each reference in the list.</p>
<table>