Ignore:
Timestamp:
Sep 9, 2021, 3:56:32 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
d0b9247
Parents:
dd1cc02 (diff), d8d512e (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:
10 added
20 edited
13 moved

Legend:

Unmodified
Added
Removed
  • doc/theses/andrew_beach_MMath/code/CondCatch.java

    rdd1cc02 r5a40e4e  
    66        static boolean should_catch = false;
    77
    8         static void throw_exception() throws EmptyException {
    9                 throw new EmptyException();
    10         }
    11 
    12         static void cond_catch() throws EmptyException {
    13                 try {
    14                         throw_exception();
    15                 } catch (EmptyException exc) {
    16                         if (!should_catch) {
    17                                 throw exc;
    18                         }
    19                 }
    20         }
    21 
    228        private static long loop(int times) {
    239                long startTime = System.nanoTime();
    2410                for (int count = 0 ; count < times ; ++count) {
    2511                        try {
    26                                 cond_catch();
     12                                try {
     13                                        throw new EmptyException();
     14                                } catch (EmptyException exc) {
     15                                        if (!should_catch) {
     16                                                throw exc;
     17                                        }
     18                                }
    2719                        } catch (EmptyException exc) {
    2820                                // ...
     
    4638
    4739                long time = loop(times);
    48                 System.out.println("Run-Time (ns): " + time);
     40                System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.);
    4941        }
    5042}
  • doc/theses/andrew_beach_MMath/code/ThrowEmpty.java

    rdd1cc02 r5a40e4e  
    3939
    4040                long time = loop(times, total_frames);
    41                 System.out.println("Run-Time (ns): " + time);
     41                System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.);
    4242        }
    4343}
  • doc/theses/andrew_beach_MMath/code/ThrowFinally.java

    rdd1cc02 r5a40e4e  
    4444
    4545                long time = loop(times, total_frames);
    46                 System.out.println("Run-Time (ns): " + time);
     46                System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.);
    4747        }
    4848}
  • doc/theses/andrew_beach_MMath/code/ThrowOther.java

    rdd1cc02 r5a40e4e  
    5252
    5353                long time = loop(times, total_frames);
    54                 System.out.println("Run-Time (ns): " + time);
     54                System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.);
    5555        }
    5656}
  • doc/theses/andrew_beach_MMath/code/TryCatch.java

    rdd1cc02 r5a40e4e  
    33class NotRaisedException extends Exception {}
    44
    5 public class CrossCatch {
     5public class TryCatch {
    66        private static boolean shouldThrow = false;
    77
     
    3131
    3232                long time = loop(times);
    33                 System.out.println("Run-Time (ns): " + time);
     33                System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.);
    3434        }
    3535}
  • doc/theses/andrew_beach_MMath/code/TryFinally.java

    rdd1cc02 r5a40e4e  
    1 // Cross a Try Statement with a Finally Clause
     1// Enter and Leave a Try Statement with a Finally Handler
    22
    3 public class CrossFinally {
     3public class TryFinally {
    44        private static boolean shouldThrow = false;
    55
     
    2727
    2828                long time = loop(times);
    29                 System.out.println("Run-Time (ns): " + time);
     29                System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.);
    3030        }
    3131}
  • doc/theses/andrew_beach_MMath/code/cond-catch.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.h>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(empty_exception)();
    8 
    9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
     7exception empty_exception;
     8vtable(empty_exception) empty_vt;
    109
    1110bool should_catch = false;
    12 
    13 void throw_exception() {
    14         throw (empty_exception){&empty_vt};
    15 }
    16 
    17 void cond_catch() {
    18         try {
    19                 throw_exception();
    20         } catch (empty_exception * exc ; should_catch) {
    21                 asm volatile ("# catch block (conditional)");
    22         }
    23 }
    2411
    2512int main(int argc, char * argv[]) {
    2613        unsigned int times = 1;
    2714        if (1 < argc) {
    28                 times = strtol(argv[1], 0p, 10);
     15                times = strto(argv[1], 0p, 10);
    2916        }
    3017        if (2 < argc) {
    31                 should_catch = strtol(argv[2], 0p, 10);
     18                should_catch = (unsigned int)strto(argv[2], 0p, 2);
    3219        }
    3320
     
    3522        for (unsigned int count = 0 ; count < times ; ++count) {
    3623                try {
    37                         cond_catch();
     24                        throw (empty_exception){&empty_vt};
     25                } catch (empty_exception * exc ; should_catch) {
     26                        asm volatile ("# catch block (conditional)");
    3827                } catch (empty_exception * exc) {
    3928                        asm volatile ("# catch block (unconditional)");
     
    4130        }
    4231        Time end_time = timeHiRes();
    43         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     32        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    4433}
  • doc/theses/andrew_beach_MMath/code/cond-catch.cpp

    rdd1cc02 r5a40e4e  
    44#include <exception>
    55#include <iostream>
     6#include <iomanip>
    67
     8using namespace std;
    79using namespace std::chrono;
    810
     
    1012
    1113bool should_catch = false;
    12 
    13 void throw_exception() {
    14         throw EmptyException();
    15 }
    16 
    17 void cond_catch() {
    18         try {
    19                 throw_exception();
    20         } catch (EmptyException & exc) {
    21                 if (!should_catch) {
    22                         throw;
    23                 }
    24                 asm volatile ("# catch block (conditional)");
    25         }
    26 }
    2714
    2815int main(int argc, char * argv[]) {
     
    3825    for (unsigned int count = 0 ; count < times ; ++count) {
    3926        try {
    40                         cond_catch();
     27                        try {
     28                                throw EmptyException();
     29                        } catch (EmptyException & exc) {
     30                                if (!should_catch) {
     31                                        throw;
     32                                }
     33                                asm volatile ("# catch block (conditional)");
     34                        }
    4135                } catch (EmptyException &) {
    4236                        asm volatile ("# catch block (unconditional)");
     
    4539        time_point<steady_clock> end_time = steady_clock::now();
    4640        nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time);
    47         std::cout << "Run-Time (ns): " << duration.count() << std::endl;
     41        cout << "Run-Time (s): " << fixed << setprecision(1) << duration.count() / 1'000'000'000. << endl;
    4842}
  • doc/theses/andrew_beach_MMath/code/cond-catch.py

    rdd1cc02 r5a40e4e  
    1313
    1414
    15 def throw_exception():
    16     raise EmptyException()
    17 
    18 
    19 def cond_catch():
    20     try:
    21         throw_exception()
    22     except EmptyException as exc:
    23         if not should_catch:
    24             raise
    25 
    26 
    2715def main(argv):
    2816    times = 1
     
    3523    for count in range(times):
    3624        try:
    37             cond_catch();
     25            try:
     26                raise EmptyException()
     27            except EmptyException as exc:
     28                if not should_catch:
     29                    raise
    3830        except EmptyException:
    3931            pass
    4032
    4133    end_time = thread_time_ns()
    42     print('Run-Time (ns):', end_time - start_time)
     34    print('Run-Time (s): {:.1f}'.format((end_time - start_time) / 1_000_000_000.))
    4335
    4436
  • doc/theses/andrew_beach_MMath/code/cond-fixup.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(empty_exception)();
    8 
    9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
     7exception empty_exception;
     8vtable(empty_exception) empty_vt;
    109
    1110bool should_catch = false;
    12 
    13 void throw_exception() {
    14         throwResume (empty_exception){&empty_vt};
    15 }
    16 
    17 void cond_catch() {
    18         try {
    19                 throw_exception();
    20         } catchResume (empty_exception * exc ; should_catch) {
    21                 asm volatile ("# fixup block (conditional)");
    22         }
    23 }
    2411
    2512int main(int argc, char * argv[]) {
    2613        unsigned int times = 1;
    2714        if (1 < argc) {
    28                 times = strtol(argv[1], 0p, 10);
     15                times = strto(argv[1], 0p, 10);
    2916        }
    3017        if (2 < argc) {
    31                 should_catch = strtol(argv[2], 0p, 10);
     18                should_catch = (unsigned int)strto(argv[2], 0p, 2);
    3219        }
    3320
     
    3522        for (unsigned int count = 0 ; count < times ; ++count) {
    3623                try {
    37                         cond_catch();
     24                        throwResume (empty_exception){&empty_vt};
     25                } catchResume (empty_exception * exc ; should_catch) {
     26                        asm volatile ("# fixup block (conditional)");
    3827                } catchResume (empty_exception * exc) {
    3928                        asm volatile ("# fixup block (unconditional)");
     
    4130        }
    4231        Time end_time = timeHiRes();
    43         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     32        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    4433}
  • doc/theses/andrew_beach_MMath/code/resume-detor.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(empty_exception)();
    8 
    9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
     7exception empty_exception;
     8vtable(empty_exception) empty_vt;
    109
    1110struct WithDestructor {};
     
    1716void unwind_destructor(unsigned int frames) {
    1817        if (frames) {
    19 
    2018                WithDestructor object;
    2119                unwind_destructor(frames - 1);
     
    2927        unsigned int total_frames = 1;
    3028        if (1 < argc) {
    31                 times = strtol(argv[1], 0p, 10);
     29                times = strto(argv[1], 0p, 10);
    3230        }
    3331        if (2 < argc) {
    34                 total_frames = strtol(argv[2], 0p, 10);
     32                total_frames = strto(argv[2], 0p, 10);
    3533        }
    3634
     
    4442        }
    4543        Time end_time = timeHiRes();
    46         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     44        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    4745}
  • doc/theses/andrew_beach_MMath/code/resume-empty.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(empty_exception)();
     7exception empty_exception;
     8vtable(empty_exception) empty_vt;
    89
    9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
    10 
    11 void unwind_empty(unsigned int frames) {
     10void nounwind_empty(unsigned int frames) {
    1211        if (frames) {
    13                 unwind_empty(frames - 1);
     12                nounwind_empty(frames - 1);
     13                if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
    1414        } else {
    1515                throwResume (empty_exception){&empty_vt};
     
    2121        unsigned int total_frames = 1;
    2222        if (1 < argc) {
    23                 times = strtol(argv[1], 0p, 10);
     23                times = strto(argv[1], 0p, 10);
    2424        }
    2525        if (2 < argc) {
    26                 total_frames = strtol(argv[2], 0p, 10);
     26                total_frames = strto(argv[2], 0p, 10);
    2727        }
    2828
    2929        Time start_time = timeHiRes();
    30         for (int count = 0 ; count < times ; ++count) {
     30        for (unsigned int count = 0 ; count < times ; ++count) {
    3131                try {
    32                         unwind_empty(total_frames);
     32                        nounwind_empty(total_frames);
    3333                } catchResume (empty_exception *) {
    3434                        asm volatile ("# fixup block");
     
    3636        }
    3737        Time end_time = timeHiRes();
    38         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     38        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    3939}
  • doc/theses/andrew_beach_MMath/code/resume-finally.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(empty_exception)();
    8 
    9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
     7exception empty_exception;
     8vtable(empty_exception) empty_vt;
    109
    1110void unwind_finally(unsigned int frames) {
     
    2524        unsigned int total_frames = 1;
    2625        if (1 < argc) {
    27                 times = strtol(argv[1], 0p, 10);
     26                times = strto(argv[1], 0p, 10);
    2827        }
    2928        if (2 < argc) {
    30                 total_frames = strtol(argv[2], 0p, 10);
     29                total_frames = strto(argv[2], 0p, 10);
    3130        }
    3231
     
    4039        }
    4140        Time end_time = timeHiRes();
    42         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     41        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    4342}
  • doc/theses/andrew_beach_MMath/code/resume-other.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(empty_exception)();
     7exception empty_exception;
     8vtable(empty_exception) empty_vt;
     9exception not_raised_exception;
    810
    9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
    10 
    11 EHM_EXCEPTION(not_raised_exception)();
    12 
    13 void unwind_other(unsigned int frames) {
     11void nounwind_other(unsigned int frames) {
    1412        if (frames) {
    1513                try {
    16                         unwind_other(frames - 1);
     14                        nounwind_other(frames - 1);
    1715                } catchResume (not_raised_exception *) {
    1816                        asm volatile ("# fixup block (stack)");
     
    2725        unsigned int total_frames = 1;
    2826        if (1 < argc) {
    29                 times = strtol(argv[1], 0p, 10);
     27                times = strto(argv[1], 0p, 10);
    3028        }
    3129        if (2 < argc) {
    32                 total_frames = strtol(argv[2], 0p, 10);
     30                total_frames = strto(argv[2], 0p, 10);
    3331        }
    3432
     
    3634        for (int count = 0 ; count < times ; ++count) {
    3735                try {
    38                         unwind_other(total_frames);
     36                        nounwind_other(total_frames);
    3937                } catchResume (empty_exception *) {
    4038                        asm volatile ("# fixup block (base)");
     
    4240        }
    4341        Time end_time = timeHiRes();
    44         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     42        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    4543}
  • doc/theses/andrew_beach_MMath/code/run.sh

    rdd1cc02 r5a40e4e  
    11#!/usr/bin/env bash
    22
    3 readonly ALL_TESTS=(cond-match-{all,none} cross-{catch,finally} \
    4                 raise-{detor,empty,finally,other})
     3readonly ALL_TESTS=(raise-{empty,detor,finally,other} try-{catch,finally} \
     4                        cond-match-{all,none} fixup-{empty,other})
    55
    66gen-file-name() (
     
    1818)
    1919
    20 readonly N=${1:-5}
     20readonly N=${1:-1}
    2121readonly OUT_FILE=$(gen-file-name ${2:-run-%-$N})
    2222
  • doc/theses/andrew_beach_MMath/code/test.sh

    rdd1cc02 r5a40e4e  
    44# test.sh LANGUAGE TEST
    55#   Run the TEST in LANGUAGE.
     6# test.sh -a
     7#   Build all tests.
    68# test.sh -b SOURCE_FILE...
    79#   Build a test from SOURCE_FILE(s).
     10# test.sh -c
     11#   Clean all executables.
    812# test.sh -v LANGUAGE TEST FILE
    913#   View the result from TEST in LANGUAGE stored in FILE.
    1014
    11 readonly ITERATIONS=1000000 # 1 000 000, one million
     15readonly DIR=$(dirname "$(readlink -f "$0")")
     16cd $DIR
     17
     18readonly MIL=000000
     19# Various preset values used as arguments.
     20readonly ITERS_1M=1$MIL
     21readonly ITERS_10M=10$MIL
     22readonly ITERS_100M=100$MIL
     23readonly ITERS_1000M=1000$MIL
    1224readonly STACK_HEIGHT=100
    1325
     
    2335        case "$1" in
    2436        *.cfa)
    25                 # Requires a symbolic link.
    26                 mmake "${1%.cfa}" "$1" ./cfa -DNDEBUG -nodebug -O3 "$1" -o "${1%.cfa}"
     37                # A symbolic link/local copy can be used as an override.
     38                cmd=./cfa
     39                if [ ! -x $cmd ]; then
     40                        cmd=cfa
     41                fi
     42                mmake "${1%.cfa}" "$1" $cmd -DNDEBUG -nodebug -O3 "$1" -o "${1%.cfa}"
    2743                ;;
    2844        *.cpp)
    29                 mmake "${1%.cpp}-cpp" "$1" g++ -DNDEBUG -O3 "$1" -o "${1%.cpp}-cpp"
     45                mmake "${1%.cpp}-cpp" "$1" g++-10 -DNDEBUG -O3 "$1" -o "${1%.cpp}-cpp"
    3046                ;;
    3147        *.java)
     
    3955)
    4056
    41 if [ "-b" = "$1" ]; then
     57if [ "-a" = "$1" ]; then
     58        for file in *.cfa *.cpp *.java; do
     59                build $file
     60        done
     61        exit 0
     62elif [ "-b" = "$1" ]; then
    4263        for file in "${@:2}"; do
    4364                build $file
    4465        done
    4566        exit 0
     67elif [ "-c" = "$1" ]; then
     68        rm $(basename -s ".cfa" -a *.cfa)
     69        rm $(basename -s ".cpp" -a *.cpp)
     70        rm *-cpp
     71        rm *.class
     72        exit 0
    4673elif [ "-v" = "$1" -a 4 = "$#" ]; then
    47     TEST_LANG="$2"
    48     TEST_CASE="$3"
    49     VIEW_FILE="$4"
     74        TEST_LANG="$2"
     75        TEST_CASE="$3"
     76        VIEW_FILE="$4"
    5077elif [ 2 -eq "$#" ]; then
    5178        TEST_LANG="$1"
     
    6390
    6491case "$TEST_CASE" in
    65 cond-match-all)
    66         CFAT="./cond-catch $ITERATIONS 1"
    67         CFAR="./cond-fixup $ITERATIONS 1"
    68         CPP="./cond-catch-cpp $ITERATIONS 1"
    69         JAVA="java CondCatch $ITERATIONS 1"
    70         PYTHON="./cond_catch.py $ITERATIONS 1"
    71         ;;
    72 cond-match-none)
    73         CFAT="./cond-catch $ITERATIONS 0"
    74         CFAR="./cond-fixup $ITERATIONS 0"
    75         CPP="./cond-catch-cpp $ITERATIONS 0"
    76         JAVA="java CondCatch $ITERATIONS 0"
    77         PYTHON="./cond_catch.py $ITERATIONS 0"
    78         ;;
    79 cross-catch)
    80         CFAT="./cross-catch $ITERATIONS"
    81         CFAR="./cross-resume $ITERATIONS"
    82         CPP="./cross-catch-cpp $ITERATIONS"
    83         JAVA="java CrossCatch $ITERATIONS"
    84         PYTHON="./cross_catch.py $ITERATIONS"
    85         ;;
    86 cross-finally)
    87         CFAT="./cross-finally $ITERATIONS"
    88         CFAR=unsupported
    89         CPP=unsupported
    90         JAVA="java CrossFinally $ITERATIONS"
    91         PYTHON="./cross_finally.py $ITERATIONS"
     92raise-empty)
     93        CFAT="./throw-empty $ITERS_1M $STACK_HEIGHT"
     94        CFAR="./resume-empty $ITERS_10M $STACK_HEIGHT"
     95        CPP="./throw-empty-cpp $ITERS_1M $STACK_HEIGHT"
     96        JAVA="java ThrowEmpty $ITERS_1M $STACK_HEIGHT"
     97        PYTHON="./throw-empty.py $ITERS_1M $STACK_HEIGHT"
    9298        ;;
    9399raise-detor)
    94         CFAT="./throw-detor $ITERATIONS $STACK_HEIGHT"
    95         CFAR="./resume-detor $ITERATIONS $STACK_HEIGHT"
    96         CPP="./throw-detor-cpp $ITERATIONS $STACK_HEIGHT"
     100        CFAT="./throw-detor $ITERS_1M $STACK_HEIGHT"
     101        CFAR="./resume-detor $ITERS_10M $STACK_HEIGHT"
     102        CPP="./throw-detor-cpp $ITERS_1M $STACK_HEIGHT"
    97103        JAVA=unsupported
    98104        PYTHON=unsupported
    99105        ;;
    100 raise-empty)
    101         CFAT="./throw-empty $ITERATIONS $STACK_HEIGHT"
    102         CFAR="./resume-empty $ITERATIONS $STACK_HEIGHT"
    103         CPP="./throw-empty-cpp $ITERATIONS $STACK_HEIGHT"
    104         JAVA="java ThrowEmpty $ITERATIONS $STACK_HEIGHT"
    105         PYTHON="./throw_empty.py $ITERATIONS $STACK_HEIGHT"
    106         ;;
    107106raise-finally)
    108         CFAT="./throw-finally $ITERATIONS $STACK_HEIGHT"
    109         CFAR="./resume-finally $ITERATIONS $STACK_HEIGHT"
     107        CFAT="./throw-finally $ITERS_1M $STACK_HEIGHT"
     108        CFAR="./resume-finally $ITERS_10M $STACK_HEIGHT"
    110109        CPP=unsupported
    111         JAVA="java ThrowFinally $ITERATIONS $STACK_HEIGHT"
    112         PYTHON="./throw_finally.py $ITERATIONS $STACK_HEIGHT"
     110        JAVA="java ThrowFinally $ITERS_1M $STACK_HEIGHT"
     111        PYTHON="./throw-finally.py $ITERS_1M $STACK_HEIGHT"
    113112        ;;
    114113raise-other)
    115         CFAT="./throw-other $ITERATIONS $STACK_HEIGHT"
    116         CFAR="./resume-other $ITERATIONS $STACK_HEIGHT"
    117         CPP="./throw-other-cpp $ITERATIONS $STACK_HEIGHT"
    118         JAVA="java ThrowOther $ITERATIONS $STACK_HEIGHT"
    119         PYTHON="./throw_other.py $ITERATIONS $STACK_HEIGHT"
     114        CFAT="./throw-other $ITERS_1M $STACK_HEIGHT"
     115        CFAR="./resume-other $ITERS_10M $STACK_HEIGHT"
     116        CPP="./throw-other-cpp $ITERS_1M $STACK_HEIGHT"
     117        JAVA="java ThrowOther $ITERS_1M $STACK_HEIGHT"
     118        PYTHON="./throw-other.py $ITERS_1M $STACK_HEIGHT"
     119        ;;
     120try-catch)
     121        CFAT="./try-catch $ITERS_1000M"
     122        CFAR="./try-resume $ITERS_1000M"
     123        CPP="./try-catch-cpp $ITERS_1000M"
     124        JAVA="java TryCatch $ITERS_1000M"
     125        PYTHON="./try-catch.py $ITERS_1000M"
     126        ;;
     127try-finally)
     128        CFAT="./try-finally $ITERS_1000M"
     129        CFAR=unsupported
     130        CPP=unsupported
     131        JAVA="java TryFinally $ITERS_1000M"
     132        PYTHON="./try-finally.py $ITERS_1000M"
     133        ;;
     134cond-match-all)
     135        CFAT="./cond-catch $ITERS_10M 1"
     136        CFAR="./cond-fixup $ITERS_100M 1"
     137        CPP="./cond-catch-cpp $ITERS_10M 1"
     138        JAVA="java CondCatch $ITERS_10M 1"
     139        PYTHON="./cond-catch.py $ITERS_10M 1"
     140        ;;
     141cond-match-none)
     142        CFAT="./cond-catch $ITERS_10M 0"
     143        CFAR="./cond-fixup $ITERS_100M 0"
     144        CPP="./cond-catch-cpp $ITERS_10M 0"
     145        JAVA="java CondCatch $ITERS_10M 0"
     146        PYTHON="./cond-catch.py $ITERS_10M 0"
     147        ;;
     148fixup-empty)
     149        CFAT="./fixup-empty-f $ITERS_10M $STACK_HEIGHT"
     150        CFAR="./fixup-empty-r $ITERS_10M $STACK_HEIGHT"
     151        CPP="./fixup-empty-cpp $ITERS_10M $STACK_HEIGHT"
     152        JAVA="java FixupEmpty $ITERS_10M $STACK_HEIGHT"
     153        PYTHON="./fixup-empty.py $ITERS_10M $STACK_HEIGHT"
     154        ;;
     155fixup-other)
     156        CFAT="./fixup-other-f $ITERS_10M $STACK_HEIGHT"
     157        CFAR="./fixup-other-r $ITERS_10M $STACK_HEIGHT"
     158        CPP="./fixup-other-cpp $ITERS_10M $STACK_HEIGHT"
     159        JAVA="java FixupOther $ITERS_10M $STACK_HEIGHT"
     160        PYTHON="./fixup-other.py $ITERS_10M $STACK_HEIGHT"
    120161        ;;
    121162*)
     
    140181
    141182if [ -n "$VIEW_FILE" ]; then
    142     grep -A 1 -B 0 "$CALL" "$VIEW_FILE" | sed -n -e 's!Run-Time (ns): !!;T;p'
    143     exit
     183        grep -A 1 -B 0 "$CALL" "$VIEW_FILE" | sed -n -e 's!Run-Time (ns): !!;T;p'
     184        exit
    144185fi
    145186
  • doc/theses/andrew_beach_MMath/code/throw-detor.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(empty_exception)();
    8 
    9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
     7exception empty_exception;
     8vtable(empty_exception) empty_vt;
    109
    1110struct WithDestructor {};
     
    2827        unsigned int total_frames = 1;
    2928        if (1 < argc) {
    30                 times = strtol(argv[1], 0p, 10);
     29                times = strto(argv[1], 0p, 10);
    3130        }
    3231        if (2 < argc) {
    33                 total_frames = strtol(argv[2], 0p, 10);
     32                total_frames = strto(argv[2], 0p, 10);
    3433        }
    3534
     
    4342        }
    4443        Time end_time = timeHiRes();
    45         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     44        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    4645}
  • doc/theses/andrew_beach_MMath/code/throw-detor.cpp

    rdd1cc02 r5a40e4e  
    44#include <exception>
    55#include <iostream>
     6#include <iomanip>
    67
     8using namespace std;
    79using namespace std::chrono;
    810
     
    4446        time_point<steady_clock> end_time = steady_clock::now();
    4547        nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time);
    46         std::cout << "Run-Time (ns): " << duration.count() << std::endl;
     48        cout << "Run-Time (s): " << fixed << setprecision(1) << duration.count() / 1'000'000'000. << endl;
    4749}
  • doc/theses/andrew_beach_MMath/code/throw-empty.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(empty_exception)();
    8 
    9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
     7exception empty_exception;
     8vtable(empty_exception) empty_vt;
    109
    1110void unwind_empty(unsigned int frames) {
     
    2120        unsigned int total_frames = 1;
    2221        if (1 < argc) {
    23                 times = strtol(argv[1], 0p, 10);
     22                times = strto(argv[1], 0p, 10);
    2423        }
    2524        if (2 < argc) {
    26                 total_frames = strtol(argv[2], 0p, 10);
     25                total_frames = strto(argv[2], 0p, 10);
    2726        }
    2827
     
    3635        }
    3736        Time end_time = timeHiRes();
    38         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     37        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    3938}
  • doc/theses/andrew_beach_MMath/code/throw-empty.cpp

    rdd1cc02 r5a40e4e  
    11// Throw Across Empty Function
    22#include <chrono>
     3#include <cstdio>
    34#include <cstdlib>
    45#include <exception>
    56#include <iostream>
     7#include <iomanip>
    68
     9using namespace std;
    710using namespace std::chrono;
    811
     
    1215        if (frames) {
    1316                unwind_empty(frames - 1);
     17                if (-1 == frames) printf("~");
    1418        } else {
    1519                throw (EmptyException){};
     
    3741        time_point<steady_clock> end_time = steady_clock::now();
    3842        nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time);
    39         std::cout << "Run-Time (ns): " << duration.count() << std::endl;
     43        cout << "Run-Time (s): " << fixed << setprecision(1) << duration.count() / 1'000'000'000. << endl;
    4044}
  • doc/theses/andrew_beach_MMath/code/throw-empty.py

    rdd1cc02 r5a40e4e  
    3333
    3434    end_time = thread_time_ns()
    35     print('Run-Time (ns):', end_time - start_time)
     35    print('Run-Time (s): {:.1f}'.format((end_time - start_time) / 1_000_000_000.))
    3636
    3737
  • doc/theses/andrew_beach_MMath/code/throw-finally.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(empty_exception)();
     7exception empty_exception;
     8vtable(empty_exception) empty_vt;
    89
    9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
     10unsigned int frames;                                                                    // use global because of gcc thunk problem
    1011
    11 void unwind_finally(unsigned int frames) {
     12void unwind_finally(unsigned int dummy) {
    1213        if (frames) {
     14                frames -= 1;
    1315                try {
    14                         unwind_finally(frames - 1);
     16                        unwind_finally(42);
    1517                } finally {
    1618                        asm volatile ("# finally block");
    1719                }
    1820        } else {
     21                dummy = 42;
    1922                throw (empty_exception){&empty_vt};
    2023        }
     
    2528        unsigned int total_frames = 1;
    2629        if (1 < argc) {
    27                 times = strtol(argv[1], 0p, 10);
     30                times = strto(argv[1], 0p, 10);
    2831        }
    2932        if (2 < argc) {
    30                 total_frames = strtol(argv[2], 0p, 10);
     33                total_frames = strto(argv[2], 0p, 10);
    3134        }
     35        frames = total_frames;
    3236
    3337        Time start_time = timeHiRes();
    3438        for (int count = 0 ; count < times ; ++count) {
    3539                try {
    36                         unwind_finally(total_frames);
     40                        unwind_finally(42);
    3741                } catch (empty_exception *) {
    3842                        asm volatile ("# catch block");
     
    4044        }
    4145        Time end_time = timeHiRes();
    42         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     46        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    4347}
  • doc/theses/andrew_beach_MMath/code/throw-finally.py

    rdd1cc02 r5a40e4e  
    3636
    3737    end_time = thread_time_ns()
    38     print('Run-Time (ns):', end_time - start_time)
     38    print('Run-Time (s): {:.1f}'.format((end_time - start_time) / 1_000_000_000.))
    3939
    4040
  • doc/theses/andrew_beach_MMath/code/throw-other.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(empty_exception)();
     7exception empty_exception;
     8vtable(empty_exception) empty_vt;
     9exception not_raised_exception;
    810
    9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
     11unsigned int frames;                                                                    // use global because of gcc thunk problem
    1012
    11 EHM_EXCEPTION(not_raised_exception)();
    12 
    13 void unwind_other(unsigned int frames) {
     13void unwind_other(unsigned int dummy) {
    1414        if (frames) {
     15                frames -= 1;
    1516                try {
    16                         unwind_other(frames - 1);
     17                        unwind_other(42);
    1718                } catch (not_raised_exception *) {
    1819                        asm volatile ("# catch block (stack)");
    1920                }
    2021        } else {
     22                dummy = 42;
    2123                throw (empty_exception){&empty_vt};
    2224        }
     
    2729        unsigned int total_frames = 1;
    2830        if (1 < argc) {
    29                 times = strtol(argv[1], 0p, 10);
     31                times = strto(argv[1], 0p, 10);
    3032        }
    3133        if (2 < argc) {
    32                 total_frames = strtol(argv[2], 0p, 10);
     34                total_frames = strto(argv[2], 0p, 10);
    3335        }
     36        frames = total_frames;
    3437
    3538        Time start_time = timeHiRes();
    3639        for (int count = 0 ; count < times ; ++count) {
    3740                try {
    38                         unwind_other(total_frames);
     41                        unwind_other(42);
    3942                } catch (empty_exception *) {
    4043                        asm volatile ("# catch block (base)");
     
    4245        }
    4346        Time end_time = timeHiRes();
    44         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     47        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    4548}
  • doc/theses/andrew_beach_MMath/code/throw-other.cpp

    rdd1cc02 r5a40e4e  
    44#include <exception>
    55#include <iostream>
     6#include <iomanip>
    67
     8using namespace std;
    79using namespace std::chrono;
    810
     
    4345        time_point<steady_clock> end_time = steady_clock::now();
    4446        nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time);
    45         std::cout << "Run-Time (ns): " << duration.count() << std::endl;
     47        cout << "Run-Time (s): " << fixed << setprecision(1) << duration.count() / 1'000'000'000. << endl;
    4648}
  • doc/theses/andrew_beach_MMath/code/throw-other.py

    rdd1cc02 r5a40e4e  
    4040
    4141    end_time = thread_time_ns()
    42     print('Run-Time (ns):', end_time - start_time)
     42    print('Run-Time (s): {:.1f}'.format((end_time - start_time) / 1_000_000_000.))
    4343
    4444
  • doc/theses/andrew_beach_MMath/code/throw-with.py

    rdd1cc02 r5a40e4e  
    4343
    4444    end_time = thread_time_ns()
    45     print('Run-Time (ns):', end_time - start_time)
     45    print('Run-Time (s): {:.1f}'.format((end_time - start_time) / 1_000_000_000.))
    4646
    4747
  • doc/theses/andrew_beach_MMath/code/try-catch.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(not_raised_exception)();
    8 
    9 EHM_VIRTUAL_TABLE(not_raised_exception, not_vt);
     7exception not_raised_exception;
     8vtable(not_raised_exception) not_vt;
    109
    1110int main(int argc, char * argv[]) {
     
    1312        volatile bool should_throw = false;
    1413        if (1 < argc) {
    15                 times = strtol(argv[1], 0p, 10);
     14                times = strto(argv[1], 0p, 10);
    1615        }
    1716
     
    2827        }
    2928        Time end_time = timeHiRes();
    30         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     29        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    3130}
  • doc/theses/andrew_beach_MMath/code/try-catch.cpp

    rdd1cc02 r5a40e4e  
    44#include <exception>
    55#include <iostream>
     6#include <iomanip>
    67
     8using namespace std;
    79using namespace std::chrono;
    810
     
    2931        time_point<steady_clock> end_time = steady_clock::now();
    3032        nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time);
    31         std::cout << "Run-Time (ns): " << duration.count() << std::endl;
     33        cout << "Run-Time (s): " << fixed << setprecision(1) << duration.count() / 1'000'000'000. << endl;
    3234}
  • doc/theses/andrew_beach_MMath/code/try-catch.py

    rdd1cc02 r5a40e4e  
    2323
    2424    end_time = thread_time_ns()
    25     print('Run-Time (ns):', end_time - start_time)
     25    print('Run-Time (s): {:.1f}'.format((end_time - start_time) / 1_000_000_000.))
    2626
    2727
  • doc/theses/andrew_beach_MMath/code/try-finally.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(not_raised_exception)();
    8 
    9 EHM_VIRTUAL_TABLE(not_raised_exception, not_vt);
     7exception not_raised_exception;
     8vtable(not_raised_exception) not_vt;
    109
    1110int main(int argc, char * argv[]) {
     
    1312        volatile bool should_throw = false;
    1413        if (1 < argc) {
    15                 times = strtol(argv[1], 0p, 10);
     14                times = strto(argv[1], 0p, 10);
    1615        }
    1716
     
    2827        }
    2928        Time end_time = timeHiRes();
    30         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     29        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    3130}
  • doc/theses/andrew_beach_MMath/code/try-finally.py

    rdd1cc02 r5a40e4e  
    2222
    2323    end_time = thread_time_ns()
    24     print('Run-Time (ns):', end_time - start_time)
     24    print('Run-Time (s): {:.1f}'.format((end_time - start_time) / 1_000_000_000.))
    2525
    2626
  • doc/theses/andrew_beach_MMath/code/try-resume.cfa

    rdd1cc02 r5a40e4e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(not_raised_exception)();
     7exception not_raised_exception;
    88
    99int main(int argc, char * argv[]) {
     
    1111        unsigned int total_frames = 1;
    1212        if (1 < argc) {
    13                 times = strtol(argv[1], 0p, 10);
     13                times = strto(argv[1], 0p, 10);
    1414        }
    1515        if (2 < argc) {
    16                 total_frames = strtol(argv[2], 0p, 10);
     16                total_frames = strto(argv[2], 0p, 10);
    1717        }
    1818
     
    2626        }
    2727        Time end_time = timeHiRes();
    28         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     28        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    2929}
Note: See TracChangeset for help on using the changeset viewer.