[squeak-dev] Compiler

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Thu Jun 21 17:43:06 UTC 2012


2012/6/21 Bert Freudenberg <bert at freudenbergs.de>:
> On 2012-06-21, at 17:55, Nicolas Cellier wrote:
>> OK, but with the LargeFrame = 56 limit, I cannot compile a method written
>>
>> ^1+(1+(1+(...  64x times )))
>>
>> or I get an Error triggered by:
>>
>> CompiledMethod>>needsFrameSize: newFrameSize
>>       "Set the largeFrameBit to accomodate the newFrameSize"
>>       | largeFrameBit header |
>>       largeFrameBit := 16r20000.
>>       (self numTemps + newFrameSize) > LargeFrame ifTrue:
>>               [^ TooDeepStackError signal: 'Cannot compile -- stack including
>> temps is too deep'].
>>       header := self objectAt: 1.
>>       (header bitAnd: largeFrameBit) ~= 0
>>               ifTrue: [header := header - largeFrameBit].
>>       self objectAt: 1 put: header
>>                       + ( ((self numTemps + newFrameSize) > SmallFrame or: [ self
>> primitive = 84 "perform:withArguments:"])
>>                                       ifTrue: [largeFrameBit]
>>                                       ifFalse: [0])
>>
>> To overcome the limitation, I would have to re-arrange the order of
>> push/sends. Since I can't easily guess absence of side effect in
>> Smalltalk, I can't reorder.
>> So I would have to push in a temporary array rather than in a stack
>> (simulate a stack), then push (array at: i) on demand just before
>> sending (I think the closure bytecodes also provide some short form).
>> Phew...
>>
>> Nicolas
>
> That sounds way harder than pulling out subexpressions into hidden temp vars. E.g.,
>
>        ^ 1 + (2 + (3 + 4))
>
> is exactly equivalent (same order of message sends) to
>
>        | t1 t2 |
>        t1 := 3 + 4.
>        t2 := 2 + t1.
>        ^ 1 + t2
>
> If the temp number limit was lifted this would be the way to go, I think.
>
> - Bert -
>

Sure, it's rather theorical without thinking of any application, but
if these are objects rather than literals (that we can expect being
constant), say for example some instance variable, then can we
guaranty that the first message won't have any side effect...

(a at: 1) + ( (a at:2) * ( (a at: 1 put: ( ... ) ) + (... ) ) )

Nicolas


More information about the Squeak-dev mailing list