Bug 793076 (part 1) - Remove unnecessary |cx| parameters. r=jwalden.

This commit is contained in:
Nicholas Nethercote
2012-09-20 21:41:49 -07:00
parent 8e971dbb47
commit 23ab1e42a2
12 changed files with 45 additions and 46 deletions

View File

@@ -2005,8 +2005,8 @@ ExtractDateFromOptions(JSContext* aCx, const JS::Value& aOptions)
nsresult rv = params.Init(aCx, &aOptions); nsresult rv = params.Init(aCx, &aOptions);
if (NS_SUCCEEDED(rv) && !JSVAL_IS_VOID(params.since) && !params.since.isNull() && params.since.isObject()) { if (NS_SUCCEEDED(rv) && !JSVAL_IS_VOID(params.since) && !params.since.isNull() && params.since.isObject()) {
JSObject* obj = JSVAL_TO_OBJECT(params.since); JSObject* obj = JSVAL_TO_OBJECT(params.since);
if (JS_ObjectIsDate(aCx, obj) && js_DateIsValid(aCx, obj)) { if (JS_ObjectIsDate(aCx, obj) && js_DateIsValid(obj)) {
result = js_DateGetMsecSinceEpoch(aCx, obj); result = js_DateGetMsecSinceEpoch(obj);
} }
} }
} }

View File

@@ -170,10 +170,10 @@ Key::EncodeJSValInternal(JSContext* aCx, const jsval aVal,
} }
if (JS_ObjectIsDate(aCx, obj)) { if (JS_ObjectIsDate(aCx, obj)) {
if (!js_DateIsValid(aCx, obj)) { if (!js_DateIsValid(obj)) {
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
} }
EncodeNumber(js_DateGetMsecSinceEpoch(aCx, obj), eDate + aTypeOffset); EncodeNumber(js_DateGetMsecSinceEpoch(obj), eDate + aTypeOffset);
return NS_OK; return NS_OK;
} }
} }

View File

@@ -80,7 +80,7 @@ SmsFilter::SetStartDate(JSContext* aCx, const jsval& aStartDate)
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
mData.startDate() = js_DateGetMsecSinceEpoch(aCx, &obj); mData.startDate() = js_DateGetMsecSinceEpoch(&obj);
return NS_OK; return NS_OK;
} }
@@ -115,7 +115,7 @@ SmsFilter::SetEndDate(JSContext* aCx, const jsval& aEndDate)
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
mData.endDate() = js_DateGetMsecSinceEpoch(aCx, &obj); mData.endDate() = js_DateGetMsecSinceEpoch(&obj);
return NS_OK; return NS_OK;
} }

View File

