lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I meant statically typed temporaries.



> On Mar 8, 2015, at 5:15 PM, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> 
> On 9 March 2015 at 00:00, Ahmed Charles <acharles@outlook.com> wrote:
>>> I think more optimization is possible though. For instance - could I
>>> avoid setting the types if the compiler knows they are
>>> integer/floating? I thought I could but I found an issue.
>>> Types can be preset for locals so those are fine.
>>> But when expressions are evaluated using temporary registers then if
>>> the type is not set what happens is that any operation that uses the
>>> temporary value gets the wrong type. Perhaps the compiler could be
>>> clever enough to set the type at the end of the expression evaluation
>>> rather than at every step. I will look into this more at some point.
>> 
>> Wouldn't the solution to this be to have typed temporaries?
> 
> Well that is correct but then that is the performance issue - because
> I have to set the type on every temporary which means an extra store.
> 
> For example:
> 
> local i: int = 5+6+7*3
> 
> Imagine there is no constant folding and that temporaries are created
> for each constant. Then I need to set the type of each temporary for
> eventually the right type to be set on the local i.
> 
> But the point I was making is that the compiler knows that the type of
> the expression is int - so it only needs to set the type at the time
> of assignment - not while evaluating the expression.
> 
> Does this make sense?
> 
> Regards
> Dibyendu
>