Ignore:
Timestamp:
Mar 8, 2016, 1:51:25 PM (10 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
52c2a72
Parents:
4e284ea6
Message:

Switch Indexer over to copy-on-write semantics for dramatic speedup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.h

    r4e284ea6 re8032b0  
    2121
    2222#include "SynTree/Visitor.h"
    23 #include "IdTable.h"
    24 #include "AggregateTable.h"
    25 #include "TypeTable.h"
    2623
    2724namespace SymTab {
     
    2926          public:
    3027                Indexer( bool useDebug = false );
     28
     29                Indexer( const Indexer &that );
     30                Indexer( Indexer &&that );
    3131                virtual ~Indexer();
     32                Indexer& operator= ( const Indexer &that );
     33                Indexer& operator= ( Indexer &&that );
    3234
    3335                //using Visitor::visit;
     
    7880                void leaveScope();
    7981
    80                 void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
    81                 DeclarationWithType* lookupId( const std::string &id) const;
     82                void lookupId( const std::string &id, std::list< DeclarationWithType* > &out ) const;
     83                DeclarationWithType* lookupId( const std::string &id ) const;
    8284                NamedTypeDecl *lookupType( const std::string &id ) const;
    8385                StructDecl *lookupStruct( const std::string &id ) const;
     
    8890                void print( std::ostream &os, int indent = 0 ) const;
    8991          private:
    90                 IdTable idTable;
    91                 TypeTable typeTable;
    92                 StructTable structTable;
    93                 EnumTable enumTable;
    94                 UnionTable unionTable;
    95                 TraitTable contextTable;
    96  
    97                 bool doDebug;                                   // display debugging trace
     92                void addId( DeclarationWithType *decl );
     93                void addType( NamedTypeDecl *decl );
     94                void addStruct( const std::string &id );
     95                void addStruct( StructDecl *decl );
     96                void addEnum( EnumDecl *decl );
     97                void addUnion( const std::string &id );
     98                void addUnion( UnionDecl *decl );
     99                void addTrait( TraitDecl *decl );
     100               
     101                struct Impl;
     102                Impl *tables;  ///< Copy-on-write instance of table data structure
     103                bool doDebug;  ///< Display debugging trace?
     104
     105                Indexer( Impl *_tables, bool _doDebug ) : tables( _tables ), doDebug( _doDebug ) {}
     106
     107                /// Takes a new ref to a table (returns null if null)
     108                static Impl *newRef( Impl *toClone );
     109                /// Clears a ref to a table (does nothing if null)
     110                static void deleteRef( Impl *toFree );
     111
     112                /// Ensures that tables variable is writable (i.e. allocated and uniquely owned by this Indexer)
     113                void makeWritable();
    98114        };
    99115} // namespace SymTab
Note: See TracChangeset for help on using the changeset viewer.