[Intl] Add CountUsage for intl objects/functions

Chrome side changes in https://chromium-review.googlesource.com/c/chromium/src/+/1255629

Bug: v8:8250
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng;luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Icba3e73217919c71925774d0cfbab69a7ffa1bba
Reviewed-on: https://chromium-review.googlesource.com/c/1255628
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56358}
This commit is contained in:
Frank Tang 2018-10-03 13:59:09 -07:00 committed by Commit Bot
parent 77f917bafb
commit 6029498ea8
5 changed files with 61 additions and 0 deletions

View File

@ -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

View File

@ -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,

View File

@ -349,6 +349,9 @@ Object* FormatConstructor(BuiltinArguments args, Isolate* isolate,
BUILTIN(NumberFormatConstructor) {
HandleScope scope(isolate);
isolate->CountUsage(v8::Isolate::UseCounterFeature::kNumberFormat);
return FormatConstructor<JSNumberFormat>(
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<JSDateTimeFormat>(
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<JSLocale> 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<JSReceiver> new_target;
// 1. If NewTarget is undefined, let newTarget be the active
// function object, else let newTarget be NewTarget.

View File

@ -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<Object> value = args.at(0);
// Unwrap the receiver {value}.

View File

@ -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<String> str2;