@@ -72,7 +72,7 @@ SmsMessage::Create(int32_t aId,
if (!JS_ObjectIsDate(aCx, &obj)) { if (!JS_ObjectIsDate(aCx, &obj)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
data.timestamp() = js_DateGetMsecSinceEpoch(aCx, &obj); data.timestamp() = js_DateGetMsecSinceEpoch(&obj);
} else { } else {
if (!aTimestamp.isNumber()) { if (!aTimestamp.isNumber()) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;

View File

@@ -29,12 +29,12 @@ TimeManager::Set(const JS::Value& date, JSContext* ctx) {
if (date.isObject()) { if (date.isObject()) {
JSObject* dateObj = JSVAL_TO_OBJECT(date); JSObject* dateObj = JSVAL_TO_OBJECT(date);
if (JS_ObjectIsDate(ctx, dateObj) && js_DateIsValid(ctx, dateObj)) { if (JS_ObjectIsDate(ctx, dateObj) && js_DateIsValid(dateObj)) {
dateMSec = js_DateGetMsecSinceEpoch(ctx, dateObj); dateMSec = js_DateGetMsecSinceEpoch(dateObj);
} }
else { else {
NS_WARN_IF_FALSE(JS_ObjectIsDate(ctx, dateObj), "This is not a Date object"); NS_WARN_IF_FALSE(JS_ObjectIsDate(ctx, dateObj), "This is not a Date object");
NS_WARN_IF_FALSE(js_DateIsValid(ctx, dateObj), "Date is not valid"); NS_WARN_IF_FALSE(js_DateIsValid(dateObj), "Date is not valid");
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
} else if (date.isNumber()) { } else if (date.isNumber()) {

View File

@@ -686,7 +686,7 @@ JSStructuredCloneWriter::startWrite(const Value &v)
return out.writePair(SCTAG_REGEXP_OBJECT, reobj.getFlags()) && return out.writePair(SCTAG_REGEXP_OBJECT, reobj.getFlags()) &&
writeString(SCTAG_STRING, reobj.getSource()); writeString(SCTAG_STRING, reobj.getSource());
} else if (obj->isDate()) { } else if (obj->isDate()) {
double d = js_DateGetMsecSinceEpoch(context(), obj); double d = js_DateGetMsecSinceEpoch(obj);
return out.writePair(SCTAG_DATE_OBJECT, 0) && out.writeDouble(d); return out.writePair(SCTAG_DATE_OBJECT, 0) && out.writeDouble(d);
} else if (obj->isTypedArray()) { } else if (obj->isTypedArray()) {
return writeTypedArray(obj); return writeTypedArray(obj);

View File

@@ -437,7 +437,7 @@ DaylightSavingTA(double t, JSContext *cx)
} }
int64_t timeMilliseconds = static_cast<int64_t>(t); int64_t timeMilliseconds = static_cast<int64_t>(t);
int64_t offsetMilliseconds = cx->dstOffsetCache.getDSTOffsetMilliseconds(timeMilliseconds, cx); int64_t offsetMilliseconds = cx->dstOffsetCache.getDSTOffsetMilliseconds(timeMilliseconds);
return static_cast<double>(offsetMilliseconds); return static_cast<double>(offsetMilliseconds);
} }
@@ -1265,7 +1265,7 @@ date_now(JSContext *cx, unsigned argc, Value *vp)
* Set UTC time to a given time and invalidate cached local time. * Set UTC time to a given time and invalidate cached local time.
*/ */
static JSBool static JSBool
SetUTCTime(JSContext *cx, JSObject *obj, double t, Value *vp = NULL) SetUTCTime(JSObject *obj, double t, Value *vp = NULL)
{ {
JS_ASSERT(obj->isDate()); JS_ASSERT(obj->isDate());
@@ -1282,10 +1282,9 @@ SetUTCTime(JSContext *cx, JSObject *obj, double t, Value *vp = NULL)
} }
static void static void
SetDateToNaN(JSContext *cx, JSObject *obj, Value *vp = NULL) SetDateToNaN(JSObject *obj, Value *vp = NULL)
{ {
double NaN = cx->runtime->NaNValue.getDoubleRef(); SetUTCTime(obj, js_NaN, vp);
SetUTCTime(cx, obj, NaN, vp);
} }
/* /*
@@ -1809,7 +1808,7 @@ date_setTime_impl(JSContext *cx, CallArgs args)
Rooted<JSObject*> thisObj(cx, &args.thisv().toObject()); Rooted<JSObject*> thisObj(cx, &args.thisv().toObject());
if (args.length() == 0) { if (args.length() == 0) {
SetDateToNaN(cx, thisObj, args.rval().address()); SetDateToNaN(thisObj, args.rval().address());
return true; return true;
} }
@@ -1817,7 +1816,7 @@ date_setTime_impl(JSContext *cx, CallArgs args)
if (!ToNumber(cx, args[0], &result)) if (!ToNumber(cx, args[0], &result))
return false; return false;
return SetUTCTime(cx, thisObj, TimeClip(result), args.rval().address()); return SetUTCTime(thisObj, TimeClip(result), args.rval().address());
} }
static JSBool static JSBool
@@ -1878,7 +1877,7 @@ date_setMilliseconds_impl(JSContext *cx, CallArgs args)
double u = TimeClip(UTC(MakeDate(Day(t), time), cx)); double u = TimeClip(UTC(MakeDate(Day(t), time), cx));
/* Steps 4-5. */ /* Steps 4-5. */
return SetUTCTime(cx, thisObj, u, args.rval().address()); return SetUTCTime(thisObj, u, args.rval().address());
} }
static JSBool static JSBool
@@ -1909,7 +1908,7 @@ date_setUTCMilliseconds_impl(JSContext *cx, CallArgs args)
double v = TimeClip(MakeDate(Day(t), time)); double v = TimeClip(MakeDate(Day(t), time));
/* Steps 4-5. */ /* Steps 4-5. */
return SetUTCTime(cx, thisObj, v, args.rval().address()); return SetUTCTime(thisObj, v, args.rval().address());
} }
static JSBool static JSBool
@@ -1947,7 +1946,7 @@ date_setSeconds_impl(JSContext *cx, CallArgs args)
double u = TimeClip(UTC(date, cx)); double u = TimeClip(UTC(date, cx));
/* Steps 6-7. */ /* Steps 6-7. */
return SetUTCTime(cx, thisObj, u, args.rval().address()); return SetUTCTime(thisObj, u, args.rval().address());
} }
/* ES5 15.9.5.31. */ /* ES5 15.9.5.31. */
@@ -1985,7 +1984,7 @@ date_setUTCSeconds_impl(JSContext *cx, CallArgs args)
double v = TimeClip(date); double v = TimeClip(date);
/* Steps 6-7. */ /* Steps 6-7. */
return SetUTCTime(cx, thisObj, v, args.rval().address()); return SetUTCTime(thisObj, v, args.rval().address());
} }
/* ES5 15.9.5.32. */ /* ES5 15.9.5.32. */
@@ -2028,7 +2027,7 @@ date_setMinutes_impl(JSContext *cx, CallArgs args)
double u = TimeClip(UTC(date, cx)); double u = TimeClip(UTC(date, cx));
/* Steps 7-8. */ /* Steps 7-8. */
return SetUTCTime(cx, thisObj, u, args.rval().address()); return SetUTCTime(thisObj, u, args.rval().address());
} }
/* ES5 15.9.5.33. */ /* ES5 15.9.5.33. */
@@ -2071,7 +2070,7 @@ date_setUTCMinutes_impl(JSContext *cx, CallArgs args)
double v = TimeClip(date); double v = TimeClip(date);
/* Steps 7-8. */ /* Steps 7-8. */
return SetUTCTime(cx, thisObj, v, args.rval().address()); return SetUTCTime(thisObj, v, args.rval().address());
} }
/* ES5 15.9.5.34. */ /* ES5 15.9.5.34. */
@@ -2119,7 +2118,7 @@ date_setHours_impl(JSContext *cx, CallArgs args)
double u = TimeClip(UTC(date, cx)); double u = TimeClip(UTC(date, cx));
/* Steps 7-8. */ /* Steps 7-8. */
return SetUTCTime(cx, thisObj, u, args.rval().address()); return SetUTCTime(thisObj, u, args.rval().address());
} }
/* ES5 15.9.5.35. */ /* ES5 15.9.5.35. */
@@ -2167,7 +2166,7 @@ date_setUTCHours_impl(JSContext *cx, CallArgs args)
double v = TimeClip(newDate); double v = TimeClip(newDate);
/* Steps 8-9. */ /* Steps 8-9. */
return SetUTCTime(cx, thisObj, v, args.rval().address()); return SetUTCTime(thisObj, v, args.rval().address());
} }
/* ES5 15.9.5.36. */ /* ES5 15.9.5.36. */
@@ -2200,7 +2199,7 @@ date_setDate_impl(JSContext *cx, CallArgs args)
double u = TimeClip(UTC(newDate, cx)); double u = TimeClip(UTC(newDate, cx));
/* Steps 5-6. */ /* Steps 5-6. */
return SetUTCTime(cx, thisObj, u, args.rval().address()); return SetUTCTime(thisObj, u, args.rval().address());
} }
/* ES5 15.9.5.37. */ /* ES5 15.9.5.37. */
@@ -2233,7 +2232,7 @@ date_setUTCDate_impl(JSContext *cx, CallArgs args)
double v = TimeClip(newDate); double v = TimeClip(newDate);
/* Steps 5-6. */ /* Steps 5-6. */
return SetUTCTime(cx, thisObj, v, args.rval().address()); return SetUTCTime(thisObj, v, args.rval().address());
} }
static JSBool static JSBool
@@ -2291,7 +2290,7 @@ date_setMonth_impl(JSContext *cx, CallArgs args)
double u = TimeClip(UTC(newDate, cx)); double u = TimeClip(UTC(newDate, cx));
/* Steps 6-7. */ /* Steps 6-7. */
return SetUTCTime(cx, thisObj, u, args.rval().address()); return SetUTCTime(thisObj, u, args.rval().address());
} }
static JSBool static JSBool
@@ -2329,7 +2328,7 @@ date_setUTCMonth_impl(JSContext *cx, CallArgs args)
double v = TimeClip(newDate); double v = TimeClip(newDate);
/* Steps 6-7. */ /* Steps 6-7. */
return SetUTCTime(cx, thisObj, v, args.rval().address()); return SetUTCTime(thisObj, v, args.rval().address());
} }
static JSBool static JSBool
@@ -2388,7 +2387,7 @@ date_setFullYear_impl(JSContext *cx, CallArgs args)
double u = TimeClip(UTC(newDate, cx)); double u = TimeClip(UTC(newDate, cx));
/* Steps 7-8. */ /* Steps 7-8. */
return SetUTCTime(cx, thisObj, u, args.rval().address()); return SetUTCTime(thisObj, u, args.rval().address());
} }
static JSBool static JSBool
@@ -2431,7 +2430,7 @@ date_setUTCFullYear_impl(JSContext *cx, CallArgs args)
double v = TimeClip(newDate); double v = TimeClip(newDate);
/* Steps 7-8. */ /* Steps 7-8. */
return SetUTCTime(cx, thisObj, v, args.rval().address()); return SetUTCTime(thisObj, v, args.rval().address());
} }
static JSBool static JSBool
@@ -2459,7 +2458,7 @@ date_setYear_impl(JSContext *cx, CallArgs args)
/* Step 3. */ /* Step 3. */
if (MOZ_DOUBLE_IS_NaN(y)) { if (MOZ_DOUBLE_IS_NaN(y)) {
SetDateToNaN(cx, thisObj, args.rval().address()); SetDateToNaN(thisObj, args.rval().address());
return true; return true;
} }
@@ -2475,7 +2474,7 @@ date_setYear_impl(JSContext *cx, CallArgs args)
double u = UTC(MakeDate(day, TimeWithinDay(t)), cx); double u = UTC(MakeDate(day, TimeWithinDay(t)), cx);
/* Steps 7-8. */ /* Steps 7-8. */
return SetUTCTime(cx, thisObj, TimeClip(u), args.rval().address()); return SetUTCTime(thisObj, TimeClip(u), args.rval().address());
} }
static JSBool static JSBool
@@ -3158,7 +3157,7 @@ js_InitDateClass(JSContext *cx, HandleObject obj)
RootedObject dateProto(cx, global->createBlankPrototype(cx, &DateClass)); RootedObject dateProto(cx, global->createBlankPrototype(cx, &DateClass));
if (!dateProto) if (!dateProto)
return NULL; return NULL;
SetDateToNaN(cx, dateProto); SetDateToNaN(dateProto);
RootedFunction ctor(cx); RootedFunction ctor(cx);
ctor = global->createConstructor(cx, js_Date, cx->names().Date, MAXARGS); ctor = global->createConstructor(cx, js_Date, cx->names().Date, MAXARGS);
@@ -3200,7 +3199,7 @@ js_NewDateObjectMsec(JSContext *cx, double msec_time)
JSObject *obj = NewBuiltinClassInstance(cx, &DateClass); JSObject *obj = NewBuiltinClassInstance(cx, &DateClass);
if (!obj) if (!obj)
return NULL; return NULL;
if (!SetUTCTime(cx, obj, msec_time)) if (!SetUTCTime(obj, msec_time))
return NULL; return NULL;
return obj; return obj;
} }
@@ -3225,7 +3224,7 @@ js_ClearDateCaches()
} }
JS_FRIEND_API(JSBool) JS_FRIEND_API(JSBool)
js_DateIsValid(JSContext *cx, JSObject* obj) js_DateIsValid(JSObject* obj)
{ {
return obj->isDate() && !MOZ_DOUBLE_IS_NaN(obj->getDateUTCTime().toNumber()); return obj->isDate() && !MOZ_DOUBLE_IS_NaN(obj->getDateUTCTime().toNumber());
} }
@@ -3287,7 +3286,7 @@ js_DateGetMinutes(JSContext *cx, JSObject* obj)
} }
JS_FRIEND_API(int) JS_FRIEND_API(int)
js_DateGetSeconds(JSContext *cx, JSObject* obj) js_DateGetSeconds(JSObject* obj)
{ {
if (!obj->isDate()) if (!obj->isDate())
return 0; return 0;
@@ -3299,7 +3298,7 @@ js_DateGetSeconds(JSContext *cx, JSObject* obj)
} }
JS_FRIEND_API(double) JS_FRIEND_API(double)
js_DateGetMsecSinceEpoch(JSContext *cx, RawObject obj) js_DateGetMsecSinceEpoch(RawObject obj)
{ {
return obj->isDate() ? obj->getDateUTCTime().toNumber() : 0; return obj->isDate() ? obj->getDateUTCTime().toNumber() : 0;
} }

