Title: [214923] trunk/Source
Revision
214923
Author
[email protected]
Date
2017-04-04 18:18:07 -0700 (Tue, 04 Apr 2017)

Log Message

Air::eliminateDeadCode() should not use a HashSet
https://bugs.webkit.org/show_bug.cgi?id=170487

Reviewed by Saam Barati.
        
Source/_javascript_Core:

Introduce TmpSet, which is like a HashSet<Tmp>. Use this to make eliminateDeadCode()
about 50% faster, resulting in a 1% wasm -O1 compile time progression.

* _javascript_Core.xcodeproj/project.pbxproj:
* b3/air/AirEliminateDeadCode.cpp:
(JSC::B3::Air::eliminateDeadCode):
* b3/air/AirTmpSet.h: Added.
(JSC::B3::Air::TmpSet::TmpSet):
(JSC::B3::Air::TmpSet::add):
(JSC::B3::Air::TmpSet::remove):
(JSC::B3::Air::TmpSet::contains):
(JSC::B3::Air::TmpSet::size):
(JSC::B3::Air::TmpSet::isEmpty):
(JSC::B3::Air::TmpSet::iterator::iterator):
(JSC::B3::Air::TmpSet::iterator::operator*):
(JSC::B3::Air::TmpSet::iterator::operator++):
(JSC::B3::Air::TmpSet::iterator::operator==):
(JSC::B3::Air::TmpSet::iterator::operator!=):
(JSC::B3::Air::TmpSet::begin):
(JSC::B3::Air::TmpSet::end):

Source/WTF:

BitVector::iterator knows when it's at the end. Expose this functionality.

* wtf/BitVector.h:
(WTF::BitVector::iterator::isAtEnd):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (214922 => 214923)


--- trunk/Source/_javascript_Core/ChangeLog	2017-04-05 00:59:58 UTC (rev 214922)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-04-05 01:18:07 UTC (rev 214923)
@@ -1,3 +1,31 @@
+2017-04-04  Filip Pizlo  <[email protected]>
+
+        Air::eliminateDeadCode() should not use a HashSet
+        https://bugs.webkit.org/show_bug.cgi?id=170487
+
+        Reviewed by Saam Barati.
+        
+        Introduce TmpSet, which is like a HashSet<Tmp>. Use this to make eliminateDeadCode()
+        about 50% faster, resulting in a 1% wasm -O1 compile time progression.
+
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * b3/air/AirEliminateDeadCode.cpp:
+        (JSC::B3::Air::eliminateDeadCode):
+        * b3/air/AirTmpSet.h: Added.
+        (JSC::B3::Air::TmpSet::TmpSet):
+        (JSC::B3::Air::TmpSet::add):
+        (JSC::B3::Air::TmpSet::remove):
+        (JSC::B3::Air::TmpSet::contains):
+        (JSC::B3::Air::TmpSet::size):
+        (JSC::B3::Air::TmpSet::isEmpty):
+        (JSC::B3::Air::TmpSet::iterator::iterator):
+        (JSC::B3::Air::TmpSet::iterator::operator*):
+        (JSC::B3::Air::TmpSet::iterator::operator++):
+        (JSC::B3::Air::TmpSet::iterator::operator==):
+        (JSC::B3::Air::TmpSet::iterator::operator!=):
+        (JSC::B3::Air::TmpSet::begin):
+        (JSC::B3::Air::TmpSet::end):
+
 2017-04-04  Keith Miller  <[email protected]>
 
         WebAssembly: ModuleInformation should be a ref counted thing that can be shared across threads.

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (214922 => 214923)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2017-04-05 00:59:58 UTC (rev 214922)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2017-04-05 01:18:07 UTC (rev 214923)
@@ -632,6 +632,7 @@
 		0F9B1DB41C0E42A500E5BFD2 /* FTLOutput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F9B1DB31C0E42A500E5BFD2 /* FTLOutput.cpp */; };
 		0F9B1DB71C0E42BD00E5BFD2 /* FTLOSRExitHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F9B1DB51C0E42BD00E5BFD2 /* FTLOSRExitHandle.cpp */; };
 		0F9B1DB81C0E42BD00E5BFD2 /* FTLOSRExitHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9B1DB61C0E42BD00E5BFD2 /* FTLOSRExitHandle.h */; };
