Title: [277068] trunk/Source
Revision
277068
Author
mark....@apple.com
Date
2021-05-05 20:37:15 -0700 (Wed, 05 May 2021)

Log Message

Introduce VM::hasPendingTerminationException() to make code a little more terse.
https://bugs.webkit.org/show_bug.cgi?id=225412

Reviewed by Michael Saboff.

Source/_javascript_Core:

This is purely a refactoring patch.  There is no behavior change.

* interpreter/Interpreter.cpp:
(JSC::Interpreter::executeProgram):
* jit/JITOperations.cpp:
* runtime/ExceptionScope.h:
(JSC::ExceptionScope::assertNoExceptionExceptTermination):
(JSC::ExceptionScope::releaseAssertNoExceptionExceptTermination):
* runtime/JSObject.h:
(JSC::JSObject::get const):
* runtime/LazyPropertyInlines.h:
(JSC::ElementType>::callFunc):
* runtime/VM.cpp:
(JSC::VM::throwException):
* runtime/VM.h:
(JSC::VM::hasPendingTerminationException const):
* runtime/VMTraps.cpp:
(JSC::VMTraps::deferTerminationSlow):

Source/WebCore:

* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::handleResponseOnStreamingAction):
* bindings/js/JSDOMPromise.cpp:
(WebCore::DOMPromise::whenPromiseIsSettled):
* bindings/js/JSDOMPromiseDeferred.cpp:
(WebCore::DeferredPromise::reject):
* bindings/js/ReadableStream.cpp:
(WebCore::invokeReadableStreamFunction):
(WebCore::ReadableStream::lock):
(WebCore::checkReadableStream):
* bindings/js/ReadableStreamDefaultController.cpp:
(WebCore::invokeReadableStreamDefaultControllerFunction):
(WebCore::ReadableStreamDefaultController::error):
(WebCore::ReadableStreamDefaultController::enqueue):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (277067 => 277068)


--- trunk/Source/_javascript_Core/ChangeLog	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-05-06 03:37:15 UTC (rev 277068)
@@ -1,5 +1,31 @@
 2021-05-05  Mark Lam  <mark....@apple.com>
 
+        Introduce VM::hasPendingTerminationException() to make code a little more terse.
+        https://bugs.webkit.org/show_bug.cgi?id=225412
+
+        Reviewed by Michael Saboff.
+
+        This is purely a refactoring patch.  There is no behavior change.
+
+        * interpreter/Interpreter.cpp:
+        (JSC::Interpreter::executeProgram):
+        * jit/JITOperations.cpp:
+        * runtime/ExceptionScope.h:
+        (JSC::ExceptionScope::assertNoExceptionExceptTermination):
+        (JSC::ExceptionScope::releaseAssertNoExceptionExceptTermination):
+        * runtime/JSObject.h:
+        (JSC::JSObject::get const):
+        * runtime/LazyPropertyInlines.h:
+        (JSC::ElementType>::callFunc):
+        * runtime/VM.cpp:
+        (JSC::VM::throwException):
+        * runtime/VM.h:
+        (JSC::VM::hasPendingTerminationException const):
+        * runtime/VMTraps.cpp:
+        (JSC::VMTraps::deferTerminationSlow):
+
+2021-05-05  Mark Lam  <mark....@apple.com>
+
         Enable incremental sweeping of GCAwareJITStubRoutines.
         https://bugs.webkit.org/show_bug.cgi?id=225376
 

Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (277067 => 277068)


--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2021-05-06 03:37:15 UTC (rev 277068)
@@ -798,7 +798,7 @@
 
     // Compile source to bytecode if necessary:
     JSObject* error = program->initializeGlobalProperties(vm, globalObject, scope);
-    EXCEPTION_ASSERT(!throwScope.exception() || !error || vm.isTerminationException(throwScope.exception()));
+    EXCEPTION_ASSERT(!throwScope.exception() || !error || vm.hasPendingTerminationException());
     RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception()));
     if (UNLIKELY(error))
         return checkedReturn(throwException(globalObject, throwScope, error));

Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (277067 => 277068)


