Changes in / [f37147b:d0ffed1]


Ignore:
Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/CodeTools/DeclStats.cc

    rf37147b rd0ffed1  
    6363                        std::map<unsigned, unsigned> p_poly;   ///< Count of decls with each percentage of polymorphic elements
    6464                        VectorMap<unsigned> n_types;           ///< Count of decls with each number of distinct types in the pack
    65                         /// Count of decls with each percentage of new types in lists.
    66                         /// Types used in the parameter list that recur in the return list are not considered to be new.
    67                         std::map<unsigned, unsigned> p_new;
    6865
    6966                        ArgPackStats& operator+= (const ArgPackStats& o) {
     
    7471                                sum(p_poly, o.p_poly);
    7572                                sum(n_types, o.n_types);
    76                                 sum(p_new, o.p_new);
    7773                               
    7874                                return *this;
     
    9086                        /// Count of uses of each non-basic type
    9187                        std::unordered_map<std::string, unsigned> compound_type_names;
    92                         /// Count of decls using each basic type
    93                         std::unordered_map<std::string, unsigned> basic_type_decls;
    94                         /// Count of decls using each compound type
    95                         std::unordered_map<std::string, unsigned> compound_type_decls;
    9688                        /// Stats for the parameter list
    9789                        ArgPackStats params;
     
    10698                        ArgPackStats assn_returns;
    10799                       
    108                         Stats() : n_decls(0), n_type_params(), by_name(), basic_type_names(), compound_type_names(), basic_type_decls(), compound_type_decls(), params(), returns(), n_assns(), assn_params(), assn_returns() {}
     100                        Stats() : n_decls(0), n_type_params(), by_name(), basic_type_names(), compound_type_names(), params(), returns(), n_assns(), assn_params(), assn_returns() {}
    109101
    110102                public:
     
    115107                                sum( basic_type_names, o.basic_type_names );
    116108                                sum( compound_type_names, o.compound_type_names );
    117                                 sum( basic_type_decls, o.basic_type_decls );
    118                                 sum( compound_type_decls, o.compound_type_decls );
    119109                                sum( params, o.params );
    120110                                sum( returns, o.returns );
     
    130120                std::unordered_set<std::string> seen_names;  ///< Stores manglenames already seen to avoid double-counting
    131121                Stats total;
    132                 /// Count of expressions with (depth, fanout)
    133                 std::map<std::pair<unsigned, unsigned>, unsigned> exprs_by_fanout_at_depth;
    134122
    135123                /// Update arg pack stats based on a declaration list
    136                 void analyze( Stats& stats, std::unordered_set<std::string>& seen, ArgPackStats& pstats, std::list<DeclarationWithType*>& decls ) {
     124                void analyze( Stats& stats, ArgPackStats& pstats, std::list<DeclarationWithType*>& decls ) {
    137125                        std::unordered_set<std::string> types;
    138                         unsigned n = 0;        ///< number of args/returns
    139                         unsigned n_basic = 0;  ///< number of basic types
    140                         unsigned n_poly = 0;   ///< number of polymorphic types
    141                         unsigned n_new = 0;    ///< number of new types
     126                        unsigned n = 0;
     127                        unsigned n_basic = 0;
     128                        unsigned n_poly = 0;
    142129                        for ( auto decl : decls ) {
    143130                                Type* dt = decl->get_type();
     
    148135                                dt->print( ss );
    149136                                types.insert( ss.str() );
    150                                 bool this_new = seen.insert( ss.str() ).second;
    151                                 if ( this_new ) { ++n_new; }
    152137
    153138                                if ( dynamic_cast<BasicType*>( dt ) ) {
    154139                                        ++n_basic;
    155140                                        ++stats.basic_type_names[ ss.str() ];
    156                                         if ( this_new ) {
    157                                                 ++stats.basic_type_decls[ ss.str() ];
    158                                         }
    159141                                } else if ( GenPoly::hasPolyBase( dt ) ) {
    160142                                        ++n_poly;
    161143                                } else {
    162144                                        ++stats.compound_type_names[ ss.str() ];
    163                                         if ( this_new ) {
    164                                                 ++stats.compound_type_decls[ ss.str() ];
    165                                         }
    166145                                }
    167146                        }
     
    172151                                ++pstats.p_basic[ n_basic*100/n ];
    173152                                ++pstats.p_poly[ n_poly*100/n ];
    174                                 ++pstats.p_new[ n_new*100/n ];
    175153                        }
    176154                        ++pstats.n_types.at( types.size() );
     
    178156               
    179157                void analyzeFunc( FunctionType* fnTy, Stats& stats, ArgPackStats& params, ArgPackStats& returns ) {
    180                         std::unordered_set<std::string> seen;
    181                         analyze( stats, seen, params, fnTy->get_parameters() );
    182                         analyze( stats, seen, returns, fnTy->get_returnVals() );
    183                 }
    184 
    185                 void analyzeExpr( UntypedExpr *expr, unsigned depth ) {
    186                         auto& args = expr->get_args();
    187                         unsigned fanout = args.size();
    188                         ++exprs_by_fanout_at_depth[ std::make_pair(depth, fanout) ];
    189                         for ( Expression* arg : args ) {
    190                                 if ( UntypedExpr *uearg = dynamic_cast<UntypedExpr*>(arg) ) {
    191                                         analyzeExpr( uearg, depth+1 );
    192                                 }
    193                         }
     158                        analyze( stats, params, fnTy->get_parameters() );
     159                        analyze( stats, returns, fnTy->get_returnVals() );
    194160                }
    195161
     
    230196                }
    231197
    232                 virtual void visit( UntypedExpr *expr ) {
    233                         analyzeExpr( expr, 0 );
    234                 }
    235 
    236198        private:
    237199                template<typename F>
     
    313275                        printAllMap("%_poly_" + name, [&extract](const Stats& stats) { return extract(stats).p_poly; });
    314276                        printAllMap("n_distinct_types_" + name, [&extract](const Stats& stats) { return extract(stats).n_types; });
    315                         printAllMap("%_new_types_in_" + name, [&extract](const Stats& stats) { return extract(stats).p_new; });
    316                 }
    317 
    318                 void printPairMap( const std::string& name,
    319                                    const std::map<std::pair<unsigned, unsigned>, unsigned>& map ) {
    320                         for ( const auto& entry : map ) {
    321                                 const auto& key = entry.first;
    322                                 std::cout << "\"" << name << "\"," << key.first << "," << key.second << ","
    323                                           << entry.second << std::endl;
    324                         }
    325277                }
    326278               
     
    339291                        printAll("basic_type_names", [](const Stats& stats) { return stats.basic_type_names.size(); });
    340292                        printAllSparseHisto("basic_type_uses", [](const Stats& stats) { return stats.basic_type_names; });
    341                         printAllSparseHisto("decls_using_basic_type", [](const Stats& stats) { return stats.basic_type_decls; });
    342293                        printAll("compound_type_names", [](const Stats& stats) { return stats.compound_type_names.size(); });
    343294                        printAllSparseHisto("compound_type_uses", [](const Stats& stats) { return stats.compound_type_names; });
    344                         printAllSparseHisto("decls_using_compound_type", [](const Stats& stats) { return stats.compound_type_decls; });
    345295                        printAllPack("params", [](const Stats& stats) { return stats.params; });
    346296                        printAllPack("returns", [](const Stats& stats) { return stats.returns; });
     
    348298                        printAllPack("assn_params", [](const Stats& stats) { return stats.assn_params; });
    349299                        printAllPack("assn_returns", [](const Stats& stats) { return stats.assn_returns; });
    350                         std::cout << std::endl;
    351 
    352                         printPairMap("exprs_by_depth+fanout", exprs_by_fanout_at_depth);
    353300                }
    354301        };
  • src/Parser/ParseNode.h

    rf37147b rd0ffed1  
    109109        ExpressionNode( const ExpressionNode &other );
    110110        virtual ~ExpressionNode() {}
    111         virtual ExpressionNode * clone() const override { return expr ? new ExpressionNode( expr->clone() ) : nullptr; }
     111        virtual ExpressionNode * clone() const { return expr ? new ExpressionNode( expr->clone() ) : nullptr; }
    112112
    113113        bool get_extension() const { return extension; }
     
    259259        DeclarationNode();
    260260        ~DeclarationNode();
    261         DeclarationNode * clone() const override;
     261        DeclarationNode * clone() const;
    262262
    263263        DeclarationNode * addQualifiers( DeclarationNode * );
  • src/libcfa/concurrency/invoke.h

    rf37147b rd0ffed1  
    6060
    6161      struct coStack_t {
    62             unsigned int size;                // size of stack
    63             void *storage;                            // pointer to stack
    64             void *limit;                              // stack grows towards stack limit
    65             void *base;                               // base of stack
    66             void *context;                            // address of cfa_context_t
    67             void *top;                                // address of top of storage
     62            unsigned int size;          // size of stack
     63            void *storage;                      // pointer to stack
     64            void *limit;                        // stack grows towards stack limit
     65            void *base;                         // base of stack
     66            void *context;                      // address of cfa_context_t
     67            void *top;                          // address of top of storage
    6868            bool userStack;     
    6969      };
     
    7373      struct coroutine {
    7474            struct coStack_t stack;
    75             const char *name;                         // textual name for coroutine/task, initialized by uC++ generated code
    76             int errno_;                               // copy of global UNIX variable errno
    77             enum coroutine_state state;       // current execution status for coroutine
    78             struct coroutine *starter;        // first coroutine to resume this one
    79             struct coroutine *last;                   // last coroutine to resume this one
     75            const char *name;                   // textual name for coroutine/task, initialized by uC++ generated code
     76            int errno_;                         // copy of global UNIX variable errno
     77            enum coroutine_state state; // current execution status for coroutine
     78            struct coroutine *starter;  // first coroutine to resume this one
     79            struct coroutine *last;             // last coroutine to resume this one
    8080      };
    8181
    8282      struct thread {
    83             struct coroutine c;                 // coroutine body used to store context
    84             struct signal_once terminated;      // indicate if execuation state is not halted
    85             struct thread * next;               // instrusive link field for threads
     83            struct coroutine c;           // coroutine body used to store context
     84            struct signal_once terminated;// indicate if execuation state is not halted
     85            struct thread * next;         // instrusive link field for threads
    8686      };
    8787
  • src/libcfa/concurrency/monitor

    rf37147b rd0ffed1  
    2121#include "invoke.h"
    2222
    23 struct __monitor_t {
     23struct monitor {
    2424        spinlock lock;
    25         thread * owner;
     25        thread * holder;
    2626        simple_thread_list entry_queue;
    27         unsigned int recursion;
    2827};
    2928
    30 static inline void ?{}(__monitor_t * this) {
    31         this->owner = 0;
    32         this->recursion = 0;
    33 }
     29void enter(monitor *);
     30void leave(monitor *);
    3431
    35 void enter(__monitor_t *);
    36 void leave(__monitor_t *);
    37 
    38 struct monitor_guard_t {
    39         __monitor_t * m;
     32struct monitor_guard {
     33        monitor * m;
    4034};
    4135
    42 static inline void ?{}( monitor_guard_t * this, __monitor_t * m ) {
     36static inline void ?{}( monitor_guard * this, monitor * m ) {
    4337        this->m = m;
    4438        enter( this->m );
    4539}
    4640
    47 static inline void ^?{}( monitor_guard_t * this ) {
     41static inline void ^?{}( monitor_guard * this ) {
    4842        leave( this->m );
    4943}
  • src/libcfa/concurrency/monitor.c

    rf37147b rd0ffed1  
    66// file "LICENCE" distributed with Cforall.
    77//
    8 // __monitor_t.c --
     8// monitor.c --
    99//
    1010// Author           : Thierry Delisle
     
    1919#include "kernel_private.h"
    2020
    21 void enter(__monitor_t * this) {
     21void enter(monitor * this) {
    2222        lock( &this->lock );
    2323        thread * thrd = this_thread();
    2424
    25         if( !this->owner ) {
    26                 //No one has the monitor, just take it
    27                 this->owner = thrd;
    28                 this->recursion = 1;
    29         }
    30         else if( this->owner == thrd) {
    31                 //We already have the monitor, just not how many times we took it
    32                 assert( this->recursion > 0 );
    33                 this->recursion += 1;
     25        if( this->holder ) {
     26                append( &this->entry_queue, thrd );
     27                ScheduleInternal( &this->lock );
     28                return;
    3429        }
    3530        else {
    36                 //Some one else has the monitor, wait in line for it
    37                 append( &this->entry_queue, thrd );
    38                 ScheduleInternal( &this->lock );
    39 
    40                 //ScheduleInternal will unlock spinlock, no need to unlock ourselves
    41                 return;
     31                this->holder = thrd;
    4232        }
    4333
     
    4535}
    4636
    47 void leave(__monitor_t * this) {
     37void leave(monitor * this) {
    4838        lock( &this->lock );
    4939
    5040        thread * thrd = this_thread();
    51         assert( thrd == this->owner );
     41        assert( thrd == this->holder );
    5242
    53         //Leaving a recursion level, decrement the counter
    54         this->recursion -= 1;
    55 
    56         //If we left the last level of recursion it means we are changing who owns the monitor
    57         thread * new_owner = 0;
    58         if( this->recursion == 0) {
    59                 //Get the next thread in the list
    60                 new_owner = this->owner = pop_head( &this->entry_queue );
    61 
    62                 //We are passing the monitor to someone else, which means recursion level is not 0
    63                 this->recursion = new_owner ? 1 : 0;
    64         }       
     43        this->holder = pop_head( &this->entry_queue );
    6544
    6645        unlock( &this->lock );
    6746
    68         //If we have a new owner, we need to wake-up the thread
    69         if( new_owner ) {
    70                 ScheduleThread( new_owner );
    71         }
     47        if( this->holder ) ScheduleThread( this->holder );
    7248}
  • src/prelude/prelude.cf

    rf37147b rd0ffed1  
    131131                !?( float _Complex ),           !?( double _Complex ),          !?( long double _Complex );
    132132
    133 forall ( dtype DT ) int !?(                DT * );
    134 forall ( dtype DT ) int !?( const          DT * );
    135 forall ( dtype DT ) int !?(       volatile DT * );
    136133forall ( dtype DT ) int !?( const volatile DT * );
    137134forall ( ftype FT ) int !?( FT * );
     
    238235           ?>?( long double, long double ),                             ?>=?( long double, long double );
    239236
    240 forall( dtype DT ) signed int ?<?(                 DT *,                DT * );
    241 forall( dtype DT ) signed int ?<?(  const          DT *, const          DT * );
    242 forall( dtype DT ) signed int ?<?(        volatile DT *,       volatile DT * );
    243237forall( dtype DT ) signed int ?<?(  const volatile DT *, const volatile DT * );
    244 
    245 forall( dtype DT ) signed int ?>?(                 DT *,                DT * );
    246 forall( dtype DT ) signed int ?>?(  const          DT *, const          DT * );
    247 forall( dtype DT ) signed int ?>?(        volatile DT *,       volatile DT * );
    248238forall( dtype DT ) signed int ?>?(  const volatile DT *, const volatile DT * );
    249 
    250 forall( dtype DT ) signed int ?<=?(                 DT *,                DT * );
    251 forall( dtype DT ) signed int ?<=?(  const          DT *, const          DT * );
    252 forall( dtype DT ) signed int ?<=?(        volatile DT *,       volatile DT * );
    253239forall( dtype DT ) signed int ?<=?( const volatile DT *, const volatile DT * );
    254 
    255 forall( dtype DT ) signed int ?>=?(                 DT *,                DT * );
    256 forall( dtype DT ) signed int ?>=?(  const          DT *, const          DT * );
    257 forall( dtype DT ) signed int ?>=?(        volatile DT *,       volatile DT * );
    258240forall( dtype DT ) signed int ?>=?( const volatile DT *, const volatile DT * );
    259241
  • src/tests/avltree/avl_test.c

    rf37147b rd0ffed1  
    3636
    3737  // char* -> char*
    38   struct c_str { char *str; };  // wraps a C string
    39   int ?<?(c_str a, c_str b) {
    40     return strcmp(a.str,b.str) < 0;
     38  int ?<?(char *a, char *b) {
     39    return strcmp(a,b) < 0;
    4140  }
    42   tree(c_str, char *) * ssmap = create((c_str){"queso"}, "cheese");
    43   insert(&ssmap, (c_str){"foo"}, "bar");
    44   insert(&ssmap, (c_str){"hello"}, "world");
     41  tree(char *, char *) * ssmap = create("queso", "cheese");
     42  insert(&ssmap, "foo", "bar");
     43  insert(&ssmap, "hello", "world");
    4544  assert( height(ssmap) == 2 );
    4645
    47   printf("%s %s %s\n", *find(ssmap, (c_str){"hello"}), *find(ssmap, (c_str){"foo"}), *find(ssmap, (c_str){"queso"}));
     46  printf("%s %s %s\n", *find(ssmap, "hello"), *find(ssmap, "foo"), *find(ssmap, "queso"));
    4847
    49   remove(&ssmap, (c_str){"foo"});
     48  remove(&ssmap, "foo");
    5049  delete(ssmap);
    5150}
  • src/tests/monitor.c

    rf37147b rd0ffed1  
    66struct global_t {
    77        int value;
    8         __monitor_t m;
     8        monitor m;
    99};
    1010
     
    1616
    1717void increment( /*mutex*/ global_t * this ) {
    18         monitor_guard_t g1 = { &this->m };
    19         {
    20                 monitor_guard_t g2 = { &this->m };
    21                 {
    22                         monitor_guard_t g3 = { &this->m };
    23                         this->value += 1;
    24                 }
    25         }
     18        monitor_guard g = { &this->m };
     19        this->value += 1;
    2620}
    2721
Note: See TracChangeset for help on using the changeset viewer.