Fix incorrect assert

An assert was recently added that every local in the
origFunc was also a local in the genFunc, but its not necessarily
true. Also fix the usage to not corrupt the ActRec in this case.
Esse commit está contido em:
mwilliams
2013-07-03 14:11:04 -07:00
commit de Sara Golemon
commit 8075c39588
3 arquivos alterados com 27 adições e 14 exclusões
+11 -14
Ver Arquivo
@@ -1005,19 +1005,14 @@ void HhbcTranslator::emitCIterFree(uint32_t iterId) {
typedef std::map<int, int> ContParamMap;
/*
* mapContParams builds a mapping between named locals in origFunc and
* corresponding named locals in genFunc. If this step succeeds and
* there's no VarEnv at runtime, the continuation's variables can be
* filled completely inline in the TC (assuming there aren't too
* many).
* corresponding named locals in genFunc.
*/
static
void mapContParams(ContParamMap& map,
const Func* origFunc, const Func* genFunc) {
const StringData* const* varNames = origFunc->localNames();
for (Id i = 0; i < origFunc->numNamedLocals(); ++i) {
Id id = genFunc->lookupVarId(varNames[i]);
assert(id != kInvalidId);
map[i] = id;
map[i] = genFunc->lookupVarId(varNames[i]);
}
}
@@ -1055,13 +1050,15 @@ void HhbcTranslator::emitCreateCont(Id funNameStrId) {
SSATmp* contAR = gen(
LdRaw, Type::PtrToGen, cont, cns(RawMemSlot::ContARPtr));
for (int i = 0; i < origLocals; ++i) {
// We must generate an AssertLoc because we don't have tracelet
// guards on the object type in these outer generator functions.
gen(AssertLoc, Type::Gen, LocalId(i), m_tb->fp());
// Copy the value of the local to the cont object and set the
// local to uninit so that we don't need to change refcounts.
gen(StMem, contAR, cns(-cellsToBytes(params[i] + 1)), ldLoc(i));
gen(StLoc, LocalId(i), m_tb->fp(), m_tb->genDefUninit());
if (params[i] != kInvalidId) {
// We must generate an AssertLoc because we don't have tracelet
// guards on the object type in these outer generator functions.
gen(AssertLoc, Type::Gen, LocalId(i), m_tb->fp());
// Copy the value of the local to the cont object and set the
// local to uninit so that we don't need to change refcounts.
gen(StMem, contAR, cns(-cellsToBytes(params[i] + 1)), ldLoc(i));
gen(StLoc, LocalId(i), m_tb->fp(), m_tb->genDefUninit());
}
}
if (fillThis) {
assert(thisId != kInvalidId);
+14
Ver Arquivo
@@ -0,0 +1,14 @@
<?php
function test($a) {
$f = function() use($a) {
yield 1;
yield 2;
};
foreach ($f() as $v) {
var_dump($v);
}
}
test("unused");
+2
Ver Arquivo
@@ -0,0 +1,2 @@
int(1)
int(2)