Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Unified Diff: src/js/array.js

Issue 1879053003: Replace DefineIndexedProperty with %CreateDataProperty (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/js/regexp.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/array.js
diff --git a/src/js/array.js b/src/js/array.js
index 1406df336d03825cb8dac8f47abd0abd2f058323..b65167ebde1275992a86ec34520898e51b11db8c 100644
--- a/src/js/array.js
+++ b/src/js/array.js
@@ -11,7 +11,6 @@
// -------------------------------------------------------------------
// Imports
-var AddIndexedProperty;
var FLAG_harmony_species;
var GetIterator;
var GetMethod;
@@ -31,7 +30,6 @@ var iteratorSymbol = utils.ImportNow("iterator_symbol");
var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
utils.Import(function(from) {
- AddIndexedProperty = from.AddIndexedProperty;
GetIterator = from.GetIterator;
GetMethod = from.GetMethod;
MakeTypeError = from.MakeTypeError;
@@ -62,17 +60,6 @@ function ArraySpeciesCreate(array, length) {
}
-function DefineIndexedProperty(array, i, value) {
- if (FLAG_harmony_species) {
- var result = ObjectDefineProperty(array, i, {
- value: value, writable: true, configurable: true, enumerable: true
- });
- if (!result) throw MakeTypeError(kStrictCannotAssign, i);
- } else {
- AddIndexedProperty(array, i, value);
- }
-}
-
function KeySortCompare(a, b) {
return a - b;
}
@@ -265,7 +252,7 @@ function SparseSlice(array, start_i, del_count, len, deleted_elements) {
for (var i = start_i; i < limit; ++i) {
var current = array[i];
if (!IS_UNDEFINED(current) || i in array) {
- DefineIndexedProperty(deleted_elements, i - start_i, current);
+ %CreateDataProperty(deleted_elements, i - start_i, current);
}
}
} else {
@@ -275,7 +262,7 @@ function SparseSlice(array, start_i, del_count, len, deleted_elements) {
if (key >= start_i) {
var current = array[key];
if (!IS_UNDEFINED(current) || key in array) {
- DefineIndexedProperty(deleted_elements, key - start_i, current);
+ %CreateDataProperty(deleted_elements, key - start_i, current);
}
}
}
@@ -352,7 +339,7 @@ function SimpleSlice(array, start_i, del_count, len, deleted_elements) {
var index = start_i + i;
if (HAS_INDEX(array, index, is_array)) {
var current = array[index];
- DefineIndexedProperty(deleted_elements, i, current);
+ %CreateDataProperty(deleted_elements, i, current);
}
}
}
@@ -1211,7 +1198,7 @@ function InnerArrayFilter(f, receiver, array, length, result) {
if (HAS_INDEX(array, i, is_array)) {
var element = array[i];
if (%_Call(f, receiver, element, i, array)) {
- DefineIndexedProperty(result, result_length, element);
+ %CreateDataProperty(result, result_length, element);
result_length++;
}
}
@@ -1331,7 +1318,7 @@ function ArrayMap(f, receiver) {
for (var i = 0; i < length; i++) {
if (HAS_INDEX(array, i, is_array)) {
var element = array[i];
- DefineIndexedProperty(result, i, %_Call(f, receiver, element, i, array));
+ %CreateDataProperty(result, i, %_Call(f, receiver, element, i, array));
}
}
return result;
@@ -1736,17 +1723,6 @@ function ArrayIncludes(searchElement, fromIndex) {
}
-function AddArrayElement(constructor, array, i, value) {
- if (constructor === GlobalArray) {
- AddIndexedProperty(array, i, value);
- } else {
- ObjectDefineProperty(array, i, {
- value: value, writable: true, configurable: true, enumerable: true
- });
- }
-}
-
-
// ES6, draft 10-14-14, section 22.1.2.1
function ArrayFrom(arrayLike, mapfn, receiver) {
var items = TO_OBJECT(arrayLike);
@@ -1775,7 +1751,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
} else {
mappedValue = nextValue;
}
- AddArrayElement(this, result, k, mappedValue);
+ %CreateDataProperty(result, k, mappedValue);
k++;
}
result.length = k;
@@ -1791,7 +1767,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
} else {
mappedValue = nextValue;
}
- AddArrayElement(this, result, k, mappedValue);
+ %CreateDataProperty(result, k, mappedValue);
}
result.length = k;
@@ -1807,7 +1783,7 @@ function ArrayOf(...args) {
// TODO: Implement IsConstructor (ES6 section 7.2.5)
var array = %IsConstructor(constructor) ? new constructor(length) : [];
for (var i = 0; i < length; i++) {
- AddArrayElement(constructor, array, i, args[i]);
+ %CreateDataProperty(array, i, args[i]);
}
array.length = length;
return array;
« no previous file with comments | « no previous file | src/js/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698