You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another thing we could consider doing is optimizing accessing of variables who's pointers are offset from a value in the r-stack.
In a function, I use some contiguous available memory to store the local variables, and the root location is stored on the top of the r-stack.
So accessing the 3rd input of a function looks like 'r@ 2 + @'
I grab the pointer from the r-stack, add 2 to it so we are now pointing to the 3rd input, and then fetch it.
loading a value into the 3rd input of a function looks like 'r@ 2 + !'
So I am thinking we can add opcodes for access and setting the first 8 values
Currently we are using 8 opcodes to access or update a local variable. 5 opcodes to encode the integer, and 3 more opcodes to tell what we are doing.
By teaching the chalang VM these 16 new commands, we could get it down to 1 opcode for the first 8 local variables.
8 inputs is more than how many you need in the majority of function definitions.
The text was updated successfully, but these errors were encountered:
Another thing we could consider doing is optimizing accessing of variables who's pointers are offset from a value in the r-stack.
In a function, I use some contiguous available memory to store the local variables, and the root location is stored on the top of the r-stack.
So accessing the 3rd input of a function looks like 'r@ 2 + @'
I grab the pointer from the r-stack, add 2 to it so we are now pointing to the 3rd input, and then fetch it.
loading a value into the 3rd input of a function looks like 'r@ 2 + !'
So I am thinking we can add opcodes for access and setting the first 8 values
r@0 -> 'r@ @'
r!0 -> 'r@ !'
r@1 -> 'r@ 1 + @'
r!2 -> 'r@ 2 + !'
Currently we are using 8 opcodes to access or update a local variable. 5 opcodes to encode the integer, and 3 more opcodes to tell what we are doing.
By teaching the chalang VM these 16 new commands, we could get it down to 1 opcode for the first 8 local variables.
8 inputs is more than how many you need in the majority of function definitions.
The text was updated successfully, but these errors were encountered: