Title: [141295] trunk/Source
Revision
141295
Author
mhahnenb...@apple.com
Date
2013-01-30 12:05:14 -0800 (Wed, 30 Jan 2013)

Log Message

Structure::m_outOfLineCapacity is unnecessary
https://bugs.webkit.org/show_bug.cgi?id=108206

Reviewed by Geoffrey Garen.

Source/_javascript_Core: 

We can calculate our out of line capacity by using the outOfLineSize and our knowledge about our resize policy.
According to GDB, this knocks Structures down from 136 bytes to 128 bytes (I'm guessing the extra bytes are from
better alignment of object fields), which puts Structures in a smaller size class. Woohoo! Looks neutral on our 
benchmarks.

* runtime/Structure.cpp:
(JSC::Structure::Structure):
(JSC):
(JSC::Structure::suggestedNewOutOfLineStorageCapacity):
(JSC::Structure::addPropertyTransition):
(JSC::Structure::addPropertyWithoutTransition):
* runtime/Structure.h:
(Structure):
(JSC::Structure::outOfLineCapacity):
(JSC::Structure::totalStorageCapacity):

Source/WTF: 

We're adding a new function that gives us the ability to round a value up to the next power of a certain base.

* wtf/MathExtras.h:
(WTF::roundUpToPowerOf):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (141294 => 141295)


--- trunk/Source/_javascript_Core/ChangeLog	2013-01-30 20:03:24 UTC (rev 141294)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-01-30 20:05:14 UTC (rev 141295)
@@ -1,3 +1,26 @@
+2013-01-29  Mark Hahnenberg  <mhahnenb...@apple.com>
+
+        Structure::m_outOfLineCapacity is unnecessary
+        https://bugs.webkit.org/show_bug.cgi?id=108206
+
+        Reviewed by Geoffrey Garen.
+
+        We can calculate our out of line capacity by using the outOfLineSize and our knowledge about our resize policy.
+        According to GDB, this knocks Structures down from 136 bytes to 128 bytes (I'm guessing the extra bytes are from
+        better alignment of object fields), which puts Structures in a smaller size class. Woohoo! Looks neutral on our 
+        benchmarks.
+
+        * runtime/Structure.cpp:
+        (JSC::Structure::Structure):
+        (JSC):
+        (JSC::Structure::suggestedNewOutOfLineStorageCapacity):
+        (JSC::Structure::addPropertyTransition):
+        (JSC::Structure::addPropertyWithoutTransition):
+        * runtime/Structure.h:
+        (Structure):
+        (JSC::Structure::outOfLineCapacity):
+        (JSC::Structure::totalStorageCapacity):
+
 2013-01-29  Geoffrey Garen  <gga...@apple.com>
 
         Be a little more conservative about emitting table-based switches

Modified: trunk/Source/_javascript_Core/runtime/Structure.cpp (141294 => 141295)


--- trunk/Source/_javascript_Core/runtime/Structure.cpp	2013-01-30 20:03:24 UTC (rev 141294)
+++ trunk/Source/_javascript_Core/runtime/Structure.cpp	2013-01-30 20:05:14 UTC (rev 141295)
@@ -157,7 +157,6 @@
     , m_prototype(globalData, this, prototype)
     , m_classInfo(classInfo)
     , m_transitionWatchpointSet(InitializedWatching)
-    , m_outOfLineCapacity(0)
     , m_inlineCapacity(inlineCapacity)
     , m_offset(invalidOffset)
     , m_dictionaryKind(NoneDictionaryKind)
@@ -184,7 +183,6 @@
     , m_prototype(globalData, this, jsNull())
     , m_classInfo(&s_info)
     , m_transitionWatchpointSet(InitializedWatching)
-    , m_outOfLineCapacity(0)
     , m_inlineCapacity(0)
     , m_offset(invalidOffset)
     , m_dictionaryKind(NoneDictionaryKind)
@@ -207,7 +205,6 @@
     , m_prototype(globalData, this, previous->storedPrototype())
     , m_classInfo(previous->m_classInfo)
     , m_transitionWatchpointSet(InitializedWatching)
-    , m_outOfLineCapacity(previous->m_outOfLineCapacity)
     , m_inlineCapacity(previous->m_inlineCapacity)
     , m_offset(invalidOffset)
     , m_dictionaryKind(previous->m_dictionaryKind)
@@ -273,14 +270,9 @@
     return currentCapacity * outOfLineGrowthFactor;
 }
 
-void Structure::growOutOfLineCapacity()
-{
-    m_outOfLineCapacity = nextOutOfLineStorageCapacity(m_outOfLineCapacity);
-}
-
 size_t Structure::suggestedNewOutOfLineStorageCapacity()
 {
-    return nextOutOfLineStorageCapacity(m_outOfLineCapacity);
+    return nextOutOfLineStorageCapacity(outOfLineCapacity());
 }
  
 void Structure::despecifyDictionaryFunction(JSGlobalData& globalData, PropertyName propertyName)
