Fewer varEnvs in generators
If the original function has a variable that the generator does not, we create a varenv. Its not clear that that should ever happen, but it *was* happening because: - closures get a magic variable called 0Closure, but generators from closures did not. - unused parameters didnt get put into the variable table, so generators with unused parameters got a varenv
Esse commit está contido em:
@@ -5319,15 +5319,17 @@ void EmitterVisitor::emitPostponedMeths() {
|
||||
|
||||
m_curFunc = fe;
|
||||
|
||||
if (fe->isClosureBody()) {
|
||||
if (fe->isClosureBody() || fe->isGeneratorFromClosure()) {
|
||||
// We are going to keep the closure as the first local
|
||||
fe->allocVarId(StringData::GetStaticString("0Closure"));
|
||||
|
||||
ClosureUseVarVec* useVars = p.m_closureUseVars;
|
||||
for (auto& useVar : *useVars) {
|
||||
// These are all locals. I want them right after the params so I don't
|
||||
// have to keep track of which one goes where at runtime.
|
||||
fe->allocVarId(useVar.first);
|
||||
if (fe->isClosureBody()) {
|
||||
ClosureUseVarVec* useVars = p.m_closureUseVars;
|
||||
for (auto& useVar : *useVars) {
|
||||
// These are all locals. I want them right after the params so I don't
|
||||
// have to keep track of which one goes where at runtime.
|
||||
fe->allocVarId(useVar.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "hphp/runtime/base/complex_types.h"
|
||||
|
||||
#include "hphp/compiler/statement/method_statement.h"
|
||||
#include "hphp/compiler/statement/return_statement.h"
|
||||
#include "hphp/compiler/statement/statement_list.h"
|
||||
@@ -47,6 +45,8 @@
|
||||
#include "hphp/compiler/builtin_symbols.h"
|
||||
#include "hphp/compiler/analysis/alias_manager.h"
|
||||
|
||||
#include "hphp/runtime/base/complex_types.h"
|
||||
|
||||
#include "hphp/util/parser/parser.h"
|
||||
#include "hphp/util/util.h"
|
||||
|
||||
@@ -389,8 +389,7 @@ void MethodStatement::analyzeProgram(AnalysisResultPtr ar) {
|
||||
if (ExpressionListPtr params = orig->getParams()) {
|
||||
for (int i = 0; i < params->getCount(); ++i) {
|
||||
auto param = dynamic_pointer_cast<ParameterExpression>((*params)[i]);
|
||||
Symbol *gp = variables->addDeclaredSymbol(
|
||||
param->getName(), ConstructPtr());
|
||||
Symbol *gp = variables->addDeclaredSymbol(param->getName(), param);
|
||||
gp->setGeneratorParameter();
|
||||
if (param->isRef()) {
|
||||
gp->setRefGeneratorParameter();
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário