factor/library/compiler/x86/slots.factor

53 lines
1.5 KiB
Factor
Raw Normal View History

2005-05-13 00:09:49 -04:00
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: compiler-backend
2005-12-02 02:25:44 -05:00
USING: alien arrays assembler compiler inference kernel
2005-05-13 00:09:49 -04:00
kernel-internals lists math memory namespaces sequences words ;
M: %slot generate-node ( vop -- )
2005-12-04 22:06:12 -05:00
drop
2005-05-13 00:09:49 -04:00
! turn tagged fixnum slot # into an offset, multiple of 4
2005-12-04 22:06:12 -05:00
0 input-operand 1 SHR
2005-09-08 22:23:54 -04:00
! compute slot address in 0 vop-out
2005-12-04 22:06:12 -05:00
0 output-operand 0 input-operand ADD
2005-09-08 22:23:54 -04:00
! load slot value in 0 vop-out
2005-12-04 22:06:12 -05:00
0 output-operand dup 1array MOV ;
2005-05-13 00:09:49 -04:00
M: %fast-slot generate-node ( vop -- )
2005-12-04 22:06:12 -05:00
drop
0 output-operand 1 input-operand 0 input 2array MOV ;
2005-05-13 00:09:49 -04:00
: card-offset 1 getenv ;
M: %write-barrier generate-node ( vop -- )
#! Mark the card pointed to by vreg.
2005-12-04 22:06:12 -05:00
drop
0 input-operand dup card-bits SHR
2005-12-02 02:25:44 -05:00
card-offset 2array card-mark OR
0 rel-cards ;
2005-05-13 00:09:49 -04:00
M: %set-slot generate-node ( vop -- )
2005-12-04 22:06:12 -05:00
drop
2005-05-13 00:09:49 -04:00
! turn tagged fixnum slot # into an offset, multiple of 4
2005-12-04 22:06:12 -05:00
2 input-operand 1 SHR
2005-09-08 22:23:54 -04:00
! compute slot address in 1 vop-in
2005-12-04 22:06:12 -05:00
2 input-operand 1 input-operand ADD
2005-05-13 00:09:49 -04:00
! store new slot value
2005-12-04 22:06:12 -05:00
0 output-operand 1 input-operand 1array MOV ;
2005-05-13 00:09:49 -04:00
M: %fast-set-slot generate-node ( vop -- )
2005-12-04 22:06:12 -05:00
drop
1 input-operand 2 input 2array 0 output-operand MOV ;
2005-12-04 22:06:12 -05:00
: userenv@ ( n -- addr ) cell * "userenv" f dlsym + ;
M: %getenv generate-node ( vop -- )
2005-12-04 22:06:12 -05:00
drop
0 output-operand 0 input userenv@ 1array MOV
0 input 0 rel-userenv ;
M: %setenv generate-node ( vop -- )
2005-12-04 22:06:12 -05:00
drop
1 input userenv@ 1array 0 input-operand MOV
1 input rel-userenv ;