Fix exception scope verification failures in runtime/Intl* files.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Nov 2016 23:56:06 +0000 (23:56 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Nov 2016 23:56:06 +0000 (23:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165014

Reviewed by Saam Barati.

* runtime/IntlCollatorConstructor.cpp:
(JSC::constructIntlCollator):
(JSC::IntlCollatorConstructorFuncSupportedLocalesOf):
* runtime/IntlCollatorPrototype.cpp:
(JSC::IntlCollatorPrototypeFuncResolvedOptions):
* runtime/IntlDateTimeFormatConstructor.cpp:
(JSC::constructIntlDateTimeFormat):
(JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf):
* runtime/IntlDateTimeFormatPrototype.cpp:
(JSC::IntlDateTimeFormatFuncFormatDateTime):
(JSC::IntlDateTimeFormatPrototypeGetterFormat):
(JSC::IntlDateTimeFormatPrototypeFuncResolvedOptions):
* runtime/IntlNumberFormatConstructor.cpp:
(JSC::constructIntlNumberFormat):
(JSC::IntlNumberFormatConstructorFuncSupportedLocalesOf):
* runtime/IntlNumberFormatPrototype.cpp:
(JSC::IntlNumberFormatFuncFormatNumber):
(JSC::IntlNumberFormatPrototypeGetterFormat):
(JSC::IntlNumberFormatPrototypeFuncResolvedOptions):
* runtime/IntlObject.cpp:
(JSC::lookupSupportedLocales):
* runtime/IntlObjectInlines.h:
(JSC::constructIntlInstanceWithWorkaroundForLegacyIntlConstructor):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/IntlCollatorConstructor.cpp
Source/JavaScriptCore/runtime/IntlCollatorPrototype.cpp
Source/JavaScriptCore/runtime/IntlDateTimeFormatConstructor.cpp
Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp
Source/JavaScriptCore/runtime/IntlNumberFormatConstructor.cpp
Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp
Source/JavaScriptCore/runtime/IntlObject.cpp
Source/JavaScriptCore/runtime/IntlObjectInlines.h

index 62670304f321bf779b18e7310cf56042688018bc..4924b475ede9d0d473823b02517a822900d36513 100644 (file)
@@ -1,3 +1,34 @@
+2016-11-21  Mark Lam  <mark.lam@apple.com>
+
+        Fix exception scope verification failures in runtime/Intl* files.
+        https://bugs.webkit.org/show_bug.cgi?id=165014
+
+        Reviewed by Saam Barati.
+
+        * runtime/IntlCollatorConstructor.cpp:
+        (JSC::constructIntlCollator):
+        (JSC::IntlCollatorConstructorFuncSupportedLocalesOf):
+        * runtime/IntlCollatorPrototype.cpp:
+        (JSC::IntlCollatorPrototypeFuncResolvedOptions):
+        * runtime/IntlDateTimeFormatConstructor.cpp:
+        (JSC::constructIntlDateTimeFormat):
+        (JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf):
+        * runtime/IntlDateTimeFormatPrototype.cpp:
+        (JSC::IntlDateTimeFormatFuncFormatDateTime):
+        (JSC::IntlDateTimeFormatPrototypeGetterFormat):
+        (JSC::IntlDateTimeFormatPrototypeFuncResolvedOptions):
+        * runtime/IntlNumberFormatConstructor.cpp:
+        (JSC::constructIntlNumberFormat):
+        (JSC::IntlNumberFormatConstructorFuncSupportedLocalesOf):
+        * runtime/IntlNumberFormatPrototype.cpp:
+        (JSC::IntlNumberFormatFuncFormatNumber):
+        (JSC::IntlNumberFormatPrototypeGetterFormat):
+        (JSC::IntlNumberFormatPrototypeFuncResolvedOptions):
+        * runtime/IntlObject.cpp:
+        (JSC::lookupSupportedLocales):
+        * runtime/IntlObjectInlines.h:
+        (JSC::constructIntlInstanceWithWorkaroundForLegacyIntlConstructor):
+
 2016-11-28  Mark Lam  <mark.lam@apple.com>
 
         Fix exception scope verification failures in IteratorOperations.h.
index b3b5bdf4964ceb7ce0dc63054dbcbefb30f7a62f..47097ea83800ef340ad518986ec0394bdc6b39fb 100644 (file)
@@ -96,6 +96,7 @@ static EncodedJSValue JSC_HOST_CALL constructIntlCollator(ExecState* state)
     ASSERT(collator);
 
     // 4. Return InitializeCollator(collator, locales, options).
+    scope.release();
     collator->initializeCollator(*state, state->argument(0), state->argument(1));
     return JSValue::encode(collator);
 }
@@ -148,6 +149,7 @@ EncodedJSValue JSC_HOST_CALL IntlCollatorConstructorFuncSupportedLocalesOf(ExecS
 
     // 3. Return SupportedLocales(%Collator%.[[availableLocales]], requestedLocales, options).
     JSGlobalObject* globalObject = state->callee()->globalObject();
+    scope.release();
     return JSValue::encode(supportedLocales(*state, globalObject->intlCollatorAvailableLocales(), requestedLocales, state->argument(1)));
 }
 
index 73ae062bcedcc6efc2a9b27ad4d1fce81650b90d..61322663b8109939cd913d98a13de3b59a9d6934 100644 (file)
@@ -145,6 +145,7 @@ EncodedJSValue JSC_HOST_CALL IntlCollatorPrototypeFuncResolvedOptions(ExecState*
     if (!collator)
         return JSValue::encode(throwTypeError(state, scope, ASCIILiteral("Intl.Collator.prototype.resolvedOptions called on value that's not an object initialized as a Collator")));
 
+    scope.release();
     return JSValue::encode(collator->resolvedOptions(*state));
 }
 
index 8d26eed7c743c919c10760b27c585b7ecd62ae12..e2de6394e6f387507d3d9d2fb57c967b34176b99 100644 (file)
@@ -96,6 +96,7 @@ static EncodedJSValue JSC_HOST_CALL constructIntlDateTimeFormat(ExecState* state
     ASSERT(dateTimeFormat);
 
     // 4. Return InitializeDateTimeFormat(dateTimeFormat, locales, options).
+    scope.release();
     dateTimeFormat->initializeDateTimeFormat(*state, state->argument(0), state->argument(1));
     return JSValue::encode(dateTimeFormat);
 }
@@ -149,6 +150,7 @@ EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatConstructorFuncSupportedLocalesOf
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     // 3. Return SupportedLocales(availableLocales, requestedLocales, options).
+    scope.release();
     return JSValue::encode(supportedLocales(*state, availableLocales, requestedLocales, state->argument(1)));
 }
 
