Closed Bug 524346 Opened 15 years ago Closed 15 years ago

using jsval, not jsdouble *, for JSRuntime::js(Nan|PositiveInfinity|NegativeInfinity)

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: igor, Assigned: igor)

References

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 2 obsolete files)

Currently jsNan, jsPositiveInfinity, jsNegativeInfinity are defined as jsdouble * fields in JSRuntime. On the other hand, in most cases when code uses them, the constants are converted to jsval. This suggests to declare the constants as jsval to avoid an extra bloat due to jsval tag manipulations.
Attached patch v1 (obsolete) (deleted) — Splinter Review
The patch converts double constants in JSRuntime into jsval. It also replaces few NewWeaklyRootedDouble calls with js_NewDoubleInRootedValue.
Attachment #408271 - Flags: review?(mrbkap)
Not to say this is necessarily bad, but I recall someone recently benchmarking manipulating tag bits on a value just read from memory and finding that modern CPUs coalesce the load and tag/de-tag into essentially the same underlying cycle. Are you sure the cost to tag these bits every time is actually observable?
Comment on attachment 408271 [details] [diff] [review] v1 I don't feel strongly about this. I think that igor's point here is that having all of those DOUBLE_TO_JSVALs pollutes the code (even if the actual generated code is equally fast). While this change is inconsistent with JSRuntime::emptyString, from reading through the patch, this is clearly the directly we want (as opposed to emptyString, where the majority of uses use the JSString * instead of the jsval).
Attachment #408271 - Flags: review?(mrbkap) → review+
Less code noise is good, that's far more sensible than tagging cost. Might it make sense to rename to NaNValue, negativeInfinityValue, positiveInfinityValue to follow the convention of including v/val/value in jsval-typed variables? This would also get rid of a js prefix that seems unneeded now.
(In reply to comment #4) > Less code noise is good, that's far more sensible than tagging cost. > > Might it make sense to rename to NaNValue, negativeInfinityValue, > positiveInfinityValue to follow the convention of including v/val/value in > jsval-typed variables? This would also get rid of a js prefix that seems > unneeded now. +1 -- or more ;-). /be
Attached patch v2 (obsolete) (deleted) — Splinter Review
The new version uses NaNValue, negativeInfinityValue, positiveInfinityValue for JSRuntime:: fields.
Attachment #408271 - Attachment is obsolete: true
Attachment #408572 - Flags: review+
http://hg.mozilla.org/tracemonkey/rev/14c76164f4c2 http://tinderbox.mozilla.org/showlog.cgi?log=TraceMonkey/1256639539.1256644303.21754.gz&fulltext=1 did this cause: TEST-UNEXPECTED-FAIL | trace-test.py | /builds/slave/tracemonkey-macosx-debug/build/js/src/trace-test/tests/sunspider/check-date-format-tofte.js: Assertion failure: JSVAL_IS_DOUBLE(v), at /builds/slave/tracemonkey-macosx-debug/build/js/src/jsapi.h:190 TEST-UNEXPECTED-FAIL | trace-test.py | /builds/slave/tracemonkey-macosx-debug/build/js/src/trace-test/tests/sunspider/check-date-format-xparb.js: Assertion failure: JSVAL_IS_DOUBLE(v), at /builds/slave/tracemonkey-macosx-debug/build/js/src/jsapi.h:190
Attached patch v3 (deleted) — Splinter Review
fixing a bad typo in GetAndCacheLocalTime
Attachment #408572 - Attachment is obsolete: true
Attachment #408627 - Flags: review+
Depends on: 524671
Whiteboard: fixed-in-tracemonkey
Flags: in-testsuite-
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: