Changeset 9ad2f9f for src/ResolvExpr/TypeEnvironment.h
- Timestamp:
- Oct 3, 2018, 5:08:14 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 59cf83b
- Parents:
- 588c2b0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/TypeEnvironment.h
r588c2b0 r9ad2f9f 39 39 // declarations. 40 40 // 41 // I've seen a TU go from 54 minutes to 1 minute 34 seconds with the addition of this comparator. 41 // I've seen a TU go from 54 minutes to 1 minute 34 seconds with the addition of this 42 // comparator. 42 43 // 43 44 // Note: since this compares pointers for position, minor changes in the source file that affect 44 45 // memory layout can alter compilation time in unpredictable ways. For example, the placement 45 46 // of a line directive can reorder type pointers with respect to each other so that assertions 46 // are seen in different orders, causing a potentially different number of unification calls when 47 // resolving assertions. I've seen a TU go from 36 seconds to 27 seconds by reordering line directives 48 // alone, so it would be nice to fix this comparison so that assertions compare more consistently. 49 // I've tried to modify this to compare on mangle name instead of type as the second comparator, but 50 // this causes some assertions to never be recorded. More investigation is needed. 47 // are seen in different orders, causing a potentially different number of unification calls 48 // when resolving assertions. I've seen a TU go from 36 seconds to 27 seconds by reordering 49 // line directives alone, so it would be nice to fix this comparison so that assertions compare 50 // more consistently. I've tried to modify this to compare on mangle name instead of type as 51 // the second comparator, but this causes some assertions to never be recorded. More 52 // investigation is needed. 51 53 struct AssertCompare { 52 54 bool operator()( DeclarationWithType * d1, DeclarationWithType * d2 ) const { … … 58 60 struct AssertionSetValue { 59 61 bool isUsed; 60 // chain of Unique IDs of the assertion declarations. The first ID in the chain is the ID of an assertion on the current type, 61 // with each successive ID being the ID of an assertion pulled in by the previous ID. The last ID in the chain is 62 // the ID of the assertion that pulled in the current assertion. 62 // chain of Unique IDs of the assertion declarations. The first ID in the chain is the ID 63 // of an assertion on the current type, with each successive ID being the ID of an 64 // assertion pulled in by the previous ID. The last ID in the chain is the ID of the 65 // assertion that pulled in the current assertion. 63 66 std::list< UniqueId > idChain; 64 67 }; … … 91 94 92 95 class TypeEnvironment { 96 using ClassList = std::list< EqvClass >; 93 97 public: 94 98 const EqvClass* lookup( const std::string &var ) const; … … 103 107 bool isEmpty() const { return env.empty(); } 104 108 void print( std::ostream &os, Indenter indent = {} ) const; 105 // void combine( const TypeEnvironment &second, Type *(*combineFunc)( Type*, Type* ) ); 109 110 /// Simply concatenate the second environment onto this one; no safety checks performed 106 111 void simpleCombine( const TypeEnvironment &second ); 112 113 private: 114 /// Unifies the type bound of to with the type bound of from, returning false if fails 115 bool mergeBound( EqvClass& to, const EqvClass& from, OpenVarSet& openVars, const SymTab::Indexer& indexer ); 116 117 /// Merges two type classes from local environment, returning false if fails 118 bool mergeClasses( ClassList::iterator to, ClassList::iterator from, OpenVarSet& openVars, const SymTab::Indexer& indexer ); 119 120 public: 121 /// Merges the second environment with this one, checking compatibility. 122 /// Returns false if fails, but does NOT roll back partial changes. 123 bool combine( const TypeEnvironment& second, OpenVarSet& openVars, const SymTab::Indexer& indexer ); 124 107 125 void extractOpenVars( OpenVarSet &openVars ) const; 108 126 TypeEnvironment *clone() const { return new TypeEnvironment( *this ); } … … 123 141 void forbidWidening(); 124 142 125 using iterator = std::list< EqvClass >::const_iterator;143 using iterator = ClassList::const_iterator; 126 144 iterator begin() const { return env.begin(); } 127 145 iterator end() const { return env.end(); } 128 146 129 147 private: 130 std::list< EqvClass >env;148 ClassList env; 131 149 132 std::list< EqvClass >::iterator internal_lookup( const std::string &var );150 ClassList::iterator internal_lookup( const std::string &var ); 133 151 }; 134 152
Note: See TracChangeset
for help on using the changeset viewer.