compiler: add intrinsic for context-object primitive

release
Slava Pestov 2010-03-26 23:11:05 -04:00
parent d3767a7f27
commit d98e752199
4 changed files with 22 additions and 4 deletions

View File

@ -664,6 +664,10 @@ INSN: ##vm-field-ptr
def: dst/int-rep
literal: field-name ;
INSN: ##vm-field
def: dst/int-rep
literal: field-name ;
! FFI
INSN: ##alien-invoke
literal: params stack-frame ;

View File

@ -30,6 +30,7 @@ IN: compiler.cfg.intrinsics
{
{ kernel.private:tag [ drop emit-tag ] }
{ kernel.private:context-object [ emit-context-object ] }
{ kernel.private:special-object [ emit-special-object ] }
{ kernel.private:(identity-hashcode) [ drop emit-identity-hashcode ] }
{ math.private:both-fixnums? [ drop emit-both-fixnums? ] }

View File

@ -3,17 +3,29 @@
USING: namespaces layouts sequences kernel math accessors
compiler.tree.propagation.info compiler.cfg.stacks
compiler.cfg.hats compiler.cfg.instructions
compiler.cfg.builder.blocks
compiler.cfg.utilities ;
FROM: vm => context-field-offset ;
IN: compiler.cfg.intrinsics.misc
: emit-tag ( -- )
ds-pop tag-mask get ^^and-imm ^^tag-fixnum ds-push ;
: emit-special-object ( node -- )
dup node-input-infos first literal>> [
"special-objects" ^^vm-field-ptr
swap node-input-infos first literal>>
[ ds-drop 0 ^^slot-imm ] [ ds-pop ^^offset>slot ^^slot ] if*
ds-push ;
ds-drop swap 0 ^^slot-imm
ds-push
] [ emit-primitive ] ?if ;
: context-object-offset ( -- n )
"context-objects" context-field-offset cell /i ;
: emit-context-object ( node -- )
dup node-input-infos first literal>> [
"ctx" ^^vm-field
ds-drop swap context-object-offset + 0 ^^slot-imm ds-push
] [ emit-primitive ] ?if ;
: emit-identity-hashcode ( -- )
ds-pop tag-mask get bitnot ^^load-immediate ^^and 0 0 ^^slot-imm

View File

@ -211,6 +211,7 @@ CODEGEN: ##compare-float-ordered %compare-float-ordered
CODEGEN: ##compare-float-unordered %compare-float-unordered
CODEGEN: ##save-context %save-context
CODEGEN: ##vm-field-ptr %vm-field-ptr
CODEGEN: ##vm-field %vm-field
CODEGEN: _fixnum-add %fixnum-add
CODEGEN: _fixnum-sub %fixnum-sub