- Timestamp:
- Jun 28, 2018, 4:04:11 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- e3b2474
- Parents:
- a12c81f3 (diff), 944ce47 (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. - Location:
- src
- Files:
-
- 2 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypedefTable.cc
ra12c81f3 rc653b37 10 10 // Created On : Sat May 16 15:20:13 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 7 13:17:56201813 // Update Count : 19212 // Last Modified On : Fri Jun 22 06:14:39 2018 13 // Update Count : 206 14 14 // 15 15 … … 78 78 debugPrint( cerr << "Adding current at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << endl ); 79 79 auto ret = kindTable.insertAt( scope, identifier, kind ); 80 if ( ! ret.second ) ret.first->second = kind; // exists => update 80 //if ( ! ret.second ) ret.first->second = kind; // exists => update 81 assert( ret.first->second == kind ); // exists 81 82 } // TypedefTable::addToScope 82 83 83 84 void TypedefTable::addToEnclosingScope( const string & identifier, int kind, const char * locn __attribute__((unused)) ) { 84 assert( kindTable.currentScope() >= 1 );85 auto scope = kindTable.currentScope() - 1 ;86 debugPrint( cerr << "Adding enclosing at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << endl );85 assert( kindTable.currentScope() >= 1 + level ); 86 auto scope = kindTable.currentScope() - 1 - level; 87 debugPrint( cerr << "Adding enclosing at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << " level " << level << endl ); 87 88 auto ret = kindTable.insertAt( scope, identifier, kind ); 88 89 if ( ! ret.second ) ret.first->second = kind; // exists => update … … 91 92 void TypedefTable::enterScope() { 92 93 kindTable.beginScope(); 93 debugPrint( cerr << "Entering scope " << kindTable.currentScope() << endl ); 94 debugPrint( print() ); 94 debugPrint( cerr << "Entering scope " << kindTable.currentScope() << endl; print() ); 95 95 } // TypedefTable::enterScope 96 96 97 97 void TypedefTable::leaveScope() { 98 debugPrint( cerr << "Leaving scope " << kindTable.currentScope() << endl ); 99 debugPrint( print() ); 98 debugPrint( cerr << "Leaving scope " << kindTable.currentScope() << endl; print() ); 100 99 kindTable.endScope(); 101 100 } // TypedefTable::leaveScope … … 114 113 --scope; 115 114 debugPrint( cerr << endl << "[" << scope << "]" ); 116 } 115 } // while 117 116 debugPrint( cerr << endl ); 118 } 117 } // TypedefTable::print 119 118 120 119 // Local Variables: // -
src/Parser/TypedefTable.h
ra12c81f3 rc653b37 10 10 // Created On : Sat May 16 15:24:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 7 12:10:17201813 // Update Count : 8 512 // Last Modified On : Fri Jun 22 05:29:58 2018 13 // Update Count : 86 14 14 // 15 15 … … 25 25 typedef ScopedMap< std::string, int > KindTable; 26 26 KindTable kindTable; 27 unsigned int level = 0; 27 28 public: 28 29 ~TypedefTable(); … … 37 38 void leaveScope(); 38 39 40 void up() { level += 1; } 41 void down() { level -= 1; } 42 39 43 void print( void ) const; 40 44 }; // TypedefTable -
src/Parser/lex.ll
ra12c81f3 rc653b37 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Thu Jun 7 08:27:40201813 * Update Count : 6 7912 * Last Modified On : Wed Jun 20 09:08:28 2018 13 * Update Count : 682 14 14 */ 15 15 … … 25 25 //**************************** Includes and Defines **************************** 26 26 27 // trigger before each matching rule's action 28 #define YY_USER_ACTION \ 29 yylloc.first_line = yylineno; \ 30 yylloc.first_column = column; \ 31 column += yyleng; \ 32 yylloc.last_column = column; \ 33 yylloc.last_line = yylineno; \ 34 yylloc.filename = yyfilename ? yyfilename : ""; 27 35 unsigned int column = 0; // position of the end of the last token parsed 28 #define YY_USER_ACTION yylloc.first_line = yylineno; yylloc.first_column = column; column += yyleng; yylloc.last_column = column; yylloc.last_line = yylineno; yylloc.filename = yyfilename ? yyfilename : ""; // trigger before each matching rule's action29 36 30 37 #include <string> … … 49 56 #define NUMERIC_RETURN(x) rm_underscore(); RETURN_VAL( x ) // numeric constant 50 57 #define KEYWORD_RETURN(x) RETURN_CHAR( x ) // keyword 51 #define QKEYWORD_RETURN(x) typedefTable.isKind( yytext ); RETURN_VAL(x);// quasi-keyword58 #define QKEYWORD_RETURN(x) RETURN_VAL(x); // quasi-keyword 52 59 #define IDENTIFIER_RETURN() RETURN_VAL( typedefTable.isKind( yytext ) ) 53 60 #define ATTRIBUTE_RETURN() RETURN_VAL( ATTR_IDENTIFIER ) -
src/Parser/parser.yy
ra12c81f3 rc653b37 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 7 10:07:12201813 // Update Count : 35 2712 // Last Modified On : Sun Jun 24 10:41:10 2018 13 // Update Count : 3587 14 14 // 15 15 … … 136 136 } // build_postfix_name 137 137 138 bool forall = false, xxx = false ;// aggregate have one or more forall qualifiers ?138 bool forall = false, xxx = false, yyy = false; // aggregate have one or more forall qualifiers ? 139 139 140 140 // https://www.gnu.org/software/bison/manual/bison.html#Location-Type … … 304 304 %type<en> enumerator_value_opt 305 305 306 %type<decl> exception_declaration external_definition external_definition_list external_definition_list_no_pop_push external_definition_list_opt 306 %type<decl> external_definition external_definition_list external_definition_list_opt 307 308 %type<decl> exception_declaration 307 309 308 310 %type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list … … 503 505 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 504 506 | type_name '.' no_attr_identifier // CFA, nested type 505 // { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 506 { $$ = nullptr; } 507 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 507 508 | type_name '.' '[' field_list ']' // CFA, nested type / tuple field selector 508 // { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 509 { $$ = nullptr; } 509 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 510 510 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 511 511 { … … 1821 1821 ; 1822 1822 1823 fred: 1824 // empty 1825 { yyy = false; } 1826 ; 1827 1823 1828 aggregate_type: // struct, union 1824 1829 aggregate_key attribute_list_opt '{' field_declaration_list_opt '}' 1825 1830 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); } 1826 | aggregate_key attribute_list_opt no_attr_identifier 1831 | aggregate_key attribute_list_opt no_attr_identifier fred 1827 1832 { 1828 1833 typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); // create typedef 1829 //if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update1830 1834 forall = false; // reset 1831 1835 } 1832 1836 '{' field_declaration_list_opt '}' 1833 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $ 6, true )->addQualifiers( $2 ); }1834 | aggregate_key attribute_list_opt type_name 1837 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $7, true )->addQualifiers( $2 ); } 1838 | aggregate_key attribute_list_opt type_name fred 1835 1839 { 1836 1840 typedefTable.makeTypedef( *$3->type->symbolic.name, forall ? TYPEGENname : TYPEDEFname ); // create typedef 1837 //if ( forall ) typedefTable.changeKind( *$3->type->symbolic.name, TYPEGENname ); // possibly update1838 1841 forall = false; // reset 1839 1842 } 1840 1843 '{' field_declaration_list_opt '}' 1841 { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, nullptr, $ 6, true )->addQualifiers( $2 ); }1844 { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, nullptr, $7, true )->addQualifiers( $2 ); } 1842 1845 | aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list_opt '}' // CFA 1843 1846 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); } … … 1846 1849 1847 1850 aggregate_type_nobody: // struct, union - {...} 1848 aggregate_key attribute_list_opt no_attr_identifier 1851 aggregate_key attribute_list_opt no_attr_identifier fred 1849 1852 { 1850 1853 typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); 1851 //if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update1852 1854 forall = false; // reset 1853 1855 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1854 1856 } 1855 | aggregate_key attribute_list_opt type_name 1857 | aggregate_key attribute_list_opt type_name fred 1856 1858 { 1857 1859 // Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is … … 1867 1869 aggregate_key: 1868 1870 STRUCT 1869 { $$ = DeclarationNode::Struct; }1871 { yyy = true; $$ = DeclarationNode::Struct; } 1870 1872 | UNION 1871 { $$ = DeclarationNode::Union; }1873 { yyy = true; $$ = DeclarationNode::Union; } 1872 1874 | EXCEPTION 1873 { $$ = DeclarationNode::Exception; }1875 { yyy = true; $$ = DeclarationNode::Exception; } 1874 1876 | COROUTINE 1875 { $$ = DeclarationNode::Coroutine; }1877 { yyy = true; $$ = DeclarationNode::Coroutine; } 1876 1878 | MONITOR 1877 { $$ = DeclarationNode::Monitor; }1879 { yyy = true; $$ = DeclarationNode::Monitor; } 1878 1880 | THREAD 1879 { $$ = DeclarationNode::Thread; }1881 { yyy = true; $$ = DeclarationNode::Thread; } 1880 1882 ; 1881 1883 … … 2320 2322 2321 2323 translation_unit: 2322 // empty 2323 {} // empty input file 2324 // empty, input file 2324 2325 | external_definition_list 2325 2326 { parseTree = parseTree ? parseTree->appendList( $1 ) : $1; } … … 2335 2336 ; 2336 2337 2337 // SKULLDUGGERY: Declarations in extern "X" and distribution need to be added to the current lexical scope.2338 // However, external_definition_list creates a new scope around each external_definition, but the pop loses all the2339 // types in the extern "X" and distribution at the end of the block. This version of external_definition_list does2340 2341 // not do push/pop for declarations at the level of the extern "X" and distribution block. Any recursive uses of2342 // external_definition_list within the extern "X" and distribution block correctly pushes/pops for that scope level.2343 external_definition_list_no_pop_push:2344 external_definition2345 | external_definition_list_no_pop_push2346 { forall = xxx; }2347 external_definition2348 { $$ = $1 ? $1->appendList( $3 ) : $3; }2349 ;2350 2351 2338 external_definition_list_opt: 2352 2339 // empty 2353 2340 { $$ = nullptr; } 2354 | external_definition_list_no_pop_push 2341 | external_definition_list 2342 ; 2343 2344 up: 2345 { typedefTable.up(); } 2346 ; 2347 2348 down: 2349 { typedefTable.down(); } 2355 2350 ; 2356 2351 … … 2372 2367 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2373 2368 } 2374 '{' external_definition_list_opt'}'2369 '{' up external_definition_list_opt down '}' 2375 2370 { 2376 2371 linkage = linkageStack.top(); 2377 2372 linkageStack.pop(); 2378 $$ = $ 5;2373 $$ = $6; 2379 2374 } 2380 2375 | type_qualifier_list 2381 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2382 '{' external_definition_list_opt '}' // CFA, namespace 2383 { 2384 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2376 { 2377 if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2378 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2379 } 2380 '{' up external_definition_list_opt down '}' // CFA, namespace 2381 { 2382 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2385 2383 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2386 2384 iter->addQualifiers( $1->clone() ); … … 2389 2387 xxx = false; 2390 2388 delete $1; 2391 $$ = $ 4;2389 $$ = $5; 2392 2390 } 2393 2391 | declaration_qualifier_list 2394 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2395 '{' external_definition_list_opt '}' // CFA, namespace 2396 { 2397 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2392 { 2393 if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2394 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2395 } 2396 '{' up external_definition_list_opt down '}' // CFA, namespace 2397 { 2398 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2398 2399 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2399 2400 iter->addQualifiers( $1->clone() ); … … 2402 2403 xxx = false; 2403 2404 delete $1; 2404 $$ = $ 4;2405 $$ = $5; 2405 2406 } 2406 2407 | declaration_qualifier_list type_qualifier_list 2407 2408 { 2408 // forall must be in the type_qualifier_list2409 if ( $2->type->forall ) xxx = forall = true; // remember generic type2410 } 2411 '{' external_definition_list_opt '}'// CFA, namespace2412 { 2413 for ( DeclarationNode * iter = $ 5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {2409 if ( ($1->type && $1->type->qualifiers.val) || $2->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2410 if ( ($1->type && $1->type->forall) || $2->type->forall ) xxx = forall = true; // remember generic type 2411 } 2412 '{' up external_definition_list_opt down '}' // CFA, namespace 2413 { 2414 for ( DeclarationNode * iter = $6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2414 2415 if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) { // ignore extern "C" 2415 2416 iter->addQualifiers( $1->clone() ); … … 2420 2421 delete $1; 2421 2422 delete $2; 2422 $$ = $ 5;2423 $$ = $6; 2423 2424 } 2424 2425 ; -
src/ResolvExpr/AlternativeFinder.cc
ra12c81f3 rc653b37 1099 1099 argExpansions.emplace_back(); 1100 1100 auto& argE = argExpansions.back(); 1101 argE.reserve( arg.alternatives.size() );1101 // argE.reserve( arg.alternatives.size() ); 1102 1102 1103 1103 for ( const Alternative& actual : arg ) { -
src/ResolvExpr/CommonType.cc
ra12c81f3 rc653b37 24 24 #include "SynTree/Type.h" // for BasicType, BasicType::Kind::... 25 25 #include "SynTree/Visitor.h" // for Visitor 26 #include "Unify.h" // for unifyExact, bindVar,WidenMode26 #include "Unify.h" // for unifyExact, WidenMode 27 27 #include "typeops.h" // for isFtype 28 28 … … 238 238 AssertionSet need, have; 239 239 WidenMode widen( widenFirst, widenSecond ); 240 if ( entry != openVars.end() && ! bindVar(var, voidPointer->get_base(), entry->second, env, need, have, openVars, widen, indexer ) ) return;240 if ( entry != openVars.end() && ! env.bindVar(var, voidPointer->get_base(), entry->second, need, have, openVars, widen, indexer ) ) return; 241 241 } 242 242 } -
src/ResolvExpr/ExplodedActual.h
ra12c81f3 rc653b37 32 32 33 33 ExplodedActual() : env(), cost(Cost::zero), exprs() {} 34 35 34 ExplodedActual( const Alternative& actual, const SymTab::Indexer& indexer ); 35 ExplodedActual(ExplodedActual&&) = default; 36 ExplodedActual& operator= (ExplodedActual&&) = default; 36 37 }; 37 38 } -
src/ResolvExpr/Resolver.cc
ra12c81f3 rc653b37 582 582 583 583 // Make sure we don't widen any existing bindings 584 for ( auto & i : resultEnv ) { 585 i.allowWidening = false; 586 } 587 584 resultEnv.forbidWidening(); 585 588 586 // Find any unbound type variables 589 587 resultEnv.extractOpenVars( openVars ); -
src/ResolvExpr/TypeEnvironment.cc
ra12c81f3 rc653b37 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:19:47 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun May 17 12:23:36 201513 // Update Count : 311 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Mon Jun 18 11:58:00 2018 13 // Update Count : 4 14 14 // 15 15 … … 17 17 #include <algorithm> // for copy, set_intersection 18 18 #include <iterator> // for ostream_iterator, insert_iterator 19 #include <memory> // for unique_ptr 19 20 #include <utility> // for pair, move 20 21 … … 22 23 #include "SynTree/Type.h" // for Type, FunctionType, Type::Fora... 23 24 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution 25 #include "Tuples/Tuples.h" // for isTtype 24 26 #include "TypeEnvironment.h" 27 #include "typeops.h" // for occurs 28 #include "Unify.h" // for unifyInexact 25 29 26 30 namespace ResolvExpr { … … 65 69 } 66 70 71 EqvClass::EqvClass( EqvClass &&other ) 72 : vars{std::move(other.vars)}, type{other.type}, 73 allowWidening{std::move(other.allowWidening)}, data{std::move(other.data)} { 74 other.type = nullptr; 75 } 76 67 77 EqvClass &EqvClass::operator=( const EqvClass &other ) { 68 78 if ( this == &other ) return *this; … … 72 82 } 73 83 84 EqvClass &EqvClass::operator=( EqvClass &&other ) { 85 if ( this == &other ) return *this; 86 delete type; 87 88 vars = std::move(other.vars); 89 type = other.type; 90 other.type = nullptr; 91 allowWidening = std::move(other.allowWidening); 92 data = std::move(other.data); 93 94 return *this; 95 } 96 74 97 EqvClass::~EqvClass() { 75 98 delete type; 99 } 100 101 void EqvClass::set_type( Type* ty ) { 102 if ( ty == type ) return; 103 delete type; 104 type = ty; 76 105 } 77 106 … … 92 121 const EqvClass* TypeEnvironment::lookup( const std::string &var ) const { 93 122 for ( std::list< EqvClass >::const_iterator i = env.begin(); i != env.end(); ++i ) { 94 if ( i->vars.find( var ) != i->vars.end() ) { 95 /// std::cout << var << " is in class "; 96 /// i->print( std::cout ); 97 return &*i; 98 } 99 /// std::cout << var << " is not in class "; 100 /// i->print( std::cout ); 123 if ( i->vars.find( var ) != i->vars.end() ) return &*i; 101 124 } // for 102 125 return nullptr; … … 116 139 } 117 140 118 void TypeEnvironment::add( const EqvClass &eqvClass ) {119 filterOverlappingClasses( env, eqvClass );120 env.push_back( eqvClass );121 }122 123 141 void TypeEnvironment::add( EqvClass &&eqvClass ) { 124 142 filterOverlappingClasses( env, eqvClass ); … … 131 149 newClass.vars.insert( (*i)->get_name() ); 132 150 newClass.data = TypeDecl::Data{ (*i) }; 133 env.push_back( newClass);151 env.push_back( std::move(newClass) ); 134 152 } // for 135 153 } … … 145 163 // transition to TypeSubstitution 146 164 newClass.data = TypeDecl::Data{ TypeDecl::Dtype, false }; 147 add( newClass);165 add( std::move(newClass) ); 148 166 } 149 167 } … … 152 170 for ( std::list< EqvClass >::const_iterator theClass = env.begin(); theClass != env.end(); ++theClass ) { 153 171 for ( std::set< std::string >::const_iterator theVar = theClass->vars.begin(); theVar != theClass->vars.end(); ++theVar ) { 154 /// std::cerr << "adding " << *theVar;155 172 if ( theClass->type ) { 156 /// std::cerr << " bound to ";157 /// theClass->type->print( std::cerr );158 /// std::cerr << std::endl;159 173 sub.add( *theVar, theClass->type ); 160 174 } else if ( theVar != theClass->vars.begin() ) { 161 175 TypeInstType *newTypeInst = new TypeInstType( Type::Qualifiers(), *theClass->vars.begin(), theClass->data.kind == TypeDecl::Ftype ); 162 /// std::cerr << " bound to variable " << *theClass->vars.begin() << std::endl;163 176 sub.add( *theVar, newTypeInst ); 164 177 delete newTypeInst; … … 166 179 } // for 167 180 } // for 168 /// std::cerr << "input env is:" << std::endl;169 /// print( std::cerr, 8 );170 /// std::cerr << "sub is:" << std::endl;171 /// sub.print( std::cerr, 8 );172 181 sub.normalize(); 173 182 } … … 181 190 std::list< EqvClass >::iterator TypeEnvironment::internal_lookup( const std::string &var ) { 182 191 for ( std::list< EqvClass >::iterator i = env.begin(); i != env.end(); ++i ) { 183 if ( i->vars.find( var ) == i->vars.end() ) { 184 return i; 185 } // if 192 if ( i->vars.count( var ) ) return i; 186 193 } // for 187 194 return env.end(); … … 190 197 void TypeEnvironment::simpleCombine( const TypeEnvironment &second ) { 191 198 env.insert( env.end(), second.env.begin(), second.env.end() ); 192 }193 194 void TypeEnvironment::combine( const TypeEnvironment &second, Type *(*combineFunc)( Type*, Type* ) ) {195 TypeEnvironment secondCopy( second );196 for ( std::list< EqvClass >::iterator firstClass = env.begin(); firstClass != env.end(); ++firstClass ) {197 EqvClass &newClass = *firstClass;198 std::set< std::string > newVars;199 for ( std::set< std::string >::const_iterator var = firstClass->vars.begin(); var != firstClass->vars.end(); ++var ) {200 std::list< EqvClass >::iterator secondClass = secondCopy.internal_lookup( *var );201 if ( secondClass != secondCopy.env.end() ) {202 newVars.insert( secondClass->vars.begin(), secondClass->vars.end() );203 if ( secondClass->type ) {204 if ( newClass.type ) {205 Type *newType = combineFunc( newClass.type, secondClass->type );206 delete newClass.type;207 newClass.type = newType;208 newClass.allowWidening = newClass.allowWidening && secondClass->allowWidening;209 } else {210 newClass.type = secondClass->type->clone();211 newClass.allowWidening = secondClass->allowWidening;212 } // if213 } // if214 secondCopy.env.erase( secondClass );215 } // if216 } // for217 newClass.vars.insert( newVars.begin(), newVars.end() );218 } // for219 for ( std::list< EqvClass >::iterator secondClass = secondCopy.env.begin(); secondClass != secondCopy.env.end(); ++secondClass ) {220 env.push_back( *secondClass );221 } // for222 199 } 223 200 … … 241 218 } 242 219 220 bool isFtype( Type *type ) { 221 if ( dynamic_cast< FunctionType* >( type ) ) { 222 return true; 223 } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( type ) ) { 224 return typeInst->get_isFtype(); 225 } // if 226 return false; 227 } 228 229 bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) { 230 switch ( data.kind ) { 231 case TypeDecl::Dtype: 232 // to bind to an object type variable, the type must not be a function type. 233 // if the type variable is specified to be a complete type then the incoming 234 // type must also be complete 235 // xxx - should this also check that type is not a tuple type and that it's not a ttype? 236 return ! isFtype( type ) && (! data.isComplete || type->isComplete() ); 237 case TypeDecl::Ftype: 238 return isFtype( type ); 239 case TypeDecl::Ttype: 240 // ttype unifies with any tuple type 241 return dynamic_cast< TupleType * >( type ) || Tuples::isTtype( type ); 242 } // switch 243 return false; 244 } 245 246 bool TypeEnvironment::bindVar( TypeInstType *typeInst, Type *bindTo, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) { 247 248 // remove references from other, so that type variables can only bind to value types 249 bindTo = bindTo->stripReferences(); 250 OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() ); 251 assert( tyvar != openVars.end() ); 252 if ( ! tyVarCompatible( tyvar->second, bindTo ) ) { 253 return false; 254 } // if 255 if ( occurs( bindTo, typeInst->get_name(), *this ) ) { 256 return false; 257 } // if 258 auto curClass = internal_lookup( typeInst->get_name() ); 259 if ( curClass != env.end() ) { 260 if ( curClass->type ) { 261 Type *common = 0; 262 // attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to 263 std::unique_ptr< Type > newType( curClass->type->clone() ); 264 newType->get_qualifiers() = typeInst->get_qualifiers(); 265 if ( unifyInexact( newType.get(), bindTo, *this, need, have, openVars, widenMode & WidenMode( curClass->allowWidening, true ), indexer, common ) ) { 266 if ( common ) { 267 common->get_qualifiers() = Type::Qualifiers{}; 268 curClass->set_type( common ); 269 } // if 270 } else return false; 271 } else { 272 Type* newType = bindTo->clone(); 273 newType->get_qualifiers() = Type::Qualifiers{}; 274 curClass->set_type( newType ); 275 curClass->allowWidening = widenMode.widenFirst && widenMode.widenSecond; 276 } // if 277 } else { 278 EqvClass newClass; 279 newClass.vars.insert( typeInst->get_name() ); 280 newClass.type = bindTo->clone(); 281 newClass.type->get_qualifiers() = Type::Qualifiers(); 282 newClass.allowWidening = widenMode.widenFirst && widenMode.widenSecond; 283 newClass.data = data; 284 env.push_back( std::move(newClass) ); 285 } // if 286 return true; 287 } 288 289 bool TypeEnvironment::bindVarToVar( TypeInstType *var1, TypeInstType *var2, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) { 290 291 auto class1 = internal_lookup( var1->get_name() ); 292 auto class2 = internal_lookup( var2->get_name() ); 293 294 // exit early if variables already bound together 295 if ( class1 != env.end() && class1 == class2 ) { 296 class1->allowWidening &= widenMode; 297 return true; 298 } 299 300 bool widen1 = false, widen2 = false; 301 const Type *type1 = nullptr, *type2 = nullptr; 302 303 // check for existing bindings, perform occurs check 304 if ( class1 != env.end() ) { 305 if ( class1->type ) { 306 if ( occurs( class1->type, var2->get_name(), *this ) ) return false; 307 type1 = class1->type; 308 } // if 309 widen1 = widenMode.widenFirst && class1->allowWidening; 310 } // if 311 if ( class2 != env.end() ) { 312 if ( class2->type ) { 313 if ( occurs( class2->type, var1->get_name(), *this ) ) return false; 314 type2 = class2->type; 315 } // if 316 widen2 = widenMode.widenSecond && class2->allowWidening; 317 } // if 318 319 if ( type1 && type2 ) { 320 // both classes bound, merge if bound types can be unified 321 std::unique_ptr<Type> newType1{ type1->clone() }, newType2{ type2->clone() }; 322 WidenMode newWidenMode{ widen1, widen2 }; 323 Type *common = 0; 324 if ( unifyInexact( newType1.get(), newType2.get(), *this, need, have, openVars, newWidenMode, indexer, common ) ) { 325 class1->vars.insert( class2->vars.begin(), class2->vars.end() ); 326 class1->allowWidening = widen1 && widen2; 327 if ( common ) { 328 common->get_qualifiers() = Type::Qualifiers{}; 329 class1->set_type( common ); 330 } 331 env.erase( class2 ); 332 } else return false; 333 } else if ( class1 != env.end() && class2 != env.end() ) { 334 // both classes exist, at least one unbound, merge unconditionally 335 if ( type1 ) { 336 class1->vars.insert( class2->vars.begin(), class2->vars.end() ); 337 class1->allowWidening = widen1; 338 env.erase( class2 ); 339 } else { 340 class2->vars.insert( class1->vars.begin(), class1->vars.end() ); 341 class2->allowWidening = widen2; 342 env.erase( class1 ); 343 } // if 344 } else if ( class1 != env.end() ) { 345 // var2 unbound, add to class1 346 class1->vars.insert( var2->get_name() ); 347 class1->allowWidening = widen1; 348 } else if ( class2 != env.end() ) { 349 // var1 unbound, add to class2 350 class2->vars.insert( var1->get_name() ); 351 class2->allowWidening = widen2; 352 } else { 353 // neither var bound, create new class 354 EqvClass newClass; 355 newClass.vars.insert( var1->get_name() ); 356 newClass.vars.insert( var2->get_name() ); 357 newClass.allowWidening = widen1 && widen2; 358 newClass.data = data; 359 env.push_back( std::move(newClass) ); 360 } // if 361 return true; 362 } 363 364 void TypeEnvironment::forbidWidening() { 365 for ( EqvClass& c : env ) c.allowWidening = false; 366 } 367 243 368 std::ostream & operator<<( std::ostream & out, const TypeEnvironment & env ) { 244 369 env.print( out ); -
src/ResolvExpr/TypeEnvironment.h
ra12c81f3 rc653b37 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:24:58 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 22 09:35:45 201713 // Update Count : 311 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Mon Jun 18 11:58:00 2018 13 // Update Count : 4 14 14 // 15 15 … … 21 21 #include <set> // for set 22 22 #include <string> // for string 23 #include <utility> // for move, swap 24 25 #include "WidenMode.h" // for WidenMode 23 26 24 27 #include "SynTree/Declaration.h" // for TypeDecl::Data, DeclarationWit... … … 77 80 EqvClass( const EqvClass &other ); 78 81 EqvClass( const EqvClass &other, const Type *ty ); 82 EqvClass( EqvClass &&other ); 79 83 EqvClass &operator=( const EqvClass &other ); 84 EqvClass &operator=( EqvClass &&other ); 80 85 ~EqvClass(); 81 86 void print( std::ostream &os, Indenter indent = {} ) const; 87 88 /// Takes ownership of `ty`, freeing old `type` 89 void set_type(Type* ty); 82 90 }; 83 91 … … 85 93 public: 86 94 const EqvClass* lookup( const std::string &var ) const; 87 void add( const EqvClass &eqvClass );95 private: 88 96 void add( EqvClass &&eqvClass ); 97 public: 89 98 void add( const Type::ForallList &tyDecls ); 90 99 void add( const TypeSubstitution & sub ); … … 94 103 bool isEmpty() const { return env.empty(); } 95 104 void print( std::ostream &os, Indenter indent = {} ) const; 96 void combine( const TypeEnvironment &second, Type *(*combineFunc)( Type*, Type* ) );105 // void combine( const TypeEnvironment &second, Type *(*combineFunc)( Type*, Type* ) ); 97 106 void simpleCombine( const TypeEnvironment &second ); 98 107 void extractOpenVars( OpenVarSet &openVars ) const; … … 103 112 void addActual( const TypeEnvironment& actualEnv, OpenVarSet& openVars ); 104 113 105 typedef std::list< EqvClass >::iterator iterator; 106 iterator begin() { return env.begin(); } 107 iterator end() { return env.end(); } 108 typedef std::list< EqvClass >::const_iterator const_iterator; 109 const_iterator begin() const { return env.begin(); } 110 const_iterator end() const { return env.end(); } 114 /// Binds the type class represented by `typeInst` to the type `bindTo`; will add 115 /// the class if needed. Returns false on failure. 116 bool bindVar( TypeInstType *typeInst, Type *bindTo, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ); 117 118 /// Binds the type classes represented by `var1` and `var2` together; will add 119 /// one or both classes if needed. Returns false on failure. 120 bool bindVarToVar( TypeInstType *var1, TypeInstType *var2, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ); 121 122 /// Disallows widening for all bindings in the environment 123 void forbidWidening(); 124 125 using iterator = std::list< EqvClass >::const_iterator; 126 iterator begin() const { return env.begin(); } 127 iterator end() const { return env.end(); } 128 111 129 private: 112 130 std::list< EqvClass > env; 131 113 132 std::list< EqvClass >::iterator internal_lookup( const std::string &var ); 114 133 }; -
src/ResolvExpr/Unify.cc
ra12c81f3 rc653b37 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:27:10 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Mar 16 16:22:54 201713 // Update Count : 4 211 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Mon Jun 18 11:58:00 2018 13 // Update Count : 43 14 14 // 15 15 … … 129 129 } 130 130 131 bool isFtype( Type *type ) {132 if ( dynamic_cast< FunctionType* >( type ) ) {133 return true;134 } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( type ) ) {135 return typeInst->get_isFtype();136 } // if137 return false;138 }139 140 bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) {141 switch ( data.kind ) {142 case TypeDecl::Dtype:143 // to bind to an object type variable, the type must not be a function type.144 // if the type variable is specified to be a complete type then the incoming145 // type must also be complete146 // xxx - should this also check that type is not a tuple type and that it's not a ttype?147 return ! isFtype( type ) && (! data.isComplete || type->isComplete() );148 case TypeDecl::Ftype:149 return isFtype( type );150 case TypeDecl::Ttype:151 // ttype unifies with any tuple type152 return dynamic_cast< TupleType * >( type ) || Tuples::isTtype( type );153 } // switch154 return false;155 }156 157 bool bindVar( TypeInstType *typeInst, Type *other, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {158 // remove references from other, so that type variables can only bind to value types159 other = other->stripReferences();160 OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() );161 assert( tyvar != openVars.end() );162 if ( ! tyVarCompatible( tyvar->second, other ) ) {163 return false;164 } // if165 if ( occurs( other, typeInst->get_name(), env ) ) {166 return false;167 } // if168 if ( const EqvClass *curClass = env.lookup( typeInst->get_name() ) ) {169 if ( curClass->type ) {170 Type *common = 0;171 // attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to172 std::unique_ptr< Type > newType( curClass->type->clone() );173 newType->get_qualifiers() = typeInst->get_qualifiers();174 if ( unifyInexact( newType.get(), other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass->allowWidening, true ), indexer, common ) ) {175 if ( common ) {176 common->get_qualifiers() = Type::Qualifiers();177 env.add( EqvClass{ *curClass, common } );178 } // if179 return true;180 } else {181 return false;182 } // if183 } else {184 EqvClass newClass { *curClass, other };185 newClass.type->get_qualifiers() = Type::Qualifiers();186 newClass.allowWidening = widenMode.widenFirst && widenMode.widenSecond;187 env.add( std::move(newClass) );188 } // if189 } else {190 EqvClass newClass;191 newClass.vars.insert( typeInst->get_name() );192 newClass.type = other->clone();193 newClass.type->get_qualifiers() = Type::Qualifiers();194 newClass.allowWidening = widenMode.widenFirst && widenMode.widenSecond;195 newClass.data = data;196 env.add( newClass );197 } // if198 return true;199 }200 201 bool bindVarToVar( TypeInstType *var1, TypeInstType *var2, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {202 bool result = true;203 const EqvClass *class1 = env.lookup( var1->get_name() );204 const EqvClass *class2 = env.lookup( var2->get_name() );205 bool widen1 = false, widen2 = false;206 Type *type1 = nullptr, *type2 = nullptr;207 208 if ( class1 ) {209 if ( class1->type ) {210 if ( occurs( class1->type, var2->get_name(), env ) ) {211 return false;212 } // if213 type1 = class1->type->clone();214 } // if215 widen1 = widenMode.widenFirst && class1->allowWidening;216 } // if217 if ( class2 ) {218 if ( class2->type ) {219 if ( occurs( class2->type, var1->get_name(), env ) ) {220 return false;221 } // if222 type2 = class2->type->clone();223 } // if224 widen2 = widenMode.widenSecond && class2->allowWidening;225 } // if226 227 if ( type1 && type2 ) {228 // std::cerr << "has type1 && type2" << std::endl;229 WidenMode newWidenMode ( widen1, widen2 );230 Type *common = 0;231 if ( unifyInexact( type1, type2, env, needAssertions, haveAssertions, openVars, newWidenMode, indexer, common ) ) {232 EqvClass newClass1 = *class1;233 newClass1.vars.insert( class2->vars.begin(), class2->vars.end() );234 newClass1.allowWidening = widen1 && widen2;235 if ( common ) {236 common->get_qualifiers() = Type::Qualifiers();237 delete newClass1.type;238 newClass1.type = common;239 } // if240 env.add( std::move(newClass1) );241 } else {242 result = false;243 } // if244 } else if ( class1 && class2 ) {245 if ( type1 ) {246 EqvClass newClass1 = *class1;247 newClass1.vars.insert( class2->vars.begin(), class2->vars.end() );248 newClass1.allowWidening = widen1;249 env.add( std::move(newClass1) );250 } else {251 EqvClass newClass2 = *class2;252 newClass2.vars.insert( class1->vars.begin(), class1->vars.end() );253 newClass2.allowWidening = widen2;254 env.add( std::move(newClass2) );255 } // if256 } else if ( class1 ) {257 EqvClass newClass1 = *class1;258 newClass1.vars.insert( var2->get_name() );259 newClass1.allowWidening = widen1;260 env.add( std::move(newClass1) );261 } else if ( class2 ) {262 EqvClass newClass2 = *class2;263 newClass2.vars.insert( var1->get_name() );264 newClass2.allowWidening = widen2;265 env.add( std::move(newClass2) );266 } else {267 EqvClass newClass;268 newClass.vars.insert( var1->get_name() );269 newClass.vars.insert( var2->get_name() );270 newClass.allowWidening = widen1 && widen2;271 newClass.data = data;272 env.add( newClass );273 } // if274 delete type1;275 delete type2;276 return result;277 }278 279 131 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) { 280 132 OpenVarSet closedVars; … … 321 173 322 174 if ( isopen1 && isopen2 && entry1->second == entry2->second ) { 323 result = bindVarToVar( var1, var2, entry1->second, env, needAssertions, haveAssertions, openVars, widenMode, indexer );175 result = env.bindVarToVar( var1, var2, entry1->second, needAssertions, haveAssertions, openVars, widenMode, indexer ); 324 176 } else if ( isopen1 ) { 325 result = bindVar( var1, type2, entry1->second, env, needAssertions, haveAssertions, openVars, widenMode, indexer );177 result = env.bindVar( var1, type2, entry1->second, needAssertions, haveAssertions, openVars, widenMode, indexer ); 326 178 } else if ( isopen2 ) { // TODO: swap widenMode values in call, since type positions are flipped? 327 result = bindVar( var2, type1, entry2->second, env, needAssertions, haveAssertions, openVars, widenMode, indexer );179 result = env.bindVar( var2, type1, entry2->second, needAssertions, haveAssertions, openVars, widenMode, indexer ); 328 180 } else { 329 181 PassVisitor<Unify> comparator( type2, env, needAssertions, haveAssertions, openVars, widenMode, indexer ); -
src/ResolvExpr/Unify.h
ra12c81f3 rc653b37 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 13:09:04 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jul 21 23:09:34 201713 // Update Count : 311 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Mon Jun 18 11:58:00 2018 13 // Update Count : 4 14 14 // 15 15 … … 21 21 #include "SynTree/Declaration.h" // for TypeDecl, TypeDecl::Data 22 22 #include "TypeEnvironment.h" // for AssertionSet, OpenVarSet 23 #include "WidenMode.h" // for WidenMode 23 24 24 25 class Type; … … 29 30 30 31 namespace ResolvExpr { 31 struct WidenMode {32 WidenMode( bool widenFirst, bool widenSecond ): widenFirst( widenFirst ), widenSecond( widenSecond ) {}33 WidenMode &operator|=( const WidenMode &other ) { widenFirst |= other.widenFirst; widenSecond |= other.widenSecond; return *this; }34 WidenMode &operator&=( const WidenMode &other ) { widenFirst &= other.widenFirst; widenSecond &= other.widenSecond; return *this; }35 WidenMode operator|( const WidenMode &other ) { WidenMode newWM( *this ); newWM |= other; return newWM; }36 WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; }37 operator bool() { return widenFirst && widenSecond; }38 39 bool widenFirst : 1, widenSecond : 1;40 };41 42 bool bindVar( TypeInstType *typeInst, Type *other, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer );43 32 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 44 33 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType ); 45 34 bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 35 bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer, Type *&common ); 46 36 47 37 template< typename Iterator1, typename Iterator2 > -
src/SynTree/Type.cc
ra12c81f3 rc653b37 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 25 15:16:32 201713 // Update Count : 3 812 // Last Modified On : Fri Jun 22 10:17:19 2018 13 // Update Count : 39 14 14 // 15 15 #include "Type.h" … … 69 69 70 70 // These must remain in the same order as the corresponding bit fields. 71 const char * Type::FuncSpecifiersNames[] = { "inline", " fortran", "_Noreturn" };71 const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" }; 72 72 const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" }; 73 73 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; -
src/tests/.gitignore
ra12c81f3 rc653b37 1 1 .out/ 2 2 .err/ 3 .type -
src/tests/concurrent/coroutineYield.c
ra12c81f3 rc653b37 5 5 #include <time> 6 6 7 #define __kick_rate 150000ul 7 8 #include "long_tests.h" 8 9 … … 25 26 void main(Coroutine& this) { 26 27 while(true) { 27 sout | "Coroutine 1" | endl; 28 #if !defined(TEST_FOREVER) 29 sout | "Coroutine 1" | endl; 30 #endif 28 31 yield(); 29 sout | "Coroutine 2" | endl; 32 #if !defined(TEST_FOREVER) 33 sout | "Coroutine 2" | endl; 34 #endif 30 35 suspend(); 31 36 } … … 36 41 Coroutine c; 37 42 for(int i = 0; TEST(i < N); i++) { 38 sout | "Thread 1" | endl; 43 #if !defined(TEST_FOREVER) 44 sout | "Thread 1" | endl; 45 #endif 39 46 resume(c); 40 sout | "Thread 2" | endl; 47 #if !defined(TEST_FOREVER) 48 sout | "Thread 2" | endl; 49 #endif 41 50 yield(); 42 51 KICK_WATCHDOG; -
src/tests/concurrent/signal/disjoint.c
ra12c81f3 rc653b37 69 69 } 70 70 71 d.counter++; 72 73 if( (d.counter % 1000) == 0 ) sout | d.counter | endl; 71 #if !defined(TEST_FOREVER) 72 d.counter++; 73 if( (d.counter % 1000) == 0 ) sout | d.counter | endl; 74 #endif 74 75 75 76 return TEST(d.counter < N); -
src/tests/concurrent/signal/wait.c
ra12c81f3 rc653b37 12 12 #include <time> 13 13 14 #define __kick_rate 12000ul 14 15 #include "long_tests.h" 15 16 -
src/tests/long_tests.h
ra12c81f3 rc653b37 4 4 5 5 #if defined(TEST_FOREVER) 6 7 static unsigned long long __kick_count = 0; 8 #if !defined(__kick_rate) 9 #define __kick_rate 5000ul 10 #endif 11 6 12 #define TEST(x) 1 7 #define KICK_WATCHDOG write(STDOUT_FILENO, ".", 1) 8 #elif defined(TEST_LONG) 13 #define KICK_WATCHDOG do { __kick_count++; if(__kick_count > __kick_rate) { write(STDOUT_FILENO, ".", 1); __kick_count = 0; } } while(0) 14 15 16 #else 17 9 18 #define TEST(x) x 10 19 #define KICK_WATCHDOG 11 #else 12 #define TEST(x) x 13 #define KICK_WATCHDOG 20 14 21 #endif -
src/tests/preempt_longrun/Makefile.am
ra12c81f3 rc653b37 25 25 TIME = /usr/bin/time -f "%E" 26 26 27 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -I.. -I. -DTEST_$(shell echo $(type) | tr a-z A-Z) 27 # $(shell ./update-type $(type)) 28 # ./update-type $(type) 29 30 UPDATED_TYPE = $(shell ./update-type $(type)) 31 32 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -I.. -I. -DTEST_$(shell cat .type | tr a-z A-Z) 28 33 CFLAGS = ${BUILD_FLAGS} 29 34 CC = @CFA_BINDIR@/@CFA_NAME@ … … 45 50 46 51 clean-local: 47 rm -f ${TESTS} core* out.log 52 rm -f ${TESTS} core* out.log .type 48 53 49 % : %.c ${CC} 54 % : %.c ${CC} ${UPDATED_TYPE} 50 55 ${AM_V_GEN}${CC} ${CFLAGS} ${<} $(debug) -o ${@} 51 56 -
src/tests/preempt_longrun/Makefile.in
ra12c81f3 rc653b37 456 456 WATCHDOG = ${abs_top_srcdir}/tools/watchdog 457 457 TIME = /usr/bin/time -f "%E" 458 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -I.. -I. -DTEST_$(shell echo $(type) | tr a-z A-Z) 458 459 # $(shell ./update-type $(type)) 460 # ./update-type $(type) 461 UPDATED_TYPE = $(shell ./update-type $(type)) 462 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -I.. -I. -DTEST_$(shell cat .type | tr a-z A-Z) 459 463 TESTS = block coroutine create disjoint enter enter3 processor stack wait yield 460 464 all: all-am … … 889 893 890 894 clean-local: 891 rm -f ${TESTS} core* out.log 892 893 % : %.c ${CC} 895 rm -f ${TESTS} core* out.log .type 896 897 % : %.c ${CC} ${UPDATED_TYPE} 894 898 ${AM_V_GEN}${CC} ${CFLAGS} ${<} $(debug) -o ${@} 895 899 -
src/tests/preempt_longrun/enter.c
ra12c81f3 rc653b37 4 4 #include <time> 5 5 6 #define __kick_rate 75000ul 6 7 #include "long_tests.h" 7 8 -
src/tests/preempt_longrun/enter3.c
ra12c81f3 rc653b37 4 4 #include <time> 5 5 6 #define __kick_rate 75000ul 6 7 #include "long_tests.h" 7 8 -
src/tests/preempt_longrun/stack.c
ra12c81f3 rc653b37 4 4 #include <time> 5 5 6 #define __kick_rate 5000000ul 6 7 #include "long_tests.h" 7 8 … … 17 18 18 19 void main(worker_t & this) { 19 volatile long long p = 5_021_609ul; 20 volatile long long a = 326_417ul; 21 volatile long long n = 1l; 22 for (volatile long long i = 0; TEST(i < p); i++) { 23 n *= a; 24 n %= p; 25 KICK_WATCHDOG; 26 } 20 while(TEST(0)) { 21 volatile long long p = 5_021_609ul; 22 volatile long long a = 326_417ul; 23 volatile long long n = 1l; 24 for (volatile long long i = 0; i < p; i++) { 25 n *= a; 26 n %= p; 27 KICK_WATCHDOG; 28 } 27 29 28 if( !TEST(n == a) ) { 29 abort(); 30 if( !TEST(n == a) ) { 31 abort(); 32 } 30 33 } 31 34 } -
src/tests/preempt_longrun/yield.c
ra12c81f3 rc653b37 3 3 #include <time> 4 4 5 #define __kick_rate 550000ul 5 6 #include "long_tests.h" 6 7
Note:
See TracChangeset
for help on using the changeset viewer.