+		0F9C03D51E9476F200CD9125 /* AirTmpSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9C03D41E9476F000CD9125 /* AirTmpSet.h */; };
 		0F9CABC81DB54A780008E83B /* AirPadInterference.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F9CABC61DB54A760008E83B /* AirPadInterference.cpp */; };
 		0F9CABC91DB54A7A0008E83B /* AirPadInterference.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9CABC71DB54A760008E83B /* AirPadInterference.h */; };
 		0F9D3370165DBB90005AD387 /* Disassembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F9D336E165DBB8D005AD387 /* Disassembler.cpp */; };
@@ -3166,6 +3167,7 @@
 		0F9B1DB31C0E42A500E5BFD2 /* FTLOutput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FTLOutput.cpp; path = ftl/FTLOutput.cpp; sourceTree = "<group>"; };
 		0F9B1DB51C0E42BD00E5BFD2 /* FTLOSRExitHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FTLOSRExitHandle.cpp; path = ftl/FTLOSRExitHandle.cpp; sourceTree = "<group>"; };
 		0F9B1DB61C0E42BD00E5BFD2 /* FTLOSRExitHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLOSRExitHandle.h; path = ftl/FTLOSRExitHandle.h; sourceTree = "<group>"; };
+		0F9C03D41E9476F000CD9125 /* AirTmpSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirTmpSet.h; path = b3/air/AirTmpSet.h; sourceTree = "<group>"; };
 		0F9CABC61DB54A760008E83B /* AirPadInterference.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirPadInterference.cpp; path = b3/air/AirPadInterference.cpp; sourceTree = "<group>"; };
 		0F9CABC71DB54A760008E83B /* AirPadInterference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirPadInterference.h; path = b3/air/AirPadInterference.h; sourceTree = "<group>"; };
 		0F9D336E165DBB8D005AD387 /* Disassembler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Disassembler.cpp; path = disassembler/Disassembler.cpp; sourceTree = "<group>"; };
@@ -5656,6 +5658,7 @@
 				0FEC85681BDACDC70080FF74 /* AirTmp.cpp */,
 				0FEC85691BDACDC70080FF74 /* AirTmp.h */,
 				0FEC856A1BDACDC70080FF74 /* AirTmpInlines.h */,
+				0F9C03D41E9476F000CD9125 /* AirTmpSet.h */,
 				0FE0E4AB1C24C94A002E17B6 /* AirTmpWidth.cpp */,
 				0FE0E4AC1C24C94A002E17B6 /* AirTmpWidth.h */,
 				0F3730921C0D67EE00052BFA /* AirUseCounts.h */,
@@ -8351,6 +8354,7 @@
 				6553A33217A1F1EE008CF6F3 /* CommonSlowPathsExceptions.h in Headers */,
 				0FD82E39141AB14D00179C94 /* CompactJITCodeMap.h in Headers */,
 				A7E5A3A81797432D00E893C0 /* CompilationResult.h in Headers */,
+				0F9C03D51E9476F200CD9125 /* AirTmpSet.h in Headers */,
 				BC18C3F40E16F5CD00B34460 /* Completion.h in Headers */,
 				0F6FC751196110A800E1D02D /* ComplexGetStatus.h in Headers */,
 				0FDB2CEA174896C7007B3C1B /* ConcurrentJSLock.h in Headers */,

Modified: trunk/Source/_javascript_Core/b3/air/AirEliminateDeadCode.cpp (214922 => 214923)


--- trunk/Source/_javascript_Core/b3/air/AirEliminateDeadCode.cpp	2017-04-05 00:59:58 UTC (rev 214922)
+++ trunk/Source/_javascript_Core/b3/air/AirEliminateDeadCode.cpp	2017-04-05 01:18:07 UTC (rev 214923)
@@ -31,6 +31,8 @@
 #include "AirCode.h"
 #include "AirInstInlines.h"
 #include "AirPhaseScope.h"
