Last Comment Bug 719135 - IonMonkey: Compile unspecialized SUB, MUL, DIV and MOD
: IonMonkey: Compile unspecialized SUB, MUL, DIV and MOD
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: All All
: -- normal (vote)
: mozilla12
Assigned To: Jan de Mooij [:jandem]
:
:
Mentors:
Depends on:
Blocks: 684381
  Show dependency treegraph
 
Reported: 2012-01-18 10:08 PST by Jan de Mooij [:jandem]
Modified: 2012-01-23 13:33 PST (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch for inbound (13.95 KB, patch)
2012-01-19 06:06 PST, Jan de Mooij [:jandem]
dvander: review+
Details | Diff | Splinter Review
Patch (20.16 KB, patch)
2012-01-23 06:29 PST, Jan de Mooij [:jandem]
nicolas.b.pierron: review+
Details | Diff | Splinter Review

Description Jan de Mooij [:jandem] 2012-01-18 10:08:53 PST
We should probably rename MAddGeneric to MBinaryArithGeneric or something and call different stubs depending on the op.

We need this for Kraken gaussian-blur and some SS tests. Bug 715772 would help too, but this shouldn't be too hard and at some point we'll have to do it anyway.
Comment 1 Jan de Mooij [:jandem] 2012-01-19 06:06:04 PST
Created attachment 589846 [details] [diff] [review]
Patch for inbound

Adding stubs to jsinterp.cpp and calling them in the interpreter loop caused a 40 ms SS regression, so I decided to add these operations to jsinterpinlines instead. This matches the other *Operation functions in jsinterpinlines.
Comment 2 :Ms2ger (⌚ UTC+1/+2) 2012-01-20 04:23:41 PST
Comment on attachment 589846 [details] [diff] [review]
Patch for inbound

>--- a/js/src/jsinterpinlines.h
>+++ b/js/src/jsinterpinlines.h
>+AddOperation(JSContext *cx, const Value &lhs, const Value &rhs, Value *res)
>+{
>+        bool lIsString, rIsString;
>+        if ((lIsString = lval.isString()) | (rIsString = rval.isString())) {

This is pre-existing code, but isn't it trying to be too smart? It looks equivalent to

bool lIsString = lval.isString(), rIsString = rval.isString();
if (lIsString || rIsString) {
Comment 3 Jan de Mooij [:jandem] 2012-01-20 04:30:57 PST
https://hg.mozilla.org/integration/mozilla-inbound/rev/65d66257a176

This is just the first part so please don't close this bug.
Comment 4 Jan de Mooij [:jandem] 2012-01-20 04:40:21 PST
(In reply to Ms2ger from comment #2)
>  
> This is pre-existing code, but isn't it trying to be too smart? It looks
> equivalent to
> 
> bool lIsString = lval.isString(), rIsString = rval.isString();
> if (lIsString || rIsString) {

Agreed. It may be interesting to compare the generated asm, and even if it's slightly better I don't think this kind of optimization helps much now that we have JITs.

r=me if you want to change it.
Comment 5 Ed Morley [:emorley] 2012-01-21 06:55:45 PST
https://hg.mozilla.org/mozilla-central/rev/65d66257a176
Comment 6 Jan de Mooij [:jandem] 2012-01-23 06:29:20 PST
Created attachment 590689 [details] [diff] [review]
Patch
Comment 7 Nicolas B. Pierron [:nbp] 2012-01-23 08:23:16 PST
Comment on attachment 590689 [details] [diff] [review]
Patch

Review of attachment 590689 [details] [diff] [review]:
-----------------------------------------------------------------

Good job.

I like the idea of having the MAdd/MSub/... and LBinaryV, except that we may want LBinaryV supporting more functions.
During the review I verified that JSOP_* from JSOP_ADD to JSOP_MOD are packed, to make sure the switch case would not be replaced by series of if.  May be LBinaryV name should reflect this limitation.

::: js/src/ion/MIR.h
@@ +1094,5 @@
>          if (type() != ins->type())
>              return false;
>  
> +        if (isEffectful() || ins->isEffectful())
> +            return false;

Would it be better to limit congruentTo to identical aliasSet scopes instead of avoiding it, such as sharing an effectful call extracted from then-part and else-part of an if statement ?
Comment 8 Jan de Mooij [:jandem] 2012-01-23 12:49:31 PST
(In reply to Nicolas B. Pierron [:pierron] from comment #7)
> 

Thanks for the quick review.

> 
> During the review I verified that JSOP_* from JSOP_ADD to JSOP_MOD are
> packed, to make sure the switch case would not be replaced by series of if. 
> May be LBinaryV name should reflect this limitation.

I just tested this with Clang 3.0 by adding some other ops to the switch. If there is a small number of "holes", it will still generate a jump table (the missing case values just jump to the default case). If there is a large number of holes, it generates a jump table and either adds jumps for the ops not handled by the table or it generates multiple jump tables.

> 
> Would it be better to limit congruentTo to identical aliasSet scopes instead
> of avoiding it, such as sharing an effectful call extracted from then-part
> and else-part of an if statement ?

We'd have to move the calls before the "if" but GVN won't do that (and GVN/LICM never move effectful instructions).
Comment 9 Jan de Mooij [:jandem] 2012-01-23 13:33:16 PST
http://hg.mozilla.org/projects/ionmonkey/rev/ff07f7795262

Note You need to log in before you can comment on or make changes to this bug.