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