Commit 5cb925e4 authored by yangguo's avatar yangguo Committed by Commit bot

Revert of Revert of Hook up more import/exports in natives. (patchset #1 id:1...

Revert of Revert of Hook up more import/exports in natives. (patchset #1 id:1 of https://codereview.chromium.org/1154743003/)

Reason for revert:
Unrelated failure that was uncovered by this CL has been fixed (https://codereview.chromium.org/1152243002/)

Original issue's description:
> Revert of Hook up more import/exports in natives. (patchset #3 id:40001 of https://codereview.chromium.org/1154483002/)
>
> Reason for revert:
> [Sheriff] Speculative revert for gc stress failures:
> http://build.chromium.org/p/client.v8/builders/V8%20Linux64%20GC%20Stress%20-%20custom%20snapshot/builds/481
>
> Original issue's description:
> > Hook up more import/exports in natives.
> >
> > R=jkummerow@chromium.org
> >
> > Committed: https://crrev.com/7a918ac9658d11778f39593bfcc19d7c506defd9
> > Cr-Commit-Position: refs/heads/master@{#28573}
> >
> > Committed: https://crrev.com/e13a39dd7f4062898709d7c68900677df0513995
> > Cr-Commit-Position: refs/heads/master@{#28578}
>
> TBR=jkummerow@chromium.org,erik.corry@gmail.com,yangguo@chromium.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://crrev.com/eb0024d1dbdda5f51b006dd54887404ee6c5cbfc
> Cr-Commit-Position: refs/heads/master@{#28584}

TBR=jkummerow@chromium.org,erik.corry@gmail.com,machenbach@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

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

Cr-Commit-Position: refs/heads/master@{#28608}
parent 61a5962b
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
var $iteratorCreateResultObject;
var $arrayValues; var $arrayValues;
(function(global, utils) { (function(global, utils) {
...@@ -124,16 +123,16 @@ function ArrayKeys() { ...@@ -124,16 +123,16 @@ function ArrayKeys() {
%FunctionSetPrototype(ArrayIterator, {__proto__: $iteratorPrototype}); %FunctionSetPrototype(ArrayIterator, {__proto__: $iteratorPrototype});
%FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator'); %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
$installFunctions(ArrayIterator.prototype, DONT_ENUM, [ utils.InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
'next', ArrayIteratorNext 'next', ArrayIteratorNext
]); ]);
$setFunctionName(ArrayIteratorIterator, symbolIterator); utils.SetFunctionName(ArrayIteratorIterator, symbolIterator);
%AddNamedProperty(ArrayIterator.prototype, symbolIterator, %AddNamedProperty(ArrayIterator.prototype, symbolIterator,
ArrayIteratorIterator, DONT_ENUM); ArrayIteratorIterator, DONT_ENUM);
%AddNamedProperty(ArrayIterator.prototype, symbolToStringTag, %AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
"Array Iterator", READ_ONLY | DONT_ENUM); "Array Iterator", READ_ONLY | DONT_ENUM);
$installFunctions(GlobalArray.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
// No 'values' since it breaks webcompat: http://crbug.com/409858 // No 'values' since it breaks webcompat: http://crbug.com/409858
'entries', ArrayEntries, 'entries', ArrayEntries,
'keys', ArrayKeys 'keys', ArrayKeys
...@@ -152,7 +151,13 @@ endmacro ...@@ -152,7 +151,13 @@ endmacro
TYPED_ARRAYS(EXTEND_TYPED_ARRAY) TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
$iteratorCreateResultObject = CreateIteratorResultObject; // -------------------------------------------------------------------
// Exports
utils.Export(function(to) {
to.ArrayIteratorCreateResultObject = CreateIteratorResultObject;
});
$arrayValues = ArrayValues; $arrayValues = ArrayValues;
}) })
...@@ -3,22 +3,12 @@ ...@@ -3,22 +3,12 @@
// found in the LICENSE file. // found in the LICENSE file.
var $arrayConcat; var $arrayConcat;
var $arrayJoin;
var $arrayPush; var $arrayPush;
var $arrayPop; var $arrayPop;
var $arrayShift; var $arrayShift;
var $arraySlice; var $arraySlice;
var $arraySplice; var $arraySplice;
var $arrayUnshift; var $arrayUnshift;
var $innerArrayForEach;
var $innerArrayEvery;
var $innerArrayFilter;
var $innerArrayIndexOf;
var $innerArrayLastIndexOf;
var $innerArrayMap;
var $innerArrayReverse;
var $innerArraySome;
var $innerArraySort;
(function(global, utils) { (function(global, utils) {
...@@ -33,10 +23,20 @@ var GlobalArray = global.Array; ...@@ -33,10 +23,20 @@ var GlobalArray = global.Array;
var InternalArray = utils.InternalArray; var InternalArray = utils.InternalArray;
var InternalPackedArray = utils.InternalPackedArray; var InternalPackedArray = utils.InternalPackedArray;
var Delete;
var MathMin; var MathMin;
var ObjectHasOwnProperty;
var ObjectIsFrozen;
var ObjectIsSealed;
var ObjectToString;
utils.Import(function(from) { utils.Import(function(from) {
Delete = from.Delete;
MathMin = from.MathMin; MathMin = from.MathMin;
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
ObjectIsFrozen = from.ObjectIsFrozen;
ObjectIsSealed = from.ObjectIsSealed;
ObjectToString = from.ObjectToString;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -392,7 +392,7 @@ function ArrayToString() { ...@@ -392,7 +392,7 @@ function ArrayToString() {
func = array.join; func = array.join;
} }
if (!IS_SPEC_FUNCTION(func)) { if (!IS_SPEC_FUNCTION(func)) {
return %_CallFunction(array, $objectToString); return %_CallFunction(array, ObjectToString);
} }
return %_CallFunction(array, func); return %_CallFunction(array, func);
} }
...@@ -467,7 +467,7 @@ function ArrayPop() { ...@@ -467,7 +467,7 @@ function ArrayPop() {
n--; n--;
var value = array[n]; var value = array[n];
$delete(array, $toName(n), true); Delete(array, $toName(n), true);
array.length = n; array.length = n;
return value; return value;
} }
...@@ -645,7 +645,7 @@ function ArrayShift() { ...@@ -645,7 +645,7 @@ function ArrayShift() {
return; return;
} }
if ($objectIsSealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed); if (ObjectIsSealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed);
if (%IsObserved(array)) if (%IsObserved(array))
return ObservedArrayShift.call(array, len); return ObservedArrayShift.call(array, len);
...@@ -696,7 +696,7 @@ function ArrayUnshift(arg1) { // length == 1 ...@@ -696,7 +696,7 @@ function ArrayUnshift(arg1) { // length == 1
var num_arguments = %_ArgumentsLength(); var num_arguments = %_ArgumentsLength();
if (len > 0 && UseSparseVariant(array, len, IS_ARRAY(array), len) && if (len > 0 && UseSparseVariant(array, len, IS_ARRAY(array), len) &&
!$objectIsSealed(array)) { !ObjectIsSealed(array)) {
SparseMove(array, 0, 0, len, num_arguments); SparseMove(array, 0, 0, len, num_arguments);
} else { } else {
SimpleMove(array, 0, 0, len, num_arguments); SimpleMove(array, 0, 0, len, num_arguments);
...@@ -842,9 +842,9 @@ function ArraySplice(start, delete_count) { ...@@ -842,9 +842,9 @@ function ArraySplice(start, delete_count) {
deleted_elements.length = del_count; deleted_elements.length = del_count;
var num_elements_to_add = num_arguments > 2 ? num_arguments - 2 : 0; var num_elements_to_add = num_arguments > 2 ? num_arguments - 2 : 0;
if (del_count != num_elements_to_add && $objectIsSealed(array)) { if (del_count != num_elements_to_add && ObjectIsSealed(array)) {
throw MakeTypeError(kArrayFunctionsOnSealed); throw MakeTypeError(kArrayFunctionsOnSealed);
} else if (del_count > 0 && $objectIsFrozen(array)) { } else if (del_count > 0 && ObjectIsFrozen(array)) {
throw MakeTypeError(kArrayFunctionsOnFrozen); throw MakeTypeError(kArrayFunctionsOnFrozen);
} }
...@@ -1582,7 +1582,7 @@ var unscopables = { ...@@ -1582,7 +1582,7 @@ var unscopables = {
DONT_ENUM | READ_ONLY); DONT_ENUM | READ_ONLY);
// Set up non-enumerable functions on the Array object. // Set up non-enumerable functions on the Array object.
$installFunctions(GlobalArray, DONT_ENUM, [ utils.InstallFunctions(GlobalArray, DONT_ENUM, [
"isArray", ArrayIsArray "isArray", ArrayIsArray
]); ]);
...@@ -1603,7 +1603,7 @@ var getFunction = function(name, jsBuiltin, len) { ...@@ -1603,7 +1603,7 @@ var getFunction = function(name, jsBuiltin, len) {
// set their names. // set their names.
// Manipulate the length of some of the functions to meet // Manipulate the length of some of the functions to meet
// expectations set by ECMA-262 or Mozilla. // expectations set by ECMA-262 or Mozilla.
$installFunctions(GlobalArray.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"toString", getFunction("toString", ArrayToString), "toString", getFunction("toString", ArrayToString),
"toLocaleString", getFunction("toLocaleString", ArrayToLocaleString), "toLocaleString", getFunction("toLocaleString", ArrayToLocaleString),
"join", getFunction("join", ArrayJoin), "join", getFunction("join", ArrayJoin),
...@@ -1632,7 +1632,7 @@ $installFunctions(GlobalArray.prototype, DONT_ENUM, [ ...@@ -1632,7 +1632,7 @@ $installFunctions(GlobalArray.prototype, DONT_ENUM, [
// The internal Array prototype doesn't need to be fancy, since it's never // The internal Array prototype doesn't need to be fancy, since it's never
// exposed to user code. // exposed to user code.
// Adding only the functions that are actually used. // Adding only the functions that are actually used.
$setUpLockedPrototype(InternalArray, GlobalArray(), [ utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [
"concat", getFunction("concat", ArrayConcatJS), "concat", getFunction("concat", ArrayConcatJS),
"indexOf", getFunction("indexOf", ArrayIndexOf), "indexOf", getFunction("indexOf", ArrayIndexOf),
"join", getFunction("join", ArrayJoin), "join", getFunction("join", ArrayJoin),
...@@ -1642,15 +1642,30 @@ $setUpLockedPrototype(InternalArray, GlobalArray(), [ ...@@ -1642,15 +1642,30 @@ $setUpLockedPrototype(InternalArray, GlobalArray(), [
"splice", getFunction("splice", ArraySplice) "splice", getFunction("splice", ArraySplice)
]); ]);
$setUpLockedPrototype(InternalPackedArray, GlobalArray(), [ utils.SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [
"join", getFunction("join", ArrayJoin), "join", getFunction("join", ArrayJoin),
"pop", getFunction("pop", ArrayPop), "pop", getFunction("pop", ArrayPop),
"push", getFunction("push", ArrayPush), "push", getFunction("push", ArrayPush),
"shift", getFunction("shift", ArrayShift) "shift", getFunction("shift", ArrayShift)
]); ]);
// -------------------------------------------------------------------
// Exports
utils.Export(function(to) {
to.ArrayJoin = ArrayJoin;
to.InnerArrayEvery = InnerArrayEvery;
to.InnerArrayFilter = InnerArrayFilter;
to.InnerArrayForEach = InnerArrayForEach;
to.InnerArrayIndexOf = InnerArrayIndexOf;
to.InnerArrayLastIndexOf = InnerArrayLastIndexOf;
to.InnerArrayMap = InnerArrayMap;
to.InnerArrayReverse = InnerArrayReverse;
to.InnerArraySome = InnerArraySome;
to.InnerArraySort = InnerArraySort;
});
$arrayConcat = ArrayConcatJS; $arrayConcat = ArrayConcatJS;
$arrayJoin = ArrayJoin;
$arrayPush = ArrayPush; $arrayPush = ArrayPush;
$arrayPop = ArrayPop; $arrayPop = ArrayPop;
$arrayShift = ArrayShift; $arrayShift = ArrayShift;
...@@ -1658,14 +1673,4 @@ $arraySlice = ArraySlice; ...@@ -1658,14 +1673,4 @@ $arraySlice = ArraySlice;
$arraySplice = ArraySplice; $arraySplice = ArraySplice;
$arrayUnshift = ArrayUnshift; $arrayUnshift = ArrayUnshift;
$innerArrayEvery = InnerArrayEvery;
$innerArrayFilter = InnerArrayFilter;
$innerArrayForEach = InnerArrayForEach;
$innerArrayIndexOf = InnerArrayIndexOf;
$innerArrayLastIndexOf = InnerArrayLastIndexOf;
$innerArrayMap = InnerArrayMap;
$innerArrayReverse = InnerArrayReverse;
$innerArraySome = InnerArraySome;
$innerArraySort = InnerArraySort;
}); });
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
...@@ -95,13 +94,13 @@ function ArrayBufferIsViewJS(obj) { ...@@ -95,13 +94,13 @@ function ArrayBufferIsViewJS(obj) {
%AddNamedProperty(GlobalArrayBuffer.prototype, %AddNamedProperty(GlobalArrayBuffer.prototype,
symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY); symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY);
$installGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen); utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
$installFunctions(GlobalArrayBuffer, DONT_ENUM, [ utils.InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
"isView", ArrayBufferIsViewJS "isView", ArrayBufferIsViewJS
]); ]);
$installFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
"slice", ArrayBufferSlice "slice", ArrayBufferSlice
]); ]);
......
...@@ -1530,7 +1530,8 @@ bool Genesis::CallUtilsFunction(Isolate* isolate, const char* name) { ...@@ -1530,7 +1530,8 @@ bool Genesis::CallUtilsFunction(Isolate* isolate, const char* name) {
isolate->factory()->NewStringFromAsciiChecked(name); isolate->factory()->NewStringFromAsciiChecked(name);
Handle<Object> fun = JSObject::GetDataProperty(utils, name_string); Handle<Object> fun = JSObject::GetDataProperty(utils, name_string);
Handle<Object> receiver = isolate->factory()->undefined_value(); Handle<Object> receiver = isolate->factory()->undefined_value();
return !Execution::Call(isolate, fun, receiver, 0, NULL).is_null(); Handle<Object> args[] = {utils};
return !Execution::Call(isolate, fun, receiver, 1, args).is_null();
} }
...@@ -2446,6 +2447,8 @@ bool Genesis::InstallExperimentalNatives() { ...@@ -2446,6 +2447,8 @@ bool Genesis::InstallExperimentalNatives() {
#undef INSTALL_EXPERIMENTAL_NATIVES #undef INSTALL_EXPERIMENTAL_NATIVES
} }
CallUtilsFunction(isolate(), "PostExperimentals");
InstallExperimentalNativeFunctions(); InstallExperimentalNativeFunctions();
return true; return true;
} }
......
...@@ -70,14 +70,14 @@ function SetValues() { ...@@ -70,14 +70,14 @@ function SetValues() {
%SetCode(SetIterator, SetIteratorConstructor); %SetCode(SetIterator, SetIteratorConstructor);
%FunctionSetPrototype(SetIterator, {__proto__: $iteratorPrototype}); %FunctionSetPrototype(SetIterator, {__proto__: $iteratorPrototype});
%FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); %FunctionSetInstanceClassName(SetIterator, 'Set Iterator');
$installFunctions(SetIterator.prototype, DONT_ENUM, [ utils.InstallFunctions(SetIterator.prototype, DONT_ENUM, [
'next', SetIteratorNextJS 'next', SetIteratorNextJS
]); ]);
%AddNamedProperty(SetIterator.prototype, symbolToStringTag, %AddNamedProperty(SetIterator.prototype, symbolToStringTag,
"Set Iterator", READ_ONLY | DONT_ENUM); "Set Iterator", READ_ONLY | DONT_ENUM);
$installFunctions(GlobalSet.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
'entries', SetEntries, 'entries', SetEntries,
'keys', SetValues, 'keys', SetValues,
'values', SetValues 'values', SetValues
...@@ -152,7 +152,7 @@ function MapValues() { ...@@ -152,7 +152,7 @@ function MapValues() {
%SetCode(MapIterator, MapIteratorConstructor); %SetCode(MapIterator, MapIteratorConstructor);
%FunctionSetPrototype(MapIterator, {__proto__: $iteratorPrototype}); %FunctionSetPrototype(MapIterator, {__proto__: $iteratorPrototype});
%FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); %FunctionSetInstanceClassName(MapIterator, 'Map Iterator');
$installFunctions(MapIterator.prototype, DONT_ENUM, [ utils.InstallFunctions(MapIterator.prototype, DONT_ENUM, [
'next', MapIteratorNextJS 'next', MapIteratorNextJS
]); ]);
...@@ -160,7 +160,7 @@ $installFunctions(MapIterator.prototype, DONT_ENUM, [ ...@@ -160,7 +160,7 @@ $installFunctions(MapIterator.prototype, DONT_ENUM, [
"Map Iterator", READ_ONLY | DONT_ENUM); "Map Iterator", READ_ONLY | DONT_ENUM);
$installFunctions(GlobalMap.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
'entries', MapEntries, 'entries', MapEntries,
'keys', MapKeys, 'keys', MapKeys,
'values', MapValues 'values', MapValues
......
...@@ -8,10 +8,19 @@ ...@@ -8,10 +8,19 @@
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalMap = global.Map; var GlobalMap = global.Map;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var GlobalSet = global.Set; var GlobalSet = global.Set;
var NumberIsNaN;
utils.Import(function(from) {
NumberIsNaN = from.NumberIsNaN;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
function HashToEntry(table, hash, numBuckets) { function HashToEntry(table, hash, numBuckets) {
...@@ -22,7 +31,7 @@ function HashToEntry(table, hash, numBuckets) { ...@@ -22,7 +31,7 @@ function HashToEntry(table, hash, numBuckets) {
function SetFindEntry(table, numBuckets, key, hash) { function SetFindEntry(table, numBuckets, key, hash) {
var keyIsNaN = $numberIsNaN(key); var keyIsNaN = NumberIsNaN(key);
for (var entry = HashToEntry(table, hash, numBuckets); for (var entry = HashToEntry(table, hash, numBuckets);
entry !== NOT_FOUND; entry !== NOT_FOUND;
entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) { entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) {
...@@ -30,7 +39,7 @@ function SetFindEntry(table, numBuckets, key, hash) { ...@@ -30,7 +39,7 @@ function SetFindEntry(table, numBuckets, key, hash) {
if (key === candidate) { if (key === candidate) {
return entry; return entry;
} }
if (keyIsNaN && $numberIsNaN(candidate)) { if (keyIsNaN && NumberIsNaN(candidate)) {
return entry; return entry;
} }
} }
...@@ -40,7 +49,7 @@ function SetFindEntry(table, numBuckets, key, hash) { ...@@ -40,7 +49,7 @@ function SetFindEntry(table, numBuckets, key, hash) {
function MapFindEntry(table, numBuckets, key, hash) { function MapFindEntry(table, numBuckets, key, hash) {
var keyIsNaN = $numberIsNaN(key); var keyIsNaN = NumberIsNaN(key);
for (var entry = HashToEntry(table, hash, numBuckets); for (var entry = HashToEntry(table, hash, numBuckets);
entry !== NOT_FOUND; entry !== NOT_FOUND;
entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) { entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) {
...@@ -48,7 +57,7 @@ function MapFindEntry(table, numBuckets, key, hash) { ...@@ -48,7 +57,7 @@ function MapFindEntry(table, numBuckets, key, hash) {
if (key === candidate) { if (key === candidate) {
return entry; return entry;
} }
if (keyIsNaN && $numberIsNaN(candidate)) { if (keyIsNaN && NumberIsNaN(candidate)) {
return entry; return entry;
} }
} }
...@@ -239,8 +248,8 @@ function SetForEach(f, receiver) { ...@@ -239,8 +248,8 @@ function SetForEach(f, receiver) {
%FunctionSetLength(SetForEach, 1); %FunctionSetLength(SetForEach, 1);
// Set up the non-enumerable functions on the Set prototype object. // Set up the non-enumerable functions on the Set prototype object.
$installGetter(GlobalSet.prototype, "size", SetGetSize); utils.InstallGetter(GlobalSet.prototype, "size", SetGetSize);
$installFunctions(GlobalSet.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
"add", SetAdd, "add", SetAdd,
"has", SetHas, "has", SetHas,
"delete", SetDelete, "delete", SetDelete,
...@@ -427,8 +436,8 @@ function MapForEach(f, receiver) { ...@@ -427,8 +436,8 @@ function MapForEach(f, receiver) {
%FunctionSetLength(MapForEach, 1); %FunctionSetLength(MapForEach, 1);
// Set up the non-enumerable functions on the Map prototype object. // Set up the non-enumerable functions on the Map prototype object.
$installGetter(GlobalMap.prototype, "size", MapGetSize); utils.InstallGetter(GlobalMap.prototype, "size", MapGetSize);
$installFunctions(GlobalMap.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
"get", MapGet, "get", MapGet,
"set", MapSet, "set", MapSet,
"has", MapHas, "has", MapHas,
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// This file relies on the fact that the following declarations have been made
// in v8natives.js:
// var $isFinite = GlobalIsFinite;
var $createDate; var $createDate;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -22,10 +18,12 @@ var $createDate; ...@@ -22,10 +18,12 @@ var $createDate;
var GlobalDate = global.Date; var GlobalDate = global.Date;
var InternalArray = utils.InternalArray; var InternalArray = utils.InternalArray;
var IsFinite;
var MathAbs; var MathAbs;
var MathFloor; var MathFloor;
utils.Import(function(from) { utils.Import(function(from) {
IsFinite = from.IsFinite;
MathAbs = from.MathAbs; MathAbs = from.MathAbs;
MathFloor = from.MathFloor; MathFloor = from.MathFloor;
}); });
...@@ -60,10 +58,10 @@ function UTC(time) { ...@@ -60,10 +58,10 @@ function UTC(time) {
// ECMA 262 - 15.9.1.11 // ECMA 262 - 15.9.1.11
function MakeTime(hour, min, sec, ms) { function MakeTime(hour, min, sec, ms) {
if (!$isFinite(hour)) return NAN; if (!IsFinite(hour)) return NAN;
if (!$isFinite(min)) return NAN; if (!IsFinite(min)) return NAN;
if (!$isFinite(sec)) return NAN; if (!IsFinite(sec)) return NAN;
if (!$isFinite(ms)) return NAN; if (!IsFinite(ms)) return NAN;
return TO_INTEGER(hour) * msPerHour return TO_INTEGER(hour) * msPerHour
+ TO_INTEGER(min) * msPerMinute + TO_INTEGER(min) * msPerMinute
+ TO_INTEGER(sec) * msPerSecond + TO_INTEGER(sec) * msPerSecond
...@@ -84,7 +82,7 @@ function TimeInYear(year) { ...@@ -84,7 +82,7 @@ function TimeInYear(year) {
// MakeDay(2007, -33, 1) --> MakeDay(2004, 3, 1) // MakeDay(2007, -33, 1) --> MakeDay(2004, 3, 1)
// MakeDay(2007, 14, -50) --> MakeDay(2007, 8, 11) // MakeDay(2007, 14, -50) --> MakeDay(2007, 8, 11)
function MakeDay(year, month, date) { function MakeDay(year, month, date) {
if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) return NAN; if (!IsFinite(year) || !IsFinite(month) || !IsFinite(date)) return NAN;
// Convert to integer and map -0 to 0. // Convert to integer and map -0 to 0.
year = TO_INTEGER_MAP_MINUS_ZERO(year); year = TO_INTEGER_MAP_MINUS_ZERO(year);
...@@ -116,7 +114,7 @@ function MakeDate(day, time) { ...@@ -116,7 +114,7 @@ function MakeDate(day, time) {
// ECMA 262 - 15.9.1.14 // ECMA 262 - 15.9.1.14
function TimeClip(time) { function TimeClip(time) {
if (!$isFinite(time)) return NAN; if (!IsFinite(time)) return NAN;
if (MathAbs(time) > MAX_TIME_MS) return NAN; if (MathAbs(time) > MAX_TIME_MS) return NAN;
return TO_INTEGER(time); return TO_INTEGER(time);
} }
...@@ -774,7 +772,7 @@ function CreateDate(time) { ...@@ -774,7 +772,7 @@ function CreateDate(time) {
%FunctionSetPrototype(GlobalDate, new GlobalDate(NAN)); %FunctionSetPrototype(GlobalDate, new GlobalDate(NAN));
// Set up non-enumerable properties of the Date object itself. // Set up non-enumerable properties of the Date object itself.
$installFunctions(GlobalDate, DONT_ENUM, [ utils.InstallFunctions(GlobalDate, DONT_ENUM, [
"UTC", DateUTC, "UTC", DateUTC,
"parse", DateParse, "parse", DateParse,
"now", DateNow "now", DateNow
...@@ -785,7 +783,7 @@ $installFunctions(GlobalDate, DONT_ENUM, [ ...@@ -785,7 +783,7 @@ $installFunctions(GlobalDate, DONT_ENUM, [
// Set up non-enumerable functions of the Date prototype object and // Set up non-enumerable functions of the Date prototype object and
// set their names. // set their names.
$installFunctions(GlobalDate.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [
"toString", DateToString, "toString", DateToString,
"toDateString", DateToDateString, "toDateString", DateToDateString,
"toTimeString", DateToTimeString, "toTimeString", DateToTimeString,
......
...@@ -8,8 +8,17 @@ ...@@ -8,8 +8,17 @@
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalFunction = global.Function; var GlobalFunction = global.Function;
var NewFunctionString;
utils.Import(function(from) {
NewFunctionString = from.NewFunctionString;
});
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Generator functions and objects are specified by ES6, sections 15.19.3 and // Generator functions and objects are specified by ES6, sections 15.19.3 and
...@@ -67,7 +76,7 @@ function GeneratorObjectThrow(exn) { ...@@ -67,7 +76,7 @@ function GeneratorObjectThrow(exn) {
function GeneratorFunctionConstructor(arg1) { // length == 1 function GeneratorFunctionConstructor(arg1) { // length == 1
var source = $newFunctionString(arguments, 'function*'); var source = NewFunctionString(arguments, 'function*');
var global_proxy = %GlobalProxy(GeneratorFunctionConstructor); var global_proxy = %GlobalProxy(GeneratorFunctionConstructor);
// Compile the string in the constructor and not a helper so that errors // Compile the string in the constructor and not a helper so that errors
// appear to come from here. // appear to come from here.
...@@ -85,7 +94,7 @@ function GeneratorFunctionConstructor(arg1) { // length == 1 ...@@ -85,7 +94,7 @@ function GeneratorFunctionConstructor(arg1) { // length == 1
// Set up non-enumerable functions on the generator prototype object. // Set up non-enumerable functions on the generator prototype object.
var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype;
$installFunctions(GeneratorObjectPrototype, utils.InstallFunctions(GeneratorObjectPrototype,
DONT_ENUM, DONT_ENUM,
["next", GeneratorObjectNext, ["next", GeneratorObjectNext,
"throw", GeneratorObjectThrow]); "throw", GeneratorObjectThrow]);
......
...@@ -52,7 +52,7 @@ function ArrayIncludes(searchElement, fromIndex) { ...@@ -52,7 +52,7 @@ function ArrayIncludes(searchElement, fromIndex) {
%FunctionSetLength(ArrayIncludes, 1); %FunctionSetLength(ArrayIncludes, 1);
// Set up the non-enumerable functions on the Array prototype object. // Set up the non-enumerable functions on the Array prototype object.
$installFunctions(GlobalArray.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"includes", ArrayIncludes "includes", ArrayIncludes
]); ]);
......
...@@ -2,12 +2,6 @@ ...@@ -2,12 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
var $innerArrayCopyWithin;
var $innerArrayFill;
var $innerArrayFind;
var $innerArrayFindIndex;
var $arrayFrom;
(function(global, utils) { (function(global, utils) {
'use strict'; 'use strict';
...@@ -20,12 +14,18 @@ var $arrayFrom; ...@@ -20,12 +14,18 @@ var $arrayFrom;
var GlobalArray = global.Array; var GlobalArray = global.Array;
var GlobalSymbol = global.Symbol; var GlobalSymbol = global.Symbol;
var GetIterator;
var GetMethod;
var MathMax; var MathMax;
var MathMin; var MathMin;
var ObjectIsFrozen;
utils.Import(function(from) { utils.Import(function(from) {
GetIterator = from.GetIterator;
GetMethod = from.GetMethod;
MathMax = from.MathMax; MathMax = from.MathMax;
MathMin = from.MathMin; MathMin = from.MathMin;
ObjectIsFrozen = from.ObjectIsFrozen;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -76,7 +76,6 @@ function InnerArrayCopyWithin(target, start, end, array, length) { ...@@ -76,7 +76,6 @@ function InnerArrayCopyWithin(target, start, end, array, length) {
return array; return array;
} }
$innerArrayCopyWithin = InnerArrayCopyWithin;
// ES6 draft 03-17-15, section 22.1.3.3 // ES6 draft 03-17-15, section 22.1.3.3
function ArrayCopyWithin(target, start, end) { function ArrayCopyWithin(target, start, end) {
...@@ -112,7 +111,6 @@ function InnerArrayFind(predicate, thisArg, array, length) { ...@@ -112,7 +111,6 @@ function InnerArrayFind(predicate, thisArg, array, length) {
return; return;
} }
$innerArrayFind = InnerArrayFind;
// ES6 draft 07-15-13, section 15.4.3.23 // ES6 draft 07-15-13, section 15.4.3.23
function ArrayFind(predicate, thisArg) { function ArrayFind(predicate, thisArg) {
...@@ -148,7 +146,6 @@ function InnerArrayFindIndex(predicate, thisArg, array, length) { ...@@ -148,7 +146,6 @@ function InnerArrayFindIndex(predicate, thisArg, array, length) {
return -1; return -1;
} }
$innerArrayFindIndex = InnerArrayFindIndex;
// ES6 draft 07-15-13, section 15.4.3.24 // ES6 draft 07-15-13, section 15.4.3.24
function ArrayFindIndex(predicate, thisArg) { function ArrayFindIndex(predicate, thisArg) {
...@@ -179,7 +176,7 @@ function InnerArrayFill(value, start, end, array, length) { ...@@ -179,7 +176,7 @@ function InnerArrayFill(value, start, end, array, length) {
if (end > length) end = length; if (end > length) end = length;
} }
if ((end - i) > 0 && $objectIsFrozen(array)) { if ((end - i) > 0 && ObjectIsFrozen(array)) {
throw MakeTypeError(kArrayFunctionsOnFrozen); throw MakeTypeError(kArrayFunctionsOnFrozen);
} }
...@@ -187,7 +184,6 @@ function InnerArrayFill(value, start, end, array, length) { ...@@ -187,7 +184,6 @@ function InnerArrayFill(value, start, end, array, length) {
array[i] = value; array[i] = value;
return array; return array;
} }
$innerArrayFill = InnerArrayFill;
// ES6, draft 04-05-14, section 22.1.3.6 // ES6, draft 04-05-14, section 22.1.3.6
function ArrayFill(value, start, end) { function ArrayFill(value, start, end) {
...@@ -216,7 +212,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) { ...@@ -216,7 +212,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
} }
} }
var iterable = $getMethod(items, symbolIterator); var iterable = GetMethod(items, symbolIterator);
var k; var k;
var result; var result;
var mappedValue; var mappedValue;
...@@ -225,7 +221,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) { ...@@ -225,7 +221,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
if (!IS_UNDEFINED(iterable)) { if (!IS_UNDEFINED(iterable)) {
result = %IsConstructor(this) ? new this() : []; result = %IsConstructor(this) ? new this() : [];
var iterator = $getIterator(items, iterable); var iterator = GetIterator(items, iterable);
k = 0; k = 0;
while (true) { while (true) {
...@@ -266,7 +262,6 @@ function ArrayFrom(arrayLike, mapfn, receiver) { ...@@ -266,7 +262,6 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
return result; return result;
} }
} }
$arrayFrom = ArrayFrom;
// ES6, draft 05-22-14, section 22.1.2.3 // ES6, draft 05-22-14, section 22.1.2.3
function ArrayOf() { function ArrayOf() {
...@@ -283,7 +278,7 @@ function ArrayOf() { ...@@ -283,7 +278,7 @@ function ArrayOf() {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
$installConstants(GlobalSymbol, [ utils.InstallConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping // TODO(dslomov, caitp): Move to symbol.js when shipping
"isConcatSpreadable", symbolIsConcatSpreadable "isConcatSpreadable", symbolIsConcatSpreadable
]); ]);
...@@ -295,17 +290,28 @@ $installConstants(GlobalSymbol, [ ...@@ -295,17 +290,28 @@ $installConstants(GlobalSymbol, [
%FunctionSetLength(ArrayFindIndex, 1); %FunctionSetLength(ArrayFindIndex, 1);
// Set up non-enumerable functions on the Array object. // Set up non-enumerable functions on the Array object.
$installFunctions(GlobalArray, DONT_ENUM, [ utils.InstallFunctions(GlobalArray, DONT_ENUM, [
"from", ArrayFrom, "from", ArrayFrom,
"of", ArrayOf "of", ArrayOf
]); ]);
// Set up the non-enumerable functions on the Array prototype object. // Set up the non-enumerable functions on the Array prototype object.
$installFunctions(GlobalArray.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"copyWithin", ArrayCopyWithin, "copyWithin", ArrayCopyWithin,
"find", ArrayFind, "find", ArrayFind,
"findIndex", ArrayFindIndex, "findIndex", ArrayFindIndex,
"fill", ArrayFill "fill", ArrayFill
]); ]);
// -------------------------------------------------------------------
// Exports
utils.Export(function(to) {
to.ArrayFrom = ArrayFrom;
to.InnerArrayCopyWithin = InnerArrayCopyWithin;
to.InnerArrayFill = InnerArrayFill;
to.InnerArrayFind = InnerArrayFind;
to.InnerArrayFindIndex = InnerArrayFindIndex;
});
}) })
...@@ -9,8 +9,19 @@ ...@@ -9,8 +9,19 @@
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalObject = global.Object; var GlobalObject = global.Object;
var OwnPropertyKeys;
utils.Import(function(from) {
OwnPropertyKeys = from.OwnPropertyKeys;
});
// -------------------------------------------------------------------
// ES6, draft 04-03-15, section 19.1.2.1 // ES6, draft 04-03-15, section 19.1.2.1
function ObjectAssign(target, sources) { function ObjectAssign(target, sources) {
var to = TO_OBJECT_INLINE(target); var to = TO_OBJECT_INLINE(target);
...@@ -24,7 +35,7 @@ function ObjectAssign(target, sources) { ...@@ -24,7 +35,7 @@ function ObjectAssign(target, sources) {
} }
var from = TO_OBJECT_INLINE(nextSource); var from = TO_OBJECT_INLINE(nextSource);
var keys = $ownPropertyKeys(from); var keys = OwnPropertyKeys(from);
var len = keys.length; var len = keys.length;
for (var j = 0; j < len; ++j) { for (var j = 0; j < len; ++j) {
...@@ -39,7 +50,7 @@ function ObjectAssign(target, sources) { ...@@ -39,7 +50,7 @@ function ObjectAssign(target, sources) {
} }
// Set up non-enumerable functions on the Object object. // Set up non-enumerable functions on the Object object.
$installFunctions(GlobalObject, DONT_ENUM, [ utils.InstallFunctions(GlobalObject, DONT_ENUM, [
"assign", ObjectAssign "assign", ObjectAssign
]); ]);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
var GlobalReflect = global.Reflect; var GlobalReflect = global.Reflect;
$installFunctions(GlobalReflect, DONT_ENUM, [ utils.InstallFunctions(GlobalReflect, DONT_ENUM, [
"apply", $reflectApply, "apply", $reflectApply,
"construct", $reflectConstruct "construct", $reflectConstruct
]); ]);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
var GlobalSymbol = global.Symbol; var GlobalSymbol = global.Symbol;
$installConstants(GlobalSymbol, [ utils.InstallConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping // TODO(dslomov, caitp): Move to symbol.js when shipping
"toStringTag", symbolToStringTag "toStringTag", symbolToStringTag
]); ]);
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
macro TYPED_ARRAYS(FUNCTION) macro TYPED_ARRAYS(FUNCTION)
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize. // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
FUNCTION(Uint8Array) FUNCTION(Uint8Array)
...@@ -28,6 +31,40 @@ endmacro ...@@ -28,6 +31,40 @@ endmacro
TYPED_ARRAYS(DECLARE_GLOBALS) TYPED_ARRAYS(DECLARE_GLOBALS)
DECLARE_GLOBALS(Array) DECLARE_GLOBALS(Array)
var ArrayFrom;
var InnerArrayCopyWithin;
var InnerArrayEvery;
var InnerArrayFill;
var InnerArrayFilter;
var InnerArrayFind;
var InnerArrayFindIndex;
var InnerArrayForEach;
var InnerArrayIndexOf;
var InnerArrayLastIndexOf;
var InnerArrayMap;
var InnerArrayReverse;
var InnerArraySome;
var InnerArraySort;
var IsNaN;
utils.Import(function(from) {
ArrayFrom = from.ArrayFrom;
InnerArrayCopyWithin = from.InnerArrayCopyWithin;
InnerArrayEvery = from.InnerArrayEvery;
InnerArrayFill = from.InnerArrayFill;
InnerArrayFilter = from.InnerArrayFilter;
InnerArrayFind = from.InnerArrayFind;
InnerArrayFindIndex = from.InnerArrayFindIndex;
InnerArrayForEach = from.InnerArrayForEach;
InnerArrayIndexOf = from.InnerArrayIndexOf;
InnerArrayLastIndexOf = from.InnerArrayLastIndexOf;
InnerArrayMap = from.InnerArrayMap;
InnerArrayReverse = from.InnerArrayReverse;
InnerArraySome = from.InnerArraySome;
InnerArraySort = from.InnerArraySort;
IsNaN = from.IsNaN;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
function ConstructTypedArray(constructor, array) { function ConstructTypedArray(constructor, array) {
...@@ -58,7 +95,7 @@ function TypedArrayCopyWithin(target, start, end) { ...@@ -58,7 +95,7 @@ function TypedArrayCopyWithin(target, start, end) {
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
// TODO(littledan): Replace with a memcpy for better performance // TODO(littledan): Replace with a memcpy for better performance
return $innerArrayCopyWithin(target, start, end, this, length); return InnerArrayCopyWithin(target, start, end, this, length);
} }
%FunctionSetLength(TypedArrayCopyWithin, 2); %FunctionSetLength(TypedArrayCopyWithin, 2);
...@@ -68,7 +105,7 @@ function TypedArrayEvery(f, receiver) { ...@@ -68,7 +105,7 @@ function TypedArrayEvery(f, receiver) {
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
return $innerArrayEvery(f, receiver, this, length); return InnerArrayEvery(f, receiver, this, length);
} }
%FunctionSetLength(TypedArrayEvery, 1); %FunctionSetLength(TypedArrayEvery, 1);
...@@ -78,7 +115,7 @@ function TypedArrayForEach(f, receiver) { ...@@ -78,7 +115,7 @@ function TypedArrayForEach(f, receiver) {
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
$innerArrayForEach(f, receiver, this, length); InnerArrayForEach(f, receiver, this, length);
} }
%FunctionSetLength(TypedArrayForEach, 1); %FunctionSetLength(TypedArrayForEach, 1);
...@@ -88,7 +125,7 @@ function TypedArrayFill(value, start, end) { ...@@ -88,7 +125,7 @@ function TypedArrayFill(value, start, end) {
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
return $innerArrayFill(value, start, end, this, length); return InnerArrayFill(value, start, end, this, length);
} }
%FunctionSetLength(TypedArrayFill, 1); %FunctionSetLength(TypedArrayFill, 1);
...@@ -97,7 +134,7 @@ function TypedArrayFilter(predicate, thisArg) { ...@@ -97,7 +134,7 @@ function TypedArrayFilter(predicate, thisArg) {
if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
var array = $innerArrayFilter(predicate, thisArg, this, length); var array = InnerArrayFilter(predicate, thisArg, this, length);
return ConstructTypedArrayLike(this, array); return ConstructTypedArrayLike(this, array);
} }
%FunctionSetLength(TypedArrayFilter, 1); %FunctionSetLength(TypedArrayFilter, 1);
...@@ -108,7 +145,7 @@ function TypedArrayFind(predicate, thisArg) { ...@@ -108,7 +145,7 @@ function TypedArrayFind(predicate, thisArg) {
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
return $innerArrayFind(predicate, thisArg, this, length); return InnerArrayFind(predicate, thisArg, this, length);
} }
%FunctionSetLength(TypedArrayFind, 1); %FunctionSetLength(TypedArrayFind, 1);
...@@ -118,7 +155,7 @@ function TypedArrayFindIndex(predicate, thisArg) { ...@@ -118,7 +155,7 @@ function TypedArrayFindIndex(predicate, thisArg) {
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
return $innerArrayFindIndex(predicate, thisArg, this, length); return InnerArrayFindIndex(predicate, thisArg, this, length);
} }
%FunctionSetLength(TypedArrayFindIndex, 1); %FunctionSetLength(TypedArrayFindIndex, 1);
...@@ -128,15 +165,15 @@ function TypedArrayReverse() { ...@@ -128,15 +165,15 @@ function TypedArrayReverse() {
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
return $innerArrayReverse(this, length); return InnerArrayReverse(this, length);
} }
function TypedArrayComparefn(x, y) { function TypedArrayComparefn(x, y) {
if ($isNaN(x) && $isNaN(y)) { if (IsNaN(x) && IsNaN(y)) {
return $isNaN(y) ? 0 : 1; return IsNaN(y) ? 0 : 1;
} }
if ($isNaN(x)) { if (IsNaN(x)) {
return 1; return 1;
} }
if (x === 0 && x === y) { if (x === 0 && x === y) {
...@@ -162,7 +199,7 @@ function TypedArraySort(comparefn) { ...@@ -162,7 +199,7 @@ function TypedArraySort(comparefn) {
comparefn = TypedArrayComparefn; comparefn = TypedArrayComparefn;
} }
return %_CallFunction(this, length, comparefn, $innerArraySort); return %_CallFunction(this, length, comparefn, InnerArraySort);
} }
...@@ -172,7 +209,7 @@ function TypedArrayIndexOf(element, index) { ...@@ -172,7 +209,7 @@ function TypedArrayIndexOf(element, index) {
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
return %_CallFunction(this, element, index, length, $innerArrayIndexOf); return %_CallFunction(this, element, index, length, InnerArrayIndexOf);
} }
%FunctionSetLength(TypedArrayIndexOf, 1); %FunctionSetLength(TypedArrayIndexOf, 1);
...@@ -184,7 +221,7 @@ function TypedArrayLastIndexOf(element, index) { ...@@ -184,7 +221,7 @@ function TypedArrayLastIndexOf(element, index) {
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
return %_CallFunction(this, element, index, length, return %_CallFunction(this, element, index, length,
%_ArgumentsLength(), $innerArrayLastIndexOf); %_ArgumentsLength(), InnerArrayLastIndexOf);
} }
%FunctionSetLength(TypedArrayLastIndexOf, 1); %FunctionSetLength(TypedArrayLastIndexOf, 1);
...@@ -196,7 +233,7 @@ function TypedArrayMap(predicate, thisArg) { ...@@ -196,7 +233,7 @@ function TypedArrayMap(predicate, thisArg) {
// TODO(littledan): Preallocate rather than making an intermediate // TODO(littledan): Preallocate rather than making an intermediate
// InternalArray, for better performance. // InternalArray, for better performance.
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
var array = $innerArrayMap(predicate, thisArg, this, length); var array = InnerArrayMap(predicate, thisArg, this, length);
return ConstructTypedArrayLike(this, array); return ConstructTypedArrayLike(this, array);
} }
%FunctionSetLength(TypedArrayMap, 1); %FunctionSetLength(TypedArrayMap, 1);
...@@ -208,7 +245,7 @@ function TypedArraySome(f, receiver) { ...@@ -208,7 +245,7 @@ function TypedArraySome(f, receiver) {
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
return $innerArraySome(f, receiver, this, length); return InnerArraySome(f, receiver, this, length);
} }
%FunctionSetLength(TypedArraySome, 1); %FunctionSetLength(TypedArraySome, 1);
...@@ -227,7 +264,7 @@ function TypedArrayOf() { ...@@ -227,7 +264,7 @@ function TypedArrayOf() {
function TypedArrayFrom(source, mapfn, thisArg) { function TypedArrayFrom(source, mapfn, thisArg) {
// TODO(littledan): Investigate if there is a receiver which could be // TODO(littledan): Investigate if there is a receiver which could be
// faster to accumulate on than Array, e.g., a TypedVector. // faster to accumulate on than Array, e.g., a TypedVector.
var array = %_CallFunction(GlobalArray, source, mapfn, thisArg, $arrayFrom); var array = %_CallFunction(GlobalArray, source, mapfn, thisArg, ArrayFrom);
return ConstructTypedArray(this, array); return ConstructTypedArray(this, array);
} }
%FunctionSetLength(TypedArrayFrom, 1); %FunctionSetLength(TypedArrayFrom, 1);
...@@ -235,13 +272,13 @@ function TypedArrayFrom(source, mapfn, thisArg) { ...@@ -235,13 +272,13 @@ function TypedArrayFrom(source, mapfn, thisArg) {
// TODO(littledan): Fix the TypedArray proto chain (bug v8:4085). // TODO(littledan): Fix the TypedArray proto chain (bug v8:4085).
macro EXTEND_TYPED_ARRAY(NAME) macro EXTEND_TYPED_ARRAY(NAME)
// Set up non-enumerable functions on the object. // Set up non-enumerable functions on the object.
$installFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [ utils.InstallFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [
"from", TypedArrayFrom, "from", TypedArrayFrom,
"of", TypedArrayOf "of", TypedArrayOf
]); ]);
// Set up non-enumerable functions on the prototype object. // Set up non-enumerable functions on the prototype object.
$installFunctions(GlobalNAME.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [
"copyWithin", TypedArrayCopyWithin, "copyWithin", TypedArrayCopyWithin,
"every", TypedArrayEvery, "every", TypedArrayEvery,
"fill", TypedArrayFill, "fill", TypedArrayFill,
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ var $iteratorPrototype; ...@@ -15,7 +15,7 @@ var $iteratorPrototype;
return this; return this;
} }
$setFunctionName(IteratorPrototypeIterator, symbolIterator); utils.SetFunctionName(IteratorPrototypeIterator, symbolIterator);
%AddNamedProperty($iteratorPrototype, symbolIterator, %AddNamedProperty($iteratorPrototype, symbolIterator,
IteratorPrototypeIterator, DONT_ENUM); IteratorPrototypeIterator, DONT_ENUM);
}) })
...@@ -18,10 +18,12 @@ var InternalArray = utils.InternalArray; ...@@ -18,10 +18,12 @@ var InternalArray = utils.InternalArray;
var MathMax; var MathMax;
var MathMin; var MathMin;
var ObjectHasOwnProperty;
utils.Import(function(from) { utils.Import(function(from) {
MathMax = from.MathMax; MathMax = from.MathMax;
MathMin = from.MathMin; MathMin = from.MathMin;
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -37,7 +39,7 @@ function Revive(holder, name, reviver) { ...@@ -37,7 +39,7 @@ function Revive(holder, name, reviver) {
} }
} else { } else {
for (var p in val) { for (var p in val) {
if (%_CallFunction(val, p, $objectHasOwnProperty)) { if (HAS_OWN_PROPERTY(val, p)) {
var newElement = Revive(val, p, reviver); var newElement = Revive(val, p, reviver);
if (IS_UNDEFINED(newElement)) { if (IS_UNDEFINED(newElement)) {
delete val[p]; delete val[p];
...@@ -99,7 +101,7 @@ function SerializeObject(value, replacer, stack, indent, gap) { ...@@ -99,7 +101,7 @@ function SerializeObject(value, replacer, stack, indent, gap) {
if (IS_ARRAY(replacer)) { if (IS_ARRAY(replacer)) {
var length = replacer.length; var length = replacer.length;
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
if (%_CallFunction(replacer, i, $objectHasOwnProperty)) { if (HAS_OWN_PROPERTY(replacer, i)) {
var p = replacer[i]; var p = replacer[i];
var strP = JSONSerialize(p, value, replacer, stack, indent, gap); var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
if (!IS_UNDEFINED(strP)) { if (!IS_UNDEFINED(strP)) {
...@@ -112,7 +114,7 @@ function SerializeObject(value, replacer, stack, indent, gap) { ...@@ -112,7 +114,7 @@ function SerializeObject(value, replacer, stack, indent, gap) {
} }
} else { } else {
for (var p in value) { for (var p in value) {
if (%_CallFunction(value, p, $objectHasOwnProperty)) { if (HAS_OWN_PROPERTY(value, p)) {
var strP = JSONSerialize(p, value, replacer, stack, indent, gap); var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
if (!IS_UNDEFINED(strP)) { if (!IS_UNDEFINED(strP)) {
var member = %QuoteJSONString(p) + ":"; var member = %QuoteJSONString(p) + ":";
...@@ -232,7 +234,7 @@ function JSONStringify(value, replacer, space) { ...@@ -232,7 +234,7 @@ function JSONStringify(value, replacer, space) {
%AddNamedProperty(GlobalJSON, symbolToStringTag, "JSON", READ_ONLY | DONT_ENUM); %AddNamedProperty(GlobalJSON, symbolToStringTag, "JSON", READ_ONLY | DONT_ENUM);
// Set up non-enumerable properties of the JSON object. // Set up non-enumerable properties of the JSON object.
$installFunctions(GlobalJSON, DONT_ENUM, [ utils.InstallFunctions(GlobalJSON, DONT_ENUM, [
"parse", JSONParse, "parse", JSONParse,
"stringify", JSONStringify "stringify", JSONStringify
]); ]);
......
...@@ -154,7 +154,7 @@ macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : $nonStringToStrin ...@@ -154,7 +154,7 @@ macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : $nonStringToStrin
macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : $nonNumberToNumber(arg)); macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : $nonNumberToNumber(arg));
macro TO_OBJECT_INLINE(arg) = (IS_SPEC_OBJECT(%IS_VAR(arg)) ? arg : $toObject(arg)); macro TO_OBJECT_INLINE(arg) = (IS_SPEC_OBJECT(%IS_VAR(arg)) ? arg : $toObject(arg));
macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null"); macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null");
macro HAS_OWN_PROPERTY(arg, index) = (%_CallFunction(arg, index, $objectHasOwnProperty)); macro HAS_OWN_PROPERTY(arg, index) = (%_CallFunction(arg, index, ObjectHasOwnProperty));
macro SHOULD_CREATE_WRAPPER(functionName, receiver) = (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(functionName)); macro SHOULD_CREATE_WRAPPER(functionName, receiver) = (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(functionName));
macro HAS_INDEX(array, index, is_array) = ((is_array && %_HasFastPackedElements(%IS_VAR(array))) ? (index < array.length) : (index in array)); macro HAS_INDEX(array, index, is_array) = ((is_array && %_HasFastPackedElements(%IS_VAR(array))) ? (index < array.length) : (index in array));
......
...@@ -292,7 +292,7 @@ var Math = new MathConstructor(); ...@@ -292,7 +292,7 @@ var Math = new MathConstructor();
%AddNamedProperty(Math, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM); %AddNamedProperty(Math, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM);
// Set up math constants. // Set up math constants.
$installConstants(Math, [ utils.InstallConstants(Math, [
// ECMA-262, section 15.8.1.1. // ECMA-262, section 15.8.1.1.
"E", 2.7182818284590452354, "E", 2.7182818284590452354,
// ECMA-262, section 15.8.1.2. // ECMA-262, section 15.8.1.2.
...@@ -309,7 +309,7 @@ $installConstants(Math, [ ...@@ -309,7 +309,7 @@ $installConstants(Math, [
// Set up non-enumerable functions of the Math object and // Set up non-enumerable functions of the Math object and
// set their names. // set their names.
$installFunctions(Math, DONT_ENUM, [ utils.InstallFunctions(Math, DONT_ENUM, [
"random", MathRandom, "random", MathRandom,
"abs", MathAbs, "abs", MathAbs,
"acos", MathAcosJS, "acos", MathAcosJS,
......
...@@ -27,9 +27,6 @@ var MakeReferenceError; ...@@ -27,9 +27,6 @@ var MakeReferenceError;
var MakeSyntaxError; var MakeSyntaxError;
var MakeTypeError; var MakeTypeError;
var MakeURIError; var MakeURIError;
var MakeReferenceErrorEmbedded;
var MakeSyntaxErrorEmbedded;
var MakeTypeErrorEmbedded;
(function(global, utils) { (function(global, utils) {
...@@ -40,12 +37,17 @@ var MakeTypeErrorEmbedded; ...@@ -40,12 +37,17 @@ var MakeTypeErrorEmbedded;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var InternalArray = utils.InternalArray; var InternalArray = utils.InternalArray;
var ObjectDefineProperty = utils.ObjectDefineProperty;
var ArrayJoin;
var ObjectToString;
var StringCharAt; var StringCharAt;
var StringIndexOf; var StringIndexOf;
var StringSubstring; var StringSubstring;
utils.Import(function(from) { utils.Import(function(from) {
ArrayJoin = from.ArrayJoin;
ObjectToString = from.ObjectToString;
StringCharAt = from.StringCharAt; StringCharAt = from.StringCharAt;
StringIndexOf = from.StringIndexOf; StringIndexOf = from.StringIndexOf;
StringSubstring = from.StringSubstring; StringSubstring = from.StringSubstring;
...@@ -85,7 +87,7 @@ function NoSideEffectToString(obj) { ...@@ -85,7 +87,7 @@ function NoSideEffectToString(obj) {
} }
if (IS_SYMBOL(obj)) return %_CallFunction(obj, $symbolToString); if (IS_SYMBOL(obj)) return %_CallFunction(obj, $symbolToString);
if (IS_OBJECT(obj) if (IS_OBJECT(obj)
&& %GetDataProperty(obj, "toString") === $objectToString) { && %GetDataProperty(obj, "toString") === ObjectToString) {
var constructor = %GetDataProperty(obj, "constructor"); var constructor = %GetDataProperty(obj, "constructor");
if (typeof constructor == "function") { if (typeof constructor == "function") {
var constructorName = constructor.name; var constructorName = constructor.name;
...@@ -137,7 +139,7 @@ function ToStringCheckErrorObject(obj) { ...@@ -137,7 +139,7 @@ function ToStringCheckErrorObject(obj) {
function ToDetailString(obj) { function ToDetailString(obj) {
if (obj != null && IS_OBJECT(obj) && obj.toString === $objectToString) { if (obj != null && IS_OBJECT(obj) && obj.toString === ObjectToString) {
var constructor = obj.constructor; var constructor = obj.constructor;
if (typeof constructor == "function") { if (typeof constructor == "function") {
var constructorName = constructor.name; var constructorName = constructor.name;
...@@ -409,7 +411,7 @@ function ScriptNameOrSourceURL() { ...@@ -409,7 +411,7 @@ function ScriptNameOrSourceURL() {
} }
$setUpLockedPrototype(Script, [ utils.SetUpLockedPrototype(Script, [
"source", "source",
"name", "name",
"source_url", "source_url",
...@@ -473,7 +475,7 @@ function SourceLocationSourceText() { ...@@ -473,7 +475,7 @@ function SourceLocationSourceText() {
} }
$setUpLockedPrototype(SourceLocation, utils.SetUpLockedPrototype(SourceLocation,
["script", "position", "line", "column", "start", "end"], ["script", "position", "line", "column", "start", "end"],
["sourceText", SourceLocationSourceText] ["sourceText", SourceLocationSourceText]
); );
...@@ -517,7 +519,7 @@ function SourceSliceSourceText() { ...@@ -517,7 +519,7 @@ function SourceSliceSourceText() {
StringSubstring); StringSubstring);
} }
$setUpLockedPrototype(SourceSlice, utils.SetUpLockedPrototype(SourceSlice,
["script", "from_line", "to_line", "from_position", "to_position"], ["script", "from_line", "to_line", "from_position", "to_position"],
["sourceText", SourceSliceSourceText] ["sourceText", SourceSliceSourceText]
); );
...@@ -715,7 +717,7 @@ function CallSiteToString() { ...@@ -715,7 +717,7 @@ function CallSiteToString() {
return line; return line;
} }
$setUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [ utils.SetUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
"getThis", CallSiteGetThis, "getThis", CallSiteGetThis,
"getTypeName", CallSiteGetTypeName, "getTypeName", CallSiteGetTypeName,
"isToplevel", CallSiteIsToplevel, "isToplevel", CallSiteIsToplevel,
...@@ -842,7 +844,7 @@ function FormatStackTrace(obj, raw_stack) { ...@@ -842,7 +844,7 @@ function FormatStackTrace(obj, raw_stack) {
} }
lines.push(" at " + line); lines.push(" at " + line);
} }
return %_CallFunction(lines, "\n", $arrayJoin); return %_CallFunction(lines, "\n", ArrayJoin);
} }
...@@ -902,13 +904,7 @@ var StackTraceSetter = function(v) { ...@@ -902,13 +904,7 @@ var StackTraceSetter = function(v) {
// Use a dummy function since we do not actually want to capture a stack trace // Use a dummy function since we do not actually want to capture a stack trace
// when constructing the initial Error prototytpes. // when constructing the initial Error prototytpes.
var captureStackTrace = function captureStackTrace(obj, cons_opt) { var captureStackTrace = function() {};
// Define accessors first, as this may fail and throw.
$objectDefineProperty(obj, 'stack', { get: StackTraceGetter,
set: StackTraceSetter,
configurable: true });
%CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace);
}
// Define special error type constructors. // Define special error type constructors.
...@@ -963,9 +959,6 @@ GlobalSyntaxError = DefineError(global, function SyntaxError() { }); ...@@ -963,9 +959,6 @@ GlobalSyntaxError = DefineError(global, function SyntaxError() { });
GlobalTypeError = DefineError(global, function TypeError() { }); GlobalTypeError = DefineError(global, function TypeError() { });
GlobalURIError = DefineError(global, function URIError() { }); GlobalURIError = DefineError(global, function URIError() { });
GlobalError.captureStackTrace = captureStackTrace;
%AddNamedProperty(GlobalError.prototype, 'message', '', DONT_ENUM); %AddNamedProperty(GlobalError.prototype, 'message', '', DONT_ENUM);
// Global list of error objects visited during ErrorToString. This is // Global list of error objects visited during ErrorToString. This is
...@@ -1030,7 +1023,7 @@ function ErrorToString() { ...@@ -1030,7 +1023,7 @@ function ErrorToString() {
} }
} }
$installFunctions(GlobalError.prototype, DONT_ENUM, utils.InstallFunctions(GlobalError.prototype, DONT_ENUM,
['toString', ErrorToString]); ['toString', ErrorToString]);
$errorToString = ErrorToString; $errorToString = ErrorToString;
...@@ -1077,10 +1070,22 @@ MakeURIError = function() { ...@@ -1077,10 +1070,22 @@ MakeURIError = function() {
return MakeGenericError(GlobalURIError, kURIMalformed); return MakeGenericError(GlobalURIError, kURIMalformed);
} }
//Boilerplate for exceptions for stack overflows. Used from // Boilerplate for exceptions for stack overflows. Used from
//Isolate::StackOverflow(). // Isolate::StackOverflow().
$stackOverflowBoilerplate = MakeRangeError(kStackOverflow); $stackOverflowBoilerplate = MakeRangeError(kStackOverflow);
%DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack', %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack',
StackTraceGetter, StackTraceSetter, DONT_ENUM); StackTraceGetter, StackTraceSetter,
DONT_ENUM);
}) // Define actual captureStackTrace function after everything has been set up.
captureStackTrace = function captureStackTrace(obj, cons_opt) {
// Define accessors first, as this may fail and throw.
ObjectDefineProperty(obj, 'stack', { get: StackTraceGetter,
set: StackTraceSetter,
configurable: true });
%CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace);
};
GlobalError.captureStackTrace = captureStackTrace;
});
...@@ -23,6 +23,14 @@ var GlobalArray = global.Array; ...@@ -23,6 +23,14 @@ var GlobalArray = global.Array;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var InternalArray = utils.InternalArray; var InternalArray = utils.InternalArray;
var ObjectFreeze;
var ObjectIsFrozen;
utils.Import(function(from) {
ObjectFreeze = from.ObjectFreeze;
ObjectIsFrozen = from.ObjectIsFrozen;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Overview: // Overview:
...@@ -380,7 +388,7 @@ function ObjectObserve(object, callback, acceptList) { ...@@ -380,7 +388,7 @@ function ObjectObserve(object, callback, acceptList) {
throw MakeTypeError(kObserveGlobalProxy, "observe"); throw MakeTypeError(kObserveGlobalProxy, "observe");
if (!IS_SPEC_FUNCTION(callback)) if (!IS_SPEC_FUNCTION(callback))
throw MakeTypeError(kObserveNonFunction, "observe"); throw MakeTypeError(kObserveNonFunction, "observe");
if ($objectIsFrozen(callback)) if (ObjectIsFrozen(callback))
throw MakeTypeError(kObserveCallbackFrozen); throw MakeTypeError(kObserveCallbackFrozen);
var objectObserveFn = %GetObjectContextObjectObserve(object); var objectObserveFn = %GetObjectContextObjectObserve(object);
...@@ -473,7 +481,7 @@ function ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, type) { ...@@ -473,7 +481,7 @@ function ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, type) {
%DefineDataPropertyUnchecked( %DefineDataPropertyUnchecked(
newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE); newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE);
} }
$objectFreeze(newRecord); ObjectFreeze(newRecord);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, newRecord); ObjectInfoEnqueueInternalChangeRecord(objectInfo, newRecord);
} }
...@@ -525,8 +533,8 @@ function EnqueueSpliceRecord(array, index, removed, addedCount) { ...@@ -525,8 +533,8 @@ function EnqueueSpliceRecord(array, index, removed, addedCount) {
addedCount: addedCount addedCount: addedCount
}; };
$objectFreeze(changeRecord); ObjectFreeze(changeRecord);
$objectFreeze(changeRecord.removed); ObjectFreeze(changeRecord.removed);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord); ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
} }
...@@ -550,7 +558,7 @@ function NotifyChange(type, object, name, oldValue) { ...@@ -550,7 +558,7 @@ function NotifyChange(type, object, name, oldValue) {
}; };
} }
$objectFreeze(changeRecord); ObjectFreeze(changeRecord);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord); ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
} }
...@@ -607,7 +615,7 @@ function ObjectGetNotifier(object) { ...@@ -607,7 +615,7 @@ function ObjectGetNotifier(object) {
if (%IsJSGlobalProxy(object)) if (%IsJSGlobalProxy(object))
throw MakeTypeError(kObserveGlobalProxy, "getNotifier"); throw MakeTypeError(kObserveGlobalProxy, "getNotifier");
if ($objectIsFrozen(object)) return null; if (ObjectIsFrozen(object)) return null;
if (!%ObjectWasCreatedInCurrentOrigin(object)) return null; if (!%ObjectWasCreatedInCurrentOrigin(object)) return null;
...@@ -665,17 +673,17 @@ function ObserveMicrotaskRunner() { ...@@ -665,17 +673,17 @@ function ObserveMicrotaskRunner() {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
$installFunctions(GlobalObject, DONT_ENUM, [ utils.InstallFunctions(GlobalObject, DONT_ENUM, [
"deliverChangeRecords", ObjectDeliverChangeRecords, "deliverChangeRecords", ObjectDeliverChangeRecords,
"getNotifier", ObjectGetNotifier, "getNotifier", ObjectGetNotifier,
"observe", ObjectObserve, "observe", ObjectObserve,
"unobserve", ObjectUnobserve "unobserve", ObjectUnobserve
]); ]);
$installFunctions(GlobalArray, DONT_ENUM, [ utils.InstallFunctions(GlobalArray, DONT_ENUM, [
"observe", ArrayObserve, "observe", ArrayObserve,
"unobserve", ArrayUnobserve "unobserve", ArrayUnobserve
]); ]);
$installFunctions(notifierPrototype, DONT_ENUM, [ utils.InstallFunctions(notifierPrototype, DONT_ENUM, [
"notify", ObjectNotifierNotify, "notify", ObjectNotifierNotify,
"performChange", ObjectNotifierPerformChange "performChange", ObjectNotifierPerformChange
]); ]);
......
...@@ -13,45 +13,214 @@ ...@@ -13,45 +13,214 @@
var imports = UNDEFINED; var imports = UNDEFINED;
var exports = UNDEFINED; var exports = UNDEFINED;
var imports_from_experimental = UNDEFINED;
utils.Export = function Export(f) { // Export to other scripts.
// In normal natives, this exports functions to other normal natives.
// In experimental natives, this exports to other experimental natives and
// to normal natives that import using utils.ImportFromExperimental.
function Export(f) {
f.next = exports; f.next = exports;
exports = f; exports = f;
}; };
utils.Import = function Import(f) { // Import from other scripts.
// In normal natives, this imports from other normal natives.
// In experimental natives, this imports from other experimental natives and
// whitelisted exports from normal natives.
function Import(f) {
f.next = imports; f.next = imports;
imports = f; imports = f;
}; };
// In normal natives, import from experimental natives.
// Not callable from experimental natives.
function ImportFromExperimental(f) {
f.next = imports_from_experimental;
imports_from_experimental = f;
};
function SetFunctionName(f, name, prefix) {
if (IS_SYMBOL(name)) {
name = "[" + %SymbolDescription(name) + "]";
}
if (IS_UNDEFINED(prefix)) {
%FunctionSetName(f, name);
} else {
%FunctionSetName(f, prefix + " " + name);
}
}
function InstallConstants(object, constants) {
%CheckIsBootstrapping();
%OptimizeObjectForAddingMultipleProperties(object, constants.length >> 1);
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
for (var i = 0; i < constants.length; i += 2) {
var name = constants[i];
var k = constants[i + 1];
%AddNamedProperty(object, name, k, attributes);
}
%ToFastProperties(object);
}
function InstallFunctions(object, attributes, functions) {
%CheckIsBootstrapping();
%OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1);
for (var i = 0; i < functions.length; i += 2) {
var key = functions[i];
var f = functions[i + 1];
SetFunctionName(f, key);
%FunctionRemovePrototype(f);
%AddNamedProperty(object, key, f, attributes);
%SetNativeFlag(f);
}
%ToFastProperties(object);
}
// Helper function to install a getter-only accessor property.
function InstallGetter(object, name, getter, attributes) {
%CheckIsBootstrapping();
if (typeof attributes == "undefined") {
attributes = DONT_ENUM;
}
SetFunctionName(getter, name, "get");
%FunctionRemovePrototype(getter);
%DefineAccessorPropertyUnchecked(object, name, getter, null, attributes);
%SetNativeFlag(getter);
}
// Helper function to install a getter/setter accessor property.
function InstallGetterSetter(object, name, getter, setter) {
%CheckIsBootstrapping();
SetFunctionName(getter, name, "get");
SetFunctionName(setter, name, "set");
%FunctionRemovePrototype(getter);
%FunctionRemovePrototype(setter);
%DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM);
%SetNativeFlag(getter);
%SetNativeFlag(setter);
}
// Prevents changes to the prototype of a built-in function.
// The "prototype" property of the function object is made non-configurable,
// and the prototype object is made non-extensible. The latter prevents
// changing the __proto__ property.
function SetUpLockedPrototype(
constructor, fields, methods) {
%CheckIsBootstrapping();
var prototype = constructor.prototype;
// Install functions first, because this function is used to initialize
// PropertyDescriptor itself.
var property_count = (methods.length >> 1) + (fields ? fields.length : 0);
if (property_count >= 4) {
%OptimizeObjectForAddingMultipleProperties(prototype, property_count);
}
if (fields) {
for (var i = 0; i < fields.length; i++) {
%AddNamedProperty(prototype, fields[i],
UNDEFINED, DONT_ENUM | DONT_DELETE);
}
}
for (var i = 0; i < methods.length; i += 2) {
var key = methods[i];
var f = methods[i + 1];
%AddNamedProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY);
%SetNativeFlag(f);
}
%InternalSetPrototype(prototype, null);
%ToFastProperties(prototype);
}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// To be called by bootstrapper // To be called by bootstrapper
utils.PostNatives = function() { var experimental_exports = UNDEFINED;
function PostNatives(utils) {
%CheckIsBootstrapping(); %CheckIsBootstrapping();
var container = {}; var container = {};
for ( ; !IS_UNDEFINED(exports); exports = exports.next) exports(container); for ( ; !IS_UNDEFINED(exports); exports = exports.next) exports(container);
for ( ; !IS_UNDEFINED(imports); imports = imports.next) imports(container); for ( ; !IS_UNDEFINED(imports); imports = imports.next) imports(container);
// Whitelist of exports from normal natives to experimental natives.
var expose_to_experimental = [ var expose_to_experimental = [
"GetIterator",
"GetMethod",
"InnerArrayEvery",
"InnerArrayFilter",
"InnerArrayForEach",
"InnerArrayIndexOf",
"InnerArrayLastIndexOf",
"InnerArrayMap",
"InnerArrayReverse",
"InnerArraySome",
"InnerArraySort",
"IsNaN",
"MathMax", "MathMax",
"MathMin", "MathMin",
"ObjectIsFrozen",
"OwnPropertyKeys",
"ToNameArray",
]; ];
var experimental = {}; experimental_exports = {};
%OptimizeObjectForAddingMultipleProperties( %OptimizeObjectForAddingMultipleProperties(
experimental, expose_to_experimental.length); experimental_exports, expose_to_experimental.length);
for (var key of expose_to_experimental) experimental[key] = container[key]; for (var key of expose_to_experimental) {
%ToFastProperties(experimental); experimental_exports[key] = container[key];
}
%ToFastProperties(experimental_exports);
container = UNDEFINED; container = UNDEFINED;
utils.Export = UNDEFINED;
utils.PostNatives = UNDEFINED; utils.PostNatives = UNDEFINED;
utils.Import = function ImportFromExperimental(f) { utils.ImportFromExperimental = UNDEFINED;
f(experimental); };
};
function PostExperimentals(utils) {
%CheckIsBootstrapping();
for ( ; !IS_UNDEFINED(exports); exports = exports.next) {
exports(experimental_exports);
}
for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
imports(experimental_exports);
}
for ( ; !IS_UNDEFINED(imports_from_experimental);
imports_from_experimental = imports_from_experimental.next) {
imports_from_experimental(experimental_exports);
}
experimental_exports = UNDEFINED;
utils.PostExperimentals = UNDEFINED;
utils.Import = UNDEFINED;
utils.Export = UNDEFINED;
}; };
// -----------------------------------------------------------------------
InstallFunctions(utils, NONE, [
"Import", Import,
"Export", Export,
"ImportFromExperimental", ImportFromExperimental,
"SetFunctionName", SetFunctionName,
"InstallConstants", InstallConstants,
"InstallFunctions", InstallFunctions,
"InstallGetter", InstallGetter,
"InstallGetterSetter", InstallGetterSetter,
"SetUpLockedPrototype", SetUpLockedPrototype,
"PostNatives", PostNatives,
"PostExperimentals", PostExperimentals,
]);
}) })
...@@ -371,7 +371,7 @@ function PromiseHasUserDefinedRejectHandler() { ...@@ -371,7 +371,7 @@ function PromiseHasUserDefinedRejectHandler() {
%AddNamedProperty(GlobalPromise.prototype, symbolToStringTag, "Promise", %AddNamedProperty(GlobalPromise.prototype, symbolToStringTag, "Promise",
DONT_ENUM | READ_ONLY); DONT_ENUM | READ_ONLY);
$installFunctions(GlobalPromise, DONT_ENUM, [ utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
"defer", PromiseDeferred, "defer", PromiseDeferred,
"accept", PromiseResolved, "accept", PromiseResolved,
"reject", PromiseRejected, "reject", PromiseRejected,
...@@ -380,7 +380,7 @@ $installFunctions(GlobalPromise, DONT_ENUM, [ ...@@ -380,7 +380,7 @@ $installFunctions(GlobalPromise, DONT_ENUM, [
"resolve", PromiseCast "resolve", PromiseCast
]); ]);
$installFunctions(GlobalPromise.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
"chain", PromiseChain, "chain", PromiseChain,
"then", PromiseThen, "then", PromiseThen,
"catch", PromiseCatch "catch", PromiseCatch
......
...@@ -2,11 +2,8 @@ ...@@ -2,11 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
var $proxyDelegateCallAndConstruct;
var $proxyDerivedGetTrap; var $proxyDerivedGetTrap;
var $proxyDerivedHasTrap; var $proxyDerivedHasTrap;
var $proxyDerivedHasOwnTrap;
var $proxyDerivedKeysTrap;
var $proxyDerivedSetTrap; var $proxyDerivedSetTrap;
var $proxyEnumerate; var $proxyEnumerate;
...@@ -16,10 +13,19 @@ var $proxyEnumerate; ...@@ -16,10 +13,19 @@ var $proxyEnumerate;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// ----------------------------------------------------------------------------
// Imports
var GlobalFunction = global.Function; var GlobalFunction = global.Function;
var GlobalObject = global.Object; var GlobalObject = global.Object;
// ------------------------------------------------------------------- var ToNameArray;
utils.Import(function(from) {
ToNameArray = from.ToNameArray;
});
//----------------------------------------------------------------------------
function ProxyCreate(handler, proto) { function ProxyCreate(handler, proto) {
if (!IS_SPEC_OBJECT(handler)) if (!IS_SPEC_OBJECT(handler))
...@@ -175,7 +181,7 @@ function ProxyEnumerate(proxy) { ...@@ -175,7 +181,7 @@ function ProxyEnumerate(proxy) {
if (IS_UNDEFINED(handler.enumerate)) { if (IS_UNDEFINED(handler.enumerate)) {
return %Apply(DerivedEnumerateTrap, handler, [], 0, 0) return %Apply(DerivedEnumerateTrap, handler, [], 0, 0)
} else { } else {
return $toNameArray(handler.enumerate(), "enumerate", false) return ToNameArray(handler.enumerate(), "enumerate", false)
} }
} }
...@@ -185,17 +191,23 @@ var Proxy = new GlobalObject(); ...@@ -185,17 +191,23 @@ var Proxy = new GlobalObject();
%AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM); %AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM);
//Set up non-enumerable properties of the Proxy object. //Set up non-enumerable properties of the Proxy object.
$installFunctions(Proxy, DONT_ENUM, [ utils.InstallFunctions(Proxy, DONT_ENUM, [
"create", ProxyCreate, "create", ProxyCreate,
"createFunction", ProxyCreateFunction "createFunction", ProxyCreateFunction
]) ])
$proxyDelegateCallAndConstruct = DelegateCallAndConstruct; // -------------------------------------------------------------------
// Exports
$proxyDerivedGetTrap = DerivedGetTrap; $proxyDerivedGetTrap = DerivedGetTrap;
$proxyDerivedHasTrap = DerivedHasTrap; $proxyDerivedHasTrap = DerivedHasTrap;
$proxyDerivedHasOwnTrap = DerivedHasOwnTrap;
$proxyDerivedKeysTrap = DerivedKeysTrap;
$proxyDerivedSetTrap = DerivedSetTrap; $proxyDerivedSetTrap = DerivedSetTrap;
$proxyEnumerate = ProxyEnumerate; $proxyEnumerate = ProxyEnumerate;
utils.Export(function(to) {
to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct;
to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap;
to.ProxyDerivedKeysTrap = DerivedKeysTrap;
});
}) })
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
var $regexpExec;
var $regexpExecNoTests;
var $regexpLastMatchInfo;
var $regexpLastMatchInfoOverride; var $regexpLastMatchInfoOverride;
var harmony_regexps = false; var harmony_regexps = false;
var harmony_unicode_regexps = false; var harmony_unicode_regexps = false;
...@@ -22,12 +19,12 @@ var InternalPackedArray = utils.InternalPackedArray; ...@@ -22,12 +19,12 @@ var InternalPackedArray = utils.InternalPackedArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Property of the builtins object for recording the result of the last // Property of the builtins object for recording the result of the last
// regexp match. The property $regexpLastMatchInfo includes the matchIndices // regexp match. The property RegExpLastMatchInfo includes the matchIndices
// array of the last successful regexp match (an array of start/end index // array of the last successful regexp match (an array of start/end index
// pairs for the match and all the captured substrings), the invariant is // pairs for the match and all the captured substrings), the invariant is
// that there are at least two capture indeces. The array also contains // that there are at least two capture indeces. The array also contains
// the subject string for the last successful match. // the subject string for the last successful match.
$regexpLastMatchInfo = new InternalPackedArray( var RegExpLastMatchInfo = new InternalPackedArray(
2, // REGEXP_NUMBER_OF_CAPTURES 2, // REGEXP_NUMBER_OF_CAPTURES
"", // Last subject. "", // Last subject.
UNDEFINED, // Last input - settable with RegExpSetInput. UNDEFINED, // Last input - settable with RegExpSetInput.
...@@ -104,7 +101,7 @@ function RegExpCompileJS(pattern, flags) { ...@@ -104,7 +101,7 @@ function RegExpCompileJS(pattern, flags) {
function DoRegExpExec(regexp, string, index) { function DoRegExpExec(regexp, string, index) {
var result = %_RegExpExec(regexp, string, index, $regexpLastMatchInfo); var result = %_RegExpExec(regexp, string, index, RegExpLastMatchInfo);
if (result !== null) $regexpLastMatchInfoOverride = null; if (result !== null) $regexpLastMatchInfoOverride = null;
return result; return result;
} }
...@@ -138,7 +135,7 @@ endmacro ...@@ -138,7 +135,7 @@ endmacro
function RegExpExecNoTests(regexp, string, start) { function RegExpExecNoTests(regexp, string, start) {
// Must be called with RegExp, string and positive integer as arguments. // Must be called with RegExp, string and positive integer as arguments.
var matchInfo = %_RegExpExec(regexp, string, start, $regexpLastMatchInfo); var matchInfo = %_RegExpExec(regexp, string, start, RegExpLastMatchInfo);
if (matchInfo !== null) { if (matchInfo !== null) {
$regexpLastMatchInfoOverride = null; $regexpLastMatchInfoOverride = null;
RETURN_NEW_RESULT_FROM_MATCH_INFO(matchInfo, string); RETURN_NEW_RESULT_FROM_MATCH_INFO(matchInfo, string);
...@@ -171,8 +168,8 @@ function RegExpExecJS(string) { ...@@ -171,8 +168,8 @@ function RegExpExecJS(string) {
i = 0; i = 0;
} }
// matchIndices is either null or the $regexpLastMatchInfo array. // matchIndices is either null or the RegExpLastMatchInfo array.
var matchIndices = %_RegExpExec(this, string, i, $regexpLastMatchInfo); var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo);
if (IS_NULL(matchIndices)) { if (IS_NULL(matchIndices)) {
this.lastIndex = 0; this.lastIndex = 0;
...@@ -182,7 +179,7 @@ function RegExpExecJS(string) { ...@@ -182,7 +179,7 @@ function RegExpExecJS(string) {
// Successful match. // Successful match.
$regexpLastMatchInfoOverride = null; $regexpLastMatchInfoOverride = null;
if (updateLastIndex) { if (updateLastIndex) {
this.lastIndex = $regexpLastMatchInfo[CAPTURE1]; this.lastIndex = RegExpLastMatchInfo[CAPTURE1];
} }
RETURN_NEW_RESULT_FROM_MATCH_INFO(matchIndices, string); RETURN_NEW_RESULT_FROM_MATCH_INFO(matchIndices, string);
} }
...@@ -214,14 +211,14 @@ function RegExpTest(string) { ...@@ -214,14 +211,14 @@ function RegExpTest(string) {
this.lastIndex = 0; this.lastIndex = 0;
return false; return false;
} }
// matchIndices is either null or the $regexpLastMatchInfo array. // matchIndices is either null or the RegExpLastMatchInfo array.
var matchIndices = %_RegExpExec(this, string, i, $regexpLastMatchInfo); var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo);
if (IS_NULL(matchIndices)) { if (IS_NULL(matchIndices)) {
this.lastIndex = 0; this.lastIndex = 0;
return false; return false;
} }
$regexpLastMatchInfoOverride = null; $regexpLastMatchInfoOverride = null;
this.lastIndex = $regexpLastMatchInfo[CAPTURE1]; this.lastIndex = RegExpLastMatchInfo[CAPTURE1];
return true; return true;
} else { } else {
// Non-global, non-sticky regexp. // Non-global, non-sticky regexp.
...@@ -235,8 +232,8 @@ function RegExpTest(string) { ...@@ -235,8 +232,8 @@ function RegExpTest(string) {
%_StringCharCodeAt(regexp.source, 2) != 63) { // '?' %_StringCharCodeAt(regexp.source, 2) != 63) { // '?'
regexp = TrimRegExp(regexp); regexp = TrimRegExp(regexp);
} }
// matchIndices is either null or the $regexpLastMatchInfo array. // matchIndices is either null or the RegExpLastMatchInfo array.
var matchIndices = %_RegExpExec(regexp, string, 0, $regexpLastMatchInfo); var matchIndices = %_RegExpExec(regexp, string, 0, RegExpLastMatchInfo);
if (IS_NULL(matchIndices)) { if (IS_NULL(matchIndices)) {
this.lastIndex = 0; this.lastIndex = 0;
return false; return false;
...@@ -281,10 +278,10 @@ function RegExpGetLastMatch() { ...@@ -281,10 +278,10 @@ function RegExpGetLastMatch() {
if ($regexpLastMatchInfoOverride !== null) { if ($regexpLastMatchInfoOverride !== null) {
return OVERRIDE_MATCH($regexpLastMatchInfoOverride); return OVERRIDE_MATCH($regexpLastMatchInfoOverride);
} }
var regExpSubject = LAST_SUBJECT($regexpLastMatchInfo); var regExpSubject = LAST_SUBJECT(RegExpLastMatchInfo);
return %_SubString(regExpSubject, return %_SubString(regExpSubject,
$regexpLastMatchInfo[CAPTURE0], RegExpLastMatchInfo[CAPTURE0],
$regexpLastMatchInfo[CAPTURE1]); RegExpLastMatchInfo[CAPTURE1]);
} }
...@@ -294,14 +291,14 @@ function RegExpGetLastParen() { ...@@ -294,14 +291,14 @@ function RegExpGetLastParen() {
if (override.length <= 3) return ''; if (override.length <= 3) return '';
return override[override.length - 3]; return override[override.length - 3];
} }
var length = NUMBER_OF_CAPTURES($regexpLastMatchInfo); var length = NUMBER_OF_CAPTURES(RegExpLastMatchInfo);
if (length <= 2) return ''; // There were no captures. if (length <= 2) return ''; // There were no captures.
// We match the SpiderMonkey behavior: return the substring defined by the // We match the SpiderMonkey behavior: return the substring defined by the
// last pair (after the first pair) of elements of the capture array even if // last pair (after the first pair) of elements of the capture array even if
// it is empty. // it is empty.
var regExpSubject = LAST_SUBJECT($regexpLastMatchInfo); var regExpSubject = LAST_SUBJECT(RegExpLastMatchInfo);
var start = $regexpLastMatchInfo[CAPTURE(length - 2)]; var start = RegExpLastMatchInfo[CAPTURE(length - 2)];
var end = $regexpLastMatchInfo[CAPTURE(length - 1)]; var end = RegExpLastMatchInfo[CAPTURE(length - 1)];
if (start != -1 && end != -1) { if (start != -1 && end != -1) {
return %_SubString(regExpSubject, start, end); return %_SubString(regExpSubject, start, end);
} }
...@@ -313,8 +310,8 @@ function RegExpGetLeftContext() { ...@@ -313,8 +310,8 @@ function RegExpGetLeftContext() {
var start_index; var start_index;
var subject; var subject;
if (!$regexpLastMatchInfoOverride) { if (!$regexpLastMatchInfoOverride) {
start_index = $regexpLastMatchInfo[CAPTURE0]; start_index = RegExpLastMatchInfo[CAPTURE0];
subject = LAST_SUBJECT($regexpLastMatchInfo); subject = LAST_SUBJECT(RegExpLastMatchInfo);
} else { } else {
var override = $regexpLastMatchInfoOverride; var override = $regexpLastMatchInfoOverride;
start_index = OVERRIDE_POS(override); start_index = OVERRIDE_POS(override);
...@@ -328,8 +325,8 @@ function RegExpGetRightContext() { ...@@ -328,8 +325,8 @@ function RegExpGetRightContext() {
var start_index; var start_index;
var subject; var subject;
if (!$regexpLastMatchInfoOverride) { if (!$regexpLastMatchInfoOverride) {
start_index = $regexpLastMatchInfo[CAPTURE1]; start_index = RegExpLastMatchInfo[CAPTURE1];
subject = LAST_SUBJECT($regexpLastMatchInfo); subject = LAST_SUBJECT(RegExpLastMatchInfo);
} else { } else {
var override = $regexpLastMatchInfoOverride; var override = $regexpLastMatchInfoOverride;
subject = OVERRIDE_SUBJECT(override); subject = OVERRIDE_SUBJECT(override);
...@@ -352,11 +349,11 @@ function RegExpMakeCaptureGetter(n) { ...@@ -352,11 +349,11 @@ function RegExpMakeCaptureGetter(n) {
return ''; return '';
} }
var index = n * 2; var index = n * 2;
if (index >= NUMBER_OF_CAPTURES($regexpLastMatchInfo)) return ''; if (index >= NUMBER_OF_CAPTURES(RegExpLastMatchInfo)) return '';
var matchStart = $regexpLastMatchInfo[CAPTURE(index)]; var matchStart = RegExpLastMatchInfo[CAPTURE(index)];
var matchEnd = $regexpLastMatchInfo[CAPTURE(index + 1)]; var matchEnd = RegExpLastMatchInfo[CAPTURE(index + 1)];
if (matchStart == -1 || matchEnd == -1) return ''; if (matchStart == -1 || matchEnd == -1) return '';
return %_SubString(LAST_SUBJECT($regexpLastMatchInfo), matchStart, matchEnd); return %_SubString(LAST_SUBJECT(RegExpLastMatchInfo), matchStart, matchEnd);
}; };
} }
...@@ -367,7 +364,7 @@ function RegExpMakeCaptureGetter(n) { ...@@ -367,7 +364,7 @@ function RegExpMakeCaptureGetter(n) {
GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
%SetCode(GlobalRegExp, RegExpConstructor); %SetCode(GlobalRegExp, RegExpConstructor);
$installFunctions(GlobalRegExp.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
"exec", RegExpExecJS, "exec", RegExpExecJS,
"test", RegExpTest, "test", RegExpTest,
"toString", RegExpToString, "toString", RegExpToString,
...@@ -381,11 +378,11 @@ $installFunctions(GlobalRegExp.prototype, DONT_ENUM, [ ...@@ -381,11 +378,11 @@ $installFunctions(GlobalRegExp.prototype, DONT_ENUM, [
// value is set the value it is set to is coerced to a string. // value is set the value it is set to is coerced to a string.
// Getter and setter for the input. // Getter and setter for the input.
var RegExpGetInput = function() { var RegExpGetInput = function() {
var regExpInput = LAST_INPUT($regexpLastMatchInfo); var regExpInput = LAST_INPUT(RegExpLastMatchInfo);
return IS_UNDEFINED(regExpInput) ? "" : regExpInput; return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
}; };
var RegExpSetInput = function(string) { var RegExpSetInput = function(string) {
LAST_INPUT($regexpLastMatchInfo) = $toString(string); LAST_INPUT(RegExpLastMatchInfo) = $toString(string);
}; };
%OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
...@@ -443,7 +440,13 @@ for (var i = 1; i < 10; ++i) { ...@@ -443,7 +440,13 @@ for (var i = 1; i < 10; ++i) {
} }
%ToFastProperties(GlobalRegExp); %ToFastProperties(GlobalRegExp);
$regexpExecNoTests = RegExpExecNoTests; // -------------------------------------------------------------------
$regexpExec = DoRegExpExec; // Exports
utils.Export(function(to) {
to.RegExpExec = DoRegExpExec;
to.RegExpExecNoTests = RegExpExecNoTests;
to.RegExpLastMatchInfo = RegExpLastMatchInfo;
});
}) })
...@@ -8,9 +8,18 @@ ...@@ -8,9 +8,18 @@
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalString = global.String; var GlobalString = global.String;
//------------------------------------------------------------------- var ArrayIteratorCreateResultObject;
utils.Import(function(from) {
ArrayIteratorCreateResultObject = from.ArrayIteratorCreateResultObject;
});
// -------------------------------------------------------------------
var stringIteratorIteratedStringSymbol = var stringIteratorIteratedStringSymbol =
GLOBAL_PRIVATE("StringIterator#iteratedString"); GLOBAL_PRIVATE("StringIterator#iteratedString");
...@@ -41,7 +50,7 @@ function StringIteratorNext() { ...@@ -41,7 +50,7 @@ function StringIteratorNext() {
var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol); var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol);
if (IS_UNDEFINED(s)) { if (IS_UNDEFINED(s)) {
return $iteratorCreateResultObject(UNDEFINED, true); return ArrayIteratorCreateResultObject(UNDEFINED, true);
} }
var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol); var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol);
...@@ -50,7 +59,7 @@ function StringIteratorNext() { ...@@ -50,7 +59,7 @@ function StringIteratorNext() {
if (position >= length) { if (position >= length) {
SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol,
UNDEFINED); UNDEFINED);
return $iteratorCreateResultObject(UNDEFINED, true); return ArrayIteratorCreateResultObject(UNDEFINED, true);
} }
var first = %_StringCharCodeAt(s, position); var first = %_StringCharCodeAt(s, position);
...@@ -67,7 +76,7 @@ function StringIteratorNext() { ...@@ -67,7 +76,7 @@ function StringIteratorNext() {
SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, position); SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, position);
return $iteratorCreateResultObject(resultString, false); return ArrayIteratorCreateResultObject(resultString, false);
} }
...@@ -81,13 +90,13 @@ function StringPrototypeIterator() { ...@@ -81,13 +90,13 @@ function StringPrototypeIterator() {
%FunctionSetPrototype(StringIterator, {__proto__: $iteratorPrototype}); %FunctionSetPrototype(StringIterator, {__proto__: $iteratorPrototype});
%FunctionSetInstanceClassName(StringIterator, 'String Iterator'); %FunctionSetInstanceClassName(StringIterator, 'String Iterator');
$installFunctions(StringIterator.prototype, DONT_ENUM, [ utils.InstallFunctions(StringIterator.prototype, DONT_ENUM, [
'next', StringIteratorNext 'next', StringIteratorNext
]); ]);
%AddNamedProperty(StringIterator.prototype, symbolToStringTag, %AddNamedProperty(StringIterator.prototype, symbolToStringTag,
"String Iterator", READ_ONLY | DONT_ENUM); "String Iterator", READ_ONLY | DONT_ENUM);
$setFunctionName(StringPrototypeIterator, symbolIterator); utils.SetFunctionName(StringPrototypeIterator, symbolIterator);
%AddNamedProperty(GlobalString.prototype, symbolIterator, %AddNamedProperty(GlobalString.prototype, symbolIterator,
StringPrototypeIterator, DONT_ENUM); StringPrototypeIterator, DONT_ENUM);
......
...@@ -16,10 +16,16 @@ var InternalPackedArray = utils.InternalPackedArray; ...@@ -16,10 +16,16 @@ var InternalPackedArray = utils.InternalPackedArray;
var MathMax; var MathMax;
var MathMin; var MathMin;
var RegExpExec;
var RegExpExecNoTests;
var RegExpLastMatchInfo;
utils.Import(function(from) { utils.Import(function(from) {
MathMax = from.MathMax; MathMax = from.MathMax;
MathMin = from.MathMin; MathMin = from.MathMin;
RegExpExec = from.RegExpExec;
RegExpExecNoTests = from.RegExpExecNoTests;
RegExpLastMatchInfo = from.RegExpLastMatchInfo;
}); });
//------------------------------------------------------------------- //-------------------------------------------------------------------
...@@ -162,15 +168,15 @@ function StringMatchJS(regexp) { ...@@ -162,15 +168,15 @@ function StringMatchJS(regexp) {
// value is discarded. // value is discarded.
var lastIndex = regexp.lastIndex; var lastIndex = regexp.lastIndex;
TO_INTEGER_FOR_SIDE_EFFECT(lastIndex); TO_INTEGER_FOR_SIDE_EFFECT(lastIndex);
if (!regexp.global) return $regexpExecNoTests(regexp, subject, 0); if (!regexp.global) return RegExpExecNoTests(regexp, subject, 0);
var result = %StringMatch(subject, regexp, $regexpLastMatchInfo); var result = %StringMatch(subject, regexp, RegExpLastMatchInfo);
if (result !== null) $regexpLastMatchInfoOverride = null; if (result !== null) $regexpLastMatchInfoOverride = null;
regexp.lastIndex = 0; regexp.lastIndex = 0;
return result; return result;
} }
// Non-regexp argument. // Non-regexp argument.
regexp = new GlobalRegExp(regexp); regexp = new GlobalRegExp(regexp);
return $regexpExecNoTests(regexp, subject, 0); return RegExpExecNoTests(regexp, subject, 0);
} }
...@@ -195,7 +201,7 @@ function StringNormalizeJS(form) { ...@@ -195,7 +201,7 @@ function StringNormalizeJS(form) {
} }
// This has the same size as the $regexpLastMatchInfo array, and can be used // 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 // for functions that expect that structure to be returned. It is used when
// the needle is a string rather than a regexp. In this case we can't update // the needle is a string rather than a regexp. In this case we can't update
// lastMatchArray without erroneously affecting the properties on the global // lastMatchArray without erroneously affecting the properties on the global
...@@ -237,7 +243,7 @@ function StringReplace(search, replace) { ...@@ -237,7 +243,7 @@ function StringReplace(search, replace) {
if (!search.global) { if (!search.global) {
// Non-global regexp search, string replace. // Non-global regexp search, string replace.
var match = $regexpExec(search, subject, 0); var match = RegExpExec(search, subject, 0);
if (match == null) { if (match == null) {
search.lastIndex = 0 search.lastIndex = 0
return subject; return subject;
...@@ -246,7 +252,7 @@ function StringReplace(search, replace) { ...@@ -246,7 +252,7 @@ function StringReplace(search, replace) {
return %_SubString(subject, 0, match[CAPTURE0]) + return %_SubString(subject, 0, match[CAPTURE0]) +
%_SubString(subject, match[CAPTURE1], subject.length) %_SubString(subject, match[CAPTURE1], subject.length)
} }
return ExpandReplacement(replace, subject, $regexpLastMatchInfo, return ExpandReplacement(replace, subject, RegExpLastMatchInfo,
%_SubString(subject, 0, match[CAPTURE0])) + %_SubString(subject, 0, match[CAPTURE0])) +
%_SubString(subject, match[CAPTURE1], subject.length); %_SubString(subject, match[CAPTURE1], subject.length);
} }
...@@ -255,17 +261,17 @@ function StringReplace(search, replace) { ...@@ -255,17 +261,17 @@ function StringReplace(search, replace) {
search.lastIndex = 0; search.lastIndex = 0;
if ($regexpLastMatchInfoOverride == null) { if ($regexpLastMatchInfoOverride == null) {
return %StringReplaceGlobalRegExpWithString( return %StringReplaceGlobalRegExpWithString(
subject, search, replace, $regexpLastMatchInfo); subject, search, replace, RegExpLastMatchInfo);
} else { } else {
// We use this hack to detect whether StringReplaceRegExpWithString // We use this hack to detect whether StringReplaceRegExpWithString
// found at least one hit. In that case we need to remove any // found at least one hit. In that case we need to remove any
// override. // override.
var saved_subject = $regexpLastMatchInfo[LAST_SUBJECT_INDEX]; var saved_subject = RegExpLastMatchInfo[LAST_SUBJECT_INDEX];
$regexpLastMatchInfo[LAST_SUBJECT_INDEX] = 0; RegExpLastMatchInfo[LAST_SUBJECT_INDEX] = 0;
var answer = %StringReplaceGlobalRegExpWithString( var answer = %StringReplaceGlobalRegExpWithString(
subject, search, replace, $regexpLastMatchInfo); subject, search, replace, RegExpLastMatchInfo);
if (%_IsSmi($regexpLastMatchInfo[LAST_SUBJECT_INDEX])) { if (%_IsSmi(RegExpLastMatchInfo[LAST_SUBJECT_INDEX])) {
$regexpLastMatchInfo[LAST_SUBJECT_INDEX] = saved_subject; RegExpLastMatchInfo[LAST_SUBJECT_INDEX] = saved_subject;
} else { } else {
$regexpLastMatchInfoOverride = null; $regexpLastMatchInfoOverride = null;
} }
...@@ -431,7 +437,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) { ...@@ -431,7 +437,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
} }
var res = %RegExpExecMultiple(regexp, var res = %RegExpExecMultiple(regexp,
subject, subject,
$regexpLastMatchInfo, RegExpLastMatchInfo,
resultArray); resultArray);
regexp.lastIndex = 0; regexp.lastIndex = 0;
if (IS_NULL(res)) { if (IS_NULL(res)) {
...@@ -440,7 +446,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) { ...@@ -440,7 +446,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
return subject; return subject;
} }
var len = res.length; var len = res.length;
if (NUMBER_OF_CAPTURES($regexpLastMatchInfo) == 2) { if (NUMBER_OF_CAPTURES(RegExpLastMatchInfo) == 2) {
// If the number of captures is two then there are no explicit captures in // 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 // 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. // this case we can simplify quite a bit and end up with something faster.
...@@ -494,7 +500,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) { ...@@ -494,7 +500,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) { function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
var matchInfo = $regexpExec(regexp, subject, 0); var matchInfo = RegExpExec(regexp, subject, 0);
if (IS_NULL(matchInfo)) { if (IS_NULL(matchInfo)) {
regexp.lastIndex = 0; regexp.lastIndex = 0;
return subject; return subject;
...@@ -542,7 +548,7 @@ function StringSearch(re) { ...@@ -542,7 +548,7 @@ function StringSearch(re) {
} else { } else {
regexp = new GlobalRegExp(re); regexp = new GlobalRegExp(re);
} }
var match = $regexpExec(regexp, TO_STRING_INLINE(this), 0); var match = RegExpExec(regexp, TO_STRING_INLINE(this), 0);
if (match) { if (match) {
return match[CAPTURE0]; return match[CAPTURE0];
} }
...@@ -628,7 +634,7 @@ function StringSplitJS(separator, limit) { ...@@ -628,7 +634,7 @@ function StringSplitJS(separator, limit) {
function StringSplitOnRegExp(subject, separator, limit, length) { function StringSplitOnRegExp(subject, separator, limit, length) {
if (length === 0) { if (length === 0) {
if ($regexpExec(separator, subject, 0, 0) != null) { if (RegExpExec(separator, subject, 0, 0) != null) {
return []; return [];
} }
return [subject]; return [subject];
...@@ -647,7 +653,7 @@ function StringSplitOnRegExp(subject, separator, limit, length) { ...@@ -647,7 +653,7 @@ function StringSplitOnRegExp(subject, separator, limit, length) {
break; break;
} }
var matchInfo = $regexpExec(separator, subject, startIndex); var matchInfo = RegExpExec(separator, subject, startIndex);
if (matchInfo == null || length === (startMatch = matchInfo[CAPTURE0])) { if (matchInfo == null || length === (startMatch = matchInfo[CAPTURE0])) {
result[result.length] = %_SubString(subject, currentIndex, length); result[result.length] = %_SubString(subject, currentIndex, length);
break; break;
...@@ -1124,14 +1130,14 @@ function StringRaw(callSite) { ...@@ -1124,14 +1130,14 @@ function StringRaw(callSite) {
GlobalString.prototype, "constructor", GlobalString, DONT_ENUM); GlobalString.prototype, "constructor", GlobalString, DONT_ENUM);
// Set up the non-enumerable functions on the String object. // Set up the non-enumerable functions on the String object.
$installFunctions(GlobalString, DONT_ENUM, [ utils.InstallFunctions(GlobalString, DONT_ENUM, [
"fromCharCode", StringFromCharCode, "fromCharCode", StringFromCharCode,
"fromCodePoint", StringFromCodePoint, "fromCodePoint", StringFromCodePoint,
"raw", StringRaw "raw", StringRaw
]); ]);
// Set up the non-enumerable functions on the String prototype object. // Set up the non-enumerable functions on the String prototype object.
$installFunctions(GlobalString.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [
"valueOf", StringValueOf, "valueOf", StringValueOf,
"toString", StringToString, "toString", StringToString,
"charAt", StringCharAtJS, "charAt", StringCharAtJS,
......
...@@ -18,9 +18,18 @@ var $symbolToString; ...@@ -18,9 +18,18 @@ var $symbolToString;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalObject = global.Object; var GlobalObject = global.Object;
var GlobalSymbol = global.Symbol; var GlobalSymbol = global.Symbol;
var ObjectGetOwnPropertyKeys;
utils.Import(function(from) {
ObjectGetOwnPropertyKeys = from.ObjectGetOwnPropertyKeys;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
function SymbolConstructor(x) { function SymbolConstructor(x) {
...@@ -73,7 +82,7 @@ function ObjectGetOwnPropertySymbols(obj) { ...@@ -73,7 +82,7 @@ function ObjectGetOwnPropertySymbols(obj) {
// TODO(arv): Proxies use a shared trap for String and Symbol keys. // TODO(arv): Proxies use a shared trap for String and Symbol keys.
return $objectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING); return ObjectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
...@@ -81,7 +90,7 @@ function ObjectGetOwnPropertySymbols(obj) { ...@@ -81,7 +90,7 @@ function ObjectGetOwnPropertySymbols(obj) {
%SetCode(GlobalSymbol, SymbolConstructor); %SetCode(GlobalSymbol, SymbolConstructor);
%FunctionSetPrototype(GlobalSymbol, new GlobalObject()); %FunctionSetPrototype(GlobalSymbol, new GlobalObject());
$installConstants(GlobalSymbol, [ utils.InstallConstants(GlobalSymbol, [
// TODO(rossberg): expose when implemented. // TODO(rossberg): expose when implemented.
// "hasInstance", symbolHasInstance, // "hasInstance", symbolHasInstance,
// "isConcatSpreadable", symbolIsConcatSpreadable, // "isConcatSpreadable", symbolIsConcatSpreadable,
...@@ -93,7 +102,7 @@ $installConstants(GlobalSymbol, [ ...@@ -93,7 +102,7 @@ $installConstants(GlobalSymbol, [
"unscopables", symbolUnscopables "unscopables", symbolUnscopables
]); ]);
$installFunctions(GlobalSymbol, DONT_ENUM, [ utils.InstallFunctions(GlobalSymbol, DONT_ENUM, [
"for", SymbolFor, "for", SymbolFor,
"keyFor", SymbolKeyFor "keyFor", SymbolKeyFor
]); ]);
...@@ -103,12 +112,12 @@ $installFunctions(GlobalSymbol, DONT_ENUM, [ ...@@ -103,12 +112,12 @@ $installFunctions(GlobalSymbol, DONT_ENUM, [
%AddNamedProperty( %AddNamedProperty(
GlobalSymbol.prototype, symbolToStringTag, "Symbol", DONT_ENUM | READ_ONLY); GlobalSymbol.prototype, symbolToStringTag, "Symbol", DONT_ENUM | READ_ONLY);
$installFunctions(GlobalSymbol.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalSymbol.prototype, DONT_ENUM, [
"toString", SymbolToString, "toString", SymbolToString,
"valueOf", SymbolValueOf "valueOf", SymbolValueOf
]); ]);
$installFunctions(GlobalObject, DONT_ENUM, [ utils.InstallFunctions(GlobalObject, DONT_ENUM, [
"getOwnPropertySymbols", ObjectGetOwnPropertySymbols "getOwnPropertySymbols", ObjectGetOwnPropertySymbols
]); ]);
......
...@@ -1023,7 +1023,7 @@ function MathLog2(x) { ...@@ -1023,7 +1023,7 @@ function MathLog2(x) {
//------------------------------------------------------------------- //-------------------------------------------------------------------
$installFunctions(GlobalMath, DONT_ENUM, [ utils.InstallFunctions(GlobalMath, DONT_ENUM, [
"cos", MathCos, "cos", MathCos,
"sin", MathSin, "sin", MathSin,
"tan", MathTan, "tan", MathTan,
......
...@@ -16,17 +16,6 @@ var GlobalArrayBuffer = global.ArrayBuffer; ...@@ -16,17 +16,6 @@ var GlobalArrayBuffer = global.ArrayBuffer;
var GlobalDataView = global.DataView; var GlobalDataView = global.DataView;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var MathMax;
var MathMin;
utils.Import(function(from) {
MathMax = from.MathMax;
MathMin = from.MathMin;
});
// -------------------------------------------------------------------
macro TYPED_ARRAYS(FUNCTION) macro TYPED_ARRAYS(FUNCTION)
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize. // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
FUNCTION(1, Uint8Array, 1) FUNCTION(1, Uint8Array, 1)
...@@ -46,6 +35,14 @@ endmacro ...@@ -46,6 +35,14 @@ endmacro
TYPED_ARRAYS(DECLARE_GLOBALS) TYPED_ARRAYS(DECLARE_GLOBALS)
var MathMax;
var MathMin;
utils.Import(function(from) {
MathMax = from.MathMax;
MathMin = from.MathMin;
});
// --------------- Typed Arrays --------------------- // --------------- Typed Arrays ---------------------
macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
...@@ -326,16 +323,16 @@ macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) ...@@ -326,16 +323,16 @@ macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
%AddNamedProperty(GlobalNAME.prototype, %AddNamedProperty(GlobalNAME.prototype,
"BYTES_PER_ELEMENT", ELEMENT_SIZE, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
READ_ONLY | DONT_ENUM | DONT_DELETE); READ_ONLY | DONT_ENUM | DONT_DELETE);
$installGetter(GlobalNAME.prototype, "buffer", NAME_GetBuffer); utils.InstallGetter(GlobalNAME.prototype, "buffer", NAME_GetBuffer);
$installGetter(GlobalNAME.prototype, "byteOffset", NAME_GetByteOffset, utils.InstallGetter(GlobalNAME.prototype, "byteOffset", NAME_GetByteOffset,
DONT_ENUM | DONT_DELETE); DONT_ENUM | DONT_DELETE);
$installGetter(GlobalNAME.prototype, "byteLength", NAME_GetByteLength, utils.InstallGetter(GlobalNAME.prototype, "byteLength", NAME_GetByteLength,
DONT_ENUM | DONT_DELETE); DONT_ENUM | DONT_DELETE);
$installGetter(GlobalNAME.prototype, "length", NAME_GetLength, utils.InstallGetter(GlobalNAME.prototype, "length", NAME_GetLength,
DONT_ENUM | DONT_DELETE); DONT_ENUM | DONT_DELETE);
$installGetter(GlobalNAME.prototype, symbolToStringTag, utils.InstallGetter(GlobalNAME.prototype, symbolToStringTag,
TypedArrayGetToStringTag); TypedArrayGetToStringTag);
$installFunctions(GlobalNAME.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [
"subarray", NAMESubArray, "subarray", NAMESubArray,
"set", TypedArraySet "set", TypedArraySet
]); ]);
...@@ -442,11 +439,13 @@ DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER) ...@@ -442,11 +439,13 @@ DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
%AddNamedProperty(GlobalDataView.prototype, symbolToStringTag, "DataView", %AddNamedProperty(GlobalDataView.prototype, symbolToStringTag, "DataView",
READ_ONLY|DONT_ENUM); READ_ONLY|DONT_ENUM);
$installGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS); utils.InstallGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS);
$installGetter(GlobalDataView.prototype, "byteOffset", DataViewGetByteOffset); utils.InstallGetter(GlobalDataView.prototype, "byteOffset",
$installGetter(GlobalDataView.prototype, "byteLength", DataViewGetByteLength); DataViewGetByteOffset);
utils.InstallGetter(GlobalDataView.prototype, "byteLength",
DataViewGetByteLength);
$installFunctions(GlobalDataView.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalDataView.prototype, DONT_ENUM, [
"getInt8", DataViewGetInt8JS, "getInt8", DataViewGetInt8JS,
"setInt8", DataViewSetInt8JS, "setInt8", DataViewSetInt8JS,
......
...@@ -360,7 +360,7 @@ function URIEncodeComponent(component) { ...@@ -360,7 +360,7 @@ function URIEncodeComponent(component) {
// Set up non-enumerable URI functions on the global object and set // Set up non-enumerable URI functions on the global object and set
// their names. // their names.
$installFunctions(global, DONT_ENUM, [ utils.InstallFunctions(global, DONT_ENUM, [
"escape", URIEscapeJS, "escape", URIEscapeJS,
"unescape", URIUnescapeJS, "unescape", URIUnescapeJS,
"decodeURI", URIDecode, "decodeURI", URIDecode,
......
This diff is collapsed.
...@@ -88,7 +88,7 @@ function WeakMapDelete(key) { ...@@ -88,7 +88,7 @@ function WeakMapDelete(key) {
DONT_ENUM | READ_ONLY); DONT_ENUM | READ_ONLY);
// Set up the non-enumerable functions on the WeakMap prototype object. // Set up the non-enumerable functions on the WeakMap prototype object.
$installFunctions(GlobalWeakMap.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalWeakMap.prototype, DONT_ENUM, [
"get", WeakMapGet, "get", WeakMapGet,
"set", WeakMapSet, "set", WeakMapSet,
"has", WeakMapHas, "has", WeakMapHas,
...@@ -158,7 +158,7 @@ function WeakSetDelete(value) { ...@@ -158,7 +158,7 @@ function WeakSetDelete(value) {
DONT_ENUM | READ_ONLY); DONT_ENUM | READ_ONLY);
// Set up the non-enumerable functions on the WeakSet prototype object. // Set up the non-enumerable functions on the WeakSet prototype object.
$installFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [
"add", WeakSetAdd, "add", WeakSetAdd,
"has", WeakSetHas, "has", WeakSetHas,
"delete", WeakSetDelete "delete", WeakSetDelete
......
...@@ -29,5 +29,5 @@ ...@@ -29,5 +29,5 @@
// Test call of JS runtime functions. // Test call of JS runtime functions.
var a = %$isNaN(0/0); var a = %MakeError(0, "error");
assertEquals(true, a); assertInstanceof(a, Error);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment