Title: [273256] branches/safari-611-branch
Revision
273256
Author
[email protected]
Date
2021-02-22 09:55:08 -0800 (Mon, 22 Feb 2021)

Log Message

Cherry-pick r270665. rdar://problem/74409412

    Removing unnecessary locking from JSValue API functions
    https://bugs.webkit.org/show_bug.cgi?id=219723

    Reviewed by Filip Pizlo.

    PerformanceTests:

    Print an error message when benchmarks fail to run and add option to change
    the configuration used to build the benchmarks.

    * APIBench/api-bench:

    Source/_javascript_Core:

    Remove the unnecessary locking from the JSValueIs* and JSValueMake* API functions
    that only work on primitives. Also remove the unnecessary method dispatching and
    call from the -[JSValue is*] methods.

    This improves the APIBench score by another ~8% since these are such common operations.
    Here are the results: (Baseline includes https://bugs.webkit.org/show_bug.cgi?id=219663)

    CURRENT_API:        Baseline   Change
    ----------------------------------------
    RichardsMostlyC:      74ms      60ms
    RichardsMostlyObjC:  304ms     300ms
    RichardsMostlySwift: 305ms     293ms
    RichardsSomeC:        97ms      77ms
    RichardsSomeObjC:    158ms     159ms
    RichardsSomeSwift:   202ms     198ms

    UPCOMING_API:       Baseline   Change
    ----------------------------------------
    RichardsMostlyC:      23ms      19ms
    RichardsMostlyObjC:  282ms     282ms
    RichardsMostlySwift: 280ms     282ms
    RichardsSomeC:        95ms      76ms
    RichardsSomeObjC:    157ms     156ms
    RichardsSomeSwift:   202ms     197ms
    ----------------------------------------
    Score:             33.6404   36.4006

    * API/APICast.h:
    (toRef):
    * API/JSValue.mm:
    (-[JSValue isUndefined]):
    (-[JSValue isNull]):
    (-[JSValue isBoolean]):
    (-[JSValue isNumber]):
    (-[JSValue isString]):
    (-[JSValue isObject]):
    (-[JSValue isSymbol]):
    * API/JSValueRef.cpp:
    (JSValueGetType):
    (JSValueIsUndefined):
    (JSValueIsNull):
    (JSValueIsBoolean):
    (JSValueIsNumber):
    (JSValueIsString):
    (JSValueIsObject):
    (JSValueIsSymbol):
    (JSValueMakeUndefined):
    (JSValueMakeNull):
    (JSValueMakeBoolean):
    (JSValueMakeNumber):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270665 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-611-branch/PerformanceTests/APIBench/api-bench (273255 => 273256)


--- branches/safari-611-branch/PerformanceTests/APIBench/api-bench	2021-02-22 17:55:04 UTC (rev 273255)
+++ branches/safari-611-branch/PerformanceTests/APIBench/api-bench	2021-02-22 17:55:08 UTC (rev 273256)
@@ -37,6 +37,7 @@
 CURRENT_API=()
 UPCOMING_API=()
 ARCHS=${ARCHS:-$(uname -m)}
+CONFIGURATION=${CONFIGURATION:-Release}
 
 shouldBuild=true
 runReferences=true
@@ -148,7 +149,7 @@
     fi
 
     log "Building $BENCHMARK_NAME... (FRAMEWORK_SEARCH_PATHS='$BUILD_DIRECTORY')"
-    xcodebuild -project "$project" -target "$BENCHMARK_NAME" -configuration Release build "FRAMEWORK_SEARCH_PATHS='$BUILD_DIRECTORY'" "ARCHS='$ARCHS'"
+    xcodebuild -project "$project" -target "$BENCHMARK_NAME" -configuration "$CONFIGURATION" build "FRAMEWORK_SEARCH_PATHS='$BUILD_DIRECTORY'" "ARCHS='$ARCHS'"
 }
 
 build() {
@@ -161,9 +162,14 @@
 }
 
 runNativeBenchmark() {
-    pushd "build/Release" &> /dev/null
+    pushd "build/$CONFIGURATION" &> /dev/null
     "./$BENCHMARK_NAME"
+    local exitCode=$?
+    if [ $exitCode -ne 0 ]; then
+        echo "Benchmark exited with an error: $PWD/$BENCHMARK_NAME exited with $exitCode" 1>&2
+    fi
     popd &> /dev/null
+    return $exitCode
 }
 
 runBenchmarkIteration() {
@@ -179,6 +185,9 @@
 
     local result
     result=$(runBenchmarkIteration)
+    if [ $? -ne 0 ]; then
+        exit 1
+    fi
     RESULTS[$((BENCHMARK_ID * iterations + ITERATION))]=$result
     log "Finished in ${result}ms"
 }

