]> gitweb.factorcode.org Git - factor.git/commitdiff
splitting generic word callsites when only one method is applicable
authorDaniel Ehrenberg <littledan@pool-224-36.res.carleton.edu>
Mon, 19 Apr 2010 21:01:09 +0000 (16:01 -0500)
committerDaniel Ehrenberg <littledan@pool-224-36.res.carleton.edu>
Tue, 4 May 2010 21:46:07 +0000 (16:46 -0500)
basis/compiler/tree/propagation/inlining/inlining.factor

index 4a227cfa7717b003377e7e2f4f58c25c4533535d..ad3de5d8f72b311cfff230e18f2b262a1bbdbca6 100644 (file)
@@ -47,12 +47,34 @@ M: callable splicing-nodes splicing-body ;
         ] if
     ] [ 2drop undo-inlining ] if ;
 
+:: split-code ( class generic -- quot/f )
+    class generic method-for-class :> method
+    method [
+        dup class instance?
+        [ method execute ]
+        [ generic no-method ] if
+    ] and ;
+
+:: split-method-call ( class generic -- quot/f )
+    class object = [ f ] [
+        object generic method-classes 
+        [| last-class new-class |
+            class new-class classes-intersect? [
+                new-class class class<= [
+                    last-class new-class class<=
+                    last-class new-class ? f
+                ] [ object t ] if
+            ] [ last-class f ] if
+        ] any?
+        [ drop f ] [ generic split-code ] if
+    ] if ;
+
 : inlining-standard-method ( #call word -- class/f method/f )
     dup "methods" word-prop assoc-empty? [ 2drop f f ] [
         2dup [ in-d>> length ] [ dispatch# ] bi* <= [ 2drop f f ] [
             [ in-d>> <reversed> ] [ [ dispatch# ] keep ] bi*
             [ swap nth value-info class>> dup ] dip
-            method-for-class
+            { [ method-for-class ] [ split-method-call ] } 2||
         ] if
     ] if ;