]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg: nuke ##allot-byte-array instruction
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 16 Jul 2010 23:57:45 +0000 (19:57 -0400)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 16 Jul 2010 23:57:45 +0000 (19:57 -0400)
basis/compiler/cfg/builder/alien/boxing/boxing.factor
basis/compiler/cfg/gc-checks/gc-checks.factor
basis/compiler/cfg/instructions/instructions.factor
basis/compiler/cfg/intrinsics/allot/allot.factor
basis/compiler/cfg/linear-scan/linear-scan-tests.factor
basis/compiler/codegen/codegen.factor
basis/cpu/architecture/architecture.factor
basis/cpu/x86/32/32.factor
basis/cpu/x86/64/64.factor
vm/byte_arrays.cpp
vm/byte_arrays.hpp

index fb57700c80809c10b706841ea0e8049e2ac9726c..0234c128085f480c9f68db6bf8c4b04f2658d61d 100644 (file)
@@ -4,7 +4,8 @@ USING: accessors alien.c-types arrays assocs combinators
 classes.struct fry kernel layouts locals math namespaces
 sequences sequences.generalizations system
 compiler.cfg.builder.alien.params compiler.cfg.hats
-compiler.cfg.registers compiler.cfg.instructions cpu.architecture ;
+compiler.cfg.registers compiler.cfg.instructions
+compiler.cfg.intrinsics.allot cpu.architecture ;
 IN: compiler.cfg.builder.alien.boxing
 
 SYMBOL: struct-return-area
@@ -117,7 +118,7 @@ M: long-long-type box
     <gc-map> ^^box-long-long ;
 
 M: struct-c-type box
-    '[ _ heap-size <gc-map> ^^allot-byte-array dup ^^unbox-byte-array ] 2dip
+    '[ _ heap-size emit-allot-byte-array dup ^^unbox-byte-array ] 2dip
     implode-struct ;
 
 GENERIC: box-parameter ( vregs reps c-type -- dst )
index eab3fce6660aedf4c50f570c767277fefbc43380..8213c577e165a69944749bdf29adb0336de45e26 100644 (file)
@@ -31,6 +31,7 @@ GENERIC# gc-check-offsets* 1 ( call-index seen-allocation? insn n -- call-index
     seen-allocation? [ call-index , ] when
     insn-index 1 + f ;
 
+M: ##callback-inputs gc-check-offsets* gc-check-here ;
 M: ##phi gc-check-offsets* gc-check-here ;
 M: gc-map-insn gc-check-offsets* gc-check-here ;
 M: ##allocation gc-check-offsets* 3drop t ;
index 7efd1b3a5dc7926699bc3a99f761984e239fcea3..f78b77d2f0cc5771bf9bffe5e0472dc8393e9db9 100644 (file)
@@ -663,10 +663,6 @@ def: dst/tagged-rep
 use: src1/int-rep src2/int-rep
 literal: boxer gc-map ;
 
