Bug 1434979 - LCovSource::writeScripts mini-bug with odd source notes. r=nbp.

Before this patch, we would only ever add hits on instructions that have source
notes. That is usually right, because that's the only time the line number
changes.

But at the start of a script, this makes us skip instructions until we reach
one with source notes. This interacts badly with SRC_XDELTA notes, which can
appear on any instruction, or even between instructions, because all it means
is "bump the source note pc". So "skip instructions until we see source notes"
is nondeterministic because of SRC_XDELTA's meaninglessness.

The fix is to add hits on the first non-prologue instruction of a script, as
well as instructions that have source notes.

--HG--
extra : rebase_source : be93186c27bfe290fbaaf3dcd2915f26d93f1381
This commit is contained in:
Jason Orendorff 2018-02-01 12:29:19 -06:00
Родитель 766ff2211c
Коммит e4cbeaac1b
1 изменённых файлов: 5 добавлений и 5 удалений

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

@ -198,11 +198,8 @@ LCovSource::writeScript(JSScript* script)
// If we have additional source notes, walk all the source notes of the
// current pc.
if (snpc <= pc) {
if (snpc <= pc || !firstLineHasBeenWritten) {
size_t oldLine = lineno;
// Without this check, we'll never write the script's first line
if (lineno == script->lineno() && !firstLineHasBeenWritten)
oldLine = 0;
while (!SN_IS_TERMINATOR(sn) && snpc <= pc) {
SrcNoteType type = SN_TYPE(sn);
if (type == SRC_SETLINE)
@ -216,7 +213,10 @@ LCovSource::writeScript(JSScript* script)
snpc += SN_DELTA(sn);
}
if (oldLine != lineno && fallsthrough) {
if ((oldLine != lineno || !firstLineHasBeenWritten) &&
pc >= script->main() &&
fallsthrough)
{
auto p = linesHit_.lookupForAdd(lineno);
if (!p) {
if (!linesHit_.add(p, lineno, hits))