Bug 170102 - Air::Liveness shouldn't need HashSets
Summary: Air::Liveness shouldn't need HashSets
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: 171010
  Show dependency treegraph
 
Reported: 2017-03-25 14:40 PDT by Filip Pizlo
Modified: 2017-04-19 14:32 PDT (History)
10 users (show)

See Also:


Attachments
it begins (21.69 KB, patch)
2017-03-25 14:46 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (28.53 KB, patch)
2017-03-25 19:13 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (21.00 KB, patch)
2017-03-25 19:15 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (22.31 KB, patch)
2017-03-26 13:34 PDT, Filip Pizlo
ysuzuki: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2017-03-25 14:40:18 PDT
Patch forthcoming.
Comment 1 Filip Pizlo 2017-03-25 14:46:54 PDT
Created attachment 305400 [details]
it begins
Comment 2 Filip Pizlo 2017-03-25 15:45:21 PDT
It works, but it looks like a slow-down!
Comment 3 Filip Pizlo 2017-03-25 19:13:32 PDT
Created attachment 305410 [details]
the patch
Comment 4 Build Bot 2017-03-25 19:14:49 PDT
Attachment 305410 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/b3/B3TimingScope.cpp:60:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Source/WTF/wtf/Vector.h:1516:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 2 in 15 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Filip Pizlo 2017-03-25 19:15:40 PDT
Created attachment 305411 [details]
the patch
Comment 6 Build Bot 2017-03-25 19:17:38 PDT
Attachment 305411 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/b3/B3TimingScope.cpp:60:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Source/WTF/wtf/Vector.h:1516:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 2 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Filip Pizlo 2017-03-26 13:34:05 PDT
Created attachment 305435 [details]
the patch
Comment 8 Build Bot 2017-03-26 13:37:24 PDT
Attachment 305435 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/b3/B3TimingScope.cpp:60:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Source/WTF/wtf/Vector.h:1516:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 2 in 15 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 Yusuke Suzuki 2017-03-26 15:01:47 PDT
Comment on attachment 305435 [details]
the patch

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

r=me

> Source/JavaScriptCore/ChangeLog:11
> +        compile time progression on WasmBench.

Cool.

> Source/JavaScriptCore/b3/air/AirLiveness.h:133
>              dirtyBlocks.set(blockIndex);

Cool.

> Source/JavaScriptCore/b3/air/AirLiveness.h:188
> +                        liveAtTail = m_workset.values();

OK, m_workset.values() is already sorted.

> Source/JavaScriptCore/b3/air/AirLiveness.h:202
> +                        mergeBuffer.resize(0);
> +                        mergeBuffer.reserveCapacity(liveAtTail.size() + m_workset.size());
> +                        auto iter = mergeDeduplicatedSorted(
> +                            liveAtTail.begin(), liveAtTail.end(),
> +                            m_workset.begin(), m_workset.end(),
> +                            mergeBuffer.begin());
> +                        mergeBuffer.resize(iter - mergeBuffer.begin());
> +                        
> +                        if (mergeBuffer.size() == liveAtTail.size())
> +                            continue;
> +                    
> +                        RELEASE_ASSERT(mergeBuffer.size() > liveAtTail.size());
> +                        liveAtTail = mergeBuffer;

OK, merging 2 sorted sequence into one sorted mergeBuffer.

> Source/JavaScriptCore/b3/air/AirTmp.h:95
> +

Is this used?

> Source/JavaScriptCore/b3/air/AirTmp.h:149
> +    }

Ditto.
Comment 10 Filip Pizlo 2017-03-26 15:06:02 PDT
(In reply to Yusuke Suzuki from comment #9)
> Comment on attachment 305435 [details]
> the patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=305435&action=review
> 
> r=me
> 
> > Source/JavaScriptCore/ChangeLog:11
> > +        compile time progression on WasmBench.
> 
> Cool.
> 
> > Source/JavaScriptCore/b3/air/AirLiveness.h:133
> >              dirtyBlocks.set(blockIndex);
> 
> Cool.
> 
> > Source/JavaScriptCore/b3/air/AirLiveness.h:188
> > +                        liveAtTail = m_workset.values();
> 
> OK, m_workset.values() is already sorted.
> 
> > Source/JavaScriptCore/b3/air/AirLiveness.h:202
> > +                        mergeBuffer.resize(0);
> > +                        mergeBuffer.reserveCapacity(liveAtTail.size() + m_workset.size());
> > +                        auto iter = mergeDeduplicatedSorted(
> > +                            liveAtTail.begin(), liveAtTail.end(),
> > +                            m_workset.begin(), m_workset.end(),
> > +                            mergeBuffer.begin());
> > +                        mergeBuffer.resize(iter - mergeBuffer.begin());
> > +                        
> > +                        if (mergeBuffer.size() == liveAtTail.size())
> > +                            continue;
> > +                    
> > +                        RELEASE_ASSERT(mergeBuffer.size() > liveAtTail.size());
> > +                        liveAtTail = mergeBuffer;
> 
> OK, merging 2 sorted sequence into one sorted mergeBuffer.
> 
> > Source/JavaScriptCore/b3/air/AirTmp.h:95
> > +
> 
> Is this used?

It's meant to be a replacement for when we say Arg(tmp).bank().  I think I may have used it in an earlier version of this patch.

> 
> > Source/JavaScriptCore/b3/air/AirTmp.h:149
> > +    }
> 
> Ditto.

Same thing, earlier version of this patch.
Comment 11 Filip Pizlo 2017-03-26 15:11:45 PDT
Landed in r214409.
Comment 12 Yusuke Suzuki 2017-03-26 17:49:17 PDT
Comment on attachment 305435 [details]
the patch

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

Oops, one nit comment.

> Source/JavaScriptCore/b3/air/AirLiveness.h:191
> +                        mergeBuffer.reserveCapacity(liveAtTail.size() + m_workset.size());

I think this just allocates capacity(), but the size() of mergeBuffer is still zero.
So, I think the following mergeDeduplicatedSorted is not safe especially in regards of ASAN.
I think we need to perform `resize(liveAtTail.size() + m_workset.size()` here.
Comment 13 Filip Pizlo 2017-03-26 17:52:10 PDT
(In reply to Yusuke Suzuki from comment #12)
> Comment on attachment 305435 [details]
> the patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=305435&action=review
> 
> Oops, one nit comment.
> 
> > Source/JavaScriptCore/b3/air/AirLiveness.h:191
> > +                        mergeBuffer.reserveCapacity(liveAtTail.size() + m_workset.size());
> 
> I think this just allocates capacity(), but the size() of mergeBuffer is
> still zero.
> So, I think the following mergeDeduplicatedSorted is not safe especially in
> regards of ASAN.
> I think we need to perform `resize(liveAtTail.size() + m_workset.size()`
> here.

You're right!  Previously this was OK because I was using uncheckedAppend but then I switched to insertion iterators.
Comment 14 Filip Pizlo 2017-03-26 19:20:06 PDT
(In reply to Filip Pizlo from comment #13)
> (In reply to Yusuke Suzuki from comment #12)
> > Comment on attachment 305435 [details]
> > the patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=305435&action=review
> > 
> > Oops, one nit comment.
> > 
> > > Source/JavaScriptCore/b3/air/AirLiveness.h:191
> > > +                        mergeBuffer.reserveCapacity(liveAtTail.size() + m_workset.size());
> > 
> > I think this just allocates capacity(), but the size() of mergeBuffer is
> > still zero.
> > So, I think the following mergeDeduplicatedSorted is not safe especially in
> > regards of ASAN.
> > I think we need to perform `resize(liveAtTail.size() + m_workset.size()`
> > here.
> 
> You're right!  Previously this was OK because I was using uncheckedAppend
> but then I switched to insertion iterators.

Fixed in https://bugs.webkit.org/show_bug.cgi?id=170111