Title: [163419] trunk/Source/_javascript_Core
Revision
163419
Author
mhahnenb...@apple.com
Date
2014-02-04 17:28:07 -0800 (Tue, 04 Feb 2014)

Log Message

Reduce boilerplate in BlockAllocator.h
https://bugs.webkit.org/show_bug.cgi?id=128222

Reviewed by Filip Pizlo.

There are a lot of template specializations for the various types of HeapBlocks 
in BlockAllocator.h. We could reduce the spew by using a macro.

* heap/BlockAllocator.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (163418 => 163419)


--- trunk/Source/_javascript_Core/ChangeLog	2014-02-05 01:03:21 UTC (rev 163418)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-02-05 01:28:07 UTC (rev 163419)
@@ -1,3 +1,15 @@
+2014-02-04  Mark Hahnenberg  <mhahnenb...@apple.com>
+
+        Reduce boilerplate in BlockAllocator.h
+        https://bugs.webkit.org/show_bug.cgi?id=128222
+
+        Reviewed by Filip Pizlo.
+
+        There are a lot of template specializations for the various types of HeapBlocks 
+        in BlockAllocator.h. We could reduce the spew by using a macro.
+
+        * heap/BlockAllocator.h:
+
 2014-02-04  Filip Pizlo  <fpi...@apple.com>
 
         DFG PutByVal on typed arrays should detect OutOfBounds sooner

Modified: trunk/Source/_javascript_Core/heap/BlockAllocator.h (163418 => 163419)


--- trunk/Source/_javascript_Core/heap/BlockAllocator.h	2014-02-05 01:03:21 UTC (rev 163418)
+++ trunk/Source/_javascript_Core/heap/BlockAllocator.h	2014-02-05 01:28:07 UTC (rev 163419)
@@ -217,78 +217,27 @@
     region->destroy();
 }
 
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<CopiedBlock>()
-{
-    return m_copiedRegionSet;
-}
+#define REGION_SET_FOR(blockType, set) \
+    template <> \
+    inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<blockType>() \
+    { \
+        return set; \
+    } \
+    template <> \
+    inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<blockType>>() \
+    { \
+        return set; \
+    } \
 
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<MarkedBlock>()
-{
-    return m_markedRegionSet;
-}
+REGION_SET_FOR(MarkedBlock, m_markedRegionSet);
+REGION_SET_FOR(CopiedBlock, m_copiedRegionSet);
+REGION_SET_FOR(WeakBlock, m_fourKBBlockRegionSet);
+REGION_SET_FOR(GCArraySegment<const JSCell*>, m_fourKBBlockRegionSet);
+REGION_SET_FOR(CopyWorkListSegment, m_workListRegionSet);
+REGION_SET_FOR(HandleBlock, m_fourKBBlockRegionSet);
 
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<WeakBlock>()
-{
-    return m_fourKBBlockRegionSet;
-}
+#undef REGION_SET_FOR
 
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<GCArraySegment<const JSCell*>>()
-{
-    return m_fourKBBlockRegionSet;
-}
-
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<CopyWorkListSegment>()
-{
-    return m_workListRegionSet;
-}
-
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HandleBlock>()
-{
-    return m_fourKBBlockRegionSet;
-}
-
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<CopiedBlock>>()
-{
-    return m_copiedRegionSet;
-}
-
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<MarkedBlock>>()
-{
-    return m_markedRegionSet;
-}
-
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<WeakBlock>>()
-{
-    return m_fourKBBlockRegionSet;
-}
-
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<GCArraySegment<const JSCell*>>>()
-{
-    return m_fourKBBlockRegionSet;
-}
-
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<CopyWorkListSegment>>()
-{
-    return m_workListRegionSet;
-}
-
-template <>
-inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<HandleBlock>>()
-{
-    return m_fourKBBlockRegionSet;
-}
-
 template <typename T>
 inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor()
 {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to