diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp index 076bf63ce160..a2e30612d32c 100644 --- a/js/src/jsdate.cpp +++ b/js/src/jsdate.cpp @@ -3199,20 +3199,3 @@ js_DateGetMsecSinceEpoch(JSContext *cx, JSObject *obj) return obj->isDate() ? obj->getDateUTCTime().toNumber() : 0; } -#ifdef JS_THREADSAFE -#include "prinrval.h" - -JS_FRIEND_API(uint32_t) -js_IntervalNow() -{ - return uint32_t(PR_IntervalToMilliseconds(PR_IntervalNow())); -} - -#else /* !JS_THREADSAFE */ - -JS_FRIEND_API(uint32_t) -js_IntervalNow() -{ - return uint32_t(PRMJ_Now() / PRMJ_USEC_PER_MSEC); -} -#endif diff --git a/js/src/jsdate.h b/js/src/jsdate.h index cad6d0a9fb10..cf0f35e804c2 100644 --- a/js/src/jsdate.h +++ b/js/src/jsdate.h @@ -83,11 +83,6 @@ js_DateGetMinutes(JSContext *cx, JSObject* obj); extern JS_FRIEND_API(int) js_DateGetSeconds(JSContext *cx, JSObject* obj); -typedef uint32_t JSIntervalTime; - -extern JS_FRIEND_API(JSIntervalTime) -js_IntervalNow(); - /* Date constructor native. Exposed only so the JIT can know its address. */ JSBool js_Date(JSContext *cx, unsigned argc, js::Value *vp); diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index bd656e00feca..f7649e6293f6 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -141,7 +141,7 @@ static PRLock *gWatchdogLock = NULL; static PRCondVar *gWatchdogWakeup = NULL; static PRThread *gWatchdogThread = NULL; static bool gWatchdogHasTimeout = false; -static PRIntervalTime gWatchdogTimeout = 0; +static int64_t gWatchdogTimeout = 0; static PRCondVar *gSleepWakeup = NULL; @@ -302,7 +302,7 @@ GetLine(FILE *file, const char * prompt) * on timing. */ struct JSShellContextData { - volatile JSIntervalTime startTime; + volatile int64_t startTime; }; static JSShellContextData * @@ -316,7 +316,7 @@ NewContextData() calloc(sizeof(JSShellContextData), 1); if (!data) return NULL; - data->startTime = js_IntervalNow(); + data->startTime = PRMJ_Now(); return data; } @@ -2790,12 +2790,11 @@ Resolver(JSContext *cx, unsigned argc, jsval *vp) /* * Check that t1 comes strictly before t2. The function correctly deals with - * PRIntervalTime wrap-around between t2 and t1 assuming that t2 and t1 stays - * within INT32_MAX from each other. We use MAX_TIMEOUT_INTERVAL to enforce - * this restriction. + * wrap-around between t2 and t1 assuming that t2 and t1 stays within INT32_MAX + * from each other. We use MAX_TIMEOUT_INTERVAL to enforce this restriction. */ static bool -IsBefore(PRIntervalTime t1, PRIntervalTime t2) +IsBefore(int64_t t1, int64_t t2) { return int32_t(t1 - t2) < 0; } @@ -2803,7 +2802,7 @@ IsBefore(PRIntervalTime t1, PRIntervalTime t2) static JSBool Sleep_fn(JSContext *cx, unsigned argc, jsval *vp) { - PRIntervalTime t_ticks; + int64_t t_ticks; if (argc == 0) { t_ticks = 0; @@ -2820,19 +2819,19 @@ Sleep_fn(JSContext *cx, unsigned argc, jsval *vp) } t_ticks = (t_secs <= 0.0) ? 0 - : PRIntervalTime(PR_TicksPerSecond() * t_secs); + : int64_t(PRMJ_USEC_PER_SEC * t_secs); } if (t_ticks == 0) { JS_YieldRequest(cx); } else { JSAutoSuspendRequest suspended(cx); PR_Lock(gWatchdogLock); - PRIntervalTime to_wakeup = PR_IntervalNow() + t_ticks; + int64_t to_wakeup = PRMJ_Now() + t_ticks; for (;;) { PR_WaitCondVar(gSleepWakeup, t_ticks); if (gCanceled) break; - PRIntervalTime now = PR_IntervalNow(); + int64_t now = PRMJ_Now(); if (!IsBefore(now, to_wakeup)) break; t_ticks = to_wakeup - now; @@ -2892,7 +2891,7 @@ WatchdogMain(void *arg) PR_Lock(gWatchdogLock); while (gWatchdogThread) { - PRIntervalTime now = PR_IntervalNow(); + int64_t now = PRMJ_Now(); if (gWatchdogHasTimeout && !IsBefore(now, gWatchdogTimeout)) { /* * The timeout has just expired. Trigger the operation callback @@ -2906,9 +2905,9 @@ WatchdogMain(void *arg) /* Wake up any threads doing sleep. */ PR_NotifyAllCondVar(gSleepWakeup); } else { - PRIntervalTime sleepDuration = gWatchdogHasTimeout - ? gWatchdogTimeout - now - : PR_INTERVAL_NO_TIMEOUT; + int64_t sleepDuration = gWatchdogHasTimeout + ? gWatchdogTimeout - now + : PR_INTERVAL_NO_TIMEOUT; DebugOnly status = PR_WaitCondVar(gWatchdogWakeup, sleepDuration); JS_ASSERT(status == PR_SUCCESS); @@ -2927,8 +2926,8 @@ ScheduleWatchdog(JSRuntime *rt, double t) return true; } - PRIntervalTime interval = PRIntervalTime(ceil(t * PR_TicksPerSecond())); - PRIntervalTime timeout = PR_IntervalNow() + interval; + int64_t interval = int64_t(ceil(t * PRMJ_USEC_PER_SEC)); + int64_t timeout = PRMJ_Now() + interval; PR_Lock(gWatchdogLock); if (!gWatchdogThread) { JS_ASSERT(!gWatchdogHasTimeout); @@ -3081,7 +3080,7 @@ Elapsed(JSContext *cx, unsigned argc, jsval *vp) double d = 0.0; JSShellContextData *data = GetContextData(cx); if (data) - d = js_IntervalNow() - data->startTime; + d = PRMJ_Now() - data->startTime; return JS_NewNumberValue(cx, d, vp); } JS_ReportError(cx, "Wrong number of arguments");