Title: [292682] trunk/Source/_javascript_Core
Revision
292682
Author
ysuz...@apple.com
Date
2022-04-09 15:25:24 -0700 (Sat, 09 Apr 2022)

Log Message

[JSC] Use Vector with inline capacity in ObjectPropertyConditionSet creation
https://bugs.webkit.org/show_bug.cgi?id=239025

Reviewed by Keith Miller.

Since we anyway allocate ThreadSafeRefCountedFixedVector<ObjectPropertyCondition> in ObjectPropertyConditionSet, which has exact size,
generateXXX and mergeWith should not allocate heap Vector just for temporarily collecting ObjectPropertyCondition.
We pick 8 in generateXXX function and 16 for mergeWith function. This looks reasonable number and at least covers all cases in Speedometer2.

* bytecode/ObjectPropertyConditionSet.cpp:
(JSC::ObjectPropertyConditionSet::mergedWith const):
(JSC::generateConditionsForPropertyMiss):
(JSC::generateConditionsForPropertySetterMiss):
(JSC::generateConditionsForPrototypePropertyHit):
(JSC::generateConditionsForPrototypePropertyHitCustom):
(JSC::generateConditionsForInstanceOf):
(JSC::generateConditionsForPrototypeEquivalenceConcurrently):
(JSC::generateConditionsForPropertyMissConcurrently):
(JSC::generateConditionsForPropertySetterMissConcurrently):
* bytecode/ObjectPropertyConditionSet.h:
(JSC::ObjectPropertyConditionSet::create):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (292681 => 292682)


--- trunk/Source/_javascript_Core/ChangeLog	2022-04-09 20:26:16 UTC (rev 292681)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-04-09 22:25:24 UTC (rev 292682)
@@ -1,3 +1,27 @@
+2022-04-09  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] Use Vector with inline capacity in ObjectPropertyConditionSet creation
+        https://bugs.webkit.org/show_bug.cgi?id=239025
+
+        Reviewed by Keith Miller.
+
+        Since we anyway allocate ThreadSafeRefCountedFixedVector<ObjectPropertyCondition> in ObjectPropertyConditionSet, which has exact size,
+        generateXXX and mergeWith should not allocate heap Vector just for temporarily collecting ObjectPropertyCondition.
+        We pick 8 in generateXXX function and 16 for mergeWith function. This looks reasonable number and at least covers all cases in Speedometer2.
+
+        * bytecode/ObjectPropertyConditionSet.cpp:
+        (JSC::ObjectPropertyConditionSet::mergedWith const):
+        (JSC::generateConditionsForPropertyMiss):
+        (JSC::generateConditionsForPropertySetterMiss):
+        (JSC::generateConditionsForPrototypePropertyHit):
+        (JSC::generateConditionsForPrototypePropertyHitCustom):
+        (JSC::generateConditionsForInstanceOf):
+        (JSC::generateConditionsForPrototypeEquivalenceConcurrently):
+        (JSC::generateConditionsForPropertyMissConcurrently):
+        (JSC::generateConditionsForPropertySetterMissConcurrently):
+        * bytecode/ObjectPropertyConditionSet.h:
+        (JSC::ObjectPropertyConditionSet::create):
+
 2022-04-09  Adrian Perez de Castro  <ape...@igalia.com>
 
         [GTK][WPE] Missing inter-module documentation links

Modified: trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.cpp (292681 => 292682)


--- trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.cpp	2022-04-09 20:26:16 UTC (rev 292681)
+++ trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.cpp	2022-04-09 22:25:24 UTC (rev 292682)
@@ -102,7 +102,7 @@
     if (!isValid() || !other.isValid())
         return invalid();
 
-    Vector<ObjectPropertyCondition> result;
+    Vector<ObjectPropertyCondition, 16> result;
     
     if (!isEmpty())
         result.append(m_data->begin(), m_data->size());
@@ -121,7 +121,7 @@
             result.append(newCondition);
     }
 
-    return create(WTFMove(result));
+    return ObjectPropertyConditionSet::create(WTFMove(result));
 }
 
 bool ObjectPropertyConditionSet::structuresEnsureValidity() const
