Changeset 52ffa30


Ignore:
Timestamp:
Jan 11, 2019, 3:15:51 PM (3 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
276a55b2, 690166d, 95b8aa7
Parents:
d97c3a4 (diff), 7bd3bf2 (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

Files:
7 edited
1 moved

Legend:

Unmodified
Added
Removed
  • automake/cfa.m4

    rd97c3a4 r52ffa30  
    7373                "arm"        ) cannon_arch_name="arm";;
    7474                "ARM"        ) cannon_arch_name="arm";;
     75                "armv7l"     ) cannon_arch_name="arm";;
    7576                *)
    7677                >&2 echo "Unkown architecture " $arch_name;
  • configure

    rd97c3a4 r52ffa30  
    35503550                "arm"        ) cannon_arch_name="arm";;
    35513551                "ARM"        ) cannon_arch_name="arm";;
     3552                "armv7l"     ) cannon_arch_name="arm";;
    35523553                *)
    35533554                >&2 echo "Unkown architecture " $arch_name;
     
    35903591                "arm"        ) cannon_arch_name="arm";;
    35913592                "ARM"        ) cannon_arch_name="arm";;
     3593                "armv7l"     ) cannon_arch_name="arm";;
    35923594                *)
    35933595                >&2 echo "Unkown architecture " $arch_name;
  • libcfa/src/concurrency/coroutine.cfa

    rd97c3a4 r52ffa30  
    2222#include <string.h>
    2323#include <unistd.h>
     24// use this define to make unwind.h play nice, definetely a hack
     25#define HIDE_EXPORTS
     26#include <unwind.h>
     27#undef HIDE_EXPORTS
    2428#include <sys/mman.h>
    2529}
     
    2933#define __CFA_INVOKE_PRIVATE__
    3034#include "invoke.h"
     35
     36extern "C" {
     37      void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage) __attribute__ ((__noreturn__));
     38      static void _CtxCoroutine_UnwindCleanup(_Unwind_Reason_Code, struct _Unwind_Exception *) __attribute__ ((__noreturn__));
     39      static void _CtxCoroutine_UnwindCleanup(_Unwind_Reason_Code, struct _Unwind_Exception *) {
     40            abort();
     41      }
     42}
    3143
    3244//-----------------------------------------------------------------------------
     
    6779      starter = NULL;
    6880      last = NULL;
    69 }
    70 
    71 void ^?{}(coroutine_desc& this) {}
     81      cancellation = NULL;
     82}
     83
     84void ^?{}(coroutine_desc& this) {
     85      if(this.state != Halted) {
     86            coroutine_desc * src = TL_GET( this_coroutine );
     87            coroutine_desc * dst = &this;
     88
     89            struct _Unwind_Exception storage;
     90            storage.exception_class = -1;
     91            storage.exception_cleanup = _CtxCoroutine_UnwindCleanup;
     92            this.cancellation = &storage;
     93            this.last = src;
     94
     95              // not resuming self ?
     96              if ( src == dst ) {
     97                      abort( "Attempt by coroutine %.256s (%p) to terminate itself.\n", src->name, src );
     98            }
     99
     100              CoroutineCtxSwitch( src, dst );
     101      }
     102}
    72103
    73104// Part of the Public API
     
    105136      // Safety note : This could cause some false positives due to preemption
    106137      verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );
     138
     139      if( unlikely(src->cancellation != NULL) ) {
     140            _CtxCoroutine_Unwind(src->cancellation);
     141      }
    107142} //ctxSwitchDirect
    108143
     
    162197      }
    163198
    164       void __leave_coroutine(void) {
     199      void __leave_coroutine() {
    165200            coroutine_desc * src = TL_GET( this_coroutine ); // optimization
    166 
    167             assertf( src->starter != 0,
     201            coroutine_desc * starter = src->cancellation != 0 ? src->last : src->starter;
     202
     203            src->state = Halted;
     204
     205            assertf( starter != 0,
    168206                  "Attempt to suspend/leave coroutine \"%.256s\" (%p) that has never been resumed.\n"
    169207                  "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.",
    170208                  src->name, src );
    171             assertf( src->starter->state != Halted,
     209            assertf( starter->state != Halted,
    172210                  "Attempt by coroutine \"%.256s\" (%p) to suspend/leave back to terminated coroutine \"%.256s\" (%p).\n"
    173211                  "Possible cause is terminated coroutine's main routine has already returned.",
    174                   src->name, src, src->starter->name, src->starter );
    175 
    176             CoroutineCtxSwitch( src, src->starter );
     212                  src->name, src, starter->name, starter );
     213
     214            CoroutineCtxSwitch( src, starter );
    177215      }
    178216}
  • libcfa/src/concurrency/invoke.c

    rd97c3a4 r52ffa30  
    1717#include <stdlib.h>
    1818#include <stdio.h>
     19#include <unwind.h>
    1920
    2021#include "invoke.h"
     
    5051        main( this );
    5152
    52         cor->state = Halted;
    53 
    5453        //Final suspend, should never return
    5554        __leave_coroutine();
    5655        __cabi_abort( "Resumed dead coroutine" );
     56}
     57
     58static _Unwind_Reason_Code _CtxCoroutine_UnwindStop(
     59        __attribute((__unused__)) int version,
     60        _Unwind_Action actions,
     61        __attribute((__unused__)) _Unwind_Exception_Class exceptionClass,
     62        __attribute((__unused__)) struct _Unwind_Exception * unwind_exception,
     63        __attribute((__unused__)) struct _Unwind_Context * context,
     64        __attribute((__unused__)) void * param
     65) {
     66        if( actions & _UA_END_OF_STACK  ) {
     67                // We finished unwinding the coroutine,
     68                // leave it
     69                __leave_coroutine();
     70                __cabi_abort( "Resumed dead coroutine" );
     71        }
     72        if( actions & _UA_CLEANUP_PHASE ) return _URC_NO_REASON;
     73
     74        return _URC_FATAL_PHASE2_ERROR;
     75}
     76
     77void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage) __attribute__ ((__noreturn__));
     78void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage) {
     79        _Unwind_Reason_Code ret = _Unwind_ForcedUnwind( storage, _CtxCoroutine_UnwindStop, NULL );
     80        printf("UNWIND ERROR %d after force unwind\n", ret);
     81        abort();
    5782}
    5883
  • libcfa/src/concurrency/invoke.h

    rd97c3a4 r52ffa30  
    8080
    8181        struct coroutine_desc {
    82                 struct coStack_t stack;                                                 // stack information of the coroutine
    83                 const char * name;                                                              // textual name for coroutine/task, initialized by uC++ generated code
    84                 int errno_;                                                                             // copy of global UNIX variable errno
    85                 enum coroutine_state state;                                             // current execution status for coroutine
    86                 struct coroutine_desc * starter;                                // first coroutine to resume this one
    87                 struct coroutine_desc * last;                                   // last coroutine to resume this one
    88         };
    89 
     82                // stack information of the coroutine
     83                struct coStack_t stack;
     84
     85                // textual name for coroutine/task, initialized by uC++ generated code
     86                const char * name;
     87
     88                // copy of global UNIX variable errno
     89                int errno_;
     90
     91                // current execution status for coroutine
     92                enum coroutine_state state;
     93                // first coroutine to resume this one
     94                struct coroutine_desc * starter;
     95
     96                // last coroutine to resume this one
     97                struct coroutine_desc * last;
     98
     99                // If non-null stack must be unwound with this exception
     100                struct _Unwind_Exception * cancellation;
     101
     102        };
     103
     104        // struct which calls the monitor is accepting
    90105        struct __waitfor_mask_t {
    91106                // the index of the accepted function, -1 if none
  • tests/coroutine/pingpong.cfa

    rd97c3a4 r52ffa30  
    2424
    2525void ?{}( PingPong & this, const char * name, unsigned int N, PingPong & part ) {
     26        (this.__cor){name};
    2627        this.name = name;
    2728        this.N = N;
  • tests/test.py

    rd97c3a4 r52ffa30  
    1919
    2020        def matchTest(path):
    21                 match = re.search("%s\/([\w\/\-_]*).expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt" % settings.SRCDIR, path)
     21                match = re.search("^%s\/([\w\/\-_]*).expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt$" % settings.SRCDIR, path)
    2222                if match :
    2323                        test = Test()
Note: See TracChangeset for help on using the changeset viewer.