Ricing locals
parent
1c7d9c1066
commit
69a0ad5e42
|
@ -2,8 +2,8 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: bootstrap.image.private kernel kernel.private namespaces
|
||||
system cpu.x86.assembler layouts compiler.units math
|
||||
math.private compiler.constants vocabs
|
||||
slots.private words words.private ;
|
||||
math.private compiler.constants vocabs slots.private words
|
||||
words.private locals.backend ;
|
||||
IN: bootstrap.x86
|
||||
|
||||
big-endian off
|
||||
|
@ -302,4 +302,20 @@ big-endian off
|
|||
ds-reg [] arg0 MOV ! save
|
||||
] f f f \ fixnum-bitnot define-sub-primitive
|
||||
|
||||
[
|
||||
arg0 ds-reg [] MOV ! load local number
|
||||
fixnum>slot@ ! turn local number into offset
|
||||
arg1 bootstrap-cell MOV ! load base
|
||||
arg1 arg0 SUB ! turn it into a stack offset
|
||||
arg0 rs-reg arg1 [+] MOV ! load local value
|
||||
ds-reg [] arg0 MOV ! push to stack
|
||||
] f f f \ get-local define-sub-primitive
|
||||
|
||||
[
|
||||
arg0 ds-reg [] MOV ! load local count
|
||||
ds-reg bootstrap-cell SUB ! adjust stack pointer
|
||||
fixnum>slot@ ! turn local number into offset
|
||||
rs-reg arg0 SUB ! decrement retain stack pointer
|
||||
] f f f \ drop-locals define-sub-primitive
|
||||
|
||||
[ "bootstrap.x86" forget-vocab ] with-compilation-unit
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: math kernel slots.private sequences effects words ;
|
||||
USING: math.private kernel slots.private sequences effects words ;
|
||||
IN: locals.backend
|
||||
|
||||
: load-locals ( n -- )
|
||||
dup zero? [ drop ] [ swap >r 1- load-locals ] if ;
|
||||
|
||||
: get-local ( n -- value )
|
||||
dup zero? [ drop dup ] [ r> swap 1- get-local swap >r ] if ;
|
||||
dup 0 eq? [ drop ] [ swap >r 1 fixnum-fast load-locals ] if ;
|
||||
|
||||
: local-value 2 slot ; inline
|
||||
|
||||
: set-local-value 2 set-slot ; inline
|
||||
|
||||
: drop-locals ( n -- )
|
||||
dup zero? [ drop ] [ r> drop 1- drop-locals ] if ;
|
||||
|
|
|
@ -80,6 +80,7 @@ bootstrapping? on
|
|||
"io.files"
|
||||
"io.files.private"
|
||||
"io.streams.c"
|
||||
"locals.backend"
|
||||
"kernel"
|
||||
"kernel.private"
|
||||
"math"
|
||||
|
@ -370,6 +371,8 @@ tuple
|
|||
{ "eq?" "kernel" }
|
||||
{ "tag" "kernel.private" }
|
||||
{ "slot" "slots.private" }
|
||||
{ "get-local" "locals.backend" }
|
||||
{ "drop-locals" "locals.backend" }
|
||||
} [ make-sub-primitive ] assoc-each
|
||||
|
||||
! Primitive words
|
||||
|
|
Loading…
Reference in New Issue