+#include "AirTmpInlines.h"
+#include "AirTmpSet.h"
 #include <wtf/IndexSet.h>
 
 namespace JSC { namespace B3 { namespace Air {
@@ -39,7 +41,7 @@
 {
     PhaseScope phaseScope(code, "eliminateDeadCode");
 
-    HashSet<Tmp> liveTmps;
+    TmpSet liveTmps;
     IndexSet<StackSlot*> liveStackSlots;
     bool changed;
 
@@ -63,7 +65,7 @@
         case Arg::Tmp:
             if (arg.isReg())
                 return false;
-            return liveTmps.add(arg.tmp()).isNewEntry;
+            return liveTmps.add(arg.tmp());
         case Arg::Stack:
             if (arg.stackSlot()->isLocked())
                 return false;

Added: trunk/Source/_javascript_Core/b3/air/AirTmpSet.h (0 => 214923)


--- trunk/Source/_javascript_Core/b3/air/AirTmpSet.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/b3/air/AirTmpSet.h	2017-04-05 01:18:07 UTC (rev 214923)
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#pragma once
+
+#if ENABLE(B3_JIT)
+
+#include "AirTmp.h"
+#include <wtf/IndexSet.h>
+
+namespace JSC { namespace B3 { namespace Air {
+
+class TmpSet {
+public:
+    TmpSet()
+    {
+    }
+    
+    bool add(Tmp tmp)
+    {
+        if (tmp.isGP())
+            return m_gp.add(tmp);
+        return m_fp.add(tmp);
+    }
+    
+    bool remove(Tmp tmp)
+    {
+        if (tmp.isGP())
+            return m_gp.remove(tmp);
+        return m_fp.remove(tmp);
+    }
+    
+    bool contains(Tmp tmp)
+    {
+        if (tmp.isGP())
+            return m_gp.contains(tmp);
+        return m_fp.contains(tmp);
+    }
+    
+    size_t size() const
+    {
+        return m_gp.size() + m_fp.size();
+    }
+    
+    bool isEmpty() const
+    {
+        return !size();
+    }
+
+    class iterator {
+    public:
+        iterator()
+        {
+        }
+        
+        iterator(BitVector::iterator gpIter, BitVector::iterator fpIter)
+            : m_gpIter(gpIter)
+            , m_fpIter(fpIter)
+        {
+        }
+        
+        Tmp operator*()
+        {
+            if (!m_gpIter.isAtEnd())
+                return Tmp::tmpForAbsoluteIndex(GP, *m_gpIter);
+            return Tmp::tmpForAbsoluteIndex(FP, *m_fpIter);
+        }
+        
+        iterator& operator++()
+        {
+            if (!m_gpIter.isAtEnd()) {
+                ++m_gpIter;
+                return *this;
+            }
+            ++m_fpIter;
+            return *this;
+        }
+        
+        bool operator==(const iterator& other) const
+        {
+            return m_gpIter == other.m_gpIter
+                && m_fpIter == other.m_fpIter;
+        }
+        
+        bool operator!=(const iterator& other) const
+        {
+            return !(*this == other);
+        }
+        
+    private:
+        BitVector::iterator m_gpIter;
+        BitVector::iterator m_fpIter;
+    };
+    
+    iterator begin() const { return iterator(m_gp.indices().begin(), m_fp.indices().begin()); }
+    iterator end() const { return iterator(m_gp.indices().end(), m_fp.indices().end()); }
+
+private:
+    IndexSet<Tmp::AbsolutelyIndexed<GP>> m_gp;
+    IndexSet<Tmp::AbsolutelyIndexed<FP>> m_fp;
+};
+
+} } } // namespace JSC::B3::Air
+
+#endif // ENABLE(B3_JIT)
+

Modified: trunk/Source/WTF/ChangeLog (214922 => 214923)


--- trunk/Source/WTF/ChangeLog	2017-04-05 00:59:58 UTC (rev 214922)
+++ trunk/Source/WTF/ChangeLog	2017-04-05 01:18:07 UTC (rev 214923)
@@ -1,3 +1,15 @@
+2017-04-04  Filip Pizlo  <[email protected]>
+
+        Air::eliminateDeadCode() should not use a HashSet
+        https://bugs.webkit.org/show_bug.cgi?id=170487
+
+        Reviewed by Saam Barati.
+        
+        BitVector::iterator knows when it's at the end. Expose this functionality.
+
+        * wtf/BitVector.h:
+        (WTF::BitVector::iterator::isAtEnd):
+
 2017-04-04  Keith Miller  <[email protected]>
 
         WebAssembly: ModuleInformation should be a ref counted thing that can be shared across threads.

Modified: trunk/Source/WTF/wtf/BitVector.h (214922 => 214923)


--- trunk/Source/WTF/wtf/BitVector.h	2017-04-05 00:59:58 UTC (rev 214922)
+++ trunk/Source/WTF/wtf/BitVector.h	2017-04-05 01:18:07 UTC (rev 214923)
@@ -307,6 +307,11 @@
             m_index = m_bitVector->findBit(m_index + 1, true);
             return *this;
         }
+
+        bool isAtEnd() const
+        {
+            return m_index >= m_bitVector->size();
+        }
         
         bool operator==(const iterator& other) const
         {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to