2010-04-01 20:06:18 -04:00
|
|
|
! Copyright (C) 2008, 2010 Slava Pestov.
|
2008-12-06 10:16:29 -05:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-11-11 01:50:57 -05:00
|
|
|
USING: namespaces layouts sequences kernel math accessors
|
|
|
|
compiler.tree.propagation.info compiler.cfg.stacks
|
|
|
|
compiler.cfg.hats compiler.cfg.instructions
|
2010-03-26 23:11:05 -04:00
|
|
|
compiler.cfg.builder.blocks
|
2009-11-11 01:50:57 -05:00
|
|
|
compiler.cfg.utilities ;
|
2010-04-01 20:06:18 -04:00
|
|
|
FROM: vm => context-field-offset vm-field-offset ;
|
2008-12-06 10:16:29 -05:00
|
|
|
IN: compiler.cfg.intrinsics.misc
|
|
|
|
|
|
|
|
: emit-tag ( -- )
|
2010-04-21 03:08:52 -04:00
|
|
|
ds-pop ^^tagged>integer tag-mask get ^^and-imm ds-push ;
|
2008-12-06 10:16:29 -05:00
|
|
|
|
2010-04-01 20:06:18 -04:00
|
|
|
: special-object-offset ( n -- offset )
|
|
|
|
cells "special-objects" vm-field-offset + ;
|
|
|
|
|
2010-01-13 00:08:18 -05:00
|
|
|
: emit-special-object ( node -- )
|
2010-03-26 23:11:05 -04:00
|
|
|
dup node-input-infos first literal>> [
|
2010-04-01 20:06:18 -04:00
|
|
|
ds-drop
|
|
|
|
special-object-offset ^^vm-field
|
2010-03-26 23:11:05 -04:00
|
|
|
ds-push
|
|
|
|
] [ emit-primitive ] ?if ;
|
|
|
|
|
2010-04-01 20:06:18 -04:00
|
|
|
: emit-set-special-object ( node -- )
|
|
|
|
dup node-input-infos second literal>> [
|
|
|
|
ds-drop
|
|
|
|
[ ds-pop ] dip special-object-offset ##set-vm-field
|
|
|
|
] [ emit-primitive ] ?if ;
|
|
|
|
|
|
|
|
: context-object-offset ( n -- n )
|
|
|
|
cells "context-objects" context-field-offset + ;
|
2010-03-26 23:11:05 -04:00
|
|
|
|
|
|
|
: emit-context-object ( node -- )
|
|
|
|
dup node-input-infos first literal>> [
|
2010-04-01 20:06:18 -04:00
|
|
|
"ctx" vm-field-offset ^^vm-field
|
|
|
|
ds-drop swap context-object-offset cell /i 0 ^^slot-imm ds-push
|
2010-03-26 23:11:05 -04:00
|
|
|
] [ emit-primitive ] ?if ;
|
2009-11-11 01:50:57 -05:00
|
|
|
|
|
|
|
: emit-identity-hashcode ( -- )
|
2010-04-21 03:08:52 -04:00
|
|
|
ds-pop ^^tagged>integer
|
|
|
|
tag-mask get bitnot ^^load-integer ^^and
|
|
|
|
0 ^^alien-cell
|
2009-11-11 01:50:57 -05:00
|
|
|
hashcode-shift ^^shr-imm
|
|
|
|
ds-push ;
|