]> gitweb.factorcode.org Git - factor.git/blob - basis/cpu/x86/x86.factor
Fixing various bugs; alias analysis wasn't handling ##phi nodes, stack analysis incor...
[factor.git] / basis / cpu / x86 / x86.factor
1 ! Copyright (C) 2005, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs alien alien.c-types arrays strings
4 cpu.x86.assembler cpu.x86.assembler.private cpu.architecture
5 kernel kernel.private math memory namespaces make sequences
6 words system layouts combinators math.order fry locals
7 compiler.constants compiler.cfg.registers
8 compiler.cfg.instructions compiler.cfg.intrinsics
9 compiler.codegen compiler.codegen.fixup ;
10 IN: cpu.x86
11
12 << enable-fixnum-log2 >>
13
14 ! Add some methods to the assembler to be more useful to the backend
15 M: label JMP 0 JMP rc-relative label-fixup ;
16 M: label JUMPcc [ 0 ] dip JUMPcc rc-relative label-fixup ;
17
18 M: x86 two-operand? t ;
19
20 HOOK: temp-reg-1 cpu ( -- reg )
21 HOOK: temp-reg-2 cpu ( -- reg )
22
23 HOOK: param-reg-1 cpu ( -- reg )
24 HOOK: param-reg-2 cpu ( -- reg )
25
26 HOOK: pic-tail-reg cpu ( -- reg )
27
28 M: x86 %load-immediate MOV ;
29
30 M: x86 %load-reference swap 0 MOV rc-absolute-cell rel-immediate ;
31
32 HOOK: ds-reg cpu ( -- reg )
33 HOOK: rs-reg cpu ( -- reg )
34
35 : reg-stack ( n reg -- op ) swap cells neg [+] ;
36
37 GENERIC: loc>operand ( loc -- operand )
38
39 M: ds-loc loc>operand n>> ds-reg reg-stack ;
40 M: rs-loc loc>operand n>> rs-reg reg-stack ;
41
42 M: x86 %peek loc>operand MOV ;
43 M: x86 %replace loc>operand swap MOV ;
44 : (%inc) ( n reg -- ) swap cells dup 0 > [ ADD ] [ neg SUB ] if ; inline
45 M: x86 %inc-d ( n -- ) ds-reg (%inc) ;
46 M: x86 %inc-r ( n -- ) rs-reg (%inc) ;
47
48 : align-stack ( n -- n' )
49     os macosx? cpu x86.64? or [ 16 align ] when ;
50
51 HOOK: reserved-area-size cpu ( -- n )
52
53 M: x86 stack-frame-size ( stack-frame -- i )
54     [ spill-counts>> [ swap reg-size * ] { } assoc>map sum ]
55     [ params>> ]
56     [ return>> ]
57     tri + +
58     3 cells +
59     reserved-area-size +
60     align-stack ;
61
62 M: x86 %call ( word -- ) 0 CALL rc-relative rel-word-pic ;
63
64 : xt-tail-pic-offset ( -- n )
65     #! See the comment in vm/cpu-x86.hpp
66     cell 4 + 1 + ; inline
67
68 M: x86 %jump ( word -- )
69     pic-tail-reg 0 MOV xt-tail-pic-offset rc-absolute-cell rel-here
70     0 JMP rc-relative rel-word-pic-tail ;
71
72 M: x86 %jump-label ( label -- ) 0 JMP rc-relative label-fixup ;
73
74 M: x86 %return ( -- ) 0 RET ;
75
76 : code-alignment ( align -- n )
77     [ building get [ integer? ] count dup ] dip align swap - ;
78
79 : align-code ( n -- )
80     0 <repetition> % ;
81
82 :: (%slot) ( obj slot tag temp -- op )
83     temp slot obj [+] LEA
84     temp tag neg [+] ; inline
85
86 :: (%slot-imm) ( obj slot tag -- op )
87     obj slot cells tag - [+] ; inline
88
89 M: x86 %slot ( dst obj slot tag temp -- ) (%slot) MOV ;
90 M: x86 %slot-imm ( dst obj slot tag -- ) (%slot-imm) MOV ;
91 M: x86 %set-slot ( src obj slot tag temp -- ) (%slot) swap MOV ;
92 M: x86 %set-slot-imm ( src obj slot tag -- ) (%slot-imm) swap MOV ;
93
94 M: x86 %add     [+] LEA ;
95 M: x86 %add-imm [+] LEA ;
96 M: x86 %sub     nip SUB ;
97 M: x86 %sub-imm neg [+] LEA ;
98 M: x86 %mul     nip swap IMUL2 ;
99 M: x86 %mul-imm nip IMUL2 ;
100 M: x86 %and     nip AND ;
101 M: x86 %and-imm nip AND ;
102 M: x86 %or      nip OR ;
103 M: x86 %or-imm  nip OR ;
104 M: x86 %xor     nip XOR ;
105 M: x86 %xor-imm nip XOR ;
106 M: x86 %shl-imm nip SHL ;
107 M: x86 %shr-imm nip SHR ;
108 M: x86 %sar-imm nip SAR ;
109 M: x86 %not     drop NOT ;
110 M: x86 %log2    BSR ;
111
112 : ?MOV ( dst src -- )
113     2dup = [ 2drop ] [ MOV ] if ; inline
114
115 :: move>args ( src1 src2 -- )
116     {
117         { [ src1 param-reg-2 = ] [ param-reg-1 src2 ?MOV param-reg-1 param-reg-2 XCHG ] }
118         { [ src1 param-reg-1 = ] [ param-reg-2 src2 ?MOV ] }
119         { [ src2 param-reg-1 = ] [ param-reg-2 src1 ?MOV param-reg-1 param-reg-2 XCHG ] }
120         { [ src2 param-reg-2 = ] [ param-reg-1 src1 ?MOV ] }
121         [
122             param-reg-1 src1 MOV
123             param-reg-2 src2 MOV
124         ]
125     } cond ;
126
127 HOOK: %alien-invoke-tail cpu ( func dll -- )
128
129 :: overflow-template ( src1 src2 insn inverse func -- )
130     <label> "no-overflow" set
131     src1 src2 insn call
132     ds-reg [] src1 MOV
133     "no-overflow" get JNO
134     src1 src2 inverse call
135     src1 src2 move>args
136     %prepare-alien-invoke
137     func f %alien-invoke
138     "no-overflow" resolve-label ; inline
139
140 :: overflow-template-tail ( src1 src2 insn inverse func -- )
141     <label> "no-overflow" set
142     src1 src2 insn call
143     "no-overflow" get JNO
144     src1 src2 inverse call
145     src1 src2 move>args
146     %prepare-alien-invoke
147     func f %alien-invoke-tail
148     "no-overflow" resolve-label
149     ds-reg [] src1 MOV
150     0 RET ; inline
151
152 M: x86 %fixnum-add ( src1 src2 -- )
153     [ ADD ] [ SUB ] "overflow_fixnum_add" overflow-template ;
154
155 M: x86 %fixnum-add-tail ( src1 src2 -- )
156     [ ADD ] [ SUB ] "overflow_fixnum_add" overflow-template-tail ;
157
158 M: x86 %fixnum-sub ( src1 src2 -- )
159     [ SUB ] [ ADD ] "overflow_fixnum_subtract" overflow-template ;
160
161 M: x86 %fixnum-sub-tail ( src1 src2 -- )
162     [ SUB ] [ ADD ] "overflow_fixnum_subtract" overflow-template-tail ;
163
164 M:: x86 %fixnum-mul ( src1 src2 temp1 temp2 -- )
165     "no-overflow" define-label
166     temp1 src1 MOV
167     temp1 tag-bits get SAR
168     src2 temp1 IMUL2
169     ds-reg [] temp1 MOV
170     "no-overflow" get JNO
171     src1 src2 move>args
172     param-reg-1 tag-bits get SAR
173     param-reg-2 tag-bits get SAR
174     %prepare-alien-invoke
175     "overflow_fixnum_multiply" f %alien-invoke
176     "no-overflow" resolve-label ;
177
178 M:: x86 %fixnum-mul-tail ( src1 src2 temp1 temp2 -- )
179     "overflow" define-label
180     temp1 src1 MOV
181     temp1 tag-bits get SAR
182     src2 temp1 IMUL2
183     "overflow" get JO
184     ds-reg [] temp1 MOV
185     0 RET
186     "overflow" resolve-label
187     src1 src2 move>args
188     param-reg-1 tag-bits get SAR
189     param-reg-2 tag-bits get SAR
190     %prepare-alien-invoke
191     "overflow_fixnum_multiply" f %alien-invoke-tail ;
192
193 : bignum@ ( reg n -- op )
194     cells bignum tag-number - [+] ; inline
195
196 M:: x86 %integer>bignum ( dst src temp -- )
197     #! on entry, inreg is a signed 32-bit quantity
198     #! exits with tagged ptr to bignum in outreg
199     #! 1 cell header, 1 cell length, 1 cell sign, + digits
200     #! length is the # of digits + sign
201     [
202         "end" define-label
203         ! Load cached zero value
204         dst 0 >bignum %load-reference
205         src 0 CMP
206         ! Is it zero? Then just go to the end and return this zero
207         "end" get JE
208         ! Allocate a bignum
209         dst 4 cells bignum temp %allot
210         ! Write length
211         dst 1 bignum@ 2 tag-fixnum MOV
212         ! Store value
213         dst 3 bignum@ src MOV
214         ! Compute sign
215         temp src MOV
216         temp cell-bits 1- SAR
217         temp 1 AND
218         ! Store sign
219         dst 2 bignum@ temp MOV
220         ! Make negative value positive
221         temp temp ADD
222         temp NEG
223         temp 1 ADD
224         src temp IMUL2
225         ! Store the bignum
226         dst 3 bignum@ temp MOV
227         "end" resolve-label
228     ] with-scope ;
229
230 M:: x86 %bignum>integer ( dst src temp -- )
231     [
232         "end" define-label
233         ! load length
234         temp src 1 bignum@ MOV
235         ! if the length is 1, its just the sign and nothing else,
236         ! so output 0
237         dst 0 MOV
238         temp 1 tag-fixnum CMP
239         "end" get JE
240         ! load the value
241         dst src 3 bignum@ MOV
242         ! load the sign
243         temp src 2 bignum@ MOV
244         ! convert it into -1 or 1
245         temp temp ADD
246         temp NEG
247         temp 1 ADD
248         ! make dst signed
249         temp dst IMUL2
250         "end" resolve-label
251     ] with-scope ;
252
253 M: x86 %add-float nip ADDSD ;
254 M: x86 %sub-float nip SUBSD ;
255 M: x86 %mul-float nip MULSD ;
256 M: x86 %div-float nip DIVSD ;
257
258 M: x86 %integer>float CVTSI2SD ;
259 M: x86 %float>integer CVTTSD2SI ;
260
261 M: x86 %copy ( dst src -- ) ?MOV ;
262
263 M: x86 %copy-float ( dst src -- )
264     2dup = [ 2drop ] [ MOVSD ] if ;
265
266 M: x86 %unbox-float ( dst src -- )
267     float-offset [+] MOVSD ;
268
269 M:: x86 %unbox-any-c-ptr ( dst src temp -- )
270     [
271         { "is-byte-array" "end" "start" } [ define-label ] each
272         dst 0 MOV
273         temp src MOV
274         ! We come back here with displaced aliens
275         "start" resolve-label
276         ! Is the object f?
277         temp \ f tag-number CMP
278         "end" get JE
279         ! Is the object an alien?
280         temp header-offset [+] alien type-number tag-fixnum CMP
281         "is-byte-array" get JNE
282         ! If so, load the offset and add it to the address
283         dst temp alien-offset [+] ADD
284         ! Now recurse on the underlying alien
285         temp temp underlying-alien-offset [+] MOV
286         "start" get JMP
287         "is-byte-array" resolve-label
288         ! Add byte array address to address being computed
289         dst temp ADD
290         ! Add an offset to start of byte array's data
291         dst byte-array-offset ADD
292         "end" resolve-label
293     ] with-scope ;
294
295 M:: x86 %box-float ( dst src temp -- )
296     dst 16 float temp %allot
297     dst float-offset [+] src MOVSD ;
298
299 : alien@ ( reg n -- op ) cells alien tag-number - [+] ;
300
301 M:: x86 %box-alien ( dst src temp -- )
302     [
303         "end" define-label
304         dst \ f tag-number MOV
305         src 0 CMP
306         "end" get JE
307         dst 4 cells alien temp %allot
308         dst 1 alien@ \ f tag-number MOV
309         dst 2 alien@ \ f tag-number MOV
310         ! Store src in alien-offset slot
311         dst 3 alien@ src MOV
312         "end" resolve-label
313     ] with-scope ;
314
315 : small-reg-4 ( reg -- reg' )
316     H{
317         { EAX EAX }
318         { ECX ECX }
319         { EDX EDX }
320         { EBX EBX }
321         { ESP ESP }
322         { EBP EBP }
323         { ESI ESP }
324         { EDI EDI }
325
326         { RAX EAX }
327         { RCX ECX }
328         { RDX EDX }
329         { RBX EBX }
330         { RSP ESP }
331         { RBP EBP }
332         { RSI ESP }
333         { RDI EDI }
334     } at ; inline
335
336 : small-reg-2 ( reg -- reg' )
337     small-reg-4 H{
338         { EAX AX }
339         { ECX CX }
340         { EDX DX }
341         { EBX BX }
342         { ESP SP }
343         { EBP BP }
344         { ESI SI }
345         { EDI DI }
346     } at ; inline
347
348 : small-reg-1 ( reg -- reg' )
349     small-reg-4 {
350         { EAX AL }
351         { ECX CL }
352         { EDX DL }
353         { EBX BL }
354     } at ; inline
355
356 : small-reg ( reg size -- reg' )
357     {
358         { 1 [ small-reg-1 ] }
359         { 2 [ small-reg-2 ] }
360         { 4 [ small-reg-4 ] }
361     } case ;
362
363 : small-regs ( -- regs ) { EAX ECX EDX EBX } ; inline
364
365 : small-reg-that-isn't ( exclude -- reg' )
366     small-regs swap [ small-reg-4 ] map '[ _ memq? not ] find nip ;
367
368 : with-save/restore ( reg quot -- )
369     [ drop PUSH ] [ call ] [ drop POP ] 2tri ; inline
370
371 :: with-small-register ( dst exclude quot: ( new-dst -- ) -- )
372     #! If the destination register overlaps a small register, we
373     #! call the quot with that. Otherwise, we find a small
374     #! register that is not in exclude, and call quot, saving
375     #! and restoring the small register.
376     dst small-reg-4 small-regs memq? [ dst quot call ] [
377         exclude small-reg-that-isn't
378         [ quot call ] with-save/restore
379     ] if ; inline
380
381 M:: x86 %string-nth ( dst src index temp -- )
382     "end" define-label
383     dst { src index temp } [| new-dst |
384         ! Load the least significant 7 bits into new-dst.
385         ! 8th bit indicates whether we have to load from
386         ! the aux vector or not.
387         temp src index [+] LEA
388         new-dst 1 small-reg temp string-offset [+] MOV
389         new-dst new-dst 1 small-reg MOVZX
390         ! Do we have to look at the aux vector?
391         new-dst HEX: 80 CMP
392         "end" get JL
393         ! Yes, this is a non-ASCII character. Load aux vector
394         temp src string-aux-offset [+] MOV
395         new-dst temp XCHG
396         ! Compute index
397         new-dst index ADD
398         new-dst index ADD
399         ! Load high 16 bits
400         new-dst 2 small-reg new-dst byte-array-offset [+] MOV
401         new-dst new-dst 2 small-reg MOVZX
402         new-dst 7 SHL
403         ! Compute code point
404         new-dst temp XOR
405         "end" resolve-label
406         dst new-dst ?MOV
407     ] with-small-register ;
408
409 M:: x86 %set-string-nth-fast ( ch str index temp -- )
410     ch { index str temp } [| new-ch |
411         new-ch ch ?MOV
412         temp str index [+] LEA
413         temp string-offset [+] new-ch 1 small-reg MOV
414     ] with-small-register ;
415
416 :: %alien-integer-getter ( dst src size quot -- )
417     dst { src } [| new-dst |
418         new-dst dup size small-reg dup src [] MOV
419         quot call
420         dst new-dst ?MOV
421     ] with-small-register ; inline
422
423 : %alien-unsigned-getter ( dst src size -- )
424     [ MOVZX ] %alien-integer-getter ; inline
425
426 M: x86 %alien-unsigned-1 1 %alien-unsigned-getter ;
427 M: x86 %alien-unsigned-2 2 %alien-unsigned-getter ;
428
429 : %alien-signed-getter ( dst src size -- )
430     [ MOVSX ] %alien-integer-getter ; inline
431
432 M: x86 %alien-signed-1 1 %alien-signed-getter ;
433 M: x86 %alien-signed-2 2 %alien-signed-getter ;
434 M: x86 %alien-signed-4 4 %alien-signed-getter ;
435
436 M: x86 %alien-unsigned-4 4 [ 2drop ] %alien-integer-getter ;
437
438 M: x86 %alien-cell [] MOV ;
439 M: x86 %alien-float dupd [] MOVSS dup CVTSS2SD ;
440 M: x86 %alien-double [] MOVSD ;
441
442 :: %alien-integer-setter ( ptr value size -- )
443     value { ptr } [| new-value |
444         new-value value ?MOV
445         ptr [] new-value size small-reg MOV
446     ] with-small-register ; inline
447
448 M: x86 %set-alien-integer-1 1 %alien-integer-setter ;
449 M: x86 %set-alien-integer-2 2 %alien-integer-setter ;
450 M: x86 %set-alien-integer-4 4 %alien-integer-setter ;
451 M: x86 %set-alien-cell [ [] ] dip MOV ;
452 M: x86 %set-alien-float dup dup CVTSD2SS [ [] ] dip MOVSS ;
453 M: x86 %set-alien-double [ [] ] dip MOVSD ;
454
455 : load-zone-ptr ( reg -- )
456     #! Load pointer to start of zone array
457     0 MOV "nursery" f rc-absolute-cell rel-dlsym ;
458
459 : load-allot-ptr ( nursery-ptr allot-ptr -- )
460     [ drop load-zone-ptr ] [ swap cell [+] MOV ] 2bi ;
461
462 : inc-allot-ptr ( nursery-ptr n -- )
463     [ cell [+] ] dip 8 align ADD ;
464
465 : store-header ( temp class -- )
466     [ [] ] [ type-number tag-fixnum ] bi* MOV ;
467
468 : store-tagged ( dst tag -- )
469     tag-number OR ;
470
471 M:: x86 %allot ( dst size class nursery-ptr -- )
472     nursery-ptr dst load-allot-ptr
473     dst class store-header
474     dst class store-tagged
475     nursery-ptr size inc-allot-ptr ;
476
477 M:: x86 %write-barrier ( src card# table -- )
478     #! Mark the card pointed to by vreg.
479     ! Mark the card
480     card# src MOV
481     card# card-bits SHR
482     table "cards_offset" f %alien-global
483     table table [] MOV
484     table card# [+] card-mark <byte> MOV
485
486     ! Mark the card deck
487     card# deck-bits card-bits - SHR
488     table "decks_offset" f %alien-global
489     table table [] MOV
490     table card# [+] card-mark <byte> MOV ;
491
492 M: x86 %gc ( -- )
493     "end" define-label
494     temp-reg-1 load-zone-ptr
495     temp-reg-2 temp-reg-1 cell [+] MOV
496     temp-reg-2 1024 ADD
497     temp-reg-1 temp-reg-1 3 cells [+] MOV
498     temp-reg-2 temp-reg-1 CMP
499     "end" get JLE
500     %prepare-alien-invoke
501     "minor_gc" f %alien-invoke
502     "end" resolve-label ;
503
504 M: x86 %alien-global
505     [ 0 MOV ] 2dip rc-absolute-cell rel-dlsym ;
506
507 HOOK: stack-reg cpu ( -- reg )
508
509 : decr-stack-reg ( n -- )
510     dup 0 = [ drop ] [ stack-reg swap SUB ] if ;
511
512 : incr-stack-reg ( n -- )
513     dup 0 = [ drop ] [ stack-reg swap ADD ] if ;
514
515 M: x86 %epilogue ( n -- ) cell - incr-stack-reg ;
516
517 :: %boolean ( dst temp word -- )
518     dst \ f tag-number MOV
519     temp 0 MOV \ t rc-absolute-cell rel-immediate
520     dst temp word execute ; inline
521
522 M: x86 %compare ( dst temp cc src1 src2 -- )
523     CMP {
524         { cc< [ \ CMOVL %boolean ] }
525         { cc<= [ \ CMOVLE %boolean ] }
526         { cc> [ \ CMOVG %boolean ] }
527         { cc>= [ \ CMOVGE %boolean ] }
528         { cc= [ \ CMOVE %boolean ] }
529         { cc/= [ \ CMOVNE %boolean ] }
530     } case ;
531
532 M: x86 %compare-imm ( dst temp cc src1 src2 -- )
533     %compare ;
534
535 M: x86 %compare-float ( dst temp cc src1 src2 -- )
536     UCOMISD {
537         { cc< [ \ CMOVB %boolean ] }
538         { cc<= [ \ CMOVBE %boolean ] }
539         { cc> [ \ CMOVA %boolean ] }
540         { cc>= [ \ CMOVAE %boolean ] }
541         { cc= [ \ CMOVE %boolean ] }
542         { cc/= [ \ CMOVNE %boolean ] }
543     } case ;
544
545 M: x86 %compare-branch ( label cc src1 src2 -- )
546     CMP {
547         { cc< [ JL ] }
548         { cc<= [ JLE ] }
549         { cc> [ JG ] }
550         { cc>= [ JGE ] }
551         { cc= [ JE ] }
552         { cc/= [ JNE ] }
553     } case ;
554
555 M: x86 %compare-imm-branch ( label src1 src2 cc -- )
556     %compare-branch ;
557
558 M: x86 %compare-float-branch ( label cc src1 src2 -- )
559     UCOMISD {
560         { cc< [ JB ] }
561         { cc<= [ JBE ] }
562         { cc> [ JA ] }
563         { cc>= [ JAE ] }
564         { cc= [ JE ] }
565         { cc/= [ JNE ] }
566     } case ;
567
568 : stack@ ( n -- op ) stack-reg swap [+] ;
569
570 : param@ ( n -- op ) reserved-area-size + stack@ ;
571
572 : spill-integer-base ( stack-frame -- n )
573     [ params>> ] [ return>> ] bi + reserved-area-size + ;
574
575 : spill-integer@ ( n -- op )
576     cells
577     stack-frame get spill-integer-base
578     + stack@ ;
579
580 : spill-float-base ( stack-frame -- n )
581     [ spill-integer-base ]
582     [ spill-counts>> int-regs swap at int-regs reg-size * ]
583     bi + ;
584
585 : spill-float@ ( n -- op )
586     double-float-regs reg-size *
587     stack-frame get spill-float-base
588     + stack@ ;
589
590 M: x86 %spill-integer ( src n -- ) spill-integer@ swap MOV ;
591 M: x86 %reload-integer ( dst n -- ) spill-integer@ MOV ;
592
593 M: x86 %spill-float ( src n -- ) spill-float@ swap MOVSD ;
594 M: x86 %reload-float ( dst n -- ) spill-float@ MOVSD ;
595
596 M: x86 %loop-entry 16 code-alignment [ NOP ] times ;
597
598 M: int-regs %save-param-reg drop [ param@ ] dip MOV ;
599 M: int-regs %load-param-reg drop swap param@ MOV ;
600
601 GENERIC: MOVSS/D ( dst src reg-class -- )
602
603 M: single-float-regs MOVSS/D drop MOVSS ;
604 M: double-float-regs MOVSS/D drop MOVSD ;
605
606 M: float-regs %save-param-reg [ param@ ] 2dip MOVSS/D ;
607 M: float-regs %load-param-reg [ swap param@ ] dip MOVSS/D ;
608
609 GENERIC: push-return-reg ( reg-class -- )
610 GENERIC: load-return-reg ( n reg-class -- )
611 GENERIC: store-return-reg ( n reg-class -- )
612
613 M: x86 %prepare-alien-invoke
614     #! Save Factor stack pointers in case the C code calls a
615     #! callback which does a GC, which must reliably trace
616     #! all roots.
617     temp-reg-1 "stack_chain" f %alien-global
618     temp-reg-1 temp-reg-1 [] MOV
619     temp-reg-1 [] stack-reg MOV
620     temp-reg-1 [] cell SUB
621     temp-reg-1 2 cells [+] ds-reg MOV
622     temp-reg-1 3 cells [+] rs-reg MOV ;
623
624 M: x86 value-struct? drop t ;
625
626 M: x86 small-enough? ( n -- ? )
627     HEX: -80000000 HEX: 7fffffff between? ;
628
629 : next-stack@ ( n -- operand )
630     #! nth parameter from the next stack frame. Used to box
631     #! input values to callbacks; the callback has its own
632     #! stack frame set up, and we want to read the frame
633     #! set up by the caller.
634     stack-frame get total-size>> + stack@ ;