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 @@ ...@@ -11,7 +11,6 @@
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
var AddIndexedProperty;
var FLAG_harmony_species; var FLAG_harmony_species;
var GetIterator; var GetIterator;
var GetMethod; var GetMethod;
...@@ -31,7 +30,6 @@ var iteratorSymbol = utils.ImportNow("iterator_symbol"); ...@@ -31,7 +30,6 @@ var iteratorSymbol = utils.ImportNow("iterator_symbol");
var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
utils.Import(function(from) { utils.Import(function(from) {
AddIndexedProperty = from.AddIndexedProperty;
GetIterator = from.GetIterator; GetIterator = from.GetIterator;
GetMethod = from.GetMethod; GetMethod = from.GetMethod;
MakeTypeError = from.MakeTypeError; MakeTypeError = from.MakeTypeError;
...@@ -62,17 +60,6 @@ function ArraySpeciesCreate(array, length) { ...@@ -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) { function KeySortCompare(a, b) {
return a - b; return a - b;
} }
...@@ -265,7 +252,7 @@ function SparseSlice(array, start_i, del_count, len, deleted_elements) { ...@@ -265,7 +252,7 @@ function SparseSlice(array, start_i, del_count, len, deleted_elements) {
for (var i = start_i; i < limit; ++i) { for (var i = start_i; i < limit; ++i) {
var current = array[i]; var current = array[i];
if (!IS_UNDEFINED(current) || i in array) { if (!IS_UNDEFINED(current) || i in array) {
DefineIndexedProperty(deleted_elements, i - start_i, current); %CreateDataProperty(deleted_elements, i - start_i, current);
} }
} }
} else { } else {
...@@ -275,7 +262,7 @@ function SparseSlice(array, start_i, del_count, len, deleted_elements) { ...@@ -275,7 +262,7 @@ function SparseSlice(array, start_i, del_count, len, deleted_elements) {
if (key >= start_i) { if (key >= start_i) {
var current = array[key]; var current = array[key];
if (!IS_UNDEFINED(current) || key in array) { 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) { ...@@ -352,7 +339,7 @@ function SimpleSlice(array, start_i, del_count, len, deleted_elements) {
var index = start_i + i; var index = start_i + i;
if (HAS_INDEX(array, index, is_array)) { if (HAS_INDEX(array, index, is_array)) {
var current = array[index]; 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) { ...@@ -1211,7 +1198,7 @@ function InnerArrayFilter(f, receiver, array, length, result) {
if (HAS_INDEX(array, i, is_array)) { if (HAS_INDEX(array, i, is_array)) {
var element = array[i]; var element = array[i];
if (%_Call(f, receiver, element, i, array)) { if (%_Call(f, receiver, element, i, array)) {
DefineIndexedProperty(result, result_length, element); %CreateDataProperty(result, result_length, element);
result_length++; result_length++;
} }
} }
...@@ -1331,7 +1318,7 @@ function ArrayMap(f, receiver) { ...@@ -1331,7 +1318,7 @@ function ArrayMap(f, receiver) {
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
if (HAS_INDEX(array, i, is_array)) { if (HAS_INDEX(array, i, is_array)) {
var element = array[i]; var element = array[i];
DefineIndexedProperty(result, i, %_Call(f, receiver, element, i, array)); %CreateDataProperty(result, i, %_Call(f, receiver, element, i, array));
} }
} }
return result; return result;
...@@ -1736,17 +1723,6 @@ function ArrayIncludes(searchElement, fromIndex) { ...@@ -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 // ES6, draft 10-14-14, section 22.1.2.1
function ArrayFrom(arrayLike, mapfn, receiver) { function ArrayFrom(arrayLike, mapfn, receiver) {
var items = TO_OBJECT(arrayLike); var items = TO_OBJECT(arrayLike);
...@@ -1775,7 +1751,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) { ...@@ -1775,7 +1751,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
} else { } else {
mappedValue = nextValue; mappedValue = nextValue;
} }
AddArrayElement(this, result, k, mappedValue); %CreateDataProperty(result, k, mappedValue);
k++; k++;
} }
result.length = k; result.length = k;
...@@ -1791,7 +1767,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) { ...@@ -1791,7 +1767,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
} else { } else {
mappedValue = nextValue; mappedValue = nextValue;
} }
AddArrayElement(this, result, k, mappedValue); %CreateDataProperty(result, k, mappedValue);
} }
result.length = k; result.length = k;
...@@ -1807,7 +1783,7 @@ function ArrayOf(...args) { ...@@ -1807,7 +1783,7 @@ function ArrayOf(...args) {
// TODO: Implement IsConstructor (ES6 section 7.2.5) // TODO: Implement IsConstructor (ES6 section 7.2.5)
var array = %IsConstructor(constructor) ? new constructor(length) : []; var array = %IsConstructor(constructor) ? new constructor(length) : [];
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
AddArrayElement(constructor, array, i, args[i]); %CreateDataProperty(array, i, args[i]);
} }
array.length = length; array.length = length;
return array; return array;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
var AddIndexedProperty;
var ExpandReplacement; var ExpandReplacement;
var GlobalArray = global.Array; var GlobalArray = global.Array;
var GlobalObject = global.Object; var GlobalObject = global.Object;
...@@ -29,7 +28,6 @@ var splitSymbol = utils.ImportNow("split_symbol"); ...@@ -29,7 +28,6 @@ var splitSymbol = utils.ImportNow("split_symbol");
var SpeciesConstructor; var SpeciesConstructor;
utils.Import(function(from) { utils.Import(function(from) {
AddIndexedProperty = from.AddIndexedProperty;
ExpandReplacement = from.ExpandReplacement; ExpandReplacement = from.ExpandReplacement;
MakeTypeError = from.MakeTypeError; MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple; MaxSimple = from.MaxSimple;
...@@ -502,7 +500,7 @@ function RegExpSubclassSplit(string, limit) { ...@@ -502,7 +500,7 @@ function RegExpSubclassSplit(string, limit) {
var result; var result;
if (size === 0) { if (size === 0) {
result = RegExpSubclassExec(splitter, string); result = RegExpSubclassExec(splitter, string);
if (IS_NULL(result)) AddIndexedProperty(array, 0, string); if (IS_NULL(result)) %AddElement(array, 0, string);
return array; return array;
} }
var stringIndex = prevStringIndex; var stringIndex = prevStringIndex;
...@@ -518,7 +516,7 @@ function RegExpSubclassSplit(string, limit) { ...@@ -518,7 +516,7 @@ function RegExpSubclassSplit(string, limit) {
if (end === stringIndex) { if (end === stringIndex) {
stringIndex += AdvanceStringIndex(string, stringIndex, unicode); stringIndex += AdvanceStringIndex(string, stringIndex, unicode);
} else { } else {
AddIndexedProperty( %AddElement(
array, arrayIndex, array, arrayIndex,
%_SubString(string, prevStringIndex, stringIndex)); %_SubString(string, prevStringIndex, stringIndex));
arrayIndex++; arrayIndex++;
...@@ -526,7 +524,7 @@ function RegExpSubclassSplit(string, limit) { ...@@ -526,7 +524,7 @@ function RegExpSubclassSplit(string, limit) {
prevStringIndex = end; prevStringIndex = end;
var numberOfCaptures = MaxSimple(TO_LENGTH(result.length), 0); var numberOfCaptures = MaxSimple(TO_LENGTH(result.length), 0);
for (var i = 1; i < numberOfCaptures; i++) { for (var i = 1; i < numberOfCaptures; i++) {
AddIndexedProperty(array, arrayIndex, result[i]); %AddElement(array, arrayIndex, result[i]);
arrayIndex++; arrayIndex++;
if (arrayIndex === lim) return array; if (arrayIndex === lim) return array;
} }
...@@ -534,7 +532,7 @@ function RegExpSubclassSplit(string, limit) { ...@@ -534,7 +532,7 @@ function RegExpSubclassSplit(string, limit) {
} }
} }
} }
AddIndexedProperty(array, arrayIndex, %AddElement(array, arrayIndex,
%_SubString(string, prevStringIndex, size)); %_SubString(string, prevStringIndex, size));
return array; return array;
} }
......
...@@ -43,19 +43,6 @@ utils.ImportFromExperimental(function(from) { ...@@ -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) { function ToPositiveInteger(x, rangeErrorIndex) {
var i = TO_INTEGER_MAP_MINUS_ZERO(x); var i = TO_INTEGER_MAP_MINUS_ZERO(x);
if (i < 0) throw MakeRangeError(rangeErrorIndex); if (i < 0) throw MakeRangeError(rangeErrorIndex);
...@@ -122,7 +109,6 @@ function SpeciesConstructor(object, defaultConstructor, conservative) { ...@@ -122,7 +109,6 @@ function SpeciesConstructor(object, defaultConstructor, conservative) {
// Exports // Exports
utils.Export(function(to) { utils.Export(function(to) {
to.AddIndexedProperty = AddIndexedProperty;
to.MaxSimple = MaxSimple; to.MaxSimple = MaxSimple;
to.MinSimple = MinSimple; to.MinSimple = MinSimple;
to.ToPositiveInteger = ToPositiveInteger; to.ToPositiveInteger = ToPositiveInteger;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
var AddIndexedProperty;
// array.js has to come before typedarray.js for this to work // array.js has to come before typedarray.js for this to work
var ArrayToString = utils.ImportNow("ArrayToString"); var ArrayToString = utils.ImportNow("ArrayToString");
var ArrayValues; var ArrayValues;
...@@ -71,7 +70,6 @@ endmacro ...@@ -71,7 +70,6 @@ endmacro
TYPED_ARRAYS(DECLARE_GLOBALS) TYPED_ARRAYS(DECLARE_GLOBALS)
utils.Import(function(from) { utils.Import(function(from) {
AddIndexedProperty = from.AddIndexedProperty;
ArrayValues = from.ArrayValues; ArrayValues = from.ArrayValues;
GetIterator = from.GetIterator; GetIterator = from.GetIterator;
GetMethod = from.GetMethod; GetMethod = from.GetMethod;
......
...@@ -1238,6 +1238,21 @@ RUNTIME_FUNCTION(Runtime_ObjectDefineProperty) { ...@@ -1238,6 +1238,21 @@ RUNTIME_FUNCTION(Runtime_ObjectDefineProperty) {
return JSReceiver::DefineProperty(isolate, o, name, attributes); 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) { RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) {
HandleScope scope(isolate); HandleScope scope(isolate);
......
...@@ -438,7 +438,8 @@ namespace internal { ...@@ -438,7 +438,8 @@ namespace internal {
F(CreateIterResultObject, 2, 1) \ F(CreateIterResultObject, 2, 1) \
F(IsAccessCheckNeeded, 1, 1) \ F(IsAccessCheckNeeded, 1, 1) \
F(ObjectDefineProperties, 2, 1) \ F(ObjectDefineProperties, 2, 1) \
F(ObjectDefineProperty, 3, 1) F(ObjectDefineProperty, 3, 1) \
F(CreateDataProperty, 3, 1)
#define FOR_EACH_INTRINSIC_OBSERVE(F) \ #define FOR_EACH_INTRINSIC_OBSERVE(F) \
F(IsObserved, 1, 1) \ 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