diff --git a/hphp/compiler/analysis/function_scope.cpp b/hphp/compiler/analysis/function_scope.cpp index 49b75513f..9bd791b1d 100644 --- a/hphp/compiler/analysis/function_scope.cpp +++ b/hphp/compiler/analysis/function_scope.cpp @@ -62,8 +62,7 @@ FunctionScope::FunctionScope(AnalysisResultConstPtr ar, bool method, m_containsThis(false), m_containsBareThis(0), m_nrvoFix(true), m_inlineAsExpr(false), m_inlineSameContext(false), m_contextSensitive(false), - m_directInvoke(false), m_needsRefTemp(false), - m_needsObjTemp(false), m_needsCheckMem(false), + m_directInvoke(false), m_closureGenerator(false), m_noLSB(false), m_nextLSB(false), m_hasTry(false), m_hasGoto(false), m_localRedeclaring(false), m_redeclaring(-1), m_inlineIndex(0), m_optFunction(0), m_nextID(0) { @@ -102,9 +101,6 @@ FunctionScope::FunctionScope(FunctionScopePtr orig, m_inlineSameContext(orig->m_inlineSameContext), m_contextSensitive(orig->m_contextSensitive), m_directInvoke(orig->m_directInvoke), - m_needsRefTemp(orig->m_needsRefTemp), - m_needsObjTemp(orig->m_needsObjTemp), - m_needsCheckMem(orig->m_needsCheckMem), m_closureGenerator(orig->m_closureGenerator), m_noLSB(orig->m_noLSB), m_nextLSB(orig->m_nextLSB), m_hasTry(orig->m_hasTry), m_hasGoto(orig->m_hasGoto), m_localRedeclaring(orig->m_localRedeclaring), @@ -203,7 +199,7 @@ FunctionScope::FunctionScope(bool method, const std::string &name, m_containsThis(false), m_containsBareThis(0), m_nrvoFix(true), m_inlineAsExpr(false), m_inlineSameContext(false), m_contextSensitive(false), - m_directInvoke(false), m_needsRefTemp(false), m_needsObjTemp(false), + m_directInvoke(false), m_closureGenerator(false), m_noLSB(false), m_nextLSB(false), m_hasTry(false), m_hasGoto(false), m_localRedeclaring(false), m_redeclaring(-1), m_inlineIndex(0), diff --git a/hphp/compiler/analysis/function_scope.h b/hphp/compiler/analysis/function_scope.h index 1c8a18030..c9ac085f5 100644 --- a/hphp/compiler/analysis/function_scope.h +++ b/hphp/compiler/analysis/function_scope.h @@ -116,12 +116,6 @@ public: bool hasGeneratorAsBody() const; MethodStatementRawPtr getOrigGenStmt() const; FunctionScopeRawPtr getOrigGenFS() const; - void setNeedsRefTemp() { m_needsRefTemp = true; } - bool needsRefTemp() const { return m_needsRefTemp; } - void setNeedsObjTemp() { m_needsObjTemp = true; } - bool needsObjTemp() const { return m_needsObjTemp; } - void setNeedsCheckMem() { m_needsCheckMem = true; } - bool needsCheckMem() const { return m_needsCheckMem; } void setClosureGenerator() { m_closureGenerator = true; } bool isClosureGenerator() const { assert(!m_closureGenerator || isClosure()); @@ -475,9 +469,6 @@ private: unsigned m_inlineSameContext : 1; unsigned m_contextSensitive : 1; unsigned m_directInvoke : 1; - unsigned m_needsRefTemp : 1; - unsigned m_needsObjTemp : 1; - unsigned m_needsCheckMem : 1; unsigned m_closureGenerator : 1; unsigned m_noLSB : 1; unsigned m_nextLSB : 1; diff --git a/hphp/compiler/expression/array_element_expression.cpp b/hphp/compiler/expression/array_element_expression.cpp index 007bb625c..4caf244dc 100644 --- a/hphp/compiler/expression/array_element_expression.cpp +++ b/hphp/compiler/expression/array_element_expression.cpp @@ -167,16 +167,6 @@ void ArrayElementExpression::analyzeProgram(AnalysisResultPtr ar) { m_variable->analyzeProgram(ar); if (m_offset) m_offset->analyzeProgram(ar); if (ar->getPhase() == AnalysisResult::AnalyzeFinal) { - if (!m_global && (m_context & AccessContext) && - !(m_context & (LValue|RefValue|DeepReference| - UnsetContext|RefParameter|InvokeArgument))) { - TypePtr type = m_variable->getActualType(); - if (!type || - (!type->is(Type::KindOfString) && !type->is(Type::KindOfArray))) { - FunctionScopePtr scope = getFunctionScope(); - if (scope && !needsCSE()) scope->setNeedsRefTemp(); - } - } if (m_global) { if (getContext() & (LValue|RefValue|DeepReference)) { setContext(NoLValueWrapper); @@ -191,8 +181,6 @@ void ArrayElementExpression::analyzeProgram(AnalysisResultPtr ar) { shared_from_this()); } } - FunctionScopePtr scope = getFunctionScope(); - if (scope) scope->setNeedsCheckMem(); } else { TypePtr at(m_variable->getActualType()); TypePtr et(m_variable->getExpectedType()); diff --git a/hphp/compiler/expression/constant_expression.cpp b/hphp/compiler/expression/constant_expression.cpp index 4422b843d..3478159ed 100644 --- a/hphp/compiler/expression/constant_expression.cpp +++ b/hphp/compiler/expression/constant_expression.cpp @@ -151,8 +151,6 @@ void ConstantExpression::analyzeProgram(AnalysisResultPtr ar) { } } else if (ar->getPhase() == AnalysisResult::AnalyzeFinal && m_dynamic) { getFileScope()->addConstantDependency(ar, m_name); - FunctionScopePtr scope = getFunctionScope(); - if (scope) scope->setNeedsCheckMem(); } } diff --git a/hphp/compiler/expression/expression.cpp b/hphp/compiler/expression/expression.cpp index 13a809f4b..7a117c952 100644 --- a/hphp/compiler/expression/expression.cpp +++ b/hphp/compiler/expression/expression.cpp @@ -858,59 +858,3 @@ bool Expression::getTypeCastPtrs( return dstType && srcType && ((m_context & LValue) == 0) && Type::IsCastNeeded(ar, srcType, dstType); } - -bool Expression::needsFastCastTemp(AnalysisResultPtr ar) { - if (is(KindOfSimpleVariable)) return false; - if (!canUseFastCast(ar)) return false; - if (hasAnyContext(ExistContext|AccessContext) && - (is(KindOfObjectPropertyExpression) || - is(KindOfArrayElementExpression))) { - return false; - } - assert(m_actualType); - return !m_actualType->isPrimitive(); -} - -bool Expression::couldCppTypeBeReferenced() { - if (is(KindOfDynamicVariable)) return true; - SimpleVariablePtr p( - dynamic_pointer_cast( - shared_from_this())); - BlockScopeRawPtr scope(getScope()); - VariableTablePtr vt(scope ? scope->getVariables() : VariableTablePtr()); - // a simple variable could have its CPP type referenced if: - // it could be aliased or, - // it is a non-lval parameter or, - // the scope it lives in has a dynamic variable or contains extract() - // note that we default to true (the conservative case) if no symbol - // or variable table is found - return p ? - (p->couldBeAliased() || - (!p->getSymbol() || - (p->getSymbol()->isParameter() && !p->getSymbol()->isLvalParam())) || - (!vt || (vt->getAttribute(VariableTable::ContainsDynamicVariable) || - vt->getAttribute(VariableTable::ContainsExtract)))) : - !isTemporary(); -} - -bool Expression::canUseFastCast(AnalysisResultPtr ar) { - TypePtr srcType, dstType; - getTypeCastPtrs(ar, srcType, dstType); - // if the impl type is Variant and the actual type is known - // with a fast cast method, and we have a dst type that - // is not Variant (in CPP), then we have something to benefit - // from doing a fast cast and should emit one. - if (m_implementedType && - Type::IsMappedToVariant(m_implementedType) && - m_actualType && - Type::HasFastCastMethod(m_actualType) && - dstType && - !Type::IsMappedToVariant(dstType)) { - if (m_assertedType) return true; - if (is(KindOfSimpleVariable) && - static_cast(this)->isGuarded()) { - return true; - } - } - return false; -} diff --git a/hphp/compiler/expression/expression.h b/hphp/compiler/expression/expression.h index 40b1ea0be..d850fd0ed 100644 --- a/hphp/compiler/expression/expression.h +++ b/hphp/compiler/expression/expression.h @@ -189,10 +189,7 @@ public: void collectCPPTemps(ExpressionPtrVec &collection); void disableCSE(); bool hasChainRoots(); - bool hasCPPTemp() const { return !m_cppTemp.empty(); } - const std::string &cppTemp() const { return m_cppTemp; } std::string genCPPTemp(CodeGenerator &cg, AnalysisResultPtr ar); - void setCPPTemp(const std::string &s) { m_cppTemp = s; } BlockScopeRawPtr getOriginalScope(); void setOriginalScope(BlockScopeRawPtr scope); ClassScopeRawPtr getOriginalClass(); @@ -223,10 +220,6 @@ public: } ExpressionPtr getNextCanonCsePtr() const; ExpressionPtr getCanonCsePtr() const; - bool needsCSE() const { - ExpressionPtr p(getCanonCsePtr()); - return p && p->hasCPPCseTemp(); - } ExpressionPtr getCanonTypeInfPtr() const; /** @@ -397,10 +390,6 @@ protected: TypePtr m_expectedType; // null if the same as m_actualType TypePtr m_implementedType; // null if the same as m_actualType TypePtr m_assertedType; - std::string m_cppTemp; - std::string m_cppCseTemp; - - bool hasCPPCseTemp() const { return !m_cppCseTemp.empty(); } TypePtr inferAssignmentTypes(AnalysisResultPtr ar, TypePtr type, bool coerce, ExpressionPtr variable, @@ -419,10 +408,6 @@ protected: bool getTypeCastPtrs( AnalysisResultPtr ar, TypePtr &srcType, TypePtr &dstType); - bool couldCppTypeBeReferenced(); - bool needsFastCastTemp(AnalysisResultPtr ar); - bool canUseFastCast(AnalysisResultPtr ar); - BlockScopeRawPtr m_originalScope; ExpressionPtr m_canonPtr; ExpressionPtr m_replacement; diff --git a/hphp/compiler/expression/function_call.cpp b/hphp/compiler/expression/function_call.cpp index d478af1a0..fac1b8e64 100644 --- a/hphp/compiler/expression/function_call.cpp +++ b/hphp/compiler/expression/function_call.cpp @@ -204,10 +204,6 @@ void FunctionCall::analyzeProgram(AnalysisResultPtr ar) { } } } - if (getContext() & RefValue) { - FunctionScopePtr fs = getFunctionScope(); - if (fs) fs->setNeedsCheckMem(); - } } } diff --git a/hphp/compiler/expression/object_property_expression.cpp b/hphp/compiler/expression/object_property_expression.cpp index 114116f1f..54e9eb7e3 100644 --- a/hphp/compiler/expression/object_property_expression.cpp +++ b/hphp/compiler/expression/object_property_expression.cpp @@ -150,16 +150,6 @@ void ObjectPropertyExpression::analyzeProgram(AnalysisResultPtr ar) { !static_pointer_cast(m_object)->isGuarded())) { setLocalEffect(DiagnosticEffect); } - if (FunctionScopePtr func = getFunctionScope()) { - if (!m_valid && - m_context & (LValue|RefValue|DeepReference|UnsetContext)) { - func->setNeedsRefTemp(); - } - if (getContext() & (RefValue | AssignmentLHS | OprLValue)) { - func->setNeedsCheckMem(); - } - if (m_valid) func->setNeedsObjTemp(); - } } } diff --git a/hphp/compiler/expression/parameter_expression.cpp b/hphp/compiler/expression/parameter_expression.cpp index d3ad6502c..75318d56d 100644 --- a/hphp/compiler/expression/parameter_expression.cpp +++ b/hphp/compiler/expression/parameter_expression.cpp @@ -89,7 +89,6 @@ void ParameterExpression::analyzeProgram(AnalysisResultPtr ar) { if (fs->isMagicMethod() || fs->getName() == "offsetget") { fs->getVariables()->addLvalParam(m_name); } - if (m_ref) fs->setNeedsCheckMem(); } } diff --git a/hphp/compiler/expression/qop_expression.h b/hphp/compiler/expression/qop_expression.h index 0a73a32c2..e37a76b98 100644 --- a/hphp/compiler/expression/qop_expression.h +++ b/hphp/compiler/expression/qop_expression.h @@ -43,10 +43,6 @@ private: ExpressionPtr m_condition; ExpressionPtr m_expYes; ExpressionPtr m_expNo; - // we use this, rather than m_cppTemp, because the result - // may need explicit casting, and m_cppTemp is assumed to - // already have been cast. - std::string m_cppValue; }; /////////////////////////////////////////////////////////////////////////////// diff --git a/hphp/compiler/expression/simple_variable.cpp b/hphp/compiler/expression/simple_variable.cpp index 4cbd1b43d..e8e2f0a30 100644 --- a/hphp/compiler/expression/simple_variable.cpp +++ b/hphp/compiler/expression/simple_variable.cpp @@ -192,10 +192,6 @@ void SimpleVariable::analyzeProgram(AnalysisResultPtr ar) { m_sym->setLvalParam(); } } - if (m_superGlobal || m_name == "GLOBALS") { - FunctionScopePtr func = getFunctionScope(); - if (func) func->setNeedsCheckMem(); - } } } diff --git a/hphp/compiler/expression/static_member_expression.cpp b/hphp/compiler/expression/static_member_expression.cpp index 733d9a4c0..0818729b5 100644 --- a/hphp/compiler/expression/static_member_expression.cpp +++ b/hphp/compiler/expression/static_member_expression.cpp @@ -115,10 +115,6 @@ void StaticMemberExpression::analyzeProgram(AnalysisResultPtr ar) { addUserClass(ar, m_className); } m_exp->analyzeProgram(ar); - if (ar->getPhase() >= AnalysisResult::AnalyzeFinal) { - FunctionScopePtr fs = getFunctionScope(); - if (fs) fs->setNeedsCheckMem(); - } } ConstructPtr StaticMemberExpression::getNthKid(int n) const { diff --git a/hphp/compiler/statement/global_statement.cpp b/hphp/compiler/statement/global_statement.cpp index 4e5fd05a7..b168c9120 100644 --- a/hphp/compiler/statement/global_statement.cpp +++ b/hphp/compiler/statement/global_statement.cpp @@ -62,10 +62,6 @@ StatementPtr GlobalStatement::clone() { void GlobalStatement::analyzeProgram(AnalysisResultPtr ar) { m_exp->analyzeProgram(ar); - if (ar->getPhase() == AnalysisResult::AnalyzeFinal) { - FunctionScopePtr fs = getFunctionScope(); - if (fs) fs->setNeedsCheckMem(); - } } ConstructPtr GlobalStatement::getNthKid(int n) const { diff --git a/hphp/compiler/statement/return_statement.cpp b/hphp/compiler/statement/return_statement.cpp index f0b75b51a..1ec4809ab 100644 --- a/hphp/compiler/statement/return_statement.cpp +++ b/hphp/compiler/statement/return_statement.cpp @@ -59,48 +59,6 @@ void ReturnStatement::analyzeProgram(AnalysisResultPtr ar) { } m_exp->analyzeProgram(ar); } - if (ar->getPhase() == AnalysisResult::AnalyzeFinal) { - if (m_exp) { - TypePtr retType = m_exp->getCPPType(); - bool needsCheck = !retType->isPrimitive(); - if (m_exp->is(Expression::KindOfSimpleFunctionCall) || - m_exp->is(Expression::KindOfDynamicFunctionCall) || - m_exp->is(Expression::KindOfObjectMethodExpression)) { - // return a value from another function call - needsCheck = false; - } - ExpressionPtr tmp = m_exp; - while (tmp && - (tmp->is(Expression::KindOfObjectPropertyExpression) || - tmp->is(Expression::KindOfArrayElementExpression))) { - if (ObjectPropertyExpressionPtr opExp = - dynamic_pointer_cast(tmp)) { - tmp = opExp->getObject(); - } else { - ArrayElementExpressionPtr aeExp = - dynamic_pointer_cast(tmp); - assert(aeExp); - tmp = aeExp->getVariable(); - } - } - if (SimpleVariablePtr svExp = dynamic_pointer_cast(tmp)) { - if (svExp->isThis()) { - // returning something from $this - needsCheck = false; - } else { - Symbol *sym = svExp->getSymbol(); - if (sym && sym->isParameter() && !sym->isLvalParam()) { - // returning something from non-lval parameter - needsCheck = false; - } - } - } - if (needsCheck) { - FunctionScopePtr funcScope = getFunctionScope(); - if (funcScope) funcScope->setNeedsCheckMem(); - } - } - } } ConstructPtr ReturnStatement::getNthKid(int n) const { diff --git a/hphp/compiler/statement/static_statement.cpp b/hphp/compiler/statement/static_statement.cpp index 0bb0167ff..067cfd059 100644 --- a/hphp/compiler/statement/static_statement.cpp +++ b/hphp/compiler/statement/static_statement.cpp @@ -79,9 +79,6 @@ void StaticStatement::analyzeProgram(AnalysisResultPtr ar) { Symbol *sym = var->getSymbol(); sym->setStaticInitVal(value); } - } else if (ar->getPhase() == AnalysisResult::AnalyzeFinal) { - FunctionScopePtr fs = getFunctionScope(); - if (fs) fs->setNeedsCheckMem(); } }