Fixing bug in dependency tracking for guarded method inlining

db4
Daniel Ehrenberg 2010-04-25 13:05:02 -05:00
parent 0d055060ad
commit 4d5b7fe883
3 changed files with 35 additions and 8 deletions

View File

@ -53,6 +53,7 @@ ERROR: bad-splitting class generic ;
:: split-code ( class generic -- quot/f )
class generic method :> my-method
my-method [ class generic bad-splitting ] unless
class generic my-method depends-on-method-is
generic dispatch# (picker) :> picker
[
picker call class instance?
@ -62,8 +63,8 @@ ERROR: bad-splitting class generic ;
:: split-method-call ( class generic -- quot/f )
class generic subclass-with-only-method [
class generic depends-on-single-method
generic split-code
[ class generic depends-on-single-method ]
[ generic split-code ] bi
] [ f ] if* ;
: inlining-standard-method ( #call word -- class/f method/f )

View 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 classes.tuple ;
strings.private classes.tuple eval ;
FROM: math => float ;
SPECIALIZED-ARRAY: double
SPECIALIZED-ARRAY: void*
@ -999,3 +999,19 @@ UNION: ?fixnum fixnum POSTPONE: f ;
[ f ] [ [ { integer } declare >fixnum ] { >fixnum } inlined? ] unit-test
[ f ] [ [ { word } declare parent-word ] { parent-word } inlined? ] unit-test
! Make sure guarded method inlining installs the right dependencies
[ ] [
"IN: compiler.tree.propagation.tests
USING: kernel.private accessors ;
TUPLE: foo bar ;
UNION: ?foo foo POSTPONE: f ;
: baz ( ?foo -- bar ) { ?foo } declare bar>> ;" eval( -- )
] unit-test
[ 3 ] [ "USE: kernel IN: compiler.tree.propagation.tests 3 foo boa baz" eval( -- x ) ] unit-test
[ ] [ "IN: compiler.tree.propagation.tests TUPLE: foo baz bar ;" eval( -- ) ] unit-test
[ 3 ] [ "USE: kernel IN: compiler.tree.propagation.tests 2 3 foo boa baz" eval( -- x ) ] unit-test

View File

@ -145,11 +145,11 @@ TUPLE: depends-on-final class ;
M: depends-on-final satisfied?
class>> { [ class? ] [ final-class? ] } 1&& ;
TUPLE: depends-on-single-method class generic ;
TUPLE: depends-on-single-method method-class object-class generic ;
: depends-on-single-method ( class generic -- )
[ nip depends-on-conditionally ]
[ \ depends-on-single-method add-conditional-dependency ] 2bi ;
: depends-on-single-method ( method-class object-class generic -- )
[ nip [ depends-on-conditionally ] bi@ ]
[ \ depends-on-single-method add-conditional-dependency ] 3bi ;
:: subclass-with-only-method ( class generic -- subclass/f )
generic method-classes [ f ] [
@ -161,7 +161,17 @@ TUPLE: depends-on-single-method class generic ;
] if-empty ;
M: depends-on-single-method satisfied?
[ class>> ] [ generic>> ] bi subclass-with-only-method >boolean ;
[ method-class>> ] [ object-class>> ] [ generic>> ] tri
subclass-with-only-method = ;
TUPLE: depends-on-method-is class generic method ;
: depends-on-method-is ( class generic method -- )
[ [ depends-on-conditionally ] tri@ ]
[ \ depends-on-method-is add-conditional-dependency ] 3bi ;
M: depends-on-method-is satisfied?
[ class>> ] [ generic>> method ] [ method>> ] tri = ;
: init-dependencies ( -- )
H{ } clone dependencies set