Closed Bug 800064 Opened 12 years ago Closed 12 years ago

The watchdog time computation in JS Shell fails to properly account for units

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: nmatsakis, Unassigned)

Details

Attachments

(1 file, 4 obsolete files)

Attached patch Patch to convert units. (obsolete) — Splinter Review
This test looks infinitely but should not:

timeout(1);
var start = new Date();

while (true) {
    var end = new Date();
    var duration = (end.getTime() - start.getTime()) / 1000;
    if (duration > 1) {
        print("tick");
        start = new Date();
    }
}

The problem is that the watchdog code in the shell fails to convert into the correct NSPR interval units.
Attachment #670055 - Flags: review?(terrence)
Attachment #670055 - Attachment is patch: true
Comment on attachment 670055 [details] [diff] [review]
Patch to convert units.

Review of attachment 670055 [details] [diff] [review]:
-----------------------------------------------------------------

Bugzilla won't auto-detect patches so you have to check the |patch| checkbox when attaching a patch for the spliter review button to show up.

r=me with the nit below and a jit-test, as we discussed on IRC.

::: js/src/shell/js.cpp
@@ +2782,4 @@
>          } else {
> +             int64_t sleepDuration = gWatchdogHasTimeout
> +               ? (gWatchdogTimeout - now) / PRMJ_USEC_PER_SEC * PR_TicksPerSecond()
> +               : PR_INTERVAL_NO_TIMEOUT;

This is getting to0 long to look nice as a ternary.  Please adjust this to:
uint64_t sleepDuration = PR_INTERVAL_NO_TIMEOUT;
if (gWatchdogHasTimeout)
    sleepDuration = (gWatchdogTimeout - now) / PRMJ_USEC_PER_SEC * PR_TicksPerSecond();
Attachment #670055 - Flags: review?(terrence) → review+
Attached patch Fix bug, add a test. (obsolete) — Splinter Review
Attachment #670055 - Attachment is obsolete: true
Attachment #670108 - Flags: review?(terrence)
Comment on attachment 670108 [details] [diff] [review]
Fix bug, add a test.

Review of attachment 670108 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/shell/js.cpp
@@ +2782,4 @@
>          } else {
> +             int64_t sleepDuration = gWatchdogHasTimeout
> +               ? (gWatchdogTimeout - now) / PRMJ_USEC_PER_SEC * PR_TicksPerSecond()
> +               : PR_INTERVAL_NO_TIMEOUT;

Did you forget to hg qref?
Attached patch reformat. (obsolete) — Splinter Review
Sorry, missed your first comment about reformatting.
Attachment #670108 - Attachment is obsolete: true
Attachment #670108 - Flags: review?(terrence)
Attachment #670114 - Flags: review?(terrence)
Comment on attachment 670114 [details] [diff] [review]
reformat.

Review of attachment 670114 [details] [diff] [review]:
-----------------------------------------------------------------

Looks great!
Attachment #670114 - Flags: review?(terrence) → review+
We should get this in: I can push it for you if you'd like.
Attached patch refreshed version. (obsolete) — Splinter Review
Attachment #670114 - Attachment is obsolete: true
Terrence, just realized I forgot to add "commit-needed" to this bug (missed your comment).  I'll do that now.
Keywords: checkin-needed
Attachment #680408 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/ae03089b3ad8
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: