Title: [208808] trunk/Source/_javascript_Core
Revision
208808
Author
[email protected]
Date
2016-11-16 13:05:43 -0800 (Wed, 16 Nov 2016)

Log Message

Fix exception scope checking in JSGlobalObject.cpp.
https://bugs.webkit.org/show_bug.cgi?id=164831

Reviewed by Saam Barati.

* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
- Use a CatchScope here because we don't ever expect JSGlobalObject initialization
  to fail with errors.
(JSC::JSGlobalObject::put):
- Fix exception check requirements.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (208807 => 208808)


--- trunk/Source/_javascript_Core/ChangeLog	2016-11-16 21:02:10 UTC (rev 208807)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-11-16 21:05:43 UTC (rev 208808)
@@ -1,3 +1,17 @@
+2016-11-16  Mark Lam  <[email protected]>
+
+        Fix exception scope checking in JSGlobalObject.cpp.
+        https://bugs.webkit.org/show_bug.cgi?id=164831
+
+        Reviewed by Saam Barati.
+
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init):
+        - Use a CatchScope here because we don't ever expect JSGlobalObject initialization
+          to fail with errors.
+        (JSC::JSGlobalObject::put):
+        - Fix exception check requirements.
+
 2016-11-16  Keith Miller  <[email protected]>
 
         Unreviewed, ARM build fix.

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (208807 => 208808)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2016-11-16 21:02:10 UTC (rev 208807)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2016-11-16 21:05:43 UTC (rev 208808)
@@ -358,6 +358,7 @@
 void JSGlobalObject::init(VM& vm)
 {
     ASSERT(vm.currentThreadIsHoldingAPILock());
+    auto catchScope = DECLARE_CATCH_SCOPE(vm);
 
     Base::setStructure(vm, Structure::toCacheableDictionaryTransition(vm, structure()));
 
@@ -740,13 +741,20 @@
     JSFunction* privateFuncConcatSlowPath = JSFunction::createBuiltinFunction(vm, arrayPrototypeConcatSlowPathCodeGenerator(vm), this);
 
     JSObject* regExpProtoFlagsGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->flags);
+    ASSERT_UNUSED(catchScope, !catchScope.exception());
     JSObject* regExpProtoGlobalGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->global);
+    ASSERT(!catchScope.exception());
     m_regExpProtoGlobalGetter.set(vm, this, regExpProtoGlobalGetterObject);
     JSObject* regExpProtoIgnoreCaseGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->ignoreCase);
+    ASSERT(!catchScope.exception());
     JSObject* regExpProtoMultilineGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->multiline);
+    ASSERT(!catchScope.exception());
     JSObject* regExpProtoSourceGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->source);
+    ASSERT(!catchScope.exception());
     JSObject* regExpProtoStickyGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->sticky);
+    ASSERT(!catchScope.exception());
     JSObject* regExpProtoUnicodeGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->unicode);
+    ASSERT(!catchScope.exception());
     m_regExpProtoUnicodeGetter.set(vm, this, regExpProtoUnicodeGetterObject);
     JSObject* builtinRegExpExec = asObject(m_regExpPrototype->getDirect(vm, vm.propertyNames->exec).asCell());
     m_regExpProtoExec.set(vm, this, builtinRegExpExec);
@@ -893,7 +901,6 @@
 
     {
         ExecState* exec = globalExec();
-        auto scope = DECLARE_THROW_SCOPE(vm);
 
         auto setupAdaptiveWatchpoint = [&] (JSObject* base, const Identifier& ident) -> ObjectPropertyCondition {
             // Performing these gets should not throw.
@@ -900,10 +907,10 @@
             PropertySlot slot(base, PropertySlot::InternalMethodType::Get);
             bool result = base->getOwnPropertySlot(base, exec, ident, slot);
             ASSERT_UNUSED(result, result);
-            ASSERT_UNUSED(scope, !scope.exception());
+            ASSERT(!catchScope.exception());
             RELEASE_ASSERT(slot.isCacheableValue());
             JSValue functionValue = slot.getValue(exec, ident);
-            ASSERT_UNUSED(scope, !scope.exception());
+            ASSERT(!catchScope.exception());
             ASSERT(jsDynamicCast<JSFunction*>(functionValue));
 
             ObjectPropertyCondition condition = generateConditionForSelfEquivalence(m_vm, nullptr, base, ident.impl());
@@ -934,17 +941,24 @@
 
 bool JSGlobalObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
 {
+    VM& vm = exec->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
     JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(cell);
     ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(thisObject));
 
-    if (UNLIKELY(isThisValueAltered(slot, thisObject)))
+    if (UNLIKELY(isThisValueAltered(slot, thisObject))) {
+        scope.release();
         return ordinarySetSlow(exec, thisObject, propertyName, value, slot.thisValue(), slot.isStrictMode());
+    }
 
     bool shouldThrowReadOnlyError = slot.isStrictMode();
     bool ignoreReadOnlyErrors = false;
     bool putResult = false;
-    if (symbolTablePutTouchWatchpointSet(thisObject, exec, propertyName, value, shouldThrowReadOnlyError, ignoreReadOnlyErrors, putResult))
+    bool done = symbolTablePutTouchWatchpointSet(thisObject, exec, propertyName, value, shouldThrowReadOnlyError, ignoreReadOnlyErrors, putResult);
+    ASSERT((!!scope.exception() == (done && !putResult)) || !shouldThrowReadOnlyError);
+    if (done)
         return putResult;
+    scope.release();
     return Base::put(thisObject, exec, propertyName, value, slot);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to