index d75055c289ab9b5b4904f8548ddc31ada9d627d3..81420776a236582e9f34efdffd6a3023464fc0d9 100644 (file)
@@ -105,6 +105,7 @@ static EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatFuncFormatDateTime(ExecSta
     }
 
     // 5. Return FormatDateTime(dtf, x).
+    scope.release();
     return JSValue::encode(format->format(*state, value));
 }
 
@@ -119,8 +120,11 @@ EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatPrototypeGetterFormat(ExecState*
 
     // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
     // https://bugs.webkit.org/show_bug.cgi?id=153679
-    if (!dtf)
-        dtf = jsDynamicCast<IntlDateTimeFormat*>(state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName()));
+    if (!dtf) {
+        JSValue value = state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName());
+        RETURN_IF_EXCEPTION(scope, encodedJSValue());
+        dtf = jsDynamicCast<IntlDateTimeFormat*>(value);
+    }
 
     // 2. ReturnIfAbrupt(dtf).
     if (!dtf)
@@ -157,12 +161,16 @@ EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatPrototypeFuncResolvedOptions(Exec
 
     // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
     // https://bugs.webkit.org/show_bug.cgi?id=153679
-    if (!dateTimeFormat)
-        dateTimeFormat = jsDynamicCast<IntlDateTimeFormat*>(state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName()));
+    if (!dateTimeFormat) {
+        JSValue value = state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName());
+        RETURN_IF_EXCEPTION(scope, encodedJSValue());
+        dateTimeFormat = jsDynamicCast<IntlDateTimeFormat*>(value);
+    }
 
     if (!dateTimeFormat)
         return JSValue::encode(throwTypeError(state, scope, ASCIILiteral("Intl.DateTimeFormat.prototype.resolvedOptions called on value that's not an object initialized as a DateTimeFormat")));
 
+    scope.release();
     return JSValue::encode(dateTimeFormat->resolvedOptions(*state));
 }
 
index df4fd4ed193fcb54dc4cf83f01554986d8d3abf2..1c43b91d4013cc5583f37180592ca5669d0defe6 100644 (file)
@@ -96,6 +96,7 @@ static EncodedJSValue JSC_HOST_CALL constructIntlNumberFormat(ExecState* state)
     ASSERT(numberFormat);
 
     // 4. Return InitializeNumberFormat(numberFormat, locales, options).
