help-smalltalk
[Top][All Lists]
Advanced

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

Re : [Help-smalltalk] About no_opt macro


From: Mathieu Suen
Subject: Re : [Help-smalltalk] About no_opt macro
Date: Wed, 13 Oct 2010 08:06:36 +0100 (BST)

:) thanks for make it perfectly clear.




----- Message d'origine ----
> De : Paolo Bonzini <address@hidden>
> À : Mathieu Suen <address@hidden>
> Cc : address@hidden
> Envoyé le : Mar 12 octobre 2010, 16h 29min 14s
> Objet : Re: [Help-smalltalk] About no_opt macro
> 
> On 10/12/2010 03:28 PM, Mathieu Suen wrote:
> > Will reading the vm.def, I  cam across the no_opt macro.
> > I guess is to avoid some optimization but  but what kind of optimization 
> > and 
>why.
> > 
> > The macro is define  as:
> > 
> > #define no_opt(x)    ({ __typeof__ ((x)) _result;  \
> >               asm ("" : "=r"  (_result) : "0" ((x))); _result; })
> > 
> > 
> >  From what I  understand is that it define a variable _result and force to 
>move x
> > into  _result.
> > 
> > The macro is used in tha bytecode PLUS_SPECIAL an  MINUS SPECIAL ... :
> > 
> >   intptr_t iresult = no_opt (iop1 +  iop2);
> > 
> > Thanks for shading the light on this point.
> 
> Here  is the context:
> 
>       intptr_t iop1 = (intptr_t)  op1;
>       intptr_t iop2 = ((intptr_t) op2) - 1;
>        intptr_t iresult = no_opt (iop1 + iop2);
>        if (iresult < iop1)
> 
> Remember that these snippets are copied in many  places.  For example, when 
>compiling code for a superoperator (compound  bytecode) like
> 
>      PUSH_TEMPORARY(*)
>       PUSH_INTEGER(1)
>      PLUS_SPECIAL()
> 
> GCC would  have
> 
>       intptr_t iop1 = (intptr_t) op1;
>        intptr_t iresult = no_opt (iop1 + 2);
>       if  (iresult < iop1)
> 
> Without no_opt, "iop1 + 2 < iop1" would be  simplified to "false", thus 
> causing 
>the overflow check to  misbehave.
> 
> Paolo
> 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]