Bug 1362403 - update source coordinates after emitting loop bodies; r=jimb

MozReview-Commit-ID: CEJV2nSvg24

--HG--
extra : rebase_source : d607b725e4841233e176c639a8ec5c42ca7e86b4
This commit is contained in:
Tom Tromey 2017-05-05 11:50:56 -06:00
Родитель 7d9e71c048
Коммит 2e878c27aa
2 изменённых файлов: 39 добавлений и 0 удалений

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

@ -7280,6 +7280,10 @@ BytecodeEmitter::emitForOf(ParseNode* forOfLoop, EmitterScope* headLexicalEmitte
auto loopDepth = this->stackDepth;
#endif
// Make sure this code is attributed to the "for".
if (!updateSourceCoordNotes(forOfHead->pn_pos.begin))
return false;
if (!emit1(JSOP_POP)) // ITER
return false;
if (!emit1(JSOP_DUP)) // ITER ITER
@ -7488,6 +7492,10 @@ BytecodeEmitter::emitForIn(ParseNode* forInLoop, EmitterScope* headLexicalEmitte
// Set offset for continues.
loopInfo.continueTarget = { offset() };
// Make sure this code is attributed to the "for".
if (!updateSourceCoordNotes(forInHead->pn_pos.begin))
return false;
if (!emitLoopEntry(nullptr, initialJump)) // ITER ITERVAL
return false;
if (!emit1(JSOP_POP)) // ITER

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

@ -0,0 +1,31 @@
var g = newGlobal();
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
var log;
var previous;
dbg.onDebuggerStatement = function (frame) {
let debugLine = frame.script.getOffsetLocation(frame.offset).lineNumber;
log = '';
previous = '';
frame.onStep = function() {
let foundLine = this.script.getOffsetLocation(this.offset).lineNumber;
if (this.script.getLineOffsets(foundLine).indexOf(this.offset) >= 0) {
let thisline = (foundLine - debugLine).toString(16);
if (thisline !== previous) {
log += thisline;
previous = thisline;
}
}
};
};
function testOne(loopKind) {
let body = "var array = [2, 4, 6];\ndebugger;\nfor (let iter " +
loopKind + " array) {\n print(iter);\n}\n";
g.eval(body);
assertEq(log, "12121212");
}
testOne("in");
testOne("of");