+    scope.release();
     numberFormat->initializeNumberFormat(*state, state->argument(0), state->argument(1));
     return JSValue::encode(numberFormat);
 }
@@ -149,6 +150,7 @@ EncodedJSValue JSC_HOST_CALL IntlNumberFormatConstructorFuncSupportedLocalesOf(E
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     // 3. Return SupportedLocales(availableLocales, requestedLocales, options).
+    scope.release();
     return JSValue::encode(supportedLocales(*state, availableLocales, requestedLocales, state->argument(1)));
 }
 
index 84f88523a6d4946d9b1b96251584eab6f835cfd1..3128c847ba9f5dd1d1cb394f833c2ad15b6290ce 100644 (file)
@@ -94,6 +94,7 @@ static EncodedJSValue JSC_HOST_CALL IntlNumberFormatFuncFormatNumber(ExecState*
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     // 6. Return FormatNumber(nf, x).
+    scope.release();
     return JSValue::encode(numberFormat->formatNumber(*state, number));
 }
 
@@ -108,8 +109,11 @@ EncodedJSValue JSC_HOST_CALL IntlNumberFormatPrototypeGetterFormat(ExecState* st
 
     // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
     // https://bugs.webkit.org/show_bug.cgi?id=153679
-    if (!nf)
-        nf = jsDynamicCast<IntlNumberFormat*>(state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName()));
+    if (!nf) {
+        JSValue value = state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName());
+        RETURN_IF_EXCEPTION(scope, encodedJSValue());
+        nf = jsDynamicCast<IntlNumberFormat*>(value);
+    }
 
     if (!nf)
         return JSValue::encode(throwTypeError(state, scope, ASCIILiteral("Intl.NumberFormat.prototype.format called on value that's not an object initialized as a NumberFormat")));
@@ -145,12 +149,16 @@ EncodedJSValue JSC_HOST_CALL IntlNumberFormatPrototypeFuncResolvedOptions(ExecSt
 
     // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
     // https://bugs.webkit.org/show_bug.cgi?id=153679
-    if (!numberFormat)
-        numberFormat = jsDynamicCast<IntlNumberFormat*>(state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName()));
+    if (!numberFormat) {
+        JSValue value = state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName());
+        RETURN_IF_EXCEPTION(scope, encodedJSValue());
+        numberFormat = jsDynamicCast<IntlNumberFormat*>(value);
+    }
 
     if (!numberFormat)
         return JSValue::encode(throwTypeError(state, scope, ASCIILiteral("Intl.NumberFormat.prototype.resolvedOptions called on value that's not an object initialized as a NumberFormat")));
 
+    scope.release();
     return JSValue::encode(numberFormat->resolvedOptions(*state));
 }
 
index a5f8ec5fe7dd1d43d390b441b00958adc021e030..de3a63133fd5ce19cbcb8dd86d3f9baf61ebc763 100644 (file)
@@ -908,8 +908,10 @@ static JSArray* lookupSupportedLocales(ExecState& state, const HashSet<String>&
         String availableLocale = bestAvailableLocale(availableLocales, noExtensionsLocale);
 
         // f. If availableLocale is not undefined, then append locale to the end of subset.
-        if (!availableLocale.isNull())
+        if (!availableLocale.isNull()) {
             subset->push(&state, jsString(&state, locale));
+            RETURN_IF_EXCEPTION(scope, nullptr);
+        }
 
         // g. Increment k by 1.
     }
index 72be09b4d894a706e47a56f07143a28eb0ead244..eb0e859764d182863f0fc0ab53e953c444bcfd60 100644 (file)
@@ -44,7 +44,9 @@ JSValue constructIntlInstanceWithWorkaroundForLegacyIntlConstructor(ExecState& s
 
     if (!jsDynamicCast<IntlInstance*>(thisValue)) {
         JSValue prototype = callee->getDirect(vm, vm.propertyNames->prototype);
-        if (JSObject::defaultHasInstance(&state, thisValue, prototype)) {
+        bool hasInstance = JSObject::defaultHasInstance(&state, thisValue, prototype);
+        RETURN_IF_EXCEPTION(scope, JSValue());
+        if (hasInstance) {
             JSObject* thisObject = thisValue.toObject(&state);
             RETURN_IF_EXCEPTION(scope, JSValue());
 
@@ -55,7 +57,7 @@ JSValue constructIntlInstanceWithWorkaroundForLegacyIntlConstructor(ExecState& s
             return thisObject;
         }
     }
-
+    scope.release();
     return factory(vm);
 }