Bug 151114 - B3 should be able to compile a program with ChillDiv
Summary: B3 should be able to compile a program with ChillDiv
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Filip Pizlo
URL:
Keywords:
Depends on:
Blocks: 150279 151115
  Show dependency treegraph
 
Reported: 2015-11-10 11:19 PST by Filip Pizlo
Modified: 2015-11-10 23:21 PST (History)
12 users (show)

See Also:


Attachments
work in progress (36.63 KB, patch)
2015-11-10 12:12 PST, Filip Pizlo
no flags Details | Formatted Diff | Diff
more (84.31 KB, patch)
2015-11-10 13:26 PST, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (108.07 KB, patch)
2015-11-10 16:54 PST, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (108.25 KB, patch)
2015-11-10 17:09 PST, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (108.31 KB, patch)
2015-11-10 17:42 PST, Filip Pizlo
benjamin: review+
Details | Formatted Diff | Diff
patch for landing (29.87 KB, patch)
2015-11-10 21:53 PST, Filip Pizlo
no flags Details | Formatted Diff | Diff
patch for landing (108.58 KB, patch)
2015-11-10 22:06 PST, Filip Pizlo
no flags Details | Formatted Diff | Diff
patch for landing (108.58 KB, patch)
2015-11-10 22:33 PST, Filip Pizlo
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2015-11-10 11:19:57 PST
Patch forthcoming.
Comment 1 Filip Pizlo 2015-11-10 12:12:30 PST
Created attachment 265215 [details]
work in progress
Comment 2 Filip Pizlo 2015-11-10 13:26:03 PST
Created attachment 265223 [details]
more
Comment 3 Filip Pizlo 2015-11-10 16:54:05 PST
Created attachment 265247 [details]
the patch
Comment 4 WebKit Commit Bot 2015-11-10 16:56:32 PST
Attachment 265247 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/b3/B3BlockInsertionSet.h:78:  The parameter name "block" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/b3/B3ConstDoubleValue.h:45:  The parameter name "proc" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/b3/B3ConstDoubleValue.h:46:  The parameter name "proc" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/b3/B3ConstDoubleValue.h:47:  The parameter name "proc" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 4 in 47 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Filip Pizlo 2015-11-10 17:09:19 PST
Created attachment 265251 [details]
the patch

With some fixes.
Comment 6 Filip Pizlo 2015-11-10 17:42:20 PST
Created attachment 265255 [details]
the patch

Fix 32-bit.
Comment 7 Benjamin Poulain 2015-11-10 21:06:06 PST
Comment on attachment 265255 [details]
the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=265255&action=review

> Source/JavaScriptCore/ChangeLog:22
> +        This introduces an idiom that handles this. It's BlockInsertionSet::splitBefore(). The
> +        idea is that it uses the current block before the split as the continuation after the
> +        split. When you call splitBefore(), you pass it your loop index and your InsertionSet
> +        (if applicable). It makes sure that it changes those auxiliary things in such a way that
> +        you can keep looping.
> +

splitBefore() -> splitForward()

> Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h:394
> +    void x86ConvertToDoubleWord64(RegisterID rax, RegisterID rdx)

ConvertToQuadword?

> Source/JavaScriptCore/assembler/X86Assembler.h:1295
> +    void cdqq()

Looks like the official name for this is "cqo"

> Source/JavaScriptCore/b3/B3BasicBlockUtils.h:75
> +void updatePredecessors(BasicBlock* root)

updatePredecessors -> updatePredecessorsAfter(block)?
The name is a bit weird.

> Source/JavaScriptCore/b3/B3Common.h:101
> +    if (den == -1 && num == -2147483647 - 1)

Why not use numeric_limits?

> Source/JavaScriptCore/b3/B3Common.h:110
> +    if (den == -1 && num == -9223372036854775807ll - 1)

ditto, and some later.

> Source/JavaScriptCore/b3/B3LowerMacros.cpp:59
> +        m_changed |= m_blockInsertionSet.execute();

Having this at the end means no Macro can use a Macro in its expansion.

I guess you could assert that by running the algorithm again in Debug and checking that m_blockInsertionSet.execute() returns false.

> Source/JavaScriptCore/b3/B3LowerMacros.cpp:90
> +                //     res = num / dev;

dev -> den

> Source/JavaScriptCore/b3/B3LowerMacros.cpp:97
> +                Value* one =
> +                    m_insertionSet.insertIntConstant(m_index, m_value, 1);

Could be on a single line.
Comment 8 Geoffrey Garen 2015-11-10 21:26:11 PST
Comment on attachment 265255 [details]
the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=265255&action=review

>> Source/JavaScriptCore/ChangeLog:22
>> +
> 
> splitBefore() -> splitForward()

Or maybe just split()? (The split is forward and backward, and it breaks what comes before from what comes after.)
Comment 9 Filip Pizlo 2015-11-10 21:26:51 PST
(In reply to comment #7)
> Comment on attachment 265255 [details]
> the patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=265255&action=review
> 
> > Source/JavaScriptCore/ChangeLog:22
> > +        This introduces an idiom that handles this. It's BlockInsertionSet::splitBefore(). The
> > +        idea is that it uses the current block before the split as the continuation after the
> > +        split. When you call splitBefore(), you pass it your loop index and your InsertionSet
> > +        (if applicable). It makes sure that it changes those auxiliary things in such a way that
> > +        you can keep looping.
> > +
> 
> splitBefore() -> splitForward()
> 
> > Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h:394
> > +    void x86ConvertToDoubleWord64(RegisterID rax, RegisterID rdx)
> 
> ConvertToQuadword?

Good point.

> 
> > Source/JavaScriptCore/assembler/X86Assembler.h:1295
> > +    void cdqq()
> 
> Looks like the official name for this is "cqo"
> 
> > Source/JavaScriptCore/b3/B3BasicBlockUtils.h:75
> > +void updatePredecessors(BasicBlock* root)
> 
> updatePredecessors -> updatePredecessorsAfter(block)?
> The name is a bit weird.

Sure.

> 
> > Source/JavaScriptCore/b3/B3Common.h:101
> > +    if (den == -1 && num == -2147483647 - 1)
> 
> Why not use numeric_limits?

I guess I should!  This was old school paranoia about -2147483648 not being a valid constant.  Seems that numeric_limits does the right thing though.

> 
> > Source/JavaScriptCore/b3/B3Common.h:110
> > +    if (den == -1 && num == -9223372036854775807ll - 1)
> 
> ditto, and some later.
> 
> > Source/JavaScriptCore/b3/B3LowerMacros.cpp:59
> > +        m_changed |= m_blockInsertionSet.execute();
> 
> Having this at the end means no Macro can use a Macro in its expansion.

That's true!  I think it would be bad form to have an expansion that requires more expansions.  Good discipline about this prevents us from having to worry about fixpointing this phase, or having the phase never converge.

> 
> I guess you could assert that by running the algorithm again in Debug and
> checking that m_blockInsertionSet.execute() returns false.

We could.  The phase also returns a bool saying if it changed anything.  We could internally have the phase run itself twice.

> 
> > Source/JavaScriptCore/b3/B3LowerMacros.cpp:90
> > +                //     res = num / dev;
> 
> dev -> den
> 
> > Source/JavaScriptCore/b3/B3LowerMacros.cpp:97
> > +                Value* one =
> > +                    m_insertionSet.insertIntConstant(m_index, m_value, 1);
> 
> Could be on a single line.
Comment 10 Filip Pizlo 2015-11-10 21:27:58 PST
(In reply to comment #8)
> Comment on attachment 265255 [details]
> the patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=265255&action=review
> 
> >> Source/JavaScriptCore/ChangeLog:22
> >> +
> > 
> > splitBefore() -> splitForward()
> 
> Or maybe just split()? (The split is forward and backward, and it breaks
> what comes before from what comes after.)

Well, if we wanted to split blocks when transforming in a backward algorithm, then we'd want the newly created block to hold things *above* the valueIndex.

Hence why I call it "splitForward()".  The "Forward" tells you that it's meant to be used in a transformation that walks forward.
Comment 11 Filip Pizlo 2015-11-10 21:53:02 PST
Created attachment 265269 [details]
patch for landing
Comment 12 WebKit Commit Bot 2015-11-10 21:56:10 PST
Attachment 265269 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/b3/B3ConstDoubleValue.h:47:  The parameter name "proc" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/b3/testb3.cpp:209:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/JavaScriptCore/b3/testb3.cpp:302:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/JavaScriptCore/b3/testb3.cpp:2855:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/JavaScriptCore/b3/testb3.cpp:2861:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 5 in 17 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Filip Pizlo 2015-11-10 22:06:44 PST
Created attachment 265270 [details]
patch for landing

The right patch this time!
Comment 14 Filip Pizlo 2015-11-10 22:33:02 PST
Created attachment 265271 [details]
patch for landing
Comment 15 WebKit Commit Bot 2015-11-10 23:21:23 PST
Comment on attachment 265271 [details]
patch for landing

Clearing flags on attachment: 265271

Committed r192295: <http://trac.webkit.org/changeset/192295>
Comment 16 WebKit Commit Bot 2015-11-10 23:21:28 PST
All reviewed patches have been landed.  Closing bug.