Skip to content

Commit

Permalink
[JSC] use UNLIKELY in Intl APIs for rare cases
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=267738
rdar://121221571

Reviewed by Alexey Shvayka and Justin Michaud.

The case that CallFrame's `this` is not the desired object
is rare, so we should use `UNLIKELY` for them in Intl APIs.

* Source/JavaScriptCore/runtime/IntlCollatorPrototype.cpp:
(JSC::JSC_DEFINE_CUSTOM_GETTER):
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/IntlDisplayNamesPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/IntlDurationFormatPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/IntlListFormatPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/IntlLocalePrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSC_DEFINE_CUSTOM_GETTER):
* Source/JavaScriptCore/runtime/IntlPluralRulesPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/IntlRelativeTimeFormatPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/IntlSegmentIteratorPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/IntlSegmenterPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/IntlSegmentsPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):

Canonical link: https://commits.webkit.org/273221@main
  • Loading branch information
hyjorc1 committed Jan 19, 2024
1 parent 8c2f912 commit ae031c1
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/runtime/IntlCollatorPrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlCollatorPrototypeGetterCompare, (JSGlobalObject* gl
// 10.3.3 Intl.Collator.prototype.compare (ECMA-402 2.0)
// 1. Let collator be this Collator object.
IntlCollator* collator = jsDynamicCast<IntlCollator*>(JSValue::decode(thisValue));
if (!collator)
if (UNLIKELY(!collator))
return JSValue::encode(throwTypeError(globalObject, scope, "Intl.Collator.prototype.compare called on value that's not a Collator"_s));

JSBoundFunction* boundCompare = collator->boundCompare();
Expand Down Expand Up @@ -144,7 +144,7 @@ JSC_DEFINE_HOST_FUNCTION(intlCollatorPrototypeFuncResolvedOptions, (JSGlobalObje

// 10.3.5 Intl.Collator.prototype.resolvedOptions() (ECMA-402 2.0)
IntlCollator* collator = jsDynamicCast<IntlCollator*>(callFrame->thisValue());
if (!collator)
if (UNLIKELY(!collator))
return JSValue::encode(throwTypeError(globalObject, scope, "Intl.Collator.prototype.resolvedOptions called on value that's not a Collator"_s));

RELEASE_AND_RETURN(scope, JSValue::encode(collator->resolvedOptions(globalObject)));
Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/runtime/IntlDisplayNamesPrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ JSC_DEFINE_HOST_FUNCTION(intlDisplayNamesPrototypeFuncOf, (JSGlobalObject* globa
auto scope = DECLARE_THROW_SCOPE(vm);

auto* displayNames = jsDynamicCast<IntlDisplayNames*>(callFrame->thisValue());
if (!displayNames)
if (UNLIKELY(!displayNames))
return throwVMTypeError(globalObject, scope, "Intl.DisplayNames.prototype.of called on value that's not a DisplayNames"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(displayNames->of(globalObject, callFrame->argument(0))));
Expand All @@ -93,7 +93,7 @@ JSC_DEFINE_HOST_FUNCTION(intlDisplayNamesPrototypeFuncResolvedOptions, (JSGlobal
auto scope = DECLARE_THROW_SCOPE(vm);

auto* displayNames = jsDynamicCast<IntlDisplayNames*>(callFrame->thisValue());
if (!displayNames)
if (UNLIKELY(!displayNames))
return throwVMTypeError(globalObject, scope, "Intl.DisplayNames.prototype.resolvedOptions called on value that's not a DisplayNames"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(displayNames->resolvedOptions(globalObject)));
Expand Down
6 changes: 3 additions & 3 deletions Source/JavaScriptCore/runtime/IntlDurationFormatPrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ JSC_DEFINE_HOST_FUNCTION(intlDurationFormatPrototypeFuncFormat, (JSGlobalObject*
auto scope = DECLARE_THROW_SCOPE(vm);

auto* durationFormat = jsDynamicCast<IntlDurationFormat*>(callFrame->thisValue());
if (!durationFormat)
if (UNLIKELY(!durationFormat))
return throwVMTypeError(globalObject, scope, "Intl.DurationFormat.prototype.format called on value that's not a DurationFormat"_s);

JSValue argument = callFrame->argument(0);
Expand All @@ -103,7 +103,7 @@ JSC_DEFINE_HOST_FUNCTION(intlDurationFormatPrototypeFuncFormatToParts, (JSGlobal
auto scope = DECLARE_THROW_SCOPE(vm);

auto* durationFormat = jsDynamicCast<IntlDurationFormat*>(callFrame->thisValue());
if (!durationFormat)
if (UNLIKELY(!durationFormat))
return throwVMTypeError(globalObject, scope, "Intl.DurationFormat.prototype.formatToParts called on value that's not a DurationFormat"_s);

JSValue argument = callFrame->argument(0);
Expand All @@ -123,7 +123,7 @@ JSC_DEFINE_HOST_FUNCTION(intlDurationFormatPrototypeFuncResolvedOptions, (JSGlob
auto scope = DECLARE_THROW_SCOPE(vm);

auto* durationFormat = jsDynamicCast<IntlDurationFormat*>(callFrame->thisValue());
if (!durationFormat)
if (UNLIKELY(!durationFormat))
return throwVMTypeError(globalObject, scope, "Intl.DurationFormat.prototype.resolvedOptions called on value that's not a DurationFormat"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(durationFormat->resolvedOptions(globalObject)));
Expand Down
6 changes: 3 additions & 3 deletions Source/JavaScriptCore/runtime/IntlListFormatPrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ JSC_DEFINE_HOST_FUNCTION(intlListFormatPrototypeFuncFormat, (JSGlobalObject* glo
auto scope = DECLARE_THROW_SCOPE(vm);

auto* listFormat = jsDynamicCast<IntlListFormat*>(callFrame->thisValue());
if (!listFormat)
if (UNLIKELY(!listFormat))
return throwVMTypeError(globalObject, scope, "Intl.ListFormat.prototype.format called on value that's not a ListFormat"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(listFormat->format(globalObject, callFrame->argument(0))));
Expand All @@ -95,7 +95,7 @@ JSC_DEFINE_HOST_FUNCTION(intlListFormatPrototypeFuncFormatToParts, (JSGlobalObje
auto scope = DECLARE_THROW_SCOPE(vm);

auto* listFormat = jsDynamicCast<IntlListFormat*>(callFrame->thisValue());
if (!listFormat)
if (UNLIKELY(!listFormat))
return throwVMTypeError(globalObject, scope, "Intl.ListFormat.prototype.formatToParts called on value that's not a ListFormat"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(listFormat->formatToParts(globalObject, callFrame->argument(0))));
Expand All @@ -108,7 +108,7 @@ JSC_DEFINE_HOST_FUNCTION(intlListFormatPrototypeFuncResolvedOptions, (JSGlobalOb
auto scope = DECLARE_THROW_SCOPE(vm);

auto* listFormat = jsDynamicCast<IntlListFormat*>(callFrame->thisValue());
if (!listFormat)
if (UNLIKELY(!listFormat))
return throwVMTypeError(globalObject, scope, "Intl.ListFormat.prototype.resolvedOptions called on value that's not a ListFormat"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(listFormat->resolvedOptions(globalObject)));
Expand Down
40 changes: 20 additions & 20 deletions Source/JavaScriptCore/runtime/IntlLocalePrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ JSC_DEFINE_HOST_FUNCTION(intlLocalePrototypeFuncMaximize, (JSGlobalObject* globa
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(callFrame->thisValue());
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.maximize called on value that's not a Locale"_s);

IntlLocale* newLocale = IntlLocale::create(vm, globalObject->localeStructure());
Expand All @@ -134,7 +134,7 @@ JSC_DEFINE_HOST_FUNCTION(intlLocalePrototypeFuncMinimize, (JSGlobalObject* globa
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(callFrame->thisValue());
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.minimize called on value that's not a Locale"_s);

IntlLocale* newLocale = IntlLocale::create(vm, globalObject->localeStructure());
Expand All @@ -150,7 +150,7 @@ JSC_DEFINE_HOST_FUNCTION(intlLocalePrototypeFuncToString, (JSGlobalObject* globa
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(callFrame->thisValue());
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.toString called on value that's not a Locale"_s);

const String& fullString = locale->toString();
Expand All @@ -164,7 +164,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlLocalePrototypeGetterBaseName, (JSGlobalObject* glo
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(JSValue::decode(thisValue));
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.baseName called on value that's not a Locale"_s);

const String& baseName = locale->baseName();
Expand All @@ -178,7 +178,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlLocalePrototypeGetterCalendar, (JSGlobalObject* glo
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(JSValue::decode(thisValue));
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.calendar called on value that's not a Locale"_s);

const String& calendar = locale->calendar();
Expand All @@ -192,7 +192,7 @@ JSC_DEFINE_HOST_FUNCTION(intlLocalePrototypeFuncGetCalendars, (JSGlobalObject* g
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(callFrame->thisValue());
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.getCalendars called on value that's not a Locale"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(locale->calendars(globalObject)));
Expand All @@ -205,7 +205,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlLocalePrototypeGetterCaseFirst, (JSGlobalObject* gl
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(JSValue::decode(thisValue));
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.caseFirst called on value that's not a Locale"_s);

const String& caseFirst = locale->caseFirst();
Expand All @@ -219,7 +219,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlLocalePrototypeGetterCollation, (JSGlobalObject* gl
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(JSValue::decode(thisValue));
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.collation called on value that's not a Locale"_s);

const String& collation = locale->collation();
Expand All @@ -233,7 +233,7 @@ JSC_DEFINE_HOST_FUNCTION(intlLocalePrototypeFuncGetCollations, (JSGlobalObject*
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(callFrame->thisValue());
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.getCollations called on value that's not a Locale"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(locale->collations(globalObject)));
Expand All @@ -246,7 +246,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlLocalePrototypeGetterHourCycle, (JSGlobalObject* gl
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(JSValue::decode(thisValue));
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.hourCycle called on value that's not a Locale"_s);

const String& hourCycle = locale->hourCycle();
Expand All @@ -260,7 +260,7 @@ JSC_DEFINE_HOST_FUNCTION(intlLocalePrototypeFuncGetHourCycles, (JSGlobalObject*
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(callFrame->thisValue());
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.getHourCycles called on value that's not a Locale"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(locale->hourCycles(globalObject)));
Expand All @@ -273,7 +273,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlLocalePrototypeGetterNumeric, (JSGlobalObject* glob
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(JSValue::decode(thisValue));
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.numeric called on value that's not a Locale"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(jsBoolean(locale->numeric() == TriState::True)));
Expand All @@ -286,7 +286,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlLocalePrototypeGetterNumberingSystem, (JSGlobalObje
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(JSValue::decode(thisValue));
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.numberingSystem called on value that's not a Locale"_s);

const String& numberingSystem = locale->numberingSystem();
Expand All @@ -300,7 +300,7 @@ JSC_DEFINE_HOST_FUNCTION(intlLocalePrototypeFuncGetNumberingSystems, (JSGlobalOb
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(callFrame->thisValue());
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.getNumberingSystems called on value that's not a Locale"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(locale->numberingSystems(globalObject)));
Expand All @@ -313,7 +313,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlLocalePrototypeGetterLanguage, (JSGlobalObject* glo
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(JSValue::decode(thisValue));
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.language called on value that's not a Locale"_s);

const String& language = locale->language();
Expand All @@ -327,7 +327,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlLocalePrototypeGetterScript, (JSGlobalObject* globa
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(JSValue::decode(thisValue));
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.script called on value that's not a Locale"_s);

const String& script = locale->script();
Expand All @@ -341,7 +341,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlLocalePrototypeGetterRegion, (JSGlobalObject* globa
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(JSValue::decode(thisValue));
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.region called on value that's not a Locale"_s);

const String& region = locale->region();
Expand All @@ -355,7 +355,7 @@ JSC_DEFINE_HOST_FUNCTION(intlLocalePrototypeFuncGetTimeZones, (JSGlobalObject* g
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(callFrame->thisValue());
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.getTimeZones called on value that's not a Locale"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(locale->timeZones(globalObject)));
Expand All @@ -368,7 +368,7 @@ JSC_DEFINE_HOST_FUNCTION(intlLocalePrototypeFuncGetTextInfo, (JSGlobalObject* gl
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(callFrame->thisValue());
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.getTextInfo called on value that's not a Locale"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(locale->textInfo(globalObject)));
Expand All @@ -381,7 +381,7 @@ JSC_DEFINE_HOST_FUNCTION(intlLocalePrototypeFuncGetWeekInfo, (JSGlobalObject* gl
auto scope = DECLARE_THROW_SCOPE(vm);

auto* locale = jsDynamicCast<IntlLocale*>(callFrame->thisValue());
if (!locale)
if (UNLIKELY(!locale))
return throwVMTypeError(globalObject, scope, "Intl.Locale.prototype.getWeekInfo called on value that's not a Locale"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(locale->weekInfo(globalObject)));
Expand Down
6 changes: 3 additions & 3 deletions Source/JavaScriptCore/runtime/IntlPluralRulesPrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ JSC_DEFINE_HOST_FUNCTION(intlPluralRulesPrototypeFuncSelect, (JSGlobalObject* gl
// https://tc39.github.io/ecma402/#sec-intl.pluralrules.prototype.select
IntlPluralRules* pluralRules = jsDynamicCast<IntlPluralRules*>(callFrame->thisValue());

if (!pluralRules)
if (UNLIKELY(!pluralRules))
return JSValue::encode(throwTypeError(globalObject, scope, "Intl.PluralRules.prototype.select called on value that's not a PluralRules"_s));

double value = callFrame->argument(0).toNumber(globalObject);
Expand All @@ -107,7 +107,7 @@ JSC_DEFINE_HOST_FUNCTION(intlPluralRulesPrototypeFuncSelectRange, (JSGlobalObjec

// https://tc39.es/proposal-intl-numberformat-v3/out/pluralrules/diff.html#sec-intl.pluralrules.prototype.selectrange
IntlPluralRules* pluralRules = jsDynamicCast<IntlPluralRules*>(callFrame->thisValue());
if (!pluralRules)
if (UNLIKELY(!pluralRules))
return JSValue::encode(throwTypeError(globalObject, scope, "Intl.PluralRules.prototype.selectRange called on value that's not a PluralRules"_s));

JSValue startValue = callFrame->argument(0);
Expand Down Expand Up @@ -135,7 +135,7 @@ JSC_DEFINE_HOST_FUNCTION(intlPluralRulesPrototypeFuncResolvedOptions, (JSGlobalO
// https://tc39.github.io/ecma402/#sec-intl.pluralrules.prototype.resolvedoptions
IntlPluralRules* pluralRules = jsDynamicCast<IntlPluralRules*>(callFrame->thisValue());

if (!pluralRules)
if (UNLIKELY(!pluralRules))
return JSValue::encode(throwTypeError(globalObject, scope, "Intl.PluralRules.prototype.resolvedOptions called on value that's not a PluralRules"_s));

RELEASE_AND_RETURN(scope, JSValue::encode(pluralRules->resolvedOptions(globalObject)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ JSC_DEFINE_HOST_FUNCTION(intlRelativeTimeFormatPrototypeFuncFormat, (JSGlobalObj
auto scope = DECLARE_THROW_SCOPE(vm);

auto* relativeTimeFormat = jsDynamicCast<IntlRelativeTimeFormat*>(callFrame->thisValue());
if (!relativeTimeFormat)
if (UNLIKELY(!relativeTimeFormat))
return JSValue::encode(throwTypeError(globalObject, scope, "Intl.RelativeTimeFormat.prototype.format called on value that's not a RelativeTimeFormat"_s));

double value = callFrame->argument(0).toNumber(globalObject);
Expand All @@ -102,7 +102,7 @@ JSC_DEFINE_HOST_FUNCTION(intlRelativeTimeFormatPrototypeFuncFormatToParts, (JSGl
auto scope = DECLARE_THROW_SCOPE(vm);

auto* relativeTimeFormat = jsDynamicCast<IntlRelativeTimeFormat*>(callFrame->thisValue());
if (!relativeTimeFormat)
if (UNLIKELY(!relativeTimeFormat))
return JSValue::encode(throwTypeError(globalObject, scope, "Intl.RelativeTimeFormat.prototype.formatToParts called on value that's not a RelativeTimeFormat"_s));

double value = callFrame->argument(0).toNumber(globalObject);
Expand All @@ -121,7 +121,7 @@ JSC_DEFINE_HOST_FUNCTION(intlRelativeTimeFormatPrototypeFuncResolvedOptions, (JS
auto scope = DECLARE_THROW_SCOPE(vm);

auto* relativeTimeFormat = jsDynamicCast<IntlRelativeTimeFormat*>(callFrame->thisValue());
if (!relativeTimeFormat)
if (UNLIKELY(!relativeTimeFormat))
return JSValue::encode(throwTypeError(globalObject, scope, "Intl.RelativeTimeFormat.prototype.resolvedOptions called on value that's not a RelativeTimeFormat"_s));

RELEASE_AND_RETURN(scope, JSValue::encode(relativeTimeFormat->resolvedOptions(globalObject)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ JSC_DEFINE_HOST_FUNCTION(intlSegmentIteratorPrototypeFuncNext, (JSGlobalObject*
auto scope = DECLARE_THROW_SCOPE(vm);

auto* segmentIterator = jsDynamicCast<IntlSegmentIterator*>(callFrame->thisValue());
if (!segmentIterator)
if (UNLIKELY(!segmentIterator))
return throwVMTypeError(globalObject, scope, "Intl.SegmentIterator.prototype.next called on value that's not a SegmentIterator"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(segmentIterator->next(globalObject)));
Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/runtime/IntlSegmenterPrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ JSC_DEFINE_HOST_FUNCTION(intlSegmenterPrototypeFuncSegment, (JSGlobalObject* glo
auto scope = DECLARE_THROW_SCOPE(vm);

auto* segmenter = jsDynamicCast<IntlSegmenter*>(callFrame->thisValue());
if (!segmenter)
if (UNLIKELY(!segmenter))
return throwVMTypeError(globalObject, scope, "Intl.Segmenter.prototype.segment called on value that's not a Segmenter"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(segmenter->segment(globalObject, callFrame->argument(0))));
Expand All @@ -93,7 +93,7 @@ JSC_DEFINE_HOST_FUNCTION(intlSegmenterPrototypeFuncResolvedOptions, (JSGlobalObj
auto scope = DECLARE_THROW_SCOPE(vm);

auto* segmenter = jsDynamicCast<IntlSegmenter*>(callFrame->thisValue());
if (!segmenter)
if (UNLIKELY(!segmenter))
return throwVMTypeError(globalObject, scope, "Intl.Segmenter.prototype.resolvedOptions called on value that's not a Segmenter"_s);

RELEASE_AND_RETURN(scope, JSValue::encode(segmenter->resolvedOptions(globalObject)));
Expand Down
Loading

0 comments on commit ae031c1

Please sign in to comment.