[Vm-dev] Eliot's BlockClosure model questions

Igor Stasenko siguctua at gmail.com
Fri Aug 2 10:47:42 UTC 2013


On 2 August 2013 11:12, stephane ducasse <stephane.ducasse at gmail.com> wrote:
>
> Hi eliot and clement (and others)
>
> I'm not sure that this is something that we can gain from but I read and totally forgot :)
> the paper:
> optimizing Closures in O(0) time
>
> http://users-cs.au.dk/danvy/sfp12/papers/keep-hearn-dybvig-paper-sfp12.pdf
>

skimmed through it..
in smalltalk there is no 'well-known' closures (or at least you cannot
determine it at compile time),
so optimizations which described there (in section 2.1) , we can only
apply for cases 2a and 2b,
but nothing from case1xx.

The only case of 'well-known' closures in smalltalk is things like
ifTrue/ifFalse/to:do: which handled directly by compiler by inlining
them

We could try to optimize this:

foo
| x |
x := 3.
^ [:y | y + x ]

17 <20> pushConstant: 3
18 <68> popIntoTemp: 0
19 <10> pushTemp: 0
20 <8F 11 00 04> closureNumCopied: 1 numArgs: 1 bytes 24 to 27
24 	<10> pushTemp: 0
25 	<11> pushTemp: 1
26 	<B0> send: +
27 	<7D> blockReturn
28 <7C> returnTop


(here
25 	<11> pushTemp: 1

'potentially' can be replaced by
 pushConstant: 3
)

but that could be very tricky, given the need to reflectively support
all things..
(imagine you get access to method's context and say
tempAt: 1 put: 5...
so we expecting that closure start adding 5 instead of 3?

of course, if we lower our expectations, then it can be optimized more
aggressively.

-- 
Best regards,
Igor Stasenko.


More information about the Vm-dev mailing list