]> gitweb.factorcode.org Git - factor.git/commitdiff
Adding dependency checking and proper handing of dispatch# to the new method inlining
authorDaniel Ehrenberg <littledan@pool-224-36.res.carleton.edu>
Sun, 25 Apr 2010 07:12:23 +0000 (02:12 -0500)
committerDaniel Ehrenberg <littledan@pool-224-36.res.carleton.edu>
Tue, 4 May 2010 21:46:38 +0000 (16:46 -0500)
basis/compiler/tree/cleanup/cleanup-tests.factor
basis/compiler/tree/propagation/inlining/inlining.factor
basis/compiler/tree/propagation/propagation-tests.factor
basis/stack-checker/dependencies/dependencies.factor

index 05f9092ee130fe95ee6e3f72e607fabc95beaed5..cdfc0e6d3df6013ed729a6908447740bdb8dc8b7 100644 (file)
@@ -182,11 +182,16 @@ M: fixnum annotate-entry-test-1 drop ;
 
 : annotate-entry-test-2 ( from to -- obj ) 0 -rot (annotate-entry-test-2) ; inline
 
-[ f ] [
+[ t ] [
     [ { bignum } declare annotate-entry-test-2 ]
     \ annotate-entry-test-1 inlined?
 ] unit-test
 
+[ f ] [
+    [ { bignum } declare annotate-entry-test-2 ]
+    M\ fixnum annotate-entry-test-1 inlined?
+] unit-test
+
 [ t ] [
     [ { float } declare 10 [ 2.3 * ] times >float ]
     \ >float inlined?
index 19b515ba12d6615e930161391381207813d9acb3..f33718a8b6b7a4605a5968cc5c5813502d36daff 100644 (file)
@@ -5,6 +5,7 @@ math.partial-dispatch generic generic.standard generic.single generic.math
 classes.algebra classes.union sets quotations assocs combinators
 combinators.short-circuit words namespaces continuations classes
 fry hints locals
+stack-checker.dependencies
 compiler.tree
 compiler.tree.builder
 compiler.tree.recursive
@@ -50,26 +51,20 @@ M: callable splicing-nodes splicing-body ;
 ERROR: bad-splitting class generic ;
 
 :: split-code ( class generic -- quot/f )
-    class generic method-for-class
-    [ class generic bad-splitting ] unless
+    class generic method-for-class :> method
+    method [ class generic bad-splitting ] unless
+    generic dispatch# (picker) :> picker
     [
-        dup class instance?
-        [ generic execute ]
+        picker call class instance?
+        [ method execute ]
         [ generic no-method ] if
     ] ;
 
-:: find-method-call ( class generic -- subclass/f )
-    generic method-classes [ f ] [
-        f swap [| last-class new-class |
-            class new-class classes-intersect? [
-                last-class [ f f ] [ new-class t ] if
-            ] [ last-class t ] if
-        ] all? swap and
-    ] if-empty ;
-
 :: split-method-call ( class generic -- quot/f )
-    class generic find-method-call
-    [ generic split-code ] [ f ] if* ;
+    class generic subclass-with-only-method [
+        class generic depends-on-single-method
+        generic split-code
+    ] [ f ] if* ;
 
 : inlining-standard-method ( #call word -- class/f method/f )
     dup "methods" word-prop assoc-empty? [ 2drop f f ] [
index 3b831aeb541322f583910cd484d1a61312355c73..473285e8c5599e42a9e199ad890130edd4f89582 100644 (file)
@@ -9,7 +9,7 @@ compiler.tree.debugger compiler.tree.checker slots.private words
 hashtables classes assocs locals specialized-arrays system
 sorting math.libm math.floats.private math.integers.private
 math.intervals quotations effects alien alien.data sets
-strings.private ;
+strings.private classes.tuple ;
 FROM: math => float ;
 SPECIALIZED-ARRAY: double
 SPECIALIZED-ARRAY: void*
@@ -863,11 +863,11 @@ TUPLE: foo bar ;
 GENERIC: whatever ( x -- y )
 M: number whatever drop foo ; inline
 
-[ t ] [ [ 1 whatever new ] { new } inlined? ] unit-test
+[ t ] [ [ 1 whatever new ] { new } M\ tuple-class new suffix inlined? ] unit-test
 
 : that-thing ( -- class ) foo ;
 
-[ f ] [ [ that-thing new ] { new } inlined? ] unit-test
+[ f ] [ [ that-thing new ] { new } M\ tuple-class new suffix inlined? ] unit-test
 
 GENERIC: whatever2 ( x -- y )
 M: number whatever2 drop H{ { 1 1 } { 2 2 } { 3 3 } { 4 4 } { 5 6 } } ; inline
index 50d5ff6189f70932793d083f2692d40247c8011e..5d74e85e877d8677e7c88088e11b947c36d977ab 100644 (file)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs accessors classes classes.algebra fry
 generic kernel math namespaces sequences words sets
-combinators.short-circuit classes.tuple alien.c-types ;
+combinators.short-circuit classes.tuple alien.c-types
+locals ;
 FROM: classes.tuple.private => tuple-layout ;
 FROM: assocs => change-at ;
 FROM: namespaces => set ;
@@ -144,6 +145,24 @@ TUPLE: depends-on-final class ;
 M: depends-on-final satisfied?
     class>> { [ class? ] [ final-class? ] } 1&& ;
 
+TUPLE: depends-on-single-method class generic ;
+
+: depends-on-single-method ( class generic -- )
+    [ nip depends-on-conditionally ]
+    [ \ depends-on-single-method add-conditional-dependency ] 2bi ;
+
+:: subclass-with-only-method ( class generic -- subclass/f )
+    generic method-classes [ f ] [
+        f swap [| last-class new-class |
+            class new-class classes-intersect? [
+                last-class [ f f ] [ new-class t ] if
+            ] [ last-class t ] if
+        ] all? swap and
+    ] if-empty ;
+
+M: depends-on-single-method satisfied?
+    [ class>> ] [ generic>> ] bi subclass-with-only-method >boolean ;
+
 : init-dependencies ( -- )
     H{ } clone dependencies set
     H{ } clone generic-dependencies set