Title: [242054] trunk/Source/_javascript_Core
Revision
242054
Author
[email protected]
Date
2019-02-25 12:15:53 -0800 (Mon, 25 Feb 2019)

Log Message

Avoid hashing CompactVariableEnvironment when decoding CompactVariableMap::Handle
https://bugs.webkit.org/show_bug.cgi?id=194937

Reviewed by Saam Barati.

Hashing the CompactVariableEnvironment is expensive and we could avoid it
when decoding multiple handles to the same environment. This is sound because
a pointer to the same CompactVariableEnvironment will hash the same.

* runtime/CachedTypes.cpp:
(JSC::Decoder::handleForEnvironment const):
(JSC::Decoder::setHandleForEnvironment):
(JSC::CachedCompactVariableMapHandle::decode const):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (242053 => 242054)


--- trunk/Source/_javascript_Core/ChangeLog	2019-02-25 20:13:01 UTC (rev 242053)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-02-25 20:15:53 UTC (rev 242054)
@@ -1,5 +1,21 @@
 2019-02-25  Tadeu Zagallo  <[email protected]>
 
+        Avoid hashing CompactVariableEnvironment when decoding CompactVariableMap::Handle
+        https://bugs.webkit.org/show_bug.cgi?id=194937
+
+        Reviewed by Saam Barati.
+
+        Hashing the CompactVariableEnvironment is expensive and we could avoid it
+        when decoding multiple handles to the same environment. This is sound because
+        a pointer to the same CompactVariableEnvironment will hash the same.
+
+        * runtime/CachedTypes.cpp:
+        (JSC::Decoder::handleForEnvironment const):
+        (JSC::Decoder::setHandleForEnvironment):
+        (JSC::CachedCompactVariableMapHandle::decode const):
+
+2019-02-25  Tadeu Zagallo  <[email protected]>
+
         Remove unnecessary WTF:: prefixes in CachedTypes
         https://bugs.webkit.org/show_bug.cgi?id=194936
 

Modified: trunk/Source/_javascript_Core/runtime/CachedTypes.cpp (242053 => 242054)


--- trunk/Source/_javascript_Core/runtime/CachedTypes.cpp	2019-02-25 20:13:01 UTC (rev 242053)
+++ trunk/Source/_javascript_Core/runtime/CachedTypes.cpp	2019-02-25 20:15:53 UTC (rev 242054)
@@ -259,6 +259,19 @@
         m_finalizers.append(finalizer);
     }
 
+    CompactVariableMap::Handle handleForEnvironment(CompactVariableEnvironment* environment) const
+    {
+        auto it = m_environmentToHandleMap.find(environment);
+        ASSERT(it != m_environmentToHandleMap.end());
+        return it->value;
+    }
+
+    void setHandleForEnvironment(CompactVariableEnvironment* environment, const CompactVariableMap::Handle& handle)
+    {
+        auto addResult = m_environmentToHandleMap.add(environment, handle);
+        ASSERT_UNUSED(addResult, addResult.isNewEntry);
+    }
+
 private:
     VM& m_vm;
     const uint8_t* m_baseAddress;
@@ -267,6 +280,7 @@
 #endif
     HashMap<ptrdiff_t, void*> m_offsetToPtrMap;
     Vector<std::function<void()>> m_finalizers;
+    HashMap<CompactVariableEnvironment*, CompactVariableMap::Handle> m_environmentToHandleMap;
 };
 
 template<typename T>
@@ -938,15 +952,16 @@
     {
         bool isNewAllocation;
         CompactVariableEnvironment* environment = m_environment.decode(decoder, isNewAllocation);
+        if (!isNewAllocation)
+            return decoder.handleForEnvironment(environment);
         bool isNewEntry;
         CompactVariableMap::Handle handle = decoder.vm().m_compactVariableMap->get(environment, isNewEntry);
-        if (!isNewAllocation)
-            ASSERT(!isNewEntry);
-        else if (!isNewEntry) {
+        if (!isNewEntry) {
             decoder.addFinalizer([=] {
                 delete environment;
             });
         }
+        decoder.setHandleForEnvironment(environment, handle);
         return handle;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to