Modified: branches/safari-611-branch/PerformanceTests/ChangeLog (273255 => 273256)


--- branches/safari-611-branch/PerformanceTests/ChangeLog	2021-02-22 17:55:04 UTC (rev 273255)
+++ branches/safari-611-branch/PerformanceTests/ChangeLog	2021-02-22 17:55:08 UTC (rev 273256)
@@ -1,3 +1,87 @@
+2021-02-17  Ruben Turcios  <[email protected]>
+
+        Cherry-pick r270665. rdar://problem/74409412
+
+    Removing unnecessary locking from JSValue API functions
+    https://bugs.webkit.org/show_bug.cgi?id=219723
+    
+    Reviewed by Filip Pizlo.
+    
+    PerformanceTests:
+    
+    Print an error message when benchmarks fail to run and add option to change
+    the configuration used to build the benchmarks.
+    
+    * APIBench/api-bench:
+    
+    Source/_javascript_Core:
+    
+    Remove the unnecessary locking from the JSValueIs* and JSValueMake* API functions
+    that only work on primitives. Also remove the unnecessary method dispatching and
+    call from the -[JSValue is*] methods.
+    
+    This improves the APIBench score by another ~8% since these are such common operations.
+    Here are the results: (Baseline includes https://bugs.webkit.org/show_bug.cgi?id=219663)
+    
+    CURRENT_API:        Baseline   Change
+    ----------------------------------------
+    RichardsMostlyC:      74ms      60ms
+    RichardsMostlyObjC:  304ms     300ms
+    RichardsMostlySwift: 305ms     293ms
+    RichardsSomeC:        97ms      77ms
+    RichardsSomeObjC:    158ms     159ms
+    RichardsSomeSwift:   202ms     198ms
+    
+    UPCOMING_API:       Baseline   Change
+    ----------------------------------------
+    RichardsMostlyC:      23ms      19ms
+    RichardsMostlyObjC:  282ms     282ms
+    RichardsMostlySwift: 280ms     282ms
+    RichardsSomeC:        95ms      76ms
+    RichardsSomeObjC:    157ms     156ms
+    RichardsSomeSwift:   202ms     197ms
+    ----------------------------------------
+    Score:             33.6404   36.4006
+    
+    * API/APICast.h:
+    (toRef):
+    * API/JSValue.mm:
+    (-[JSValue isUndefined]):
+    (-[JSValue isNull]):
+    (-[JSValue isBoolean]):
+    (-[JSValue isNumber]):
+    (-[JSValue isString]):
+    (-[JSValue isObject]):
+    (-[JSValue isSymbol]):
+    * API/JSValueRef.cpp:
+    (JSValueGetType):
+    (JSValueIsUndefined):
+    (JSValueIsNull):
+    (JSValueIsBoolean):
+    (JSValueIsNumber):
+    (JSValueIsString):
+    (JSValueIsObject):
+    (JSValueIsSymbol):
+    (JSValueMakeUndefined):
+    (JSValueMakeNull):
+    (JSValueMakeBoolean):
+    (JSValueMakeNumber):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270665 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-12-10  Tadeu Zagallo  <[email protected]>
+
+            Removing unnecessary locking from JSValue API functions
+            https://bugs.webkit.org/show_bug.cgi?id=219723
+
+            Reviewed by Filip Pizlo.
+
+            Print an error message when benchmarks fail to run and add option to change
+            the configuration used to build the benchmarks.
+
+            * APIBench/api-bench:
+
 2021-02-10  Alan Coon  <[email protected]>
 
         Revert r272538. rdar://problem/74183111

Modified: branches/safari-611-branch/Source/_javascript_Core/API/APICast.h (273255 => 273256)


--- branches/safari-611-branch/Source/_javascript_Core/API/APICast.h	2021-02-22 17:55:04 UTC (rev 273255)
+++ branches/safari-611-branch/Source/_javascript_Core/API/APICast.h	2021-02-22 17:55:08 UTC (rev 273256)
@@ -88,6 +88,13 @@
     return result;
 }
 
