- Revision
- 233627
- Author
- [email protected]
- Date
- 2018-07-08 09:41:14 -0700 (Sun, 08 Jul 2018)
Log Message
[JSC] Optimize padding of InferredTypeTable by using cellLock
https://bugs.webkit.org/show_bug.cgi?id=187447
Reviewed by Mark Lam.
Use cellLock() in InferredTypeTable to guard changes of internal structures.
This is the same usage to SparseArrayValueMap. By using cellLock(), we can
reduce the size of InferredTypeTable from 40 to 32.
* runtime/InferredTypeTable.cpp:
(JSC::InferredTypeTable::visitChildren):
(JSC::InferredTypeTable::get):
(JSC::InferredTypeTable::willStoreValue):
(JSC::InferredTypeTable::makeTop):
* runtime/InferredTypeTable.h:
Using enum class and using. And remove `isEmpty()` since it is not used.
* runtime/Structure.h:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (233626 => 233627)
--- trunk/Source/_javascript_Core/ChangeLog 2018-07-08 12:29:08 UTC (rev 233626)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-07-08 16:41:14 UTC (rev 233627)
@@ -1,3 +1,24 @@
+2018-07-08 Yusuke Suzuki <[email protected]>
+
+ [JSC] Optimize padding of InferredTypeTable by using cellLock
+ https://bugs.webkit.org/show_bug.cgi?id=187447
+
+ Reviewed by Mark Lam.
+
+ Use cellLock() in InferredTypeTable to guard changes of internal structures.
+ This is the same usage to SparseArrayValueMap. By using cellLock(), we can
+ reduce the size of InferredTypeTable from 40 to 32.
+
+ * runtime/InferredTypeTable.cpp:
+ (JSC::InferredTypeTable::visitChildren):
+ (JSC::InferredTypeTable::get):
+ (JSC::InferredTypeTable::willStoreValue):
+ (JSC::InferredTypeTable::makeTop):
+ * runtime/InferredTypeTable.h:
+ Using enum class and using. And remove `isEmpty()` since it is not used.
+
+ * runtime/Structure.h:
+
2018-07-07 Yusuke Suzuki <[email protected]>
[JSC] Optimize layout of SourceProvider to reduce padding
Modified: trunk/Source/_javascript_Core/runtime/InferredTypeTable.cpp (233626 => 233627)
--- trunk/Source/_javascript_Core/runtime/InferredTypeTable.cpp 2018-07-08 12:29:08 UTC (rev 233626)
+++ trunk/Source/_javascript_Core/runtime/InferredTypeTable.cpp 2018-07-08 16:41:14 UTC (rev 233627)
@@ -55,7 +55,7 @@
InferredTypeTable* inferredTypeTable = jsCast<InferredTypeTable*>(cell);
Base::visitChildren(cell, visitor);
- ConcurrentJSLocker locker(inferredTypeTable->m_lock);
+ auto locker = holdLock(inferredTypeTable->cellLock());
for (auto& entry : inferredTypeTable->m_table) {
auto entryValue = entry.value;
@@ -69,7 +69,7 @@
}
}
-InferredType* InferredTypeTable::get(const ConcurrentJSLocker&, UniquedStringImpl* uid)
+InferredType* InferredTypeTable::get(const AbstractLocker&, UniquedStringImpl* uid)
{
auto iter = m_table.find(uid);
if (iter == m_table.end())
@@ -90,7 +90,7 @@
InferredType* InferredTypeTable::get(UniquedStringImpl* uid)
{
- ConcurrentJSLocker locker(m_lock);
+ auto locker = holdLock(cellLock());
return get(locker, uid);
}
@@ -104,7 +104,7 @@
{
// The algorithm here relies on the fact that only one thread modifies the hash map.
- if (age == OldProperty) {
+ if (age == StoredPropertyAge::OldProperty) {
TableType::iterator iter = m_table.find(propertyName.uid());
if (iter == m_table.end())
return false; // Absence on replace => top.
@@ -122,7 +122,7 @@
TableType::AddResult result;
{
- ConcurrentJSLocker locker(m_lock);
+ auto locker = holdLock(cellLock());
result = m_table.add(propertyName.uid(), WriteBarrier<InferredType>());
}
InferredType* entryValue = result.iterator->value.get();
@@ -145,7 +145,7 @@
void InferredTypeTable::makeTop(VM& vm, PropertyName propertyName, StoredPropertyAge age)
{
// The algorithm here relies on the fact that only one thread modifies the hash map.
- if (age == OldProperty) {
+ if (age == StoredPropertyAge::OldProperty) {
TableType::iterator iter = m_table.find(propertyName.uid());
if (iter == m_table.end())
return; // Absence on replace => top.
@@ -162,7 +162,7 @@
TableType::AddResult result;
{
- ConcurrentJSLocker locker(m_lock);
+ auto locker = holdLock(cellLock());
result = m_table.add(propertyName.uid(), WriteBarrier<InferredType>());
}
if (!result.iterator->value)
Modified: trunk/Source/_javascript_Core/runtime/InferredTypeTable.h (233626 => 233627)
--- trunk/Source/_javascript_Core/runtime/InferredTypeTable.h 2018-07-08 12:29:08 UTC (rev 233626)
+++ trunk/Source/_javascript_Core/runtime/InferredTypeTable.h 2018-07-08 16:41:14 UTC (rev 233627)
@@ -55,20 +55,13 @@
DECLARE_INFO;
- ConcurrentJSLock& lock() { return m_lock; }
-
- bool isEmpty() const { return m_table.isEmpty(); }
-
// Get the current inferred type. Returns nullptr for both Top and Bottom. Null means Bottom if the
// owning Structure doesn't know about the property.
- InferredType* get(const ConcurrentJSLocker&, UniquedStringImpl*);
+ InferredType* get(const AbstractLocker&, UniquedStringImpl*);
InferredType* get(UniquedStringImpl*);
InferredType* get(PropertyName);
- enum StoredPropertyAge {
- NewProperty,
- OldProperty
- };
+ enum class StoredPropertyAge { NewProperty, OldProperty };
// Returns true if the InferredType for this property is still relevant after the store. It's not
// relevant if it's Top. Note that this table will internally prune Top entries.
@@ -97,13 +90,9 @@
// that's bad. We avoid such confusion by ensuring that a transition always adds an entry. Hence,
// absence-means-bottom only comes into play for properties added before the InferredTypeTable was
// created.
- typedef HashMap<RefPtr<UniquedStringImpl>, WriteBarrier<InferredType>, IdentifierRepHash> TableType;
-
+ using TableType = HashMap<RefPtr<UniquedStringImpl>, WriteBarrier<InferredType>, IdentifierRepHash>;
+
TableType m_table;
-
- // We only grab this lock when we're doing modifications on the main thread, or reads on the compiler
- // thread. The compiler thread is not allowed to do modifications.
- ConcurrentJSLock m_lock;
};
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/Structure.h (233626 => 233627)
--- trunk/Source/_javascript_Core/runtime/Structure.h 2018-07-08 12:29:08 UTC (rev 233626)
+++ trunk/Source/_javascript_Core/runtime/Structure.h 2018-07-08 16:41:14 UTC (rev 233627)
@@ -617,7 +617,7 @@
{
if (hasBeenDictionary() || (!shouldOptimize && !m_inferredTypeTable) || !VM::canUseJIT())
return;
- willStoreValueSlow(vm, propertyName, value, shouldOptimize, InferredTypeTable::NewProperty);
+ willStoreValueSlow(vm, propertyName, value, shouldOptimize, InferredTypeTable::StoredPropertyAge::NewProperty);
}
// Call this when we know that this is a new property for the object, but not new for the
@@ -628,7 +628,7 @@
{
if (hasBeenDictionary() || !m_inferredTypeTable || !VM::canUseJIT())
return;
- willStoreValueSlow(vm, propertyName, value, shouldOptimize, InferredTypeTable::NewProperty);
+ willStoreValueSlow(vm, propertyName, value, shouldOptimize, InferredTypeTable::StoredPropertyAge::NewProperty);
}
// Call this when we know that the inferred type table exists and has an entry for this property.
@@ -637,7 +637,7 @@
{
if (hasBeenDictionary() || !VM::canUseJIT())
return;
- willStoreValueSlow(vm, propertyName, value, shouldOptimize, InferredTypeTable::OldProperty);
+ willStoreValueSlow(vm, propertyName, value, shouldOptimize, InferredTypeTable::StoredPropertyAge::OldProperty);
}
Ref<StructureShape> toStructureShape(JSValue, bool& sawPolyProtoStructure);