Changeset 18783b4


Ignore:
Timestamp:
Sep 4, 2021, 10:34:43 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
49b3389
Parents:
f450f2f
Message:

attempt to remove tail-recursion optimization

Location:
doc/theses/andrew_beach_MMath/code
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/andrew_beach_MMath/code/fixup-empty-f.cfa

    rf450f2f r18783b4  
    44#include <stdlib.hfa>                                                                   // strto
    55
    6 int nounwind_fixup(unsigned int frames, void (*raised_rtn)(int &)) {
     6void nounwind_fixup(unsigned int frames, void (*raised_rtn)(int &)) {
    77        if (frames) {
    8                 int rtn = nounwind_fixup(frames - 1, raised_rtn);
    9                 if ( rtn == 42 ) printf( "42" );                                // make non-tail recursive
    10                 return rtn;
    11 
     8                nounwind_fixup(frames - 1, raised_rtn);
     9                if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
    1210        } else {
    1311                int fixup = 17;
    1412                raised_rtn(fixup);
    15                 return fixup;
    1613        }
    1714}
  • doc/theses/andrew_beach_MMath/code/fixup-empty-r.cfa

    rf450f2f r18783b4  
    1010vtable(fixup_exception) fixup_vt;
    1111
    12 int nounwind_empty(unsigned int frames) {
     12void nounwind_empty(unsigned int frames) {
    1313        if (frames) {
    14                 int rtn = nounwind_empty(frames - 1);
    15                 if ( rtn == 42 ) printf( "42" );                                // make non-tail recursive
    16                 return rtn;
     14                nounwind_empty(frames - 1);
     15                if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
    1716        } else {
    1817                int fixup = 17;
    1918                throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup
    20                 return fixup;
    2119        }
    2220}
  • doc/theses/andrew_beach_MMath/code/fixup-other-f.cfa

    rf450f2f r18783b4  
    1414                frames -= 1;
    1515                nounwind_fixup(42, raised_rtn, not_raised);
     16                if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
    1617        } else {
    1718                int fixup = dummy;
  • doc/theses/andrew_beach_MMath/code/fixup-other-r.cfa

    rf450f2f r18783b4  
    2020                try {
    2121                        nounwind_other(42);
     22                        if ( frames == -1 ) printf( "42" );                     // prevent recursion optimizations
    2223                } catchResume (not_raised_exception * ex) {
    2324                        ex->fixup = frames + 42;                                        // use local scope => lexical link
  • doc/theses/andrew_beach_MMath/code/resume-empty.cfa

    rf450f2f r18783b4  
    1111        if (frames) {
    1212                nounwind_empty(frames - 1);
     13                if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
    1314        } else {
    1415                throwResume (empty_exception){&empty_vt};
Note: See TracChangeset for help on using the changeset viewer.