@@ -247,7 +247,7 @@
 ObjectPropertyConditionSet generateConditions(
     VM& vm, JSGlobalObject* globalObject, Structure* structure, JSObject* prototype, const Functor& functor)
 {
-    Vector<ObjectPropertyCondition> conditions;
+    Vector<ObjectPropertyCondition, 8> conditions;
     
     for (;;) {
         if (ObjectPropertyConditionSetInternal::verbose)
@@ -315,7 +315,7 @@
 {
     return generateConditions(
         vm, globalObject, headStructure, nullptr,
-        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
+        [&](auto& conditions, JSObject* object) -> bool {
             ObjectPropertyCondition result =
                 generateCondition(vm, owner, object, uid, PropertyCondition::Absence, Concurrency::MainThread);
             if (!result)
@@ -330,7 +330,7 @@
 {
     return generateConditions(
         vm, globalObject, headStructure, nullptr,
-        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
+        [&](auto& conditions, JSObject* object) -> bool {
             ObjectPropertyCondition result =
                 generateCondition(vm, owner, object, uid, PropertyCondition::AbsenceOfSetEffect, Concurrency::MainThread);
             if (!result)
@@ -346,7 +346,7 @@
 {
     return generateConditions(
         vm, globalObject, headStructure, prototype,
-        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
+        [&](auto& conditions, JSObject* object) -> bool {
             PropertyCondition::Kind kind =
                 object == prototype ? PropertyCondition::Presence : PropertyCondition::Absence;
             ObjectPropertyCondition result =
@@ -364,7 +364,7 @@
 {
     return generateConditions(
         vm, globalObject, headStructure, prototype,
-        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
+        [&](auto& conditions, JSObject* object) -> bool {
             auto kind = PropertyCondition::Absence;
             if (object == prototype) {
                 Structure* structure = object->structure(vm);
@@ -415,7 +415,7 @@
         dataLog("Searching for prototype ", JSValue(prototype), " starting with structure ", RawPointer(headStructure), " with shouldHit = ", shouldHit, "\n");
     ObjectPropertyConditionSet result = generateConditions(
         vm, globalObject, headStructure, shouldHit ? prototype : nullptr,
-        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
+        [&](auto& conditions, JSObject* object) -> bool {
             if (ObjectPropertyConditionSetInternal::verbose)
                 dataLog("Encountered object: ", RawPointer(object), "\n");
             if (object == prototype) {
@@ -444,7 +444,7 @@
     VM& vm, JSGlobalObject* globalObject, Structure* headStructure, JSObject* prototype, UniquedStringImpl* uid)
 {
     return generateConditions(vm, globalObject, headStructure, prototype,
-        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
+        [&](auto& conditions, JSObject* object) -> bool {
             PropertyCondition::Kind kind =
                 object == prototype ? PropertyCondition::Equivalence : PropertyCondition::Absence;
             ObjectPropertyCondition result = generateCondition(vm, nullptr, object, uid, kind, Concurrency::ConcurrentThread);
@@ -460,7 +460,7 @@
 {
     return generateConditions(
         vm, globalObject, headStructure, nullptr,
-        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
+        [&](auto& conditions, JSObject* object) -> bool {
             ObjectPropertyCondition result = generateCondition(vm, nullptr, object, uid, PropertyCondition::Absence, Concurrency::ConcurrentThread);
             if (!result)
                 return false;
@@ -474,7 +474,7 @@
 {
     return generateConditions(
         vm, globalObject, headStructure, nullptr,
-        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
+        [&](auto& conditions, JSObject* object) -> bool {
             ObjectPropertyCondition result =
                 generateCondition(vm, nullptr, object, uid, PropertyCondition::AbsenceOfSetEffect, Concurrency::ConcurrentThread);
             if (!result)

Modified: trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.h (292681 => 292682)


--- trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.h	2022-04-09 20:26:16 UTC (rev 292681)
+++ trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.h	2022-04-09 22:25:24 UTC (rev 292682)
@@ -54,8 +54,9 @@
         ASSERT(!result.isValid());
         return result;
     }
-    
-    static ObjectPropertyConditionSet create(Vector<ObjectPropertyCondition>&& vector)
+
+    template<typename Vector>
+    static ObjectPropertyConditionSet create(Vector&& vector)
     {
         if (vector.isEmpty())
             return ObjectPropertyConditionSet();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to