Use import/export for more functions (instead of js builtins object).
R=cbruni@chromium.org Review URL: https://codereview.chromium.org/1404943002 Cr-Commit-Position: refs/heads/master@{#31285}
This commit is contained in:
parent
5a3929ea4f
commit
558f1441c6
@ -2041,14 +2041,6 @@ bool Genesis::InstallNatives(ContextType context_type) {
|
||||
builtins->set_native_context(*native_context());
|
||||
builtins->set_global_proxy(native_context()->global_proxy());
|
||||
|
||||
|
||||
// Set up the 'builtin' property, which refers to the js builtins object.
|
||||
static const PropertyAttributes attributes =
|
||||
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
|
||||
Handle<String> builtins_string =
|
||||
factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("builtins"));
|
||||
JSObject::AddProperty(builtins, builtins_string, builtins, attributes);
|
||||
|
||||
// Set up the reference from the global object to the builtins object.
|
||||
JSGlobalObject::cast(native_context()->global_object())->
|
||||
set_builtins(*builtins);
|
||||
|
@ -8,17 +8,27 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var ErrorToString;
|
||||
var FunctionSourceString;
|
||||
var GlobalArray = global.Array;
|
||||
var IsNaN = global.isNaN;
|
||||
var JSONStringify = global.JSON.stringify;
|
||||
var MapEntries;
|
||||
var MapIteratorNext;
|
||||
var MathMin = global.Math.min;
|
||||
var promiseStatusSymbol = utils.ImportNow("promise_status_symbol");
|
||||
var promiseValueSymbol = utils.ImportNow("promise_value_symbol");
|
||||
var SetIteratorNext;
|
||||
var SetValues;
|
||||
var SymbolToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ErrorToString = from.ErrorToString;
|
||||
FunctionSourceString = from.FunctionSourceString;
|
||||
MapEntries = from.MapEntries;
|
||||
MapIteratorNext = from.MapIteratorNext;
|
||||
SetIteratorNext = from.SetIteratorNext;
|
||||
SetValues = from.SetValues;
|
||||
SymbolToString = from.SymbolToString;
|
||||
});
|
||||
|
||||
@ -1298,7 +1308,7 @@ ErrorMirror.prototype.toText = function() {
|
||||
// Use the same text representation as in messages.js.
|
||||
var text;
|
||||
try {
|
||||
text = %_CallFunction(this.value_, builtins.$errorToString);
|
||||
text = %_CallFunction(this.value_, ErrorToString);
|
||||
} catch (e) {
|
||||
text = '#<Error>';
|
||||
}
|
||||
@ -1368,7 +1378,7 @@ MapMirror.prototype.entries = function(opt_limit) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var iter = %_CallFunction(this.value_, builtins.$mapEntries);
|
||||
var iter = %_CallFunction(this.value_, MapEntries);
|
||||
var next;
|
||||
while ((!opt_limit || result.length < opt_limit) &&
|
||||
!(next = iter.next()).done) {
|
||||
@ -1410,8 +1420,8 @@ SetMirror.prototype.values = function(opt_limit) {
|
||||
return %GetWeakSetValues(this.value_, opt_limit || 0);
|
||||
}
|
||||
|
||||
var iter = %_CallFunction(this.value_, builtins.$setValues);
|
||||
return IteratorGetValues_(iter, builtins.$setIteratorNext, opt_limit);
|
||||
var iter = %_CallFunction(this.value_, SetValues);
|
||||
return IteratorGetValues_(iter, SetIteratorNext, opt_limit);
|
||||
};
|
||||
|
||||
|
||||
@ -1431,11 +1441,11 @@ inherits(IteratorMirror, ObjectMirror);
|
||||
IteratorMirror.prototype.preview = function(opt_limit) {
|
||||
if (IS_MAP_ITERATOR(this.value_)) {
|
||||
return IteratorGetValues_(%MapIteratorClone(this.value_),
|
||||
builtins.$mapIteratorNext,
|
||||
MapIteratorNext,
|
||||
opt_limit);
|
||||
} else if (IS_SET_ITERATOR(this.value_)) {
|
||||
return IteratorGetValues_(%SetIteratorClone(this.value_),
|
||||
builtins.$setIteratorNext,
|
||||
SetIteratorNext,
|
||||
opt_limit);
|
||||
}
|
||||
};
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
var $arrayValues;
|
||||
|
||||
(function(global, utils) {
|
||||
|
||||
"use strict";
|
||||
@ -161,7 +159,9 @@ TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
|
||||
// -------------------------------------------------------------------
|
||||
// Exports
|
||||
|
||||
$arrayValues = ArrayValues;
|
||||
utils.Export(function(to) {
|
||||
to.ArrayValues = ArrayValues;
|
||||
});
|
||||
|
||||
%InstallToContext([
|
||||
"array_keys_iterator", ArrayKeys,
|
||||
|
@ -15,18 +15,20 @@ var GlobalArrayBuffer = global.ArrayBuffer;
|
||||
var GlobalObject = global.Object;
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
var ToPositiveInteger;
|
||||
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
|
||||
|
||||
utils.Import(function(from) {
|
||||
MathMax = from.MathMax;
|
||||
MathMin = from.MathMin;
|
||||
ToPositiveInteger = from.ToPositiveInteger;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function ArrayBufferConstructor(length) { // length = 1
|
||||
if (%_IsConstructCall()) {
|
||||
var byteLength = $toPositiveInteger(length, kInvalidArrayBufferLength);
|
||||
var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength);
|
||||
%ArrayBufferInitialize(this, byteLength, kNotShared);
|
||||
} else {
|
||||
throw MakeTypeError(kConstructorNotFunction, "ArrayBuffer");
|
||||
|
@ -2,11 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
var $mapEntries;
|
||||
var $mapIteratorNext;
|
||||
var $setIteratorNext;
|
||||
var $setValues;
|
||||
|
||||
(function(global, utils) {
|
||||
|
||||
"use strict";
|
||||
@ -87,9 +82,6 @@ utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
|
||||
|
||||
%AddNamedProperty(GlobalSet.prototype, iteratorSymbol, SetValues, DONT_ENUM);
|
||||
|
||||
$setIteratorNext = SetIteratorNextJS;
|
||||
$setValues = SetValues;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function MapIteratorConstructor(map, kind) {
|
||||
@ -170,7 +162,14 @@ utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
|
||||
|
||||
%AddNamedProperty(GlobalMap.prototype, iteratorSymbol, MapEntries, DONT_ENUM);
|
||||
|
||||
$mapEntries = MapEntries;
|
||||
$mapIteratorNext = MapIteratorNextJS;
|
||||
// -------------------------------------------------------------------
|
||||
// Exports
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.MapEntries = MapEntries;
|
||||
to.MapIteratorNext = MapIteratorNextJS;
|
||||
to.SetIteratorNext = SetIteratorNextJS;
|
||||
to.SetValues = SetValues;
|
||||
});
|
||||
|
||||
})
|
||||
|
@ -2,9 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
var $getHash;
|
||||
var $getExistingHash;
|
||||
|
||||
(function(global, utils) {
|
||||
"use strict";
|
||||
|
||||
@ -462,10 +459,6 @@ utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
|
||||
"forEach", MapForEach
|
||||
]);
|
||||
|
||||
// Expose to the global scope.
|
||||
$getHash = GetHash;
|
||||
$getExistingHash = GetExistingHash;
|
||||
|
||||
function MapFromArray(array) {
|
||||
var map = new GlobalMap;
|
||||
var length = array.length;
|
||||
@ -501,4 +494,9 @@ function SetFromArray(array) {
|
||||
"set_from_array",SetFromArray,
|
||||
]);
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.GetExistingHash = GetExistingHash;
|
||||
to.GetHash = GetHash;
|
||||
});
|
||||
|
||||
})
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
var $createDate;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
(function(global, utils) {
|
||||
@ -21,6 +19,7 @@ var InternalArray = utils.InternalArray;
|
||||
var IsFinite;
|
||||
var MathAbs;
|
||||
var MathFloor;
|
||||
var NaN = %GetRootNaN();
|
||||
|
||||
utils.Import(function(from) {
|
||||
IsFinite = from.IsFinite;
|
||||
@ -32,7 +31,7 @@ utils.Import(function(from) {
|
||||
|
||||
// This file contains date support implemented in JavaScript.
|
||||
|
||||
var timezone_cache_time = NAN;
|
||||
var timezone_cache_time = NaN;
|
||||
var timezone_cache_timezone;
|
||||
|
||||
function LocalTimezone(t) {
|
||||
@ -58,10 +57,10 @@ function UTC(time) {
|
||||
|
||||
// ECMA 262 - 15.9.1.11
|
||||
function MakeTime(hour, min, sec, ms) {
|
||||
if (!IsFinite(hour)) return NAN;
|
||||
if (!IsFinite(min)) return NAN;
|
||||
if (!IsFinite(sec)) return NAN;
|
||||
if (!IsFinite(ms)) return NAN;
|
||||
if (!IsFinite(hour)) return NaN;
|
||||
if (!IsFinite(min)) return NaN;
|
||||
if (!IsFinite(sec)) return NaN;
|
||||
if (!IsFinite(ms)) return NaN;
|
||||
return TO_INTEGER(hour) * msPerHour
|
||||
+ TO_INTEGER(min) * msPerMinute
|
||||
+ TO_INTEGER(sec) * msPerSecond
|
||||
@ -82,7 +81,7 @@ function TimeInYear(year) {
|
||||
// MakeDay(2007, -33, 1) --> MakeDay(2004, 3, 1)
|
||||
// MakeDay(2007, 14, -50) --> MakeDay(2007, 8, 11)
|
||||
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.
|
||||
year = TO_INTEGER_MAP_MINUS_ZERO(year);
|
||||
@ -91,7 +90,7 @@ function MakeDay(year, month, date) {
|
||||
|
||||
if (year < kMinYear || year > kMaxYear ||
|
||||
month < kMinMonth || month > kMaxMonth) {
|
||||
return NAN;
|
||||
return NaN;
|
||||
}
|
||||
|
||||
// Now we rely on year and month being SMIs.
|
||||
@ -107,15 +106,15 @@ function MakeDate(day, time) {
|
||||
// is no way that the time can be within range even after UTC
|
||||
// conversion we return NaN immediately instead of relying on
|
||||
// TimeClip to do it.
|
||||
if (MathAbs(time) > MAX_TIME_BEFORE_UTC) return NAN;
|
||||
if (MathAbs(time) > MAX_TIME_BEFORE_UTC) return NaN;
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
// ECMA 262 - 15.9.1.14
|
||||
function TimeClip(time) {
|
||||
if (!IsFinite(time)) return NAN;
|
||||
if (MathAbs(time) > MAX_TIME_MS) return NAN;
|
||||
if (!IsFinite(time)) return NaN;
|
||||
if (MathAbs(time) > MAX_TIME_MS) return NaN;
|
||||
return TO_INTEGER(time) + 0;
|
||||
}
|
||||
|
||||
@ -265,7 +264,7 @@ var parse_buffer = new InternalArray(8);
|
||||
// ECMA 262 - 15.9.4.2
|
||||
function DateParse(string) {
|
||||
var arr = %DateParseString(string, parse_buffer);
|
||||
if (IS_NULL(arr)) return NAN;
|
||||
if (IS_NULL(arr)) return NaN;
|
||||
|
||||
var day = MakeDay(arr[0], arr[1], arr[2]);
|
||||
var time = MakeTime(arr[3], arr[4], arr[5], arr[6]);
|
||||
@ -707,7 +706,7 @@ function DateGetYear() {
|
||||
function DateSetYear(year) {
|
||||
CHECK_DATE(this);
|
||||
year = TO_NUMBER(year);
|
||||
if (NUMBER_IS_NAN(year)) return SET_UTC_DATE_VALUE(this, NAN);
|
||||
if (NUMBER_IS_NAN(year)) return SET_UTC_DATE_VALUE(this, NaN);
|
||||
year = (0 <= TO_INTEGER(year) && TO_INTEGER(year) <= 99)
|
||||
? 1900 + TO_INTEGER(year) : year;
|
||||
var t = LOCAL_DATE_VALUE(this);
|
||||
@ -783,7 +782,7 @@ function DateToJSON(key) {
|
||||
|
||||
|
||||
var date_cache_version_holder;
|
||||
var date_cache_version = NAN;
|
||||
var date_cache_version = NaN;
|
||||
|
||||
|
||||
function CheckDateCacheCurrent() {
|
||||
@ -797,11 +796,11 @@ function CheckDateCacheCurrent() {
|
||||
date_cache_version = date_cache_version_holder[0];
|
||||
|
||||
// Reset the timezone cache:
|
||||
timezone_cache_time = NAN;
|
||||
timezone_cache_time = NaN;
|
||||
timezone_cache_timezone = UNDEFINED;
|
||||
|
||||
// Reset the date cache:
|
||||
Date_cache.time = NAN;
|
||||
Date_cache.time = NaN;
|
||||
Date_cache.string = null;
|
||||
}
|
||||
|
||||
|
@ -10,13 +10,18 @@
|
||||
|
||||
var GlobalSharedArrayBuffer = global.SharedArrayBuffer;
|
||||
var GlobalObject = global.Object;
|
||||
var ToPositiveInteger;
|
||||
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
|
||||
|
||||
utils.Import(function(from) {
|
||||
ToPositiveInteger = from.ToPositiveInteger;
|
||||
})
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function SharedArrayBufferConstructor(length) { // length = 1
|
||||
if (%_IsConstructCall()) {
|
||||
var byteLength = $toPositiveInteger(length, kInvalidArrayBufferLength);
|
||||
var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength);
|
||||
%ArrayBufferInitialize(this, byteLength, kShared);
|
||||
} else {
|
||||
throw MakeTypeError(kConstructorNotFunction, "SharedArrayBuffer");
|
||||
|
@ -169,7 +169,6 @@ macro GET_PRIVATE(obj, sym) = (obj[sym]);
|
||||
macro SET_PRIVATE(obj, sym, val) = (obj[sym] = val);
|
||||
|
||||
# Constants. The compiler constant folds them.
|
||||
define NAN = $NaN;
|
||||
define INFINITY = (1/0);
|
||||
define UNDEFINED = (void 0);
|
||||
|
||||
|
@ -15,6 +15,7 @@ var rngstate; // Initialized to a Uint32Array during genesis.
|
||||
var GlobalMath = global.Math;
|
||||
var GlobalObject = global.Object;
|
||||
var InternalArray = utils.InternalArray;
|
||||
var NaN = %GetRootNaN();
|
||||
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@ -82,7 +83,7 @@ function MathMax(arg1, arg2) { // length == 2
|
||||
return (arg1 === 0 && %_IsMinusZero(arg1)) ? arg2 : arg1;
|
||||
}
|
||||
// All comparisons failed, one of the arguments must be NaN.
|
||||
return NAN;
|
||||
return NaN;
|
||||
}
|
||||
var r = -INFINITY;
|
||||
for (var i = 0; i < length; i++) {
|
||||
@ -109,7 +110,7 @@ function MathMin(arg1, arg2) { // length == 2
|
||||
return (arg1 === 0 && %_IsMinusZero(arg1)) ? arg1 : arg2;
|
||||
}
|
||||
// All comparisons failed, one of the arguments must be NaN.
|
||||
return NAN;
|
||||
return NaN;
|
||||
}
|
||||
var r = INFINITY;
|
||||
for (var i = 0; i < length; i++) {
|
||||
@ -206,7 +207,7 @@ function MathAsinh(x) {
|
||||
// ES6 draft 09-27-13, section 20.2.2.3.
|
||||
function MathAcosh(x) {
|
||||
x = TO_NUMBER(x);
|
||||
if (x < 1) return NAN;
|
||||
if (x < 1) return NaN;
|
||||
// Idempotent for NaN and +Infinity.
|
||||
if (!NUMBER_IS_FINITE(x)) return x;
|
||||
return MathLog(x + %_MathSqrt(x + 1) * %_MathSqrt(x - 1));
|
||||
@ -218,7 +219,7 @@ function MathAtanh(x) {
|
||||
// Idempotent for +/-0.
|
||||
if (x === 0) return x;
|
||||
// Returns NaN for NaN and +/- Infinity.
|
||||
if (!NUMBER_IS_FINITE(x)) return NAN;
|
||||
if (!NUMBER_IS_FINITE(x)) return NaN;
|
||||
return 0.5 * MathLog((1 + x) / (1 - x));
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
var $errorToString;
|
||||
var MakeError;
|
||||
var MakeEvalError;
|
||||
var MakeRangeError;
|
||||
@ -983,8 +982,6 @@ function ErrorToString() {
|
||||
utils.InstallFunctions(GlobalError.prototype, DONT_ENUM,
|
||||
['toString', ErrorToString]);
|
||||
|
||||
$errorToString = ErrorToString;
|
||||
|
||||
MakeError = function(type, arg0, arg1, arg2) {
|
||||
return MakeGenericError(GlobalError, type, arg0, arg1, arg2);
|
||||
}
|
||||
@ -1043,4 +1040,8 @@ GlobalError.captureStackTrace = captureStackTrace;
|
||||
"uri_error_function", GlobalURIError,
|
||||
]);
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.ErrorToString = ErrorToString;
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -11,14 +11,15 @@
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GetHash;
|
||||
var GlobalArray = global.Array;
|
||||
var GlobalObject = global.Object;
|
||||
var InternalArray = utils.InternalArray;
|
||||
|
||||
var ObjectFreeze;
|
||||
var ObjectIsFrozen;
|
||||
|
||||
utils.Import(function(from) {
|
||||
GetHash = from.GetHash;
|
||||
ObjectFreeze = from.ObjectFreeze;
|
||||
ObjectIsFrozen = from.ObjectIsFrozen;
|
||||
});
|
||||
@ -200,7 +201,7 @@ function ObjectInfoGetOrCreate(object) {
|
||||
performingCount: 0,
|
||||
};
|
||||
%WeakCollectionSet(GetObservationStateJS().objectInfoMap,
|
||||
object, objectInfo, $getHash(object));
|
||||
object, objectInfo, GetHash(object));
|
||||
}
|
||||
return objectInfo;
|
||||
}
|
||||
@ -208,13 +209,13 @@ function ObjectInfoGetOrCreate(object) {
|
||||
|
||||
function ObjectInfoGet(object) {
|
||||
return %WeakCollectionGet(GetObservationStateJS().objectInfoMap, object,
|
||||
$getHash(object));
|
||||
GetHash(object));
|
||||
}
|
||||
|
||||
|
||||
function ObjectInfoGetFromNotifier(notifier) {
|
||||
return %WeakCollectionGet(GetObservationStateJS().notifierObjectInfoMap,
|
||||
notifier, $getHash(notifier));
|
||||
notifier, GetHash(notifier));
|
||||
}
|
||||
|
||||
|
||||
@ -223,7 +224,7 @@ function ObjectInfoGetNotifier(objectInfo) {
|
||||
var notifier = { __proto__: notifierPrototype };
|
||||
objectInfo.notifier = notifier;
|
||||
%WeakCollectionSet(GetObservationStateJS().notifierObjectInfoMap,
|
||||
notifier, objectInfo, $getHash(notifier));
|
||||
notifier, objectInfo, GetHash(notifier));
|
||||
}
|
||||
|
||||
return objectInfo.notifier;
|
||||
@ -335,13 +336,13 @@ function ConvertAcceptListToTypeMap(arg) {
|
||||
// normalizes. When delivery clears any pending change records, it re-optimizes.
|
||||
function CallbackInfoGet(callback) {
|
||||
return %WeakCollectionGet(GetObservationStateJS().callbackInfoMap, callback,
|
||||
$getHash(callback));
|
||||
GetHash(callback));
|
||||
}
|
||||
|
||||
|
||||
function CallbackInfoSet(callback, callbackInfo) {
|
||||
%WeakCollectionSet(GetObservationStateJS().callbackInfoMap,
|
||||
callback, callbackInfo, $getHash(callback));
|
||||
callback, callbackInfo, GetHash(callback));
|
||||
}
|
||||
|
||||
|
||||
|
@ -163,6 +163,7 @@ function PostNatives(utils) {
|
||||
// Whitelist of exports from normal natives to experimental natives and debug.
|
||||
var expose_list = [
|
||||
"ArrayToString",
|
||||
"ErrorToString",
|
||||
"FunctionSourceString",
|
||||
"GetIterator",
|
||||
"GetMethod",
|
||||
@ -180,6 +181,8 @@ function PostNatives(utils) {
|
||||
"InnerArraySort",
|
||||
"InnerArrayToLocaleString",
|
||||
"IsNaN",
|
||||
"MapEntries",
|
||||
"MapIteratorNext",
|
||||
"MathMax",
|
||||
"MathMin",
|
||||
"ObjectIsFrozen",
|
||||
@ -187,8 +190,11 @@ function PostNatives(utils) {
|
||||
"ObserveArrayMethods",
|
||||
"ObserveObjectMethods",
|
||||
"OwnPropertyKeys",
|
||||
"SetIteratorNext",
|
||||
"SetValues",
|
||||
"SymbolToString",
|
||||
"ToNameArray",
|
||||
"ToPositiveInteger",
|
||||
// From runtime:
|
||||
"is_concat_spreadable_symbol",
|
||||
"iterator_symbol",
|
||||
|
@ -11,10 +11,8 @@
|
||||
|
||||
// The following declarations are shared with other native JS files.
|
||||
// They are all declared at this one spot to avoid redeclaration errors.
|
||||
var $NaN;
|
||||
var $sameValue;
|
||||
var $sameValueZero;
|
||||
var $toPositiveInteger;
|
||||
|
||||
var harmony_tolength = false;
|
||||
|
||||
@ -234,10 +232,12 @@ function ToPositiveInteger(x, rangeErrorIndex) {
|
||||
// ----------------------------------------------------------------------------
|
||||
// Exports
|
||||
|
||||
$NaN = %GetRootNaN();
|
||||
$sameValue = SameValue;
|
||||
$sameValueZero = SameValueZero;
|
||||
$toPositiveInteger = ToPositiveInteger;
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.ToPositiveInteger = ToPositiveInteger;
|
||||
});
|
||||
|
||||
%InstallToContext([
|
||||
"apply_prepare_builtin", APPLY_PREPARE,
|
||||
|
@ -11,11 +11,14 @@
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var ArrayValues;
|
||||
var GlobalArray = global.Array;
|
||||
var GlobalArrayBuffer = global.ArrayBuffer;
|
||||
var GlobalDataView = global.DataView;
|
||||
var GlobalObject = global.Object;
|
||||
var InternalArray = utils.InternalArray;
|
||||
var iteratorSymbol = utils.ImportNow("iterator_symbol");
|
||||
var ToPositiveInteger;
|
||||
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
|
||||
|
||||
macro TYPED_ARRAYS(FUNCTION)
|
||||
@ -37,18 +40,20 @@ endmacro
|
||||
|
||||
TYPED_ARRAYS(DECLARE_GLOBALS)
|
||||
|
||||
var InternalArray = utils.InternalArray;
|
||||
utils.Import(function(from) {
|
||||
ArrayValues = from.ArrayValues;
|
||||
ToPositiveInteger = from.ToPositiveInteger;
|
||||
});
|
||||
|
||||
// --------------- Typed Arrays ---------------------
|
||||
|
||||
macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
|
||||
function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
|
||||
if (!IS_UNDEFINED(byteOffset)) {
|
||||
byteOffset =
|
||||
$toPositiveInteger(byteOffset, kInvalidTypedArrayLength);
|
||||
byteOffset = ToPositiveInteger(byteOffset, kInvalidTypedArrayLength);
|
||||
}
|
||||
if (!IS_UNDEFINED(length)) {
|
||||
length = $toPositiveInteger(length, kInvalidTypedArrayLength);
|
||||
length = ToPositiveInteger(length, kInvalidTypedArrayLength);
|
||||
}
|
||||
|
||||
var bufferByteLength = %_ArrayBufferGetByteLength(buffer);
|
||||
@ -89,7 +94,7 @@ function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
|
||||
|
||||
function NAMEConstructByLength(obj, length) {
|
||||
var l = IS_UNDEFINED(length) ?
|
||||
0 : $toPositiveInteger(length, kInvalidTypedArrayLength);
|
||||
0 : ToPositiveInteger(length, kInvalidTypedArrayLength);
|
||||
if (l > %_MaxSmi()) {
|
||||
throw MakeRangeError(kInvalidTypedArrayLength);
|
||||
}
|
||||
@ -104,7 +109,7 @@ function NAMEConstructByLength(obj, length) {
|
||||
|
||||
function NAMEConstructByArrayLike(obj, arrayLike) {
|
||||
var length = arrayLike.length;
|
||||
var l = $toPositiveInteger(length, kInvalidTypedArrayLength);
|
||||
var l = ToPositiveInteger(length, kInvalidTypedArrayLength);
|
||||
|
||||
if (l > %_MaxSmi()) {
|
||||
throw MakeRangeError(kInvalidTypedArrayLength);
|
||||
@ -155,7 +160,7 @@ function NAMEConstructor(arg1, arg2, arg3) {
|
||||
NAMEConstructByLength(this, arg1);
|
||||
} else {
|
||||
var iteratorFn = arg1[iteratorSymbol];
|
||||
if (IS_UNDEFINED(iteratorFn) || iteratorFn === $arrayValues) {
|
||||
if (IS_UNDEFINED(iteratorFn) || iteratorFn === ArrayValues) {
|
||||
NAMEConstructByArrayLike(this, arg1);
|
||||
} else {
|
||||
NAMEConstructByIterable(this, arg1, iteratorFn);
|
||||
@ -381,10 +386,10 @@ function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
|
||||
// TODO(binji): support SharedArrayBuffers?
|
||||
if (!IS_ARRAYBUFFER(buffer)) throw MakeTypeError(kDataViewNotArrayBuffer);
|
||||
if (!IS_UNDEFINED(byteOffset)) {
|
||||
byteOffset = $toPositiveInteger(byteOffset, kInvalidDataViewOffset);
|
||||
byteOffset = ToPositiveInteger(byteOffset, kInvalidDataViewOffset);
|
||||
}
|
||||
if (!IS_UNDEFINED(byteLength)) {
|
||||
byteLength = TO_INTEGER(byteLength);
|
||||
byteLength = TO_INTEGER(byteLength);
|
||||
}
|
||||
|
||||
var bufferByteLength = %_ArrayBufferGetByteLength(buffer);
|
||||
@ -446,7 +451,7 @@ function DataViewGetTYPENAMEJS(offset, little_endian) {
|
||||
'DataView.getTYPENAME', this);
|
||||
}
|
||||
if (%_ArgumentsLength() < 1) throw MakeTypeError(kInvalidArgument);
|
||||
offset = $toPositiveInteger(offset, kInvalidDataViewAccessorOffset);
|
||||
offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
|
||||
return %DataViewGetTYPENAME(this, offset, !!little_endian);
|
||||
}
|
||||
|
||||
@ -456,7 +461,7 @@ function DataViewSetTYPENAMEJS(offset, value, little_endian) {
|
||||
'DataView.setTYPENAME', this);
|
||||
}
|
||||
if (%_ArgumentsLength() < 2) throw MakeTypeError(kInvalidArgument);
|
||||
offset = $toPositiveInteger(offset, kInvalidDataViewAccessorOffset);
|
||||
offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
|
||||
%DataViewSetTYPENAME(this, offset, TO_NUMBER(value), !!little_endian);
|
||||
}
|
||||
endmacro
|
||||
|
@ -18,6 +18,7 @@ var GlobalObject = global.Object;
|
||||
var InternalArray = utils.InternalArray;
|
||||
var iteratorSymbol = utils.ImportNow("iterator_symbol");
|
||||
var MathAbs;
|
||||
var NaN = %GetRootNaN();
|
||||
var ObserveBeginPerformSplice;
|
||||
var ObserveEndPerformSplice;
|
||||
var ObserveEnqueueSpliceRecord;
|
||||
@ -81,7 +82,7 @@ function GlobalParseInt(string, radix) {
|
||||
string = TO_STRING(string);
|
||||
radix = TO_INT32(radix);
|
||||
if (!(radix == 0 || (2 <= radix && radix <= 36))) {
|
||||
return NAN;
|
||||
return NaN;
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,7 +121,7 @@ var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
|
||||
|
||||
utils.InstallConstants(global, [
|
||||
// ECMA 262 - 15.1.1.1.
|
||||
"NaN", NAN,
|
||||
"NaN", NaN,
|
||||
// ECMA-262 - 15.1.1.2.
|
||||
"Infinity", INFINITY,
|
||||
// ECMA-262 - 15.1.1.2.
|
||||
@ -1600,7 +1601,7 @@ utils.InstallConstants(GlobalNumber, [
|
||||
// ECMA-262 section 15.7.3.2.
|
||||
"MIN_VALUE", 5e-324,
|
||||
// ECMA-262 section 15.7.3.3.
|
||||
"NaN", NAN,
|
||||
"NaN", NaN,
|
||||
// ECMA-262 section 15.7.3.4.
|
||||
"NEGATIVE_INFINITY", -INFINITY,
|
||||
// ECMA-262 section 15.7.3.5.
|
||||
|
@ -8,11 +8,21 @@
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GetExistingHash;
|
||||
var GetHash;
|
||||
var GlobalObject = global.Object;
|
||||
var GlobalWeakMap = global.WeakMap;
|
||||
var GlobalWeakSet = global.WeakSet;
|
||||
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
|
||||
|
||||
utils.Import(function(from) {
|
||||
GetExistingHash = from.GetExistingHash;
|
||||
GetHash = from.GetHash;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Harmony WeakMap
|
||||
|
||||
@ -44,7 +54,7 @@ function WeakMapGet(key) {
|
||||
'WeakMap.prototype.get', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(key)) return UNDEFINED;
|
||||
var hash = $getExistingHash(key);
|
||||
var hash = GetExistingHash(key);
|
||||
if (IS_UNDEFINED(hash)) return UNDEFINED;
|
||||
return %WeakCollectionGet(this, key, hash);
|
||||
}
|
||||
@ -56,7 +66,7 @@ function WeakMapSet(key, value) {
|
||||
'WeakMap.prototype.set', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(key)) throw MakeTypeError(kInvalidWeakMapKey);
|
||||
return %WeakCollectionSet(this, key, value, $getHash(key));
|
||||
return %WeakCollectionSet(this, key, value, GetHash(key));
|
||||
}
|
||||
|
||||
|
||||
@ -66,7 +76,7 @@ function WeakMapHas(key) {
|
||||
'WeakMap.prototype.has', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(key)) return false;
|
||||
var hash = $getExistingHash(key);
|
||||
var hash = GetExistingHash(key);
|
||||
if (IS_UNDEFINED(hash)) return false;
|
||||
return %WeakCollectionHas(this, key, hash);
|
||||
}
|
||||
@ -78,7 +88,7 @@ function WeakMapDelete(key) {
|
||||
'WeakMap.prototype.delete', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(key)) return false;
|
||||
var hash = $getExistingHash(key);
|
||||
var hash = GetExistingHash(key);
|
||||
if (IS_UNDEFINED(hash)) return false;
|
||||
return %WeakCollectionDelete(this, key, hash);
|
||||
}
|
||||
@ -130,7 +140,7 @@ function WeakSetAdd(value) {
|
||||
'WeakSet.prototype.add', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(value)) throw MakeTypeError(kInvalidWeakSetValue);
|
||||
return %WeakCollectionSet(this, value, true, $getHash(value));
|
||||
return %WeakCollectionSet(this, value, true, GetHash(value));
|
||||
}
|
||||
|
||||
|
||||
@ -140,7 +150,7 @@ function WeakSetHas(value) {
|
||||
'WeakSet.prototype.has', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(value)) return false;
|
||||
var hash = $getExistingHash(value);
|
||||
var hash = GetExistingHash(value);
|
||||
if (IS_UNDEFINED(hash)) return false;
|
||||
return %WeakCollectionHas(this, value, hash);
|
||||
}
|
||||
@ -152,7 +162,7 @@ function WeakSetDelete(value) {
|
||||
'WeakSet.prototype.delete', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(value)) return false;
|
||||
var hash = $getExistingHash(value);
|
||||
var hash = GetExistingHash(value);
|
||||
if (IS_UNDEFINED(hash)) return false;
|
||||
return %WeakCollectionDelete(this, value, hash);
|
||||
}
|
||||
|
10
src/third_party/fdlibm/fdlibm.js
vendored
10
src/third_party/fdlibm/fdlibm.js
vendored
@ -36,9 +36,9 @@ var rempio2result;
|
||||
// Imports
|
||||
|
||||
var GlobalMath = global.Math;
|
||||
|
||||
var MathAbs;
|
||||
var MathExp;
|
||||
var NaN = %GetRootNaN();
|
||||
|
||||
utils.Import(function(from) {
|
||||
MathAbs = from.MathAbs;
|
||||
@ -476,7 +476,7 @@ function MathLog1p(x) {
|
||||
if (x === -1) {
|
||||
return -INFINITY; // log1p(-1) = -inf
|
||||
} else {
|
||||
return NAN; // log1p(x<-1) = NaN
|
||||
return NaN; // log1p(x<-1) = NaN
|
||||
}
|
||||
} else if (ax < 0x3c900000) {
|
||||
// For |x| < 2^-54 we can return x.
|
||||
@ -492,7 +492,7 @@ function MathLog1p(x) {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Infinity and NAN
|
||||
// Handle Infinity and NaN
|
||||
if (hx >= 0x7ff00000) return x;
|
||||
|
||||
if (k !== 0) {
|
||||
@ -885,7 +885,7 @@ function MathLog10(x) {
|
||||
// log10(+/- 0) = -Infinity.
|
||||
if (((hx & 0x7fffffff) | lx) === 0) return -INFINITY;
|
||||
// log10 of negative number is NaN.
|
||||
if (hx < 0) return NAN;
|
||||
if (hx < 0) return NaN;
|
||||
// Subnormal number. Scale up x.
|
||||
k -= 54;
|
||||
x *= TWO54;
|
||||
@ -947,7 +947,7 @@ function MathLog2(x) {
|
||||
if ((ix | lx) == 0) return -INFINITY;
|
||||
|
||||
// log(x) = NaN, if x < 0
|
||||
if (hx < 0) return NAN;
|
||||
if (hx < 0) return NaN;
|
||||
|
||||
// log2(Infinity) = Infinity, log2(NaN) = NaN
|
||||
if (ix >= 0x7ff00000) return x;
|
||||
|
Loading…
Reference in New Issue
Block a user