+#if CPU(ADDRESS64)
+inline JSC::JSValue toJS(JSValueRef value)
+{
+    return bitwise_cast<JSC::JSValue>(value);
+}
+#endif
+
 inline JSC::JSValue toJSForGC(JSC::JSGlobalObject* globalObject, JSValueRef v)
 {
     ASSERT_UNUSED(globalObject, globalObject);
@@ -148,6 +155,13 @@
     return toRef(getVM(globalObject), v);
 }
 
+#if CPU(ADDRESS64)
+inline JSValueRef toRef(JSC::JSValue v)
+{
+    return bitwise_cast<JSValueRef>(v);
+}
+#endif
+
 inline JSObjectRef toRef(JSC::JSObject* o)
 {
     return reinterpret_cast<JSObjectRef>(o);

Modified: branches/safari-611-branch/Source/_javascript_Core/API/JSValue.mm (273255 => 273256)


--- branches/safari-611-branch/Source/_javascript_Core/API/JSValue.mm	2021-02-22 17:55:04 UTC (rev 273255)
+++ branches/safari-611-branch/Source/_javascript_Core/API/JSValue.mm	2021-02-22 17:55:08 UTC (rev 273256)
@@ -398,37 +398,65 @@
 
 - (BOOL)isUndefined
 {
+#if !CPU(ADDRESS64)
     return JSValueIsUndefined([_context JSGlobalContextRef], m_value);
+#else
+    return toJS(m_value).isUndefined();
+#endif
 }
 
 - (BOOL)isNull
 {
-    return JSValueIsNull([_context JSGlobalContextRef], m_value);
+#if !CPU(ADDRESS64)
+    return JSValueIsUndefined([_context JSGlobalContextRef], m_value);
+#else
+    return toJS(m_value).isNull();
+#endif
 }
 
 - (BOOL)isBoolean
 {
-    return JSValueIsBoolean([_context JSGlobalContextRef], m_value);
+#if !CPU(ADDRESS64)
+    return JSValueIsUndefined([_context JSGlobalContextRef], m_value);
+#else
+    return toJS(m_value).isBoolean();
+#endif
 }
 
 - (BOOL)isNumber
 {
-    return JSValueIsNumber([_context JSGlobalContextRef], m_value);
+#if !CPU(ADDRESS64)
+    return JSValueIsUndefined([_context JSGlobalContextRef], m_value);
+#else
+    return toJS(m_value).isNumber();
+#endif
 }
 
 - (BOOL)isString
 {
-    return JSValueIsString([_context JSGlobalContextRef], m_value);
+#if !CPU(ADDRESS64)
+    return JSValueIsUndefined([_context JSGlobalContextRef], m_value);
+#else
+    return toJS(m_value).isString();
+#endif
 }
 
 - (BOOL)isObject
 {
+#if !CPU(ADDRESS64)
     return JSValueIsObject([_context JSGlobalContextRef], m_value);
+#else
+    return toJS(m_value).isObject();
+#endif
 }
 
 - (BOOL)isSymbol
 {
+#if !CPU(ADDRESS64)
     return JSValueIsSymbol([_context JSGlobalContextRef], m_value);
+#else
+    return toJS(m_value).isSymbol();
+#endif
 }
 
 - (BOOL)isArray

Modified: branches/safari-611-branch/Source/_javascript_Core/API/JSValueRef.cpp (273255 => 273256)


--- branches/safari-611-branch/Source/_javascript_Core/API/JSValueRef.cpp	2021-02-22 17:55:04 UTC (rev 273255)
+++ branches/safari-611-branch/Source/_javascript_Core/API/JSValueRef.cpp	2021-02-22 17:55:08 UTC (rev 273256)
@@ -54,10 +54,13 @@
         ASSERT_NOT_REACHED();
         return kJSTypeUndefined;
     }
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     JSValue jsValue = toJS(globalObject, value);
+#else
+    JSValue jsValue = toJS(value);
+#endif
 
     if (jsValue.isUndefined())
         return kJSTypeUndefined;
@@ -81,10 +84,13 @@
         ASSERT_NOT_REACHED();
         return false;
     }
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     return toJS(globalObject, value).isUndefined();
+#else
+    return toJS(value).isUndefined();
+#endif
 }
 
 bool JSValueIsNull(JSContextRef ctx, JSValueRef value)
@@ -93,10 +99,14 @@
         ASSERT_NOT_REACHED();
         return false;
     }
