[M3commit] [modula3/cm3] 496e9b: Fix compiler-generated FINALLY procedure using par...

Rodney Bates rodney.m.bates at acm.org
Sun Aug 2 02:36:54 CEST 2015

  Branch: refs/heads/master
  Home:   https://github.com/modula3/cm3
  Commit: 496e9be1dcdcf87bda8e72239fc90132591b4cf4
  Author: Rodney Bates <rodney.m.bates at acm.org>
  Date:   2015-08-01 (Sat, 01 Aug 2015)

  Changed paths:
    M m3-sys/m3front/src/misc/CG.m3

  Log Message:
  Fix compiler-generated FINALLY procedure using parent procedure's temporary.

 Changes to be committed:

	modified:   m3-sys/m3front/src/misc/CG.m3

CG was not stacking global variables used for keeping track of temporaries
when entering nested procedures.  In the case of a compiler-generated
nested procedure for the finally part of a TRY--FINALLY block, this
meant the finally code could use a temporary allocated by the parent,
though not in use at the time.  This violated the comment in M3CG_Ops.i3:

    declare_temp (s: ByteSize;  a: Alignment;  t: Type;
            in_memory: BOOLEAN): Var;
    (* declares an anonymous local variable.  Temps are declared
       and freed between their containing procedure's begin_procedure and
       end_procedure calls.  Temps are never referenced by nested procedures. *)

In cases of nested procedures explicitly declared in source code, this
didn't matter because they are located ahead of any of the parent
procedure's executable code, when it has no allocated temps, and they
free their own temps at their end, restoring the previous state.

More information about the M3commit mailing list