Ignore:
Timestamp:
Sep 16, 2021, 2:22:01 PM (4 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
432bffe, 7e7a076
Parents:
a8367eb (diff), 140eb16 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

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

Legend:

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

    ra8367eb r4d8fbf4  
    22#include <clock.hfa>
    33#include <fstream.hfa>
    4 #include <stdlib.hfa>                                                                   // strto
     4#include <stdlib.hfa>
    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                // "Always" false, but prevents recursion elimination.
     10                if (-1 == frames) printf("~");
    1211        } else {
    1312                int fixup = 17;
    1413                raised_rtn(fixup);
    15                 return fixup;
    1614        }
    1715}
     
    2725        }
    2826
     27        // Closures at the top level are allowed to be true closures.
    2928        void raised(int & fixup) {
    30                 fixup = total_frames + 42;                                              // use local scope => lexical link
    31                 if ( total_frames == 42 ) printf( "42" );
     29                fixup = total_frames + 42;
     30                if (total_frames == 42) printf("42");
    3231        }
    3332
  • doc/theses/andrew_beach_MMath/code/fixup-empty-r.cfa

    ra8367eb r4d8fbf4  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>                                                                   // strto
     5#include <stdlib.hfa>
    66
    77exception fixup_exception {
     
    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                // "Always" false, but prevents recursion elimination.
     16                if (-1 == frames) printf("~");
    1717        } else {
    1818                int fixup = 17;
    19                 throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup
    20                 return fixup;
     19                throwResume (fixup_exception){&fixup_vt, fixup};
    2120        }
    2221}
  • doc/theses/andrew_beach_MMath/code/fixup-other-f.cfa

    ra8367eb r4d8fbf4  
    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);
     17                // Always false, but prevents recursion elimination.
     18                if (-1 == frames) printf("~");
    1619        } else {
    1720                int fixup = dummy;
     
    3134        frames = total_frames;
    3235
     36        // Closures at the top level are allowed to be true closures.
    3337        void raised(int & fixup) {
    34                 fixup = total_frames + 42;                                              // use local scope => lexical link
     38                fixup = total_frames + 42;
    3539        }
    3640        void not_raised(int & fixup) {
    37                 fixup = total_frames + 42;                                              // use local scope => lexical link
     41                fixup = total_frames + 42;
    3842        }
    3943
  • doc/theses/andrew_beach_MMath/code/fixup-other-r.cfa

    ra8367eb r4d8fbf4  
    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);
     23                        // Always false, but prevents recursion elimination.
     24                        if (-1 == frames) printf("~");
    2225                } catchResume (not_raised_exception * ex) {
    23                         ex->fixup = frames + 42;                                        // use local scope => lexical link
     26                        ex->fixup = frames + 42;
    2427                }
    2528        } else {
    2629                int fixup = dummy;
    27                 throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup
     30                throwResume (fixup_exception){&fixup_vt, fixup};
    2831        }
    2932}
  • doc/theses/andrew_beach_MMath/code/resume-empty.cfa

    ra8367eb r4d8fbf4  
    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};
  • doc/theses/andrew_beach_MMath/code/test.sh

    ra8367eb r4d8fbf4  
    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
     
    5255)
    5356
    54 if [ "-a" = "$1" ]; then                        # build all
     57if [ "-a" = "$1" ]; then
    5558        for file in *.cfa *.cpp *.java; do
    5659                build $file
    5760        done
    5861        exit 0
    59 elif [ "-b" = "$1" ]; then                      # build given
     62elif [ "-b" = "$1" ]; then
    6063        for file in "${@:2}"; do
    6164                build $file
    6265        done
    6366        exit 0
    64 elif [ "-c" = "$1" ]; then                      # clean all
     67elif [ "-c" = "$1" ]; then
    6568        rm $(basename -s ".cfa" -a *.cfa)
    6669        rm $(basename -s ".cpp" -a *.cpp)
     
    8992raise-empty)
    9093        CFAT="./throw-empty $ITERS_1M $STACK_HEIGHT"
    91         CFAR="./resume-empty $ITERS_1M $STACK_HEIGHT"
     94        CFAR="./resume-empty $ITERS_10M $STACK_HEIGHT"
    9295        CPP="./throw-empty-cpp $ITERS_1M $STACK_HEIGHT"
    9396        JAVA="java ThrowEmpty $ITERS_1M $STACK_HEIGHT"
     
    9699raise-detor)
    97100        CFAT="./throw-detor $ITERS_1M $STACK_HEIGHT"
    98         CFAR="./resume-detor $ITERS_1M $STACK_HEIGHT"
     101        CFAR="./resume-detor $ITERS_10M $STACK_HEIGHT"
    99102        CPP="./throw-detor-cpp $ITERS_1M $STACK_HEIGHT"
    100103        JAVA=unsupported
     
    103106raise-finally)
    104107        CFAT="./throw-finally $ITERS_1M $STACK_HEIGHT"
    105         CFAR="./resume-finally $ITERS_1M $STACK_HEIGHT"
     108        CFAR="./resume-finally $ITERS_10M $STACK_HEIGHT"
    106109        CPP=unsupported
    107110        JAVA="java ThrowFinally $ITERS_1M $STACK_HEIGHT"
     
    110113raise-other)
    111114        CFAT="./throw-other $ITERS_1M $STACK_HEIGHT"
    112         CFAR="./resume-other $ITERS_1M $STACK_HEIGHT"
     115        CFAR="./resume-other $ITERS_10M $STACK_HEIGHT"
    113116        CPP="./throw-other-cpp $ITERS_1M $STACK_HEIGHT"
    114117        JAVA="java ThrowOther $ITERS_1M $STACK_HEIGHT"
     
    131134cond-match-all)
    132135        CFAT="./cond-catch $ITERS_10M 1"
    133         CFAR="./cond-fixup $ITERS_10M 1"
     136        CFAR="./cond-fixup $ITERS_100M 1"
    134137        CPP="./cond-catch-cpp $ITERS_10M 1"
    135138        JAVA="java CondCatch $ITERS_10M 1"
     
    138141cond-match-none)
    139142        CFAT="./cond-catch $ITERS_10M 0"
    140         CFAR="./cond-fixup $ITERS_10M 0"
     143        CFAR="./cond-fixup $ITERS_100M 0"
    141144        CPP="./cond-catch-cpp $ITERS_10M 0"
    142145        JAVA="java CondCatch $ITERS_10M 0"
     
    164167
    165168case "$TEST_LANG" in
    166         cfa-t) CALL="$CFAT";;
    167         cfa-r) CALL="$CFAR";;
    168         cpp) CALL="$CPP";;
    169         java) CALL="$JAVA";;
    170         python) CALL="$PYTHON";;
    171         *)
    172                 echo "No such language: $TEST_LANG" >&2
    173                 exit 2
     169cfa-t) CALL="$CFAT";;
     170cfa-r) CALL="$CFAR";;
     171cpp) CALL="$CPP";;
     172java) CALL="$JAVA";;
     173python) CALL="$PYTHON";;
     174*)
     175        echo "No such language: $TEST_LANG" >&2
     176        exit 2
    174177        ;;
    175178esac
     
    178181
    179182if [ -n "$VIEW_FILE" ]; then
    180         grep -A 1 -B 0 "$CALL" "$VIEW_FILE" | sed -n -e 's!Run-Time (ns): !!;T;p'
     183        grep -A 1 -B 0 "$CALL" "$VIEW_FILE" | sed -n -e 's!Run-Time.*: !!;T;p'
    181184        exit
    182185fi
  • doc/theses/andrew_beach_MMath/code/throw-empty.cfa

    ra8367eb r4d8fbf4  
    1111        if (frames) {
    1212                unwind_empty(frames - 1);
     13                if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
    1314        } else {
    1415                throw (empty_exception){&empty_vt};
  • doc/theses/andrew_beach_MMath/code/throw-empty.cpp

    ra8367eb r4d8fbf4  
    11// Throw Across Empty Function
    22#include <chrono>
     3#include <cstdio>
    34#include <cstdlib>
    45#include <exception>
     
    1415        if (frames) {
    1516                unwind_empty(frames - 1);
     17                if (-1 == frames) printf("~");
    1618        } else {
    1719                throw (EmptyException){};
Note: See TracChangeset for help on using the changeset viewer.