Ignore:
Timestamp:
Mar 12, 2019, 3:00:54 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
30e32b2, a2545593
Parents:
9d9a451 (diff), 91d6584 (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 second draft of Aaron's thesis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    r9d9a451 r53bb8f1  
    2626#include "Common/SemanticError.h"  // for SemanticError
    2727#include "Common/utility.h"        // for cloneAll
     28#include "Common/Stats/Counter.h" // for counters
    2829#include "GenPoly/GenPoly.h"
    2930#include "InitTweak/InitTweak.h"   // for isConstructor, isCopyFunction, isC...
     
    4142
    4243namespace SymTab {
     44
     45        // Statistics block
     46        namespace {
     47
     48                static inline auto stats_idtable() {
     49                        using namespace Stats::Counters;
     50                        static auto group = build<CounterGroup>("IdTable");
     51                        static struct {
     52                                SimpleCounter * find;
     53                                AverageCounter<double> * size;
     54                                AverageCounter<double> * key;
     55                        } ret = {
     56                                .find = build<SimpleCounter>("Find calls", group),
     57                                .size = build<AverageCounter<double>>("Average Size", group),
     58                                .key  = build<AverageCounter<double>>("Average Key Size", group),
     59                        };
     60                        return ret;
     61                }
     62
     63                static inline auto stats_indexers() {
     64                        using namespace Stats::Counters;
     65                        static auto group   = build<CounterGroup>("Indexers");
     66                        static struct {
     67                                SimpleCounter * count;
     68                                AverageCounter<double> * size;
     69                                AverageCounter<double> * depth_a;
     70                                MaxCounter<size_t> * depth_m;
     71                        } ret = {
     72                                .count   = build<SimpleCounter>("Count", group),
     73                                .size    = build<AverageCounter<double>>("Average Size", group),
     74                                .depth_a = build<AverageCounter<double>>("Average Depth", group),
     75                                .depth_m = build<MaxCounter<size_t>>("Max Depth", group),
     76                        };
     77                        return ret;
     78                }
     79        }
     80
    4381        std::ostream & operator<<( std::ostream & out, const Indexer::IdData & data ) {
    4482                return out << "(" << data.id << "," << data.baseExpr << ")";
     
    197235        }
    198236
    199         Indexer::Indexer() : tables( 0 ), scope( 0 ) {}
    200 
    201         Indexer::Indexer( const Indexer &that ) : doDebug( that.doDebug ), tables( newRef( that.tables ) ), scope( that.scope ) {}
     237        Indexer::Indexer() : tables( 0 ), scope( 0 ) {
     238                (*stats_indexers().count)++;
     239        }
     240
     241        Indexer::Indexer( const Indexer &that ) : doDebug( that.doDebug ), tables( newRef( that.tables ) ), scope( that.scope ) {
     242                (*stats_indexers().count)++;
     243        }
    202244
    203245        Indexer::Indexer( Indexer &&that ) : doDebug( that.doDebug ), tables( that.tables ), scope( that.scope ) {
     
    206248
    207249        Indexer::~Indexer() {
     250                if(tables) {
     251                        stats_indexers().size->push( tables->idTable.size() );
     252                        size_t depth = 1;
     253                        for( auto crnt = tables->base.tables; crnt; crnt = crnt->base.tables ) {
     254                                ++depth;
     255                        }
     256                        stats_indexers().depth_a->push( depth );
     257                        stats_indexers().depth_m->push( depth );
     258                }
    208259                deleteRef( tables );
    209260        }
     
    237288                while ( searchTables ) {
    238289
     290                        (*stats_idtable().find)++;
     291                        stats_idtable().key->push( id.size() );
     292                        stats_idtable().size->push( searchTables->idTable.size() );
    239293                        IdTable::const_iterator decls = searchTables->idTable.find( id );
    240294                        if ( decls != searchTables->idTable.end() ) {
     
    313367                if ( tables->scope < scope ) return nullptr;
    314368
     369                (*stats_idtable().find)++;
     370                stats_idtable().key->push( id.size() );
     371                stats_idtable().size->push( tables->idTable.size() );
    315372                IdTable::const_iterator decls = tables->idTable.find( id );
    316373                if ( decls != tables->idTable.end() ) {
     
    331388                if ( tables->scope < scope ) return false;
    332389
     390                (*stats_idtable().find)++;
     391                stats_idtable().key->push( id.size() );
     392                stats_idtable().size->push( tables->idTable.size() );
    333393                IdTable::const_iterator decls = tables->idTable.find( id );
    334394                if ( decls != tables->idTable.end() ) {
     
    347407                if ( tables->scope < scope ) return false;
    348408
     409                (*stats_idtable().find)++;
     410                stats_idtable().key->push( id.size() );
     411                stats_idtable().size->push( tables->idTable.size() );
    349412                IdTable::const_iterator decls = tables->idTable.find( id );
    350413                if ( decls != tables->idTable.end() ) {
Note: See TracChangeset for help on using the changeset viewer.