--- trunk/Source/_javascript_Core/jit/JITOperations.cpp	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp	2021-05-06 03:37:15 UTC (rev 277068)
@@ -2405,7 +2405,7 @@
 
     if (baseValue.isObject()) {
         const Identifier fieldName = fieldNameValue.toPropertyKey(globalObject);
-        EXCEPTION_ASSERT(!scope.exception() || vm.isTerminationException(scope.exception()));
+        EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
         RETURN_IF_EXCEPTION(scope, encodedJSValue());
         ASSERT(fieldName.isSymbol());
 
@@ -3534,7 +3534,7 @@
     RELEASE_ASSERT(!!scope.exception());
 
     Exception* exception = scope.exception();
-    if (vm.isTerminationException(exception)) {
+    if (UNLIKELY(vm.isTerminationException(exception))) {
         genericUnwind(vm, callFrame);
         return nullptr;
     }

Modified: trunk/Source/_javascript_Core/runtime/ExceptionScope.h (277067 => 277068)


--- trunk/Source/_javascript_Core/runtime/ExceptionScope.h	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/_javascript_Core/runtime/ExceptionScope.h	2021-05-06 03:37:15 UTC (rev 277068)
@@ -54,8 +54,8 @@
 
     ALWAYS_INLINE void assertNoException() { RELEASE_ASSERT_WITH_MESSAGE(!exception(), "%s", unexpectedExceptionMessage().data()); }
     ALWAYS_INLINE void releaseAssertNoException() { RELEASE_ASSERT_WITH_MESSAGE(!exception(), "%s", unexpectedExceptionMessage().data()); }
-    ALWAYS_INLINE void assertNoExceptionExceptTermination() { RELEASE_ASSERT_WITH_MESSAGE(!exception() || m_vm.isTerminationException(exception()), "%s", unexpectedExceptionMessage().data()); }
-    ALWAYS_INLINE void releaseAssertNoExceptionExceptTermination() { RELEASE_ASSERT_WITH_MESSAGE(!exception() || m_vm.isTerminationException(exception()), "%s", unexpectedExceptionMessage().data()); }
+    ALWAYS_INLINE void assertNoExceptionExceptTermination() { RELEASE_ASSERT_WITH_MESSAGE(!exception() || m_vm.hasPendingTerminationException(), "%s", unexpectedExceptionMessage().data()); }
+    ALWAYS_INLINE void releaseAssertNoExceptionExceptTermination() { RELEASE_ASSERT_WITH_MESSAGE(!exception() || m_vm.hasPendingTerminationException(), "%s", unexpectedExceptionMessage().data()); }
 
 #if ASAN_ENABLED || ENABLE(C_LOOP)
     const void* stackPosition() const {  return m_location.stackPosition; }
@@ -90,8 +90,8 @@
 
     ALWAYS_INLINE void assertNoException() { ASSERT(!exception()); }
     ALWAYS_INLINE void releaseAssertNoException() { RELEASE_ASSERT(!exception()); }
-    ALWAYS_INLINE void assertNoExceptionExceptTermination() { ASSERT(!exception() || m_vm.isTerminationException(exception())); }
-    ALWAYS_INLINE void releaseAssertNoExceptionExceptTermination() { RELEASE_ASSERT(!exception() || m_vm.isTerminationException(exception())); }
+    ALWAYS_INLINE void assertNoExceptionExceptTermination() { ASSERT(!exception() || m_vm.hasPendingTerminationException()); }
+    ALWAYS_INLINE void releaseAssertNoExceptionExceptTermination() { RELEASE_ASSERT(!exception() || m_vm.hasPendingTerminationException()); }
 
 protected:
     ALWAYS_INLINE ExceptionScope(VM& vm)

Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (277067 => 277068)


--- trunk/Source/_javascript_Core/runtime/JSObject.h	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h	2021-05-06 03:37:15 UTC (rev 277068)
@@ -1495,7 +1495,7 @@
     PropertySlot slot(this, PropertySlot::InternalMethodType::Get);
     bool hasProperty = const_cast<JSObject*>(this)->getPropertySlot(globalObject, propertyName, slot);
 
-    EXCEPTION_ASSERT(!scope.exception() || vm.isTerminationException(scope.exception()) || !hasProperty);
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException() || !hasProperty);
     RETURN_IF_EXCEPTION(scope, jsUndefined());
 
     if (hasProperty)
@@ -1511,7 +1511,7 @@
     PropertySlot slot(this, PropertySlot::InternalMethodType::Get);
     bool hasProperty = const_cast<JSObject*>(this)->getPropertySlot(globalObject, propertyName, slot);
 
-    EXCEPTION_ASSERT(!scope.exception() || vm.isTerminationException(scope.exception()) || !hasProperty);
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException() || !hasProperty);
     RETURN_IF_EXCEPTION(scope, jsUndefined());
 
     if (hasProperty)

Modified: trunk/Source/_javascript_Core/runtime/LazyPropertyInlines.h (277067 => 277068)


