Commit a915f5bf authored by verwaest's avatar verwaest Committed by Commit bot

Replace DefineIndexedProperty with %CreateDataProperty

This should bring back the performance of speedometer-backbone at least very close to the performance before @@species.

BUG=chromium:596825
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#35468}
parent 53bc649e
......@@ -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;
......
......@@ -11,7 +11,6 @@
// -------------------------------------------------------------------
// Imports
var AddIndexedProperty;
var ExpandReplacement;
var GlobalArray = global.Array;
var GlobalObject = global.Object;
......@@ -29,7 +28,6 @@ var splitSymbol = utils.ImportNow("split_symbol");
var SpeciesConstructor;
utils.Import(function(from) {
AddIndexedProperty = from.AddIndexedProperty;
ExpandReplacement = from.ExpandReplacement;
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
......@@ -502,7 +500,7 @@ function RegExpSubclassSplit(string, limit) {
var result;
if (size === 0) {
result = RegExpSubclassExec(splitter, string);
if (IS_NULL(result)) AddIndexedProperty(array, 0, string);
if (IS_NULL(result)) %AddElement(array, 0, string);
return array;
}
var stringIndex = prevStringIndex;
......@@ -518,7 +516,7 @@ function RegExpSubclassSplit(string, limit) {
if (end === stringIndex) {
stringIndex += AdvanceStringIndex(string, stringIndex, unicode);
} else {
AddIndexedProperty(
%AddElement(
array, arrayIndex,
%_SubString(string, prevStringIndex, stringIndex));
arrayIndex++;
......@@ -526,7 +524,7 @@ function RegExpSubclassSplit(string, limit) {
prevStringIndex = end;
var numberOfCaptures = MaxSimple(TO_LENGTH(result.length), 0);
for (var i = 1; i < numberOfCaptures; i++) {
AddIndexedProperty(array, arrayIndex, result[i]);
%AddElement(array, arrayIndex, result[i]);
arrayIndex++;
if (arrayIndex === lim) return array;
}
......@@ -534,7 +532,7 @@ function RegExpSubclassSplit(string, limit) {
}
}
}
AddIndexedProperty(array, arrayIndex,
%AddElement(array, arrayIndex,
%_SubString(string, prevStringIndex, size));
return array;
}
......
......@@ -43,19 +43,6 @@ utils.ImportFromExperimental(function(from) {
*/
// This function should be called rather than %AddElement in contexts where the
// argument might not be less than 2**32-1. ES2015 ToLength semantics mean that
// this is a concern at basically all callsites.
function AddIndexedProperty(obj, index, value) {
if (index === TO_UINT32(index) && index !== kMaxUint32) {
%AddElement(obj, index, value);
} else {
%AddNamedProperty(obj, TO_STRING(index), value, NONE);
}
}
%SetForceInlineFlag(AddIndexedProperty);
function ToPositiveInteger(x, rangeErrorIndex) {
var i = TO_INTEGER_MAP_MINUS_ZERO(x);
if (i < 0) throw MakeRangeError(rangeErrorIndex);
......@@ -122,7 +109,6 @@ function SpeciesConstructor(object, defaultConstructor, conservative) {
// Exports
utils.Export(function(to) {
to.AddIndexedProperty = AddIndexedProperty;
to.MaxSimple = MaxSimple;
to.MinSimple = MinSimple;
to.ToPositiveInteger = ToPositiveInteger;
......
......@@ -11,7 +11,6 @@
// -------------------------------------------------------------------
// Imports
var AddIndexedProperty;
// array.js has to come before typedarray.js for this to work
var ArrayToString = utils.ImportNow("ArrayToString");
var ArrayValues;
......@@ -71,7 +70,6 @@ endmacro
TYPED_ARRAYS(DECLARE_GLOBALS)
utils.Import(function(from) {
AddIndexedProperty = from.AddIndexedProperty;
ArrayValues = from.ArrayValues;
GetIterator = from.GetIterator;
GetMethod = from.GetMethod;
......
......@@ -1238,6 +1238,21 @@ RUNTIME_FUNCTION(Runtime_ObjectDefineProperty) {
return JSReceiver::DefineProperty(isolate, o, name, attributes);
}
RUNTIME_FUNCTION(Runtime_CreateDataProperty) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, o, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
bool success;
LookupIterator it = LookupIterator::PropertyOrElement(
isolate, o, key, &success, LookupIterator::HIDDEN);
if (!success) return isolate->heap()->exception();
MAYBE_RETURN(
JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR),
isolate->heap()->exception());
return *value;
}
RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) {
HandleScope scope(isolate);
......
......@@ -438,7 +438,8 @@ namespace internal {
F(CreateIterResultObject, 2, 1) \
F(IsAccessCheckNeeded, 1, 1) \
F(ObjectDefineProperties, 2, 1) \
F(ObjectDefineProperty, 3, 1)
F(ObjectDefineProperty, 3, 1) \
F(CreateDataProperty, 3, 1)
#define FOR_EACH_INTRINSIC_OBSERVE(F) \
F(IsObserved, 1, 1) \
......
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