diff --git a/core/compiler/test/templates-early.factor b/core/compiler/test/templates-early.factor index 0eee6aabbf..4ea304f0d8 100644 --- a/core/compiler/test/templates-early.factor +++ b/core/compiler/test/templates-early.factor @@ -4,6 +4,8 @@ USING: compiler generator generator.registers generator.registers.private tools.test namespaces sequences words kernel math effects ; +: ( n -- vreg ) T{ int-regs } ; + [ [ ] [ init-templates ] unit-test @@ -58,8 +60,6 @@ words kernel math effects ; { +input+ { { f "x" } } } } clone [ [ 1 0 ] [ +input+ get { } { } guess-vregs ] unit-test - [ ] [ 1 0 ensure-vregs ] unit-test - ! [ t ] [ +input+ get phantom-d get compatible? ] unit-test [ ] [ finalize-contents ] unit-test [ ] [ [ template-inputs ] { } make drop ] unit-test ] bind @@ -119,12 +119,14 @@ SYMBOL: template-chosen ! This is not empty since a load instruction is emitted [ f ] [ - [ { { f "x" } } fast-input ] { } make empty? + [ { { f "x" } } +input+ set load-inputs ] { } make + empty? ] unit-test ! This is empty since we already loaded the value [ t ] [ - [ { { f "x" } } fast-input ] { } make empty? + [ { { f "x" } } +input+ set load-inputs ] { } make + empty? ] unit-test ! This is empty since we didn't change the stack diff --git a/core/cpu/architecture/architecture.factor b/core/cpu/architecture/architecture.factor index 2645d4476d..22efad5c4d 100644 --- a/core/cpu/architecture/architecture.factor +++ b/core/cpu/architecture/architecture.factor @@ -2,8 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays generic kernel kernel.private math memory namespaces sequences layouts system hashtables classes alien -byte-arrays bit-arrays float-arrays combinators words -inference.dataflow ; +byte-arrays bit-arrays float-arrays combinators words ; IN: cpu.architecture SYMBOL: compiler-backend @@ -153,8 +152,6 @@ M: integer v>operand tag-bits get shift ; M: f v>operand drop \ f tag-number ; -M: value v>operand value-literal ; - M: object load-literal v>operand load-indirect ; PREDICATE: integer small-slot cells small-enough? ; @@ -189,7 +186,7 @@ HOOK: %unbox-alien compiler-backend ( dst src -- ) HOOK: %unbox-f compiler-backend ( dst src -- ) -HOOK: %unbox-c-ptr compiler-backend ( dst src -- ) +HOOK: %unbox-any-c-ptr compiler-backend ( dst src -- ) HOOK: %box-alien compiler-backend ( dst src -- ) diff --git a/core/cpu/ppc/architecture/architecture.factor b/core/cpu/ppc/architecture/architecture.factor index 4942020e2a..87955c5080 100644 --- a/core/cpu/ppc/architecture/architecture.factor +++ b/core/cpu/ppc/architecture/architecture.factor @@ -269,7 +269,7 @@ M: ppc-backend %alien-invoke ( symbol dll -- ) 11 %load-dlsym (%call) ; M: ppc-backend %alien-callback ( quot -- ) - 0 load-literal "c_to_factor" f %alien-invoke ; + 3 load-indirect "c_to_factor" f %alien-invoke ; M: ppc-backend %prepare-alien-indirect ( -- ) "unbox_alien" f %alien-invoke @@ -324,7 +324,7 @@ M: ppc-backend %unbox-alien ( dst src -- ) M: ppc-backend %unbox-f ( dst src -- ) drop 0 swap v>operand LI ; -M: ppc-backend %unbox-c-ptr ( dst src -- ) +M: ppc-backend %unbox-any-c-ptr ( dst src -- ) "is-f" define-label "is-alien" define-label "end" define-label diff --git a/core/cpu/ppc/intrinsics/intrinsics.factor b/core/cpu/ppc/intrinsics/intrinsics.factor index 27398b6404..53fc237c37 100644 --- a/core/cpu/ppc/intrinsics/intrinsics.factor +++ b/core/cpu/ppc/intrinsics/intrinsics.factor @@ -15,7 +15,7 @@ IN: cpu.ppc.intrinsics "val" operand "obj" operand "n" get cells - "obj" operand-tag - ; + "obj" get operand-tag - ; : %slot-literal-any-tag "obj" operand "scratch" operand %untag @@ -58,7 +58,7 @@ IN: cpu.ppc.intrinsics "cards_offset" f pick %load-dlsym dup 0 LWZ ; : %write-barrier ( -- ) - "val" operand-immediate? "obj" get fresh-object? or [ + "val" get operand-immediate? "obj" get fresh-object? or [ "obj" operand "scratch" operand card-bits SRWI "val" operand load-cards-offset "scratch" operand dup "val" operand ADD @@ -674,8 +674,7 @@ define-alien-integer-intrinsics { unboxed-c-ptr "alien" simple-c-ptr } { f "offset" fixnum } } } - ! should be unboxed-alien - { +scratch+ { { unboxed-c-ptr "output" } } } + { +scratch+ { { unboxed-alien "output" } } } { +output+ { "output" } } { +clobber+ { "offset" } } } define-intrinsic diff --git a/core/effects/effects.factor b/core/effects/effects.factor index 62d6afc393..d881184508 100644 --- a/core/effects/effects.factor +++ b/core/effects/effects.factor @@ -51,3 +51,18 @@ M: integer (stack-picture) drop "object" ; M: effect clone [ effect-in clone ] keep effect-out clone ; + +: split-shuffle ( stack shuffle -- stack1 stack2 ) + effect-in length swap cut* ; + +: load-shuffle ( stack shuffle -- ) + effect-in [ set ] 2each ; + +: shuffled-values ( shuffle -- values ) + effect-out [ get ] map ; + +: shuffle* ( stack shuffle -- newstack ) + [ [ load-shuffle ] keep shuffled-values ] with-scope ; + +: shuffle ( stack shuffle -- newstack ) + [ split-shuffle ] keep shuffle* append ; diff --git a/core/generator/generator.factor b/core/generator/generator.factor index fd82135651..5d233cd166 100644 --- a/core/generator/generator.factor +++ b/core/generator/generator.factor @@ -2,9 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs classes combinators cpu.architecture effects generator.fixup generator.registers generic hashtables -inference inference.backend inference.dataflow inference.stack -io kernel kernel.private layouts math namespaces optimizer -prettyprint quotations sequences system threads words ; +inference inference.backend inference.dataflow io kernel +kernel.private layouts math namespaces optimizer prettyprint +quotations sequences system threads words ; IN: generator SYMBOL: compiled-xts @@ -246,10 +246,8 @@ M: #dispatch generate-node : define-if-intrinsic ( word quot inputs -- ) 2array 1array define-if-intrinsics ; -: do-intrinsic ( pair -- ) first2 with-template ; - : do-if-intrinsic ( #call pair -- next ) -