+
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     return toJS(globalObject, value).isNull();
+#else
+    return toJS(value).isNull();
+#endif
 }
 
 bool JSValueIsBoolean(JSContextRef ctx, JSValueRef value)
@@ -105,10 +115,13 @@
         ASSERT_NOT_REACHED();
         return false;
     }
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     return toJS(globalObject, value).isBoolean();
+#else
+    return toJS(value).isBoolean();
+#endif
 }
 
 bool JSValueIsNumber(JSContextRef ctx, JSValueRef value)
@@ -117,10 +130,13 @@
         ASSERT_NOT_REACHED();
         return false;
     }
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     return toJS(globalObject, value).isNumber();
+#else
+    return toJS(value).isNumber();
+#endif
 }
 
 bool JSValueIsString(JSContextRef ctx, JSValueRef value)
@@ -129,10 +145,13 @@
         ASSERT_NOT_REACHED();
         return false;
     }
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     return toJS(globalObject, value).isString();
+#else
+    return toJS(value).isString();
+#endif
 }
 
 bool JSValueIsObject(JSContextRef ctx, JSValueRef value)
@@ -141,10 +160,13 @@
         ASSERT_NOT_REACHED();
         return false;
     }
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     return toJS(globalObject, value).isObject();
+#else
+    return toJS(value).isObject();
+#endif
 }
 
 bool JSValueIsSymbol(JSContextRef ctx, JSValueRef value)
@@ -153,10 +175,13 @@
         ASSERT_NOT_REACHED();
         return false;
     }
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     return toJS(globalObject, value).isSymbol();
+#else
+    return toJS(value).isSymbol();
+#endif
 }
 
 bool JSValueIsArray(JSContextRef ctx, JSValueRef value)
@@ -277,10 +302,13 @@
         ASSERT_NOT_REACHED();
         return nullptr;
     }
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     return toRef(globalObject, jsUndefined());
+#else
+    return toRef(jsUndefined());
+#endif
 }
 
 JSValueRef JSValueMakeNull(JSContextRef ctx)
@@ -289,10 +317,13 @@
         ASSERT_NOT_REACHED();
         return nullptr;
     }
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     return toRef(globalObject, jsNull());
+#else
+    return toRef(jsNull());
+#endif
 }
 
 JSValueRef JSValueMakeBoolean(JSContextRef ctx, bool value)
@@ -301,10 +332,13 @@
         ASSERT_NOT_REACHED();
         return nullptr;
     }
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     return toRef(globalObject, jsBoolean(value));
+#else
+    return toRef(jsBoolean(value));
+#endif
 }
 
 JSValueRef JSValueMakeNumber(JSContextRef ctx, double value)
@@ -313,10 +347,13 @@
         ASSERT_NOT_REACHED();
         return nullptr;
     }
+#if !CPU(ADDRESS64)
     JSGlobalObject* globalObject = toJS(ctx);
     JSLockHolder locker(globalObject);
-
     return toRef(globalObject, jsNumber(purifyNaN(value)));
+#else
+    return toRef(jsNumber(purifyNaN(value)));
+#endif
 }
 
 JSValueRef JSValueMakeSymbol(JSContextRef ctx, JSStringRef description)

Modified: branches/safari-611-branch/Source/_javascript_Core/ChangeLog (273255 => 273256)


