Title: [222007] trunk/Source/_javascript_Core
Revision
222007
Author
[email protected]
Date
2017-09-13 20:32:49 -0700 (Wed, 13 Sep 2017)

Log Message

[JSC] Move class/struct used in other class' member out of anonymous namespace
https://bugs.webkit.org/show_bug.cgi?id=176876

Reviewed by Saam Barati.

GCC warns if a class has a base or field whose type uses the anonymous namespace
and it is defined in an included file. This is because this possibly violates
one definition rule (ODR): if an included file has the anonymous namespace, each
translation unit creates its private anonymous namespace. Thus, each type
inside the anonymous namespace becomes different in each translation unit if
the file is included in multiple translation units.

While the current use in JSC is not violating ODR since these cpp files are included
only once for unified sources, specifying `-Wno-subobject-linkage` could miss
the actual bugs. So, in this patch, we just move related classes/structs out of
the anonymous namespace.

* dfg/DFGIntegerCheckCombiningPhase.cpp:
(JSC::DFG::IntegerCheckCombiningPhase::RangeKey::addition):
(JSC::DFG::IntegerCheckCombiningPhase::RangeKey::arrayBounds):
(JSC::DFG::IntegerCheckCombiningPhase::RangeKey::operator! const):
(JSC::DFG::IntegerCheckCombiningPhase::RangeKey::hash const):
(JSC::DFG::IntegerCheckCombiningPhase::RangeKey::operator== const):
(JSC::DFG::IntegerCheckCombiningPhase::RangeKey::dump const):
(JSC::DFG::IntegerCheckCombiningPhase::RangeKeyAndAddend::RangeKeyAndAddend):
(JSC::DFG::IntegerCheckCombiningPhase::RangeKeyAndAddend::operator! const):
(JSC::DFG::IntegerCheckCombiningPhase::RangeKeyAndAddend::dump const):
(JSC::DFG::IntegerCheckCombiningPhase::Range::dump const):
* dfg/DFGLICMPhase.cpp:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (222006 => 222007)


--- trunk/Source/_javascript_Core/ChangeLog	2017-09-14 03:12:17 UTC (rev 222006)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-09-14 03:32:49 UTC (rev 222007)
@@ -1,3 +1,35 @@
+2017-09-13  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Move class/struct used in other class' member out of anonymous namespace
+        https://bugs.webkit.org/show_bug.cgi?id=176876
+
+        Reviewed by Saam Barati.
+
+        GCC warns if a class has a base or field whose type uses the anonymous namespace
+        and it is defined in an included file. This is because this possibly violates
+        one definition rule (ODR): if an included file has the anonymous namespace, each
+        translation unit creates its private anonymous namespace. Thus, each type
+        inside the anonymous namespace becomes different in each translation unit if
+        the file is included in multiple translation units.
+
+        While the current use in JSC is not violating ODR since these cpp files are included
+        only once for unified sources, specifying `-Wno-subobject-linkage` could miss
+        the actual bugs. So, in this patch, we just move related classes/structs out of
+        the anonymous namespace.
+
+        * dfg/DFGIntegerCheckCombiningPhase.cpp:
+        (JSC::DFG::IntegerCheckCombiningPhase::RangeKey::addition):
+        (JSC::DFG::IntegerCheckCombiningPhase::RangeKey::arrayBounds):
+        (JSC::DFG::IntegerCheckCombiningPhase::RangeKey::operator! const):
+        (JSC::DFG::IntegerCheckCombiningPhase::RangeKey::hash const):
+        (JSC::DFG::IntegerCheckCombiningPhase::RangeKey::operator== const):
+        (JSC::DFG::IntegerCheckCombiningPhase::RangeKey::dump const):
+        (JSC::DFG::IntegerCheckCombiningPhase::RangeKeyAndAddend::RangeKeyAndAddend):
+        (JSC::DFG::IntegerCheckCombiningPhase::RangeKeyAndAddend::operator! const):
+        (JSC::DFG::IntegerCheckCombiningPhase::RangeKeyAndAddend::dump const):
+        (JSC::DFG::IntegerCheckCombiningPhase::Range::dump const):
+        * dfg/DFGLICMPhase.cpp:
+
 2017-09-13  Devin Rousso  <[email protected]>
 
         Web Inspector: Event Listeners section does not update when listeners are added/removed

