Ignore:
Timestamp:
Jul 20, 2021, 3:31:20 PM (3 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
86fc350
Parents:
815c6ae
Message:

Added asm statements to the exception benchmarks to prevent unwanted optimizations.

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

Legend:

Unmodified
Added
Removed
  • doc/theses/andrew_beach_MMath/code/cond-catch.cfa

    r815c6ae r54651005  
    1919                throw_exception();
    2020        } catch (empty_exception * exc ; should_catch) {
    21                 // ...
     21                asm volatile ("# catch block (conditional)");
    2222        }
    2323}
     
    3737                        cond_catch();
    3838                } catch (empty_exception * exc) {
    39                         // ...
     39                        asm volatile ("# catch block (unconditional)");
    4040                }
    4141        }
  • doc/theses/andrew_beach_MMath/code/cond-catch.cpp

    r815c6ae r54651005  
    2222                        throw;
    2323                }
     24                asm volatile ("# catch block (conditional)");
    2425        }
    2526}
     
    3940                        cond_catch();
    4041                } catch (EmptyException &) {
    41                         // ...
     42                        asm volatile ("# catch block (unconditional)");
    4243                }
    4344    }
  • doc/theses/andrew_beach_MMath/code/cond-fixup.cfa

    r815c6ae r54651005  
    1919                throw_exception();
    2020        } catchResume (empty_exception * exc ; should_catch) {
    21                 // ...
     21                asm volatile ("# fixup block (conditional)");
    2222        }
    2323}
     
    3737                        cond_catch();
    3838                } catchResume (empty_exception * exc) {
    39                         // ...
     39                        asm volatile ("# fixup block (unconditional)");
    4040                }
    4141        }
  • doc/theses/andrew_beach_MMath/code/cross-catch.cfa

    r815c6ae r54651005  
    77EHM_EXCEPTION(not_raised_exception)();
    88
     9EHM_VIRTUAL_TABLE(not_raised_exception, not_vt);
     10
    911int main(int argc, char * argv[]) {
    1012        unsigned int times = 1;
    11         unsigned int total_frames = 1;
     13        bool should_throw = false;
    1214        if (1 < argc) {
    1315                times = strtol(argv[1], 0p, 10);
    14         }
    15         if (2 < argc) {
    16                 total_frames = strtol(argv[2], 0p, 10);
    1716        }
    1817
     
    2019        for (unsigned int count = 0 ; count < times ; ++count) {
    2120                try {
    22                         // ...
     21                        asm volatile ("# try block" : "=rm" (should_throw));
     22                        if (should_throw) {
     23                                throw (not_raised_exception){&not_vt};
     24                        }
    2325                } catch (not_raised_exception *) {
    24                         // ...
     26                        asm volatile ("# catch block");
    2527                }
    2628        }
  • doc/theses/andrew_beach_MMath/code/cross-catch.cpp

    r815c6ae r54651005  
    1111int main(int argc, char * argv[]) {
    1212        unsigned int times = 1;
     13        bool should_throw = false;
    1314        if (1 < argc) {
    1415                times = strtol(argv[1], nullptr, 10);
     
    1819        for (unsigned int count = 0 ; count < times ; ++count) {
    1920                try {
    20                         // ...
     21                        asm volatile ("# try block" : "=rm" (should_throw));
     22                        if (should_throw) {
     23                                throw NotRaisedException();
     24                        }
    2125                } catch (NotRaisedException &) {
    22                         // ...
     26                        asm volatile ("# catch block");
    2327                }
    2428        }
  • doc/theses/andrew_beach_MMath/code/cross-finally.cfa

    r815c6ae r54651005  
    55#include <stdlib.hfa>
    66
     7EHM_EXCEPTION(not_raised_exception)();
     8
     9EHM_VIRTUAL_TABLE(not_raised_exception, not_vt);
     10
    711int main(int argc, char * argv[]) {
    812        unsigned int times = 1;
    9         unsigned int total_frames = 1;
     13        bool should_throw = false;
    1014        if (1 < argc) {
    1115                times = strtol(argv[1], 0p, 10);
    12         }
    13         if (2 < argc) {
    14                 total_frames = strtol(argv[2], 0p, 10);
    1516        }
    1617
    1718        Time start_time = timeHiRes();
    1819        for (unsigned int count = 0 ; count < times ; ++count) {
    19                  try {
    20                         // ...
     20                try {
     21                        asm volatile ("# try block" : "=rm" (should_throw));
     22                        if (should_throw) {
     23                                throw (not_raised_exception){&not_vt};
     24                        }
    2125                } finally {
    22                         // ...
     26                        asm volatile ("# finally block");
    2327                }
    2428        }
  • doc/theses/andrew_beach_MMath/code/cross-resume.cfa

    r815c6ae r54651005  
    2020        for (unsigned int count = 0 ; count < times ; ++count) {
    2121                try {
    22                         // ...
     22                        asm volatile ("");
    2323                } catchResume (not_raised_exception *) {
    24                         // ...
     24                        asm volatile ("");
    2525                }
    2626        }
  • doc/theses/andrew_beach_MMath/code/resume-detor.cfa

    r815c6ae r54651005  
    1212
    1313void ^?{}(WithDestructor & this) {
    14     // ...
     14        asm volatile ("# destructor body");
    1515}
    1616
    1717void unwind_destructor(unsigned int frames) {
    18     if (frames) {
     18        if (frames) {
    1919
    20         WithDestructor object;
    21         unwind_destructor(frames - 1);
    22     } else {
    23         throwResume (empty_exception){&empty_vt};
    24     }
     20                WithDestructor object;
     21                unwind_destructor(frames - 1);
     22        } else {
     23                throwResume (empty_exception){&empty_vt};
     24        }
    2525}
    2626
     
    3636
    3737        Time start_time = timeHiRes();
    38     for (int count = 0 ; count < times ; ++count) {
    39         try {
    40             unwind_destructor(total_frames);
    41         } catchResume (empty_exception *) {
    42             // ...
    43         }
    44     }
     38        for (int count = 0 ; count < times ; ++count) {
     39                try {
     40                        unwind_destructor(total_frames);
     41                } catchResume (empty_exception *) {
     42                        asm volatile ("# fixup block");
     43                }
     44        }
    4545        Time end_time = timeHiRes();
    4646        sout | "Run-Time (ns): " | (end_time - start_time)`ns;
  • doc/theses/andrew_beach_MMath/code/resume-empty.cfa

    r815c6ae r54651005  
    3232                        unwind_empty(total_frames);
    3333                } catchResume (empty_exception *) {
    34                         // ...
     34                        asm volatile ("# fixup block");
    3535                }
    3636        }
  • doc/theses/andrew_beach_MMath/code/resume-finally.cfa

    r815c6ae r54651005  
    1414                        unwind_finally(frames - 1);
    1515                } finally {
    16                         // ...
     16                        asm volatile ("# finally block");
    1717                }
    1818        } else {
     
    3636                        unwind_finally(total_frames);
    3737                } catchResume (empty_exception *) {
    38                         // ...
     38                        asm volatile ("# fixup block");
    3939                }
    4040        }
  • doc/theses/andrew_beach_MMath/code/resume-other.cfa

    r815c6ae r54651005  
    1616                        unwind_other(frames - 1);
    1717                } catchResume (not_raised_exception *) {
    18                         // ...
     18                        asm volatile ("# fixup block (stack)");
    1919                }
    2020        } else {
     
    3838                        unwind_other(total_frames);
    3939                } catchResume (empty_exception *) {
    40                         // ...
     40                        asm volatile ("# fixup block (base)");
    4141                }
    4242        }
  • doc/theses/andrew_beach_MMath/code/throw-detor.cfa

    r815c6ae r54651005  
    1212
    1313void ^?{}(WithDestructor & this) {
    14         // ...
     14        asm volatile ("# destructor body");
    1515}
    1616
     
    3939                        unwind_destructor(total_frames);
    4040                } catch (empty_exception *) {
    41                         // ...
     41                        asm volatile ("# catch block");
    4242                }
    4343        }
  • doc/theses/andrew_beach_MMath/code/throw-detor.cpp

    r815c6ae r54651005  
    1010
    1111struct WithDestructor {
    12         ~WithDestructor() {}
     12        ~WithDestructor() {
     13                asm volatile ("# destructor body");
     14        }
    1315};
    1416
     
    3739                        unwind_destructor(total_frames);
    3840                } catch (EmptyException &) {
    39                         // ...
     41                        asm volatile ("# catch block");
    4042                }
    4143        }
  • doc/theses/andrew_beach_MMath/code/throw-empty.cfa

    r815c6ae r54651005  
    3232                        unwind_empty(total_frames);
    3333                } catch (empty_exception *) {
    34                         // ...
     34                        asm volatile ("# catch block");
    3535                }
    3636        }
  • doc/theses/andrew_beach_MMath/code/throw-empty.cpp

    r815c6ae r54651005  
    3232                        unwind_empty(total_frames);
    3333                } catch (EmptyException &) {
    34                         // ...
     34                        asm volatile ("# catch block");
    3535                }
    3636        }
  • doc/theses/andrew_beach_MMath/code/throw-finally.cfa

    r815c6ae r54651005  
    1414                        unwind_finally(frames - 1);
    1515                } finally {
    16                         // ...
     16                        asm volatile ("# finally block");
    1717                }
    1818        } else {
     
    3636                        unwind_finally(total_frames);
    3737                } catch (empty_exception *) {
    38                         // ...
     38                        asm volatile ("# catch block");
    3939                }
    4040        }
  • doc/theses/andrew_beach_MMath/code/throw-other.cfa

    r815c6ae r54651005  
    1616                        unwind_other(frames - 1);
    1717                } catch (not_raised_exception *) {
    18                         // ...
     18                        asm volatile ("# catch block (stack)");
    1919                }
    2020        } else {
     
    3838                        unwind_other(total_frames);
    3939                } catch (empty_exception *) {
    40                         // ...
     40                        asm volatile ("# catch block (base)");
    4141                }
    4242        }
  • doc/theses/andrew_beach_MMath/code/throw-other.cpp

    r815c6ae r54651005  
    1616                        unwind_other(frames - 1);
    1717                } catch (NotRaisedException &) {
    18                         // ...
     18                        asm volatile ("# catch block (stack)");
    1919                }
    2020        } else {
     
    3838                        unwind_other(total_frames);
    3939                } catch (EmptyException &) {
    40                         // ...
     40                        asm volatile ("# catch block (base)");
    4141                }
    4242        }
Note: See TracChangeset for help on using the changeset viewer.