@@ -365,8 +357,6 @@
         Structure* transition = toCacheableDictionaryTransition(globalData, structure);
         ASSERT(structure != transition);
         offset = transition->putSpecificValue(globalData, propertyName, attributes, specificValue);
-        if (transition->outOfLineSize() > transition->outOfLineCapacity())
-            transition->growOutOfLineCapacity();
         return transition;
     }
     
@@ -391,8 +381,6 @@
     }
 
     offset = transition->putSpecificValue(globalData, propertyName, attributes, specificValue);
-    if (transition->outOfLineSize() > transition->outOfLineCapacity())
-        transition->growOutOfLineCapacity();
 
     transition->m_offset = offset;
     checkOffset(transition->m_offset, transition->inlineCapacity());
@@ -664,10 +652,7 @@
     
     pin();
 
-    PropertyOffset offset = putSpecificValue(globalData, propertyName, attributes, specificValue);
-    if (outOfLineSize() > outOfLineCapacity())
-        growOutOfLineCapacity();
-    return offset;
+    return putSpecificValue(globalData, propertyName, attributes, specificValue);
 }
 
 PropertyOffset Structure::removePropertyWithoutTransition(JSGlobalData& globalData, PropertyName propertyName)

Modified: trunk/Source/_javascript_Core/runtime/Structure.h (141294 => 141295)


--- trunk/Source/_javascript_Core/runtime/Structure.h	2013-01-30 20:03:24 UTC (rev 141294)
+++ trunk/Source/_javascript_Core/runtime/Structure.h	2013-01-30 20:05:14 UTC (rev 141295)
@@ -182,11 +182,18 @@
         }
         bool transitivelyTransitionedFrom(Structure* structureToFind);
 
-        void growOutOfLineCapacity();
         unsigned outOfLineCapacity() const
         {
-            ASSERT(structure()->classInfo() == &s_info);
-            return m_outOfLineCapacity;
+            unsigned outOfLineSize = this->outOfLineSize();
+
+            if (!outOfLineSize)
+                return 0;
+
+            if (outOfLineSize <= initialOutOfLineCapacity)
+                return initialOutOfLineCapacity;
+
+            ASSERT(outOfLineSize > initialOutOfLineCapacity);
+            return WTF::roundUpToPowerOf<outOfLineGrowthFactor>(outOfLineSize);
         }
         unsigned outOfLineSize() const
         {
@@ -226,7 +233,7 @@
         unsigned totalStorageCapacity() const
         {
             ASSERT(structure()->classInfo() == &s_info);
-            return m_outOfLineCapacity + inlineCapacity();
+            return outOfLineCapacity() + inlineCapacity();
         }
 
         PropertyOffset firstValidOffset() const
@@ -435,7 +442,6 @@
         
         mutable InlineWatchpointSet m_transitionWatchpointSet;
 
-        uint32_t m_outOfLineCapacity;
         uint8_t m_inlineCapacity;
         COMPILE_ASSERT(firstOutOfLineOffset < 256, firstOutOfLineOffset_fits);
 

Modified: trunk/Source/WTF/ChangeLog (141294 => 141295)


--- trunk/Source/WTF/ChangeLog	2013-01-30 20:03:24 UTC (rev 141294)
+++ trunk/Source/WTF/ChangeLog	2013-01-30 20:05:14 UTC (rev 141295)
@@ -1,3 +1,15 @@
+2013-01-29  Mark Hahnenberg  <mhahnenb...@apple.com>
+
+        Structure::m_outOfLineCapacity is unnecessary
+        https://bugs.webkit.org/show_bug.cgi?id=108206
+
+        Reviewed by Geoffrey Garen.
+
+        We're adding a new function that gives us the ability to round a value up to the next power of a certain base.
+
+        * wtf/MathExtras.h:
+        (WTF::roundUpToPowerOf):
+
 2013-01-30  Zeno Albisser  <z...@webkit.org>
 
         [Qt] Fix Qt/Mac build after r141024 and r141037

Modified: trunk/Source/WTF/wtf/MathExtras.h (141294 => 141295)


--- trunk/Source/WTF/wtf/MathExtras.h	2013-01-30 20:03:24 UTC (rev 141294)
+++ trunk/Source/WTF/wtf/MathExtras.h	2013-01-30 20:05:14 UTC (rev 141295)
@@ -429,4 +429,30 @@
     }
 }
 
+namespace WTF {
+
+// Be careful, this might be super slow in a hot loop.
+template<size_t exponent> inline size_t roundUpToPowerOf(size_t v)
+{
+    return round(pow(static_cast<double>(exponent), ceil(log(static_cast<double>(v)) / log(static_cast<double>(exponent)))));
+}
+
+// From http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
+template<> inline size_t roundUpToPowerOf<2>(size_t v)
+{
+    v--;
+    v |= v >> 1;
+    v |= v >> 2;
+    v |= v >> 4;
+    v |= v >> 8;
+    v |= v >> 16;
+#if defined(__LP64__) && __LP64__
+    v |= v >> 32;
+#endif
+    v++;
+    return v;
+}
+
+} // namespace WTF
+
 #endif // #ifndef WTF_MathExtras_h
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to