Modified: trunk/Source/_javascript_Core/dfg/DFGIntegerCheckCombiningPhase.cpp (222006 => 222007)


--- trunk/Source/_javascript_Core/dfg/DFGIntegerCheckCombiningPhase.cpp	2017-09-14 03:12:17 UTC (rev 222006)
+++ trunk/Source/_javascript_Core/dfg/DFGIntegerCheckCombiningPhase.cpp	2017-09-14 03:32:49 UTC (rev 222007)
@@ -39,140 +39,119 @@
 
 namespace JSC { namespace DFG {
 
-namespace {
-
 namespace DFGIntegerCheckCombiningPhaseInternal {
 static const bool verbose = false;
 }
 
-enum RangeKind {
-    InvalidRangeKind,
-    
-    // This means we did ArithAdd with CheckOverflow.
-    Addition,
-    
-    // This means we did CheckInBounds on some length.
-    ArrayBounds
-};
+class IntegerCheckCombiningPhase : public Phase {
+public:
+    enum RangeKind {
+        InvalidRangeKind,
+        
+        // This means we did ArithAdd with CheckOverflow.
+        Addition,
+        
+        // This means we did CheckInBounds on some length.
+        ArrayBounds
+    };
 
-struct RangeKey {
-    RangeKey()
-        : m_kind(InvalidRangeKind)
-        , m_key(nullptr)
-    {
-    }
-    
-    static RangeKey addition(Edge edge)
-    {
-        RangeKey result;
-        result.m_kind = Addition;
-        result.m_source = edge.sanitized();
-        result.m_key = 0;
-        return result;
-    }
-    
-    static RangeKey arrayBounds(Edge edge, Node* key)
-    {
-        RangeKey result;
-        result.m_kind = ArrayBounds;
-        result.m_source = edge.sanitized();
-        result.m_key = key;
-        return result;
-    }
-    
-    bool operator!() const { return m_kind == InvalidRangeKind; }
-    
-    unsigned hash() const
-    {
-        return m_kind + m_source.hash() + PtrHash<Node*>::hash(m_key);
-    }
-    
-    bool operator==(const RangeKey& other) const
-    {
-        return m_kind == other.m_kind
-            && m_source == other.m_source
-            && m_key == other.m_key;
-    }
-    
-    void dump(PrintStream& out) const
-    {
-        switch (m_kind) {
-        case InvalidRangeKind:
-            out.print("InvalidRangeKind(");
-            break;
-        case Addition:
-            out.print("Addition(");
-            break;
-        case ArrayBounds:
-            out.print("ArrayBounds(");
-            break;
+    struct RangeKey {
+        static RangeKey addition(Edge edge)
+        {
+            RangeKey result;
+            result.m_kind = Addition;
+            result.m_source = edge.sanitized();
+            result.m_key = 0;
+            return result;
         }
-        if (m_source)
-            out.print(m_source);
-        else
-            out.print("null");
-        out.print(", ");
-        if (m_key)
-            out.print(m_key);
-        else
-            out.print("null");
-        out.print(")");
-    }
-    
-    RangeKind m_kind;
-    Edge m_source;
-    Node* m_key;
-};
+        
+        static RangeKey arrayBounds(Edge edge, Node* key)
+        {
+            RangeKey result;
+            result.m_kind = ArrayBounds;
+            result.m_source = edge.sanitized();
+            result.m_key = key;
+            return result;
+        }
+        
+        bool operator!() const { return m_kind == InvalidRangeKind; }
+        
+        unsigned hash() const
+        {
+            return m_kind + m_source.hash() + PtrHash<Node*>::hash(m_key);
+        }
+        
+        bool operator==(const RangeKey& other) const
+        {
+            return m_kind == other.m_kind
+                && m_source == other.m_source
+                && m_key == other.m_key;
+        }
+        
+        void dump(PrintStream& out) const
+        {
+            switch (m_kind) {
+            case InvalidRangeKind:
+                out.print("InvalidRangeKind(");
+                break;
+            case Addition:
+                out.print("Addition(");
+                break;
+            case ArrayBounds:
+                out.print("ArrayBounds(");
+                break;
+            }
+            if (m_source)
+                out.print(m_source);
+            else
+                out.print("null");
+            out.print(", ");
+            if (m_key)
+                out.print(m_key);
+            else
+                out.print("null");
+            out.print(")");
+        }
+        
+        RangeKind m_kind { InvalidRangeKind };
+        Edge m_source;
+        Node* m_key { nullptr };
+    };
 
-struct RangeKeyAndAddend {
-    RangeKeyAndAddend()
-        : m_addend(0)
-    {
-    }
-    
-    RangeKeyAndAddend(RangeKey key, int32_t addend)
-        : m_key(key)
-        , m_addend(addend)
-    {
-    }
-    
-    bool operator!() const { return !m_key && !m_addend; }
-    
-    void dump(PrintStream& out) const
-    {
-        out.print(m_key, " + ", m_addend);
-    }
-    
-    RangeKey m_key;
-    int32_t m_addend;
-};
+    struct RangeKeyAndAddend {
+        RangeKeyAndAddend() = default;
+        
+        RangeKeyAndAddend(RangeKey key, int32_t addend)
+            : m_key(key)
+            , m_addend(addend)
+        {
+        }
+        
+        bool operator!() const { return !m_key && !m_addend; }
+        
+        void dump(PrintStream& out) const
+        {
+            out.print(m_key, " + ", m_addend);
+        }
+        
+        RangeKey m_key;
+        int32_t m_addend { 0 };
+    };
 
-struct Range {
-    Range()
-        : m_minBound(0)
-        , m_maxBound(0)
-        , m_count(0)
-        , m_hoisted(false)
-    {
-    }
-    
-    void dump(PrintStream& out) const
-    {
-        out.print("(", m_minBound, " @", m_minOrigin, ") .. (", m_maxBound, " @", m_maxOrigin, "), count = ", m_count, ", hoisted = ", m_hoisted);
-    }
-    
-    int32_t m_minBound;
-    CodeOrigin m_minOrigin;
-    int32_t m_maxBound;
-    CodeOrigin m_maxOrigin;
-    unsigned m_count; // If this is zero then the bounds won't necessarily make sense.
-    bool m_hoisted;
-};
+    struct Range {
+        void dump(PrintStream& out) const
+        {
+            out.print("(", m_minBound, " @", m_minOrigin, ") .. (", m_maxBound, " @", m_maxOrigin, "), count = ", m_count, ", hoisted = ", m_hoisted);
+        }
+        
+        int32_t m_minBound { 0 };
+        CodeOrigin m_minOrigin;
+        int32_t m_maxBound { 0 };
+        CodeOrigin m_maxOrigin;
+        unsigned m_count { 0 }; // If this is zero then the bounds won't necessarily make sense.
+        bool m_hoisted { false };
+    };
 
-} // anonymous namespace
-
-class IntegerCheckCombiningPhase : public Phase {
-public:
     IntegerCheckCombiningPhase(Graph& graph)
         : Phase(graph, "integer check combining")
         , m_insertionSet(graph)

Modified: trunk/Source/_javascript_Core/dfg/DFGLICMPhase.cpp (222006 => 222007)


--- trunk/Source/_javascript_Core/dfg/DFGLICMPhase.cpp	2017-09-14 03:12:17 UTC (rev 222006)
+++ trunk/Source/_javascript_Core/dfg/DFGLICMPhase.cpp	2017-09-14 03:32:49 UTC (rev 222007)
@@ -45,25 +45,16 @@
 
 namespace JSC { namespace DFG {
 
-namespace {
+class LICMPhase : public Phase {
+    static const bool verbose = false;
 
-using NaturalLoop = SSANaturalLoop;
+    using NaturalLoop = SSANaturalLoop;
 
-struct LoopData {
-    LoopData()
-        : preHeader(nullptr)
-    {
-    }
+    struct LoopData {
+        ClobberSet writes;
+        BasicBlock* preHeader { nullptr };
+    };
     
-    ClobberSet writes;
-    BasicBlock* preHeader;
-};
-
-} // anonymous namespace
-
-class LICMPhase : public Phase {
-    static const bool verbose = false;
-    
 public:
     LICMPhase(Graph& graph)
         : Phase(graph, "LICM")
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to