ADT
        ast-experimental
        enum
        forall-pointer-decay
        pthread-emulation
        qualifiedEnum
      
      
        
          | 
            Last change
 on this file since a5d1fe7 was             678f259, checked in by Andrew Beach <ajbeach@…>, 4 years ago           | 
        
        
          | 
             
Some clean-up in the exception benchmark directory. Mostly just shortening names. 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            1.2 KB
           | 
        
      
      
| Line |   | 
|---|
| 1 | // Resume Across Other Handler
 | 
|---|
| 2 | #include <clock.hfa>
 | 
|---|
| 3 | #include <exception.hfa>
 | 
|---|
| 4 | #include <fstream.hfa>
 | 
|---|
| 5 | #include <stdlib.hfa>                                                                   // strto
 | 
|---|
| 6 | 
 | 
|---|
| 7 | exception fixup_exception {
 | 
|---|
| 8 |         int & fixup;
 | 
|---|
| 9 | };
 | 
|---|
| 10 | vtable(fixup_exception) fixup_vt;
 | 
|---|
| 11 | exception not_raised_exception {
 | 
|---|
| 12 |         int & fixup;
 | 
|---|
| 13 | };
 | 
|---|
| 14 | 
 | 
|---|
| 15 | unsigned int frames;                                                                    // use global because of gcc thunk problem
 | 
|---|
| 16 | 
 | 
|---|
| 17 | void nounwind_other(unsigned int dummy) {
 | 
|---|
| 18 |         if (frames) {
 | 
|---|
| 19 |                 frames -= 1;
 | 
|---|
| 20 |                 try {
 | 
|---|
| 21 |                         nounwind_other(42);
 | 
|---|
| 22 |                 } catchResume (not_raised_exception * ex) {
 | 
|---|
| 23 |                         ex->fixup = frames + 42;                                        // use local scope => lexical link
 | 
|---|
| 24 |                 }
 | 
|---|
| 25 |         } else {
 | 
|---|
| 26 |                 int fixup = dummy;
 | 
|---|
| 27 |                 throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup
 | 
|---|
| 28 |         }
 | 
|---|
| 29 | }
 | 
|---|
| 30 | 
 | 
|---|
| 31 | int main(int argc, char * argv[]) {
 | 
|---|
| 32 |         unsigned int times = 1;
 | 
|---|
| 33 |         unsigned int total_frames = 1;
 | 
|---|
| 34 |         if (1 < argc) {
 | 
|---|
| 35 |                 times = strto(argv[1], 0p, 10);
 | 
|---|
| 36 |         }
 | 
|---|
| 37 |         if (2 < argc) {
 | 
|---|
| 38 |                 total_frames = strto(argv[2], 0p, 10);
 | 
|---|
| 39 |         }
 | 
|---|
| 40 |         frames = total_frames;
 | 
|---|
| 41 | 
 | 
|---|
| 42 |         Time start_time = timeHiRes();
 | 
|---|
| 43 |         for (int count = 0 ; count < times ; ++count) {
 | 
|---|
| 44 |                 try {
 | 
|---|
| 45 |                         nounwind_other(42);
 | 
|---|
| 46 |                 } catchResume (fixup_exception * ex) {
 | 
|---|
| 47 |                         ex->fixup = total_frames + 42;
 | 
|---|
| 48 |                 }
 | 
|---|
| 49 |         }
 | 
|---|
| 50 |         Time end_time = timeHiRes();
 | 
|---|
| 51 |         sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
 | 
|---|
| 52 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.