From 7fbaee454d72a49fe9ff8b6ef9997dc7316688e5 Mon Sep 17 00:00:00 2001 From: mwilliams Date: Tue, 13 Sep 2011 18:23:43 -0700 Subject: [PATCH] [Perf] Better type inference Summary: forceVariants was being called over-agressively. Test Plan: fast_tests slow_tests Reviewers: myang, qigao Reviewed By: myang CC: ps, mwilliams, myang Differential Revision: 330610 --- src/compiler/analysis/class_scope.cpp | 6 ++++-- src/compiler/analysis/variable_table.cpp | 2 +- src/compiler/expression/static_member_expression.cpp | 13 ++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/compiler/analysis/class_scope.cpp b/src/compiler/analysis/class_scope.cpp index f55db48e456..79d42849571 100644 --- a/src/compiler/analysis/class_scope.cpp +++ b/src/compiler/analysis/class_scope.cpp @@ -286,9 +286,12 @@ void ClassScope::collectMethods(AnalysisResultPtr ar, cls->collectMethods(ar, cur, false, forInvoke); inheritedMagicMethods(cls); funcs.insert(cur.begin(), cur.end()); + cls->getVariables()-> + forceVariants(ar, VariableTable::AnyNonPrivateVars); } m_derivesFromRedeclaring = DirectFromRedeclared; - getVariables()->forceVariants(ar, VariableTable::AnyNonPrivateVars); + getVariables()->forceVariants(ar, VariableTable::AnyNonPrivateVars, + false); getVariables()->setAttribute(VariableTable::NeedGlobalPointer); } else if (isInterface()) { m_derivesFromRedeclaring = DirectFromRedeclared; @@ -2342,7 +2345,6 @@ void ClassScope::setRedeclaring(AnalysisResultConstPtr ar, int redecId) { m_functionsVec.begin(); iter != m_functionsVec.end(); ++iter) { (*iter)->setDynamic(); } - m_variables->forceVariants(ar, VariableTable::AnyNonPrivateVars); } ClassScopePtr ClassScope::getRootParent(AnalysisResultConstPtr ar, diff --git a/src/compiler/analysis/variable_table.cpp b/src/compiler/analysis/variable_table.cpp index 3c6a2152f99..ce186c91cff 100644 --- a/src/compiler/analysis/variable_table.cpp +++ b/src/compiler/analysis/variable_table.cpp @@ -629,7 +629,7 @@ void VariableTable::forceVariants(AnalysisResultConstPtr ar, int varClass, if (recur) { ClassScopePtr parent = m_blockScope.getParentScope(ar); - if (parent) { + if (parent && !parent->isRedeclaring()) { parent->getVariables()->forceVariants(ar, varClass & ~AnyPrivateVars); } } diff --git a/src/compiler/expression/static_member_expression.cpp b/src/compiler/expression/static_member_expression.cpp index 5ab53b1d195..c23d44f6501 100644 --- a/src/compiler/expression/static_member_expression.cpp +++ b/src/compiler/expression/static_member_expression.cpp @@ -251,13 +251,12 @@ TypePtr StaticMemberExpression::inferTypes(AnalysisResultPtr ar, if (sym && sym->isStatic()) { { GET_LOCK(clsr); - clsr->checkProperty(getScope(), sym, type, coerce, ar); - } - if (modified) { - // concurrent modifications here are OK because: - // 1) you never clear the bit (you only set it to true) - // 2) the value isn't read in type inference - sym->setIndirectAltered(); + if (modified) { + sym->setType(ar, getScope(), Type::Variant, true); + sym->setIndirectAltered(); + } else { + clsr->checkProperty(getScope(), sym, type, coerce, ar); + } } found = true; } -- 2.11.4.GIT