Changeset 812ba3d for doc/theses


Ignore:
Timestamp:
Sep 7, 2021, 9:59:12 AM (3 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
2bfee8e
Parents:
49b3389
Message:

Some clean-up to make Peter's changes to the exception benchmarks fit in better. And make test.sh a bit more robust.

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

Legend:

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

    r49b3389 r812ba3d  
    22#include <clock.hfa>
    33#include <fstream.hfa>
    4 #include <stdlib.hfa>                                                                   // strto
     4#include <stdlib.hfa>
    55
    66void nounwind_fixup(unsigned int frames, void (*raised_rtn)(int &)) {
    77        if (frames) {
    88                nounwind_fixup(frames - 1, raised_rtn);
    9                 if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
     9                // "Always" false, but prevents recursion elimination.
     10                if (-1 == frames) printf("~");
    1011        } else {
    1112                int fixup = 17;
     
    2425        }
    2526
     27        // Closures at the top level are allowed to be true closures.
    2628        void raised(int & fixup) {
    27                 fixup = total_frames + 42;                                              // use local scope => lexical link
    28                 if ( total_frames == 42 ) printf( "42" );
     29                fixup = total_frames + 42;
     30                if (total_frames == 42) printf("42");
    2931        }
    3032
  • doc/theses/andrew_beach_MMath/code/fixup-empty-r.cfa

    r49b3389 r812ba3d  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>                                                                   // strto
     5#include <stdlib.hfa>
    66
    77exception fixup_exception {
     
    1313        if (frames) {
    1414                nounwind_empty(frames - 1);
    15                 if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
     15                // "Always" false, but prevents recursion elimination.
     16                if (-1 == frames) printf("~");
    1617        } else {
    1718                int fixup = 17;
    18                 throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup
     19                throwResume (fixup_exception){&fixup_vt, fixup};
    1920        }
    2021}
  • doc/theses/andrew_beach_MMath/code/fixup-other-f.cfa

    r49b3389 r812ba3d  
    22#include <clock.hfa>
    33#include <fstream.hfa>
    4 #include <stdlib.hfa>                                                                   // strto
     4#include <stdlib.hfa>
    55
    6 unsigned int frames;                                                                    // use global because of gcc thunk problem
     6// Using a global value to allow hoisting (and avoid thunks).
     7unsigned int frames;
    78
    89void nounwind_fixup(unsigned int dummy, void (*raised_rtn)(int &), void (*not_raised_rtn)(int &)) {
    910        void not_raised(int & fixup) {
    10                 fixup = frames + 42;                                                    // use local scope => lexical link
     11                fixup = frames + 42;
    1112        }
    1213
     
    1415                frames -= 1;
    1516                nounwind_fixup(42, raised_rtn, not_raised);
    16                 if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
     17                // Always false, but prevents recursion elimination.
     18                if (-1 == frames) printf("~");
    1719        } else {
    1820                int fixup = dummy;
     
    3234        frames = total_frames;
    3335
     36        // Closures at the top level are allowed to be true closures.
    3437        void raised(int & fixup) {
    35                 fixup = total_frames + 42;                                              // use local scope => lexical link
     38                fixup = total_frames + 42;
    3639        }
    3740        void not_raised(int & fixup) {
    38                 fixup = total_frames + 42;                                              // use local scope => lexical link
     41                fixup = total_frames + 42;
    3942        }
    4043
  • doc/theses/andrew_beach_MMath/code/fixup-other-r.cfa

    r49b3389 r812ba3d  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>                                                                   // strto
     5#include <stdlib.hfa>
    66
    77exception fixup_exception {
     
    1313};
    1414
    15 unsigned int frames;                                                                    // use global because of gcc thunk problem
     15// Using a global value to allow hoisting (and avoid thunks).
     16unsigned int frames;
    1617
    1718void nounwind_other(unsigned int dummy) {
     
    2021                try {
    2122                        nounwind_other(42);
    22                         if ( frames == -1 ) printf( "42" );                     // prevent recursion optimizations
     23                        // Always false, but prevents recursion elimination.
     24                        if (-1 == frames) printf("~");
    2325                } catchResume (not_raised_exception * ex) {
    24                         ex->fixup = frames + 42;                                        // use local scope => lexical link
     26                        ex->fixup = frames + 42;
    2527                }
    2628        } else {
    2729                int fixup = dummy;
    28                 throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup
     30                throwResume (fixup_exception){&fixup_vt, fixup};
    2931        }
    3032}
  • doc/theses/andrew_beach_MMath/code/test.sh

    r49b3389 r812ba3d  
    1212# test.sh -v LANGUAGE TEST FILE
    1313#   View the result from TEST in LANGUAGE stored in FILE.
     14
     15readonly DIR=$(dirname "$(readlink -f "$0")")
     16cd $DIR
    1417
    1518readonly MIL=000000
Note: See TracChangeset for help on using the changeset viewer.