Closed
Bug 901000
Opened 11 years ago
Closed 11 years ago
PJS: Math functions race since they use MathCache
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla26
People
(Reporter: shu, Assigned: pnkfelix)
References
Details
Attachments
(2 files, 2 obsolete files)
21.90 KB,
patch
|
pnkfelix
:
review+
|
Details | Diff | Splinter Review |
3.86 KB,
patch
|
pnkfelix
:
review+
|
Details | Diff | Splinter Review |
We consider Math functions safe currently, but they use a MathCache structure to cache results. This cache is engine-wide. We should either duplicate the cache per thread or not cache in PJS.
Reporter | ||
Comment 1•11 years ago
|
||
This is what was causing the indeterminism in nbody.
Assignee | ||
Comment 2•11 years ago
|
||
For the short-term, I'm planning to make PJS compile Math.sin etc to variants that do not access the cache in any way.
For the long-term, we have options. Such as:
A. Do not use the cache (as above)
B. Make the cache per-thread.
(This has sub-options, such as whether to combine the cache results at the end of a PJS invocation, or throw them away, or leave them in place for future runs on that same thread.)
C. Read from the cache but do not update it.
(I.e. adapt the code to a multiple-readers/no-writers model when in PJS.)
Comment 3•11 years ago
|
||
IIRC, the math cache greatly sped up one of the Sunspider tests. If that's still true then removing it would be a problem.
If we went with option B, I suspect combining caches wouldn't be worth it.
Comment 4•11 years ago
|
||
I'd say don't use the cache. The only reason for it is SunSpider stupidity. Pages that benefit from it would be better off recognizing the cache opportunity themselves, and not trying to do a bunch of pointless extra work. With no "legacy" "compatibility" constraints on PJS, we shouldn't preserve this wart there.
Assignee | ||
Comment 5•11 years ago
|
||
Assignee: general → pnkfelix
Attachment #794031 -
Flags: review?(nmatsakis)
Assignee | ||
Comment 6•11 years ago
|
||
Attachment #794032 -
Flags: review?(nmatsakis)
Comment 7•11 years ago
|
||
Comment on attachment 794031 [details] [diff] [review]
bz901000-pAv1-uncached-variants.patch
Review of attachment 794031 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/jsmath.cpp
@@ +144,5 @@
>
> +double
> +js::math_acos_uncached(double x)
> +{
> +#if defined(SOLARIS) && defined(__GNUC__)
Is there a way to avoid duplicating this special case #if code?
For example, perhaps math_acos should delegate to math_acos_uncached rather than `acos`? But I guess that would grow the cache unnecessarily. Another option would be to use #define macros to eliminate the redundancy.
@@ +187,5 @@
>
> +double
> +js::math_asin_uncached(double x)
> +{
> +#if defined(SOLARIS) && defined(__GNUC__)
As above.
@@ +382,5 @@
>
> +double
> +js::math_exp_uncached(double x)
> +{
> +#ifdef _WIN32
As above.
@@ +472,5 @@
>
> +double
> +js::math_log_uncached(double x)
> +{
> +#if defined(SOLARIS) && defined(__GNUC__)
As above.
@@ +968,5 @@
>
> +double
> +js::math_log1p_uncached(double x)
> +{
> +#ifdef __APPLE__
As above.
Attachment #794031 -
Flags: review?(nmatsakis) → review+
Updated•11 years ago
|
Attachment #794032 -
Flags: review?(nmatsakis) → review+
Assignee | ||
Comment 8•11 years ago
|
||
patch A, version 2: incorporates niko's suggestion of using preprocessor macros to abstract common code between impl and uncached variants.
Attachment #794031 -
Attachment is obsolete: true
Assignee | ||
Comment 9•11 years ago
|
||
Comment on attachment 794675 [details] [diff] [review]
bz901000-pAv2-uncached-variants.patch
(inherits previous r+ from nmatsakis.)
Attachment #794675 -
Flags: review+
Assignee | ||
Comment 10•11 years ago
|
||
(My try build failed for some mysterious reason. The failure was on the regression test added with this patch, so I am investigation further before attempting to land.)
Assignee | ||
Comment 11•11 years ago
|
||
Added slow marking because this was causing jit-less tests to time out.
Inheriting r+ from previous review from nmatsakis.
Attachment #794032 -
Attachment is obsolete: true
Attachment #795415 -
Flags: review+
Assignee | ||
Comment 12•11 years ago
|
||
Assignee | ||
Comment 13•11 years ago
|
||
Comment 14•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/20d71d9471cb
https://hg.mozilla.org/mozilla-central/rev/5409f0b566b1
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
You need to log in
before you can comment on or make changes to this bug.
Description
•