Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/src/js/array-iterator.js b/src/js/array-iterator.js
index b3e25e9..8203f1f 100644
--- a/src/js/array-iterator.js
+++ b/src/js/array-iterator.js
@@ -22,7 +22,7 @@
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeTypeError;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
-var GlobalTypedArray = global.Uint8Array.__proto__;
+var GlobalTypedArray = %object_get_prototype_of(global.Uint8Array);
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
diff --git a/src/js/array.js b/src/js/array.js
index 0a77b23..c29b8f7 100644
--- a/src/js/array.js
+++ b/src/js/array.js
@@ -11,7 +11,6 @@
// -------------------------------------------------------------------
// Imports
-var FLAG_harmony_species;
var GetIterator;
var GetMethod;
var GlobalArray = global.Array;
@@ -23,6 +22,7 @@
var ObjectHasOwnProperty;
var ObjectToString = utils.ImportNow("object_to_string");
var iteratorSymbol = utils.ImportNow("iterator_symbol");
+var speciesSymbol = utils.ImportNow("species_symbol");
var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
utils.Import(function(from) {
@@ -34,23 +34,12 @@
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
});
-utils.ImportFromExperimental(function(from) {
- FLAG_harmony_species = from.FLAG_harmony_species;
-});
-
// -------------------------------------------------------------------
function ArraySpeciesCreate(array, length) {
- var constructor;
-
length = INVERT_NEG_ZERO(length);
-
- if (FLAG_harmony_species) {
- constructor = %ArraySpeciesConstructor(array);
- } else {
- constructor = GlobalArray;
- }
+ var constructor = %ArraySpeciesConstructor(array);
return new constructor(length);
}
@@ -328,10 +317,9 @@
// because the receiver is not an array (so we have no choice) or because we
// know we are not deleting or moving a lot of elements.
function SimpleSlice(array, start_i, del_count, len, deleted_elements) {
- var is_array = IS_ARRAY(array);
for (var i = 0; i < del_count; i++) {
var index = start_i + i;
- if (HAS_INDEX(array, index, is_array)) {
+ if (index in array) {
var current = array[index];
%CreateDataProperty(deleted_elements, i, current);
}
@@ -340,7 +328,6 @@
function SimpleMove(array, start_i, del_count, len, num_additional_args) {
- var is_array = IS_ARRAY(array);
if (num_additional_args !== del_count) {
// Move the existing elements after the elements to be deleted
// to the right position in the resulting array.
@@ -348,7 +335,7 @@
for (var i = len - del_count; i > start_i; i--) {
var from_index = i + del_count - 1;
var to_index = i + num_additional_args - 1;
- if (HAS_INDEX(array, from_index, is_array)) {
+ if (from_index in array) {
array[to_index] = array[from_index];
} else {
delete array[to_index];
@@ -358,7 +345,7 @@
for (var i = start_i; i < len - del_count; i++) {
var from_index = i + del_count;
var to_index = i + num_additional_args;
- if (HAS_INDEX(array, from_index, is_array)) {
+ if (from_index in array) {
array[to_index] = array[from_index];
} else {
delete array[to_index];
@@ -661,7 +648,7 @@
if (UseSparseVariant(array, len, IS_ARRAY(array), end_i - start_i)) {
%NormalizeElements(array);
- %NormalizeElements(result);
+ if (IS_ARRAY(result)) %NormalizeElements(result);
SparseSlice(array, start_i, end_i - start_i, len, result);
} else {
SimpleSlice(array, start_i, end_i - start_i, len, result);
@@ -731,7 +718,7 @@
}
if (UseSparseVariant(array, len, IS_ARRAY(array), changed_elements)) {
%NormalizeElements(array);
- %NormalizeElements(deleted_elements);
+ if (IS_ARRAY(deleted_elements)) %NormalizeElements(deleted_elements);
SparseSlice(array, start_i, del_count, len, deleted_elements);
SparseMove(array, start_i, del_count, len, num_elements_to_add);
} else {
@@ -1055,9 +1042,8 @@
// or delete elements from the array.
function InnerArrayFilter(f, receiver, array, length, result) {
var result_length = 0;
- var is_array = IS_ARRAY(array);
for (var i = 0; i < length; i++) {
- if (HAS_INDEX(array, i, is_array)) {
+ if (i in array) {
var element = array[i];
if (%_Call(f, receiver, element, i, array)) {
%CreateDataProperty(result, result_length, element);
@@ -1086,17 +1072,16 @@
function InnerArrayForEach(f, receiver, array, length) {
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
- var is_array = IS_ARRAY(array);
if (IS_UNDEFINED(receiver)) {
for (var i = 0; i < length; i++) {
- if (HAS_INDEX(array, i, is_array)) {
+ if (i in array) {
var element = array[i];
f(element, i, array);
}
}
} else {
for (var i = 0; i < length; i++) {
- if (HAS_INDEX(array, i, is_array)) {
+ if (i in array) {
var element = array[i];
%_Call(f, receiver, element, i, array);
}
@@ -1119,9 +1104,8 @@
function InnerArraySome(f, receiver, array, length) {
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
- var is_array = IS_ARRAY(array);
for (var i = 0; i < length; i++) {
- if (HAS_INDEX(array, i, is_array)) {
+ if (i in array) {
var element = array[i];
if (%_Call(f, receiver, element, i, array)) return true;
}
@@ -1146,9 +1130,8 @@
function InnerArrayEvery(f, receiver, array, length) {
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
- var is_array = IS_ARRAY(array);
for (var i = 0; i < length; i++) {
- if (HAS_INDEX(array, i, is_array)) {
+ if (i in array) {
var element = array[i];
if (!%_Call(f, receiver, element, i, array)) return false;
}
@@ -1176,9 +1159,8 @@
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);
for (var i = 0; i < length; i++) {
- if (HAS_INDEX(array, i, is_array)) {
+ if (i in array) {
var element = array[i];
%CreateDataProperty(result, i, %_Call(f, receiver, element, i, array));
}
@@ -1317,11 +1299,10 @@
throw MakeTypeError(kCalledNonCallable, callback);
}
- var is_array = IS_ARRAY(array);
var i = 0;
find_initial: if (argumentsLength < 2) {
for (; i < length; i++) {
- if (HAS_INDEX(array, i, is_array)) {
+ if (i in array) {
current = array[i++];
break find_initial;
}
@@ -1330,7 +1311,7 @@
}
for (; i < length; i++) {
- if (HAS_INDEX(array, i, is_array)) {
+ if (i in array) {
var element = array[i];
current = callback(current, element, i, array);
}
@@ -1357,11 +1338,10 @@
throw MakeTypeError(kCalledNonCallable, callback);
}
- var is_array = IS_ARRAY(array);
var i = length - 1;
find_initial: if (argumentsLength < 2) {
for (; i >= 0; i--) {
- if (HAS_INDEX(array, i, is_array)) {
+ if (i in array) {
current = array[i--];
break find_initial;
}
@@ -1370,7 +1350,7 @@
}
for (; i >= 0; i--) {
- if (HAS_INDEX(array, i, is_array)) {
+ if (i in array) {
var element = array[i];
current = callback(current, element, i, array);
}
@@ -1651,6 +1631,12 @@
return array;
}
+
+function ArraySpecies() {
+ return this;
+}
+
+
// -------------------------------------------------------------------
// Set up non-enumerable constructor property on the Array.prototype
@@ -1666,6 +1652,7 @@
fill: true,
find: true,
findIndex: true,
+ includes: true,
keys: true,
};
@@ -1725,6 +1712,8 @@
"includes", getFunction("includes", ArrayIncludes, 1),
]);
+utils.InstallGetter(GlobalArray, speciesSymbol, ArraySpecies);
+
%FinishArrayPrototypeSetup(GlobalArray.prototype);
// The internal Array prototype doesn't need to be fancy, since it's never
@@ -1784,10 +1773,6 @@
to.InnerArraySort = InnerArraySort;
to.InnerArrayToLocaleString = InnerArrayToLocaleString;
to.PackedArrayReverse = PackedArrayReverse;
- to.Stack = Stack;
- to.StackHas = StackHas;
- to.StackPush = StackPush;
- to.StackPop = StackPop;
});
%InstallToContext([
diff --git a/src/js/arraybuffer.js b/src/js/arraybuffer.js
index e739960..b602dcb 100644
--- a/src/js/arraybuffer.js
+++ b/src/js/arraybuffer.js
@@ -16,6 +16,7 @@
var MaxSimple;
var MinSimple;
var SpeciesConstructor;
+var speciesSymbol = utils.ImportNow("species_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
@@ -84,6 +85,13 @@
return result;
}
+
+function ArrayBufferSpecies() {
+ return this;
+}
+
+utils.InstallGetter(GlobalArrayBuffer, speciesSymbol, ArrayBufferSpecies);
+
utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength",
ArrayBufferGetByteLen);
diff --git a/src/js/collection.js b/src/js/collection.js
index 0d7195d..bbb7ed2 100644
--- a/src/js/collection.js
+++ b/src/js/collection.js
@@ -19,6 +19,7 @@
var MapIterator;
var NumberIsNaN;
var SetIterator;
+var speciesSymbol = utils.ImportNow("species_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
@@ -255,6 +256,12 @@
}
}
+
+function SetSpecies() {
+ return this;
+}
+
+
// -------------------------------------------------------------------
%SetCode(GlobalSet, SetConstructor);
@@ -266,6 +273,8 @@
%FunctionSetLength(SetForEach, 1);
+utils.InstallGetter(GlobalSet, speciesSymbol, SetSpecies);
+
// Set up the non-enumerable functions on the Set prototype object.
utils.InstallGetter(GlobalSet.prototype, "size", SetGetSize);
utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
@@ -435,6 +444,11 @@
}
}
+
+function MapSpecies() {
+ return this;
+}
+
// -------------------------------------------------------------------
%SetCode(GlobalMap, MapConstructor);
@@ -446,6 +460,8 @@
%FunctionSetLength(MapForEach, 1);
+utils.InstallGetter(GlobalMap, speciesSymbol, MapSpecies);
+
// Set up the non-enumerable functions on the Map prototype object.
utils.InstallGetter(GlobalMap.prototype, "size", MapGetSize);
utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
diff --git a/src/js/harmony-regexp-exec.js b/src/js/harmony-regexp-exec.js
deleted file mode 100644
index e2eece9..0000000
--- a/src/js/harmony-regexp-exec.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2012 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) {
-
-%CheckIsBootstrapping();
-
-// -------------------------------------------------------------------
-// Imports
-
-var GlobalRegExp = global.RegExp;
-var RegExpSubclassExecJS = utils.ImportNow("RegExpSubclassExecJS");
-var RegExpSubclassMatch = utils.ImportNow("RegExpSubclassMatch");
-var RegExpSubclassReplace = utils.ImportNow("RegExpSubclassReplace");
-var RegExpSubclassSearch = utils.ImportNow("RegExpSubclassSearch");
-var RegExpSubclassSplit = utils.ImportNow("RegExpSubclassSplit");
-var RegExpSubclassTest = utils.ImportNow("RegExpSubclassTest");
-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.OverrideFunction(GlobalRegExp.prototype, "exec",
- RegExpSubclassExecJS, true);
-utils.OverrideFunction(GlobalRegExp.prototype, matchSymbol,
- RegExpSubclassMatch, true);
-utils.OverrideFunction(GlobalRegExp.prototype, replaceSymbol,
- RegExpSubclassReplace, true);
-utils.OverrideFunction(GlobalRegExp.prototype, searchSymbol,
- RegExpSubclassSearch, true);
-utils.OverrideFunction(GlobalRegExp.prototype, splitSymbol,
- RegExpSubclassSplit, true);
-utils.OverrideFunction(GlobalRegExp.prototype, "test",
- RegExpSubclassTest, true);
-
-})
diff --git a/src/js/harmony-species.js b/src/js/harmony-species.js
deleted file mode 100644
index 426ac46..0000000
--- a/src/js/harmony-species.js
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 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, extrasUtils) {
-
-"use strict";
-
-%CheckIsBootstrapping();
-
-var GlobalArray = global.Array;
-// It is important that this file is run after src/js/typedarray.js,
-// otherwise GlobalTypedArray would be Object, and we would break
-// old versions of Zepto.
-var GlobalTypedArray = global.Uint8Array.__proto__;
-var GlobalMap = global.Map;
-var GlobalSet = global.Set;
-var GlobalArrayBuffer = global.ArrayBuffer;
-var GlobalPromise = global.Promise;
-var GlobalRegExp = global.RegExp;
-var speciesSymbol = utils.ImportNow("species_symbol");
-
-function ArraySpecies() {
- return this;
-}
-
-function TypedArraySpecies() {
- return this;
-}
-
-function MapSpecies() {
- return this;
-}
-
-function SetSpecies() {
- return this;
-}
-
-function ArrayBufferSpecies() {
- return this;
-}
-
-function PromiseSpecies() {
- return this;
-}
-
-function RegExpSpecies() {
- return this;
-}
-
-utils.InstallGetter(GlobalArray, speciesSymbol, ArraySpecies, DONT_ENUM);
-utils.InstallGetter(GlobalTypedArray, speciesSymbol, TypedArraySpecies, DONT_ENUM);
-utils.InstallGetter(GlobalMap, speciesSymbol, MapSpecies, DONT_ENUM);
-utils.InstallGetter(GlobalSet, speciesSymbol, SetSpecies, DONT_ENUM);
-utils.InstallGetter(GlobalArrayBuffer, speciesSymbol, ArrayBufferSpecies,
- DONT_ENUM);
-utils.InstallGetter(GlobalPromise, speciesSymbol, PromiseSpecies, DONT_ENUM);
-utils.InstallGetter(GlobalRegExp, speciesSymbol, RegExpSpecies, DONT_ENUM);
-
-});
diff --git a/src/js/harmony-unicode-regexps.js b/src/js/harmony-unicode-regexps.js
deleted file mode 100644
index 16d06ba..0000000
--- a/src/js/harmony-unicode-regexps.js
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2014 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 GlobalRegExp = global.RegExp;
-var GlobalRegExpPrototype = GlobalRegExp.prototype;
-var MakeTypeError;
-
-utils.Import(function(from) {
- MakeTypeError = from.MakeTypeError;
-});
-
-// -------------------------------------------------------------------
-
-// ES6 21.2.5.15.
-function RegExpGetUnicode() {
- if (!IS_REGEXP(this)) {
- // TODO(littledan): Remove this RegExp compat workaround
- if (this === GlobalRegExpPrototype) {
- %IncrementUseCounter(kRegExpPrototypeUnicodeGetter);
- return UNDEFINED;
- }
- throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode");
- }
- return TO_BOOLEAN(REGEXP_UNICODE(this));
-}
-%SetForceInlineFlag(RegExpGetUnicode);
-
-utils.InstallGetter(GlobalRegExp.prototype, 'unicode', RegExpGetUnicode);
-
-})
diff --git a/src/js/i18n.js b/src/js/i18n.js
index 7c9535b..6c769a7 100644
--- a/src/js/i18n.js
+++ b/src/js/i18n.js
@@ -21,7 +21,6 @@
var ArrayJoin;
var ArrayPush;
var FLAG_intl_extra;
-var GlobalBoolean = global.Boolean;
var GlobalDate = global.Date;
var GlobalNumber = global.Number;
var GlobalRegExp = global.RegExp;
@@ -31,7 +30,6 @@
var InternalArray = utils.InternalArray;
var InternalRegExpMatch;
var InternalRegExpReplace
-var IsFinite;
var IsNaN;
var MakeError;
var MakeRangeError;
@@ -51,7 +49,6 @@
ArrayIndexOf = from.ArrayIndexOf;
ArrayJoin = from.ArrayJoin;
ArrayPush = from.ArrayPush;
- IsFinite = from.IsFinite;
IsNaN = from.IsNaN;
MakeError = from.MakeError;
MakeRangeError = from.MakeRangeError;
@@ -285,7 +282,7 @@
var matcher = options.localeMatcher;
if (!IS_UNDEFINED(matcher)) {
- matcher = GlobalString(matcher);
+ matcher = TO_STRING(matcher);
if (matcher !== 'lookup' && matcher !== 'best fit') {
throw MakeRangeError(kLocaleMatcher, matcher);
}
@@ -366,13 +363,13 @@
var value = options[property];
switch (type) {
case 'boolean':
- value = GlobalBoolean(value);
+ value = TO_BOOLEAN(value);
break;
case 'string':
- value = GlobalString(value);
+ value = TO_STRING(value);
break;
case 'number':
- value = GlobalNumber(value);
+ value = TO_NUMBER(value);
break;
default:
throw MakeError(kWrongValueType);
@@ -523,7 +520,7 @@
var extension = '';
var updateExtension = function updateExtension(key, value) {
- return '-' + key + '-' + GlobalString(value);
+ return '-' + key + '-' + TO_STRING(value);
}
var updateProperty = function updateProperty(property, type, value) {
@@ -742,7 +739,7 @@
return localeID;
}
- var localeString = GlobalString(localeID);
+ var localeString = TO_STRING(localeID);
if (isValidLanguageTag(localeString) === false) {
throw MakeRangeError(kInvalidLanguageTag, localeString);
@@ -1078,7 +1075,7 @@
*/
function compare(collator, x, y) {
return %InternalCompare(%GetImplFromInitializedIntlObject(collator),
- GlobalString(x), GlobalString(y));
+ TO_STRING(x), TO_STRING(y));
};
@@ -1102,8 +1099,8 @@
function getNumberOption(options, property, min, max, fallback) {
var value = options[property];
if (!IS_UNDEFINED(value)) {
- value = GlobalNumber(value);
- if (IsNaN(value) || value < min || value > max) {
+ value = TO_NUMBER(value);
+ if (NUMBER_IS_NAN(value) || value < min || value > max) {
throw MakeRangeError(kPropertyValueOutOfRange, property);
}
return %math_floor(value);
@@ -1348,7 +1345,7 @@
*/
function IntlParseNumber(formatter, value) {
return %InternalNumberParse(%GetImplFromInitializedIntlObject(formatter),
- GlobalString(value));
+ TO_STRING(value));
}
AddBoundMethod(Intl.NumberFormat, 'format', formatNumber, 1, 'numberformat');
@@ -1755,7 +1752,7 @@
dateMs = TO_NUMBER(dateValue);
}
- if (!IsFinite(dateMs)) throw MakeRangeError(kDateRange);
+ if (!NUMBER_IS_FINITE(dateMs)) throw MakeRangeError(kDateRange);
return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter),
new GlobalDate(dateMs));
@@ -1770,7 +1767,7 @@
*/
function IntlParseDate(formatter, value) {
return %InternalDateParse(%GetImplFromInitializedIntlObject(formatter),
- GlobalString(value));
+ TO_STRING(value));
}
@@ -1927,7 +1924,7 @@
*/
function adoptText(iterator, text) {
%BreakIteratorAdoptText(%GetImplFromInitializedIntlObject(iterator),
- GlobalString(text));
+ TO_STRING(text));
}
@@ -1991,6 +1988,23 @@
'dateformattime': UNDEFINED,
};
+function clearDefaultObjects() {
+ defaultObjects['dateformatall'] = UNDEFINED;
+ defaultObjects['dateformatdate'] = UNDEFINED;
+ defaultObjects['dateformattime'] = UNDEFINED;
+}
+
+var date_cache_version = 0;
+
+function checkDateCacheCurrent() {
+ var new_date_cache_version = %DateCacheVersion();
+ if (new_date_cache_version == date_cache_version) {
+ return;
+ }
+ date_cache_version = new_date_cache_version;
+
+ clearDefaultObjects();
+}
/**
* Returns cached or newly created instance of a given service.
@@ -1999,6 +2013,7 @@
function cachedOrNewService(service, locales, options, defaults) {
var useOptions = (IS_UNDEFINED(defaults)) ? options : defaults;
if (IS_UNDEFINED(locales) && IS_UNDEFINED(options)) {
+ checkDateCacheCurrent();
if (IS_UNDEFINED(defaultObjects[service])) {
defaultObjects[service] = new savedObjects[service](locales, useOptions);
}
diff --git a/src/js/json.js b/src/js/json.js
deleted file mode 100644
index c6dbed9..0000000
--- a/src/js/json.js
+++ /dev/null
@@ -1,297 +0,0 @@
-// Copyright 2009 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 GlobalDate = global.Date;
-var GlobalJSON = global.JSON;
-var GlobalSet = global.Set;
-var InternalArray = utils.InternalArray;
-var MakeTypeError;
-var MaxSimple;
-var MinSimple;
-var ObjectHasOwnProperty;
-var Stack;
-var StackHas;
-var StackPop;
-var StackPush;
-var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
-
-utils.Import(function(from) {
- MakeTypeError = from.MakeTypeError;
- MaxSimple = from.MaxSimple;
- MinSimple = from.MinSimple;
- ObjectHasOwnProperty = from.ObjectHasOwnProperty;
- Stack = from.Stack;
- StackHas = from.StackHas;
- StackPop = from.StackPop;
- StackPush = from.StackPush;
-});
-
-// -------------------------------------------------------------------
-
-function CreateDataProperty(o, p, v) {
- var desc = {value: v, enumerable: true, writable: true, configurable: true};
- return %reflect_define_property(o, p, desc);
-}
-
-
-function InternalizeJSONProperty(holder, name, reviver) {
- var val = holder[name];
- if (IS_RECEIVER(val)) {
- if (%is_arraylike(val)) {
- var length = TO_LENGTH(val.length);
- for (var i = 0; i < length; i++) {
- var newElement =
- InternalizeJSONProperty(val, %_NumberToString(i), reviver);
- if (IS_UNDEFINED(newElement)) {
- %reflect_delete_property(val, i);
- } else {
- CreateDataProperty(val, i, newElement);
- }
- }
- } else {
- var keys = %object_keys(val);
- for (var i = 0; i < keys.length; i++) {
- var p = keys[i];
- var newElement = InternalizeJSONProperty(val, p, reviver);
- if (IS_UNDEFINED(newElement)) {
- %reflect_delete_property(val, p);
- } else {
- CreateDataProperty(val, p, newElement);
- }
- }
- }
- }
- return %_Call(reviver, holder, name, val);
-}
-
-
-function JSONParse(text, reviver) {
- var unfiltered = %ParseJson(text);
- if (IS_CALLABLE(reviver)) {
- return InternalizeJSONProperty({'': unfiltered}, '', reviver);
- } else {
- return unfiltered;
- }
-}
-
-
-function SerializeArray(value, replacer, stack, indent, gap) {
- if (StackHas(stack, value)) throw MakeTypeError(kCircularStructure);
- StackPush(stack, value);
- var stepback = indent;
- indent += gap;
- var partial = new InternalArray();
- var len = TO_LENGTH(value.length);
- for (var i = 0; i < len; i++) {
- var strP = JSONSerialize(%_NumberToString(i), value, replacer, stack,
- indent, gap);
- if (IS_UNDEFINED(strP)) {
- strP = "null";
- }
- partial.push(strP);
- }
- var final;
- if (gap == "") {
- final = "[" + partial.join(",") + "]";
- } else if (partial.length > 0) {
- var separator = ",\n" + indent;
- final = "[\n" + indent + partial.join(separator) + "\n" +
- stepback + "]";
- } else {
- final = "[]";
- }
- StackPop(stack);
- return final;
-}
-
-
-function SerializeObject(value, replacer, stack, indent, gap) {
- if (StackHas(stack, value)) throw MakeTypeError(kCircularStructure);
- StackPush(stack, value);
- var stepback = indent;
- indent += gap;
- var partial = new InternalArray();
- if (IS_ARRAY(replacer)) {
- var length = replacer.length;
- for (var i = 0; i < length; i++) {
- var p = replacer[i];
- var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
- if (!IS_UNDEFINED(strP)) {
- var member = %QuoteJSONString(p) + ":";
- if (gap != "") member += " ";
- member += strP;
- partial.push(member);
- }
- }
- } else {
- var keys = %object_keys(value);
- for (var i = 0; i < keys.length; i++) {
- var p = keys[i];
- var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
- if (!IS_UNDEFINED(strP)) {
- var member = %QuoteJSONString(p) + ":";
- if (gap != "") member += " ";
- member += strP;
- partial.push(member);
- }
- }
- }
- var final;
- if (gap == "") {
- final = "{" + partial.join(",") + "}";
- } else if (partial.length > 0) {
- var separator = ",\n" + indent;
- final = "{\n" + indent + partial.join(separator) + "\n" +
- stepback + "}";
- } else {
- final = "{}";
- }
- StackPop(stack);
- return final;
-}
-
-
-function JSONSerialize(key, holder, replacer, stack, indent, gap) {
- var value = holder[key];
- if (IS_RECEIVER(value)) {
- var toJSON = value.toJSON;
- if (IS_CALLABLE(toJSON)) {
- value = %_Call(toJSON, value, key);
- }
- }
- if (IS_CALLABLE(replacer)) {
- value = %_Call(replacer, holder, key, value);
- }
- if (IS_STRING(value)) {
- return %QuoteJSONString(value);
- } else if (IS_NUMBER(value)) {
- return JSON_NUMBER_TO_STRING(value);
- } else if (IS_BOOLEAN(value)) {
- return value ? "true" : "false";
- } else if (IS_NULL(value)) {
- return "null";
- } else if (IS_RECEIVER(value) && !IS_CALLABLE(value)) {
- // Non-callable object. If it's a primitive wrapper, it must be unwrapped.
- if (%is_arraylike(value)) {
- return SerializeArray(value, replacer, stack, indent, gap);
- } else if (IS_NUMBER_WRAPPER(value)) {
- value = TO_NUMBER(value);
- return JSON_NUMBER_TO_STRING(value);
- } else if (IS_STRING_WRAPPER(value)) {
- return %QuoteJSONString(TO_STRING(value));
- } else if (IS_BOOLEAN_WRAPPER(value)) {
- return %_ValueOf(value) ? "true" : "false";
- } else {
- return SerializeObject(value, replacer, stack, indent, gap);
- }
- }
- // Undefined or a callable object.
- return UNDEFINED;
-}
-
-
-function JSONStringify(value, replacer, space) {
- if (arguments.length === 1 && !IS_PROXY(value)) {
- return %BasicJSONStringify(value);
- }
- if (!IS_CALLABLE(replacer) && %is_arraylike(replacer)) {
- var property_list = new InternalArray();
- var seen_properties = new GlobalSet();
- var length = TO_LENGTH(replacer.length);
- for (var i = 0; i < length; i++) {
- var v = replacer[i];
- var item;
- if (IS_STRING(v)) {
- item = v;
- } else if (IS_NUMBER(v)) {
- item = %_NumberToString(v);
- } else if (IS_STRING_WRAPPER(v) || IS_NUMBER_WRAPPER(v)) {
- item = TO_STRING(v);
- } else {
- continue;
- }
- if (!seen_properties.has(item)) {
- property_list.push(item);
- seen_properties.add(item);
- }
- }
- replacer = property_list;
- }
- if (IS_OBJECT(space)) {
- // Unwrap 'space' if it is wrapped
- if (IS_NUMBER_WRAPPER(space)) {
- space = TO_NUMBER(space);
- } else if (IS_STRING_WRAPPER(space)) {
- space = TO_STRING(space);
- }
- }
- var gap;
- if (IS_NUMBER(space)) {
- space = MaxSimple(0, MinSimple(TO_INTEGER(space), 10));
- gap = %_SubString(" ", 0, space);
- } else if (IS_STRING(space)) {
- if (space.length > 10) {
- gap = %_SubString(space, 0, 10);
- } else {
- gap = space;
- }
- } else {
- gap = "";
- }
- if (!IS_CALLABLE(replacer) && !property_list && !gap && !IS_PROXY(value)) {
- return %BasicJSONStringify(value);
- }
- return JSONSerialize('', {'': value}, replacer, new Stack(), "", gap);
-}
-
-// -------------------------------------------------------------------
-
-%AddNamedProperty(GlobalJSON, toStringTagSymbol, "JSON", READ_ONLY | DONT_ENUM);
-
-// Set up non-enumerable properties of the JSON object.
-utils.InstallFunctions(GlobalJSON, DONT_ENUM, [
- "parse", JSONParse,
- "stringify", JSONStringify
-]);
-
-// -------------------------------------------------------------------
-// Date.toJSON
-
-// 20.3.4.37 Date.prototype.toJSON ( key )
-function DateToJSON(key) {
- var o = TO_OBJECT(this);
- var tv = TO_PRIMITIVE_NUMBER(o);
- if (IS_NUMBER(tv) && !NUMBER_IS_FINITE(tv)) {
- return null;
- }
- return o.toISOString();
-}
-
-// Set up non-enumerable functions of the Date prototype object.
-utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [
- "toJSON", DateToJSON
-]);
-
-// -------------------------------------------------------------------
-// JSON Builtins
-
-function JsonSerializeAdapter(key, object) {
- var holder = {};
- holder[key] = object;
- // No need to pass the actual holder since there is no replacer function.
- return JSONSerialize(key, holder, UNDEFINED, new Stack(), "", "");
-}
-
-%InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]);
-
-})
diff --git a/src/js/macros.py b/src/js/macros.py
index 3cc2d6c..c6ed019 100644
--- a/src/js/macros.py
+++ b/src/js/macros.py
@@ -110,7 +110,6 @@
macro NUMBER_IS_FINITE(arg) = (%_IsSmi(%IS_VAR(arg)) || ((arg == arg) && (arg != 1/0) && (arg != -1/0)));
macro TO_BOOLEAN(arg) = (!!(arg));
macro TO_INTEGER(arg) = (%_ToInteger(arg));
-macro TO_INTEGER_MAP_MINUS_ZERO(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToIntegerMapMinusZero(arg));
macro TO_INT32(arg) = ((arg) | 0);
macro TO_UINT32(arg) = ((arg) >>> 0);
macro INVERT_NEG_ZERO(arg) = ((arg) + 0);
@@ -124,7 +123,6 @@
macro TO_NAME(arg) = (%_ToName(arg));
macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null");
macro HAS_OWN_PROPERTY(obj, key) = (%_Call(ObjectHasOwnProperty, obj, key));
-macro HAS_INDEX(array, index, is_array) = ((is_array && %_HasFastPackedElements(%IS_VAR(array)) && (index < array.length)) || (index in array));
# Private names.
macro IS_PRIVATE(sym) = (%SymbolIsPrivate(sym));
diff --git a/src/js/math.js b/src/js/math.js
index f8ad6b1..74d3aa6 100644
--- a/src/js/math.js
+++ b/src/js/math.js
@@ -16,7 +16,6 @@
var GlobalFloat64Array = global.Float64Array;
var GlobalMath = global.Math;
var GlobalObject = global.Object;
-var InternalArray = utils.InternalArray;
var NaN = %GetRootNaN();
var nextRandomIndex = 0;
var randomNumbers = UNDEFINED;
@@ -30,25 +29,6 @@
return (x > 0) ? x : 0 - x;
}
-// ECMA 262 - 15.8.2.5
-// The naming of y and x matches the spec, as does the order in which
-// ToNumber (valueOf) is called.
-function MathAtan2JS(y, x) {
- y = +y;
- x = +x;
- return %MathAtan2(y, x);
-}
-
-// ECMA 262 - 15.8.2.8
-function MathExp(x) {
- return %MathExpRT(TO_NUMBER(x));
-}
-
-// ECMA 262 - 15.8.2.10
-function MathLog(x) {
- return %_MathLogRT(TO_NUMBER(x));
-}
-
// ECMA 262 - 15.8.2.13
function MathPowJS(x, y) {
return %_MathPow(TO_NUMBER(x), TO_NUMBER(y));
@@ -63,7 +43,11 @@
// first two elements are reserved for the PRNG state.
if (nextRandomIndex <= kRandomNumberStart) {
randomNumbers = %GenerateRandomNumbers(randomNumbers);
- nextRandomIndex = randomNumbers.length;
+ if (%_IsTypedArray(randomNumbers)) {
+ nextRandomIndex = %_TypedArrayGetLength(randomNumbers);
+ } else {
+ nextRandomIndex = randomNumbers.length;
+ }
}
return randomNumbers[--nextRandomIndex];
}
@@ -71,7 +55,7 @@
function MathRandomRaw() {
if (nextRandomIndex <= kRandomNumberStart) {
randomNumbers = %GenerateRandomNumbers(randomNumbers);
- nextRandomIndex = randomNumbers.length;
+ nextRandomIndex = %_TypedArrayGetLength(randomNumbers);
}
return %_DoubleLo(randomNumbers[--nextRandomIndex]) & 0x3FFFFFFF;
}
@@ -90,9 +74,9 @@
x = TO_NUMBER(x);
// Idempotent for NaN, +/-0 and +/-Infinity.
if (x === 0 || !NUMBER_IS_FINITE(x)) return x;
- if (x > 0) return MathLog(x + %math_sqrt(x * x + 1));
+ if (x > 0) return %math_log(x + %math_sqrt(x * x + 1));
// This is to prevent numerical errors caused by large negative x.
- return -MathLog(-x + %math_sqrt(x * x + 1));
+ return -%math_log(-x + %math_sqrt(x * x + 1));
}
// ES6 draft 09-27-13, section 20.2.2.3.
@@ -101,17 +85,7 @@
if (x < 1) return NaN;
// Idempotent for NaN and +Infinity.
if (!NUMBER_IS_FINITE(x)) return x;
- return MathLog(x + %math_sqrt(x + 1) * %math_sqrt(x - 1));
-}
-
-// ES6 draft 09-27-13, section 20.2.2.7.
-function MathAtanh(x) {
- x = TO_NUMBER(x);
- // Idempotent for +/-0.
- if (x === 0) return x;
- // Returns NaN for NaN and +/- Infinity.
- if (!NUMBER_IS_FINITE(x)) return NaN;
- return 0.5 * MathLog((1 + x) / (1 - x));
+ return %math_log(x + %math_sqrt(x + 1) * %math_sqrt(x - 1));
}
// ES6 draft 09-27-13, section 20.2.2.17.
@@ -143,29 +117,6 @@
return %math_sqrt(sum) * max;
}
-// ES6 draft 09-27-13, section 20.2.2.9.
-// Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm
-// Using initial approximation adapted from Kahan's cbrt and 4 iterations
-// of Newton's method.
-function MathCbrt(x) {
- x = TO_NUMBER(x);
- if (x == 0 || !NUMBER_IS_FINITE(x)) return x;
- return x >= 0 ? CubeRoot(x) : -CubeRoot(-x);
-}
-
-macro NEWTON_ITERATION_CBRT(x, approx)
- (1.0 / 3.0) * (x / (approx * approx) + 2 * approx);
-endmacro
-
-function CubeRoot(x) {
- var approx_hi = %math_floor(%_DoubleHi(x) / 3) + 0x2A9F7893;
- var approx = %_ConstructDouble(approx_hi | 0, 0);
- approx = NEWTON_ITERATION_CBRT(x, approx);
- approx = NEWTON_ITERATION_CBRT(x, approx);
- approx = NEWTON_ITERATION_CBRT(x, approx);
- return NEWTON_ITERATION_CBRT(x, approx);
-}
-
// -------------------------------------------------------------------
%InstallToContext([
@@ -176,15 +127,6 @@
// Set up math constants.
utils.InstallConstants(GlobalMath, [
- // ECMA-262, section 15.8.1.1.
- "E", 2.7182818284590452354,
- // ECMA-262, section 15.8.1.2.
- "LN10", 2.302585092994046,
- // ECMA-262, section 15.8.1.3.
- "LN2", 0.6931471805599453,
- // ECMA-262, section 15.8.1.4.
- "LOG2E", 1.4426950408889634,
- "LOG10E", 0.4342944819032518,
"PI", 3.1415926535897932,
"SQRT1_2", 0.7071067811865476,
"SQRT2", 1.4142135623730951
@@ -195,20 +137,13 @@
utils.InstallFunctions(GlobalMath, DONT_ENUM, [
"random", MathRandom,
"abs", MathAbs,
- "exp", MathExp,
- "log", MathLog,
- "atan2", MathAtan2JS,
"pow", MathPowJS,
"sign", MathSign,
"asinh", MathAsinh,
"acosh", MathAcosh,
- "atanh", MathAtanh,
"hypot", MathHypot,
- "cbrt", MathCbrt
]);
-%SetForceInlineFlag(MathAbs);
-%SetForceInlineFlag(MathAtan2JS);
%SetForceInlineFlag(MathRandom);
%SetForceInlineFlag(MathSign);
@@ -217,7 +152,6 @@
utils.Export(function(to) {
to.MathAbs = MathAbs;
- to.MathExp = MathExp;
to.IntRandom = MathRandomRaw;
});
diff --git a/src/js/messages.js b/src/js/messages.js
index b5c4b56..24d8d2b 100644
--- a/src/js/messages.js
+++ b/src/js/messages.js
@@ -41,7 +41,6 @@
var Script = utils.ImportNow("Script");
var stackTraceSymbol = utils.ImportNow("stack_trace_symbol");
var StringIndexOf;
-var StringSubstring;
var SymbolToString;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
var Uint16x8ToString;
@@ -59,7 +58,6 @@
Int8x16ToString = from.Int8x16ToString;
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
StringIndexOf = from.StringIndexOf;
- StringSubstring = from.StringSubstring;
SymbolToString = from.SymbolToString;
Uint16x8ToString = from.Uint16x8ToString;
Uint32x4ToString = from.Uint32x4ToString;
@@ -214,210 +212,26 @@
var start_position = %MessageGetStartPosition(message);
var location = script.locationFromPosition(start_position, true);
if (location == null) return "";
- return location.sourceText();
-}
-
-
-/**
- * Find a line number given a specific source position.
- * @param {number} position The source position.
- * @return {number} 0 if input too small, -1 if input too large,
- else the line number.
- */
-function ScriptLineFromPosition(position) {
- var lower = 0;
- var upper = this.lineCount() - 1;
- var line_ends = this.line_ends;
-
- // We'll never find invalid positions so bail right away.
- if (position > line_ends[upper]) {
- return -1;
- }
-
- // This means we don't have to safe-guard indexing line_ends[i - 1].
- if (position <= line_ends[0]) {
- return 0;
- }
-
- // Binary search to find line # from position range.
- while (upper >= 1) {
- var i = (lower + upper) >> 1;
-
- if (position > line_ends[i]) {
- lower = i + 1;
- } else if (position <= line_ends[i - 1]) {
- upper = i - 1;
- } else {
- return i;
- }
- }
-
- return -1;
+ return location.sourceText;
}
/**
* Get information on a specific source position.
+ * Returns an object with the following following properties:
+ * script : script object for the source
+ * line : source line number
+ * column : source column within the line
+ * position : position within the source
+ * sourceText : a string containing the current line
* @param {number} position The source position
* @param {boolean} include_resource_offset Set to true to have the resource
* offset added to the location
- * @return {SourceLocation}
- * If line is negative or not in the source null is returned.
+ * @return If line is negative or not in the source null is returned.
*/
function ScriptLocationFromPosition(position,
include_resource_offset) {
- var line = this.lineFromPosition(position);
- if (line == -1) return null;
-
- // Determine start, end and column.
- var line_ends = this.line_ends;
- var start = line == 0 ? 0 : line_ends[line - 1] + 1;
- var end = line_ends[line];
- if (end > 0 && %_StringCharAt(this.source, end - 1) === '\r') {
- end--;
- }
- var column = position - start;
-
- // Adjust according to the offset within the resource.
- if (include_resource_offset) {
- line += this.line_offset;
- if (line == this.line_offset) {
- column += this.column_offset;
- }
- }
-
- return new SourceLocation(this, position, line, column, start, end);
-}
-
-
-/**
- * Get information on a specific source line and column possibly offset by a
- * fixed source position. This function is used to find a source position from
- * a line and column position. The fixed source position offset is typically
- * used to find a source position in a function based on a line and column in
- * the source for the function alone. The offset passed will then be the
- * start position of the source for the function within the full script source.
- * @param {number} opt_line The line within the source. Default value is 0
- * @param {number} opt_column The column in within the line. Default value is 0
- * @param {number} opt_offset_position The offset from the begining of the
- * source from where the line and column calculation starts.
- * Default value is 0
- * @return {SourceLocation}
- * If line is negative or not in the source null is returned.
- */
-function ScriptLocationFromLine(opt_line, opt_column, opt_offset_position) {
- // Default is the first line in the script. Lines in the script is relative
- // to the offset within the resource.
- var line = 0;
- if (!IS_UNDEFINED(opt_line)) {
- line = opt_line - this.line_offset;
- }
-
- // Default is first column. If on the first line add the offset within the
- // resource.
- var column = opt_column || 0;
- if (line == 0) {
- column -= this.column_offset;
- }
-
- var offset_position = opt_offset_position || 0;
- if (line < 0 || column < 0 || offset_position < 0) return null;
- if (line == 0) {
- return this.locationFromPosition(offset_position + column, false);
- } else {
- // Find the line where the offset position is located.
- var offset_line = this.lineFromPosition(offset_position);
-
- if (offset_line == -1 || offset_line + line >= this.lineCount()) {
- return null;
- }
-
- return this.locationFromPosition(
- this.line_ends[offset_line + line - 1] + 1 + column); // line > 0 here.
- }
-}
-
-
-/**
- * Get a slice of source code from the script. The boundaries for the slice is
- * specified in lines.
- * @param {number} opt_from_line The first line (zero bound) in the slice.
- * Default is 0
- * @param {number} opt_to_column The last line (zero bound) in the slice (non
- * inclusive). Default is the number of lines in the script
- * @return {SourceSlice} The source slice or null of the parameters where
- * invalid
- */
-function ScriptSourceSlice(opt_from_line, opt_to_line) {
- var from_line = IS_UNDEFINED(opt_from_line) ? this.line_offset
- : opt_from_line;
- var to_line = IS_UNDEFINED(opt_to_line) ? this.line_offset + this.lineCount()
- : opt_to_line;
-
- // Adjust according to the offset within the resource.
- from_line -= this.line_offset;
- to_line -= this.line_offset;
- if (from_line < 0) from_line = 0;
- if (to_line > this.lineCount()) to_line = this.lineCount();
-
- // Check parameters.
- if (from_line >= this.lineCount() ||
- to_line < 0 ||
- from_line > to_line) {
- return null;
- }
-
- var line_ends = this.line_ends;
- var from_position = from_line == 0 ? 0 : line_ends[from_line - 1] + 1;
- var to_position = to_line == 0 ? 0 : line_ends[to_line - 1] + 1;
-
- // Return a source slice with line numbers re-adjusted to the resource.
- return new SourceSlice(this,
- from_line + this.line_offset,
- to_line + this.line_offset,
- from_position, to_position);
-}
-
-
-function ScriptSourceLine(opt_line) {
- // Default is the first line in the script. Lines in the script are relative
- // to the offset within the resource.
- var line = 0;
- if (!IS_UNDEFINED(opt_line)) {
- line = opt_line - this.line_offset;
- }
-
- // Check parameter.
- if (line < 0 || this.lineCount() <= line) {
- return null;
- }
-
- // Return the source line.
- var line_ends = this.line_ends;
- var start = line == 0 ? 0 : line_ends[line - 1] + 1;
- var end = line_ends[line];
- return %_Call(StringSubstring, this.source, start, end);
-}
-
-
-/**
- * Returns the number of source lines.
- * @return {number}
- * Number of source lines.
- */
-function ScriptLineCount() {
- // Return number of source lines.
- return this.line_ends.length;
-}
-
-
-/**
- * Returns the position of the nth line end.
- * @return {number}
- * Zero-based position of the nth line end in the script.
- */
-function ScriptLineEnd(n) {
- return this.line_ends[n];
+ return %ScriptPositionInfo(this, position, !!include_resource_offset);
}
@@ -442,113 +256,15 @@
"name",
"source_url",
"source_mapping_url",
- "line_ends",
"line_offset",
"column_offset"
], [
- "lineFromPosition", ScriptLineFromPosition,
"locationFromPosition", ScriptLocationFromPosition,
- "locationFromLine", ScriptLocationFromLine,
- "sourceSlice", ScriptSourceSlice,
- "sourceLine", ScriptSourceLine,
- "lineCount", ScriptLineCount,
"nameOrSourceURL", ScriptNameOrSourceURL,
- "lineEnd", ScriptLineEnd
]
);
-/**
- * Class for source location. A source location is a position within some
- * source with the following properties:
- * script : script object for the source
- * line : source line number
- * column : source column within the line
- * position : position within the source
- * start : position of start of source context (inclusive)
- * end : position of end of source context (not inclusive)
- * Source text for the source context is the character interval
- * [start, end[. In most cases end will point to a newline character.
- * It might point just past the final position of the source if the last
- * source line does not end with a newline character.
- * @param {Script} script The Script object for which this is a location
- * @param {number} position Source position for the location
- * @param {number} line The line number for the location
- * @param {number} column The column within the line for the location
- * @param {number} start Source position for start of source context
- * @param {number} end Source position for end of source context
- * @constructor
- */
-function SourceLocation(script, position, line, column, start, end) {
- this.script = script;
- this.position = position;
- this.line = line;
- this.column = column;
- this.start = start;
- this.end = end;
-}
-
-
-/**
- * Get the source text for a SourceLocation
- * @return {String}
- * Source text for this location.
- */
-function SourceLocationSourceText() {
- return %_Call(StringSubstring, this.script.source, this.start, this.end);
-}
-
-
-utils.SetUpLockedPrototype(SourceLocation,
- ["script", "position", "line", "column", "start", "end"],
- ["sourceText", SourceLocationSourceText]
-);
-
-
-/**
- * Class for a source slice. A source slice is a part of a script source with
- * the following properties:
- * script : script object for the source
- * from_line : line number for the first line in the slice
- * to_line : source line number for the last line in the slice
- * from_position : position of the first character in the slice
- * to_position : position of the last character in the slice
- * The to_line and to_position are not included in the slice, that is the lines
- * in the slice are [from_line, to_line[. Likewise the characters in the slice
- * are [from_position, to_position[.
- * @param {Script} script The Script object for the source slice
- * @param {number} from_line
- * @param {number} to_line
- * @param {number} from_position
- * @param {number} to_position
- * @constructor
- */
-function SourceSlice(script, from_line, to_line, from_position, to_position) {
- this.script = script;
- this.from_line = from_line;
- this.to_line = to_line;
- this.from_position = from_position;
- this.to_position = to_position;
-}
-
-/**
- * Get the source text for a SourceSlice
- * @return {String} Source text for this slice. The last line will include
- * the line terminating characters (if any)
- */
-function SourceSliceSourceText() {
- return %_Call(StringSubstring,
- this.script.source,
- this.from_position,
- this.to_position);
-}
-
-utils.SetUpLockedPrototype(SourceSlice,
- ["script", "from_line", "to_line", "from_position", "to_position"],
- ["sourceText", SourceSliceSourceText]
-);
-
-
function GetStackTraceLine(recv, fun, pos, isGlobal) {
return new CallSite(recv, fun, pos, false).toString();
}
@@ -559,8 +275,8 @@
function CallSite(receiver, fun, pos, strict_mode) {
// For wasm frames, receiver is the wasm object and fun is the function index
// instead of an actual function.
- if (!IS_FUNCTION(fun) && !IS_NUMBER(fun)) {
- throw MakeTypeError(kCallSiteExpectsFunction, typeof fun);
+ if (!IS_FUNCTION(fun) && !%IsWasmObject(receiver)) {
+ throw MakeTypeError(kCallSiteExpectsFunction, typeof receiver, typeof fun);
}
if (IS_UNDEFINED(new.target)) {
@@ -630,12 +346,6 @@
function CallSiteGetFunctionName() {
// See if the function knows its own name
CheckCallSite(this, "getFunctionName");
- if (HAS_PRIVATE(this, callSiteWasmObjectSymbol)) {
- var wasm = GET_PRIVATE(this, callSiteWasmObjectSymbol);
- var func_index = GET_PRIVATE(this, callSiteWasmFunctionIndexSymbol);
- if (IS_UNDEFINED(wasm)) return "<WASM>";
- return %WasmGetFunctionName(wasm, func_index);
- }
return %CallSiteGetFunctionNameRT(this);
}
@@ -679,7 +389,8 @@
var funName = this.getFunctionName();
var funcIndex = GET_PRIVATE(this, callSiteWasmFunctionIndexSymbol);
var pos = this.getPosition();
- return funName + " (<WASM>:" + funcIndex + ":" + pos + ")";
+ if (IS_NULL(funName)) funName = "<WASM UNNAMED>";
+ return funName + " (<WASM>[" + funcIndex + "]+" + pos + ")";
}
var fileName;
diff --git a/src/js/prologue.js b/src/js/prologue.js
index b352eb1..79fe9b7 100644
--- a/src/js/prologue.js
+++ b/src/js/prologue.js
@@ -266,9 +266,6 @@
imports_from_experimental(exports_container);
}
- utils.CreateDoubleResultArray();
- utils.CreateDoubleResultArray = UNDEFINED;
-
utils.Export = UNDEFINED;
utils.PostDebug = UNDEFINED;
utils.PostExperimentals = UNDEFINED;
@@ -281,9 +278,6 @@
imports(exports_container);
}
- utils.CreateDoubleResultArray();
- utils.CreateDoubleResultArray = UNDEFINED;
-
exports_container = UNDEFINED;
utils.Export = UNDEFINED;
diff --git a/src/js/promise.js b/src/js/promise.js
index 42b772b..5e8c460 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -21,10 +21,13 @@
utils.ImportNow("promise_reject_reactions_symbol");
var promiseFulfillReactionsSymbol =
utils.ImportNow("promise_fulfill_reactions_symbol");
+var promiseDeferredReactionsSymbol =
+ utils.ImportNow("promise_deferred_reactions_symbol");
var promiseRawSymbol = utils.ImportNow("promise_raw_symbol");
var promiseStateSymbol = utils.ImportNow("promise_state_symbol");
var promiseResultSymbol = utils.ImportNow("promise_result_symbol");
var SpeciesConstructor;
+var speciesSymbol = utils.ImportNow("species_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
@@ -51,7 +54,7 @@
var resolve = value => {
if (alreadyResolved === true) return;
alreadyResolved = true;
- FulfillPromise(promise, value);
+ ResolvePromise(promise, value);
};
// ES#sec-promise-reject-functions
@@ -72,25 +75,25 @@
// ES#sec-promise-executor
// Promise ( executor )
-var GlobalPromise = function Promise(resolver) {
- if (resolver === promiseRawSymbol) {
+var GlobalPromise = function Promise(executor) {
+ if (executor === promiseRawSymbol) {
return %_NewObject(GlobalPromise, new.target);
}
if (IS_UNDEFINED(new.target)) throw MakeTypeError(kNotAPromise, this);
- if (!IS_CALLABLE(resolver)) {
- throw MakeTypeError(kResolverNotAFunction, resolver);
+ if (!IS_CALLABLE(executor)) {
+ throw MakeTypeError(kResolverNotAFunction, executor);
}
var promise = PromiseInit(%_NewObject(GlobalPromise, new.target));
var callbacks = CreateResolvingFunctions(promise);
-
+ var debug_is_active = DEBUG_IS_ACTIVE;
try {
- %DebugPushPromise(promise, Promise);
- resolver(callbacks.resolve, callbacks.reject);
+ if (debug_is_active) %DebugPushPromise(promise, Promise);
+ executor(callbacks.resolve, callbacks.reject);
} catch (e) {
%_Call(callbacks.reject, UNDEFINED, e);
} finally {
- %DebugPopPromise();
+ if (debug_is_active) %DebugPopPromise();
}
return promise;
@@ -98,11 +101,33 @@
// Core functionality.
-function PromiseSet(promise, status, value, onResolve, onReject) {
+function PromiseSet(promise, status, value) {
SET_PRIVATE(promise, promiseStateSymbol, status);
SET_PRIVATE(promise, promiseResultSymbol, value);
- SET_PRIVATE(promise, promiseFulfillReactionsSymbol, onResolve);
- SET_PRIVATE(promise, promiseRejectReactionsSymbol, onReject);
+
+ // There are 3 possible states for the resolve, reject symbols when we add
+ // a new callback --
+ // 1) UNDEFINED -- This is the zero state where there is no callback
+ // registered. When we see this state, we directly attach the callbacks to
+ // the symbol.
+ // 2) !IS_ARRAY -- There is a single callback directly attached to the
+ // symbols. We need to create a new array to store additional callbacks.
+ // 3) IS_ARRAY -- There are multiple callbacks already registered,
+ // therefore we can just push the new callback to the existing array.
+ SET_PRIVATE(promise, promiseFulfillReactionsSymbol, UNDEFINED);
+ SET_PRIVATE(promise, promiseRejectReactionsSymbol, UNDEFINED);
+
+ // There are 2 possible states for this symbol --
+ // 1) UNDEFINED -- This is the zero state, no deferred object is
+ // attached to this symbol. When we want to add a new deferred we
+ // directly attach it to this symbol.
+ // 2) symbol with attached deferred object -- New deferred objects
+ // are not attached to this symbol, but instead they are directly
+ // attached to the resolve, reject callback arrays. At this point,
+ // the deferred symbol's state is stale, and the deferreds should be
+ // read from the reject, resolve callbacks.
+ SET_PRIVATE(promise, promiseDeferredReactionsSymbol, UNDEFINED);
+
return promise;
}
@@ -114,38 +139,46 @@
}
function PromiseInit(promise) {
- return PromiseSet(
- promise, kPending, UNDEFINED, new InternalArray, new InternalArray)
+ return PromiseSet(promise, kPending, UNDEFINED);
}
-function PromiseDone(promise, status, value, promiseQueue) {
+function FulfillPromise(promise, status, value, promiseQueue) {
if (GET_PRIVATE(promise, promiseStateSymbol) === kPending) {
var tasks = GET_PRIVATE(promise, promiseQueue);
- if (tasks.length) PromiseEnqueue(value, tasks, status);
+ if (!IS_UNDEFINED(tasks)) {
+ var tasks = GET_PRIVATE(promise, promiseQueue);
+ var deferreds = GET_PRIVATE(promise, promiseDeferredReactionsSymbol);
+ PromiseEnqueue(value, tasks, deferreds, status);
+ }
PromiseSet(promise, status, value);
}
}
function PromiseHandle(value, handler, deferred) {
+ var debug_is_active = DEBUG_IS_ACTIVE;
try {
- %DebugPushPromise(deferred.promise, PromiseHandle);
+ if (debug_is_active) %DebugPushPromise(deferred.promise, PromiseHandle);
var result = handler(value);
deferred.resolve(result);
} catch (exception) {
try { deferred.reject(exception); } catch (e) { }
} finally {
- %DebugPopPromise();
+ if (debug_is_active) %DebugPopPromise();
}
}
-function PromiseEnqueue(value, tasks, status) {
+function PromiseEnqueue(value, tasks, deferreds, status) {
var id, name, instrumenting = DEBUG_IS_ACTIVE;
%EnqueueMicrotask(function() {
if (instrumenting) {
%DebugAsyncTaskEvent({ type: "willHandle", id: id, name: name });
}
- for (var i = 0; i < tasks.length; i += 2) {
- PromiseHandle(value, tasks[i], tasks[i + 1])
+ if (IS_ARRAY(tasks)) {
+ for (var i = 0; i < tasks.length; i += 2) {
+ PromiseHandle(value, tasks[i], tasks[i + 1]);
+ }
+ } else {
+ PromiseHandle(value, tasks, deferreds);
}
if (instrumenting) {
%DebugAsyncTaskEvent({ type: "didHandle", id: id, name: name });
@@ -158,6 +191,33 @@
}
}
+function PromiseAttachCallbacks(promise, deferred, onResolve, onReject) {
+ var maybeResolveCallbacks =
+ GET_PRIVATE(promise, promiseFulfillReactionsSymbol);
+ if (IS_UNDEFINED(maybeResolveCallbacks)) {
+ SET_PRIVATE(promise, promiseFulfillReactionsSymbol, onResolve);
+ SET_PRIVATE(promise, promiseRejectReactionsSymbol, onReject);
+ SET_PRIVATE(promise, promiseDeferredReactionsSymbol, deferred);
+ } else if (!IS_ARRAY(maybeResolveCallbacks)) {
+ var resolveCallbacks = new InternalArray();
+ var rejectCallbacks = new InternalArray();
+ var existingDeferred = GET_PRIVATE(promise, promiseDeferredReactionsSymbol);
+
+ resolveCallbacks.push(
+ maybeResolveCallbacks, existingDeferred, onResolve, deferred);
+ rejectCallbacks.push(GET_PRIVATE(promise, promiseRejectReactionsSymbol),
+ existingDeferred,
+ onReject,
+ deferred);
+
+ SET_PRIVATE(promise, promiseFulfillReactionsSymbol, resolveCallbacks);
+ SET_PRIVATE(promise, promiseRejectReactionsSymbol, rejectCallbacks);
+ } else {
+ maybeResolveCallbacks.push(onResolve, deferred);
+ GET_PRIVATE(promise, promiseRejectReactionsSymbol).push(onReject, deferred);
+ }
+}
+
function PromiseIdResolveHandler(x) { return x }
function PromiseIdRejectHandler(r) { throw r }
@@ -177,29 +237,58 @@
return new GlobalPromise(PromiseNopResolver)
}
-// ES#sec-fulfillpromise
-// FulfillPromise ( promise, value)
-function FulfillPromise(promise, x) {
- if (x === promise) {
- return RejectPromise(promise, MakeTypeError(kPromiseCyclic, x));
+// ES#sec-promise-resolve-functions
+// Promise Resolve Functions, steps 6-13
+function ResolvePromise(promise, resolution) {
+ if (resolution === promise) {
+ return RejectPromise(promise, MakeTypeError(kPromiseCyclic, resolution));
}
- if (IS_RECEIVER(x)) {
+ if (IS_RECEIVER(resolution)) {
// 25.4.1.3.2 steps 8-12
try {
- var then = x.then;
+ var then = resolution.then;
} catch (e) {
return RejectPromise(promise, e);
}
+
+ // Resolution is a native promise and if it's already resolved or
+ // rejected, shortcircuit the resolution procedure by directly
+ // reusing the value from the promise.
+ if (IsPromise(resolution) && then === PromiseThen) {
+ var thenableState = GET_PRIVATE(resolution, promiseStateSymbol);
+ if (thenableState === kFulfilled) {
+ // This goes inside the if-else to save one symbol lookup in
+ // the slow path.
+ var thenableValue = GET_PRIVATE(resolution, promiseResultSymbol);
+ FulfillPromise(promise, kFulfilled, thenableValue,
+ promiseFulfillReactionsSymbol);
+ SET_PRIVATE(promise, promiseHasHandlerSymbol, true);
+ return;
+ } else if (thenableState === kRejected) {
+ var thenableValue = GET_PRIVATE(resolution, promiseResultSymbol);
+ if (!HAS_DEFINED_PRIVATE(resolution, promiseHasHandlerSymbol)) {
+ // Promise has already been rejected, but had no handler.
+ // Revoke previously triggered reject event.
+ %PromiseRevokeReject(resolution);
+ }
+ RejectPromise(promise, thenableValue);
+ SET_PRIVATE(resolution, promiseHasHandlerSymbol, true);
+ return;
+ }
+ }
+
if (IS_CALLABLE(then)) {
// PromiseResolveThenableJob
- var id, name, instrumenting = DEBUG_IS_ACTIVE;
+ var id;
+ var name = "PromiseResolveThenableJob";
+ var instrumenting = DEBUG_IS_ACTIVE;
%EnqueueMicrotask(function() {
if (instrumenting) {
%DebugAsyncTaskEvent({ type: "willHandle", id: id, name: name });
}
var callbacks = CreateResolvingFunctions(promise);
try {
- %_Call(then, x, callbacks.resolve, callbacks.reject);
+ %_Call(then, resolution, callbacks.resolve, callbacks.reject);
} catch (e) {
%_Call(callbacks.reject, UNDEFINED, e);
}
@@ -209,28 +298,27 @@
});
if (instrumenting) {
id = ++lastMicrotaskId;
- name = "PromseResolveThenableJob";
%DebugAsyncTaskEvent({ type: "enqueue", id: id, name: name });
}
return;
}
}
- PromiseDone(promise, kFulfilled, x, promiseFulfillReactionsSymbol);
+ FulfillPromise(promise, kFulfilled, resolution, promiseFulfillReactionsSymbol);
}
// ES#sec-rejectpromise
// RejectPromise ( promise, reason )
-function RejectPromise(promise, r) {
+function RejectPromise(promise, reason) {
// Check promise status to confirm that this reject has an effect.
// Call runtime for callbacks to the debugger or for unhandled reject.
if (GET_PRIVATE(promise, promiseStateSymbol) === kPending) {
var debug_is_active = DEBUG_IS_ACTIVE;
if (debug_is_active ||
!HAS_DEFINED_PRIVATE(promise, promiseHasHandlerSymbol)) {
- %PromiseRejectEvent(promise, r, debug_is_active);
+ %PromiseRejectEvent(promise, reason, debug_is_active);
}
}
- PromiseDone(promise, kRejected, r, promiseRejectReactionsSymbol)
+ FulfillPromise(promise, kRejected, reason, promiseRejectReactionsSymbol)
}
// ES#sec-newpromisecapability
@@ -318,14 +406,11 @@
var deferred = NewPromiseCapability(constructor);
switch (status) {
case kPending:
- GET_PRIVATE(this, promiseFulfillReactionsSymbol).push(onResolve,
- deferred);
- GET_PRIVATE(this, promiseRejectReactionsSymbol).push(onReject, deferred);
+ PromiseAttachCallbacks(this, deferred, onResolve, onReject);
break;
case kFulfilled:
PromiseEnqueue(GET_PRIVATE(this, promiseResultSymbol),
- [onResolve, deferred],
- kFulfilled);
+ onResolve, deferred, kFulfilled);
break;
case kRejected:
if (!HAS_DEFINED_PRIVATE(this, promiseHasHandlerSymbol)) {
@@ -334,8 +419,7 @@
%PromiseRevokeReject(this);
}
PromiseEnqueue(GET_PRIVATE(this, promiseResultSymbol),
- [onReject, deferred],
- kRejected);
+ onReject, deferred, kRejected);
break;
}
// Mark this promise as having handler.
@@ -444,20 +528,30 @@
// Utility for debugger
+function PromiseHasUserDefinedRejectHandlerCheck(handler, deferred) {
+ if (handler !== PromiseIdRejectHandler) {
+ var combinedDeferred = GET_PRIVATE(handler, promiseCombinedDeferredSymbol);
+ if (IS_UNDEFINED(combinedDeferred)) return true;
+ if (PromiseHasUserDefinedRejectHandlerRecursive(combinedDeferred.promise)) {
+ return true;
+ }
+ } else if (PromiseHasUserDefinedRejectHandlerRecursive(deferred.promise)) {
+ return true;
+ }
+ return false;
+}
+
function PromiseHasUserDefinedRejectHandlerRecursive(promise) {
var queue = GET_PRIVATE(promise, promiseRejectReactionsSymbol);
+ var deferreds = GET_PRIVATE(promise, promiseDeferredReactionsSymbol);
if (IS_UNDEFINED(queue)) return false;
- for (var i = 0; i < queue.length; i += 2) {
- var handler = queue[i];
- if (handler !== PromiseIdRejectHandler) {
- var deferred = GET_PRIVATE(handler, promiseCombinedDeferredSymbol);
- if (IS_UNDEFINED(deferred)) return true;
- if (PromiseHasUserDefinedRejectHandlerRecursive(deferred.promise)) {
+ if (!IS_ARRAY(queue)) {
+ return PromiseHasUserDefinedRejectHandlerCheck(queue, deferreds);
+ } else {
+ for (var i = 0; i < queue.length; i += 2) {
+ if (PromiseHasUserDefinedRejectHandlerCheck(queue[i], queue[i + 1])) {
return true;
}
- } else if (PromiseHasUserDefinedRejectHandlerRecursive(
- queue[i + 1].promise)) {
- return true;
}
}
return false;
@@ -470,6 +564,11 @@
return PromiseHasUserDefinedRejectHandlerRecursive(this);
};
+
+function PromiseSpecies() {
+ return this;
+}
+
// -------------------------------------------------------------------
// Install exported functions.
@@ -484,6 +583,8 @@
"resolve", PromiseResolve
]);
+utils.InstallGetter(GlobalPromise, speciesSymbol, PromiseSpecies);
+
utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
"then", PromiseThen,
"catch", PromiseCatch
@@ -495,7 +596,7 @@
"promise_create", PromiseCreate,
"promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler,
"promise_reject", RejectPromise,
- "promise_resolve", FulfillPromise,
+ "promise_resolve", ResolvePromise,
"promise_then", PromiseThen,
"promise_create_rejected", PromiseCreateRejected,
"promise_create_resolved", PromiseCreateResolved
@@ -506,7 +607,7 @@
// promise without having to hold on to those closures forever.
utils.InstallFunctions(extrasUtils, 0, [
"createPromise", PromiseCreate,
- "resolvePromise", FulfillPromise,
+ "resolvePromise", ResolvePromise,
"rejectPromise", RejectPromise
]);
diff --git a/src/js/regexp.js b/src/js/regexp.js
index 719a081..6b7cf48 100644
--- a/src/js/regexp.js
+++ b/src/js/regexp.js
@@ -22,6 +22,7 @@
var matchSymbol = utils.ImportNow("match_symbol");
var replaceSymbol = utils.ImportNow("replace_symbol");
var searchSymbol = utils.ImportNow("search_symbol");
+var speciesSymbol = utils.ImportNow("species_symbol");
var splitSymbol = utils.ImportNow("split_symbol");
var SpeciesConstructor;
@@ -323,10 +324,10 @@
// not a '?'. But see https://code.google.com/p/v8/issues/detail?id=3560
var regexp = this;
var source = REGEXP_SOURCE(regexp);
- if (regexp.length >= 3 &&
- %_StringCharCodeAt(regexp, 0) == 46 && // '.'
- %_StringCharCodeAt(regexp, 1) == 42 && // '*'
- %_StringCharCodeAt(regexp, 2) != 63) { // '?'
+ if (source.length >= 3 &&
+ %_StringCharCodeAt(source, 0) == 46 && // '.'
+ %_StringCharCodeAt(source, 1) == 42 && // '*'
+ %_StringCharCodeAt(source, 2) != 63) { // '?'
regexp = TrimRegExp(regexp);
}
// matchIndices is either null or the RegExpLastMatchInfo array.
@@ -537,22 +538,6 @@
%FunctionRemovePrototype(RegExpSubclassSplit);
-// Legacy implementation of RegExp.prototype[Symbol.match] which
-// doesn't properly call the underlying exec method
-function RegExpMatch(string) {
- if (!IS_REGEXP(this)) {
- throw MakeTypeError(kIncompatibleMethodReceiver,
- "RegExp.prototype.@@match", this);
- }
- var subject = TO_STRING(string);
-
- if (!REGEXP_GLOBAL(this)) return RegExpExecNoTests(this, subject, 0);
- this.lastIndex = 0;
- var result = %StringMatch(subject, this, RegExpLastMatchInfo);
- return result;
-}
-
-
// ES#sec-regexp.prototype-@@match
// RegExp.prototype [ @@match ] ( string )
function RegExpSubclassMatch(string) {
@@ -952,19 +937,6 @@
%FunctionRemovePrototype(RegExpSubclassReplace);
-// Legacy implementation of RegExp.prototype[Symbol.search] which
-// doesn't properly use the overridden exec method
-function RegExpSearch(string) {
- if (!IS_REGEXP(this)) {
- throw MakeTypeError(kIncompatibleMethodReceiver,
- "RegExp.prototype.@@search", this);
- }
- var match = DoRegExpExec(this, TO_STRING(string), 0);
- if (match) return match[CAPTURE0];
- return -1;
-}
-
-
// ES#sec-regexp.prototype-@@search
// RegExp.prototype [ @@search ] ( string )
function RegExpSubclassSearch(string) {
@@ -1132,6 +1104,27 @@
}
%SetForceInlineFlag(RegExpGetSticky);
+
+// ES6 21.2.5.15.
+function RegExpGetUnicode() {
+ if (!IS_REGEXP(this)) {
+ // TODO(littledan): Remove this RegExp compat workaround
+ if (this === GlobalRegExpPrototype) {
+ %IncrementUseCounter(kRegExpPrototypeUnicodeGetter);
+ return UNDEFINED;
+ }
+ throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode");
+ }
+ return TO_BOOLEAN(REGEXP_UNICODE(this));
+}
+%SetForceInlineFlag(RegExpGetUnicode);
+
+
+function RegExpSpecies() {
+ return this;
+}
+
+
// -------------------------------------------------------------------
%FunctionSetInstanceClassName(GlobalRegExp, 'RegExp');
@@ -1141,15 +1134,17 @@
GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
%SetCode(GlobalRegExp, RegExpConstructor);
+utils.InstallGetter(GlobalRegExp, speciesSymbol, RegExpSpecies);
+
utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
- "exec", RegExpExecJS,
- "test", RegExpTest,
+ "exec", RegExpSubclassExecJS,
+ "test", RegExpSubclassTest,
"toString", RegExpToString,
"compile", RegExpCompileJS,
- matchSymbol, RegExpMatch,
- replaceSymbol, RegExpReplace,
- searchSymbol, RegExpSearch,
- splitSymbol, RegExpSplit,
+ matchSymbol, RegExpSubclassMatch,
+ replaceSymbol, RegExpSubclassReplace,
+ searchSymbol, RegExpSubclassSearch,
+ splitSymbol, RegExpSubclassSplit,
]);
utils.InstallGetter(GlobalRegExp.prototype, 'flags', RegExpGetFlags);
@@ -1158,6 +1153,7 @@
utils.InstallGetter(GlobalRegExp.prototype, 'multiline', RegExpGetMultiline);
utils.InstallGetter(GlobalRegExp.prototype, 'source', RegExpGetSource);
utils.InstallGetter(GlobalRegExp.prototype, 'sticky', RegExpGetSticky);
+utils.InstallGetter(GlobalRegExp.prototype, 'unicode', RegExpGetUnicode);
// 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.
@@ -1232,12 +1228,6 @@
to.RegExpExec = DoRegExpExec;
to.RegExpInitialize = RegExpInitialize;
to.RegExpLastMatchInfo = RegExpLastMatchInfo;
- to.RegExpSubclassExecJS = RegExpSubclassExecJS;
- to.RegExpSubclassMatch = RegExpSubclassMatch;
- to.RegExpSubclassReplace = RegExpSubclassReplace;
- to.RegExpSubclassSearch = RegExpSubclassSearch;
- to.RegExpSubclassSplit = RegExpSubclassSplit;
- to.RegExpSubclassTest = RegExpSubclassTest;
to.RegExpTest = RegExpTest;
});
diff --git a/src/js/runtime.js b/src/js/runtime.js
index a6a0b4d..216685f 100644
--- a/src/js/runtime.js
+++ b/src/js/runtime.js
@@ -16,7 +16,6 @@
%CheckIsBootstrapping();
-var FLAG_harmony_species;
var GlobalArray = global.Array;
var GlobalBoolean = global.Boolean;
var GlobalString = global.String;
@@ -30,10 +29,6 @@
speciesSymbol = from.species_symbol;
});
-utils.ImportFromExperimental(function(from) {
- FLAG_harmony_species = from.FLAG_harmony_species;
-});
-
// ----------------------------------------------------------------------------
@@ -44,7 +39,7 @@
function ToPositiveInteger(x, rangeErrorIndex) {
- var i = TO_INTEGER_MAP_MINUS_ZERO(x);
+ var i = TO_INTEGER(x) + 0;
if (i < 0) throw MakeRangeError(rangeErrorIndex);
return i;
}
@@ -65,35 +60,22 @@
// ES2015 7.3.20
-// For the fallback with --harmony-species off, there are two possible choices:
-// - "conservative": return defaultConstructor
-// - "not conservative": return object.constructor
-// This fallback path is only needed in the transition to ES2015, and the
-// choice is made simply to preserve the previous behavior so that we don't
-// have a three-step upgrade: old behavior, unspecified intermediate behavior,
-// and ES2015.
-// In some cases, we were "conservative" (e.g., ArrayBuffer, RegExp), and in
-// other cases we were "not conservative (e.g., TypedArray, Promise).
-function SpeciesConstructor(object, defaultConstructor, conservative) {
- if (FLAG_harmony_species) {
- var constructor = object.constructor;
- if (IS_UNDEFINED(constructor)) {
- return defaultConstructor;
- }
- if (!IS_RECEIVER(constructor)) {
- throw MakeTypeError(kConstructorNotReceiver);
- }
- var species = constructor[speciesSymbol];
- if (IS_NULL_OR_UNDEFINED(species)) {
- return defaultConstructor;
- }
- if (%IsConstructor(species)) {
- return species;
- }
- throw MakeTypeError(kSpeciesNotConstructor);
- } else {
- return conservative ? defaultConstructor : object.constructor;
+function SpeciesConstructor(object, defaultConstructor) {
+ var constructor = object.constructor;
+ if (IS_UNDEFINED(constructor)) {
+ return defaultConstructor;
}
+ if (!IS_RECEIVER(constructor)) {
+ throw MakeTypeError(kConstructorNotReceiver);
+ }
+ var species = constructor[speciesSymbol];
+ if (IS_NULL_OR_UNDEFINED(species)) {
+ return defaultConstructor;
+ }
+ if (%IsConstructor(species)) {
+ return species;
+ }
+ throw MakeTypeError(kSpeciesNotConstructor);
}
//----------------------------------------------------------------------------
diff --git a/src/js/string.js b/src/js/string.js
index badb2b4..d2eaa32 100644
--- a/src/js/string.js
+++ b/src/js/string.js
@@ -13,8 +13,6 @@
var ArrayJoin;
var GlobalRegExp = global.RegExp;
var GlobalString = global.String;
-var InternalArray = utils.InternalArray;
-var InternalPackedArray = utils.InternalPackedArray;
var IsRegExp;
var MakeRangeError;
var MakeTypeError;
@@ -520,25 +518,6 @@
return %StringToUpperCase(TO_STRING(this));
}
-// ES5, 15.5.4.20
-function StringTrimJS() {
- CHECK_OBJECT_COERCIBLE(this, "String.prototype.trim");
-
- return %StringTrim(TO_STRING(this), true, true);
-}
-
-function StringTrimLeft() {
- CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimLeft");
-
- return %StringTrim(TO_STRING(this), true, false);
-}
-
-function StringTrimRight() {
- CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimRight");
-
- return %StringTrim(TO_STRING(this), false, true);
-}
-
// ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1
function HtmlEscape(str) {
@@ -768,33 +747,6 @@
}
-// ES6 Draft 05-22-2014, section 21.1.2.2
-function StringFromCodePoint(_) { // length = 1
- "use strict";
- var code;
- var length = arguments.length;
- var index;
- var result = "";
- for (index = 0; index < length; index++) {
- code = arguments[index];
- if (!%_IsSmi(code)) {
- code = TO_NUMBER(code);
- }
- if (code < 0 || code > 0x10FFFF || code !== TO_INTEGER(code)) {
- throw MakeRangeError(kInvalidCodePoint, code);
- }
- if (code <= 0xFFFF) {
- result += %_StringCharFromCode(code);
- } else {
- code -= 0x10000;
- result += %_StringCharFromCode((code >>> 10) & 0x3FF | 0xD800);
- result += %_StringCharFromCode(code & 0x3FF | 0xDC00);
- }
- }
- return result;
-}
-
-
// -------------------------------------------------------------------
// String methods related to templates
@@ -823,7 +775,6 @@
// Set up the non-enumerable functions on the String object.
utils.InstallFunctions(GlobalString, DONT_ENUM, [
- "fromCodePoint", StringFromCodePoint,
"raw", StringRaw
]);
@@ -852,9 +803,6 @@
"toLocaleLowerCase", StringToLocaleLowerCase,
"toUpperCase", StringToUpperCaseJS,
"toLocaleUpperCase", StringToLocaleUpperCase,
- "trim", StringTrimJS,
- "trimLeft", StringTrimLeft,
- "trimRight", StringTrimRight,
"link", StringLink,
"anchor", StringAnchor,
diff --git a/src/js/symbol.js b/src/js/symbol.js
index 7365655..2e7cc53 100644
--- a/src/js/symbol.js
+++ b/src/js/symbol.js
@@ -17,6 +17,11 @@
utils.ImportNow("is_concat_spreadable_symbol");
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeTypeError;
+var matchSymbol = utils.ImportNow("match_symbol");
+var replaceSymbol = utils.ImportNow("replace_symbol");
+var searchSymbol = utils.ImportNow("search_symbol");
+var speciesSymbol = utils.ImportNow("species_symbol");
+var splitSymbol = utils.ImportNow("split_symbol");
var toPrimitiveSymbol = utils.ImportNow("to_primitive_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
@@ -78,11 +83,11 @@
"hasInstance", hasInstanceSymbol,
"isConcatSpreadable", isConcatSpreadableSymbol,
"iterator", iteratorSymbol,
- // TODO(yangguo): expose when implemented.
- // "match", matchSymbol,
- // "replace", replaceSymbol,
- // "search", searchSymbol,
- // "split, splitSymbol,
+ "match", matchSymbol,
+ "replace", replaceSymbol,
+ "search", searchSymbol,
+ "species", speciesSymbol,
+ "split", splitSymbol,
"toPrimitive", toPrimitiveSymbol,
"toStringTag", toStringTagSymbol,
"unscopables", unscopablesSymbol,
diff --git a/src/js/typedarray.js b/src/js/typedarray.js
index 18f6dde..8e7d9ee 100644
--- a/src/js/typedarray.js
+++ b/src/js/typedarray.js
@@ -47,6 +47,7 @@
var SpeciesConstructor;
var ToPositiveInteger;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
+var speciesSymbol = utils.ImportNow("species_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
macro TYPED_ARRAYS(FUNCTION)
@@ -68,6 +69,8 @@
TYPED_ARRAYS(DECLARE_GLOBALS)
+var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array);
+
utils.Import(function(from) {
ArrayValues = from.ArrayValues;
GetIterator = from.GetIterator;
@@ -329,42 +332,6 @@
}
%SetForceInlineFlag(TypedArraySubArray);
-function TypedArrayGetBuffer() {
- if (!IS_TYPEDARRAY(this)) {
- throw MakeTypeError(kIncompatibleMethodReceiver,
- "get TypedArray.prototype.buffer", this);
- }
- return %TypedArrayGetBuffer(this);
-}
-%SetForceInlineFlag(TypedArrayGetBuffer);
-
-function TypedArrayGetByteLength() {
- if (!IS_TYPEDARRAY(this)) {
- throw MakeTypeError(kIncompatibleMethodReceiver,
- "get TypedArray.prototype.byteLength", this);
- }
- return %_ArrayBufferViewGetByteLength(this);
-}
-%SetForceInlineFlag(TypedArrayGetByteLength);
-
-function TypedArrayGetByteOffset() {
- if (!IS_TYPEDARRAY(this)) {
- throw MakeTypeError(kIncompatibleMethodReceiver,
- "get TypedArray.prototype.byteOffset", this);
- }
- return %_ArrayBufferViewGetByteOffset(this);
-}
-%SetForceInlineFlag(TypedArrayGetByteOffset);
-
-function TypedArrayGetLength() {
- if (!IS_TYPEDARRAY(this)) {
- throw MakeTypeError(kIncompatibleMethodReceiver,
- "get TypedArray.prototype.length", this);
- }
- return %_TypedArrayGetLength(this);
-}
-%SetForceInlineFlag(TypedArrayGetLength);
-
function TypedArraySetFromArrayLike(target, source, sourceLength, offset) {
@@ -383,7 +350,7 @@
function TypedArraySetFromOverlappingTypedArray(target, source, offset) {
var sourceElementSize = source.BYTES_PER_ELEMENT;
var targetElementSize = target.BYTES_PER_ELEMENT;
- var sourceLength = source.length;
+ var sourceLength = %_TypedArrayGetLength(source);
// Copy left part.
function CopyLeftPart() {
@@ -403,7 +370,7 @@
}
var leftIndex = CopyLeftPart();
- // Copy rigth part;
+ // Copy right part;
function CopyRightPart() {
// First unmutated byte before the next write
var targetPtr =
@@ -447,7 +414,8 @@
TypedArraySetFromOverlappingTypedArray(this, obj, intOffset);
return;
case 2: // TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING
- TypedArraySetFromArrayLike(this, obj, obj.length, intOffset);
+ TypedArraySetFromArrayLike(this,
+ obj, %_TypedArrayGetLength(obj), intOffset);
return;
case 3: // TYPED_ARRAY_SET_NON_TYPED_ARRAY
var l = obj.length;
@@ -462,7 +430,7 @@
return;
}
l = TO_LENGTH(l);
- if (intOffset + l > this.length) {
+ if (intOffset + l > %_TypedArrayGetLength(this)) {
throw MakeRangeError(kTypedArraySetSourceTooLarge);
}
TypedArraySetFromArrayLike(this, obj, l, intOffset);
@@ -808,34 +776,31 @@
}
%FunctionSetLength(TypedArrayFrom, 1);
-function TypedArray() {
+// TODO(bmeurer): Migrate this to a proper builtin.
+function TypedArrayConstructor() {
if (IS_UNDEFINED(new.target)) {
throw MakeTypeError(kConstructorNonCallable, "TypedArray");
}
- if (new.target === TypedArray) {
+ if (new.target === GlobalTypedArray) {
throw MakeTypeError(kConstructAbstractClass, "TypedArray");
}
}
+function TypedArraySpecies() {
+ return this;
+}
+
// -------------------------------------------------------------------
-%FunctionSetPrototype(TypedArray, new GlobalObject());
-%AddNamedProperty(TypedArray.prototype,
- "constructor", TypedArray, DONT_ENUM);
-utils.InstallFunctions(TypedArray, DONT_ENUM, [
+%SetCode(GlobalTypedArray, TypedArrayConstructor);
+utils.InstallFunctions(GlobalTypedArray, DONT_ENUM, [
"from", TypedArrayFrom,
"of", TypedArrayOf
]);
-utils.InstallGetter(TypedArray.prototype, "buffer", TypedArrayGetBuffer);
-utils.InstallGetter(TypedArray.prototype, "byteOffset", TypedArrayGetByteOffset,
- DONT_ENUM | DONT_DELETE);
-utils.InstallGetter(TypedArray.prototype, "byteLength",
- TypedArrayGetByteLength, DONT_ENUM | DONT_DELETE);
-utils.InstallGetter(TypedArray.prototype, "length", TypedArrayGetLength,
- DONT_ENUM | DONT_DELETE);
-utils.InstallGetter(TypedArray.prototype, toStringTagSymbol,
+utils.InstallGetter(GlobalTypedArray, speciesSymbol, TypedArraySpecies);
+utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol,
TypedArrayGetToStringTag);
-utils.InstallFunctions(TypedArray.prototype, DONT_ENUM, [
+utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [
"subarray", TypedArraySubArray,
"set", TypedArraySet,
"copyWithin", TypedArrayCopyWithin,
@@ -859,15 +824,15 @@
"toLocaleString", TypedArrayToLocaleString
]);
-%AddNamedProperty(TypedArray.prototype, "toString", ArrayToString,
+%AddNamedProperty(GlobalTypedArray.prototype, "toString", ArrayToString,
DONT_ENUM);
macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
%SetCode(GlobalNAME, NAMEConstructor);
%FunctionSetPrototype(GlobalNAME, new GlobalObject());
- %InternalSetPrototype(GlobalNAME, TypedArray);
- %InternalSetPrototype(GlobalNAME.prototype, TypedArray.prototype);
+ %InternalSetPrototype(GlobalNAME, GlobalTypedArray);
+ %InternalSetPrototype(GlobalNAME.prototype, GlobalTypedArray.prototype);
%AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
READ_ONLY | DONT_ENUM | DONT_DELETE);
@@ -883,29 +848,6 @@
// --------------------------- DataView -----------------------------
-function DataViewGetBufferJS() {
- if (!IS_DATAVIEW(this)) {
- throw MakeTypeError(kIncompatibleMethodReceiver, 'DataView.buffer', this);
- }
- return %DataViewGetBuffer(this);
-}
-
-function DataViewGetByteOffset() {
- if (!IS_DATAVIEW(this)) {
- throw MakeTypeError(kIncompatibleMethodReceiver,
- 'DataView.byteOffset', this);
- }
- return %_ArrayBufferViewGetByteOffset(this);
-}
-
-function DataViewGetByteLength() {
- if (!IS_DATAVIEW(this)) {
- throw MakeTypeError(kIncompatibleMethodReceiver,
- 'DataView.byteLength', this);
- }
- return %_ArrayBufferViewGetByteLength(this);
-}
-
macro DATA_VIEW_TYPES(FUNCTION)
FUNCTION(Int8)
FUNCTION(Uint8)
@@ -944,21 +886,6 @@
DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
-// Setup the DataView constructor.
-%FunctionSetPrototype(GlobalDataView, new GlobalObject);
-
-// Set up constructor property on the DataView prototype.
-%AddNamedProperty(GlobalDataView.prototype, "constructor", GlobalDataView,
- DONT_ENUM);
-%AddNamedProperty(GlobalDataView.prototype, toStringTagSymbol, "DataView",
- READ_ONLY|DONT_ENUM);
-
-utils.InstallGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS);
-utils.InstallGetter(GlobalDataView.prototype, "byteOffset",
- DataViewGetByteOffset);
-utils.InstallGetter(GlobalDataView.prototype, "byteLength",
- DataViewGetByteLength);
-
utils.InstallFunctions(GlobalDataView.prototype, DONT_ENUM, [
"getInt8", DataViewGetInt8JS,
"setInt8", DataViewSetInt8JS,
diff --git a/src/js/uri.js b/src/js/uri.js
deleted file mode 100644
index 19bfbd3..0000000
--- a/src/js/uri.js
+++ /dev/null
@@ -1,234 +0,0 @@
-// Copyright 2006-2008 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.
-
-// This file contains support for URI manipulations written in
-// JavaScript.
-
-(function(global, utils) {
-
-"use strict";
-
-%CheckIsBootstrapping();
-
-//- ------------------------------------------------------------------
-// Imports
-
-var GlobalObject = global.Object;
-var InternalArray = utils.InternalArray;
-var MakeURIError;
-
-utils.Import(function(from) {
- MakeURIError = from.MakeURIError;
-});
-
-
-// -------------------------------------------------------------------
-// Define internal helper functions.
-
-function HexValueOf(code) {
- // 0-9
- if (code >= 48 && code <= 57) return code - 48;
- // A-F
- if (code >= 65 && code <= 70) return code - 55;
- // a-f
- if (code >= 97 && code <= 102) return code - 87;
-
- return -1;
-}
-
-function URIHexCharsToCharCode(highChar, lowChar) {
- var highCode = HexValueOf(highChar);
- var lowCode = HexValueOf(lowChar);
- if (highCode == -1 || lowCode == -1) throw MakeURIError();
- return (highCode << 4) | lowCode;
-}
-
-// Callers must ensure that |result| is a sufficiently long sequential
-// two-byte string!
-function URIDecodeOctets(octets, result, index) {
- var value;
- var o0 = octets[0];
- if (o0 < 0x80) {
- value = o0;
- } else if (o0 < 0xc2) {
- throw MakeURIError();
- } else {
- var o1 = octets[1];
- if (o0 < 0xe0) {
- var a = o0 & 0x1f;
- if ((o1 < 0x80) || (o1 > 0xbf)) throw MakeURIError();
- var b = o1 & 0x3f;
- value = (a << 6) + b;
- if (value < 0x80 || value > 0x7ff) throw MakeURIError();
- } else {
- var o2 = octets[2];
- if (o0 < 0xf0) {
- var a = o0 & 0x0f;
- if ((o1 < 0x80) || (o1 > 0xbf)) throw MakeURIError();
- var b = o1 & 0x3f;
- if ((o2 < 0x80) || (o2 > 0xbf)) throw MakeURIError();
- var c = o2 & 0x3f;
- value = (a << 12) + (b << 6) + c;
- if ((value < 0x800) || (value > 0xffff)) throw MakeURIError();
- } else {
- var o3 = octets[3];
- if (o0 < 0xf8) {
- var a = (o0 & 0x07);
- if ((o1 < 0x80) || (o1 > 0xbf)) throw MakeURIError();
- var b = (o1 & 0x3f);
- if ((o2 < 0x80) || (o2 > 0xbf)) {
- throw MakeURIError();
- }
- var c = (o2 & 0x3f);
- if ((o3 < 0x80) || (o3 > 0xbf)) throw MakeURIError();
- var d = (o3 & 0x3f);
- value = (a << 18) + (b << 12) + (c << 6) + d;
- if ((value < 0x10000) || (value > 0x10ffff)) throw MakeURIError();
- } else {
- throw MakeURIError();
- }
- }
- }
- }
- if (0xD800 <= value && value <= 0xDFFF) throw MakeURIError();
- if (value < 0x10000) {
- %_TwoByteSeqStringSetChar(index++, value, result);
- } else {
- %_TwoByteSeqStringSetChar(index++, (value >> 10) + 0xd7c0, result);
- %_TwoByteSeqStringSetChar(index++, (value & 0x3ff) + 0xdc00, result);
- }
- return index;
-}
-
-// ECMA-262, section 15.1.3
-function Decode(uri, reserved) {
- uri = TO_STRING(uri);
- var uriLength = uri.length;
- var one_byte = %NewString(uriLength, NEW_ONE_BYTE_STRING);
- var index = 0;
- var k = 0;
-
- // Optimistically assume one-byte string.
- for ( ; k < uriLength; k++) {
- var code = %_StringCharCodeAt(uri, k);
- if (code == 37) { // '%'
- if (k + 2 >= uriLength) throw MakeURIError();
- var cc = URIHexCharsToCharCode(%_StringCharCodeAt(uri, k+1),
- %_StringCharCodeAt(uri, k+2));
- if (cc >> 7) break; // Assumption wrong, two-byte string.
- if (reserved(cc)) {
- %_OneByteSeqStringSetChar(index++, 37, one_byte); // '%'.
- %_OneByteSeqStringSetChar(index++, %_StringCharCodeAt(uri, k+1),
- one_byte);
- %_OneByteSeqStringSetChar(index++, %_StringCharCodeAt(uri, k+2),
- one_byte);
- } else {
- %_OneByteSeqStringSetChar(index++, cc, one_byte);
- }
- k += 2;
- } else {
- if (code > 0x7f) break; // Assumption wrong, two-byte string.
- %_OneByteSeqStringSetChar(index++, code, one_byte);
- }
- }
-
- one_byte = %TruncateString(one_byte, index);
- if (k == uriLength) return one_byte;
-
- // Write into two byte string.
- var two_byte = %NewString(uriLength - k, NEW_TWO_BYTE_STRING);
- index = 0;
-
- for ( ; k < uriLength; k++) {
- var code = %_StringCharCodeAt(uri, k);
- if (code == 37) { // '%'
- if (k + 2 >= uriLength) throw MakeURIError();
- var cc = URIHexCharsToCharCode(%_StringCharCodeAt(uri, ++k),
- %_StringCharCodeAt(uri, ++k));
- if (cc >> 7) {
- var n = 0;
- while (((cc << ++n) & 0x80) != 0) { }
- if (n == 1 || n > 4) throw MakeURIError();
- var octets = new InternalArray(n);
- octets[0] = cc;
- if (k + 3 * (n - 1) >= uriLength) throw MakeURIError();
- for (var i = 1; i < n; i++) {
- if (uri[++k] != '%') throw MakeURIError();
- octets[i] = URIHexCharsToCharCode(%_StringCharCodeAt(uri, ++k),
- %_StringCharCodeAt(uri, ++k));
- }
- index = URIDecodeOctets(octets, two_byte, index);
- } else if (reserved(cc)) {
- %_TwoByteSeqStringSetChar(index++, 37, two_byte); // '%'.
- %_TwoByteSeqStringSetChar(index++, %_StringCharCodeAt(uri, k - 1),
- two_byte);
- %_TwoByteSeqStringSetChar(index++, %_StringCharCodeAt(uri, k),
- two_byte);
- } else {
- %_TwoByteSeqStringSetChar(index++, cc, two_byte);
- }
- } else {
- %_TwoByteSeqStringSetChar(index++, code, two_byte);
- }
- }
-
- two_byte = %TruncateString(two_byte, index);
- return one_byte + two_byte;
-}
-
-// -------------------------------------------------------------------
-// Define exported functions.
-
-// ECMA-262 - B.2.1.
-function URIEscapeJS(s) {
- return %URIEscape(s);
-}
-
-// ECMA-262 - B.2.2.
-function URIUnescapeJS(s) {
- return %URIUnescape(s);
-}
-
-// ECMA-262 - 15.1.3.1.
-function URIDecode(uri) {
- var reservedPredicate = function(cc) {
- // #$
- if (35 <= cc && cc <= 36) return true;
- // &
- if (cc == 38) return true;
- // +,
- if (43 <= cc && cc <= 44) return true;
- // /
- if (cc == 47) return true;
- // :;
- if (58 <= cc && cc <= 59) return true;
- // =
- if (cc == 61) return true;
- // ?@
- if (63 <= cc && cc <= 64) return true;
-
- return false;
- };
- return Decode(uri, reservedPredicate);
-}
-
-// ECMA-262 - 15.1.3.2.
-function URIDecodeComponent(component) {
- var reservedPredicate = function(cc) { return false; };
- return Decode(component, reservedPredicate);
-}
-
-// -------------------------------------------------------------------
-// Install exported functions.
-
-// Set up non-enumerable URI functions on the global object and set
-// their names.
-utils.InstallFunctions(global, DONT_ENUM, [
- "escape", URIEscapeJS,
- "unescape", URIUnescapeJS,
- "decodeURI", URIDecode,
- "decodeURIComponent", URIDecodeComponent
-]);
-
-})
diff --git a/src/js/v8natives.js b/src/js/v8natives.js
index 44be941..9e437a3 100644
--- a/src/js/v8natives.js
+++ b/src/js/v8natives.js
@@ -12,7 +12,6 @@
var GlobalArray = global.Array;
var GlobalNumber = global.Number;
var GlobalObject = global.Object;
-var InternalArray = utils.InternalArray;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeRangeError;
var MakeSyntaxError;
@@ -450,7 +449,6 @@
utils.Export(function(to) {
to.GetIterator = GetIterator;
to.GetMethod = GetMethod;
- to.IsFinite = GlobalIsFinite;
to.IsNaN = GlobalIsNaN;
to.NumberIsNaN = NumberIsNaN;
to.NumberIsInteger = NumberIsInteger;