Title: [290871] trunk/Source/_javascript_Core
Revision
290871
Author
[email protected]
Date
2022-03-05 13:55:27 -0800 (Sat, 05 Mar 2022)

Log Message

Optimize VMTraps::maybeNeedHandling().
https://bugs.webkit.org/show_bug.cgi?id=237503

Reviewed by Saam Barati.

There's no need for VMTraps::maybeNeedHandling() to mask the VMTraps bits for
events.  Under normal circumstances, there are no traps firing and the traps bits
are 0 anyway.  We should optimize for this and do away with the masking.  Clients
who use VMTraps::maybeNeedHandling() should and current do call VMTraps::needHandling()
to get the real story on whether there are actually traps to handle or not.  Hence,
the masking in VMTraps::maybeNeedHandling() is also not needed for correctness.

We know from experience that changes in RETURN_IN_EXCEPTION can have an impact on
performance.  Perhaps this change can also help performance.

* runtime/ExceptionScope.h:
* runtime/VMTraps.h:
(JSC::VMTraps::maybeNeedHandling const):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (290870 => 290871)


--- trunk/Source/_javascript_Core/ChangeLog	2022-03-05 21:24:10 UTC (rev 290870)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-03-05 21:55:27 UTC (rev 290871)
@@ -1,5 +1,26 @@
 2022-03-05  Mark Lam  <[email protected]>
 
+        Optimize VMTraps::maybeNeedHandling().
+        https://bugs.webkit.org/show_bug.cgi?id=237503
+
+        Reviewed by Saam Barati.
+
+        There's no need for VMTraps::maybeNeedHandling() to mask the VMTraps bits for
+        events.  Under normal circumstances, there are no traps firing and the traps bits
+        are 0 anyway.  We should optimize for this and do away with the masking.  Clients
+        who use VMTraps::maybeNeedHandling() should and current do call VMTraps::needHandling()
+        to get the real story on whether there are actually traps to handle or not.  Hence,
+        the masking in VMTraps::maybeNeedHandling() is also not needed for correctness.
+
+        We know from experience that changes in RETURN_IN_EXCEPTION can have an impact on
+        performance.  Perhaps this change can also help performance.
+
+        * runtime/ExceptionScope.h:
+        * runtime/VMTraps.h:
+        (JSC::VMTraps::maybeNeedHandling const):
+
+2022-03-05  Mark Lam  <[email protected]>
+
         Fix broken SuspendExceptionScope and remove redundant VM::DeferExceptionScope.
         https://bugs.webkit.org/show_bug.cgi?id=237441
         <rdar://problem/89769627>

Modified: trunk/Source/_javascript_Core/runtime/ExceptionScope.h (290870 => 290871)


--- trunk/Source/_javascript_Core/runtime/ExceptionScope.h	2022-03-05 21:24:10 UTC (rev 290870)
+++ trunk/Source/_javascript_Core/runtime/ExceptionScope.h	2022-03-05 21:55:27 UTC (rev 290871)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -110,7 +110,7 @@
 #define RETURN_IF_EXCEPTION(scope__, value__) do { \
         JSC::VM& vm = (scope__).vm(); \
         ASSERT(!!(scope__).exception() == vm.traps().needHandling(JSC::VMTraps::NeedExceptionHandling)); \
-        if (UNLIKELY(vm.traps().maybeNeedHandling(JSC::VMTraps::NonDebuggerEvents))) { \
+        if (UNLIKELY(vm.traps().maybeNeedHandling())) { \
             if (vm.hasExceptionsAfterHandlingTraps()) \
                 return value__; \
         } \

Modified: trunk/Source/_javascript_Core/runtime/VMTraps.h (290870 => 290871)


--- trunk/Source/_javascript_Core/runtime/VMTraps.h	2022-03-05 21:24:10 UTC (rev 290870)
+++ trunk/Source/_javascript_Core/runtime/VMTraps.h	2022-03-05 21:55:27 UTC (rev 290871)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -203,7 +203,7 @@
         return false;
     }
     // Designed to be a fast check to rule out if we might need handling, and we need to ensure needHandling on the slow path.
-    ALWAYS_INLINE bool maybeNeedHandling(BitField mask) const { return m_trapBits.loadRelaxed() & mask; }
+    ALWAYS_INLINE bool maybeNeedHandling() const { return m_trapBits.loadRelaxed(); }
     void* trapBitsAddress() { return &m_trapBits; }
 
     enum class DeferAction {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to