--- trunk/Source/_javascript_Core/runtime/LazyPropertyInlines.h	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/_javascript_Core/runtime/LazyPropertyInlines.h	2021-05-06 03:37:15 UTC (rev 277068)
@@ -99,8 +99,7 @@
     callStatelessLambda<void, Func>(initializer);
     if (UNLIKELY(initializer.property.m_pointer & initializingTag)) {
         VM& vm = initializer.vm;
-        Exception* exception = vm.exceptionForInspection();
-        RELEASE_ASSERT(exception && vm.isTerminationException(exception));
+        RELEASE_ASSERT(vm.hasPendingTerminationException());
         RELEASE_ASSERT(initializer.property.m_pointer & lazyTag);
         return nullptr;
     }

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (277067 => 277068)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2021-05-06 03:37:15 UTC (rev 277068)
@@ -992,7 +992,7 @@
 Exception* VM::throwException(JSGlobalObject* globalObject, Exception* exceptionToThrow)
 {
     // The TerminationException should never be overridden.
-    if (m_exception && isTerminationException(m_exception))
+    if (hasPendingTerminationException())
         return m_exception;
 
     // The TerminationException is not like ordinary exceptions that should be

Modified: trunk/Source/_javascript_Core/runtime/VM.h (277067 => 277068)


--- trunk/Source/_javascript_Core/runtime/VM.h	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2021-05-06 03:37:15 UTC (rev 277068)
@@ -352,6 +352,10 @@
         ASSERT(exception);
         return exception == m_terminationException;
     }
+    bool hasPendingTerminationException() const
+    {
+        return m_exception && isTerminationException(m_exception);
+    }
 
     void throwTerminationException();
 

Modified: trunk/Source/_javascript_Core/runtime/VMTraps.cpp (277067 => 277068)


--- trunk/Source/_javascript_Core/runtime/VMTraps.cpp	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/_javascript_Core/runtime/VMTraps.cpp	2021-05-06 03:37:15 UTC (rev 277068)
@@ -416,9 +416,7 @@
     ASSERT(m_deferTerminationCount == 1);
 
     VM& vm = this->vm();
-    Exception* pendingException = vm.exception();
-    ASSERT(pendingException);
-    if (vm.isTerminationException(pendingException)) {
+    if (vm.hasPendingTerminationException()) {
         ASSERT(vm.terminationInProgress());
         vm.clearException();
         m_suspendedTerminationException = true;

Modified: trunk/Source/WebCore/ChangeLog (277067 => 277068)


--- trunk/Source/WebCore/ChangeLog	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/WebCore/ChangeLog	2021-05-06 03:37:15 UTC (rev 277068)
@@ -1,3 +1,25 @@
+2021-05-05  Mark Lam  <mark....@apple.com>
+
+        Introduce VM::hasPendingTerminationException() to make code a little more terse.
+        https://bugs.webkit.org/show_bug.cgi?id=225412
+
+        Reviewed by Michael Saboff.
+
+        * bindings/js/JSDOMGlobalObject.cpp:
+        (WebCore::handleResponseOnStreamingAction):
+        * bindings/js/JSDOMPromise.cpp:
+        (WebCore::DOMPromise::whenPromiseIsSettled):
+        * bindings/js/JSDOMPromiseDeferred.cpp:
+        (WebCore::DeferredPromise::reject):
+        * bindings/js/ReadableStream.cpp:
+        (WebCore::invokeReadableStreamFunction):
+        (WebCore::ReadableStream::lock):
+        (WebCore::checkReadableStream):
+        * bindings/js/ReadableStreamDefaultController.cpp:
+        (WebCore::invokeReadableStreamDefaultControllerFunction):
+        (WebCore::ReadableStreamDefaultController::error):
+        (WebCore::ReadableStreamDefaultController::enqueue):
+
 2021-05-05  Aditya Keerthi  <akeer...@apple.com>
 
         [macOS] Use system colors for ActiveButtonText

Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (277067 => 277068)


--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2021-05-06 03:37:15 UTC (rev 277068)
@@ -145,7 +145,7 @@
         code = AbortError;
     auto value = createDOMException(globalObject, code, message);
 
-    EXCEPTION_ASSERT(!scope.exception() || vm.isTerminationException(scope.exception()));
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
 
     return JSValue::encode(value);
 }
@@ -414,7 +414,7 @@
                 auto scope = DECLARE_THROW_SCOPE(vm);
                 auto error = createDOMException(*globalObject, WTFMove(exception));
                 if (UNLIKELY(scope.exception())) {
-                    ASSERT(vm.isTerminationException(scope.exception()));
+                    ASSERT(vm.hasPendingTerminationException());
                     compiler->cancel();
                     return;
                 }

Modified: trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp (277067 => 277068)


--- trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp	2021-05-06 03:37:15 UTC (rev 277068)
@@ -57,7 +57,7 @@
     const JSC::Identifier& privateName = vm.propertyNames->builtinNames().thenPrivateName();
     auto thenFunction = promise->get(&lexicalGlobalObject, privateName);
 
-    EXCEPTION_ASSERT(!scope.exception() || vm.isTerminationException(scope.exception()));
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
     if (scope.exception())
         return IsCallbackRegistered::No;
 
@@ -71,7 +71,7 @@
     ASSERT(callData.type != JSC::CallData::Type::None);
     call(&lexicalGlobalObject, thenFunction, callData, promise, arguments);
 
-    EXCEPTION_ASSERT(!scope.exception() || vm.isTerminationException(scope.exception()));
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
     return scope.exception() ? IsCallbackRegistered::No : IsCallbackRegistered::Yes;
 }
 

