Kill needs{ObjTemp,RefTemp,CheckMem} and cppTemp
Esse commit está contido em:
@@ -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),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<SimpleVariable>(
|
||||
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<SimpleVariable*>(this)->isGuarded()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -204,10 +204,6 @@ void FunctionCall::analyzeProgram(AnalysisResultPtr ar) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getContext() & RefValue) {
|
||||
FunctionScopePtr fs = getFunctionScope();
|
||||
if (fs) fs->setNeedsCheckMem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,16 +150,6 @@ void ObjectPropertyExpression::analyzeProgram(AnalysisResultPtr ar) {
|
||||
!static_pointer_cast<SimpleVariable>(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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<ObjectPropertyExpression>(tmp)) {
|
||||
tmp = opExp->getObject();
|
||||
} else {
|
||||
ArrayElementExpressionPtr aeExp =
|
||||
dynamic_pointer_cast<ArrayElementExpression>(tmp);
|
||||
assert(aeExp);
|
||||
tmp = aeExp->getVariable();
|
||||
}
|
||||
}
|
||||
if (SimpleVariablePtr svExp = dynamic_pointer_cast<SimpleVariable>(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 {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário