Changeset 209043 in webkit


Ignore:
Timestamp:
Nov 28, 2016 3:56:06 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

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):

Location:
trunk/Source/JavaScriptCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r209037 r209043  
     12016-11-21  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix exception scope verification failures in runtime/Intl* files.
     4        https://bugs.webkit.org/show_bug.cgi?id=165014
     5
     6        Reviewed by Saam Barati.
     7
     8        * runtime/IntlCollatorConstructor.cpp:
     9        (JSC::constructIntlCollator):
     10        (JSC::IntlCollatorConstructorFuncSupportedLocalesOf):
     11        * runtime/IntlCollatorPrototype.cpp:
     12        (JSC::IntlCollatorPrototypeFuncResolvedOptions):
     13        * runtime/IntlDateTimeFormatConstructor.cpp:
     14        (JSC::constructIntlDateTimeFormat):
     15        (JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf):
     16        * runtime/IntlDateTimeFormatPrototype.cpp:
     17        (JSC::IntlDateTimeFormatFuncFormatDateTime):
     18        (JSC::IntlDateTimeFormatPrototypeGetterFormat):
     19        (JSC::IntlDateTimeFormatPrototypeFuncResolvedOptions):
     20        * runtime/IntlNumberFormatConstructor.cpp:
     21        (JSC::constructIntlNumberFormat):
     22        (JSC::IntlNumberFormatConstructorFuncSupportedLocalesOf):
     23        * runtime/IntlNumberFormatPrototype.cpp:
     24        (JSC::IntlNumberFormatFuncFormatNumber):
     25        (JSC::IntlNumberFormatPrototypeGetterFormat):
     26        (JSC::IntlNumberFormatPrototypeFuncResolvedOptions):
     27        * runtime/IntlObject.cpp:
     28        (JSC::lookupSupportedLocales):
     29        * runtime/IntlObjectInlines.h:
     30        (JSC::constructIntlInstanceWithWorkaroundForLegacyIntlConstructor):
     31
    1322016-11-28  Mark Lam  <mark.lam@apple.com>
    233
  • trunk/Source/JavaScriptCore/runtime/IntlCollatorConstructor.cpp

    r206386 r209043  
    9797
    9898    // 4. Return InitializeCollator(collator, locales, options).
     99    scope.release();
    99100    collator->initializeCollator(*state, state->argument(0), state->argument(1));
    100101    return JSValue::encode(collator);
     
    149150    // 3. Return SupportedLocales(%Collator%.[[availableLocales]], requestedLocales, options).
    150151    JSGlobalObject* globalObject = state->callee()->globalObject();
     152    scope.release();
    151153    return JSValue::encode(supportedLocales(*state, globalObject->intlCollatorAvailableLocales(), requestedLocales, state->argument(1)));
    152154}
  • trunk/Source/JavaScriptCore/runtime/IntlCollatorPrototype.cpp

    r208767 r209043  
    146146        return JSValue::encode(throwTypeError(state, scope, ASCIILiteral("Intl.Collator.prototype.resolvedOptions called on value that's not an object initialized as a Collator")));
    147147
     148    scope.release();
    148149    return JSValue::encode(collator->resolvedOptions(*state));
    149150}
  • trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormatConstructor.cpp

    r206386 r209043  
    9797
    9898    // 4. Return InitializeDateTimeFormat(dateTimeFormat, locales, options).
     99    scope.release();
    99100    dateTimeFormat->initializeDateTimeFormat(*state, state->argument(0), state->argument(1));
    100101    return JSValue::encode(dateTimeFormat);
     
    150151
    151152    // 3. Return SupportedLocales(availableLocales, requestedLocales, options).
     153    scope.release();
    152154    return JSValue::encode(supportedLocales(*state, availableLocales, requestedLocales, state->argument(1)));
    153155}
  • trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp

    r206386 r209043  
    106106
    107107    // 5. Return FormatDateTime(dtf, x).
     108    scope.release();
    108109    return JSValue::encode(format->format(*state, value));
    109110}
     
    120121    // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
    121122    // https://bugs.webkit.org/show_bug.cgi?id=153679
    122     if (!dtf)
    123         dtf = jsDynamicCast<IntlDateTimeFormat*>(state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName()));
     123    if (!dtf) {
     124        JSValue value = state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName());
     125        RETURN_IF_EXCEPTION(scope, encodedJSValue());
     126        dtf = jsDynamicCast<IntlDateTimeFormat*>(value);
     127    }
    124128
    125129    // 2. ReturnIfAbrupt(dtf).
     
    158162    // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
    159163    // https://bugs.webkit.org/show_bug.cgi?id=153679
    160     if (!dateTimeFormat)
    161         dateTimeFormat = jsDynamicCast<IntlDateTimeFormat*>(state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName()));
     164    if (!dateTimeFormat) {
     165        JSValue value = state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName());
     166        RETURN_IF_EXCEPTION(scope, encodedJSValue());
     167        dateTimeFormat = jsDynamicCast<IntlDateTimeFormat*>(value);
     168    }
    162169
    163170    if (!dateTimeFormat)
    164171        return JSValue::encode(throwTypeError(state, scope, ASCIILiteral("Intl.DateTimeFormat.prototype.resolvedOptions called on value that's not an object initialized as a DateTimeFormat")));
    165172
     173    scope.release();
    166174    return JSValue::encode(dateTimeFormat->resolvedOptions(*state));
    167175}
  • trunk/Source/JavaScriptCore/runtime/IntlNumberFormatConstructor.cpp

    r206386 r209043  
    9797
    9898    // 4. Return InitializeNumberFormat(numberFormat, locales, options).
     99    scope.release();
    99100    numberFormat->initializeNumberFormat(*state, state->argument(0), state->argument(1));
    100101    return JSValue::encode(numberFormat);
     
    150151
    151152    // 3. Return SupportedLocales(availableLocales, requestedLocales, options).
     153    scope.release();
    152154    return JSValue::encode(supportedLocales(*state, availableLocales, requestedLocales, state->argument(1)));
    153155}
  • trunk/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp

    r206386 r209043  
    9595
    9696    // 6. Return FormatNumber(nf, x).
     97    scope.release();
    9798    return JSValue::encode(numberFormat->formatNumber(*state, number));
    9899}
     
    109110    // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
    110111    // https://bugs.webkit.org/show_bug.cgi?id=153679
    111     if (!nf)
    112         nf = jsDynamicCast<IntlNumberFormat*>(state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName()));
     112    if (!nf) {
     113        JSValue value = state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName());
     114        RETURN_IF_EXCEPTION(scope, encodedJSValue());
     115        nf = jsDynamicCast<IntlNumberFormat*>(value);
     116    }
    113117
    114118    if (!nf)
     
    146150    // FIXME: Workaround to provide compatibility with ECMA-402 1.0 call/apply patterns.
    147151    // https://bugs.webkit.org/show_bug.cgi?id=153679
    148     if (!numberFormat)
    149         numberFormat = jsDynamicCast<IntlNumberFormat*>(state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName()));
     152    if (!numberFormat) {
     153        JSValue value = state->thisValue().get(state, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName());
     154        RETURN_IF_EXCEPTION(scope, encodedJSValue());
     155        numberFormat = jsDynamicCast<IntlNumberFormat*>(value);
     156    }
    150157
    151158    if (!numberFormat)
    152159        return JSValue::encode(throwTypeError(state, scope, ASCIILiteral("Intl.NumberFormat.prototype.resolvedOptions called on value that's not an object initialized as a NumberFormat")));
    153160
     161    scope.release();
    154162    return JSValue::encode(numberFormat->resolvedOptions(*state));
    155163}
  • trunk/Source/JavaScriptCore/runtime/IntlObject.cpp

    r206837 r209043  
    909909
    910910        // f. If availableLocale is not undefined, then append locale to the end of subset.
    911         if (!availableLocale.isNull())
     911        if (!availableLocale.isNull()) {
    912912            subset->push(&state, jsString(&state, locale));
     913            RETURN_IF_EXCEPTION(scope, nullptr);
     914        }
    913915
    914916        // g. Increment k by 1.
  • trunk/Source/JavaScriptCore/runtime/IntlObjectInlines.h

    r206386 r209043  
    4545    if (!jsDynamicCast<IntlInstance*>(thisValue)) {
    4646        JSValue prototype = callee->getDirect(vm, vm.propertyNames->prototype);
    47         if (JSObject::defaultHasInstance(&state, thisValue, prototype)) {
     47        bool hasInstance = JSObject::defaultHasInstance(&state, thisValue, prototype);
     48        RETURN_IF_EXCEPTION(scope, JSValue());
     49        if (hasInstance) {
    4850            JSObject* thisObject = thisValue.toObject(&state);
    4951            RETURN_IF_EXCEPTION(scope, JSValue());
     
    5658        }
    5759    }
    58 
     60    scope.release();
    5961    return factory(vm);
    6062}
Note: See TracChangeset for help on using the changeset viewer.