fix(v4.0.0): shorter chains of calls in the compiler capsule
Measured, compiling a DO loop left one return entry spare under INTERPRET and a defining word called from inside another word overflowed the nine-entry return stack (D-2); the prompt loop will take one more. C@ and C! shift without a loop. The code generator shifts each opcode into the word being built, so nothing is placed by a counted shift, and the address masks come from a table. The dictionary search, the in-liner, the end of a loop and the making of a data word are each one word reached by a jump. Every kind of line now leaves at least three return entries spare while it compiles; a word run from the interpreter has six; and CREATE ... DOES> works from the prompt, from a word, and from a word that calls that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
dac7ffac92
commit
806f876ee0
+15
-8
@@ -44,23 +44,30 @@ header DNEGATE
|
||||
L1: drop 1 + ;
|
||||
|
||||
\ ---- section 5.3: bytes --------------------------------------------------
|
||||
\ The shifts are written out, eight to a line, where DECOMPOSITION.md 5.3 has
|
||||
\ a FOR ... UNEXT loop: a loop keeps its count on the return stack, and C@ and
|
||||
\ C! are at the bottom of every chain of calls in the compiler capsule, where
|
||||
\ there is not an entry to spare (D-2). The result is the same.
|
||||
macro 8/ 2/ 2/ 2/ 2/ 2/ 2/ 2/ 2/ endmacro
|
||||
macro 8* 2* 2* 2* 2* 2* 2* 2* 2* endmacro
|
||||
|
||||
header C@
|
||||
: C@ ( baddr -- c )
|
||||
dup 2/ 2/ a! 3 and
|
||||
if K0 -1 + if K1 -1 + if K2
|
||||
drop @ 23 FOR 2/ UNEXT 255 and ;
|
||||
K2: drop @ 15 FOR 2/ UNEXT 255 and ;
|
||||
K1: drop @ 7 FOR 2/ UNEXT 255 and ;
|
||||
drop @ 8/ 8/ 8/ 255 and ;
|
||||
K2: drop @ 8/ 8/ 255 and ;
|
||||
K1: drop @ 8/ 255 and ;
|
||||
K0: drop @ 255 and ;
|
||||
|
||||
header C!
|
||||
: C! ( c baddr -- )
|
||||
dup 2/ 2/ a! 3 and push 255 and pop
|
||||
dup 2/ 2/ a! 3 and
|
||||
if K0 -1 + if K1 -1 + if K2
|
||||
drop 23 FOR 2* UNEXT @ 4278190080 inv and + ! ;
|
||||
K2: drop 15 FOR 2* UNEXT @ -16711681 and + ! ;
|
||||
K1: drop 7 FOR 2* UNEXT @ -65281 and + ! ;
|
||||
K0: drop @ -256 and + ! ;
|
||||
drop 8* 8* 8* 4278190080 and @ 4278190080 inv and + ! ;
|
||||
K2: drop 8* 8* 16711680 and @ -16711681 and + ! ;
|
||||
K1: drop 8* 65280 and @ -65281 and + ! ;
|
||||
K0: drop 255 and @ -256 and + ! ;
|
||||
|
||||
\ ---- section 5.9: strings ------------------------------------------------
|
||||
header CMOVE
|
||||
|
||||
Reference in New Issue
Block a user