Commit 2188bdaf authored by yangguo's avatar yangguo Committed by Commit bot

Install js intrinsic fallbacks for array functions on the native context.

R=cbruni@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#30382}
parent e7cd9d32
...@@ -2,14 +2,6 @@ ...@@ -2,14 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
var $arrayConcat;
var $arrayPush;
var $arrayPop;
var $arrayShift;
var $arraySlice;
var $arraySplice;
var $arrayUnshift;
(function(global, utils) { (function(global, utils) {
"use strict"; "use strict";
...@@ -1695,6 +1687,7 @@ utils.SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [ ...@@ -1695,6 +1687,7 @@ utils.SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [
utils.Export(function(to) { utils.Export(function(to) {
to.ArrayIndexOf = ArrayIndexOf; to.ArrayIndexOf = ArrayIndexOf;
to.ArrayJoin = ArrayJoin; to.ArrayJoin = ArrayJoin;
to.ArrayPush = ArrayPush;
to.ArrayToString = ArrayToString; to.ArrayToString = ArrayToString;
to.InnerArrayEvery = InnerArrayEvery; to.InnerArrayEvery = InnerArrayEvery;
to.InnerArrayFilter = InnerArrayFilter; to.InnerArrayFilter = InnerArrayFilter;
...@@ -1711,12 +1704,14 @@ utils.Export(function(to) { ...@@ -1711,12 +1704,14 @@ utils.Export(function(to) {
to.PackedArrayReverse = PackedArrayReverse; to.PackedArrayReverse = PackedArrayReverse;
}); });
$arrayConcat = ArrayConcatJS; %InstallToContext([
$arrayPush = ArrayPush; "array_concat", ArrayConcatJS,
$arrayPop = ArrayPop; "array_pop", ArrayPop,
$arrayShift = ArrayShift; "array_push", ArrayPush,
$arraySlice = ArraySlice; "array_shift", ArrayShift,
$arraySplice = ArraySplice; "array_splice", ArraySplice,
$arrayUnshift = ArrayUnshift; "array_slice", ArraySlice,
"array_unshift", ArrayUnshift,
]);
}); });
This diff is collapsed.
...@@ -91,6 +91,13 @@ enum BindingFlags { ...@@ -91,6 +91,13 @@ enum BindingFlags {
V(TO_STRING_FUN_INDEX, JSFunction, to_string_fun) V(TO_STRING_FUN_INDEX, JSFunction, to_string_fun)
#define NATIVE_CONTEXT_IMPORTED_FIELDS(V) \ #define NATIVE_CONTEXT_IMPORTED_FIELDS(V) \
V(ARRAY_CONCAT_INDEX, JSFunction, array_concat) \
V(ARRAY_POP_INDEX, JSFunction, array_pop) \
V(ARRAY_PUSH_INDEX, JSFunction, array_push) \
V(ARRAY_SHIFT_INDEX, JSFunction, array_shift) \
V(ARRAY_SPLICE_INDEX, JSFunction, array_splice) \
V(ARRAY_SLICE_INDEX, JSFunction, array_slice) \
V(ARRAY_UNSHIFT_INDEX, JSFunction, array_unshift) \
V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \ V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \
V(CREATE_DATE_FUN_INDEX, JSFunction, create_date_fun) \ V(CREATE_DATE_FUN_INDEX, JSFunction, create_date_fun) \
V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \ V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
var ArrayIndexOf; var ArrayIndexOf;
var ArrayJoin; var ArrayJoin;
var ArrayPush;
var IsFinite; var IsFinite;
var IsNaN; var IsNaN;
var GlobalBoolean = global.Boolean; var GlobalBoolean = global.Boolean;
...@@ -39,6 +40,7 @@ var StringSubstring; ...@@ -39,6 +40,7 @@ var StringSubstring;
utils.Import(function(from) { utils.Import(function(from) {
ArrayIndexOf = from.ArrayIndexOf; ArrayIndexOf = from.ArrayIndexOf;
ArrayJoin = from.ArrayJoin; ArrayJoin = from.ArrayJoin;
ArrayPush = from.ArrayPush;
IsFinite = from.IsFinite; IsFinite = from.IsFinite;
IsNaN = from.IsNaN; IsNaN = from.IsNaN;
MathFloor = from.MathFloor; MathFloor = from.MathFloor;
...@@ -298,7 +300,7 @@ function lookupSupportedLocalesOf(requestedLocales, availableLocales) { ...@@ -298,7 +300,7 @@ function lookupSupportedLocalesOf(requestedLocales, availableLocales) {
do { do {
if (!IS_UNDEFINED(availableLocales[locale])) { if (!IS_UNDEFINED(availableLocales[locale])) {
// Push requested locale not the resolved one. // Push requested locale not the resolved one.
%_CallFunction(matchedLocales, requestedLocales[i], $arrayPush); %_CallFunction(matchedLocales, requestedLocales[i], ArrayPush);
break; break;
} }
// Truncate locale if possible, if not break. // Truncate locale if possible, if not break.
...@@ -715,7 +717,7 @@ function initializeLocaleList(locales) { ...@@ -715,7 +717,7 @@ function initializeLocaleList(locales) {
} else { } else {
// We allow single string localeID. // We allow single string localeID.
if (typeof locales === 'string') { if (typeof locales === 'string') {
%_CallFunction(seen, canonicalizeLanguageTag(locales), $arrayPush); %_CallFunction(seen, canonicalizeLanguageTag(locales), ArrayPush);
return freezeArray(seen); return freezeArray(seen);
} }
...@@ -729,7 +731,7 @@ function initializeLocaleList(locales) { ...@@ -729,7 +731,7 @@ function initializeLocaleList(locales) {
var tag = canonicalizeLanguageTag(value); var tag = canonicalizeLanguageTag(value);
if (%_CallFunction(seen, tag, ArrayIndexOf) === -1) { if (%_CallFunction(seen, tag, ArrayIndexOf) === -1) {
%_CallFunction(seen, tag, $arrayPush); %_CallFunction(seen, tag, ArrayPush);
} }
} }
} }
...@@ -775,7 +777,7 @@ function isValidLanguageTag(locale) { ...@@ -775,7 +777,7 @@ function isValidLanguageTag(locale) {
if (%_CallFunction(GetLanguageVariantRE(), value, RegExpTest) && if (%_CallFunction(GetLanguageVariantRE(), value, RegExpTest) &&
extensions.length === 0) { extensions.length === 0) {
if (%_CallFunction(variants, value, ArrayIndexOf) === -1) { if (%_CallFunction(variants, value, ArrayIndexOf) === -1) {
%_CallFunction(variants, value, $arrayPush); %_CallFunction(variants, value, ArrayPush);
} else { } else {
return false; return false;
} }
...@@ -783,7 +785,7 @@ function isValidLanguageTag(locale) { ...@@ -783,7 +785,7 @@ function isValidLanguageTag(locale) {
if (%_CallFunction(GetLanguageSingletonRE(), value, RegExpTest)) { if (%_CallFunction(GetLanguageSingletonRE(), value, RegExpTest)) {
if (%_CallFunction(extensions, value, ArrayIndexOf) === -1) { if (%_CallFunction(extensions, value, ArrayIndexOf) === -1) {
%_CallFunction(extensions, value, $arrayPush); %_CallFunction(extensions, value, ArrayPush);
} else { } else {
return false; return false;
} }
......
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