Closed
Bug 146210
Opened 23 years ago
Closed 23 years ago
Need to expose JS_Now-alike via Date.now
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
VERIFIED
FIXED
mozilla1.0.1
People
(Reporter: shaver, Assigned: shaver)
References
Details
(Keywords: js1.5)
Attachments
(1 file)
1.03 KB,
patch
|
rginda
:
review+
brendan
:
superreview+
chofmann
:
approval+
|
Details | Diff | Splinter Review |
Now that we have JS_Now in the API, we should expose it via a Date static as
well, to keep people who are doing timings and the like from having to construct
a new Date object.
Brendan wanted me to do this ages ago, when we first grew JS_Now, but I was
lame. I'm going to try to cheat this into 1.0, so that it's in the release of
SpiderMonkey that matches it.
Assignee | ||
Comment 1•23 years ago
|
||
What could be easier?
Assignee | ||
Updated•23 years ago
|
Assignee | ||
Comment 2•23 years ago
|
||
My ambition knows no bounds.
Comment 3•23 years ago
|
||
Comment on attachment 84637 [details] [diff] [review]
Add Date.now
r=rginda
Attachment #84637 -
Flags: review+
Comment 4•23 years ago
|
||
QA NOTE:
I applied Mike's patch and verified that the new method Date.now()
gives the same result as new Date().valueOf(), that is, the number of
milliseconds since midnight 01 January, 1970 UTC.
function test()
{
var now1= new Date().valueOf();
var now2= Date.now();
print(now1);
print(now2);
}
js> test();
1022094173625
1022094173625
js> test();
1022094174671
1022094174671
js> test();
1022094175656
1022094175656
Comment 5•23 years ago
|
||
Comment on attachment 84637 [details] [diff] [review]
Add Date.now
sr=brendan@mozilla.org and I say ship it!
/be
Attachment #84637 -
Flags: superreview+
Assignee | ||
Comment 6•23 years ago
|
||
chofmann talked sense into me. 1.0 is done like dinner, we'll match 1.5 against
1.0.1?
Target Milestone: mozilla1.0 → mozilla1.0.1
Comment 7•23 years ago
|
||
Yeah, we should fix the property cache thread safety bug for 1.0.1 too.
/be
Updated•23 years ago
|
Comment 8•23 years ago
|
||
this crashes when called in xpcshell,
js> Date.now()
Assertion failure: lock != NULL, at
/tmp/mozilla/nsprpub/pr/src/pthreads/ptsynch.c:189
Abort
Here's the stack, whatever that should mean:
#5 0xfec357c4 in abort () from /usr/lib/libc.so.1
#6 0xfed96710 in PR_Assert (s=0xfedd7f20 "lock != NULL",
file=0xfedd7e50 "/tmp/mozilla/nsprpub/pr/src/pthreads/ptsynch.c", ln=189)
at /tmp/mozilla/nsprpub/pr/src/io/prlog.c:510
#7 0xfedbee6c in PR_Lock (lock=0x0)
at /tmp/mozilla/nsprpub/pr/src/pthreads/ptsynch.c:189
#8 0xff2449c4 in JS_dtostr (buffer=0xffbee628 "", bufferSize=25,
mode=DTOSTR_STANDARD, precision=0, d=1024655774371)
at /tmp/mozilla/js/src/jsdtoa.c:2544
#9 0xff28ef40 in js_NumberToString (cx=0x489c8, d=1024655774371)
at /tmp/mozilla/js/src/jsnum.c:619
#10 0xff2e47f8 in js_ValueToString (cx=0x489c8, v=306506)
at /tmp/mozilla/js/src/jsstr.c:2577
#11 0xff214ef0 in JS_ValueToString (cx=0x489c8, v=306506)
at /tmp/mozilla/js/src/jsapi.c:523
#12 0x14f30 in Process (cx=0x489c8, obj=0x49f78, filename=0x0,
filehandle=0xfecbc2d4)
at /tmp/mozilla/js/src/xpconnect/shell/xpcshell.cpp:521
#13 0x15604 in ProcessArgs (cx=0x489c8, obj=0x49f78, argv=0xffbefa00, argc=0)
at /tmp/mozilla/js/src/xpconnect/shell/xpcshell.cpp:655
#14 0x165cc in main (argc=0, argv=0xffbefa00)
at /tmp/mozilla/js/src/xpconnect/shell/xpcshell.cpp:910
Date.now() seems to be ok, xpcshell doesn't call InitDtoa and therefor the
lock isn't created.
How comes that this isn't triggered elsewhere?
The answer is that it is triggered elsewhere :), i knew i'd seen that crash
before. Oh well, bug 154737.
Comment 10•23 years ago
|
||
Ok, so this patch should go into the 1.0 branch. I'll mail drivers, since
shaver is AWOL, or AWL, or something.
/be
Updated•23 years ago
|
Keywords: mozilla1.0.1 → mozilla1.0.1+
Comment 11•23 years ago
|
||
Comment on attachment 84637 [details] [diff] [review]
Add Date.now
a=chofman for 1.0.1. add fixed1.0.1 after checking in.
Attachment #84637 -
Flags: approval+
Comment 12•23 years ago
|
||
checked into branch (after checkin in bug 154737)
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Keywords: mozilla1.0.1+ → fixed1.0.1
Resolution: --- → FIXED
Comment 13•23 years ago
|
||
Verified on the trunk and the 1.0 branch, the JS shell, and xpcshell.
Date.now() exists and gives the same value as new Date().valueOf();
that is, the number of milliseconds since midnight 01 January, 1970 UTC.
Status: RESOLVED → VERIFIED
Keywords: verified1.0.1
You need to log in
before you can comment on or make changes to this bug.
Description
•