Revert "Revert "Upgrade to 5.0.71.48"" DO NOT MERGE
This reverts commit f2e3994fa5148cc3d9946666f0b0596290192b0e,
and updates the x64 makefile properly so it doesn't break that
build.
FPIIM-449
Change-Id: Ib83e35bfbae6af627451c926a9650ec57c045605
(cherry picked from commit 109988c7ccb6f3fd1a58574fa3dfb88beaef6632)
diff --git a/src/js/array.js b/src/js/array.js
index f9cf161..0a5e283 100644
--- a/src/js/array.js
+++ b/src/js/array.js
@@ -12,7 +12,6 @@
// Imports
var AddIndexedProperty;
-var FLAG_harmony_tolength;
var FLAG_harmony_species;
var GetIterator;
var GetMethod;
@@ -28,7 +27,6 @@
var ObserveBeginPerformSplice;
var ObserveEndPerformSplice;
var ObserveEnqueueSpliceRecord;
-var SameValueZero;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
@@ -44,11 +42,9 @@
ObserveBeginPerformSplice = from.ObserveBeginPerformSplice;
ObserveEndPerformSplice = from.ObserveEndPerformSplice;
ObserveEnqueueSpliceRecord = from.ObserveEnqueueSpliceRecord;
- SameValueZero = from.SameValueZero;
});
utils.ImportFromExperimental(function(from) {
- FLAG_harmony_tolength = from.FLAG_harmony_tolength;
FLAG_harmony_species = from.FLAG_harmony_species;
});
@@ -213,8 +209,6 @@
elements[elements_length++] = e;
}
elements.length = elements_length;
- var result = %_FastOneByteArrayJoin(elements, '');
- if (!IS_UNDEFINED(result)) return result;
return %StringBuilderConcat(elements, elements_length, '');
}
// Non-empty separator case.
@@ -237,9 +231,6 @@
elements[i] = e;
}
}
- var result = %_FastOneByteArrayJoin(elements, separator);
- if (!IS_UNDEFINED(result)) return result;
-
return %StringBuilderJoin(elements, length, separator);
} finally {
// Make sure to remove the last element of the visited array no
@@ -431,7 +422,7 @@
function InnerArrayToLocaleString(array, length) {
- var len = TO_LENGTH_OR_UINT32(length);
+ var len = TO_LENGTH(length);
if (len === 0) return "";
return Join(array, len, ',', ConvertToLocaleString);
}
@@ -451,9 +442,6 @@
separator = TO_STRING(separator);
}
- var result = %_FastOneByteArrayJoin(array, separator);
- if (!IS_UNDEFINED(result)) return result;
-
// Fast case for one-element arrays.
if (length === 1) {
var e = array[0];
@@ -469,7 +457,7 @@
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.join");
var array = TO_OBJECT(this);
- var length = TO_LENGTH_OR_UINT32(array.length);
+ var length = TO_LENGTH(array.length);
return InnerArrayJoin(separator, array, length);
}
@@ -498,7 +486,7 @@
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.pop");
var array = TO_OBJECT(this);
- var n = TO_LENGTH_OR_UINT32(array.length);
+ var n = TO_LENGTH(array.length);
if (n == 0) {
array.length = n;
return;
@@ -516,13 +504,13 @@
function ObservedArrayPush() {
- var n = TO_LENGTH_OR_UINT32(this.length);
- var m = %_ArgumentsLength();
+ var n = TO_LENGTH(this.length);
+ var m = arguments.length;
try {
ObserveBeginPerformSplice(this);
for (var i = 0; i < m; i++) {
- this[i+n] = %_Arguments(i);
+ this[i+n] = arguments[i];
}
var new_length = n + m;
this.length = new_length;
@@ -544,8 +532,8 @@
return ObservedArrayPush.apply(this, arguments);
var array = TO_OBJECT(this);
- var n = TO_LENGTH_OR_UINT32(array.length);
- var m = %_ArgumentsLength();
+ var n = TO_LENGTH(array.length);
+ var m = arguments.length;
// It appears that there is no enforced, absolute limit on the number of
// arguments, but it would surely blow the stack to use 2**30 or more.
@@ -557,7 +545,7 @@
}
for (var i = 0; i < m; i++) {
- array[i+n] = %_Arguments(i);
+ array[i+n] = arguments[i];
}
var new_length = n + m;
@@ -650,7 +638,7 @@
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reverse");
var array = TO_OBJECT(this);
- var len = TO_LENGTH_OR_UINT32(array.length);
+ var len = TO_LENGTH(array.length);
var isArray = IS_ARRAY(array);
if (UseSparseVariant(array, len, isArray, len)) {
@@ -685,7 +673,7 @@
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.shift");
var array = TO_OBJECT(this);
- var len = TO_LENGTH_OR_UINT32(array.length);
+ var len = TO_LENGTH(array.length);
if (len === 0) {
array.length = 0;
@@ -712,14 +700,14 @@
function ObservedArrayUnshift() {
- var len = TO_LENGTH_OR_UINT32(this.length);
- var num_arguments = %_ArgumentsLength();
+ var len = TO_LENGTH(this.length);
+ var num_arguments = arguments.length;
try {
ObserveBeginPerformSplice(this);
SimpleMove(this, 0, 0, len, num_arguments);
for (var i = 0; i < num_arguments; i++) {
- this[i] = %_Arguments(i);
+ this[i] = arguments[i];
}
var new_length = len + num_arguments;
this.length = new_length;
@@ -739,8 +727,8 @@
return ObservedArrayUnshift.apply(this, arguments);
var array = TO_OBJECT(this);
- var len = TO_LENGTH_OR_UINT32(array.length);
- var num_arguments = %_ArgumentsLength();
+ var len = TO_LENGTH(array.length);
+ var num_arguments = arguments.length;
if (len > 0 && UseSparseVariant(array, len, IS_ARRAY(array), len) &&
!%object_is_sealed(array)) {
@@ -750,7 +738,7 @@
}
for (var i = 0; i < num_arguments; i++) {
- array[i] = %_Arguments(i);
+ array[i] = arguments[i];
}
var new_length = len + num_arguments;
@@ -763,7 +751,7 @@
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.slice");
var array = TO_OBJECT(this);
- var len = TO_LENGTH_OR_UINT32(array.length);
+ var len = TO_LENGTH(array.length);
var start_i = TO_INTEGER(start);
var end_i = len;
@@ -833,8 +821,8 @@
function ObservedArraySplice(start, delete_count) {
- var num_arguments = %_ArgumentsLength();
- var len = TO_LENGTH_OR_UINT32(this.length);
+ var num_arguments = arguments.length;
+ var len = TO_LENGTH(this.length);
var start_i = ComputeSpliceStartIndex(TO_INTEGER(start), len);
var del_count = ComputeSpliceDeleteCount(delete_count, num_arguments, len,
start_i);
@@ -852,9 +840,9 @@
// place of the deleted elements.
var i = start_i;
var arguments_index = 2;
- var arguments_length = %_ArgumentsLength();
+ var arguments_length = arguments.length;
while (arguments_index < arguments_length) {
- this[i++] = %_Arguments(arguments_index++);
+ this[i++] = arguments[arguments_index++];
}
this.length = len - del_count + num_elements_to_add;
@@ -879,9 +867,9 @@
if (%IsObserved(this))
return ObservedArraySplice.apply(this, arguments);
- var num_arguments = %_ArgumentsLength();
+ var num_arguments = arguments.length;
var array = TO_OBJECT(this);
- var len = TO_LENGTH_OR_UINT32(array.length);
+ var len = TO_LENGTH(array.length);
var start_i = ComputeSpliceStartIndex(TO_INTEGER(start), len);
var del_count = ComputeSpliceDeleteCount(delete_count, num_arguments, len,
start_i);
@@ -915,9 +903,9 @@
// place of the deleted elements.
var i = start_i;
var arguments_index = 2;
- var arguments_length = %_ArgumentsLength();
+ var arguments_length = arguments.length;
while (arguments_index < arguments_length) {
- array[i++] = %_Arguments(arguments_index++);
+ array[i++] = arguments[arguments_index++];
}
array.length = len - del_count + num_elements_to_add;
@@ -1068,7 +1056,7 @@
var CopyFromPrototype = function CopyFromPrototype(obj, length) {
var max = 0;
for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto)) {
- var indices = %GetArrayKeys(proto, length);
+ var indices = IS_PROXY(proto) ? length : %GetArrayKeys(proto, length);
if (IS_NUMBER(indices)) {
// It's an interval.
var proto_length = indices;
@@ -1097,7 +1085,7 @@
// elements in that range.
var ShadowPrototypeElements = function(obj, from, to) {
for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto)) {
- var indices = %GetArrayKeys(proto, to);
+ var indices = IS_PROXY(proto) ? to : %GetArrayKeys(proto, to);
if (IS_NUMBER(indices)) {
// It's an interval.
var proto_length = indices;
@@ -1217,7 +1205,7 @@
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.sort");
var array = TO_OBJECT(this);
- var length = TO_LENGTH_OR_UINT32(array.length);
+ var length = TO_LENGTH(array.length);
return InnerArraySort(array, length, comparefn);
}
@@ -1248,7 +1236,7 @@
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = TO_OBJECT(this);
- var length = TO_LENGTH_OR_UINT32(array.length);
+ var length = TO_LENGTH(array.length);
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
var result = ArraySpeciesCreate(array, 0);
return InnerArrayFilter(f, receiver, array, length, result);
@@ -1274,7 +1262,7 @@
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = TO_OBJECT(this);
- var length = TO_LENGTH_OR_UINT32(array.length);
+ var length = TO_LENGTH(array.length);
InnerArrayForEach(f, receiver, array, length);
}
@@ -1301,7 +1289,7 @@
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = TO_OBJECT(this);
- var length = TO_LENGTH_OR_UINT32(array.length);
+ var length = TO_LENGTH(array.length);
return InnerArraySome(f, receiver, array, length);
}
@@ -1325,7 +1313,7 @@
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = TO_OBJECT(this);
- var length = TO_LENGTH_OR_UINT32(array.length);
+ var length = TO_LENGTH(array.length);
return InnerArrayEvery(f, receiver, array, length);
}
@@ -1336,7 +1324,7 @@
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = TO_OBJECT(this);
- var length = TO_LENGTH_OR_UINT32(array.length);
+ var length = TO_LENGTH(array.length);
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
var result = ArraySpeciesCreate(array, length);
var is_array = IS_ARRAY(array);
@@ -1411,7 +1399,7 @@
function ArrayIndexOf(element, index) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.indexOf");
- var length = TO_LENGTH_OR_UINT32(this.length);
+ var length = TO_LENGTH(this.length);
return InnerArrayIndexOf(this, element, index, length);
}
@@ -1469,9 +1457,9 @@
function ArrayLastIndexOf(element, index) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.lastIndexOf");
- var length = TO_LENGTH_OR_UINT32(this.length);
+ var length = TO_LENGTH(this.length);
return InnerArrayLastIndexOf(this, element, index, length,
- %_ArgumentsLength());
+ arguments.length);
}
@@ -1508,9 +1496,9 @@
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = TO_OBJECT(this);
- var length = TO_LENGTH_OR_UINT32(array.length);
+ var length = TO_LENGTH(array.length);
return InnerArrayReduce(callback, current, array, length,
- %_ArgumentsLength());
+ arguments.length);
}
@@ -1548,9 +1536,9 @@
// Pull out the length so that side effects are visible before the
// callback function is checked.
var array = TO_OBJECT(this);
- var length = TO_LENGTH_OR_UINT32(array.length);
+ var length = TO_LENGTH(array.length);
return InnerArrayReduceRight(callback, current, array, length,
- %_ArgumentsLength());
+ arguments.length);
}
@@ -1701,7 +1689,7 @@
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.fill");
var array = TO_OBJECT(this);
- var length = TO_LENGTH_OR_UINT32(array.length);
+ var length = TO_LENGTH(array.length);
return InnerArrayFill(value, start, end, array, length);
}
@@ -1726,7 +1714,7 @@
while (k < length) {
var elementK = array[k];
- if (SameValueZero(searchElement, elementK)) {
+ if (%SameValueZero(searchElement, elementK)) {
return true;
}
@@ -1778,23 +1766,10 @@
if (!IS_UNDEFINED(iterable)) {
result = %IsConstructor(this) ? new this() : [];
-
- var iterator = GetIterator(items, iterable);
-
k = 0;
- while (true) {
- var next = iterator.next();
- if (!IS_RECEIVER(next)) {
- throw MakeTypeError(kIteratorResultNotAnObject, next);
- }
-
- if (next.done) {
- result.length = k;
- return result;
- }
-
- nextValue = next.value;
+ for (nextValue of
+ { [iteratorSymbol]() { return GetIterator(items, iterable) } }) {
if (mapping) {
mappedValue = %_Call(mapfn, receiver, nextValue, k);
} else {
@@ -1803,6 +1778,8 @@
AddArrayElement(this, result, k, mappedValue);
k++;
}
+ result.length = k;
+ return result;
} else {
var len = TO_LENGTH(items.length);
result = %IsConstructor(this) ? new this(len) : new GlobalArray(len);
@@ -1824,13 +1801,13 @@
// ES6, draft 05-22-14, section 22.1.2.3
-function ArrayOf() {
- var length = %_ArgumentsLength();
+function ArrayOf(...args) {
+ var length = args.length;
var constructor = this;
// 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, %_Arguments(i));
+ AddArrayElement(constructor, array, i, args[i]);
}
array.length = length;
return array;
diff --git a/src/js/generator.js b/src/js/generator.js
index 7f43656..3dcdcc0 100644
--- a/src/js/generator.js
+++ b/src/js/generator.js
@@ -36,15 +36,31 @@
if (continuation > 0) {
// Generator is suspended.
DEBUG_PREPARE_STEP_IN_IF_STEPPING(this);
- try {
- return %_GeneratorNext(this, value);
- } catch (e) {
- %GeneratorClose(this);
- throw e;
- }
+ return %_GeneratorNext(this, value);
} else if (continuation == 0) {
// Generator is already closed.
- return { value: void 0, done: true };
+ return %_CreateIterResultObject(UNDEFINED, true);
+ } else {
+ // Generator is running.
+ throw MakeTypeError(kGeneratorRunning);
+ }
+}
+
+
+function GeneratorObjectReturn(value) {
+ if (!IS_GENERATOR(this)) {
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ '[Generator].prototype.return', this);
+ }
+
+ var continuation = %GeneratorGetContinuation(this);
+ if (continuation > 0) {
+ // Generator is suspended.
+ DEBUG_PREPARE_STEP_IN_IF_STEPPING(this);
+ return %_GeneratorReturn(this, value);
+ } else if (continuation == 0) {
+ // Generator is already closed.
+ return %_CreateIterResultObject(value, true);
} else {
// Generator is running.
throw MakeTypeError(kGeneratorRunning);
@@ -61,12 +77,8 @@
var continuation = %GeneratorGetContinuation(this);
if (continuation > 0) {
// Generator is suspended.
- try {
- return %_GeneratorThrow(this, exn);
- } catch (e) {
- %GeneratorClose(this);
- throw e;
- }
+ DEBUG_PREPARE_STEP_IN_IF_STEPPING(this);
+ return %_GeneratorThrow(this, exn);
} else if (continuation == 0) {
// Generator is already closed.
throw exn;
@@ -78,9 +90,11 @@
// ----------------------------------------------------------------------------
-// Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by
-// neither Crankshaft nor TurboFan, disable optimization of wrappers here.
+// None of the three resume operations (Runtime_GeneratorNext,
+// Runtime_GeneratorReturn, Runtime_GeneratorThrow) is supported by
+// Crankshaft or TurboFan. Disable optimization of wrappers here.
%NeverOptimizeFunction(GeneratorObjectNext);
+%NeverOptimizeFunction(GeneratorObjectReturn);
%NeverOptimizeFunction(GeneratorObjectThrow);
// Set up non-enumerable functions on the generator prototype object.
@@ -88,6 +102,7 @@
utils.InstallFunctions(GeneratorObjectPrototype,
DONT_ENUM,
["next", GeneratorObjectNext,
+ "return", GeneratorObjectReturn,
"throw", GeneratorObjectThrow]);
%AddNamedProperty(GeneratorObjectPrototype, "constructor",
diff --git a/src/js/harmony-reflect.js b/src/js/harmony-reflect.js
deleted file mode 100644
index dcadad5..0000000
--- a/src/js/harmony-reflect.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2013-2015 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.
-
-(function(global, utils) {
-
-'use strict';
-
-%CheckIsBootstrapping();
-
-// -------------------------------------------------------------------
-// Imports
-
-var GlobalReflect = global.Reflect;
-var MakeTypeError;
-var ReflectApply = utils.ImportNow("reflect_apply");
-var ReflectConstruct = utils.ImportNow("reflect_construct");
-
-utils.Import(function(from) {
- MakeTypeError = from.MakeTypeError;
-});
-
-// -------------------------------------------------------------------
-
-function ReflectEnumerate(obj) {
- if (!IS_RECEIVER(obj))
- throw MakeTypeError(kCalledOnNonObject, "Reflect.enumerate")
- return (function* () { for (var x in obj) yield x })();
-}
-
-utils.InstallFunctions(GlobalReflect, DONT_ENUM, [
- "apply", ReflectApply,
- "construct", ReflectConstruct,
- "enumerate", ReflectEnumerate
-]);
-
-})
diff --git a/src/js/i18n.js b/src/js/i18n.js
index 7e00fcd..7b2f5a1 100644
--- a/src/js/i18n.js
+++ b/src/js/i18n.js
@@ -232,8 +232,8 @@
// DateTimeFormat.format needs to be 0 arg method, but can stil
// receive optional dateValue param. If one was provided, pass it
// along.
- if (%_ArgumentsLength() > 0) {
- return implementation(that, %_Arguments(0));
+ if (arguments.length > 0) {
+ return implementation(that, arguments[0]);
} else {
return implementation(that);
}
@@ -1002,8 +1002,8 @@
* @constructor
*/
%AddNamedProperty(Intl, 'Collator', function() {
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
+ var locales = arguments[0];
+ var options = arguments[1];
if (!this || this === Intl) {
// Constructor is called as a function.
@@ -1060,7 +1060,7 @@
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
- return supportedLocalesOf('collator', locales, %_Arguments(1));
+ return supportedLocalesOf('collator', locales, arguments[1]);
},
DONT_ENUM
);
@@ -1255,8 +1255,8 @@
* @constructor
*/
%AddNamedProperty(Intl, 'NumberFormat', function() {
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
+ var locales = arguments[0];
+ var options = arguments[1];
if (!this || this === Intl) {
// Constructor is called as a function.
@@ -1332,7 +1332,7 @@
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
- return supportedLocalesOf('numberformat', locales, %_Arguments(1));
+ return supportedLocalesOf('numberformat', locales, arguments[1]);
},
DONT_ENUM
);
@@ -1659,8 +1659,8 @@
* @constructor
*/
%AddNamedProperty(Intl, 'DateTimeFormat', function() {
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
+ var locales = arguments[0];
+ var options = arguments[1];
if (!this || this === Intl) {
// Constructor is called as a function.
@@ -1755,7 +1755,7 @@
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
- return supportedLocalesOf('dateformat', locales, %_Arguments(1));
+ return supportedLocalesOf('dateformat', locales, arguments[1]);
},
DONT_ENUM
);
@@ -1886,8 +1886,8 @@
* @constructor
*/
%AddNamedProperty(Intl, 'v8BreakIterator', function() {
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
+ var locales = arguments[0];
+ var options = arguments[1];
if (!this || this === Intl) {
// Constructor is called as a function.
@@ -1943,7 +1943,7 @@
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
- return supportedLocalesOf('breakiterator', locales, %_Arguments(1));
+ return supportedLocalesOf('breakiterator', locales, arguments[1]);
},
DONT_ENUM
);
@@ -2061,8 +2061,8 @@
throw MakeTypeError(kMethodInvokedOnNullOrUndefined);
}
- var locales = %_Arguments(1);
- var options = %_Arguments(2);
+ var locales = arguments[1];
+ var options = arguments[2];
var collator = cachedOrNewService('collator', locales, options);
return compare(collator, this, that);
}
@@ -2085,7 +2085,7 @@
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
var s = TO_STRING(this);
- var formArg = %_Arguments(0);
+ var formArg = arguments[0];
var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg);
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
@@ -2114,8 +2114,8 @@
throw MakeTypeError(kMethodInvokedOnWrongType, "Number");
}
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
+ var locales = arguments[0];
+ var options = arguments[1];
var numberFormat = cachedOrNewService('numberformat', locales, options);
return formatNumber(numberFormat, this);
}
@@ -2151,8 +2151,8 @@
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
+ var locales = arguments[0];
+ var options = arguments[1];
return toLocaleDateTime(
this, locales, options, 'any', 'all', 'dateformatall');
}
@@ -2169,8 +2169,8 @@
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
+ var locales = arguments[0];
+ var options = arguments[1];
return toLocaleDateTime(
this, locales, options, 'date', 'date', 'dateformatdate');
}
@@ -2187,8 +2187,8 @@
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
+ var locales = arguments[0];
+ var options = arguments[1];
return toLocaleDateTime(
this, locales, options, 'time', 'time', 'dateformattime');
}
diff --git a/src/js/json.js b/src/js/json.js
index b8836ea..73d7802 100644
--- a/src/js/json.js
+++ b/src/js/json.js
@@ -187,7 +187,7 @@
function JSONStringify(value, replacer, space) {
- if (%_ArgumentsLength() == 1 && !IS_PROXY(value)) {
+ if (arguments.length === 1 && !IS_PROXY(value)) {
return %BasicJSONStringify(value);
}
if (!IS_CALLABLE(replacer) && %is_arraylike(replacer)) {
@@ -234,6 +234,9 @@
} else {
gap = "";
}
+ if (!IS_CALLABLE(replacer) && !property_list && !gap && !IS_PROXY(value)) {
+ return %BasicJSONStringify(value);
+ }
return JSONSerialize('', {'': value}, replacer, new InternalArray(), "", gap);
}
diff --git a/src/js/macros.py b/src/js/macros.py
index 3bcc8c1..b2a7856 100644
--- a/src/js/macros.py
+++ b/src/js/macros.py
@@ -67,9 +67,9 @@
macro IS_BOOLEAN(arg) = (typeof(arg) === 'boolean');
macro IS_BOOLEAN_WRAPPER(arg) = (%_ClassOf(arg) === 'Boolean');
macro IS_DATAVIEW(arg) = (%_ClassOf(arg) === 'DataView');
-macro IS_DATE(arg) = (%_IsDate(arg));
+macro IS_DATE(arg) = (%IsDate(arg));
macro IS_ERROR(arg) = (%_ClassOf(arg) === 'Error');
-macro IS_FUNCTION(arg) = (%_IsFunction(arg));
+macro IS_FUNCTION(arg) = (%IsFunction(arg));
macro IS_GENERATOR(arg) = (%_ClassOf(arg) === 'Generator');
macro IS_GLOBAL(arg) = (%_ClassOf(arg) === 'global');
macro IS_MAP(arg) = (%_ClassOf(arg) === 'Map');
@@ -85,7 +85,7 @@
macro IS_SET(arg) = (%_ClassOf(arg) === 'Set');
macro IS_SET_ITERATOR(arg) = (%_ClassOf(arg) === 'Set Iterator');
macro IS_SHAREDARRAYBUFFER(arg) = (%_ClassOf(arg) === 'SharedArrayBuffer');
-macro IS_SIMD_VALUE(arg) = (%_IsSimdValue(arg));
+macro IS_SIMD_VALUE(arg) = (%IsSimdValue(arg));
macro IS_STRING(arg) = (typeof(arg) === 'string');
macro IS_STRING_WRAPPER(arg) = (%_ClassOf(arg) === 'String');
macro IS_STRONG(arg) = (%IsStrong(arg));
@@ -114,8 +114,6 @@
macro TO_INT32(arg) = ((arg) | 0);
macro TO_UINT32(arg) = ((arg) >>> 0);
macro TO_LENGTH(arg) = (%_ToLength(arg));
-macro TO_LENGTH_OR_UINT32(arg) = (FLAG_harmony_tolength ? TO_LENGTH(arg) : TO_UINT32(arg));
-macro TO_LENGTH_OR_INTEGER(arg) = (FLAG_harmony_tolength ? TO_LENGTH(arg) : TO_INTEGER(arg));
macro TO_STRING(arg) = (%_ToString(arg));
macro TO_NUMBER(arg) = (%_ToNumber(arg));
macro TO_OBJECT(arg) = (%_ToObject(arg));
diff --git a/src/js/math.js b/src/js/math.js
index 990a7e9..a698fd4 100644
--- a/src/js/math.js
+++ b/src/js/math.js
@@ -75,60 +75,6 @@
return %_MathLogRT(TO_NUMBER(x));
}
-// ECMA 262 - 15.8.2.11
-function MathMax(arg1, arg2) { // length == 2
- var length = %_ArgumentsLength();
- if (length == 2) {
- arg1 = TO_NUMBER(arg1);
- arg2 = TO_NUMBER(arg2);
- if (arg2 > arg1) return arg2;
- if (arg1 > arg2) return arg1;
- if (arg1 == arg2) {
- // Make sure -0 is considered less than +0.
- return (arg1 === 0 && %_IsMinusZero(arg1)) ? arg2 : arg1;
- }
- // All comparisons failed, one of the arguments must be NaN.
- return NaN;
- }
- var r = -INFINITY;
- for (var i = 0; i < length; i++) {
- var n = %_Arguments(i);
- n = TO_NUMBER(n);
- // Make sure +0 is considered greater than -0.
- if (NUMBER_IS_NAN(n) || n > r || (r === 0 && n === 0 && %_IsMinusZero(r))) {
- r = n;
- }
- }
- return r;
-}
-
-// ECMA 262 - 15.8.2.12
-function MathMin(arg1, arg2) { // length == 2
- var length = %_ArgumentsLength();
- if (length == 2) {
- arg1 = TO_NUMBER(arg1);
- arg2 = TO_NUMBER(arg2);
- if (arg2 > arg1) return arg1;
- if (arg1 > arg2) return arg2;
- if (arg1 == arg2) {
- // Make sure -0 is considered less than +0.
- return (arg1 === 0 && %_IsMinusZero(arg1)) ? arg1 : arg2;
- }
- // All comparisons failed, one of the arguments must be NaN.
- return NaN;
- }
- var r = INFINITY;
- for (var i = 0; i < length; i++) {
- var n = %_Arguments(i);
- n = TO_NUMBER(n);
- // Make sure -0 is considered less than +0.
- if (NUMBER_IS_NAN(n) || n < r || (r === 0 && n === 0 && %_IsMinusZero(n))) {
- r = n;
- }
- }
- return r;
-}
-
// ECMA 262 - 15.8.2.13
function MathPowJS(x, y) {
return %_MathPow(TO_NUMBER(x), TO_NUMBER(y));
@@ -218,17 +164,14 @@
// We may want to introduce fast paths for two arguments and when
// normalization to avoid overflow is not necessary. For now, we
// simply assume the general case.
- var length = %_ArgumentsLength();
- var args = new InternalArray(length);
+ var length = arguments.length;
var max = 0;
for (var i = 0; i < length; i++) {
- var n = %_Arguments(i);
- n = TO_NUMBER(n);
- if (n === INFINITY || n === -INFINITY) return INFINITY;
- n = MathAbs(n);
+ var n = MathAbs(arguments[i]);
if (n > max) max = n;
- args[i] = n;
+ arguments[i] = n;
}
+ if (max === INFINITY) return INFINITY;
// Kahan summation to avoid rounding errors.
// Normalize the numbers to the largest one to avoid overflow.
@@ -236,7 +179,7 @@
var sum = 0;
var compensation = 0;
for (var i = 0; i < length; i++) {
- var n = args[i] / max;
+ var n = arguments[i] / max;
var summand = n * n - compensation;
var preliminary = sum + summand;
compensation = (preliminary - sum) - summand;
@@ -314,8 +257,6 @@
"sqrt", MathSqrtJS,
"atan2", MathAtan2JS,
"pow", MathPowJS,
- "max", MathMax,
- "min", MathMin,
"imul", MathImul,
"sign", MathSign,
"trunc", MathTrunc,
@@ -349,8 +290,6 @@
to.MathExp = MathExp;
to.MathFloor = MathFloorJS;
to.IntRandom = MathRandomRaw;
- to.MathMax = MathMax;
- to.MathMin = MathMin;
});
})
diff --git a/src/js/prologue.js b/src/js/prologue.js
index 2779393..24225a0 100644
--- a/src/js/prologue.js
+++ b/src/js/prologue.js
@@ -179,8 +179,6 @@
"MapEntries",
"MapIterator",
"MapIteratorNext",
- "MathMax",
- "MathMin",
"MaxSimple",
"MinSimple",
"ObjectDefineProperty",
@@ -189,7 +187,6 @@
"PromiseChain",
"PromiseDeferred",
"PromiseResolved",
- "SameValueZero",
"SetIterator",
"SetIteratorNext",
"SetValues",
diff --git a/src/js/proxy.js b/src/js/proxy.js
index 842bac0..a111c09 100644
--- a/src/js/proxy.js
+++ b/src/js/proxy.js
@@ -12,11 +12,6 @@
// Imports
//
var GlobalProxy = global.Proxy;
-var MakeTypeError;
-
-utils.Import(function(from) {
- MakeTypeError = from.MakeTypeError;
-});
//----------------------------------------------------------------------------
@@ -25,33 +20,6 @@
return {proxy: p, revoke: () => %JSProxyRevoke(p)};
}
-// -------------------------------------------------------------------
-// Proxy Builtins
-
-// Implements part of ES6 9.5.11 Proxy.[[Enumerate]]:
-// Call the trap, which should return an iterator, exhaust the iterator,
-// and return an array containing the values.
-function ProxyEnumerate(trap, handler, target) {
- // 7. Let trapResult be ? Call(trap, handler, «target»).
- var trap_result = %_Call(trap, handler, target);
- // 8. If Type(trapResult) is not Object, throw a TypeError exception.
- if (!IS_RECEIVER(trap_result)) {
- throw MakeTypeError(kProxyEnumerateNonObject);
- }
- // 9. Return trapResult.
- var result = [];
- for (var it = trap_result.next(); !it.done; it = trap_result.next()) {
- var key = it.value;
- // Not yet spec'ed as of 2015-11-25, but will be spec'ed soon:
- // If the iterator returns a non-string value, throw a TypeError.
- if (!IS_STRING(key)) {
- throw MakeTypeError(kProxyEnumerateNonString);
- }
- result.push(key);
- }
- return result;
-}
-
//-------------------------------------------------------------------
//Set up non-enumerable properties of the Proxy object.
@@ -59,11 +27,4 @@
"revocable", ProxyCreateRevocable
]);
-// -------------------------------------------------------------------
-// Exports
-
-%InstallToContext([
- "proxy_enumerate", ProxyEnumerate,
-]);
-
})
diff --git a/src/js/regexp.js b/src/js/regexp.js
index eeacd6e..e80d019 100644
--- a/src/js/regexp.js
+++ b/src/js/regexp.js
@@ -9,7 +9,7 @@
// -------------------------------------------------------------------
// Imports
-var FLAG_harmony_tolength;
+var ExpandReplacement;
var GlobalObject = global.Object;
var GlobalRegExp = global.RegExp;
var GlobalRegExpPrototype;
@@ -17,14 +17,12 @@
var InternalPackedArray = utils.InternalPackedArray;
var MakeTypeError;
var matchSymbol = utils.ImportNow("match_symbol");
+var replaceSymbol = utils.ImportNow("replace_symbol");
var searchSymbol = utils.ImportNow("search_symbol");
var splitSymbol = utils.ImportNow("split_symbol");
-utils.ImportFromExperimental(function(from) {
- FLAG_harmony_tolength = from.FLAG_harmony_tolength;
-});
-
utils.Import(function(from) {
+ ExpandReplacement = from.ExpandReplacement;
MakeTypeError = from.MakeTypeError;
});
@@ -176,7 +174,7 @@
// Conversion is required by the ES2015 specification (RegExpBuiltinExec
// algorithm, step 4) even if the value is discarded for non-global RegExps.
- var i = TO_LENGTH_OR_INTEGER(lastIndex);
+ var i = TO_LENGTH(lastIndex);
var updateLastIndex = REGEXP_GLOBAL(this) || REGEXP_STICKY(this);
if (updateLastIndex) {
@@ -223,7 +221,7 @@
// Conversion is required by the ES2015 specification (RegExpBuiltinExec
// algorithm, step 4) even if the value is discarded for non-global RegExps.
- var i = TO_LENGTH_OR_INTEGER(lastIndex);
+ var i = TO_LENGTH(lastIndex);
if (REGEXP_GLOBAL(this) || REGEXP_STICKY(this)) {
if (i < 0 || i > string.length) {
@@ -262,7 +260,7 @@
}
function TrimRegExp(regexp) {
- if (!%_ObjectEquals(regexp_key, regexp)) {
+ if (regexp_key !== regexp) {
regexp_key = regexp;
regexp_val =
new GlobalRegExp(
@@ -283,8 +281,11 @@
%IncrementUseCounter(kRegExpPrototypeToString);
return '/(?:)/';
}
- throw MakeTypeError(kIncompatibleMethodReceiver,
- 'RegExp.prototype.toString', this);
+ if (!IS_RECEIVER(this)) {
+ throw MakeTypeError(
+ kIncompatibleMethodReceiver, 'RegExp.prototype.toString', this);
+ }
+ return '/' + TO_STRING(this.source) + '/' + TO_STRING(this.flags);
}
var result = '/' + REGEXP_SOURCE(this) + '/';
if (REGEXP_GLOBAL(this)) result += 'g';
@@ -296,6 +297,15 @@
}
+function AtSurrogatePair(subject, index) {
+ if (index + 1 >= subject.length) return false;
+ var first = %_StringCharCodeAt(subject, index);
+ if (first < 0xD800 || first > 0xDBFF) return false;
+ var second = %_StringCharCodeAt(subject, index + 1);
+ return second >= 0xDC00 || second <= 0xDFFF;
+}
+
+
// ES6 21.2.5.11.
function RegExpSplit(string, limit) {
// TODO(yangguo): allow non-regexp receivers.
@@ -337,7 +347,11 @@
// We ignore a zero-length match at the currentIndex.
if (startIndex === endIndex && endIndex === currentIndex) {
- startIndex++;
+ if (REGEXP_UNICODE(this) && AtSurrogatePair(subject, startIndex)) {
+ startIndex += 2;
+ } else {
+ startIndex++;
+ }
continue;
}
@@ -382,6 +396,175 @@
}
+// ES6 21.2.5.8.
+
+// TODO(lrn): This array will survive indefinitely if replace is never
+// called again. However, it will be empty, since the contents are cleared
+// in the finally block.
+var reusableReplaceArray = new InternalArray(4);
+
+// Helper function for replacing regular expressions with the result of a
+// function application in String.prototype.replace.
+function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
+ var resultArray = reusableReplaceArray;
+ if (resultArray) {
+ reusableReplaceArray = null;
+ } else {
+ // Inside a nested replace (replace called from the replacement function
+ // of another replace) or we have failed to set the reusable array
+ // back due to an exception in a replacement function. Create a new
+ // array to use in the future, or until the original is written back.
+ resultArray = new InternalArray(16);
+ }
+ var res = %RegExpExecMultiple(regexp,
+ subject,
+ RegExpLastMatchInfo,
+ resultArray);
+ regexp.lastIndex = 0;
+ if (IS_NULL(res)) {
+ // No matches at all.
+ reusableReplaceArray = resultArray;
+ return subject;
+ }
+ var len = res.length;
+ if (NUMBER_OF_CAPTURES(RegExpLastMatchInfo) == 2) {
+ // If the number of captures is two then there are no explicit captures in
+ // the regexp, just the implicit capture that captures the whole match. In
+ // this case we can simplify quite a bit and end up with something faster.
+ // The builder will consist of some integers that indicate slices of the
+ // input string and some replacements that were returned from the replace
+ // function.
+ var match_start = 0;
+ for (var i = 0; i < len; i++) {
+ var elem = res[i];
+ if (%_IsSmi(elem)) {
+ // Integers represent slices of the original string.
+ if (elem > 0) {
+ match_start = (elem >> 11) + (elem & 0x7ff);
+ } else {
+ match_start = res[++i] - elem;
+ }
+ } else {
+ var func_result = replace(elem, match_start, subject);
+ // Overwrite the i'th element in the results with the string we got
+ // back from the callback function.
+ res[i] = TO_STRING(func_result);
+ match_start += elem.length;
+ }
+ }
+ } else {
+ for (var i = 0; i < len; i++) {
+ var elem = res[i];
+ if (!%_IsSmi(elem)) {
+ // elem must be an Array.
+ // Use the apply argument as backing for global RegExp properties.
+ var func_result = %Apply(replace, UNDEFINED, elem, 0, elem.length);
+ // Overwrite the i'th element in the results with the string we got
+ // back from the callback function.
+ res[i] = TO_STRING(func_result);
+ }
+ }
+ }
+ var result = %StringBuilderConcat(res, len, subject);
+ resultArray.length = 0;
+ reusableReplaceArray = resultArray;
+ return result;
+}
+
+
+// Compute the string of a given regular expression capture.
+function CaptureString(string, lastCaptureInfo, index) {
+ // Scale the index.
+ var scaled = index << 1;
+ // Compute start and end.
+ var start = lastCaptureInfo[CAPTURE(scaled)];
+ // If start isn't valid, return undefined.
+ if (start < 0) return;
+ var end = lastCaptureInfo[CAPTURE(scaled + 1)];
+ return %_SubString(string, start, end);
+}
+
+
+function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
+ var matchInfo = DoRegExpExec(regexp, subject, 0);
+ if (IS_NULL(matchInfo)) {
+ regexp.lastIndex = 0;
+ return subject;
+ }
+ var index = matchInfo[CAPTURE0];
+ var result = %_SubString(subject, 0, index);
+ var endOfMatch = matchInfo[CAPTURE1];
+ // Compute the parameter list consisting of the match, captures, index,
+ // and subject for the replace function invocation.
+ // The number of captures plus one for the match.
+ var m = NUMBER_OF_CAPTURES(matchInfo) >> 1;
+ var replacement;
+ if (m == 1) {
+ // No captures, only the match, which is always valid.
+ var s = %_SubString(subject, index, endOfMatch);
+ // Don't call directly to avoid exposing the built-in global object.
+ replacement = replace(s, index, subject);
+ } else {
+ var parameters = new InternalArray(m + 2);
+ for (var j = 0; j < m; j++) {
+ parameters[j] = CaptureString(subject, matchInfo, j);
+ }
+ parameters[j] = index;
+ parameters[j + 1] = subject;
+
+ replacement = %Apply(replace, UNDEFINED, parameters, 0, j + 2);
+ }
+
+ result += replacement; // The add method converts to string if necessary.
+ // Can't use matchInfo any more from here, since the function could
+ // overwrite it.
+ return result + %_SubString(subject, endOfMatch, subject.length);
+}
+
+
+function RegExpReplace(string, replace) {
+ // TODO(littledan): allow non-regexp receivers.
+ if (!IS_REGEXP(this)) {
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ "RegExp.prototype.@@replace", this);
+ }
+ var subject = TO_STRING(string);
+ var search = this;
+
+ if (!IS_CALLABLE(replace)) {
+ replace = TO_STRING(replace);
+
+ if (!REGEXP_GLOBAL(search)) {
+ // Non-global regexp search, string replace.
+ var match = DoRegExpExec(search, subject, 0);
+ if (match == null) {
+ search.lastIndex = 0
+ return subject;
+ }
+ if (replace.length == 0) {
+ return %_SubString(subject, 0, match[CAPTURE0]) +
+ %_SubString(subject, match[CAPTURE1], subject.length)
+ }
+ return ExpandReplacement(replace, subject, RegExpLastMatchInfo,
+ %_SubString(subject, 0, match[CAPTURE0])) +
+ %_SubString(subject, match[CAPTURE1], subject.length);
+ }
+
+ // Global regexp search, string replace.
+ search.lastIndex = 0;
+ return %StringReplaceGlobalRegExpWithString(
+ subject, search, replace, RegExpLastMatchInfo);
+ }
+
+ if (REGEXP_GLOBAL(search)) {
+ // Global regexp search, function replace.
+ return StringReplaceGlobalRegExpWithFunction(subject, search, replace);
+ }
+ // Non-global regexp search, function replace.
+ return StringReplaceNonGlobalRegExpWithFunction(subject, search, replace);
+}
+
+
// ES6 21.2.5.9.
function RegExpSearch(string) {
// TODO(yangguo): allow non-regexp receivers.
@@ -530,6 +713,7 @@
"toString", RegExpToString,
"compile", RegExpCompileJS,
matchSymbol, RegExpMatch,
+ replaceSymbol, RegExpReplace,
searchSymbol, RegExpSearch,
splitSymbol, RegExpSplit,
]);
@@ -539,9 +723,6 @@
utils.InstallGetter(GlobalRegExp.prototype, 'multiline', RegExpGetMultiline);
utils.InstallGetter(GlobalRegExp.prototype, 'source', RegExpGetSource);
-// The length of compile is 1 in SpiderMonkey.
-%FunctionSetLength(GlobalRegExp.prototype.compile, 1);
-
// The properties `input` and `$_` are aliases for each other. When this
// value is set the value it is set to is coerced to a string.
// Getter and setter for the input.
diff --git a/src/js/runtime.js b/src/js/runtime.js
index 301d75a..7a61094 100644
--- a/src/js/runtime.js
+++ b/src/js/runtime.js
@@ -36,47 +36,12 @@
// ----------------------------------------------------------------------------
-/* -----------------------------
- - - - H e l p e r s - - -
- -----------------------------
+
+/* ---------------------------------
+ - - - U t i l i t i e s - - -
+ ---------------------------------
*/
-function CONCAT_ITERABLE_TO_ARRAY(iterable) {
- return %concat_iterable_to_array(this, iterable);
-};
-
-
-/* -------------------------------------
- - - - C o n v e r s i o n s - - -
- -------------------------------------
-*/
-
-// ES5, section 9.12
-function SameValue(x, y) {
- if (typeof x != typeof y) return false;
- if (IS_NUMBER(x)) {
- if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
- // x is +0 and y is -0 or vice versa.
- if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) {
- return false;
- }
- }
- if (IS_SIMD_VALUE(x)) return %SimdSameValue(x, y);
- return x === y;
-}
-
-
-// ES6, section 7.2.4
-function SameValueZero(x, y) {
- if (typeof x != typeof y) return false;
- if (IS_NUMBER(x)) {
- if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
- }
- if (IS_SIMD_VALUE(x)) return %SimdSameValueZero(x, y);
- return x === y;
-}
-
-
function ConcatIterableToArray(target, iterable) {
var index = target.length;
for (var element of iterable) {
@@ -86,12 +51,6 @@
}
-/* ---------------------------------
- - - - U t i l i t i e s - - -
- ---------------------------------
-*/
-
-
// 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.
@@ -174,17 +133,11 @@
to.AddIndexedProperty = AddIndexedProperty;
to.MaxSimple = MaxSimple;
to.MinSimple = MinSimple;
- to.SameValue = SameValue;
- to.SameValueZero = SameValueZero;
to.ToPositiveInteger = ToPositiveInteger;
to.SpeciesConstructor = SpeciesConstructor;
});
%InstallToContext([
- "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY,
-]);
-
-%InstallToContext([
"concat_iterable_to_array", ConcatIterableToArray,
]);
diff --git a/src/js/spread.js b/src/js/spread.js
index 235c91a..82ea839 100644
--- a/src/js/spread.js
+++ b/src/js/spread.js
@@ -18,11 +18,11 @@
// -------------------------------------------------------------------
function SpreadArguments() {
- var count = %_ArgumentsLength();
+ var count = arguments.length;
var args = new InternalArray();
for (var i = 0; i < count; ++i) {
- var array = %_Arguments(i);
+ var array = arguments[i];
var length = array.length;
for (var j = 0; j < length; ++j) {
args.push(array[j]);
diff --git a/src/js/string.js b/src/js/string.js
index b220038..a401978 100644
--- a/src/js/string.js
+++ b/src/js/string.js
@@ -17,12 +17,11 @@
var InternalPackedArray = utils.InternalPackedArray;
var MakeRangeError;
var MakeTypeError;
-var MathMax;
-var MathMin;
+var MaxSimple;
+var MinSimple;
var matchSymbol = utils.ImportNow("match_symbol");
-var RegExpExec;
var RegExpExecNoTests;
-var RegExpLastMatchInfo;
+var replaceSymbol = utils.ImportNow("replace_symbol");
var searchSymbol = utils.ImportNow("search_symbol");
var splitSymbol = utils.ImportNow("split_symbol");
@@ -31,11 +30,9 @@
ArrayJoin = from.ArrayJoin;
MakeRangeError = from.MakeRangeError;
MakeTypeError = from.MakeTypeError;
- MathMax = from.MathMax;
- MathMin = from.MathMin;
- RegExpExec = from.RegExpExec;
+ MaxSimple = from.MaxSimple;
+ MinSimple = from.MinSimple;
RegExpExecNoTests = from.RegExpExecNoTests;
- RegExpLastMatchInfo = from.RegExpLastMatchInfo;
});
//-------------------------------------------------------------------
@@ -84,41 +81,34 @@
// ECMA-262, section 15.5.4.6
function StringConcat(other /* and more */) { // length == 1
+ "use strict";
CHECK_OBJECT_COERCIBLE(this, "String.prototype.concat");
- var len = %_ArgumentsLength();
- var this_as_string = TO_STRING(this);
- if (len === 1) {
- return this_as_string + TO_STRING(other);
+ var s = TO_STRING(this);
+ var len = arguments.length;
+ for (var i = 0; i < len; ++i) {
+ s = s + TO_STRING(arguments[i]);
}
- var parts = new InternalArray(len + 1);
- parts[0] = this_as_string;
- for (var i = 0; i < len; i++) {
- var part = %_Arguments(i);
- parts[i + 1] = TO_STRING(part);
- }
- return %StringBuilderConcat(parts, len + 1, "");
+ return s;
}
// ECMA-262 section 15.5.4.7
-function StringIndexOfJS(pattern /* position */) { // length == 1
+function StringIndexOf(pattern, position) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.indexOf");
var subject = TO_STRING(this);
pattern = TO_STRING(pattern);
- var index = 0;
- if (%_ArgumentsLength() > 1) {
- index = %_Arguments(1); // position
- index = TO_INTEGER(index);
- if (index < 0) index = 0;
- if (index > subject.length) index = subject.length;
- }
+ var index = TO_INTEGER(position);
+ if (index < 0) index = 0;
+ if (index > subject.length) index = subject.length;
return %StringIndexOf(subject, pattern, index);
}
+%FunctionSetLength(StringIndexOf, 1);
+
// ECMA-262 section 15.5.4.8
-function StringLastIndexOfJS(pat /* position */) { // length == 1
+function StringLastIndexOf(pat, pos) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.lastIndexOf");
var sub = TO_STRING(this);
@@ -126,16 +116,14 @@
var pat = TO_STRING(pat);
var patLength = pat.length;
var index = subLength - patLength;
- if (%_ArgumentsLength() > 1) {
- var position = TO_NUMBER(%_Arguments(1));
- if (!NUMBER_IS_NAN(position)) {
- position = TO_INTEGER(position);
- if (position < 0) {
- position = 0;
- }
- if (position + patLength < subLength) {
- index = position;
- }
+ var position = TO_NUMBER(pos);
+ if (!NUMBER_IS_NAN(position)) {
+ position = TO_INTEGER(position);
+ if (position < 0) {
+ position = 0;
+ }
+ if (position + patLength < subLength) {
+ index = position;
}
}
if (index < 0) {
@@ -144,6 +132,8 @@
return %StringLastIndexOf(sub, pat, index);
}
+%FunctionSetLength(StringLastIndexOf, 1);
+
// ECMA-262 section 15.5.4.9
//
@@ -180,11 +170,10 @@
// For now we do nothing, as proper normalization requires big tables.
// If Intl is enabled, then i18n.js will override it and provide the the
// proper functionality.
-function StringNormalizeJS() {
+function StringNormalize(formArg) { // length == 0
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
var s = TO_STRING(this);
- var formArg = %_Arguments(0);
var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg);
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
@@ -197,6 +186,8 @@
return s;
}
+%FunctionSetLength(StringNormalize, 0);
+
// This has the same size as the RegExpLastMatchInfo array, and can be used
// for functions that expect that structure to be returned. It is used when
@@ -206,14 +197,12 @@
var reusableMatchInfo = [2, "", "", -1, -1];
-// ECMA-262, section 15.5.4.11
+// ES6, section 21.1.3.14
function StringReplace(search, replace) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.replace");
- var subject = TO_STRING(this);
-
// Decision tree for dispatch
- // .. regexp search
+ // .. regexp search (in src/js/regexp.js, RegExpReplace)
// .... string replace
// ...... non-global search
// ........ empty string replace
@@ -229,40 +218,15 @@
// ...... function replace
// ...... string replace (with $-expansion)
- if (IS_REGEXP(search)) {
- if (!IS_CALLABLE(replace)) {
- replace = TO_STRING(replace);
-
- if (!REGEXP_GLOBAL(search)) {
- // Non-global regexp search, string replace.
- var match = RegExpExec(search, subject, 0);
- if (match == null) {
- search.lastIndex = 0
- return subject;
- }
- if (replace.length == 0) {
- return %_SubString(subject, 0, match[CAPTURE0]) +
- %_SubString(subject, match[CAPTURE1], subject.length)
- }
- return ExpandReplacement(replace, subject, RegExpLastMatchInfo,
- %_SubString(subject, 0, match[CAPTURE0])) +
- %_SubString(subject, match[CAPTURE1], subject.length);
- }
-
- // Global regexp search, string replace.
- search.lastIndex = 0;
- return %StringReplaceGlobalRegExpWithString(
- subject, search, replace, RegExpLastMatchInfo);
+ if (!IS_NULL_OR_UNDEFINED(search)) {
+ var replacer = search[replaceSymbol];
+ if (!IS_UNDEFINED(replacer)) {
+ return %_Call(replacer, search, this, replace);
}
-
- if (REGEXP_GLOBAL(search)) {
- // Global regexp search, function replace.
- return StringReplaceGlobalRegExpWithFunction(subject, search, replace);
- }
- // Non-global regexp search, function replace.
- return StringReplaceNonGlobalRegExpWithFunction(subject, search, replace);
}
+ var subject = TO_STRING(this);
+
search = TO_STRING(search);
if (search.length == 1 &&
@@ -379,130 +343,6 @@
}
-// Compute the string of a given regular expression capture.
-function CaptureString(string, lastCaptureInfo, index) {
- // Scale the index.
- var scaled = index << 1;
- // Compute start and end.
- var start = lastCaptureInfo[CAPTURE(scaled)];
- // If start isn't valid, return undefined.
- if (start < 0) return;
- var end = lastCaptureInfo[CAPTURE(scaled + 1)];
- return %_SubString(string, start, end);
-}
-
-
-// TODO(lrn): This array will survive indefinitely if replace is never
-// called again. However, it will be empty, since the contents are cleared
-// in the finally block.
-var reusableReplaceArray = new InternalArray(4);
-
-// Helper function for replacing regular expressions with the result of a
-// function application in String.prototype.replace.
-function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
- var resultArray = reusableReplaceArray;
- if (resultArray) {
- reusableReplaceArray = null;
- } else {
- // Inside a nested replace (replace called from the replacement function
- // of another replace) or we have failed to set the reusable array
- // back due to an exception in a replacement function. Create a new
- // array to use in the future, or until the original is written back.
- resultArray = new InternalArray(16);
- }
- var res = %RegExpExecMultiple(regexp,
- subject,
- RegExpLastMatchInfo,
- resultArray);
- regexp.lastIndex = 0;
- if (IS_NULL(res)) {
- // No matches at all.
- reusableReplaceArray = resultArray;
- return subject;
- }
- var len = res.length;
- if (NUMBER_OF_CAPTURES(RegExpLastMatchInfo) == 2) {
- // If the number of captures is two then there are no explicit captures in
- // the regexp, just the implicit capture that captures the whole match. In
- // this case we can simplify quite a bit and end up with something faster.
- // The builder will consist of some integers that indicate slices of the
- // input string and some replacements that were returned from the replace
- // function.
- var match_start = 0;
- for (var i = 0; i < len; i++) {
- var elem = res[i];
- if (%_IsSmi(elem)) {
- // Integers represent slices of the original string.
- if (elem > 0) {
- match_start = (elem >> 11) + (elem & 0x7ff);
- } else {
- match_start = res[++i] - elem;
- }
- } else {
- var func_result = replace(elem, match_start, subject);
- // Overwrite the i'th element in the results with the string we got
- // back from the callback function.
- res[i] = TO_STRING(func_result);
- match_start += elem.length;
- }
- }
- } else {
- for (var i = 0; i < len; i++) {
- var elem = res[i];
- if (!%_IsSmi(elem)) {
- // elem must be an Array.
- // Use the apply argument as backing for global RegExp properties.
- var func_result = %Apply(replace, UNDEFINED, elem, 0, elem.length);
- // Overwrite the i'th element in the results with the string we got
- // back from the callback function.
- res[i] = TO_STRING(func_result);
- }
- }
- }
- var result = %StringBuilderConcat(res, len, subject);
- resultArray.length = 0;
- reusableReplaceArray = resultArray;
- return result;
-}
-
-
-function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
- var matchInfo = RegExpExec(regexp, subject, 0);
- if (IS_NULL(matchInfo)) {
- regexp.lastIndex = 0;
- return subject;
- }
- var index = matchInfo[CAPTURE0];
- var result = %_SubString(subject, 0, index);
- var endOfMatch = matchInfo[CAPTURE1];
- // Compute the parameter list consisting of the match, captures, index,
- // and subject for the replace function invocation.
- // The number of captures plus one for the match.
- var m = NUMBER_OF_CAPTURES(matchInfo) >> 1;
- var replacement;
- if (m == 1) {
- // No captures, only the match, which is always valid.
- var s = %_SubString(subject, index, endOfMatch);
- // Don't call directly to avoid exposing the built-in global object.
- replacement = replace(s, index, subject);
- } else {
- var parameters = new InternalArray(m + 2);
- for (var j = 0; j < m; j++) {
- parameters[j] = CaptureString(subject, matchInfo, j);
- }
- parameters[j] = index;
- parameters[j + 1] = subject;
-
- replacement = %Apply(replace, UNDEFINED, parameters, 0, j + 2);
- }
-
- result += replacement; // The add method converts to string if necessary.
- // Can't use matchInfo any more from here, since the function could
- // overwrite it.
- return result + %_SubString(subject, endOfMatch, subject.length);
-}
-
-
// ES6 21.1.3.15.
function StringSearch(pattern) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.search");
@@ -719,28 +559,14 @@
// ECMA-262, section 15.5.3.2
-function StringFromCharCode(code) {
- var n = %_ArgumentsLength();
- if (n == 1) return %_StringCharFromCode(code & 0xffff);
-
- var one_byte = %NewString(n, NEW_ONE_BYTE_STRING);
- var i;
- for (i = 0; i < n; i++) {
- code = %_Arguments(i) & 0xffff;
- if (code > 0xff) break;
- %_OneByteSeqStringSetChar(i, code, one_byte);
+function StringFromCharCode(_) { // length == 1
+ "use strict";
+ var s = "";
+ var n = arguments.length;
+ for (var i = 0; i < n; ++i) {
+ s += %_StringCharFromCode(arguments[i] & 0xffff);
}
- if (i == n) return one_byte;
- one_byte = %TruncateString(one_byte, i);
-
- var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING);
- %_TwoByteSeqStringSetChar(0, code, two_byte);
- i++;
- for (var j = 1; i < n; i++, j++) {
- code = %_Arguments(i) & 0xffff;
- %_TwoByteSeqStringSetChar(j, code, two_byte);
- }
- return one_byte + two_byte;
+ return s;
}
@@ -870,7 +696,7 @@
// ES6 draft 04-05-14, section 21.1.3.18
-function StringStartsWith(searchString /* position */) { // length == 1
+function StringStartsWith(searchString, position) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.startsWith");
var s = TO_STRING(this);
@@ -880,16 +706,10 @@
}
var ss = TO_STRING(searchString);
- var pos = 0;
- if (%_ArgumentsLength() > 1) {
- var arg = %_Arguments(1); // position
- if (!IS_UNDEFINED(arg)) {
- pos = TO_INTEGER(arg);
- }
- }
+ var pos = TO_INTEGER(position);
var s_len = s.length;
- var start = MathMin(MathMax(pos, 0), s_len);
+ var start = MinSimple(MaxSimple(pos, 0), s_len);
var ss_len = ss.length;
if (ss_len + start > s_len) {
return false;
@@ -898,9 +718,11 @@
return %_SubString(s, start, start + ss_len) === ss;
}
+%FunctionSetLength(StringStartsWith, 1);
+
// ES6 draft 04-05-14, section 21.1.3.7
-function StringEndsWith(searchString /* position */) { // length == 1
+function StringEndsWith(searchString, position) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.endsWith");
var s = TO_STRING(this);
@@ -911,15 +733,9 @@
var ss = TO_STRING(searchString);
var s_len = s.length;
- var pos = s_len;
- if (%_ArgumentsLength() > 1) {
- var arg = %_Arguments(1); // position
- if (!IS_UNDEFINED(arg)) {
- pos = TO_INTEGER(arg);
- }
- }
+ var pos = !IS_UNDEFINED(position) ? TO_INTEGER(position) : s_len
- var end = MathMin(MathMax(pos, 0), s_len);
+ var end = MinSimple(MaxSimple(pos, 0), s_len);
var ss_len = ss.length;
var start = end - ss_len;
if (start < 0) {
@@ -929,9 +745,11 @@
return %_SubString(s, start, start + ss_len) === ss;
}
+%FunctionSetLength(StringEndsWith, 1);
+
// ES6 draft 04-05-14, section 21.1.3.6
-function StringIncludes(searchString /* position */) { // length == 1
+function StringIncludes(searchString, position) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes");
var string = TO_STRING(this);
@@ -941,11 +759,7 @@
}
searchString = TO_STRING(searchString);
- var pos = 0;
- if (%_ArgumentsLength() > 1) {
- pos = %_Arguments(1); // position
- pos = TO_INTEGER(pos);
- }
+ var pos = TO_INTEGER(position);
var stringLength = string.length;
if (pos < 0) pos = 0;
@@ -959,6 +773,8 @@
return %StringIndexOf(string, searchString, pos) !== -1;
}
+%FunctionSetLength(StringIncludes, 1);
+
// ES6 Draft 05-22-2014, section 21.1.3.3
function StringCodePointAt(pos) {
@@ -984,12 +800,13 @@
// ES6 Draft 05-22-2014, section 21.1.2.2
function StringFromCodePoint(_) { // length = 1
+ "use strict";
var code;
- var length = %_ArgumentsLength();
+ var length = arguments.length;
var index;
var result = "";
for (index = 0; index < length; index++) {
- code = %_Arguments(index);
+ code = arguments[index];
if (!%_IsSmi(code)) {
code = TO_NUMBER(code);
}
@@ -1013,8 +830,8 @@
// ES6 Draft 03-17-2015, section 21.1.2.4
function StringRaw(callSite) {
- // TODO(caitp): Use rest parameters when implemented
- var numberOfSubstitutions = %_ArgumentsLength();
+ "use strict";
+ var numberOfSubstitutions = arguments.length;
var cooked = TO_OBJECT(callSite);
var raw = TO_OBJECT(cooked.raw);
var literalSegments = TO_LENGTH(raw.length);
@@ -1024,7 +841,7 @@
for (var i = 1; i < literalSegments; ++i) {
if (i < numberOfSubstitutions) {
- result += TO_STRING(%_Arguments(i));
+ result += TO_STRING(arguments[i]);
}
result += TO_STRING(raw[i]);
}
@@ -1058,11 +875,11 @@
"concat", StringConcat,
"endsWith", StringEndsWith,
"includes", StringIncludes,
- "indexOf", StringIndexOfJS,
- "lastIndexOf", StringLastIndexOfJS,
+ "indexOf", StringIndexOf,
+ "lastIndexOf", StringLastIndexOf,
"localeCompare", StringLocaleCompareJS,
"match", StringMatchJS,
- "normalize", StringNormalizeJS,
+ "normalize", StringNormalize,
"repeat", StringRepeat,
"replace", StringReplace,
"search", StringSearch,
@@ -1098,9 +915,10 @@
// Exports
utils.Export(function(to) {
+ to.ExpandReplacement = ExpandReplacement;
to.StringCharAt = StringCharAtJS;
- to.StringIndexOf = StringIndexOfJS;
- to.StringLastIndexOf = StringLastIndexOfJS;
+ to.StringIndexOf = StringIndexOf;
+ to.StringLastIndexOf = StringLastIndexOf;
to.StringMatch = StringMatchJS;
to.StringReplace = StringReplace;
to.StringSlice = StringSlice;
diff --git a/src/js/symbol.js b/src/js/symbol.js
index 5be6e01..ae54369 100644
--- a/src/js/symbol.js
+++ b/src/js/symbol.js
@@ -11,7 +11,6 @@
// -------------------------------------------------------------------
// Imports
-var GlobalObject = global.Object;
var GlobalSymbol = global.Symbol;
var hasInstanceSymbol = utils.ImportNow("has_instance_symbol");
var isConcatSpreadableSymbol =
@@ -73,22 +72,11 @@
return %SymbolRegistry().keyFor[symbol];
}
-
-// ES6 19.1.2.8
-function ObjectGetOwnPropertySymbols(obj) {
- obj = TO_OBJECT(obj);
-
- return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_SKIP_STRINGS);
-}
-
// -------------------------------------------------------------------
-%FunctionSetPrototype(GlobalSymbol, new GlobalObject());
-
utils.InstallConstants(GlobalSymbol, [
- // TODO(rossberg): expose when implemented.
- // "hasInstance", hasInstanceSymbol,
- // "isConcatSpreadable", isConcatSpreadableSymbol,
+ "hasInstance", hasInstanceSymbol,
+ "isConcatSpreadable", isConcatSpreadableSymbol,
"iterator", iteratorSymbol,
// TODO(yangguo): expose when implemented.
// "match", matchSymbol,
@@ -108,8 +96,6 @@
]);
%AddNamedProperty(
- GlobalSymbol.prototype, "constructor", GlobalSymbol, DONT_ENUM);
-%AddNamedProperty(
GlobalSymbol.prototype, toStringTagSymbol, "Symbol", DONT_ENUM | READ_ONLY);
utils.InstallFunctions(GlobalSymbol.prototype, DONT_ENUM | READ_ONLY, [
@@ -121,10 +107,6 @@
"valueOf", SymbolValueOf
]);
-utils.InstallFunctions(GlobalObject, DONT_ENUM, [
- "getOwnPropertySymbols", ObjectGetOwnPropertySymbols
-]);
-
// -------------------------------------------------------------------
// Exports
diff --git a/src/js/typedarray.js b/src/js/typedarray.js
index fd668a5..3d500a3 100644
--- a/src/js/typedarray.js
+++ b/src/js/typedarray.js
@@ -300,8 +300,10 @@
var newLength = endInt - beginInt;
var beginByteOffset =
%_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE;
- return TypedArraySpeciesCreate(this, %TypedArrayGetBuffer(this),
- beginByteOffset, newLength, true);
+ // BUG(v8:4665): For web compatibility, subarray needs to always build an
+ // instance of the default constructor.
+ // TODO(littledan): Switch to the standard or standardize the fix
+ return new GlobalNAME(%TypedArrayGetBuffer(this), beginByteOffset, newLength);
}
endmacro
@@ -460,6 +462,7 @@
return;
}
}
+%FunctionSetLength(TypedArraySet, 1);
function TypedArrayGetToStringTag() {
if (!%_IsTypedArray(this)) return;
@@ -564,22 +567,20 @@
function TypedArrayComparefn(x, y) {
- if (IsNaN(x) && IsNaN(y)) {
- return IsNaN(y) ? 0 : 1;
+ if (x === 0 && x === y) {
+ x = 1 / x;
+ y = 1 / y;
}
- if (IsNaN(x)) {
+ if (x < y) {
+ return -1;
+ } else if (x > y) {
+ return 1;
+ } else if (IsNaN(x) && IsNaN(y)) {
+ return IsNaN(y) ? 0 : 1;
+ } else if (IsNaN(x)) {
return 1;
}
- if (x === 0 && x === y) {
- if (%_IsMinusZero(x)) {
- if (!%_IsMinusZero(y)) {
- return -1;
- }
- } else if (%_IsMinusZero(y)) {
- return 1;
- }
- }
- return x - y;
+ return 0;
}
@@ -614,7 +615,7 @@
var length = %_TypedArrayGetLength(this);
return InnerArrayLastIndexOf(this, element, index, length,
- %_ArgumentsLength());
+ arguments.length);
}
%FunctionSetLength(TypedArrayLastIndexOf, 1);
@@ -678,7 +679,7 @@
var length = %_TypedArrayGetLength(this);
return InnerArrayReduce(callback, current, this, length,
- %_ArgumentsLength());
+ arguments.length);
}
%FunctionSetLength(TypedArrayReduce, 1);
@@ -689,7 +690,7 @@
var length = %_TypedArrayGetLength(this);
return InnerArrayReduceRight(callback, current, this, length,
- %_ArgumentsLength());
+ arguments.length);
}
%FunctionSetLength(TypedArrayReduceRight, 1);
@@ -750,10 +751,10 @@
// ES6 draft 08-24-14, section 22.2.2.2
function TypedArrayOf() {
- var length = %_ArgumentsLength();
+ var length = arguments.length;
var array = TypedArrayCreate(this, length);
for (var i = 0; i < length; i++) {
- array[i] = %_Arguments(i);
+ array[i] = arguments[i];
}
return array;
}
@@ -846,36 +847,6 @@
// --------------------------- DataView -----------------------------
-function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
- if (IS_UNDEFINED(new.target)) {
- throw MakeTypeError(kConstructorNotFunction, "DataView");
- }
-
- // TODO(binji): support SharedArrayBuffers?
- if (!IS_ARRAYBUFFER(buffer)) throw MakeTypeError(kDataViewNotArrayBuffer);
- if (!IS_UNDEFINED(byteOffset)) {
- byteOffset = ToPositiveInteger(byteOffset, kInvalidDataViewOffset);
- }
- if (!IS_UNDEFINED(byteLength)) {
- byteLength = TO_INTEGER(byteLength);
- }
-
- var bufferByteLength = %_ArrayBufferGetByteLength(buffer);
-
- var offset = IS_UNDEFINED(byteOffset) ? 0 : byteOffset;
- if (offset > bufferByteLength) throw MakeRangeError(kInvalidDataViewOffset);
-
- var length = IS_UNDEFINED(byteLength)
- ? bufferByteLength - offset
- : byteLength;
- if (length < 0 || offset + length > bufferByteLength) {
- throw new MakeRangeError(kInvalidDataViewLength);
- }
- var result = %NewObject(GlobalDataView, new.target);
- %_DataViewInitialize(result, buffer, offset, length);
- return result;
-}
-
function DataViewGetBufferJS() {
if (!IS_DATAVIEW(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, 'DataView.buffer', this);
@@ -917,26 +888,27 @@
throw MakeTypeError(kIncompatibleMethodReceiver,
'DataView.getTYPENAME', this);
}
- if (%_ArgumentsLength() < 1) throw MakeTypeError(kInvalidArgument);
+ if (arguments.length < 1) throw MakeTypeError(kInvalidArgument);
offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
return %DataViewGetTYPENAME(this, offset, !!little_endian);
}
+%FunctionSetLength(DataViewGetTYPENAMEJS, 1);
function DataViewSetTYPENAMEJS(offset, value, little_endian) {
if (!IS_DATAVIEW(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
'DataView.setTYPENAME', this);
}
- if (%_ArgumentsLength() < 2) throw MakeTypeError(kInvalidArgument);
+ if (arguments.length < 2) throw MakeTypeError(kInvalidArgument);
offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
%DataViewSetTYPENAME(this, offset, TO_NUMBER(value), !!little_endian);
}
+%FunctionSetLength(DataViewSetTYPENAMEJS, 2);
endmacro
DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
// Setup the DataView constructor.
-%SetCode(GlobalDataView, DataViewConstructor);
%FunctionSetPrototype(GlobalDataView, new GlobalObject);
// Set up constructor property on the DataView prototype.
diff --git a/src/js/v8natives.js b/src/js/v8natives.js
index 26447da..5e1a825 100644
--- a/src/js/v8natives.js
+++ b/src/js/v8natives.js
@@ -10,7 +10,6 @@
// Imports
var GlobalArray = global.Array;
-var GlobalBoolean = global.Boolean;
var GlobalNumber = global.Number;
var GlobalObject = global.Object;
var InternalArray = utils.InternalArray;
@@ -24,7 +23,6 @@
var ObserveBeginPerformSplice;
var ObserveEndPerformSplice;
var ObserveEnqueueSpliceRecord;
-var SameValue = utils.ImportNow("SameValue");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
@@ -545,17 +543,17 @@
if ((IsGenericDescriptor(desc) ||
IsDataDescriptor(desc) == IsDataDescriptor(current)) &&
(!desc.hasEnumerable() ||
- SameValue(desc.isEnumerable(), current.isEnumerable())) &&
+ %SameValue(desc.isEnumerable(), current.isEnumerable())) &&
(!desc.hasConfigurable() ||
- SameValue(desc.isConfigurable(), current.isConfigurable())) &&
+ %SameValue(desc.isConfigurable(), current.isConfigurable())) &&
(!desc.hasWritable() ||
- SameValue(desc.isWritable(), current.isWritable())) &&
+ %SameValue(desc.isWritable(), current.isWritable())) &&
(!desc.hasValue() ||
- SameValue(desc.getValue(), current.getValue())) &&
+ %SameValue(desc.getValue(), current.getValue())) &&
(!desc.hasGetter() ||
- SameValue(desc.getGet(), current.getGet())) &&
+ %SameValue(desc.getGet(), current.getGet())) &&
(!desc.hasSetter() ||
- SameValue(desc.getSet(), current.getSet()))) {
+ %SameValue(desc.getSet(), current.getSet()))) {
return true;
}
if (!current.isConfigurable()) {
@@ -594,7 +592,7 @@
}
}
if (!currentIsWritable && desc.hasValue() &&
- !SameValue(desc.getValue(), current.getValue())) {
+ !%SameValue(desc.getValue(), current.getValue())) {
if (should_throw) {
throw MakeTypeError(kRedefineDisallowed, p);
} else {
@@ -605,14 +603,14 @@
// Step 11
if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) {
if (desc.hasSetter() &&
- !SameValue(desc.getSet(), current.getSet())) {
+ !%SameValue(desc.getSet(), current.getSet())) {
if (should_throw) {
throw MakeTypeError(kRedefineDisallowed, p);
} else {
return false;
}
}
- if (desc.hasGetter() && !SameValue(desc.getGet(),current.getGet())) {
+ if (desc.hasGetter() && !%SameValue(desc.getGet(),current.getGet())) {
if (should_throw) {
throw MakeTypeError(kRedefineDisallowed, p);
} else {
@@ -772,19 +770,6 @@
}
-// ES6 section 19.1.2.6
-function ObjectGetOwnPropertyDescriptor(obj, p) {
- return %GetOwnProperty(obj, p);
-}
-
-
-// ES5 section 15.2.3.4.
-function ObjectGetOwnPropertyNames(obj) {
- obj = TO_OBJECT(obj);
- return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_SKIP_SYMBOLS);
-}
-
-
// ES5 section 15.2.3.6.
function ObjectDefineProperty(obj, p, attributes) {
// The new pure-C++ implementation doesn't support O.o.
@@ -802,11 +787,6 @@
}
-function GetOwnEnumerablePropertyNames(object) {
- return %GetOwnPropertyKeys(object, PROPERTY_FILTER_ONLY_ENUMERABLE);
-}
-
-
// ES5 section 15.2.3.7.
function ObjectDefineProperties(obj, properties) {
// The new pure-C++ implementation doesn't support O.o.
@@ -816,7 +796,7 @@
throw MakeTypeError(kCalledOnNonObject, "Object.defineProperties");
}
var props = TO_OBJECT(properties);
- var names = GetOwnEnumerablePropertyNames(props);
+ var names = %GetOwnPropertyKeys(props, PROPERTY_FILTER_ONLY_ENUMERABLE);
var descriptors = new InternalArray();
for (var i = 0; i < names.length; i++) {
descriptors.push(ToPropertyDescriptor(props[names[i]]));
@@ -889,65 +869,13 @@
"defineProperties", ObjectDefineProperties,
"getPrototypeOf", ObjectGetPrototypeOf,
"setPrototypeOf", ObjectSetPrototypeOf,
- "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
- "getOwnPropertyNames", ObjectGetOwnPropertyNames,
// getOwnPropertySymbols is added in symbol.js.
- "is", SameValue, // ECMA-262, Edition 6, section 19.1.2.10
+ // is is added in bootstrapper.cc.
// deliverChangeRecords, getNotifier, observe and unobserve are added
// in object-observe.js.
]);
-// ----------------------------------------------------------------------------
-// Boolean
-
-function BooleanConstructor(x) {
- // TODO(bmeurer): Move this to toplevel.
- "use strict";
- if (!IS_UNDEFINED(new.target)) {
- %_SetValueOf(this, TO_BOOLEAN(x));
- } else {
- return TO_BOOLEAN(x);
- }
-}
-
-
-function BooleanToString() {
- // NOTE: Both Boolean objects and values can enter here as
- // 'this'. This is not as dictated by ECMA-262.
- var b = this;
- if (!IS_BOOLEAN(b)) {
- if (!IS_BOOLEAN_WRAPPER(b)) {
- throw MakeTypeError(kNotGeneric, 'Boolean.prototype.toString');
- }
- b = %_ValueOf(b);
- }
- return b ? 'true' : 'false';
-}
-
-
-function BooleanValueOf() {
- // NOTE: Both Boolean objects and values can enter here as
- // 'this'. This is not as dictated by ECMA-262.
- if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this)) {
- throw MakeTypeError(kNotGeneric, 'Boolean.prototype.valueOf');
- }
- return %_ValueOf(this);
-}
-
-
-// ----------------------------------------------------------------------------
-
-%SetCode(GlobalBoolean, BooleanConstructor);
-%FunctionSetPrototype(GlobalBoolean, new GlobalBoolean(false));
-%AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean,
- DONT_ENUM);
-
-utils.InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [
- "toString", BooleanToString,
- "valueOf", BooleanValueOf
-]);
-
// ----------------------------------------------------------------------------
// Number