ADT
        ast-experimental
        enum
        forall-pointer-decay
        jacob/cs343-translation
        new-ast-unique-expr
        pthread-emulation
        qualifiedEnum
      
      
        
          | 
            Last change
 on this file since 8f6f3729 was             54651005, checked in by Andrew Beach <ajbeach@…>, 4 years ago           | 
        
        
          | 
             
Added asm statements to the exception benchmarks to prevent unwanted optimizations. 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            994 bytes
           | 
        
      
      
| Rev | Line |   | 
|---|
| [ea593a3] | 1 | // Resume Across Other Handler
 | 
|---|
| [ee23a8d] | 2 | #include <clock.hfa>
 | 
|---|
| [ea593a3] | 3 | #include <exception.hfa>
 | 
|---|
| [ee23a8d] | 4 | #include <fstream.hfa>
 | 
|---|
| [ea593a3] | 5 | #include <stdlib.hfa>
 | 
|---|
 | 6 | 
 | 
|---|
 | 7 | EHM_EXCEPTION(empty_exception)();
 | 
|---|
 | 8 | 
 | 
|---|
 | 9 | EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | EHM_EXCEPTION(not_raised_exception)();
 | 
|---|
 | 12 | 
 | 
|---|
 | 13 | void unwind_other(unsigned int frames) {
 | 
|---|
 | 14 |         if (frames) {
 | 
|---|
 | 15 |                 try {
 | 
|---|
 | 16 |                         unwind_other(frames - 1);
 | 
|---|
 | 17 |                 } catchResume (not_raised_exception *) {
 | 
|---|
| [54651005] | 18 |                         asm volatile ("# fixup block (stack)");
 | 
|---|
| [ea593a3] | 19 |                 }
 | 
|---|
 | 20 |         } else {
 | 
|---|
 | 21 |                 throwResume (empty_exception){&empty_vt};
 | 
|---|
 | 22 |         }
 | 
|---|
 | 23 | }
 | 
|---|
 | 24 | 
 | 
|---|
 | 25 | int main(int argc, char * argv[]) {
 | 
|---|
 | 26 |         unsigned int times = 1;
 | 
|---|
 | 27 |         unsigned int total_frames = 1;
 | 
|---|
| [ee23a8d] | 28 |         if (1 < argc) {
 | 
|---|
| [ea593a3] | 29 |                 times = strtol(argv[1], 0p, 10);
 | 
|---|
 | 30 |         }
 | 
|---|
| [ee23a8d] | 31 |         if (2 < argc) {
 | 
|---|
| [ea593a3] | 32 |                 total_frames = strtol(argv[2], 0p, 10);
 | 
|---|
 | 33 |         }
 | 
|---|
 | 34 | 
 | 
|---|
| [ee23a8d] | 35 |         Time start_time = timeHiRes();
 | 
|---|
| [ea593a3] | 36 |         for (int count = 0 ; count < times ; ++count) {
 | 
|---|
 | 37 |                 try {
 | 
|---|
 | 38 |                         unwind_other(total_frames);
 | 
|---|
 | 39 |                 } catchResume (empty_exception *) {
 | 
|---|
| [54651005] | 40 |                         asm volatile ("# fixup block (base)");
 | 
|---|
| [ea593a3] | 41 |                 }
 | 
|---|
 | 42 |         }
 | 
|---|
| [ee23a8d] | 43 |         Time end_time = timeHiRes();
 | 
|---|
 | 44 |         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
 | 
|---|
| [ea593a3] | 45 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.