Changeset aeb31b1


Ignore:
Timestamp:
Dec 3, 2020, 3:33:18 PM (11 months ago)
Author:
Colby Alexander Parsons <caparsons@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
9082e0f, cad1df1
Parents:
a78c3ff (diff), 0f88a225 (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:
5 added
14 edited
10 moved

Legend:

Unmodified
Added
Removed
  • example/io/simple/server.cfa

    ra78c3ff raeb31b1  
    1313#include <time.hfa>
    1414#include <thread.hfa>
     15#include <concurrency/iofwd.hfa>
    1516
    1617//----------
     
    2122}
    2223
    23 void message( Printer & mutex, char * msg, size_t len ) {
    24         fprintf(stderr, "'%.*s'", len, msg);
     24void message( Printer & mutex, char * _msg, size_t len ) {
     25        fprintf(stderr, "'%.*s'", len, _msg);
    2526}
    2627
     
    2930}
    3031
    31 void error( Printer & mutex, const char * msg, int error) {
    32         fprintf(stderr, "%s - %s\n", msg, strerror(error));
     32void error( Printer & mutex, const char * _msg, int error) {
     33        fprintf(stderr, "%s - %s\n", _msg, strerror(error));
    3334}
    3435
     
    4950        }
    5051}
    51 
    52 //----------
    53 extern ssize_t cfa_recvmsg(int sockfd, struct msghdr *msg, int flags);
    54 extern int cfa_accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags);
    55 extern int cfa_close(int fd);
    5652
    5753//----------
     
    8884        struct sockaddr_in cli_addr;
    8985        __socklen_t clilen = sizeof(cli_addr);
    90         int newsock = cfa_accept4(sock, (struct sockaddr *) &cli_addr, &clilen, 0);
     86        int newsock = cfa_accept4(sock, (struct sockaddr *) &cli_addr, &clilen, 0, 0, -1`s, 0p, 0p);
    9187        if (newsock < 0) {
    9288                error( printer, "accept", -newsock);
     
    9793
    9894        while(1) {
    99                 int res = cfa_recvmsg(newsock, &msg, 0);
     95                int res = cfa_recvmsg(newsock, &msg, 0, 0, -1`s, 0p, 0p);
    10096                if(res == 0) break;
    10197                if(res < 0) {
     
    107103        }
    108104
    109         ret = cfa_close(newsock);
     105        ret = cfa_close(newsock, 0, -1`s, 0p, 0p);
    110106      if(ret < 0) {
    111107            error( printer, "close new", -ret);
     
    113109      }
    114110
    115         ret = cfa_close(sock);
     111        ret = cfa_close(sock, 0, -1`s, 0p, 0p);
    116112      if(ret < 0) {
    117113            error( printer, "close old", -ret);
  • libcfa/src/concurrency/io.cfa

    ra78c3ff raeb31b1  
    160160        static inline void process(struct io_uring_cqe & cqe ) {
    161161                struct io_future_t * future = (struct io_future_t *)(uintptr_t)cqe.user_data;
    162                 __cfadbg_print_safe( io, "Kernel I/O : Syscall completed : cqe %p, result %d for %p\n", future, cqe.res, data->thrd );
     162                __cfadbg_print_safe( io, "Kernel I/O : Syscall completed : cqe %p, result %d for %p\n", &cqe, cqe.res, future );
    163163
    164164                fulfil( *future, cqe.res );
     
    298298                __u32 mask = *ring.submit_q.mask;
    299299
    300                 disable_interrupts();
    301                         __u32 off = __tls_rand();
    302                 enable_interrupts( __cfaabi_dbg_ctx );
     300                __u32 off = thread_rand();
    303301
    304302                // Loop around looking for an available spot
     
    344342                __u32 ready_mask = ring.submit_q.ready_cnt - 1;
    345343
    346                 disable_interrupts();
    347                         __u32 off = __tls_rand();
    348                 enable_interrupts( __cfaabi_dbg_ctx );
     344                __u32 off = thread_rand();
    349345
    350346                __u32 picked;
  • libcfa/src/concurrency/io/call.cfa.in

    ra78c3ff raeb31b1  
    8484
    8585                /* paranoid */ verifyf( cltr->io.ctxs, "default io contexts for cluster %p are missing\\n", cltr);
    86                 return &cltr->io.ctxs[ __tls_rand() % cltr->io.cnt ];
     86                return &cltr->io.ctxs[ thread_rand() % cltr->io.cnt ];
    8787        }
    8888#endif
  • libcfa/src/concurrency/kernel.cfa

    ra78c3ff raeb31b1  
    619619        lock( kernel_abort_lock __cfaabi_dbg_ctx2 );
    620620
     621        // disable interrupts, it no longer makes sense to try to interrupt this processor
     622        disable_interrupts();
     623
    621624        // first task to abort ?
    622625        if ( kernel_abort_called ) {                    // not first task to abort ?
  • libcfa/src/concurrency/kernel/fwd.hfa

    ra78c3ff raeb31b1  
    132132                }
    133133
     134                extern uint64_t thread_rand();
     135
    134136                //-----------------------------------------------------------------------
    135137                // Statics call at the end of each thread to register statistics
  • libcfa/src/concurrency/thread.cfa

    ra78c3ff raeb31b1  
    162162}
    163163
     164uint64_t thread_rand() {
     165        disable_interrupts();
     166        uint64_t ret = __tls_rand();
     167        enable_interrupts( __cfaabi_dbg_ctx );
     168        return ret;
     169}
     170
    164171// Local Variables: //
    165172// mode: c //
  • libcfa/src/interpose.cfa

    ra78c3ff raeb31b1  
    220220}
    221221
     222static volatile int __abort_stage = 0;
     223
    222224// Cannot forward va_list.
    223225void __abort( bool signalAbort, const char fmt[], va_list args ) {
    224         void * kernel_data = kernel_abort();                            // must be done here to lock down kernel
    225         int len;
    226 
    227         signal( SIGABRT, SIG_DFL );                                                     // prevent final "real" abort from recursing to handler
    228 
    229         len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
    230         __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    231 
    232         assert( fmt );
    233         len = vsnprintf( abort_text, abort_text_size, fmt, args );
    234         __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    235 
    236         if ( fmt[strlen( fmt ) - 1] != '\n' ) {                         // add optional newline if missing at the end of the format text
    237                 __cfaabi_bits_write( STDERR_FILENO, "\n", 1 );
    238         } // if
    239         kernel_abort_msg( kernel_data, abort_text, abort_text_size );
    240 
    241         __cfaabi_backtrace( signalAbort ? 4 : 2 );
    242 
    243         __cabi_libc.abort();                                                            // print stack trace in handler
     226        int stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
     227
     228        // First stage: stop the cforall kernel and print
     229        if(stage == 1) {
     230                // increment stage
     231                stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
     232
     233                // must be done here to lock down kernel
     234                void * kernel_data = kernel_abort();
     235                int len;
     236
     237                signal( SIGABRT, SIG_DFL );                                                     // prevent final "real" abort from recursing to handler
     238
     239                len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
     240                __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     241
     242                assert( fmt );
     243                len = vsnprintf( abort_text, abort_text_size, fmt, args );
     244                __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     245
     246                // add optional newline if missing at the end of the format text
     247                if ( fmt[strlen( fmt ) - 1] != '\n' ) {
     248                        __cfaabi_bits_write( STDERR_FILENO, "\n", 1 );
     249                } // if
     250                kernel_abort_msg( kernel_data, abort_text, abort_text_size );
     251        }
     252
     253        // Second stage: print the backtrace
     254        if(stage == 2) {
     255                // increment stage
     256                stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
     257
     258                // print stack trace in handler
     259                __cfaabi_backtrace( signalAbort ? 4 : 2 );
     260        }
     261
     262        do {
     263                // Finally call abort
     264                __cabi_libc.abort();
     265
     266                // Loop so that we never return
     267        } while(true);
    244268}
    245269
  • src/ResolvExpr/AlternativeFinder.cc

    ra78c3ff raeb31b1  
    131131
    132132        void printAlts( const AltList &list, std::ostream &os, unsigned int indentAmt ) {
    133                 Indenter indent = { indentAmt };
    134 
    135                 std::vector<int> idx;
    136                 idx.reserve(list.size());
    137                 for(int i = 0; i < list.size(); i++) { idx.push_back(i); }
    138 
    139                 std::sort(idx.begin(), idx.end(), [&list](int lhs_idx, int rhs_idx) -> bool {
    140                         const auto & lhs = list.at(lhs_idx);
    141                         const auto & rhs = list.at(rhs_idx);
    142                         if(lhs.expr->location.startsBefore(rhs.expr->location)) return true;
    143                         if(rhs.expr->location.startsBefore(lhs.expr->location)) return false;
    144 
    145                         if(lhs.env.size() < rhs.env.size()) return true;
    146                         if(lhs.env.size() > rhs.env.size()) return false;
    147 
    148                         if(lhs.openVars.size() < rhs.openVars.size()) return true;
    149                         if(lhs.openVars.size() > rhs.openVars.size()) return false;
    150 
    151                         if(lhs.need.size() < rhs.need.size()) return true;
    152                         if(lhs.need.size() > rhs.need.size()) return false;
    153 
    154                         return false;
    155                 });
    156 
    157                 for ( AltList::const_iterator i = list.begin(); i != list.end(); ++i ) {
    158                         i->print( os, indent );
    159                         os << std::endl;
     133                std::vector<std::string> sorted;
     134                sorted.reserve(list.size());
     135                for(const auto & c : list) {
     136                        std::stringstream ss;
     137                        c.print( ss, indentAmt );
     138                        sorted.push_back(ss.str());
     139                }
     140
     141                std::sort(sorted.begin(), sorted.end());
     142
     143                for ( const auto & s : sorted ) {
     144                        os << s << std::endl;
    160145                }
    161146        }
  • src/ResolvExpr/Candidate.cpp

    ra78c3ff raeb31b1  
    4141
    4242void print( std::ostream & os, const CandidateList & cands, Indenter indent ) {
    43         for ( const CandidateRef & cand : cands ) {
    44                 print( os, *cand, indent );
    45                 os << std::endl;
     43        std::vector<std::string> sorted;
     44        sorted.reserve(cands.size());
     45        for(const auto & c : cands) {
     46                std::stringstream ss;
     47                print( ss, *c, indent );
     48                sorted.push_back(ss.str());
     49        }
     50
     51        std::sort(sorted.begin(), sorted.end());
     52
     53        for ( const auto & s : sorted ) {
     54                os << s << std::endl;
    4655        }
    4756}
  • tests/.expect/castError.oast.txt

    ra78c3ff raeb31b1  
    33  Name: f
    44... to:
     5  char
     6with resolved type:
    57  char Alternatives are:
    68Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    7       Variable Expression: f: function
    8         accepting unspecified arguments
    9       ... returning nothing
    10 
     9      Variable Expression: f: double
     10      with resolved type:
     11        double
    1112    ... to:
     13      char
     14    with resolved type:
    1215      char
    1316  (types:
     
    1720
    1821Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    19       Variable Expression: f: double
     22      Variable Expression: f: function
     23        accepting unspecified arguments
     24      ... returning nothing
     25
     26      with resolved type:
     27        pointer to function
     28          accepting unspecified arguments
     29        ... returning nothing
     30
    2031    ... to:
     32      char
     33    with resolved type:
    2134      char
    2235  (types:
     
    2740Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    2841      Variable Expression: f: signed int
     42      with resolved type:
     43        signed int
    2944    ... to:
     45      char
     46    with resolved type:
    3047      char
    3148  (types:
     
    3956  Comma Expression:
    4057    constant expression (3 3: signed int)
     58    with resolved type:
     59      signed int
    4160    Name: v
    42 ... to: nothing Alternatives are:
     61... to: nothing
     62with resolved type:
     63  void  Alternatives are:
    4364Cost ( 0, 0, 2, 0, 0, 0, 0 ): Generated Cast of:
    4465      Comma Expression:
    4566        constant expression (3 3: signed int)
    46         Variable Expression: v: unsigned char
     67        with resolved type:
     68          signed int
     69        Variable Expression: v: signed short int
     70        with resolved type:
     71          signed short int
     72      with resolved type:
     73        signed short int
    4774    ... to: nothing
     75    with resolved type:
     76      void
    4877  (types:
    4978    void
     
    5483      Comma Expression:
    5584        constant expression (3 3: signed int)
    56         Variable Expression: v: signed short int
     85        with resolved type:
     86          signed int
     87        Variable Expression: v: unsigned char
     88        with resolved type:
     89          unsigned char
     90      with resolved type:
     91        unsigned char
    5792    ... to: nothing
     93    with resolved type:
     94      void
    5895  (types:
    5996    void
     
    69106    char
    70107
     108with resolved type:
     109  instance of struct S with body 1
     110  ... with parameters
     111    char
     112
  • tests/errors/.expect/completeType.nast.x64.txt

    ra78c3ff raeb31b1  
    99... with resolved type:
    1010  void Alternatives are:
     11Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
     12      Application of
     13        Variable Expression: *?: forall
     14          DT: data type
     15          function
     16        ... with parameters
     17          pointer to instance of type DT (not function type)
     18        ... returning
     19          reference to instance of type DT (not function type)
     20
     21        ... with resolved type:
     22          pointer to forall
     23            [unbound]:data type
     24            function
     25          ... with parameters
     26            pointer to instance of type [unbound] (not function type)
     27          ... returning
     28            reference to instance of type [unbound] (not function type)
     29
     30        ... to arguments
     31        Variable Expression: x: pointer to instance of struct A without body
     32        ... with resolved type:
     33          pointer to instance of struct A without body
     34
     35      ... with resolved type:
     36        reference to instance of struct A without body
     37    ... to: nothing
     38    ... with resolved type:
     39      void
     40  (types:
     41    void
     42  )
     43  Environment:([unbound]) -> instance of struct A without body (no widening)
     44
     45
    1146Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
    1247      Application of
     
    4277  )
    4378  Environment:([unbound]) -> instance of struct B with body (no widening)
    44 
    45 
    46 Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
    47       Application of
    48         Variable Expression: *?: forall
    49           DT: data type
    50           function
    51         ... with parameters
    52           pointer to instance of type DT (not function type)
    53         ... returning
    54           reference to instance of type DT (not function type)
    55 
    56         ... with resolved type:
    57           pointer to forall
    58             [unbound]:data type
    59             function
    60           ... with parameters
    61             pointer to instance of type [unbound] (not function type)
    62           ... returning
    63             reference to instance of type [unbound] (not function type)
    64 
    65         ... to arguments
    66         Variable Expression: x: pointer to instance of struct A without body
    67         ... with resolved type:
    68           pointer to instance of struct A without body
    69 
    70       ... with resolved type:
    71         reference to instance of struct A without body
    72     ... to: nothing
    73     ... with resolved type:
    74       void
    75   (types:
    76     void
    77   )
    78   Environment:([unbound]) -> instance of struct A without body (no widening)
    7979
    8080
  • tests/errors/.expect/completeType.oast.arm64.txt

    ra78c3ff raeb31b1  
    66    Name: x
    77
    8 ... to: nothing Alternatives are:
     8... to: nothing
     9with resolved type:
     10  void  Alternatives are:
    911Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
    1012      Application of
     
    2022
    2123
     24        with resolved type:
     25          pointer to forall
     26            [unbound]:data type
     27            function
     28          ... with parameters
     29            intrinsic pointer to instance of type [unbound] (not function type)
     30          ... returning
     31            _retval__operator_deref: reference to instance of type [unbound] (not function type)
     32            ... with attributes:
     33              Attribute with name: unused
     34
     35
    2236      ... to arguments
    2337        Variable Expression: x: pointer to instance of struct A with body 0
    24 
     38        with resolved type:
     39          pointer to instance of struct A with body 0
     40
     41      with resolved type:
     42        reference to instance of struct A with body 0
    2543    ... to: nothing
     44    with resolved type:
     45      void
    2646  (types:
    2747    void
    2848  )
    29   Environment: -> instance of struct A with body 0 (no widening)
     49  Environment:([unbound]) -> instance of struct A with body 0 (no widening)
    3050
    3151
     
    4363
    4464
     65        with resolved type:
     66          pointer to forall
     67            [unbound]:data type
     68            function
     69          ... with parameters
     70            intrinsic pointer to instance of type [unbound] (not function type)
     71          ... returning
     72            _retval__operator_deref: reference to instance of type [unbound] (not function type)
     73            ... with attributes:
     74              Attribute with name: unused
     75
     76
    4577      ... to arguments
    4678        Variable Expression: x: pointer to instance of struct B with body 1
    47 
     79        with resolved type:
     80          pointer to instance of struct B with body 1
     81
     82      with resolved type:
     83        reference to instance of struct B with body 1
    4884    ... to: nothing
     85    with resolved type:
     86      void
    4987  (types:
    5088    void
    5189  )
    52   Environment: -> instance of struct B with body 1 (no widening)
     90  Environment:([unbound]) -> instance of struct B with body 1 (no widening)
    5391
    5492
     
    121159            ... returning nothing
    122160
     161            with resolved type:
     162              pointer to forall
     163                [unbound]:sized data type
     164                ... with assertions
     165                  ?=?: pointer to function
     166                  ... with parameters
     167                    reference to instance of type [unbound] (not function type)
     168                    instance of type [unbound] (not function type)
     169                  ... returning
     170                    _retval__operator_assign: instance of type [unbound] (not function type)
     171                    ... with attributes:
     172                      Attribute with name: unused
     173
     174
     175                  ?{}: pointer to function
     176                  ... with parameters
     177                    reference to instance of type [unbound] (not function type)
     178                  ... returning nothing
     179
     180                  ?{}: pointer to function
     181                  ... with parameters
     182                    reference to instance of type [unbound] (not function type)
     183                    instance of type [unbound] (not function type)
     184                  ... returning nothing
     185
     186                  ^?{}: pointer to function
     187                  ... with parameters
     188                    reference to instance of type [unbound] (not function type)
     189                  ... returning nothing
     190
     191
     192                function
     193              ... with parameters
     194                pointer to instance of type [unbound] (not function type)
     195              ... returning nothing
     196
    123197          ... to arguments
    124198            Variable Expression: z: pointer to instance of type T (not function type)
    125 
     199            with resolved type:
     200              pointer to instance of type T (not function type)
     201
     202          with resolved type:
     203            void
    126204        (types:
    127205          void
    128206        )
    129         Environment: -> instance of type T (not function type) (no widening)
     207        Environment:([unbound]) -> instance of type T (not function type) (no widening)
    130208
    131209      Could not satisfy assertion:
    132210?=?: pointer to function
    133211        ... with parameters
    134           reference to instance of type _110_0_T (not function type)
    135           instance of type _110_0_T (not function type)
     212          reference to instance of type [unbound] (not function type)
     213          instance of type [unbound] (not function type)
    136214        ... returning
    137           _retval__operator_assign: instance of type _110_0_T (not function type)
     215          _retval__operator_assign: instance of type [unbound] (not function type)
    138216          ... with attributes:
    139217            Attribute with name: unused
  • tests/meta/.expect/archVast.nast.arm64.txt

    ra78c3ff raeb31b1  
    33  Name: FA64
    44... to:
     5  char
     6... with resolved type:
    57  char Alternatives are:
    68Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    79      Variable Expression: FA64: signed int
     10      ... with resolved type:
     11        signed int
    812    ... to:
     13      char
     14    ... with resolved type:
    915      char
    1016  (types:
     
    1824      ... returning nothing
    1925
     26      ... with resolved type:
     27        pointer to function
     28          accepting unspecified arguments
     29        ... returning nothing
     30
    2031    ... to:
     32      char
     33    ... with resolved type:
    2134      char
    2235  (types:
     
    2740Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    2841      Variable Expression: FA64: double
     42      ... with resolved type:
     43        double
    2944    ... to:
     45      char
     46    ... with resolved type:
    3047      char
    3148  (types:
  • tests/meta/.expect/archVast.nast.x64.txt

    ra78c3ff raeb31b1  
    77  char Alternatives are:
    88Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    9       Variable Expression: FX64: signed int
     9      Variable Expression: FX64: double
    1010      ... with resolved type:
    11         signed int
     11        double
    1212    ... to:
    1313      char
     
    3939
    4040Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    41       Variable Expression: FX64: double
     41      Variable Expression: FX64: signed int
    4242      ... with resolved type:
    43         double
     43        signed int
    4444    ... to:
    4545      char
  • tests/meta/.expect/archVast.oast.arm64.txt

    ra78c3ff raeb31b1  
    33  Name: FA64
    44... to:
     5  char
     6with resolved type:
    57  char Alternatives are:
    68Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
     
    911      ... returning nothing
    1012
     13      with resolved type:
     14        pointer to function
     15          accepting unspecified arguments
     16        ... returning nothing
     17
    1118    ... to:
     19      char
     20    with resolved type:
    1221      char
    1322  (types:
     
    1827Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    1928      Variable Expression: FA64: double
     29      with resolved type:
     30        double
    2031    ... to:
     32      char
     33    with resolved type:
    2134      char
    2235  (types:
     
    2740Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    2841      Variable Expression: FA64: signed int
     42      with resolved type:
     43        signed int
    2944    ... to:
     45      char
     46    with resolved type:
    3047      char
    3148  (types:
  • tests/meta/.expect/archVast.oast.x64.txt

    ra78c3ff raeb31b1  
    66with resolved type:
    77  char Alternatives are:
     8Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
     9      Variable Expression: FX64: double
     10      with resolved type:
     11        double
     12    ... to:
     13      char
     14    with resolved type:
     15      char
     16  (types:
     17    char
     18  )
     19  Environment:
     20
    821Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    922      Variable Expression: FX64: function
     
    1629        ... returning nothing
    1730
    18     ... to:
    19       char
    20     with resolved type:
    21       char
    22   (types:
    23     char
    24   )
    25   Environment:
    26 
    27 Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    28       Variable Expression: FX64: double
    29       with resolved type:
    30         double
    3131    ... to:
    3232      char
Note: See TracChangeset for help on using the changeset viewer.