M: ##set-slot insn-slot# slot>> constant ;
M: ##set-slot-imm insn-slot# slot>> ;
M: ##alien-global insn-slot# [ library>> ] [ symbol>> ] bi 2array ;
+M: ##vm-field-ptr insn-slot# fieldname>> 1array ; ! is this right?
M: ##slot insn-object obj>> resolve ;
M: ##slot-imm insn-object obj>> resolve ;
M: ##set-slot insn-object obj>> resolve ;
M: ##set-slot-imm insn-object obj>> resolve ;
M: ##alien-global insn-object drop \ ##alien-global ;
+M: ##vm-field-ptr insn-object drop \ ##vm-field-ptr ;
: init-alias-analysis ( insns -- insns' )
H{ } clone histories set
: ^^allot-byte-array ( n -- dst ) 2 cells + byte-array ^^allot ; inline
: ^^offset>slot ( vreg -- vreg' ) cell 4 = [ 1 ^^shr-imm ] [ any-rep ^^copy ] if ; inline
: ^^tag-fixnum ( src -- dst ) tag-bits get ^^shl-imm ; inline
-: ^^untag-fixnum ( src -- dst ) tag-bits get ^^sar-imm ; inline
\ No newline at end of file
+: ^^untag-fixnum ( src -- dst ) tag-bits get ^^sar-imm ; inline
def: dst/int-rep
literal: symbol library ;
+INSN: ##vm-field-ptr
+def: dst/int-rep
+literal: fieldname ;
+
! FFI
INSN: ##alien-invoke
literal: params stack-frame ;
ds-pop tag-mask get ^^and-imm ^^tag-fixnum ds-push ;
: emit-getenv ( node -- )
- "userenv" f ^^alien-global
+ "userenv" ^^vm-field-ptr
swap node-input-infos first literal>>
[ ds-drop 0 ^^slot-imm ] [ ds-pop ^^offset>slot 0 ^^slot ] if*
ds-push ;
[ dst>> ] [ symbol>> ] [ library>> ] tri
%alien-global ;
+M: ##vm-field-ptr generate-insn
+ [ dst>> ] [ fieldname>> ] bi %vm-field-ptr ;
+
! ##alien-invoke
GENERIC: next-fastcall-param ( rep -- )
HOOK: %set-alien-vector cpu ( ptr value rep -- )
HOOK: %alien-global cpu ( dst symbol library -- )
+HOOK: %vm-field-ptr cpu ( dst fieldname -- )
HOOK: %allot cpu ( dst size class temp -- )
HOOK: %write-barrier cpu ( src card# table -- )
[ drop %load-vm-addr ]
[ [ dup ] dip vm-field-offset ADDI ] 2bi ;
+M: ppc %vm-field-ptr ( dst field -- ) %load-vm-field-addr ;
M: ppc machine-registers
{
! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-<<<<<<< HEAD
USING: accessors assocs alien alien.c-types arrays strings
cpu.x86.assembler cpu.x86.assembler.private cpu.x86.assembler.operands
cpu.architecture kernel kernel.private math memory namespaces make
compiler.cfg.comparisons
compiler.cfg.stack-frame
compiler.codegen
-compiler.codegen.fixup ;
-=======
-USING: accessors alien combinators compiler.cfg.comparisons
-compiler.cfg.intrinsics compiler.cfg.registers
-compiler.cfg.stack-frame compiler.codegen.fixup compiler.constants
-cpu.architecture cpu.x86.assembler cpu.x86.assembler.operands fry
-kernel layouts locals make math math.order namespaces sequences system
-vm ;
->>>>>>> Added a vm C-STRUCT, using it for struct offsets in x86 asm
+compiler.codegen.fixup vm ;
IN: cpu.x86
<< enable-fixnum-log2 >>
M: x86 %shr [ SHR ] emit-shift ;
M: x86 %sar [ SAR ] emit-shift ;
+M: x86 %vm-field-ptr ( dst field -- )
+ [ drop 0 MOV rc-absolute-cell rt-vm rel-fixup ]
+ [ vm-field-offset ADD ] 2bi ;
+
: load-zone-ptr ( reg -- )
#! Load pointer to start of zone array
- [ 0 MOV rc-absolute-cell rt-vm rel-fixup ]
- [ "nursery" vm-field-offset ADD ] bi ;
+ "nursery" %vm-field-ptr ;
: load-allot-ptr ( nursery-ptr allot-ptr -- )
[ drop load-zone-ptr ] [ swap cell [+] MOV ] 2bi ;
dst class store-tagged
nursery-ptr size inc-allot-ptr ;
-: %vm-field-ptr ( reg field -- )
- [ drop 0 MOV rc-absolute-cell rt-vm rel-fixup ]
- [ vm-field-offset ADD ] 2bi ;
M:: x86 %write-barrier ( src card# table -- )
#! Mark the card pointed to by vreg.
"inline_gc" f %vm-invoke ;
M: x86 %alien-global ( dst symbol library -- )
- [ 0 MOV ] 2dip rc-absolute-cell rel-dlsym ;
+ [ 0 MOV ] 2dip rc-absolute-cell rel-dlsym ;
M: x86 %epilogue ( n -- ) cell - incr-stack-reg ;
{ "zone" "nursery" }
{ "cell" "cards_offset" }
{ "cell" "decks_offset" }
+ { "cell" "__padding__" }
+ { "cell[70]" "userenv" }
;
: vm-field-offset ( field -- offset ) "vm" offset-of ;
\ No newline at end of file
NS_VOIDRETURN;
NS_HANDLER
dpush(vm->allot_alien(F,(cell)localException));
- quot = userenv[COCOA_EXCEPTION_ENV];
+ quot = vm->userenv[COCOA_EXCEPTION_ENV];
if(!tagged<object>(quot).type_p(QUOTATION_TYPE))
{
/* No Cocoa exception handler was registered, so
zone nursery; /* new objects are allocated here */
cell cards_offset;
cell decks_offset;
- cell __padding__ ; // align to 8byte boundary (for 32bit platforms)
+#ifndef FACTOR_64
+ cell __padding__ ; // align to 8 byte boundary
+#endif
cell userenv[USER_ENV]; /* TAGGED user environment data; see getenv/setenv prims */
-
+#ifndef FACTOR_64
+ cell __padding2__; // not sure why we need this, bootstrap doesn't work without it
+#endif
// segments
inline cell align_page(cell a);