Bug 1455179: Support destructuring with default values in undefined property detection checks. r=nbp

MozReview-Commit-ID: O5sCGmjJxA

--HG--
extra : rebase_source : 08953a75afb6fe84cf52cf3f7772b35bd1a3a78a
This commit is contained in:
Kris Maglione 2018-04-18 18:36:57 -07:00
parent 06862eb744
commit 36ffd6d271

View File

@ -2251,8 +2251,9 @@ Detecting(JSContext* cx, JSScript* script, jsbytecode* pc)
{
MOZ_ASSERT(script->containsPC(pc));
// Skip jump target opcodes.
while (pc < script->codeEnd() && BytecodeIsJumpTarget(JSOp(*pc)))
// Skip jump target and dup opcodes.
while (pc < script->codeEnd() && (BytecodeIsJumpTarget(JSOp(*pc)) ||
JSOp(*pc) == JSOP_DUP))
pc = GetNextPc(pc);
MOZ_ASSERT(script->containsPC(pc));
@ -2275,8 +2276,8 @@ Detecting(JSContext* cx, JSScript* script, jsbytecode* pc)
return false;
}
// Special case #2: don't warn about (obj.prop == undefined).
if (op == JSOP_GETGNAME || op == JSOP_GETNAME) {
// Special case #2: don't warn about (obj.prop == undefined).
JSAtom* atom = script->getAtom(GET_UINT32_INDEX(pc));
if (atom == cx->names().undefined &&
(pc += CodeSpec[op].length) < endpc) {
@ -2284,6 +2285,12 @@ Detecting(JSContext* cx, JSScript* script, jsbytecode* pc)
return op == JSOP_EQ || op == JSOP_NE || op == JSOP_STRICTEQ || op == JSOP_STRICTNE;
}
}
if (op == JSOP_UNDEFINED) {
if ((pc += CodeSpec[op].length) < endpc) {
op = JSOp(*pc);
return op == JSOP_EQ || op == JSOP_NE || op == JSOP_STRICTEQ || op == JSOP_STRICTNE;
}
}
return false;
}