Ignore:
Timestamp:
Jul 31, 2019, 3:23:04 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
ae265b55, f49b3fc
Parents:
504eb72
Message:

Startup.cfa now compiles with new ast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/TypeEnvironment.hpp

    r504eb72 r2890212  
    3838/// Adding this comparison operator significantly improves assertion satisfaction run time for
    3939/// some cases. The current satisfaction algorithm's speed partially depends on the order of
    40 /// assertions. Assertions which have fewer possible matches should appear before assertions 
    41 /// which have more possible matches. This seems to imply that this could be further improved 
    42 /// by providing an indexer as an additional argument and ordering based on the number of 
     40/// assertions. Assertions which have fewer possible matches should appear before assertions
     41/// which have more possible matches. This seems to imply that this could be further improved
     42/// by providing an indexer as an additional argument and ordering based on the number of
    4343/// matches of the same kind (object, function) for the names of the declarations.
    4444///
    45 /// I've seen a TU go from 54 minutes to 1 minute 34 seconds with the addition of this 
     45/// I've seen a TU go from 54 minutes to 1 minute 34 seconds with the addition of this
    4646/// comparator.
    4747///
    48 /// Note: since this compares pointers for position, minor changes in the source file that 
    49 /// affect memory layout can alter compilation time in unpredictable ways. For example, the 
    50 /// placement of a line directive can reorder type pointers with respect to each other so that 
    51 /// assertions are seen in different orders, causing a potentially different number of 
    52 /// unification calls when resolving assertions. I've seen a TU go from 36 seconds to 27 
    53 /// seconds by reordering line directives alone, so it would be nice to fix this comparison so 
    54 /// that assertions compare more consistently. I've tried to modify this to compare on mangle 
    55 /// name instead of type as the second comparator, but this causes some assertions to never be 
     48/// Note: since this compares pointers for position, minor changes in the source file that
     49/// affect memory layout can alter compilation time in unpredictable ways. For example, the
     50/// placement of a line directive can reorder type pointers with respect to each other so that
     51/// assertions are seen in different orders, causing a potentially different number of
     52/// unification calls when resolving assertions. I've seen a TU go from 36 seconds to 27
     53/// seconds by reordering line directives alone, so it would be nice to fix this comparison so
     54/// that assertions compare more consistently. I've tried to modify this to compare on mangle
     55/// name instead of type as the second comparator, but this causes some assertions to never be
    5656/// recorded. More investigation is needed.
    5757struct AssertCompare {
     
    8787void print( std::ostream &, const OpenVarSet &, Indenter indent = {} );
    8888
    89 /// Represents an equivalence class of bound type variables, optionally with the concrete type 
     89/// Represents an equivalence class of bound type variables, optionally with the concrete type
    9090/// they bind to.
    9191struct EqvClass {
     
    9696
    9797        EqvClass() : vars(), bound(), allowWidening( true ), data() {}
    98        
     98
    9999        /// Copy-with-bound constructor
    100         EqvClass( const EqvClass & o, const Type * b ) 
     100        EqvClass( const EqvClass & o, const Type * b )
    101101        : vars( o.vars ), bound( b ), allowWidening( o.allowWidening ), data( o.data ) {}
    102102
     
    143143        void writeToSubstitution( TypeSubstitution & sub ) const;
    144144
    145         template< typename node_t, enum Node::ref_type ref_t >
    146         int apply( ptr_base< node_t, ref_t > & type ) const {
     145        template< typename node_t >
     146        auto apply( node_t && type ) const {
    147147                TypeSubstitution sub;
    148148                writeToSubstitution( sub );
    149                 return sub.apply( type );
    150         }
    151 
    152         template< typename node_t, enum Node::ref_type ref_t >
    153         int applyFree( ptr_base< node_t, ref_t > & type ) const {
     149                return sub.apply( std::forward<node_t>(type) );
     150        }
     151
     152        template< typename node_t >
     153        auto applyFree( node_t && type ) const {
    154154                TypeSubstitution sub;
    155155                writeToSubstitution( sub );
    156                 return sub.applyFree( type );
     156                return sub.applyFree( std::forward<node_t>(type) );
    157157        }
    158158
     
    173173        void addActual( const TypeEnvironment & actualEnv, OpenVarSet & openVars );
    174174
    175         /// Binds the type class represented by `typeInst` to the type `bindTo`; will add the class if 
     175        /// Binds the type class represented by `typeInst` to the type `bindTo`; will add the class if
    176176        /// needed. Returns false on failure.
    177         bool bindVar( 
    178                 const TypeInstType * typeInst, const Type * bindTo, const TypeDecl::Data & data, 
    179                 AssertionSet & need, AssertionSet & have, const OpenVarSet & openVars, 
     177        bool bindVar(
     178                const TypeInstType * typeInst, const Type * bindTo, const TypeDecl::Data & data,
     179                AssertionSet & need, AssertionSet & have, const OpenVarSet & openVars,
    180180                ResolvExpr::WidenMode widen, const SymbolTable & symtab );
    181        
    182         /// Binds the type classes represented by `var1` and `var2` together; will add one or both 
     181
     182        /// Binds the type classes represented by `var1` and `var2` together; will add one or both
    183183        /// classes if needed. Returns false on failure.
    184         bool bindVarToVar( 
    185                 const TypeInstType * var1, const TypeInstType * var2, TypeDecl::Data && data, 
    186                 AssertionSet & need, AssertionSet & have, const OpenVarSet & openVars, 
     184        bool bindVarToVar(
     185                const TypeInstType * var1, const TypeInstType * var2, TypeDecl::Data && data,
     186                AssertionSet & need, AssertionSet & have, const OpenVarSet & openVars,
    187187                ResolvExpr::WidenMode widen, const SymbolTable & symtab );
    188188
     
    199199
    200200        /// Unifies the type bound of `to` with the type bound of `from`, returning false if fails
    201         bool mergeBound( 
     201        bool mergeBound(
    202202                EqvClass & to, const EqvClass & from, OpenVarSet & openVars, const SymbolTable & symtab );
    203203
    204204        /// Merges two type classes from local environment, returning false if fails
    205         bool mergeClasses( 
    206                 ClassList::iterator to, ClassList::iterator from, OpenVarSet & openVars, 
     205        bool mergeClasses(
     206                ClassList::iterator to, ClassList::iterator from, OpenVarSet & openVars,
    207207                const SymbolTable & symtab );
    208208
Note: See TracChangeset for help on using the changeset viewer.