Commit 50ccb149 authored by yangguo's avatar yangguo Committed by Commit bot

Store fewer arrays in the context snapshot.

This slightly reduces the initial context size.

R=ishell@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28420}
parent 1643671f
...@@ -26,16 +26,6 @@ var Intl = {}; ...@@ -26,16 +26,6 @@ var Intl = {};
%AddNamedProperty(global, "Intl", Intl, DONT_ENUM); %AddNamedProperty(global, "Intl", Intl, DONT_ENUM);
var AVAILABLE_SERVICES = ['collator',
'numberformat',
'dateformat',
'breakiterator'];
var NORMALIZATION_FORMS = ['NFC',
'NFD',
'NFKC',
'NFKD'];
/** /**
* Caches available locales for each service. * Caches available locales for each service.
*/ */
...@@ -150,69 +140,6 @@ function GetTimezoneNameCheckRE() { ...@@ -150,69 +140,6 @@ function GetTimezoneNameCheckRE() {
return TIMEZONE_NAME_CHECK_RE; return TIMEZONE_NAME_CHECK_RE;
} }
/**
* Maps ICU calendar names into LDML type.
*/
var ICU_CALENDAR_MAP = {
'gregorian': 'gregory',
'japanese': 'japanese',
'buddhist': 'buddhist',
'roc': 'roc',
'persian': 'persian',
'islamic-civil': 'islamicc',
'islamic': 'islamic',
'hebrew': 'hebrew',
'chinese': 'chinese',
'indian': 'indian',
'coptic': 'coptic',
'ethiopic': 'ethiopic',
'ethiopic-amete-alem': 'ethioaa'
};
/**
* Map of Unicode extensions to option properties, and their values and types,
* for a collator.
*/
var COLLATOR_KEY_MAP = {
'kn': {'property': 'numeric', 'type': 'boolean'},
'kf': {'property': 'caseFirst', 'type': 'string',
'values': ['false', 'lower', 'upper']}
};
/**
* Map of Unicode extensions to option properties, and their values and types,
* for a number format.
*/
var NUMBER_FORMAT_KEY_MAP = {
'nu': {'property': undefined, 'type': 'string'}
};
/**
* Map of Unicode extensions to option properties, and their values and types,
* for a date/time format.
*/
var DATETIME_FORMAT_KEY_MAP = {
'ca': {'property': undefined, 'type': 'string'},
'nu': {'property': undefined, 'type': 'string'}
};
/**
* Allowed -u-co- values. List taken from:
* http://unicode.org/repos/cldr/trunk/common/bcp47/collation.xml
*/
var ALLOWED_CO_VALUES = [
'big5han', 'dict', 'direct', 'ducet', 'gb2312', 'phonebk', 'phonetic',
'pinyin', 'reformed', 'searchjl', 'stroke', 'trad', 'unihan', 'zhuyin'
];
/**
* Error message for when function object is created with new and it's not
* a constructor.
*/
var ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR =
'Function object that\'s not a constructor was created with new';
/** /**
* Adds bound method to the prototype of the given object. * Adds bound method to the prototype of the given object.
*/ */
...@@ -894,12 +821,33 @@ function initializeCollator(collator, locales, options) { ...@@ -894,12 +821,33 @@ function initializeCollator(collator, locales, options) {
// One exception is -co- which has to be part of the extension, but only for // One exception is -co- which has to be part of the extension, but only for
// usage: sort, and its value can't be 'standard' or 'search'. // usage: sort, and its value can't be 'standard' or 'search'.
var extensionMap = parseExtension(locale.extension); var extensionMap = parseExtension(locale.extension);
/**
* Map of Unicode extensions to option properties, and their values and types,
* for a collator.
*/
var COLLATOR_KEY_MAP = {
'kn': {'property': 'numeric', 'type': 'boolean'},
'kf': {'property': 'caseFirst', 'type': 'string',
'values': ['false', 'lower', 'upper']}
};
setOptions( setOptions(
options, extensionMap, COLLATOR_KEY_MAP, getOption, internalOptions); options, extensionMap, COLLATOR_KEY_MAP, getOption, internalOptions);
var collation = 'default'; var collation = 'default';
var extension = ''; var extension = '';
if (extensionMap.hasOwnProperty('co') && internalOptions.usage === 'sort') { if (extensionMap.hasOwnProperty('co') && internalOptions.usage === 'sort') {
/**
* Allowed -u-co- values. List taken from:
* http://unicode.org/repos/cldr/trunk/common/bcp47/collation.xml
*/
var ALLOWED_CO_VALUES = [
'big5han', 'dict', 'direct', 'ducet', 'gb2312', 'phonebk', 'phonetic',
'pinyin', 'reformed', 'searchjl', 'stroke', 'trad', 'unihan', 'zhuyin'
];
if (ALLOWED_CO_VALUES.indexOf(extensionMap.co) !== -1) { if (ALLOWED_CO_VALUES.indexOf(extensionMap.co) !== -1) {
extension = '-u-co-' + extensionMap.co; extension = '-u-co-' + extensionMap.co;
// ICU can't tell us what the collation is, so save user's input. // ICU can't tell us what the collation is, so save user's input.
...@@ -1126,6 +1074,15 @@ function initializeNumberFormat(numberFormat, locales, options) { ...@@ -1126,6 +1074,15 @@ function initializeNumberFormat(numberFormat, locales, options) {
// ICU prefers options to be passed using -u- extension key/values for // ICU prefers options to be passed using -u- extension key/values for
// number format, so we need to build that. // number format, so we need to build that.
var extensionMap = parseExtension(locale.extension); var extensionMap = parseExtension(locale.extension);
/**
* Map of Unicode extensions to option properties, and their values and types,
* for a number format.
*/
var NUMBER_FORMAT_KEY_MAP = {
'nu': {'property': undefined, 'type': 'string'}
};
var extension = setOptions(options, extensionMap, NUMBER_FORMAT_KEY_MAP, var extension = setOptions(options, extensionMap, NUMBER_FORMAT_KEY_MAP,
getOption, internalOptions); getOption, internalOptions);
...@@ -1520,6 +1477,16 @@ function initializeDateTimeFormat(dateFormat, locales, options) { ...@@ -1520,6 +1477,16 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
// we need to build that. // we need to build that.
var internalOptions = {}; var internalOptions = {};
var extensionMap = parseExtension(locale.extension); var extensionMap = parseExtension(locale.extension);
/**
* Map of Unicode extensions to option properties, and their values and types,
* for a date/time format.
*/
var DATETIME_FORMAT_KEY_MAP = {
'ca': {'property': undefined, 'type': 'string'},
'nu': {'property': undefined, 'type': 'string'}
};
var extension = setOptions(options, extensionMap, DATETIME_FORMAT_KEY_MAP, var extension = setOptions(options, extensionMap, DATETIME_FORMAT_KEY_MAP,
getOption, internalOptions); getOption, internalOptions);
...@@ -1591,6 +1558,25 @@ function initializeDateTimeFormat(dateFormat, locales, options) { ...@@ -1591,6 +1558,25 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "DateTimeFormat"); throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "DateTimeFormat");
} }
/**
* Maps ICU calendar names into LDML type.
*/
var ICU_CALENDAR_MAP = {
'gregorian': 'gregory',
'japanese': 'japanese',
'buddhist': 'buddhist',
'roc': 'roc',
'persian': 'persian',
'islamic-civil': 'islamicc',
'islamic': 'islamic',
'hebrew': 'hebrew',
'chinese': 'chinese',
'indian': 'indian',
'coptic': 'coptic',
'ethiopic': 'ethiopic',
'ethiopic-amete-alem': 'ethioaa'
};
var format = this; var format = this;
var fromPattern = fromLDMLString(format.resolved.pattern); var fromPattern = fromLDMLString(format.resolved.pattern);
var userCalendar = ICU_CALENDAR_MAP[format.resolved.calendar]; var userCalendar = ICU_CALENDAR_MAP[format.resolved.calendar];
...@@ -1953,6 +1939,8 @@ $overrideFunction(GlobalString.prototype, 'normalize', function(that) { ...@@ -1953,6 +1939,8 @@ $overrideFunction(GlobalString.prototype, 'normalize', function(that) {
var form = GlobalString(%_Arguments(0) || 'NFC'); var form = GlobalString(%_Arguments(0) || 'NFC');
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
var normalizationForm = NORMALIZATION_FORMS.indexOf(form); var normalizationForm = NORMALIZATION_FORMS.indexOf(form);
if (normalizationForm === -1) { if (normalizationForm === -1) {
throw MakeRangeError(kNormalizationForm, NORMALIZATION_FORMS.join(', ')); throw MakeRangeError(kNormalizationForm, NORMALIZATION_FORMS.join(', '));
......
...@@ -170,9 +170,6 @@ function StringMatchJS(regexp) { ...@@ -170,9 +170,6 @@ function StringMatchJS(regexp) {
} }
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
// ECMA-262 v6, section 21.1.3.12 // ECMA-262 v6, section 21.1.3.12
// //
// For now we do nothing, as proper normalization requires big tables. // For now we do nothing, as proper normalization requires big tables.
...@@ -182,6 +179,9 @@ function StringNormalizeJS(form) { ...@@ -182,6 +179,9 @@ function StringNormalizeJS(form) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
var form = form ? TO_STRING_INLINE(form) : 'NFC'; var form = form ? TO_STRING_INLINE(form) : 'NFC';
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
var normalizationForm = NORMALIZATION_FORMS.indexOf(form); var normalizationForm = NORMALIZATION_FORMS.indexOf(form);
if (normalizationForm === -1) { if (normalizationForm === -1) {
throw MakeRangeError(kNormalizationForm, NORMALIZATION_FORMS.join(', ')); throw MakeRangeError(kNormalizationForm, NORMALIZATION_FORMS.join(', '));
...@@ -410,7 +410,7 @@ function CaptureString(string, lastCaptureInfo, index) { ...@@ -410,7 +410,7 @@ function CaptureString(string, lastCaptureInfo, index) {
// TODO(lrn): This array will survive indefinitely if replace is never // TODO(lrn): This array will survive indefinitely if replace is never
// called again. However, it will be empty, since the contents are cleared // called again. However, it will be empty, since the contents are cleared
// in the finally block. // in the finally block.
var reusableReplaceArray = new InternalArray(16); var reusableReplaceArray = new InternalArray(4);
// Helper function for replacing regular expressions with the result of a // Helper function for replacing regular expressions with the result of a
// function application in String.prototype.replace. // function application in String.prototype.replace.
......
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