Commit 4f374bbc authored by littledan's avatar littledan Committed by Commit bot

Use InternalArrays from certain Intl code

The ECMA 402 implementation previously pushed directly to real
Arrays, which risks having observably incorrect behavior in the
presence of monkey patching. This patch uses InternalArrays instead
to avoid that hazard.

R=jshin@chromium.org,yangguo@chromium.org
BUG=chromium:604299
LOG=N

Review-Url: https://codereview.chromium.org/1923803002
Cr-Commit-Position: refs/heads/master@{#35949}
parent f65e06b9
......@@ -27,7 +27,7 @@ var GlobalRegExp = global.RegExp;
var GlobalString = global.String;
var InstallFunctions = utils.InstallFunctions;
var InstallGetter = utils.InstallGetter;
var InternalPackedArray = utils.InternalPackedArray;
var InternalArray = utils.InternalArray;
var InternalRegExpMatch;
var InternalRegExpReplace
var IsFinite;
......@@ -305,7 +305,7 @@ function supportedLocalesOf(service, locales, options) {
* Locales appear in the same order in the returned list as in the input list.
*/
function lookupSupportedLocalesOf(requestedLocales, availableLocales) {
var matchedLocales = [];
var matchedLocales = new InternalArray();
for (var i = 0; i < requestedLocales.length; ++i) {
// Remove -u- extension.
var locale = InternalRegExpReplace(
......@@ -565,14 +565,16 @@ function setOptions(inOptions, extensionMap, keyValues, getOption, outOptions) {
/**
* Converts all OwnProperties into
* Given an array-like, outputs an Array with the numbered
* properties copied over and defined
* configurable: false, writable: false, enumerable: true.
*/
function freezeArray(array) {
var l = array.length;
function freezeArray(input) {
var array = [];
var l = input.length;
for (var i = 0; i < l; i++) {
if (i in array) {
%object_define_property(array, i, {value: array[i],
if (i in input) {
%object_define_property(array, i, {value: input[i],
configurable: false,
writable: false,
enumerable: true});
......@@ -749,11 +751,8 @@ function canonicalizeLanguageTag(localeID) {
* Throws on locales that are not well formed BCP47 tags.
*/
function initializeLocaleList(locales) {
var seen = [];
if (IS_UNDEFINED(locales)) {
// Constructor is called without arguments.
seen = [];
} else {
var seen = new InternalArray();
if (!IS_UNDEFINED(locales)) {
// We allow single string localeID.
if (typeof locales === 'string') {
%_Call(ArrayPush, seen, canonicalizeLanguageTag(locales));
......@@ -808,8 +807,8 @@ function isValidLanguageTag(locale) {
// Skip language since it can match variant regex, so we start from 1.
// We are matching i-klingon here, but that's ok, since i-klingon-klingon
// is not valid and would fail LANGUAGE_TAG_RE test.
var variants = [];
var extensions = [];
var variants = new InternalArray();
var extensions = new InternalArray();
var parts = %_Call(StringSplit, locale, '-');
for (var i = 1; i < parts.length; i++) {
var value = parts[i];
......
......@@ -21,7 +21,6 @@ var GlobalArrayBuffer = global.ArrayBuffer;
var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype;
var GlobalDataView = global.DataView;
var GlobalObject = global.Object;
var InternalArray = utils.InternalArray;
var InnerArrayCopyWithin;
var InnerArrayEvery;
var InnerArrayFill;
......
// 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.
Array.prototype.__defineSetter__(0,function(value){});
if (this.Intl) {
var o = new Intl.DateTimeFormat('en-US', {'timeZone': 'Asia/Katmandu'})
}
......@@ -211,8 +211,6 @@
# incompatibilities if the test cases turn out to be broken or ambiguous.
# Some of these are related to v8:4361 in being visible side effects from Intl.
'intl402/6.2.3': [FAIL],
'intl402/9.2.1_2': [FAIL],
'intl402/9.2.6_2': [FAIL],
'intl402/Collator/10.1.2.1_4': [FAIL],
'intl402/Collator/10.1.2_a': [PASS, FAIL],
'intl402/Collator/10.2.3_b': [PASS, FAIL],
......
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