diff --git a/basis/compiler/cfg/alias-analysis/alias-analysis.factor b/basis/compiler/cfg/alias-analysis/alias-analysis.factor index fcfc89ea52..cb8b2de543 100644 --- a/basis/compiler/cfg/alias-analysis/alias-analysis.factor +++ b/basis/compiler/cfg/alias-analysis/alias-analysis.factor @@ -190,12 +190,14 @@ M: ##slot-imm insn-slot# slot>> ; 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 diff --git a/basis/compiler/cfg/hats/hats.factor b/basis/compiler/cfg/hats/hats.factor index 469ba37703..1b99b5d4dd 100644 --- a/basis/compiler/cfg/hats/hats.factor +++ b/basis/compiler/cfg/hats/hats.factor @@ -57,4 +57,4 @@ insn-classes get [ : ^^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 diff --git a/basis/compiler/cfg/instructions/instructions.factor b/basis/compiler/cfg/instructions/instructions.factor index 32e5d46c61..7c28198f67 100644 --- a/basis/compiler/cfg/instructions/instructions.factor +++ b/basis/compiler/cfg/instructions/instructions.factor @@ -450,6 +450,10 @@ INSN: ##alien-global 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 ; diff --git a/basis/compiler/cfg/intrinsics/misc/misc.factor b/basis/compiler/cfg/intrinsics/misc/misc.factor index f9f2182a4e..f9f3488773 100644 --- a/basis/compiler/cfg/intrinsics/misc/misc.factor +++ b/basis/compiler/cfg/intrinsics/misc/misc.factor @@ -10,7 +10,7 @@ IN: compiler.cfg.intrinsics.misc 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 ; diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index 0456ff485f..de15cda21c 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -270,6 +270,9 @@ M: ##alien-global generate-insn [ 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 -- ) diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index da1bcfc61f..b9d07f578e 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -202,6 +202,7 @@ HOOK: %set-alien-double cpu ( ptr value -- ) 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 -- ) diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index 37a5369259..fc6a122101 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -36,6 +36,7 @@ enable-float-intrinsics [ 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 { diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index 7e73275dde..57517ba319 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -1,6 +1,5 @@ ! 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 @@ -12,15 +11,7 @@ compiler.cfg.intrinsics 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 >> @@ -564,10 +555,13 @@ M: x86 %shl [ SHL ] emit-shift ; 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 ; @@ -587,9 +581,6 @@ M:: x86 %allot ( dst size class nursery-ptr -- ) 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. @@ -627,7 +618,7 @@ M:: x86 %call-gc ( gc-root-count -- ) "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 ; diff --git a/basis/vm/vm.factor b/basis/vm/vm.factor index 655250d755..e2e7fc879c 100644 --- a/basis/vm/vm.factor +++ b/basis/vm/vm.factor @@ -17,6 +17,8 @@ C-STRUCT: vm { "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 diff --git a/vm/os-macosx.mm b/vm/os-macosx.mm index 865371b8ac..e4da7b2221 100644 --- a/vm/os-macosx.mm +++ b/vm/os-macosx.mm @@ -14,7 +14,7 @@ NS_DURING NS_VOIDRETURN; NS_HANDLER dpush(vm->allot_alien(F,(cell)localException)); - quot = userenv[COCOA_EXCEPTION_ENV]; + quot = vm->userenv[COCOA_EXCEPTION_ENV]; if(!tagged(quot).type_p(QUOTATION_TYPE)) { /* No Cocoa exception handler was registered, so diff --git a/vm/vm.hpp b/vm/vm.hpp index e0b598de6f..8372c3f0ba 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -8,9 +8,13 @@ struct factorvm { 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);