View File

@@ -84,7 +84,7 @@ extern JS_FRIEND_API(int)
js_DateGetMinutes(JSContext *cx, JSObject* obj); js_DateGetMinutes(JSContext *cx, JSObject* obj);
extern JS_FRIEND_API(int) extern JS_FRIEND_API(int)
js_DateGetSeconds(JSContext *cx, JSObject* obj); js_DateGetSeconds(JSObject* obj);
/* Date constructor native. Exposed only so the JIT can know its address. */ /* Date constructor native. Exposed only so the JIT can know its address. */
JSBool JSBool

View File

@@ -973,10 +973,10 @@ uint32_t GetListBaseExpandoSlot();
* out-of-band for js_DateGet*) * out-of-band for js_DateGet*)
*/ */
extern JS_FRIEND_API(JSBool) extern JS_FRIEND_API(JSBool)
js_DateIsValid(JSContext *cx, JSObject* obj); js_DateIsValid(JSObject* obj);
extern JS_FRIEND_API(double) extern JS_FRIEND_API(double)
js_DateGetMsecSinceEpoch(JSContext *cx, JSRawObject obj); js_DateGetMsecSinceEpoch(JSRawObject obj);
/* Implemented in jscntxt.cpp. */ /* Implemented in jscntxt.cpp. */

