Fix js_LineNumberToPC based on MikeM@RetekSolutions.com's input (313922, r=mrbkap).
authorbrendan@mozilla.org
Mon, 02 Apr 2007 11:13:22 -0700
changeset 267 ff68b34b6a9d25e0a4bb9989cf346505598f1c93
parent 266 36d3af60c2f136f02c9301729b16889db20ebdfb
child 268 b1c0a468cbc80b6e34aaac5ba2c90ff6eef8e160
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs313922
milestone1.9a4pre
Fix js_LineNumberToPC based on MikeM@RetekSolutions.com's input (313922, r=mrbkap).
js/src/jsscript.c
--- a/js/src/jsscript.c
+++ b/js/src/jsscript.c
@@ -1627,19 +1627,23 @@ js_LineNumberToPC(JSScript *script, uint
     jssrcnote *sn;
     JSSrcNoteType type;
 
     offset = 0;
     best = -1;
     lineno = script->lineno;
     bestdiff = SN_LINE_LIMIT;
     for (sn = SCRIPT_NOTES(script); !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) {
-        if (lineno == target)
+        /*
+         * Exact-match only if offset is not in the prolog; otherwise use
+         * nearest greater-or-equal line number match.
+         */
+        if (lineno == target && script->code + offset >= script->main)
             goto out;
-        if (lineno > target) {
+        if (lineno >= target) {
             diff = lineno - target;
             if (diff < bestdiff) {
                 bestdiff = diff;
                 best = offset;
             }
         }
         offset += SN_DELTA(sn);
         type = (JSSrcNoteType) SN_TYPE(sn);