Bug 1185961 - Properly install home object on methods in classes in lazy scripts. (r=shu)

This commit is contained in:
Eric Faust 2015-08-19 11:19:46 -07:00
Родитель 240506f142
Коммит 49aef6b263
3 изменённых файлов: 38 добавлений и 1 удалений

Просмотреть файл

@ -2075,6 +2075,9 @@ Parser<FullParseHandler>::checkFunctionDefinition(HandlePropertyName funName,
if (!funbox) if (!funbox)
return false; return false;
if (fun->lazyScript()->needsHomeObject())
funbox->setNeedsHomeObject();
if (!addFreeVariablesFromLazyFunction(fun, pc)) if (!addFreeVariablesFromLazyFunction(fun, pc))
return false; return false;
@ -2395,6 +2398,8 @@ Parser<SyntaxParseHandler>::finishFunctionDefinition(Node pn, FunctionBox* funbo
lazy->setUsesArgumentsApplyAndThis(); lazy->setUsesArgumentsApplyAndThis();
if (funbox->isDerivedClassConstructor()) if (funbox->isDerivedClassConstructor())
lazy->setIsDerivedClassConstructor(); lazy->setIsDerivedClassConstructor();
if (funbox->needsHomeObject())
lazy->setNeedsHomeObject();
PropagateTransitiveParseFlags(funbox, lazy); PropagateTransitiveParseFlags(funbox, lazy);
fun->initLazyScript(lazy); fun->initLazyScript(lazy);

Просмотреть файл

@ -2053,7 +2053,7 @@ class LazyScript : public gc::TenuredCell
uint32_t version : 8; uint32_t version : 8;
uint32_t numFreeVariables : 24; uint32_t numFreeVariables : 24;
uint32_t numInnerFunctions : 21; uint32_t numInnerFunctions : 20;
uint32_t generatorKindBits : 2; uint32_t generatorKindBits : 2;
@ -2069,6 +2069,7 @@ class LazyScript : public gc::TenuredCell
uint32_t hasBeenCloned : 1; uint32_t hasBeenCloned : 1;
uint32_t treatAsRunOnce : 1; uint32_t treatAsRunOnce : 1;
uint32_t isDerivedClassConstructor : 1; uint32_t isDerivedClassConstructor : 1;
uint32_t needsHomeObject : 1;
}; };
union { union {
@ -2247,6 +2248,13 @@ class LazyScript : public gc::TenuredCell
p_.isDerivedClassConstructor = true; p_.isDerivedClassConstructor = true;
} }
bool needsHomeObject() const {
return p_.needsHomeObject;
}
void setNeedsHomeObject() {
p_.needsHomeObject = true;
}
const char* filename() const { const char* filename() const {
return scriptSource()->filename(); return scriptSource()->filename();
} }

Просмотреть файл

@ -0,0 +1,24 @@
var test = `
testcase();
function testcase() {
var tokenCodes = {
get try() {
try {
super.actual();
} catch (e) {}
}
};
var arr = [
'try',
];
for (var i = 0; i < arr.length; i++) {
if (tokenCodes[arr[i]] !== i) {};
}
}
`;
if (classesEnabled())
eval(test);
if (typeof reportCompare === 'function')
reportCompare(0,0,"OK");