View File

@@ -638,7 +638,7 @@ DSTOffsetCache::computeDSTOffsetMilliseconds(int64_t localTimeSeconds)
} }
int64_t int64_t
DSTOffsetCache::getDSTOffsetMilliseconds(int64_t localTimeMilliseconds, JSContext *cx) DSTOffsetCache::getDSTOffsetMilliseconds(int64_t localTimeMilliseconds)
{ {
sanityCheck(); sanityCheck();

View File

@@ -58,7 +58,7 @@ struct JSContext;
class DSTOffsetCache { class DSTOffsetCache {
public: public:
inline DSTOffsetCache(); inline DSTOffsetCache();
int64_t getDSTOffsetMilliseconds(int64_t localTimeMilliseconds, JSContext *cx); int64_t getDSTOffsetMilliseconds(int64_t localTimeMilliseconds);
inline void purge(); inline void purge();

View File

@@ -137,10 +137,10 @@ convertJSValToVariant(
if (aValue.isObject()) { if (aValue.isObject()) {
JSObject* obj = &aValue.toObject(); JSObject* obj = &aValue.toObject();
// We only support Date instances, all others fail. // We only support Date instances, all others fail.
if (!::js_DateIsValid(aCtx, obj)) if (!::js_DateIsValid(obj))
return nullptr; return nullptr;
double msecd = ::js_DateGetMsecSinceEpoch(aCtx, obj); double msecd = ::js_DateGetMsecSinceEpoch(obj);
msecd *= 1000.0; msecd *= 1000.0;
int64_t msec; int64_t msec;
LL_D2L(msec, msecd); LL_D2L(msec, msecd);