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

_______________________________________________
help-smalltalk mailing list
help-smalltalk@gnu.org
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to