Title: [206476] trunk/Source/_javascript_Core
Revision
206476
Author
mark....@apple.com
Date
2016-09-27 17:26:15 -0700 (Tue, 27 Sep 2016)

Log Message

createError() and JSObject::calculatedClassName() should not throw any exceptions.
https://bugs.webkit.org/show_bug.cgi?id=162637

Reviewed by Geoffrey Garen.

* runtime/ExceptionHelpers.cpp:
(JSC::createError):
- assert that errorDescriptionForValue() did not throw an exception.

* runtime/JSObject.cpp:
(JSC::JSObject::calculatedClassName):
- the code already ensures that we always return a non-null String.  Just need to
  make sure that it catches its own exceptions.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (206475 => 206476)


--- trunk/Source/_javascript_Core/ChangeLog	2016-09-28 00:25:51 UTC (rev 206475)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-09-28 00:26:15 UTC (rev 206476)
@@ -1,3 +1,19 @@
+2016-09-27  Mark Lam  <mark....@apple.com>
+
+        createError() and JSObject::calculatedClassName() should not throw any exceptions.
+        https://bugs.webkit.org/show_bug.cgi?id=162637
+
+        Reviewed by Geoffrey Garen.
+
+        * runtime/ExceptionHelpers.cpp:
+        (JSC::createError):
+        - assert that errorDescriptionForValue() did not throw an exception.
+
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::calculatedClassName):
+        - the code already ensures that we always return a non-null String.  Just need to
+          make sure that it catches its own exceptions.
+
 2016-09-27  Filip Pizlo  <fpi...@apple.com>
 
         B3::lowerMacros forgets to before->updatePredecessorsAfter() when lowering ChillMod on ARM64

Modified: trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp (206475 => 206476)


--- trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp	2016-09-28 00:25:51 UTC (rev 206475)
+++ trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp	2016-09-28 00:26:15 UTC (rev 206476)
@@ -236,7 +236,11 @@
 
 JSObject* createError(ExecState* exec, JSValue value, const String& message, ErrorInstance::SourceAppender appender)
 {
+    VM& vm = exec->vm();
+    auto scope = DECLARE_CATCH_SCOPE(vm);
+
     String errorMessage = makeString(errorDescriptionForValue(exec, value)->value(exec), ' ', message);
+    ASSERT_UNUSED(scope, !scope.exception());
     JSObject* exception = createTypeError(exec, errorMessage, appender, runtimeTypeForValue(value));
     ASSERT(exception->isErrorInstance());
     return exception;

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (206475 => 206476)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2016-09-28 00:25:51 UTC (rev 206475)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2016-09-28 00:26:15 UTC (rev 206476)
@@ -230,7 +230,11 @@
 String JSObject::calculatedClassName(JSObject* object)
 {
     String prototypeFunctionName;
-    ExecState* exec = object->globalObject()->globalExec();
+    auto globalObject = object->globalObject();
+    VM& vm = globalObject->vm();
+    auto scope = DECLARE_CATCH_SCOPE(vm);
+
+    ExecState* exec = globalObject->globalExec();
     PropertySlot slot(object->getPrototypeDirect(), PropertySlot::InternalMethodType::VMInquiry);
     PropertyName constructor(exec->propertyNames().constructor);
     if (object->getPropertySlot(exec, constructor, slot)) {
@@ -239,7 +243,6 @@
             if (constructorValue.isCell()) {
                 if (JSCell* constructorCell = constructorValue.asCell()) {
                     if (JSObject* ctorObject = constructorCell->getObject()) {
-                        VM& vm = exec->vm();
                         if (JSFunction* constructorFunction = jsDynamicCast<JSFunction*>(ctorObject))
                             prototypeFunctionName = constructorFunction->calculatedDisplayName(vm);
                         else if (InternalFunction* constructorFunction = jsDynamicCast<InternalFunction*>(ctorObject))
@@ -249,6 +252,9 @@
             }
         }
     }
+    ASSERT(!scope.exception() || prototypeFunctionName.isNull());
+    if (UNLIKELY(scope.exception()))
+        scope.clearException();
 
     if (prototypeFunctionName.isNull() || prototypeFunctionName == "Object") {
         String tableClassName = object->methodTable()->className(object);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to