-FLUSHABLE-INSN: ##allot-byte-array
-def: dst/tagged-rep
-literal: size gc-map ;
-
 ! Alien call inputs and outputs are arrays of triples with shape
 ! { vreg rep stack#/reg }
 
@@ -855,7 +851,6 @@ UNION: gc-map-insn
 ##call-gc
 ##box
 ##box-long-long
-##allot-byte-array
 factor-call-insn ;
 
 M: gc-map-insn clone call-next-method [ clone ] change-gc-map ;
@@ -889,8 +884,7 @@ hairy-clobber-insn
 ##binary-float-function
 ##unbox
 ##box
-##box-long-long
-##allot-byte-array ;
+##box-long-long ;
 
 ! Instructions that have complex expansions and require that the
 ! output registers are not equal to any of the input registers
index ff4c28a4887b0600d185c52d662fbffe00bc191c..1b7e183b7941bb26bdf45662b9fb2f0622bfe0bd 100644 (file)
@@ -66,13 +66,12 @@ IN: compiler.cfg.intrinsics.allot
     16 + byte-array ^^allot ;
 
 : emit-allot-byte-array ( len -- dst )
-    ds-drop
     dup ^^allot-byte-array
     [ byte-array store-length ] [ ds-push ] [ ] tri ;
 
 : emit-(byte-array) ( node -- )
     dup node-input-infos first literal>> dup expand-(byte-array)?
-    [ nip emit-allot-byte-array drop ] [ drop emit-primitive ] if ;
+    [ nip ds-drop emit-allot-byte-array drop ] [ drop emit-primitive ] if ;
 
 :: zero-byte-array ( len reg -- )
     0 ^^load-literal :> elt
@@ -84,6 +83,7 @@ IN: compiler.cfg.intrinsics.allot
 :: emit-<byte-array> ( node -- )
     node node-input-infos first literal>> dup expand-<byte-array>? [
         :> len
+        ds-drop
         len emit-allot-byte-array :> reg
         len reg zero-byte-array
     ] [ drop node emit-primitive ] if ;
index 873ba6ee5ce1273472fe47636355a9724cde4bba..c5534a30407c23e04c8bd89e67b3a2421b048d8c 100644 (file)
@@ -11,6 +11,7 @@ compiler.cfg.rpo
 compiler.cfg.debugger
 compiler.cfg.def-use
 compiler.cfg.comparisons
+compiler.cfg.ssa.destruction
 compiler.cfg.linear-scan
 compiler.cfg.linear-scan.numbering
 compiler.cfg.linear-scan.live-intervals
@@ -25,6 +26,36 @@ IN: compiler.cfg.linear-scan.tests
 check-allocation? on
 check-numbering? on
 
+! Live interval calculation
+
+! A value is defined and never used; make sure it has the right
+! live range
+V{
+    T{ ##load-integer f 1 0 }
+    T{ ##replace-imm f D 0 "hi" }
+    T{ ##branch }
+} 0 test-bb
+
+: test-live-intervals ( -- )
+    cfg new 0 get >>entry
+    [ cfg set ] [ number-instructions ] [ compute-live-intervals ] tri
+    2drop ;
+
+[ ] [
+    H{
+        { 1 int-rep }
+    } representations set
+    H{
+        { 1 1 }
+    } leader-map set
+    test-live-intervals
+] unit-test
+
+[ 0 0 ] [
+    1 live-intervals get at [ start>> ] [ end>> ] bi
+] unit-test
+
+! Live range and interval splitting
 [
     { T{ live-range f 1 10 } T{ live-range f 15 15 } }
     { T{ live-range f 16 20 } }
index 654d676ad1d0ec323f8e73023578788c66113932..e3746090cd85fa217eb129c6c468844984af0004 100755 (executable)
@@ -288,7 +288,6 @@ CODEGEN: ##unbox-long-long %unbox-long-long
 CODEGEN: ##local-allot %local-allot
 CODEGEN: ##box %box
 CODEGEN: ##box-long-long %box-long-long
-CODEGEN: ##allot-byte-array %allot-byte-array
 CODEGEN: ##alien-invoke %alien-invoke
 CODEGEN: ##alien-indirect %alien-indirect
 CODEGEN: ##alien-assembly %alien-assembly
index b4b5132ed55385e1c9a2363592076a45bd722896..e69a1cd283e5f98c74aa0d6f42ec38c2f22e08ce 100644 (file)
@@ -596,8 +596,6 @@ HOOK: %box cpu ( dst src func rep gc-map -- )
 
 HOOK: %box-long-long cpu ( dst src1 src2 func gc-map -- )
 
-HOOK: %allot-byte-array cpu ( dst size gc-map -- )
-
 HOOK: %save-context cpu ( temp1 temp2 -- )
 
 HOOK: %c-invoke cpu ( symbols dll gc-map -- )
index ee6082425b61e5dc6435aec28ea48598898c0f74..7ed80d1e3965f951fbcac57da837179d4ae688e8 100755 (executable)
@@ -178,12 +178,6 @@ M:: x86.32 %box-long-long ( dst src1 src2 func gc-map -- )
     func f gc-map %c-invoke
     dst EAX tagged-rep %copy ;
 
-M:: x86.32 %allot-byte-array ( dst size gc-map -- )
-    4 save-vm-ptr
-    0 stack@ size MOV
-    "allot_byte_array" f gc-map %c-invoke
-    dst EAX tagged-rep %copy ;
-
 M: x86.32 %c-invoke
     [ 0 CALL rc-relative rel-dlsym ] dip gc-map-here ;
 
index 9fdd4551c92dd65cf651a9d3616961a57511c9cb..0aad0382fd3eb128358e12bb05235d1c54114510 100644 (file)
@@ -107,12 +107,6 @@ M:: x86.64 %box ( dst src func rep gc-map -- )
     func f gc-map %c-invoke
     dst int-rep %load-return ;
 
-M:: x86.64 %allot-byte-array ( dst size gc-map -- )
-    param-reg-0 size MOV
-    param-reg-1 %mov-vm-ptr
-    "allot_byte_array" f gc-map %c-invoke
-    dst int-rep %load-return ;
-
 M: x86.64 %c-invoke
     [ R11 0 MOV rc-absolute-cell rel-dlsym R11 CALL ] dip
     gc-map-here ;
index fb1b44c91e95f658e9d19f2b73641ff02057a82b..467e41029df8e6ead037d5676046b1e159be8a28 100644 (file)
@@ -10,11 +10,6 @@ byte_array *factor_vm::allot_byte_array(cell size)
        return array;
 }
 
-VM_C_API cell allot_byte_array(cell size, factor_vm *parent)
-{
-       return tag<byte_array>(parent->allot_byte_array(size));
-}
-
 void factor_vm::primitive_byte_array()
 {
        cell size = unbox_array_size();
index f0faac248c8047fe15799dc085b68aec5ca5197e..8b686d4e57465b993a37fa851ad6b9da557c506a 100755 (executable)
@@ -21,6 +21,4 @@ template<typename Type> byte_array *factor_vm::byte_array_from_value(Type *value
        return data;
 }
 
-VM_C_API cell allot_byte_array(cell size, factor_vm *parent);
-
 }