--- branches/safari-611-branch/Source/_javascript_Core/ChangeLog	2021-02-22 17:55:04 UTC (rev 273255)
+++ branches/safari-611-branch/Source/_javascript_Core/ChangeLog	2021-02-22 17:55:08 UTC (rev 273256)
@@ -1,3 +1,133 @@
+2021-02-17  Ruben Turcios  <[email protected]>
+
+        Cherry-pick r270665. rdar://problem/74409412
+
+    Removing unnecessary locking from JSValue API functions
+    https://bugs.webkit.org/show_bug.cgi?id=219723
+    
+    Reviewed by Filip Pizlo.
+    
+    PerformanceTests:
+    
+    Print an error message when benchmarks fail to run and add option to change
+    the configuration used to build the benchmarks.
+    
+    * APIBench/api-bench:
+    
+    Source/_javascript_Core:
+    
+    Remove the unnecessary locking from the JSValueIs* and JSValueMake* API functions
+    that only work on primitives. Also remove the unnecessary method dispatching and
+    call from the -[JSValue is*] methods.
+    
+    This improves the APIBench score by another ~8% since these are such common operations.
+    Here are the results: (Baseline includes https://bugs.webkit.org/show_bug.cgi?id=219663)
+    
+    CURRENT_API:        Baseline   Change
+    ----------------------------------------
+    RichardsMostlyC:      74ms      60ms
+    RichardsMostlyObjC:  304ms     300ms
+    RichardsMostlySwift: 305ms     293ms
+    RichardsSomeC:        97ms      77ms
+    RichardsSomeObjC:    158ms     159ms
+    RichardsSomeSwift:   202ms     198ms
+    
+    UPCOMING_API:       Baseline   Change
+    ----------------------------------------
+    RichardsMostlyC:      23ms      19ms
+    RichardsMostlyObjC:  282ms     282ms
+    RichardsMostlySwift: 280ms     282ms
+    RichardsSomeC:        95ms      76ms
+    RichardsSomeObjC:    157ms     156ms
+    RichardsSomeSwift:   202ms     197ms
+    ----------------------------------------
+    Score:             33.6404   36.4006
+    
+    * API/APICast.h:
+    (toRef):
+    * API/JSValue.mm:
+    (-[JSValue isUndefined]):
+    (-[JSValue isNull]):
+    (-[JSValue isBoolean]):
+    (-[JSValue isNumber]):
+    (-[JSValue isString]):
+    (-[JSValue isObject]):
+    (-[JSValue isSymbol]):
+    * API/JSValueRef.cpp:
+    (JSValueGetType):
+    (JSValueIsUndefined):
+    (JSValueIsNull):
+    (JSValueIsBoolean):
+    (JSValueIsNumber):
+    (JSValueIsString):
+    (JSValueIsObject):
+    (JSValueIsSymbol):
+    (JSValueMakeUndefined):
+    (JSValueMakeNull):
+    (JSValueMakeBoolean):
+    (JSValueMakeNumber):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270665 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-12-10  Tadeu Zagallo  <[email protected]>
+
+            Removing unnecessary locking from JSValue API functions
+            https://bugs.webkit.org/show_bug.cgi?id=219723
+
+            Reviewed by Filip Pizlo.
+
+            Remove the unnecessary locking from the JSValueIs* and JSValueMake* API functions
+            that only work on primitives. Also remove the unnecessary method dispatching and
+            call from the -[JSValue is*] methods.
+
+            This improves the APIBench score by another ~8% since these are such common operations.
+            Here are the results: (Baseline includes https://bugs.webkit.org/show_bug.cgi?id=219663)
+
+            CURRENT_API:        Baseline   Change
+            ----------------------------------------
+            RichardsMostlyC:      74ms      60ms
+            RichardsMostlyObjC:  304ms     300ms
+            RichardsMostlySwift: 305ms     293ms
+            RichardsSomeC:        97ms      77ms
+            RichardsSomeObjC:    158ms     159ms
+            RichardsSomeSwift:   202ms     198ms
+
+            UPCOMING_API:       Baseline   Change
+            ----------------------------------------
+            RichardsMostlyC:      23ms      19ms
+            RichardsMostlyObjC:  282ms     282ms
+            RichardsMostlySwift: 280ms     282ms
+            RichardsSomeC:        95ms      76ms
+            RichardsSomeObjC:    157ms     156ms
+            RichardsSomeSwift:   202ms     197ms
+            ----------------------------------------
+            Score:             33.6404   36.4006
+
+            * API/APICast.h:
+            (toRef):
+            * API/JSValue.mm:
+            (-[JSValue isUndefined]):
+            (-[JSValue isNull]):
+            (-[JSValue isBoolean]):
+            (-[JSValue isNumber]):
+            (-[JSValue isString]):
+            (-[JSValue isObject]):
+            (-[JSValue isSymbol]):
+            * API/JSValueRef.cpp:
+            (JSValueGetType):
+            (JSValueIsUndefined):
+            (JSValueIsNull):
+            (JSValueIsBoolean):
+            (JSValueIsNumber):
+            (JSValueIsString):
+            (JSValueIsObject):
+            (JSValueIsSymbol):
+            (JSValueMakeUndefined):
+            (JSValueMakeNull):
+            (JSValueMakeBoolean):
+            (JSValueMakeNumber):
+
 2021-02-19  Alan Coon  <[email protected]>
 
         Cherry-pick r272938. rdar://problem/74500752
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to