Commit 0bd50885 authored by littledan's avatar littledan Committed by Commit bot

Remove certain non-standard properties from Intl

This patch removes the following properties, as their use count is
very low, they are V8-only, and not on a standards track.
- v8Parse
- resolved
- pattern

v8BreakIterator is left in as it has significantly more usage.

BUG=v8:3785
R=adamk,jshin@chromium.org

Review-Url: https://codereview.chromium.org/1968893002
Cr-Commit-Position: refs/heads/master@{#36190}
parent bfb1c9e6
......@@ -421,6 +421,7 @@ action("js2c_experimental") {
"src/js/harmony-species.js",
"src/js/harmony-unicode-regexps.js",
"src/js/harmony-string-padding.js",
"src/js/intl-extra.js",
"src/js/promise-extra.js",
]
......
......@@ -205,6 +205,7 @@ class Genesis BASE_EMBEDDED {
HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION)
HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION)
DECLARE_FEATURE_INITIALIZATION(promise_extra, "")
DECLARE_FEATURE_INITIALIZATION(intl_extra, "")
#undef DECLARE_FEATURE_INITIALIZATION
Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target,
......@@ -1976,6 +1977,7 @@ void Genesis::InitializeExperimentalGlobal() {
HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL)
HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL)
FEATURE_INITIALIZE_GLOBAL(promise_extra, "")
FEATURE_INITIALIZE_GLOBAL(intl_extra, "")
#undef FEATURE_INITIALIZE_GLOBAL
}
......@@ -2454,6 +2456,7 @@ void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate,
}
INITIALIZE_FLAG(FLAG_harmony_species)
INITIALIZE_FLAG(FLAG_intl_extra)
#undef INITIALIZE_FLAG
}
......@@ -2472,6 +2475,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_name)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_sent)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(promise_extra)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(intl_extra)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_explicit_tailcalls)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tailcalls)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_instanceof)
......@@ -3042,6 +3046,7 @@ bool Genesis::InstallExperimentalNatives() {
static const char* harmony_function_sent_natives[] = {nullptr};
static const char* promise_extra_natives[] = {"native promise-extra.js",
nullptr};
static const char* intl_extra_natives[] = {"native intl-extra.js", nullptr};
static const char* harmony_object_values_entries_natives[] = {nullptr};
static const char* harmony_object_own_property_descriptors_natives[] = {
nullptr};
......@@ -3071,6 +3076,7 @@ bool Genesis::InstallExperimentalNatives() {
HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES);
HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES);
HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES);
INSTALL_EXPERIMENTAL_NATIVES(intl_extra, "");
INSTALL_EXPERIMENTAL_NATIVES(promise_extra, "");
#undef INSTALL_EXPERIMENTAL_NATIVES
}
......
......@@ -188,6 +188,10 @@ DEFINE_BOOL(promise_extra, false, "additional V8 Promise functions")
// Removing extra Promise functions is shipped
DEFINE_NEG_VALUE_IMPLICATION(harmony_shipping, promise_extra, true)
DEFINE_BOOL(intl_extra, true, "additional V8 Intl functions")
// Removing extra Intl functions is staged
DEFINE_NEG_IMPLICATION(harmony, intl_extra)
// Activate on ClusterFuzz.
DEFINE_IMPLICATION(es_staging, harmony_regexp_lookbehind)
DEFINE_IMPLICATION(es_staging, move_object_start)
......
......@@ -20,6 +20,7 @@
var ArrayIndexOf;
var ArrayJoin;
var ArrayPush;
var FLAG_intl_extra;
var GlobalBoolean = global.Boolean;
var GlobalDate = global.Date;
var GlobalNumber = global.Number;
......@@ -64,6 +65,10 @@ utils.Import(function(from) {
StringSubstring = from.StringSubstring;
});
utils.ImportFromExperimental(function(from) {
FLAG_intl_extra = from.FLAG_intl_extra;
});
// Utilities for definitions
function InstallFunction(object, name, func) {
......@@ -988,7 +993,9 @@ function initializeCollator(collator, locales, options) {
// Writable, configurable and enumerable are set to false by default.
%MarkAsInitializedIntlObjectOfType(collator, 'collator', internalCollator);
collator[resolvedSymbol] = resolved;
if (FLAG_intl_extra) {
%object_define_property(collator, 'resolved', resolvedAccessor);
}
return collator;
}
......@@ -1209,7 +1216,6 @@ function initializeNumberFormat(numberFormat, locales, options) {
minimumFractionDigits: {writable: true},
minimumIntegerDigits: {writable: true},
numberingSystem: {writable: true},
pattern: patternAccessor,
requestedLocale: {value: requestedLocale, writable: true},
style: {value: internalOptions.style, writable: true},
useGrouping: {writable: true}
......@@ -1231,7 +1237,10 @@ function initializeNumberFormat(numberFormat, locales, options) {
%MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter);
numberFormat[resolvedSymbol] = resolved;
if (FLAG_intl_extra) {
%object_define_property(resolved, 'pattern', patternAccessor);
%object_define_property(numberFormat, 'resolved', resolvedAccessor);
}
return numberFormat;
}
......@@ -1337,14 +1346,12 @@ function formatNumber(formatter, value) {
/**
* Returns a Number that represents string value that was passed in.
*/
function parseNumber(formatter, value) {
function IntlParseNumber(formatter, value) {
return %InternalNumberParse(%GetImplFromInitializedIntlObject(formatter),
GlobalString(value));
}
AddBoundMethod(Intl.NumberFormat, 'format', formatNumber, 1);
AddBoundMethod(Intl.NumberFormat, 'v8Parse', parseNumber, 1);
/**
* Returns a string that matches LDML representation of the options object.
......@@ -1606,7 +1613,6 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
month: {writable: true},
numberingSystem: {writable: true},
[patternSymbol]: {writable: true},
pattern: patternAccessor,
requestedLocale: {value: requestedLocale, writable: true},
second: {writable: true},
timeZone: {writable: true},
......@@ -1625,7 +1631,10 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
%MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter);
dateFormat[resolvedSymbol] = resolved;
if (FLAG_intl_extra) {
%object_define_property(resolved, 'pattern', patternAccessor);
%object_define_property(dateFormat, 'resolved', resolvedAccessor);
}
return dateFormat;
}
......@@ -1759,7 +1768,7 @@ function formatDate(formatter, dateValue) {
* DateTimeFormat.
* Returns undefined if date string cannot be parsed.
*/
function parseDate(formatter, value) {
function IntlParseDate(formatter, value) {
return %InternalDateParse(%GetImplFromInitializedIntlObject(formatter),
GlobalString(value));
}
......@@ -1767,7 +1776,6 @@ function parseDate(formatter, value) {
// 0 because date is optional argument.
AddBoundMethod(Intl.DateTimeFormat, 'format', formatDate, 0);
AddBoundMethod(Intl.DateTimeFormat, 'v8Parse', parseDate, 1);
/**
......@@ -1842,7 +1850,9 @@ function initializeBreakIterator(iterator, locales, options) {
%MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator',
internalIterator);
iterator[resolvedSymbol] = resolved;
if (FLAG_intl_extra) {
%object_define_property(iterator, 'resolved', resolvedAccessor);
}
return iterator;
}
......@@ -2222,4 +2232,10 @@ OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
}
);
utils.Export(function(to) {
to.AddBoundMethod = AddBoundMethod;
to.IntlParseDate = IntlParseDate;
to.IntlParseNumber = IntlParseNumber;
});
})
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function(global, utils) {
"use strict";
%CheckIsBootstrapping();
var GlobalIntl = global.Intl;
var AddBoundMethod = utils.ImportNow("AddBoundMethod");
var IntlParseDate = utils.ImportNow("IntlParseDate");
var IntlParseNumber = utils.ImportNow("IntlParseNumber");
AddBoundMethod(GlobalIntl.DateTimeFormat, 'v8Parse', IntlParseDate, 1);
AddBoundMethod(GlobalIntl.NumberFormat, 'v8Parse', IntlParseNumber, 1);
})
......@@ -181,10 +181,13 @@ function PostNatives(utils) {
// Whitelist of exports from normal natives to experimental natives and debug.
var expose_list = [
"AddBoundMethod",
"ArrayToString",
"ErrorToString",
"GetIterator",
"GetMethod",
"IntlParseDate",
"IntlParseNumber",
"IsNaN",
"MakeError",
"MakeRangeError",
......
......@@ -2031,6 +2031,7 @@
'js/harmony-species.js',
'js/harmony-unicode-regexps.js',
'js/harmony-string-padding.js',
'js/intl-extra.js',
'js/promise-extra.js',
],
'libraries_bin_file': '<(SHARED_INTERMEDIATE_DIR)/libraries.bin',
......
......@@ -28,6 +28,8 @@
// Testing v8Parse method for date and time pattern.
// Month is represented as a short name.
// Flags: --intl-extra
var dtf = new Intl.DateTimeFormat(['en'],
{year: 'numeric', month: 'short',
day: 'numeric',
......
......@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --intl-extra
// Invalid input is handled properly.
var dtf = new Intl.DateTimeFormat(['en']);
......
......@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --intl-extra
// Testing v8Parse method for date only.
function checkDate(date) {
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --intl-extra
// Turning on the creates the non-standard properties
var dtf = new Intl.DateTimeFormat(['en']);
assertTrue('v8Parse' in dtf);
assertTrue('resolved' in dtf);
assertTrue(!!dtf.resolved && 'pattern' in dtf.resolved);
var nf = new Intl.NumberFormat(['en']);
assertTrue('v8Parse' in nf);
assertTrue('resolved' in nf);
assertTrue(!!nf.resolved && 'pattern' in nf.resolved);
var col = new Intl.Collator(['en']);
assertTrue('resolved' in col);
var br = new Intl.v8BreakIterator(['en']);
assertTrue('resolved' in br);
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --no-intl-extra
// Turning off the flag removes the non-standard properties
var dtf = new Intl.DateTimeFormat(['en']);
assertFalse('v8Parse' in dtf);
assertFalse('resolved' in dtf);
assertFalse(!!dtf.resolved && 'pattern' in dtf.resolved);
var nf = new Intl.NumberFormat(['en']);
assertFalse('v8Parse' in nf);
assertFalse('resolved' in nf);
assertFalse(!!nf.resolved && 'pattern' in nf.resolved);
var col = new Intl.Collator(['en']);
assertFalse('resolved' in col);
var br = new Intl.v8BreakIterator(['en']);
assertFalse('resolved' in br);
......@@ -28,6 +28,8 @@
// Create default NumberFormat.
var nf = new Intl.NumberFormat();
var beforeCount = Object.getOwnPropertyNames(nf).length;
// Array we want to iterate, actual numbers are not important.
var numberArray = [1, 2, 3];
......@@ -39,4 +41,4 @@ numberArray.forEach(nf.format);
nf.format(12345);
// Reading the format doesn't add any additional property keys
assertEquals(1, Object.getOwnPropertyNames(nf).length);
assertEquals(beforeCount, Object.getOwnPropertyNames(nf).length);
......@@ -28,6 +28,8 @@
// Currency parsing is not yet supported. We need ICU49 or higher to get
// it working.
// Flags: --intl-extra
var nf = new Intl.NumberFormat(['en'], {style: 'currency', currency: 'USD'});
assertEquals(undefined, nf.v8Parse('USD 123.43'));
......@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --intl-extra
// Invalid input is handled properly.
var nf = new Intl.NumberFormat(['en']);
......
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