This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: call-with-values inliner


I checked in the call-with-values optimization code I had
written before Jamison's patch came in. After some thought
I think that patch, though in some ways more limited, is a
useful intermediary.

The basic idea is a new function, which we may call apply-with-values.
For now apply-with-values is only created by optimizing
call-with-values - you can't call it directly. Then we rewrite:
  (call-with-values producer consumer)
to:
  (apply-with-values (producer) consumer)
Note this doesn't cause the consumer to be inlined,
but it does cause the producer to be inlined, and in
a very simple and general way. And it works even if
the consumer isn't a LambdaExp, which Jamison's patch
doesn't (though that could be changed).

Jamison, if you don't mind perhaps you could re-work your patch
as an optimization of apply-with-values - it should make for a simpler patch.

Longer-term, I'm thinking of something like:
(1) Nail down a Type representation for multiple values,
that will allow us to say at least things like "3 values of types T1,T2,T3".
(2) Given a consumer expression create a "required type" based
on the parameter types. For example (lambda ((x::T) y (y::T3)) ...)
the required type would be "3 values of types T1,unknown,T3".
(3) Validate the producer expression with the type from (2) -
or use the unknown type if the consumer isn't a fixed-arg lambda.
(4) After validating (3) we get an actual type of the producer.
We can also get a static type mismatch if the don't match, as in:
  (apply-with-values (values 3 4) (lambda (x y z) ...))
or:
  (apply-with-values (values 2 "x") (lambda ((x::number) (y::number)) ...)
(5) Now that we have a actual or required type from the producer,
then we can inline or otherwise optimize calling the consumer.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]