Modified: trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp (277067 => 277068)


--- trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp	2021-05-06 03:37:15 UTC (rev 277068)
@@ -147,7 +147,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     auto error = createDOMException(lexicalGlobalObject, WTFMove(exception));
     if (UNLIKELY(scope.exception())) {
-        ASSERT(vm.isTerminationException(scope.exception()));
+        ASSERT(vm.hasPendingTerminationException());
         return;
     }
 
@@ -181,7 +181,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     auto error = createDOMException(&lexicalGlobalObject, ec, message);
     if (UNLIKELY(scope.exception())) {
-        ASSERT(vm.isTerminationException(scope.exception()));
+        ASSERT(vm.hasPendingTerminationException());
         return;
     }
 

Modified: trunk/Source/WebCore/bindings/js/ReadableStream.cpp (277067 => 277068)


--- trunk/Source/WebCore/bindings/js/ReadableStream.cpp	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/WebCore/bindings/js/ReadableStream.cpp	2021-05-06 03:37:15 UTC (rev 277068)
@@ -72,7 +72,7 @@
     auto scope = DECLARE_CATCH_SCOPE(vm);
     auto callData = JSC::getCallData(vm, function);
     auto result = call(&lexicalGlobalObject, function, callData, thisValue, arguments);
-    EXCEPTION_ASSERT(!scope.exception() || vm.isTerminationException(scope.exception()));
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
     if (scope.exception())
         return { };
     return result;
@@ -131,7 +131,7 @@
     ASSERT(!args.hasOverflowed());
 
     JSC::construct(&lexicalGlobalObject, constructor, constructData, args);
-    EXCEPTION_ASSERT(!scope.exception() || vm.isTerminationException(scope.exception()));
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
 }
 
 static inline bool checkReadableStream(JSDOMGlobalObject& globalObject, JSReadableStream* readableStream, JSC::JSValue function)
@@ -149,7 +149,7 @@
     ASSERT(callData.type != JSC::CallData::Type::None);
 
     auto result = call(&lexicalGlobalObject, function, callData, JSC::jsUndefined(), arguments);
-    EXCEPTION_ASSERT(!scope.exception() || vm.isTerminationException(scope.exception()));
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
 
     return result.isTrue() || scope.exception();
 }

Modified: trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.cpp (277067 => 277068)


--- trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.cpp	2021-05-06 02:34:28 UTC (rev 277067)
+++ trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.cpp	2021-05-06 03:37:15 UTC (rev 277068)
@@ -50,7 +50,7 @@
     auto scope = DECLARE_CATCH_SCOPE(vm);
     auto callData = JSC::getCallData(vm, function);
     call(&lexicalGlobalObject, function, callData, JSC::jsUndefined(), arguments);
-    EXCEPTION_ASSERT(!scope.exception() || vm.isTerminationException(scope.exception()));
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
     return !scope.exception();
 }
 
@@ -75,7 +75,7 @@
     auto value = createDOMException(&lexicalGlobalObject, exception.code(), exception.message());
 
     if (UNLIKELY(scope.exception())) {
-        ASSERT(vm.isTerminationException(scope.exception()));
+        ASSERT(vm.hasPendingTerminationException());
         return;
     }
 
@@ -121,7 +121,7 @@
     auto value = toJS(&lexicalGlobalObject, &lexicalGlobalObject, chunk.get());
 
     if (UNLIKELY(scope.exception())) {
-        ASSERT(vm.isTerminationException(scope.exception()));
+        ASSERT(vm.hasPendingTerminationException());
         return false;
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to