diff --git a/include/v8.h b/include/v8.h index 340baa74ab..a4bbe1b0c4 100644 --- a/include/v8.h +++ b/include/v8.h @@ -7366,6 +7366,21 @@ class V8_EXPORT Isolate { kWasmThreadOpcodes = 51, kAtomicsNotify = 52, kAtomicsWake = 53, + kCollator = 54, + kNumberFormat = 55, + kDateTimeFormat = 56, + kPluralRules = 57, + kRelativeTimeFormat = 58, + kLocale = 59, + kListFormat = 60, + kSegmenter = 61, + kStringLocaleCompare = 62, + kStringToLocaleUpperCase = 63, + kStringToLocaleLowerCase = 64, + kNumberToLocaleString = 65, + kDateToLocaleString = 66, + kDateToLocaleDateString = 67, + kDateToLocaleTimeString = 68, // If you add new values here, you'll also need to update Chromium's: // web_feature.mojom, UseCounterCallback.cpp, and enums.xml. V8 changes to diff --git a/src/builtins/builtins-date.cc b/src/builtins/builtins-date.cc index e59daeab2c..91da4d6d7d 100644 --- a/src/builtins/builtins-date.cc +++ b/src/builtins/builtins-date.cc @@ -843,7 +843,11 @@ BUILTIN(DatePrototypeToTimeString) { // ecma402 #sup-date.prototype.tolocaledatestring BUILTIN(DatePrototypeToLocaleDateString) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kDateToLocaleDateString); + CHECK_RECEIVER(JSDate, date, "Date.prototype.toLocaleDateString"); + RETURN_RESULT_OR_FAILURE( isolate, JSDateTimeFormat::ToLocaleDateTime( isolate, @@ -858,7 +862,11 @@ BUILTIN(DatePrototypeToLocaleDateString) { // ecma402 #sup-date.prototype.tolocalestring BUILTIN(DatePrototypeToLocaleString) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kDateToLocaleString); + CHECK_RECEIVER(JSDate, date, "Date.prototype.toLocaleString"); + RETURN_RESULT_OR_FAILURE( isolate, JSDateTimeFormat::ToLocaleDateTime( isolate, @@ -873,7 +881,11 @@ BUILTIN(DatePrototypeToLocaleString) { // ecma402 #sup-date.prototype.tolocaletimestring BUILTIN(DatePrototypeToLocaleTimeString) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kDateToLocaleTimeString); + CHECK_RECEIVER(JSDate, date, "Date.prototype.toLocaleTimeString"); + RETURN_RESULT_OR_FAILURE( isolate, JSDateTimeFormat::ToLocaleDateTime( isolate, diff --git a/src/builtins/builtins-intl.cc b/src/builtins/builtins-intl.cc index 7dc600d490..48276ba043 100644 --- a/src/builtins/builtins-intl.cc +++ b/src/builtins/builtins-intl.cc @@ -349,6 +349,9 @@ Object* FormatConstructor(BuiltinArguments args, Isolate* isolate, BUILTIN(NumberFormatConstructor) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kNumberFormat); + return FormatConstructor( args, isolate, isolate->intl_number_format_function(), "Intl.NumberFormat"); @@ -438,6 +441,9 @@ BUILTIN(NumberFormatInternalFormatNumber) { BUILTIN(DateTimeFormatConstructor) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kDateTimeFormat); + return FormatConstructor( args, isolate, isolate->intl_date_time_format_function(), "Intl.DateTimeFormat"); @@ -496,6 +502,9 @@ BUILTIN(DateTimeFormatInternalFormat) { BUILTIN(ListFormatConstructor) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kListFormat); + // 1. If NewTarget is undefined, throw a TypeError exception. if (args.new_target()->IsUndefined(isolate)) { // [[Call]] THROW_NEW_ERROR_RETURN_FAILURE( @@ -582,6 +591,9 @@ MaybeHandle CreateLocale(Isolate* isolate, // Intl.Locale implementation BUILTIN(LocaleConstructor) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kLocale); + if (args.new_target()->IsUndefined(isolate)) { // [[Call]] THROW_NEW_ERROR_RETURN_FAILURE( isolate, NewTypeError(MessageTemplate::kConstructorNotFunction, @@ -742,6 +754,9 @@ BUILTIN(LocalePrototypeToString) { BUILTIN(RelativeTimeFormatConstructor) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kRelativeTimeFormat); + // 1. If NewTarget is undefined, throw a TypeError exception. if (args.new_target()->IsUndefined(isolate)) { // [[Call]] THROW_NEW_ERROR_RETURN_FAILURE( @@ -783,7 +798,11 @@ BUILTIN(RelativeTimeFormatPrototypeResolvedOptions) { BUILTIN(StringPrototypeToLocaleLowerCase) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kStringToLocaleLowerCase); + TO_THIS_STRING(string, "String.prototype.toLocaleLowerCase"); + RETURN_RESULT_OR_FAILURE( isolate, Intl::StringLocaleConvertCase(isolate, string, false, args.atOrUndefined(isolate, 1))); @@ -791,7 +810,11 @@ BUILTIN(StringPrototypeToLocaleLowerCase) { BUILTIN(StringPrototypeToLocaleUpperCase) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kStringToLocaleUpperCase); + TO_THIS_STRING(string, "String.prototype.toLocaleUpperCase"); + RETURN_RESULT_OR_FAILURE( isolate, Intl::StringLocaleConvertCase(isolate, string, true, args.atOrUndefined(isolate, 1))); @@ -800,6 +823,8 @@ BUILTIN(StringPrototypeToLocaleUpperCase) { BUILTIN(PluralRulesConstructor) { HandleScope scope(isolate); + isolate->CountUsage(v8::Isolate::UseCounterFeature::kPluralRules); + // 1. If NewTarget is undefined, throw a TypeError exception. if (args.new_target()->IsUndefined(isolate)) { // [[Call]] THROW_NEW_ERROR_RETURN_FAILURE( @@ -869,6 +894,9 @@ BUILTIN(PluralRulesSupportedLocalesOf) { BUILTIN(CollatorConstructor) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kCollator); + Handle new_target; // 1. If NewTarget is undefined, let newTarget be the active // function object, else let newTarget be NewTarget. diff --git a/src/builtins/builtins-number.cc b/src/builtins/builtins-number.cc index 2f21c2d4b1..d15c41105d 100644 --- a/src/builtins/builtins-number.cc +++ b/src/builtins/builtins-number.cc @@ -111,6 +111,9 @@ BUILTIN(NumberPrototypeToFixed) { // ES6 section 20.1.3.4 Number.prototype.toLocaleString ( [ r1 [ , r2 ] ] ) BUILTIN(NumberPrototypeToLocaleString) { HandleScope scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kNumberToLocaleString); + Handle value = args.at(0); // Unwrap the receiver {value}. diff --git a/src/builtins/builtins-string.cc b/src/builtins/builtins-string.cc index 0dafa230b5..7aba998aa4 100644 --- a/src/builtins/builtins-string.cc +++ b/src/builtins/builtins-string.cc @@ -195,6 +195,9 @@ BUILTIN(StringPrototypeLastIndexOf) { // do anything locale specific. BUILTIN(StringPrototypeLocaleCompare) { HandleScope handle_scope(isolate); + + isolate->CountUsage(v8::Isolate::UseCounterFeature::kStringLocaleCompare); + #ifdef V8_INTL_SUPPORT TO_THIS_STRING(str1, "String.prototype.localeCompare"); Handle str2;