Commit 09685b5b authored by littledan's avatar littledan Committed by Commit bot

Add UseCounters for various standards-related code paths

- Each of the three deprecated Promise functions
- Two nonstandard pieces of Intl functionality
- Accesses of the RegExp.prototype.unicode getter on the prototype

BUG=v8:3785,v8:3238,v8:4633
LOG=N
R=adamk
TBR=hpayer

Review URL: https://codereview.chromium.org/1558113002

Cr-Commit-Position: refs/heads/master@{#33142}
parent 2367abf0
...@@ -5445,6 +5445,13 @@ class V8_EXPORT Isolate { ...@@ -5445,6 +5445,13 @@ class V8_EXPORT Isolate {
kStrongMode = 10, kStrongMode = 10,
kRegExpPrototypeStickyGetter = 11, kRegExpPrototypeStickyGetter = 11,
kRegExpPrototypeToString = 12, kRegExpPrototypeToString = 12,
kRegExpPrototypeUnicodeGetter = 13,
kIntlV8Parse = 14,
kIntlPattern = 15,
kIntlResolved = 16,
kPromiseChain = 17,
kPromiseAccept = 18,
kPromiseDefer = 19,
kUseCounterFeatureCount // This enum value must be last. kUseCounterFeatureCount // This enum value must be last.
}; };
......
...@@ -355,6 +355,8 @@ namespace internal { ...@@ -355,6 +355,8 @@ namespace internal {
V(internal_error_symbol) \ V(internal_error_symbol) \
V(intl_impl_object_symbol) \ V(intl_impl_object_symbol) \
V(intl_initialized_marker_symbol) \ V(intl_initialized_marker_symbol) \
V(intl_pattern_symbol) \
V(intl_resolved_symbol) \
V(megamorphic_symbol) \ V(megamorphic_symbol) \
V(native_context_index_symbol) \ V(native_context_index_symbol) \
V(nonexistent_symbol) \ V(nonexistent_symbol) \
......
...@@ -145,7 +145,7 @@ void SetResolvedDateSettings(Isolate* isolate, ...@@ -145,7 +145,7 @@ void SetResolvedDateSettings(Isolate* isolate,
icu::UnicodeString pattern; icu::UnicodeString pattern;
date_format->toPattern(pattern); date_format->toPattern(pattern);
JSObject::SetProperty( JSObject::SetProperty(
resolved, factory->NewStringFromStaticChars("pattern"), resolved, factory->intl_pattern_symbol(),
factory->NewStringFromTwoByte( factory->NewStringFromTwoByte(
Vector<const uint16_t>( Vector<const uint16_t>(
reinterpret_cast<const uint16_t*>(pattern.getBuffer()), reinterpret_cast<const uint16_t*>(pattern.getBuffer()),
...@@ -367,7 +367,7 @@ void SetResolvedNumberSettings(Isolate* isolate, ...@@ -367,7 +367,7 @@ void SetResolvedNumberSettings(Isolate* isolate,
icu::UnicodeString pattern; icu::UnicodeString pattern;
number_format->toPattern(pattern); number_format->toPattern(pattern);
JSObject::SetProperty( JSObject::SetProperty(
resolved, factory->NewStringFromStaticChars("pattern"), resolved, factory->intl_pattern_symbol(),
factory->NewStringFromTwoByte( factory->NewStringFromTwoByte(
Vector<const uint16_t>( Vector<const uint16_t>(
reinterpret_cast<const uint16_t*>(pattern.getBuffer()), reinterpret_cast<const uint16_t*>(pattern.getBuffer()),
......
...@@ -38,8 +38,6 @@ function RegExpGetFlags() { ...@@ -38,8 +38,6 @@ function RegExpGetFlags() {
return result; return result;
} }
const kRegExpPrototypeStickyGetter = 11;
// ES6 21.2.5.12. // ES6 21.2.5.12.
function RegExpGetSticky() { function RegExpGetSticky() {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
......
...@@ -24,6 +24,9 @@ utils.Import(function(from) { ...@@ -24,6 +24,9 @@ utils.Import(function(from) {
// ES6 21.2.5.15. // ES6 21.2.5.15.
function RegExpGetUnicode() { function RegExpGetUnicode() {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
if (this === GlobalRegExpPrototype) {
%IncrementUseCounter(kRegExpPrototypeUnicodeGetter);
}
throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode"); throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode");
} }
return !!REGEXP_UNICODE(this); return !!REGEXP_UNICODE(this);
......
...@@ -33,7 +33,9 @@ var MakeTypeError; ...@@ -33,7 +33,9 @@ var MakeTypeError;
var MathFloor; var MathFloor;
var ObjectDefineProperties = utils.ImportNow("ObjectDefineProperties"); var ObjectDefineProperties = utils.ImportNow("ObjectDefineProperties");
var ObjectDefineProperty = utils.ImportNow("ObjectDefineProperty"); var ObjectDefineProperty = utils.ImportNow("ObjectDefineProperty");
var patternSymbol = utils.ImportNow("intl_pattern_symbol");
var RegExpTest; var RegExpTest;
var resolvedSymbol = utils.ImportNow("intl_resolved_symbol");
var StringIndexOf; var StringIndexOf;
var StringLastIndexOf; var StringLastIndexOf;
var StringMatch; var StringMatch;
...@@ -878,6 +880,16 @@ function BuildLanguageTagREs() { ...@@ -878,6 +880,16 @@ function BuildLanguageTagREs() {
LANGUAGE_TAG_RE = new GlobalRegExp(languageTag, 'i'); LANGUAGE_TAG_RE = new GlobalRegExp(languageTag, 'i');
} }
var resolvedAccessor = {
get() {
%IncrementUseCounter(kIntlResolved);
return this[resolvedSymbol];
},
set(value) {
this[resolvedSymbol] = value;
}
};
/** /**
* Initializes the given object so it's a valid Collator instance. * Initializes the given object so it's a valid Collator instance.
* Useful for subclassing. * Useful for subclassing.
...@@ -976,7 +988,8 @@ function initializeCollator(collator, locales, options) { ...@@ -976,7 +988,8 @@ function initializeCollator(collator, locales, options) {
// Writable, configurable and enumerable are set to false by default. // Writable, configurable and enumerable are set to false by default.
%MarkAsInitializedIntlObjectOfType(collator, 'collator', internalCollator); %MarkAsInitializedIntlObjectOfType(collator, 'collator', internalCollator);
ObjectDefineProperty(collator, 'resolved', {value: resolved}); collator[resolvedSymbol] = resolved;
ObjectDefineProperty(collator, 'resolved', resolvedAccessor);
return collator; return collator;
} }
...@@ -1016,17 +1029,17 @@ function initializeCollator(collator, locales, options) { ...@@ -1016,17 +1029,17 @@ function initializeCollator(collator, locales, options) {
} }
var coll = this; var coll = this;
var locale = getOptimalLanguageTag(coll.resolved.requestedLocale, var locale = getOptimalLanguageTag(coll[resolvedSymbol].requestedLocale,
coll.resolved.locale); coll[resolvedSymbol].locale);
return { return {
locale: locale, locale: locale,
usage: coll.resolved.usage, usage: coll[resolvedSymbol].usage,
sensitivity: coll.resolved.sensitivity, sensitivity: coll[resolvedSymbol].sensitivity,
ignorePunctuation: coll.resolved.ignorePunctuation, ignorePunctuation: coll[resolvedSymbol].ignorePunctuation,
numeric: coll.resolved.numeric, numeric: coll[resolvedSymbol].numeric,
caseFirst: coll.resolved.caseFirst, caseFirst: coll[resolvedSymbol].caseFirst,
collation: coll.resolved.collation collation: coll[resolvedSymbol].collation
}; };
}, },
DONT_ENUM DONT_ENUM
...@@ -1103,6 +1116,15 @@ function getNumberOption(options, property, min, max, fallback) { ...@@ -1103,6 +1116,15 @@ function getNumberOption(options, property, min, max, fallback) {
return fallback; return fallback;
} }
var patternAccessor = {
get() {
%IncrementUseCounter(kIntlPattern);
return this[patternSymbol];
},
set(value) {
this[patternSymbol] = value;
}
};
/** /**
* Initializes the given object so it's a valid NumberFormat instance. * Initializes the given object so it's a valid NumberFormat instance.
...@@ -1198,6 +1220,7 @@ function initializeNumberFormat(numberFormat, locales, options) { ...@@ -1198,6 +1220,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
minimumFractionDigits: {writable: true}, minimumFractionDigits: {writable: true},
minimumIntegerDigits: {writable: true}, minimumIntegerDigits: {writable: true},
numberingSystem: {writable: true}, numberingSystem: {writable: true},
pattern: patternAccessor,
requestedLocale: {value: requestedLocale, writable: true}, requestedLocale: {value: requestedLocale, writable: true},
style: {value: internalOptions.style, writable: true}, style: {value: internalOptions.style, writable: true},
useGrouping: {writable: true} useGrouping: {writable: true}
...@@ -1218,7 +1241,8 @@ function initializeNumberFormat(numberFormat, locales, options) { ...@@ -1218,7 +1241,8 @@ function initializeNumberFormat(numberFormat, locales, options) {
} }
%MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter); %MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter);
ObjectDefineProperty(numberFormat, 'resolved', {value: resolved}); numberFormat[resolvedSymbol] = resolved;
ObjectDefineProperty(numberFormat, 'resolved', resolvedAccessor);
return numberFormat; return numberFormat;
} }
...@@ -1258,33 +1282,33 @@ function initializeNumberFormat(numberFormat, locales, options) { ...@@ -1258,33 +1282,33 @@ function initializeNumberFormat(numberFormat, locales, options) {
} }
var format = this; var format = this;
var locale = getOptimalLanguageTag(format.resolved.requestedLocale, var locale = getOptimalLanguageTag(format[resolvedSymbol].requestedLocale,
format.resolved.locale); format[resolvedSymbol].locale);
var result = { var result = {
locale: locale, locale: locale,
numberingSystem: format.resolved.numberingSystem, numberingSystem: format[resolvedSymbol].numberingSystem,
style: format.resolved.style, style: format[resolvedSymbol].style,
useGrouping: format.resolved.useGrouping, useGrouping: format[resolvedSymbol].useGrouping,
minimumIntegerDigits: format.resolved.minimumIntegerDigits, minimumIntegerDigits: format[resolvedSymbol].minimumIntegerDigits,
minimumFractionDigits: format.resolved.minimumFractionDigits, minimumFractionDigits: format[resolvedSymbol].minimumFractionDigits,
maximumFractionDigits: format.resolved.maximumFractionDigits, maximumFractionDigits: format[resolvedSymbol].maximumFractionDigits,
}; };
if (result.style === 'currency') { if (result.style === 'currency') {
defineWECProperty(result, 'currency', format.resolved.currency); defineWECProperty(result, 'currency', format[resolvedSymbol].currency);
defineWECProperty(result, 'currencyDisplay', defineWECProperty(result, 'currencyDisplay',
format.resolved.currencyDisplay); format[resolvedSymbol].currencyDisplay);
} }
if (%HasOwnProperty(format.resolved, 'minimumSignificantDigits')) { if (%HasOwnProperty(format[resolvedSymbol], 'minimumSignificantDigits')) {
defineWECProperty(result, 'minimumSignificantDigits', defineWECProperty(result, 'minimumSignificantDigits',
format.resolved.minimumSignificantDigits); format[resolvedSymbol].minimumSignificantDigits);
} }
if (%HasOwnProperty(format.resolved, 'maximumSignificantDigits')) { if (%HasOwnProperty(format[resolvedSymbol], 'maximumSignificantDigits')) {
defineWECProperty(result, 'maximumSignificantDigits', defineWECProperty(result, 'maximumSignificantDigits',
format.resolved.maximumSignificantDigits); format[resolvedSymbol].maximumSignificantDigits);
} }
return result; return result;
...@@ -1602,7 +1626,8 @@ function initializeDateTimeFormat(dateFormat, locales, options) { ...@@ -1602,7 +1626,8 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
minute: {writable: true}, minute: {writable: true},
month: {writable: true}, month: {writable: true},
numberingSystem: {writable: true}, numberingSystem: {writable: true},
pattern: {writable: true}, [patternSymbol]: {writable: true},
pattern: patternAccessor,
requestedLocale: {value: requestedLocale, writable: true}, requestedLocale: {value: requestedLocale, writable: true},
second: {writable: true}, second: {writable: true},
timeZone: {writable: true}, timeZone: {writable: true},
...@@ -1620,7 +1645,8 @@ function initializeDateTimeFormat(dateFormat, locales, options) { ...@@ -1620,7 +1645,8 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
} }
%MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter); %MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter);
ObjectDefineProperty(dateFormat, 'resolved', {value: resolved}); dateFormat[resolvedSymbol] = resolved;
ObjectDefineProperty(dateFormat, 'resolved', resolvedAccessor);
return dateFormat; return dateFormat;
} }
...@@ -1679,22 +1705,22 @@ function initializeDateTimeFormat(dateFormat, locales, options) { ...@@ -1679,22 +1705,22 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
}; };
var format = this; var format = this;
var fromPattern = fromLDMLString(format.resolved.pattern); var fromPattern = fromLDMLString(format[resolvedSymbol][patternSymbol]);
var userCalendar = ICU_CALENDAR_MAP[format.resolved.calendar]; var userCalendar = ICU_CALENDAR_MAP[format[resolvedSymbol].calendar];
if (IS_UNDEFINED(userCalendar)) { if (IS_UNDEFINED(userCalendar)) {
// Use ICU name if we don't have a match. It shouldn't happen, but // Use ICU name if we don't have a match. It shouldn't happen, but
// it would be too strict to throw for this. // it would be too strict to throw for this.
userCalendar = format.resolved.calendar; userCalendar = format[resolvedSymbol].calendar;
} }
var locale = getOptimalLanguageTag(format.resolved.requestedLocale, var locale = getOptimalLanguageTag(format[resolvedSymbol].requestedLocale,
format.resolved.locale); format[resolvedSymbol].locale);
var result = { var result = {
locale: locale, locale: locale,
numberingSystem: format.resolved.numberingSystem, numberingSystem: format[resolvedSymbol].numberingSystem,
calendar: userCalendar, calendar: userCalendar,
timeZone: format.resolved.timeZone timeZone: format[resolvedSymbol].timeZone
}; };
addWECPropertyIfDefined(result, 'timeZoneName', fromPattern.timeZoneName); addWECPropertyIfDefined(result, 'timeZoneName', fromPattern.timeZoneName);
...@@ -1846,7 +1872,8 @@ function initializeBreakIterator(iterator, locales, options) { ...@@ -1846,7 +1872,8 @@ function initializeBreakIterator(iterator, locales, options) {
%MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator', %MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator',
internalIterator); internalIterator);
ObjectDefineProperty(iterator, 'resolved', {value: resolved}); iterator[resolvedSymbol] = resolved;
ObjectDefineProperty(iterator, 'resolved', resolvedAccessor);
return iterator; return iterator;
} }
...@@ -1887,12 +1914,13 @@ function initializeBreakIterator(iterator, locales, options) { ...@@ -1887,12 +1914,13 @@ function initializeBreakIterator(iterator, locales, options) {
} }
var segmenter = this; var segmenter = this;
var locale = getOptimalLanguageTag(segmenter.resolved.requestedLocale, var locale =
segmenter.resolved.locale); getOptimalLanguageTag(segmenter[resolvedSymbol].requestedLocale,
segmenter[resolvedSymbol].locale);
return { return {
locale: locale, locale: locale,
type: segmenter.resolved.type type: segmenter[resolvedSymbol].type
}; };
}, },
DONT_ENUM DONT_ENUM
......
...@@ -314,3 +314,25 @@ macro DEBUG_PREPARE_STEP_IN_IF_STEPPING(function) = if (%_DebugIsActive() != 0) ...@@ -314,3 +314,25 @@ macro DEBUG_PREPARE_STEP_IN_IF_STEPPING(function) = if (%_DebugIsActive() != 0)
# SharedFlag equivalents # SharedFlag equivalents
define kNotShared = false; define kNotShared = false;
define kShared = true; define kShared = true;
# UseCounters from include/v8.h
define kUseAsm = 0;
define kBreakIterator = 1;
define kLegacyConst = 2;
define kMarkDequeOverflow = 3;
define kStoreBufferOverflow = 4;
define kSlotsBufferOverflow = 5;
define kObjectObserve = 6;
define kForcedGC = 7;
define kSloppyMode = 8;
define kStrictMode = 9;
define kStrongMode = 10;
define kRegExpPrototypeStickyGetter = 11;
define kRegExpPrototypeToString = 12;
define kRegExpPrototypeUnicodeGetter = 13;
define kIntlV8Parse = 14;
define kIntlPattern = 15;
define kIntlResolved = 16;
define kPromiseChain = 17;
define kPromiseAccept = 18;
define kPromiseDefer = 19;
...@@ -246,10 +246,12 @@ function NewPromiseCapability(C) { ...@@ -246,10 +246,12 @@ function NewPromiseCapability(C) {
} }
function PromiseDeferred() { function PromiseDeferred() {
%IncrementUseCounter(kPromiseDefer);
return NewPromiseCapability(this); return NewPromiseCapability(this);
} }
function PromiseResolved(x) { function PromiseResolved(x) {
%IncrementUseCounter(kPromiseAccept);
return %_Call(PromiseCast, this, x); return %_Call(PromiseCast, this, x);
} }
...@@ -314,6 +316,7 @@ function PromiseThen(onResolve, onReject) { ...@@ -314,6 +316,7 @@ function PromiseThen(onResolve, onReject) {
// Chain is left around for now as an alias for then // Chain is left around for now as an alias for then
function PromiseChain(onResolve, onReject) { function PromiseChain(onResolve, onReject) {
%IncrementUseCounter(kPromiseChain);
return %_Call(PromiseThen, this, onResolve, onReject); return %_Call(PromiseThen, this, onResolve, onReject);
} }
......
...@@ -271,8 +271,6 @@ function TrimRegExp(regexp) { ...@@ -271,8 +271,6 @@ function TrimRegExp(regexp) {
} }
var kRegExpPrototypeToString = 12;
function RegExpToString() { function RegExpToString() {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
// RegExp.prototype.toString() returns '/(?:)/' as a compatibility fix; // RegExp.prototype.toString() returns '/(?:)/' as a compatibility fix;
......
...@@ -473,6 +473,8 @@ RUNTIME_FUNCTION(Runtime_InternalNumberParse) { ...@@ -473,6 +473,8 @@ RUNTIME_FUNCTION(Runtime_InternalNumberParse) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0);
CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1); CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1);
isolate->CountUsage(v8::Isolate::UseCounterFeature::kIntlV8Parse);
v8::String::Utf8Value utf8_number(v8::Utils::ToLocal(number_string)); v8::String::Utf8Value utf8_number(v8::Utils::ToLocal(number_string));
icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number)); icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number));
icu::DecimalFormat* number_format = icu::DecimalFormat* number_format =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment