Changeset 1034
- Timestamp:
- 02/11/10 11:18:34 (6 months ago)
- Location:
- trunk/rphp
- Files:
-
- 2 added
- 8 modified
-
compiler/analysis/CMakeLists.txt (modified) (1 diff)
-
compiler/analysis/pPassManager.cpp (modified) (2 diffs)
-
compiler/analysis/passes/CheckMemoryManagement.cpp (modified) (1 diff)
-
compiler/analysis/passes/Desugar.cpp (added)
-
compiler/analysis/passes/Lower_Binary_Op.cpp (modified) (1 diff)
-
doc/phc-pass-notes.txt (modified) (2 diffs)
-
frontend/cli/rphp-analyzer.cpp (modified) (4 diffs)
-
include/rphp/analysis/pAST.h (modified) (5 diffs)
-
include/rphp/analysis/pPassManager.h (modified) (2 diffs)
-
include/rphp/analysis/passes/Desugar.h (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/rphp/compiler/analysis/CMakeLists.txt
r1030 r1034 84 84 passes/CheckMemoryManagement.cpp 85 85 passes/SimplifyStrings.cpp 86 passes/Desugar.cpp 86 87 passes/DumpAST.cpp 87 88 passes/DumpStats.cpp -
trunk/rphp/compiler/analysis/pPassManager.cpp
r977 r1034 23 23 #include "rphp/analysis/pPass.h" 24 24 #include "rphp/analysis/pSourceModule.h" 25 #include "rphp/analysis/passes/CheckMemoryManagement.h" 25 26 26 27 namespace rphp { … … 46 47 (*i)->post_run(); 47 48 } 49 } 48 50 51 void pPassManager::addPass(AST::pPass* p) { 52 passQueue_.push_back(p); 53 #ifdef DEBUG 54 passQueue_.push_back(new AST::Pass::CheckMemoryManagement); 55 #endif 49 56 } 50 57 -
trunk/rphp/compiler/analysis/passes/CheckMemoryManagement.cpp
r1030 r1034 30 30 31 31 void CheckMemoryManagement::visit_pre_stmt(stmt* s) { 32 if(s && s-> refCount_!= 1) {33 std::cerr << "The following AST Node has a refCount of " << s-> refCount_<< std::endl;32 if(s && s->getRefCount() != 1) { 33 std::cerr << "The following AST Node has a refCount of " << s->getRefCount() << std::endl; 34 34 DumpAST dump(module_); 35 35 dump.pre_run(); -
trunk/rphp/compiler/analysis/passes/Lower_Binary_Op.cpp
r1030 r1034 97 97 case binaryOp::GREATER_OR_EQUAL: 98 98 case binaryOp::GREATER_THAN: 99 //TODO: file+line numbers? 99 100 return new (C_) binaryOp(n->rVal()->retain(), 100 101 n->lVal()->retain(), -
trunk/rphp/doc/phc-pass-notes.txt
r977 r1034 10 10 Constant_folding: a) we don't have a match() function in rphp b) We don't call to zend php for folding constant expressions 11 11 Remove_concat_null: Our parser shouldn't create these concats, so this issue is phc specific. 12 Desugar : - and/or renaming to && and || happens already in our parser12 Desugar *implemented Desugar* : - and/or renaming to && and || happens already in our parser 13 13 - we don't have classes yet (no need to replace self:: and parent:: yet) 14 14 - same for interfaces 15 15 - we don't store cast types as strings but as enum, so we don't have to normalize them. 16 - we already generate the same AST for return; andreturn NULL;16 - we need this to replace return; with return NULL; 17 17 - i'm unsure whether we want to transform - x to 0 - x 18 18 Split_multiple_arguments: We got a better facility to iterate over children nodes, so we don't need this imho. 19 Split_unset_isset : this one makes more sense, but we need a facility to return an expression list first (sth block-like)20 Echo_split : we definitly want this for the reason given in Echo_split.cpp, but see S-u-i...21 Early_lower_control_flow : we want this at least partially because it simplifies loop codegen later on, but we've to be19 Split_unset_isset *implemented Split_Builtins*: this one makes more sense, but we need a facility to return an expression list first (sth block-like) 20 Echo_split *implemented Split_Builtins*: we definitly want this for the reason given in Echo_split.cpp, but see S-u-i... 21 Early_lower_control_flow *implemented Early_lower_control_flow except switch and foreach!*: we want this at least partially because it simplifies loop codegen later on, but we've to be 22 22 super careful with continue. Probably the transformations by phc can be used, but we want to 23 23 sure they are optimized later if the loop body doesn't contain a continue;. 24 Lower_expr_flow : We want everything except the comma-seperated list transform. We need an EXPR_LIST anyways, i'd like24 Lower_expr_flow *implemented in Lower_Binary_Op and Lower_Conditional_Expr* and: We want everything except the comma-seperated list transform. We need an EXPR_LIST anyways, i'd like 25 25 to have one which is not binary but uses a std::vector or sth like that 26 26 List_shredder: We want this one :) … … 28 28 nearly everything. 29 29 Pre_post_op_shredder: makes sense, but is a bit more complex. 30 Switch_bin_op : should simplify codegen a bit :)30 Switch_bin_op *implented in Lower_Binary_Op*: should simplify codegen a bit :) 31 31 Remove_solo_exprs: because we don't have an Eval_expr facility, we can't really do this pass so easily as phc can. 32 32 I'm unsure whether we want to support this or not. -
trunk/rphp/frontend/cli/rphp-analyzer.cpp
r1030 r1034 36 36 37 37 #include "rphp/analysis/passes/CheckMemoryManagement.h" 38 #include "rphp/analysis/passes/Desugar.h" 38 39 #include "rphp/analysis/passes/DumpAST.h" 39 40 #include "rphp/analysis/passes/DumpStats.h" … … 62 63 cl::opt<bool> dumpAST ("dump-ast", cl::desc("Dump AST")); 63 64 cl::opt<bool> debugParse ("debug-parse", cl::desc("Debug output from parser")); 65 cl::opt<bool> runPasses ("lower", cl::desc("Lowers the AST and dumps it after lowering")); 64 66 65 67 cl::opt<std::string> passListText ("passes", cl::desc("List of passes to run")); … … 99 101 passManager.addPass<AST::Pass::DumpAST>(); 100 102 passManager.addPass<AST::Pass::DumpStats>(); 103 } 104 else if(runPasses) { 105 // make all variables etc in strings accessible to passes which need them 106 passManager.addPass<AST::Pass::SimplifyStrings>(); 101 107 passManager.addPass<AST::Pass::CheckMemoryManagement>(); 108 109 // TODO: get variable names here or use variable names which the zend engine 110 // doesn't allow for internal variables. 111 112 // uses boolean && and || 113 passManager.addPass<AST::Pass::Split_Builtins>(); 114 // uses boolean ! 115 passManager.addPass<AST::Pass::Early_Lower_Loops>(); 116 // uses conditionals 117 passManager.addPass<AST::Pass::Lower_Binary_Op>(); 118 119 passManager.addPass<AST::Pass::Lower_Conditional_Expr>(); 120 121 // do this one late in case other passes are creating return's for whatever reason... 122 passManager.addPass<AST::Pass::Desugar>(); 123 124 // debug output 125 passManager.addPass<AST::Pass::DumpAST>(); 126 passManager.addPass<AST::Pass::DumpStats>(); 102 127 } 103 128 else if (!passListText.empty()) { … … 111 136 passManager.addPass<AST::Pass::DumpAST>(); 112 137 passManager.addPass<AST::Pass::DumpStats>(); 113 passManager.addPass<AST::Pass::CheckMemoryManagement>();114 138 } 115 139 else if (*i == "simplifystrings") { 116 140 passManager.addPass<AST::Pass::SimplifyStrings>(); 117 passManager.addPass<AST::Pass::CheckMemoryManagement>();118 141 } 119 142 else if (*i == "split-builtins") { 120 143 passManager.addPass<AST::Pass::Split_Builtins>(); 121 passManager.addPass<AST::Pass::CheckMemoryManagement>();122 144 } 123 145 else if (*i == "early-lower-loops") { 124 146 passManager.addPass<AST::Pass::Early_Lower_Loops>(); 125 passManager.addPass<AST::Pass::CheckMemoryManagement>();126 147 } 127 148 else if (*i == "lower-binary-ops") { 128 149 passManager.addPass<AST::Pass::Lower_Binary_Op>(); 129 passManager.addPass<AST::Pass::CheckMemoryManagement>();130 150 } 131 151 else if (*i == "lower-conditional-exprs") { 132 152 passManager.addPass<AST::Pass::Lower_Conditional_Expr>(); 133 passManager.addPass<AST::Pass::CheckMemoryManagement>();134 153 } 135 154 } -
trunk/rphp/include/rphp/analysis/pAST.h
r1030 r1034 136 136 CLASS * retain() { stmt::retain(); return this; } 137 137 138 namespace Pass {139 class CheckMemoryManagement;140 }141 142 138 // statement base class 143 139 class stmt { … … 149 145 pUInt startLineNum_; 150 146 pUInt endLineNum_; 151 152 // We need this because we access refCount_ over there.153 friend class Pass::CheckMemoryManagement;154 147 155 148 protected: … … 203 196 ++refCount_; 204 197 return this; 198 } 199 200 pUInt getRefCount() const { 201 return refCount_; 205 202 } 206 203 … … 1107 1104 // return statement 1108 1105 class returnStmt: public stmt { 1109 1106 1110 1107 expr* rVal_; 1111 1108 … … 1127 1124 1128 1125 expr* rVal(void) { return rVal_; } 1126 void setRVal(pParseContext& C, expr* r) { if(rVal_) rVal_->destroy(C); rVal_= r; } 1129 1127 1130 1128 IMPLEMENT_SUPPORT_MEMBERS(returnStmt); -
trunk/rphp/include/rphp/analysis/pPassManager.h
r939 r1034 43 43 44 44 // no copy constructor 45 pPassManager(const pPassManager&) { }45 pPassManager(const pPassManager&); 46 46 47 47 public: … … 51 51 52 52 /// add a pass. takes ownership. 53 void addPass(AST::pPass* p) { 54 passQueue_.push_back(p); 55 } 53 void addPass(AST::pPass* p); 56 54 57 55 template <typename PassType>
