Bug 456165. Trace |new Date()|. r=brendan

This commit is contained in:
Boris Zbarsky
2008-10-06 20:28:22 -04:00
parent 8c072a197c
commit f65db6f706
6 changed files with 69 additions and 6 deletions

View File

@@ -52,6 +52,7 @@
#include "jsmath.h"
#include "jsnum.h"
#include "prmjtime.h"
#include "jsdate.h"
#include "jsscope.h"
#include "jsstr.h"
#include "jstracer.h"
@@ -875,6 +876,37 @@ js_Date_now(JSContext*)
return PRMJ_Now() / PRMJ_USEC_PER_MSEC;
}
JS_STATIC_ASSERT(JSSLOT_PRIVATE == JSSLOT_UTC_TIME);
JS_STATIC_ASSERT(JSSLOT_UTC_TIME + 1 == JSSLOT_LOCAL_TIME);
JSObject* FASTCALL
js_FastNewDate(JSContext* cx, JSObject* proto)
{
JS_ASSERT(JS_ON_TRACE(cx));
JSObject* obj = (JSObject*) js_NewGCThing(cx, GCX_OBJECT, sizeof(JSObject));
if (!obj)
return NULL;
JSClass* clasp = &js_DateClass;
obj->classword = jsuword(clasp);
obj->fslots[JSSLOT_PROTO] = OBJECT_TO_JSVAL(proto);
obj->fslots[JSSLOT_PARENT] = proto->fslots[JSSLOT_PARENT];
jsdouble* date = js_NewWeaklyRootedDouble(cx, 0.0);
if (!date)
return NULL;
*date = js_Date_now(cx);
obj->fslots[JSSLOT_UTC_TIME] = DOUBLE_TO_JSVAL(date);
obj->fslots[JSSLOT_LOCAL_TIME] = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);;
JS_ASSERT(!clasp->getObjectOps);
JS_ASSERT(proto->map->ops == &js_ObjectOps);
obj->map = js_HoldObjectMap(cx, proto->map);
obj->dslots = NULL;
return obj;
}
/* soft float */
jsdouble FASTCALL