Changeset 675716e
- Timestamp:
- Mar 1, 2019, 3:10:09 PM (5 years ago)
- 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, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 1cb7fab2
- Parents:
- 8e70823
- Location:
- src
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
r8e70823 r675716e 5 5 #include <stack> 6 6 7 #include "Common/Stats.h" 7 8 #include "Common/utility.h" 8 9 … … 426 427 }; 427 428 429 #include "Common/Stats.h" 430 431 extern struct PassVisitorStats { 432 size_t depth = 0; 433 Stats::Counters::MaxCounter<double> * max = nullptr; 434 Stats::Counters::AverageCounter<double> * avg = nullptr; 435 } pass_visitor_stats; 436 428 437 #include "SynTree/TypeSubstitution.h" 429 438 #include "PassVisitor.impl.h" -
src/Common/PassVisitor.impl.h
r8e70823 r675716e 67 67 SemanticErrorException errors; 68 68 69 pass_visitor_stats.depth++; 70 pass_visitor_stats.max->push(pass_visitor_stats.depth); 71 pass_visitor_stats.avg->push(pass_visitor_stats.depth); 69 72 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 73 74 70 75 // splice in new declarations after previous decl 71 76 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); } … … 83 88 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 84 89 } 90 pass_visitor_stats.depth--; 85 91 if ( ! errors.isEmpty() ) { 86 92 throw errors; … … 94 100 SemanticErrorException errors; 95 101 102 pass_visitor_stats.depth++; 103 pass_visitor_stats.max->push(pass_visitor_stats.depth); 104 pass_visitor_stats.avg->push(pass_visitor_stats.depth); 96 105 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 97 106 // splice in new declarations after previous decl … … 109 118 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 110 119 } 120 pass_visitor_stats.depth--; 111 121 if ( ! errors.isEmpty() ) { 112 122 throw errors; … … 126 136 if ( ! visitor.get_visit_children() ) return; 127 137 SemanticErrorException errors; 138 139 pass_visitor_stats.depth++; 140 pass_visitor_stats.max->push(pass_visitor_stats.depth); 141 pass_visitor_stats.avg->push(pass_visitor_stats.depth); 128 142 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { 129 143 try { … … 135 149 } 136 150 } 151 pass_visitor_stats.depth--; 137 152 if ( ! errors.isEmpty() ) { 138 153 throw errors; … … 153 168 if ( ! mutator.get_visit_children() ) return; 154 169 SemanticErrorException errors; 170 171 pass_visitor_stats.depth++; 172 pass_visitor_stats.max->push(pass_visitor_stats.depth); 173 pass_visitor_stats.avg->push(pass_visitor_stats.depth); 155 174 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { 156 175 try { … … 163 182 } // try 164 183 } // for 184 pass_visitor_stats.depth--; 165 185 if ( ! errors.isEmpty() ) { 166 186 throw errors; … … 185 205 DeclList_t* afterDecls = get_afterDecls(); 186 206 207 pass_visitor_stats.depth++; 208 pass_visitor_stats.max->push(pass_visitor_stats.depth); 209 pass_visitor_stats.avg->push(pass_visitor_stats.depth); 187 210 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 188 211 … … 202 225 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 203 226 } 227 pass_visitor_stats.depth--; 204 228 205 229 if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); } -
src/Common/Stats/Base.h
r8e70823 r675716e 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // Heap.h -- 8 // 9 // Author : Thierry Delisle 10 // Created On : Fri Mar 03 14:53:53 2019 11 // Last Modified By : 12 // Last Modified On : 13 // Update Count : 14 // 15 1 16 #pragma once 2 17 -
src/Common/Stats/Counter.cc
r8e70823 r675716e 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Heap.h--7 // Counter.cc -- 8 8 // 9 9 // Author : Thierry Delisle -
src/Common/Stats/Counter.h
r8e70823 r675716e 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Heap.h --7 // Counter.h -- 8 8 // 9 9 // Author : Thierry Delisle -
src/Common/module.mk
r8e70823 r675716e 17 17 SRC_COMMON = \ 18 18 Common/Assert.cc \ 19 Common/Eval.cc \ 20 Common/PassVisitor.cc \ 21 Common/SemanticError.cc \ 19 22 Common/Stats/Heap.cc \ 20 23 Common/Stats/Counter.cc \ 21 Common/Eval.cc \22 Common/SemanticError.cc \23 24 Common/UniqueName.cc 24 25 -
src/Makefile.in
r8e70823 r675716e 165 165 CodeGen/FixMain.$(OBJEXT) CodeGen/GenType.$(OBJEXT) \ 166 166 CodeGen/OperatorTable.$(OBJEXT) 167 am__objects_2 = Common/Assert.$(OBJEXT) Common/Stats/Heap.$(OBJEXT) \ 168 Common/Stats/Counter.$(OBJEXT) Common/Eval.$(OBJEXT) \ 169 Common/SemanticError.$(OBJEXT) Common/UniqueName.$(OBJEXT) 167 am__objects_2 = Common/Assert.$(OBJEXT) Common/Eval.$(OBJEXT) \ 168 Common/PassVisitor.$(OBJEXT) Common/SemanticError.$(OBJEXT) \ 169 Common/Stats/Heap.$(OBJEXT) Common/Stats/Counter.$(OBJEXT) \ 170 Common/UniqueName.$(OBJEXT) 170 171 am__objects_3 = ControlStruct/ForExprMutator.$(OBJEXT) \ 171 172 ControlStruct/LabelFixer.$(OBJEXT) \ … … 560 561 SRC_COMMON = \ 561 562 Common/Assert.cc \ 563 Common/Eval.cc \ 564 Common/PassVisitor.cc \ 565 Common/SemanticError.cc \ 562 566 Common/Stats/Heap.cc \ 563 567 Common/Stats/Counter.cc \ 564 Common/Eval.cc \565 Common/SemanticError.cc \566 568 Common/UniqueName.cc 567 569 … … 721 723 Common/Assert.$(OBJEXT): Common/$(am__dirstamp) \ 722 724 Common/$(DEPDIR)/$(am__dirstamp) 725 Common/Eval.$(OBJEXT): Common/$(am__dirstamp) \ 726 Common/$(DEPDIR)/$(am__dirstamp) 727 Common/PassVisitor.$(OBJEXT): Common/$(am__dirstamp) \ 728 Common/$(DEPDIR)/$(am__dirstamp) 729 Common/SemanticError.$(OBJEXT): Common/$(am__dirstamp) \ 730 Common/$(DEPDIR)/$(am__dirstamp) 723 731 Common/Stats/$(am__dirstamp): 724 732 @$(MKDIR_P) Common/Stats … … 731 739 Common/Stats/Counter.$(OBJEXT): Common/Stats/$(am__dirstamp) \ 732 740 Common/Stats/$(DEPDIR)/$(am__dirstamp) 733 Common/Eval.$(OBJEXT): Common/$(am__dirstamp) \734 Common/$(DEPDIR)/$(am__dirstamp)735 Common/SemanticError.$(OBJEXT): Common/$(am__dirstamp) \736 Common/$(DEPDIR)/$(am__dirstamp)737 741 Common/UniqueName.$(OBJEXT): Common/$(am__dirstamp) \ 738 742 Common/$(DEPDIR)/$(am__dirstamp) … … 1115 1119 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/DebugMalloc.Po@am__quote@ 1116 1120 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Eval.Po@am__quote@ 1121 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/PassVisitor.Po@am__quote@ 1117 1122 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/SemanticError.Po@am__quote@ 1118 1123 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/UniqueName.Po@am__quote@ -
src/main.cc
r8e70823 r675716e 65 65 using namespace std; 66 66 67 #define PASS(name, pass) \ 67 auto pass_visitor_group = new Stats::Counters::CounterGroup("Pass Visitor"); 68 69 void NewPass(const char * const name) { 70 Stats::Heap::newPass(name); 71 auto pass = new Stats::Counters::CounterGroup(name, pass_visitor_group); 72 pass_visitor_stats.depth = 0; 73 pass_visitor_stats.avg = new Stats::Counters::AverageCounter<double>("Average Depth", pass); 74 pass_visitor_stats.max = new Stats::Counters::MaxCounter<double>("Max Depth", pass); 75 } 76 77 #define PASS(name, pass) \ 68 78 if ( errorp ) { cerr << name << endl; } \ 69 Stats::Heap::newPass(name);\79 NewPass(name); \ 70 80 pass; 71 81 … … 142 152 backtrace( 6 ); // skip first 6 stack frames 143 153 signal( SIGABRT, SIG_DFL); // reset default signal handler 144 154 raise( SIGABRT ); // reraise SIGABRT 145 155 } // sigAbortHandler 146 156 … … 181 191 } // if 182 192 193 NewPass("Parse"); 194 183 195 // read in the builtins, extras, and the prelude 184 196 if ( ! nopreludep ) { // include gcc builtins … … 233 245 234 246 // add the assignment statement after the initialization of a type parameter 235 PASS( " validate", SymTab::validate( translationUnit, symtabp ) );247 PASS( "Validate", SymTab::validate( translationUnit, symtabp ) ); 236 248 if ( symtabp ) { 237 249 deleteAll( translationUnit ); … … 250 262 } // if 251 263 252 PASS( " fixLabels", ControlStruct::fixLabels( translationUnit ) );253 PASS( " fixNames", CodeGen::fixNames( translationUnit ) );254 PASS( " genInit", InitTweak::genInit( translationUnit ) );255 PASS( " expandMemberTuples" , Tuples::expandMemberTuples( translationUnit ) );264 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) ); 265 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) ); 266 PASS( "Gen Init", InitTweak::genInit( translationUnit ) ); 267 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) ); 256 268 if ( libcfap ) { 257 269 // generate the bodies of cfa library functions … … 277 289 } 278 290 279 PASS( " resolve", ResolvExpr::resolve( translationUnit ) );291 PASS( "Resolve", ResolvExpr::resolve( translationUnit ) ); 280 292 if ( exprp ) { 281 293 dump( translationUnit ); … … 284 296 285 297 // fix ObjectDecl - replaces ConstructorInit nodes 286 PASS( " fixInit", InitTweak::fix( translationUnit, buildingLibrary() ) );298 PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) ); 287 299 if ( ctorinitp ) { 288 300 dump ( translationUnit ); … … 290 302 } // if 291 303 292 PASS( " expandUniqueExpr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused293 294 PASS( " translateEHM" , ControlStruct::translateEHM( translationUnit ) );295 296 PASS( " generateWaitfor" , Concurrency::generateWaitFor( translationUnit ) );297 298 PASS( " convertSpecializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded299 300 PASS( " expandTuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?304 PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused 305 306 PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) ); 307 308 PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) ); 309 310 PASS( "Convert Specializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded 311 312 PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this? 301 313 302 314 if ( tuplep ) { … … 305 317 } 306 318 307 PASS( " virtual expandCasts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM308 309 PASS( " instantiateGenerics", GenPoly::instantiateGeneric( translationUnit ) );319 PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM 320 321 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) ); 310 322 if ( genericsp ) { 311 323 dump( translationUnit ); 312 324 return 0; 313 325 } 314 PASS( " convertLvalue", GenPoly::convertLvalue( translationUnit ) );326 PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) ); 315 327 316 328 … … 319 331 return 0; 320 332 } // if 321 PASS( " box", GenPoly::box( translationUnit ) );333 PASS( "Box", GenPoly::box( translationUnit ) ); 322 334 323 335 if ( bcodegenp ) { … … 331 343 332 344 CodeTools::fillLocations( translationUnit ); 333 PASS( " codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) );345 PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) ); 334 346 335 347 CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() ); … … 421 433 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrRstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) { 422 434 switch ( c ) { 423 424 435 case Ast: 436 case 'a': // dump AST 425 437 astp = true; 426 438 break; 427 428 439 case Bresolver: 440 case 'b': // print before resolver steps 429 441 bresolvep = true; 430 442 break; 431 443 case 'B': // print before box steps 432 444 bboxp = true; 433 445 break; 434 435 446 case CtorInitFix: 447 case 'c': // print after constructors and destructors are replaced 436 448 ctorinitp = true; 437 449 break; 438 450 case 'C': // print before code generation 439 451 bcodegenp = true; 440 452 break; 441 442 443 444 break; 445 446 453 case DeclStats: 454 case 'd': 455 declstatsp = true; 456 break; 457 case Expr: 458 case 'e': // dump AST after expression analysis 447 459 exprp = true; 448 460 break; 449 450 461 case ExprAlt: 462 case 'f': // print alternatives for expressions 451 463 expraltp = true; 452 464 break; 453 454 465 case Grammar: 466 case 'g': // bison debugging info (grammar rules) 455 467 yydebug = true; 456 468 break; 457 469 case 'G': // dump AST after instantiate generics 458 470 genericsp = true; 459 471 break; 460 461 472 case LibCFA: 473 case 'l': // generate libcfa.c 462 474 libcfap = true; 463 475 break; 464 465 476 case Linemarks: 477 case 'L': // print lines marks 466 478 linemarks = true; 467 479 break; 468 469 480 case Nopreamble: 481 case 'n': // do not read preamble 470 482 nopreludep = true; 471 483 break; 472 473 484 case Nolinemarks: 485 case 'N': // suppress line marks 474 486 linemarks = false; 475 487 break; 476 477 488 case Prototypes: 489 case 'p': // generate prototypes for preamble functions 478 490 noprotop = true; 479 491 break; 480 481 482 break; 483 484 485 break; 486 487 492 case PreludeDir: 493 PreludeDirector = optarg; 494 break; 495 case 'm': // don't replace the main 496 nomainp = true; 497 break; 498 case Parse: 499 case 'q': // dump parse tree 488 500 parsep = true; 489 501 break; 490 491 502 case Resolver: 503 case 'r': // print resolver steps 492 504 resolvep = true; 493 505 break; 494 506 case 'R': // dump resolv-proto instance 495 507 resolvprotop = true; 496 508 break; 497 509 case Stats: 498 510 { 499 511 std::stringstream ss(optarg); … … 515 527 } 516 528 break; 517 518 529 case Symbol: 530 case 's': // print symbol table events 519 531 symtabp = true; 520 532 break; 521 522 533 case Tree: 534 case 't': // build in tree 523 535 treep = true; 524 536 break; 525 526 537 case TupleExpansion: 538 case 'T': // print after tuple expansion 527 539 tuplep = true; 528 540 break; 529 541 case 'v': // dump AST after decl validation pass 530 542 validp = true; 531 543 break; 532 544 case 'w': 533 545 Wsuppress = true; 534 546 break; 535 547 case 'W': 536 548 if ( strcmp( optarg, "all" ) == 0 ) { 537 549 SemanticWarning_EnableAll(); … … 550 562 } // if 551 563 break; 552 564 case 'y': // dump AST on error 553 565 errorp = true; 554 566 break; 555 567 case 'z': // dump as codegen rather than AST 556 568 codegenp = true; 557 569 break; … … 559 571 prettycodegenp = true; 560 572 break; 561 562 break; 563 573 case 'D': // ignore -Dxxx 574 break; 575 case 'F': // source file-name without suffix 564 576 filename = optarg; 565 577 break; 566 578 case '?': 567 579 if ( optopt ) { // short option ? 568 580 assertf( false, "Unknown option: -%c\n", (char)optopt ); … … 573 585 __attribute__((fallthrough)); 574 586 #endif 575 587 default: 576 588 abort(); 577 589 } // switch
Note: See TracChangeset
for help on using the changeset viewer.