]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.*: now when we're tracking uninitialized locations instead of
authorBjörn Lindqvist <bjourne@gmail.com>
Sun, 17 May 2015 01:11:32 +0000 (03:11 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Sun, 17 May 2015 05:59:34 +0000 (07:59 +0200)
initialized ones, the height slot isn't needed on ##call anymore

basis/compiler/cfg/builder/blocks/blocks.factor
basis/compiler/cfg/builder/builder-tests.factor
basis/compiler/cfg/instructions/instructions-docs.factor
basis/compiler/cfg/instructions/instructions.factor
basis/compiler/cfg/stacks/padding/padding-tests.factor
basis/compiler/cfg/stacks/padding/padding.factor
basis/compiler/codegen/codegen-tests.factor
basis/cpu/architecture/architecture.factor
basis/cpu/ppc/ppc.factor
basis/cpu/x86/x86.factor

index e3d9288866a0a1103aac107a9c5defaa96d6b1f3..705cc38f8dafe642c7cf4365a34772c9f1ba9c76 100644 (file)
@@ -36,7 +36,7 @@ IN: compiler.cfg.builder.blocks
     [ out-d>> length ] [ in-d>> length ] bi - ;
 
 : emit-call-block ( word height -- )
-    dup adjust-d ##call, make-kill-block ;
+    adjust-d ##call, make-kill-block ;
 
 : emit-primitive ( node -- )
     [
index 7416b2f00f7e9f86d156c11cc4ba962cebf96872..90b0c29cb0116004aa0f9d1b03ff5f63e34f6786 100644 (file)
@@ -245,7 +245,7 @@ IN: compiler.cfg.builder.tests
 
 ! emit-call
 {
-    V{ T{ ##call { word print } { height 4 } } T{ ##branch } }
+    V{ T{ ##call { word print } } T{ ##branch } }
 } [
     [ \ print 4 emit-call ] V{ } make drop
     basic-block get successors>> first instructions>>
index c9bf94ab72796e61b3ccc99c5d6e9887f7baca85..a2236bcf0d501587173333cc798ae650288a4731 100644 (file)
@@ -42,6 +42,9 @@ HELP: ##box-alien
 HELP: ##call
 { $class-description
   "An instruction for calling a Factor word."
+  { $table
+    { { $slot "word" } { "The word called." } }
+  }
 } ;
 
 HELP: ##check-nursery-branch
@@ -144,13 +147,13 @@ HELP: ##reload
 { $class-description "Instruction that copies a value from a " { $link spill-slot } " to a register." } ;
 
 HELP: ##replace
-{ $class-description
-  "Copies a value from a machine register to a stack location." }
-  { $see-also ##peek ##replace-imm } ;
+{ $class-description "Copies a value from a machine register to a stack location." }
+{ $see-also ##peek ##replace-imm } ;
 
 HELP: ##replace-imm
-{ $class-description
-  "An instruction that replaces an item on the data or register stack with an " { $link immediate } " value." } ;
+{ $class-description "An instruction that replaces an item on the data or register stack with an " { $link immediate } " value. The " { $link value-numbering } " compiler optimization pass can sometimes rewrite " { $link ##replace } " instructions to ##replace-imm's." }
+{ $see-also ##replace } ;
+
 
 HELP: ##return
 { $class-description "Instruction that returns from a procedure call." } ;
index 0996a71cc196ddffa2eba0ce269b08f1e8224cb5..4b9ce2c3682a0996fa1561d4645cfae548137fe3 100644 (file)
@@ -62,7 +62,7 @@ literal: loc ;
 
 ! Subroutine calls
 INSN: ##call
-literal: word height ;
+literal: word ;
 
 INSN: ##jump
 literal: word ;
index 8fd719f0f494b7e9efb4760e511a3b51c456d13b..16ad903bb81bbc8df2d8ba252abab1e5b3aa193b 100644 (file)
@@ -58,16 +58,6 @@ IN: compiler.cfg.stacks.padding.tests
     V{ } combine-states
 ] unit-test
 
-! States can't be combined if their heights are different
-[
-    V{ { { 3 { } } { 0 { } } } { { 8 { } } { 0 { } } } } combine-states
-] [ height-mismatches? ] must-fail-with
-
-[
-    V{ { { 4 { } } { 2 { 0 1 } } } { { 5 { 4 3 2 } } { 0 { } } } }
-    combine-states
-] [ height-mismatches? ] must-fail-with
-
 ! visit-insn ##inc
 
 ! We assume that overinitialized locations are always dead.
@@ -84,37 +74,17 @@ IN: compiler.cfg.stacks.padding.tests
 ] unit-test
 
 ! visit-insn ##call
-{
-    { { 3 { } } { 0 { } } }
-} [
-    initial-state T{ ##call { height 3 } } visit-insn
-] unit-test
-
-{
-    { { -1 { } } { 0 { } } }
-} [
-    initial-state T{ ##call { height -1 } } visit-insn
-] unit-test
-
-{
-    { { 4 { } } { 0 { } } }
-} [
-    { { 2 { } } { 0 { } } } T{ ##call { height 2 } } visit-insn
-] unit-test
-
-! This looks weird but is right.
 {
     { { 0 { } } { 0 { } } }
 } [
-    { { -2 { } } { 0 { } } } T{ ##call { height 2 } } visit-insn
+    initial-state T{ ##call } visit-insn
 ] unit-test
 
-
 ! if any of the stack locations are uninitialized when ##call is
 ! visisted then something is wrong. ##call might gc and the
 ! uninitialized locations would cause a crash.
 [
-    { { 3 { 0 1 2 } } { 0 { } } } T{ ##call { height 3 } } visit-insn
+    { { 3 { 0 1 2 } } { 0 { } } } T{ ##call } visit-insn
 ] [ vacant-when-calling? ] must-fail-with
 
 ! visit-insn ##call-gc
@@ -239,7 +209,7 @@ IN: compiler.cfg.stacks.padding.tests
         }
         {
             2 V{
-                T{ ##call { word <array> } { height 0 } }
+                T{ ##call { word <array> } }
             }
         }
         {
@@ -297,7 +267,7 @@ IN: compiler.cfg.stacks.padding.tests
         { 19 { { 7 { 3 } } { 0 { } } } }
         { 20 { { 7 { } } { 0 { } } } }
         { 21 { { 4 { } } { 0 { } } } }
-        ! gc-map here
+        ! gc-map here with nothing to scrub
         { 22 { { 4 { } } { 0 { } } } }
     }
 } [
@@ -319,7 +289,7 @@ IN: compiler.cfg.stacks.padding.tests
         }
         {
             2 V{
-                T{ ##call { word <array> } { height -1 } }
+                T{ ##call { word <array> } }
             }
         }
         {
@@ -348,7 +318,7 @@ IN: compiler.cfg.stacks.padding.tests
         }
         {
             6 V{
-                T{ ##call { word f } { height 0 } }
+                T{ ##call { word f } }
             }
         }
         {
@@ -409,35 +379,35 @@ IN: compiler.cfg.stacks.padding.tests
         { 2 { { 3 { 0 1 } } { 0 { } } } }
         { 3 { { 3 { 1 } } { 0 { } } } }
         { 4 { { 3 { } } { 0 { } } } }
-        { 5 { { 2 { } } { 0 { } } } }
-        { 6 { { 2 { } } { 0 { } } } }
-        { 7 { { 2 { } } { 0 { } } } }
-        { 8 { { 3 { 0 } } { 0 { } } } }
-        { 9 { { 3 { 0 } } { 1 { 0 } } } }
-        { 10 { { 3 { 0 1 } } { 1 { } } } }
-        { 11 { { 1 { } } { 1 { } } } }
-        { 12 { { 1 { } } { 6 { 0 1 2 3 4 } } } }
-        { 13 { { 1 { } } { 6 { 0 1 2 4 } } } }
-        { 14 { { 1 { } } { 6 { 0 1 2 4 } } } }
-        { 15 { { 1 { } } { 6 { 0 1 2 } } } }
-        { 16 { { 1 { } } { 6 { 0 1 } } } }
-        { 17 { { 1 { } } { 6 { 0 } } } }
-        { 18 { { 1 { } } { 6 { } } } }
-        { 19 { { 1 { } } { 6 { } } } }
-        { 20 { { 1 { } } { 6 { } } } }
-        { 21 { { 1 { } } { 6 { } } } }
-        { 22 { { 1 { } } { 6 { } } } }
-        { 23 { { 1 { } } { 6 { } } } }
-        { 24 { { 1 { } } { 6 { } } } }
-        { 25 { { 1 { } } { 6 { } } } }
-        { 26 { { 3 { 0 1 } } { 6 { } } } }
-        { 27 { { 3 { 0 1 } } { 1 { } } } }
-        ! gc-map here
-        { 28 { { 3 { 0 1 } } { 1 { } } } }
-        { 29 { { 3 { 0 1 } } { 1 { } } } }
-        { 30 { { 0 { } } { 1 { } } } }
-        { 31 { { 1 { 0 } } { 1 { } } } }
-        { 32 { { 1 { 0 } } { 0 { } } } }
+        { 5 { { 3 { } } { 0 { } } } }
+        { 6 { { 3 { } } { 0 { } } } }
+        { 7 { { 3 { } } { 0 { } } } }
+        { 8 { { 4 { 0 } } { 0 { } } } }
+        { 9 { { 4 { 0 } } { 1 { 0 } } } }
+        { 10 { { 4 { 0 1 } } { 1 { } } } }
+        { 11 { { 2 { } } { 1 { } } } }
+        { 12 { { 2 { } } { 6 { 0 1 2 3 4 } } } }
+        { 13 { { 2 { } } { 6 { 0 1 2 4 } } } }
+        { 14 { { 2 { } } { 6 { 0 1 2 4 } } } }
+        { 15 { { 2 { } } { 6 { 0 1 2 } } } }
+        { 16 { { 2 { } } { 6 { 0 1 } } } }
+        { 17 { { 2 { } } { 6 { 0 } } } }
+        { 18 { { 2 { } } { 6 { } } } }
+        { 19 { { 2 { } } { 6 { } } } }
+        { 20 { { 2 { } } { 6 { } } } }
+        { 21 { { 2 { } } { 6 { } } } }
+        { 22 { { 2 { } } { 6 { } } } }
+        { 23 { { 2 { } } { 6 { } } } }
+        { 24 { { 2 { } } { 6 { } } } }
+        { 25 { { 2 { } } { 6 { } } } }
+        { 26 { { 4 { 0 1 } } { 6 { } } } }
+        { 27 { { 4 { 0 1 } } { 1 { } } } }
+        ! gc-map here scrubbing D 0 and D 1
+        { 28 { { 4 { 0 1 } } { 1 { } } } }
+        { 29 { { 4 { 0 1 } } { 1 { } } } }
+        { 30 { { 1 { } } { 1 { } } } }
+        { 31 { { 2 { 0 } } { 1 { } } } }
+        { 32 { { 2 { 0 } } { 0 { } } } }
     }
 } [ bug1289-cfg trace-stack-state2 ] unit-test
 
@@ -460,9 +430,9 @@ IN: compiler.cfg.stacks.padding.tests
                 T{ ##replace { loc D 0 } }
             }
         }
-        { 3 V{ T{ ##call { height -1 } } } }
+        { 3 V{ T{ ##call } } }
         { 4 V{ } }
-        { 5 V{ T{ ##call { height 0 } } } }
+        { 5 V{ T{ ##call } } }
         { 6 V{ T{ ##peek { loc D 0 } } } }
         { 7 V{ } }
         {
@@ -472,16 +442,16 @@ IN: compiler.cfg.stacks.padding.tests
                 T{ ##replace { loc D 0 } }
             }
         }
-        { 9 V{ T{ ##call { height -1 } } } }
+        { 9 V{ T{ ##call } } }
         {
             10 V{
                 T{ ##inc { loc D 1 } }
                 T{ ##replace { loc D 0 } }
             }
         }
-        { 11 V{ T{ ##call { height -1 } } } }
+        { 11 V{ T{ ##call } } }
         { 12 V{ } }
-        { 13 V{ T{ ##call { height 0 } } } }
+        { 13 V{ T{ ##call } } }
         { 14 V{ T{ ##peek { loc D 0 } } } }
         { 15 V{ } }
         {
@@ -490,7 +460,7 @@ IN: compiler.cfg.stacks.padding.tests
                 T{ ##replace { loc D 0 } }
             }
         }
-        { 17 V{ T{ ##call { height 0 } } } }
+        { 17 V{ T{ ##call } } }
         {
             18 V{
                 T{ ##peek { loc D 2 } }
@@ -507,9 +477,9 @@ IN: compiler.cfg.stacks.padding.tests
                 T{ ##replace { loc D 0 } }
             }
         }
-        { 22 V{ T{ ##call { height 0 } } } }
+        { 22 V{ T{ ##call } } }
         { 23 V{ } }
-        { 24 V{ T{ ##call { height 0 } } } }
+        { 24 V{ T{ ##call } } }
         {
             25 V{
                 T{ ##peek { loc D 0 } }
@@ -575,37 +545,37 @@ IN: compiler.cfg.stacks.padding.tests
         { 4 { { -1 { } } { 0 { } } } }
         { 5 { { -1 { } } { 0 { } } } }
         { 6 { { -1 { } } { 0 { } } } }
-        { 7 { { -2 { } } { 0 { } } } }
-        { 8 { { -1 { 0 } } { 0 { } } } }
-        { 9 { { -1 { } } { 0 { } } } }
-        { 10 { { -2 { } } { 0 { } } } }
-        { 11 { { -2 { } } { 0 { } } } }
-        { 12 { { -2 { } } { 0 { } } } }
-        { 13 { { -1 { 0 } } { 0 { } } } }
-        { 14 { { -1 { } } { 0 { } } } }
-        { 15 { { -1 { } } { 0 { } } } }
-        { 16 { { -1 { } } { 0 { } } } }
-        { 17 { { -1 { } } { 0 { } } } }
-        { 18 { { -1 { } } { 0 { } } } }
-        { 19 { { 0 { 0 1 2 } } { 0 { } } } }
-        { 20 { { -3 { } } { 0 { } } } }
-        { 21 { { -3 { } } { 0 { } } } }
-        { 22 { { -3 { } } { 0 { } } } }
-        { 23 { { -3 { } } { 0 { } } } }
-        { 24 { { -3 { } } { 0 { } } } }
-        ! gc-map here
-        { 25 { { 0 { 0 1 2 } } { 0 { } } } }
-        { 26 { { 0 { 0 1 2 } } { 0 { } } } }
-        { 27 { { -4 { } } { 0 { } } } }
-        { 28 { { -3 { 0 } } { 0 { } } } }
+        { 7 { { -1 { } } { 0 { } } } }
+        { 8 { { 0 { 0 } } { 0 { } } } }
+        { 9 { { 0 { } } { 0 { } } } }
+        { 10 { { 0 { } } { 0 { } } } }
+        { 11 { { 0 { } } { 0 { } } } }
+        { 12 { { 0 { } } { 0 { } } } }
+        { 13 { { 1 { 0 } } { 0 { } } } }
+        { 14 { { 1 { } } { 0 { } } } }
+        { 15 { { 1 { } } { 0 { } } } }
+        { 16 { { 1 { } } { 0 { } } } }
+        { 17 { { 1 { } } { 0 { } } } }
+        { 18 { { 1 { } } { 0 { } } } }
+        { 19 { { 2 { 0 1 2 } } { 0 { } } } }
+        { 20 { { -1 { } } { 0 { } } } }
+        { 21 { { -1 { } } { 0 { } } } }
+        { 22 { { -1 { } } { 0 { } } } }
+        { 23 { { -1 { } } { 0 { } } } }
+        { 24 { { -1 { } } { 0 { } } } }
+        ! gc-map here scrubbing D 0, D 1 and D 2
+        { 25 { { 2 { 0 1 2 } } { 0 { } } } }
+        { 26 { { 2 { 0 1 2 } } { 0 { } } } }
+        { 27 { { -2 { } } { 0 { } } } }
+        { 28 { { -1 { 0 } } { 0 { } } } }
         { 29 { { -1 { } } { 0 { } } } }
         { 30 { { -2 { } } { 0 { } } } }
         { 31 { { -2 { } } { 0 { } } } }
         { 32 { { -2 { } } { 0 { } } } }
         { 33 { { -1 { 0 } } { 0 { } } } }
         { 34 { { -1 { } } { 0 { } } } }
-        { 35 { { -2 { } } { 0 { } } } }
-        { 36 { { -2 { } } { 0 { } } } }
+        { 35 { { -1 { } } { 0 { } } } }
+        { 36 { { -1 { } } { 0 { } } } }
     }
 } [
     bug-benchmark-terrain-cfg trace-stack-state2
@@ -682,7 +652,7 @@ IN: compiler.cfg.stacks.padding.tests
     V{
         T{ ##replace { src 10 } { loc D 0 } }
         T{ ##inc f D -1 }
-        T{ ##call { height 0 } }
+        T{ ##call }
     } following-stack-state
 ] unit-test
 
index 3bc728dbbf73886a168916d2c2681cd0c2f1c3fb..78bd22dad0dd1fe2e002cf2ed917863949f1ce32 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs compiler.cfg.dataflow-analysis
 compiler.cfg.instructions compiler.cfg.linearization compiler.cfg.registers
-compiler.cfg.stacks.local fry grouping kernel math math.order namespaces
+compiler.cfg.stacks.local fry kernel math math.order namespaces
 sequences ;
 QUALIFIED: sets
 IN: compiler.cfg.stacks.padding
@@ -10,14 +10,12 @@ IN: compiler.cfg.stacks.padding
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 ! !! Stack
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-ERROR: height-mismatches seq ;
 
 : register-write ( n stack -- stack' )
     first2 swapd remove 2array ;
 
 : combine-stacks ( stacks -- stack )
-    [ [ first ] map dup all-equal? [ first ] [ height-mismatches ] if ]
-    [ [ second ] map sets:combine ] bi 2array ;
+    [ first first ] [ [ second ] map sets:combine ] bi 2array ;
 
 : classify-read ( stack n -- val )
     swap 2dup second member? [ 2drop 2 ] [ first >= [ 1 ] [ 0 ] if ] if ;
@@ -58,8 +56,7 @@ M: ##replace-imm visit-insn live-location ;
 M: ##replace visit-insn live-location ;
 
 M: ##call visit-insn ( state insn -- state' )
-    over ensure-no-vacant height>>
-    0 2array [ swap first2 [ + ] dip 2array ] 2map ;
+    drop dup ensure-no-vacant ;
 
 M: ##call-gc visit-insn ( state insn -- state' )
     drop all-live ;
index c2433092053fe54795e08e39126a1ce5f88b0cc9..c81164bff2278c43fd98f1c48c38fcd72d7da734 100644 (file)
@@ -4,7 +4,7 @@ kernel make compiler.constants words ;
 IN: compiler.codegen.tests
 
 [ ] [ [ ] with-fixup drop ] unit-test
-[ ] [ [ \ + %call ] with-fixup drop ] unit-test
+[ ] [ [ \ + %call ] with-fixup drop ] unit-test
 
 [ ] [ [ <label> dup define-label dup resolve-label %jump-label ] with-fixup drop ] unit-test
 [ ] [ [ <label> dup define-label dup resolve-label B{ 0 0 0 0 } % rc-absolute-cell label-fixup ] with-fixup drop ] unit-test
index 9442aed9a860f94caf363ce69f8d51f46a62ed3d..43f4c50464444fe23442a6111f5874374515fb56 100644 (file)
@@ -234,7 +234,7 @@ HOOK: %replace-imm cpu ( src loc -- )
 HOOK: %inc cpu ( loc -- )
 
 HOOK: stack-frame-size cpu ( stack-frame -- n )
-HOOK: %call cpu ( word height -- )
+HOOK: %call cpu ( word -- )
 HOOK: %jump cpu ( word -- )
 HOOK: %jump-label cpu ( label -- )
 HOOK: %return cpu ( -- )
index 0b16b71bbf999acebd18cf9be8e20e27a0575d31..5b126f0514e1310bb856a09f6dfceccf375f1578 100644 (file)
@@ -195,8 +195,8 @@ M: ppc stack-frame-size ( stack-frame -- i )
     factor-area-size +
     16 align ;
 
-M: ppc %call ( word height -- )
-    drop 0 BL rc-relative-ppc-3-pc rel-word-pic ;
+M: ppc %call ( word -- )
+    0 BL rc-relative-ppc-3-pc rel-word-pic ;
 
 : instrs ( n -- b ) 4 * ; inline
 
@@ -922,7 +922,7 @@ M:: ppc %check-nursery-branch ( label size cc temp1 temp2 -- )
     } case ;
 
 M: ppc %call-gc ( gc-map -- )
-    \ minor-gc %call gc-map-here ;
+    \ minor-gc %call gc-map-here ;
 
 M:: ppc %prologue ( stack-size -- )
     0 MFLR
index d9c7778260505793f4eb47b2d2f58a1fdb951753..d02a6078c749a99a79141d399a5ae12e7b6d476f 100644 (file)
@@ -95,7 +95,7 @@ M: x86 %replace-imm
 M: x86 %inc ( loc -- )
     [ n>> ] [ ds-loc? ds-reg rs-reg ? ] bi (%inc) ;
 
-M: x86 %call ( word height -- ) drop 0 CALL rc-relative rel-word-pic ;
+M: x86 %call ( word -- ) 0 CALL rc-relative rel-word-pic ;
 
 : xt-tail-pic-offset ( -- n )
     #! See the comment in vm/cpu-x86.hpp
@@ -510,7 +510,7 @@ M: x86 gc-root-offset
     n>> spill-offset special-offset cell + cell /i ;
 
 M: x86 %call-gc ( gc-map -- )
-    \ minor-gc %call
+    \ minor-gc %call
     gc-map-here ;
 
 M: x86 %alien-global ( dst symbol library -- )