Commit eb8c0928 authored by yangguo's avatar yangguo Committed by Commit bot

Native context: debug.js does not load from js builtins object anymore.

This mainly changes how we share ToBoolean, ToNumber and ToString between
native scripts. Instead of putting them on the js builtins object, we now
explicitly export and import those functions.

I also had to change the import/export mechanism slightly. Previously,
exports and imports are hooked up after all native scripts have been
executed. This means that imported functions cannot be called at the time
the native script is executed.

However, since ToBoolean (and also e.g. ObjectDefineProperties) is called
in v8natives.js, I changed the mechanism so that exports from previous
native scripts (runtime.js for ToBoolean) is imported immediately and can
be called.

R=cbruni@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#30244}
parent 7fc7957b
...@@ -19,16 +19,17 @@ var $arrayUnshift; ...@@ -19,16 +19,17 @@ var $arrayUnshift;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
var Delete;
var GlobalArray = global.Array; 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 ObjectHasOwnProperty;
var ObjectIsFrozen; var ObjectIsFrozen;
var ObjectIsSealed; var ObjectIsSealed;
var ObjectToString; var ObjectToString;
var ToNumber;
var ToString;
utils.Import(function(from) { utils.Import(function(from) {
Delete = from.Delete; Delete = from.Delete;
...@@ -37,6 +38,8 @@ utils.Import(function(from) { ...@@ -37,6 +38,8 @@ utils.Import(function(from) {
ObjectIsFrozen = from.ObjectIsFrozen; ObjectIsFrozen = from.ObjectIsFrozen;
ObjectIsSealed = from.ObjectIsSealed; ObjectIsSealed = from.ObjectIsSealed;
ObjectToString = from.ObjectToString; ObjectToString = from.ObjectToString;
ToNumber = from.ToNumber;
ToString = from.ToString;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -216,7 +219,7 @@ function ConvertToString(x) { ...@@ -216,7 +219,7 @@ function ConvertToString(x) {
// Assumes x is a non-string. // Assumes x is a non-string.
if (IS_NUMBER(x)) return %_NumberToString(x); if (IS_NUMBER(x)) return %_NumberToString(x);
if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
return (IS_NULL_OR_UNDEFINED(x)) ? '' : $toString($defaultString(x)); return (IS_NULL_OR_UNDEFINED(x)) ? '' : ToString($defaultString(x));
} }
...@@ -228,7 +231,7 @@ function ConvertToLocaleString(e) { ...@@ -228,7 +231,7 @@ function ConvertToLocaleString(e) {
// must throw a TypeError if ToObject(e).toLocaleString isn't // must throw a TypeError if ToObject(e).toLocaleString isn't
// callable. // callable.
var e_obj = TO_OBJECT(e); var e_obj = TO_OBJECT(e);
return $toString(e_obj.toLocaleString()); return ToString(e_obj.toLocaleString());
} }
} }
...@@ -914,8 +917,8 @@ function InnerArraySort(length, comparefn) { ...@@ -914,8 +917,8 @@ function InnerArraySort(length, comparefn) {
if (%_IsSmi(x) && %_IsSmi(y)) { if (%_IsSmi(x) && %_IsSmi(y)) {
return %SmiLexicographicCompare(x, y); return %SmiLexicographicCompare(x, y);
} }
x = $toString(x); x = ToString(x);
y = $toString(y); y = ToString(y);
if (x == y) return 0; if (x == y) return 0;
else return x < y ? -1 : 1; else return x < y ? -1 : 1;
}; };
......
...@@ -13,13 +13,14 @@ ...@@ -13,13 +13,14 @@
var GlobalArrayBuffer = global.ArrayBuffer; var GlobalArrayBuffer = global.ArrayBuffer;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var MathMax; var MathMax;
var MathMin; var MathMin;
var ToNumber;
utils.Import(function(from) { utils.Import(function(from) {
MathMax = from.MathMax; MathMax = from.MathMax;
MathMin = from.MathMin; MathMin = from.MathMin;
ToNumber = from.ToNumber;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
This diff is collapsed.
This diff is collapsed.
...@@ -8,10 +8,19 @@ ...@@ -8,10 +8,19 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Imports // Imports
var FunctionSourceString;
var GlobalArray = global.Array; var GlobalArray = global.Array;
var IsNaN = global.isNaN; var IsNaN = global.isNaN;
var JSONStringify = global.JSON.stringify; var JSONStringify = global.JSON.stringify;
var MathMin = global.Math.min; var MathMin = global.Math.min;
var ToBoolean;
var ToString;
utils.Import(function(from) {
FunctionSourceString = from.FunctionSourceString;
ToBoolean = from.ToBoolean;
ToString = from.ToString;
});
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
...@@ -990,7 +999,7 @@ FunctionMirror.prototype.source = function() { ...@@ -990,7 +999,7 @@ FunctionMirror.prototype.source = function() {
// Return source if function is resolved. Otherwise just fall through to // Return source if function is resolved. Otherwise just fall through to
// return undefined. // return undefined.
if (this.resolved()) { if (this.resolved()) {
return builtins.$functionSourceString(this.value_); return FunctionSourceString(this.value_);
} }
}; };
...@@ -1168,7 +1177,7 @@ ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index, ...@@ -1168,7 +1177,7 @@ ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index,
if (from_index > to_index) return new GlobalArray(); if (from_index > to_index) return new GlobalArray();
var values = new GlobalArray(to_index - from_index + 1); var values = new GlobalArray(to_index - from_index + 1);
for (var i = from_index; i <= to_index; i++) { for (var i = from_index; i <= to_index; i++) {
var details = %DebugGetPropertyDetails(this.value_, builtins.$toString(i)); var details = %DebugGetPropertyDetails(this.value_, ToString(i));
var value; var value;
if (details) { if (details) {
value = new PropertyMirror(this, i, details); value = new PropertyMirror(this, i, details);
...@@ -2068,7 +2077,7 @@ FrameMirror.prototype.evaluate = function(source, disable_break, ...@@ -2068,7 +2077,7 @@ FrameMirror.prototype.evaluate = function(source, disable_break,
this.details_.frameId(), this.details_.frameId(),
this.details_.inlinedFrameIndex(), this.details_.inlinedFrameIndex(),
source, source,
$toBoolean(disable_break), ToBoolean(disable_break),
opt_context_object)); opt_context_object));
}; };
......
...@@ -11,15 +11,15 @@ ...@@ -11,15 +11,15 @@
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
var GlobalArray = global.Array;
var GlobalSymbol = global.Symbol;
var GetIterator; var GetIterator;
var GetMethod; var GetMethod;
var GlobalArray = global.Array;
var GlobalSymbol = global.Symbol;
var MathMax; var MathMax;
var MathMin; var MathMin;
var ObjectIsFrozen; var ObjectIsFrozen;
var ObjectDefineProperty; var ObjectDefineProperty;
var ToNumber;
utils.Import(function(from) { utils.Import(function(from) {
GetIterator = from.GetIterator; GetIterator = from.GetIterator;
...@@ -28,6 +28,7 @@ utils.Import(function(from) { ...@@ -28,6 +28,7 @@ utils.Import(function(from) {
MathMin = from.MathMin; MathMin = from.MathMin;
ObjectIsFrozen = from.ObjectIsFrozen; ObjectIsFrozen = from.ObjectIsFrozen;
ObjectDefineProperty = from.ObjectDefineProperty; ObjectDefineProperty = from.ObjectDefineProperty;
ToNumber = from.ToNumber;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -12,11 +12,12 @@ ...@@ -12,11 +12,12 @@
// Imports // Imports
var GlobalObject = global.Object; var GlobalObject = global.Object;
var MathMax; var MathMax;
var ToNumber;
utils.Import(function(from) { utils.Import(function(from) {
MathMax = from.MathMax; MathMax = from.MathMax;
ToNumber = from.ToNumber;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -49,8 +50,8 @@ function AtomicsCompareExchangeJS(sta, index, oldValue, newValue) { ...@@ -49,8 +50,8 @@ function AtomicsCompareExchangeJS(sta, index, oldValue, newValue) {
if (index < 0 || index >= %_TypedArrayGetLength(sta)) { if (index < 0 || index >= %_TypedArrayGetLength(sta)) {
return UNDEFINED; return UNDEFINED;
} }
oldValue = $toNumber(oldValue); oldValue = ToNumber(oldValue);
newValue = $toNumber(newValue); newValue = ToNumber(newValue);
return %_AtomicsCompareExchange(sta, index, oldValue, newValue); return %_AtomicsCompareExchange(sta, index, oldValue, newValue);
} }
...@@ -69,7 +70,7 @@ function AtomicsStoreJS(sta, index, value) { ...@@ -69,7 +70,7 @@ function AtomicsStoreJS(sta, index, value) {
if (index < 0 || index >= %_TypedArrayGetLength(sta)) { if (index < 0 || index >= %_TypedArrayGetLength(sta)) {
return UNDEFINED; return UNDEFINED;
} }
value = $toNumber(value); value = ToNumber(value);
return %_AtomicsStore(sta, index, value); return %_AtomicsStore(sta, index, value);
} }
...@@ -79,7 +80,7 @@ function AtomicsAddJS(ia, index, value) { ...@@ -79,7 +80,7 @@ function AtomicsAddJS(ia, index, value) {
if (index < 0 || index >= %_TypedArrayGetLength(ia)) { if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
return UNDEFINED; return UNDEFINED;
} }
value = $toNumber(value); value = ToNumber(value);
return %_AtomicsAdd(ia, index, value); return %_AtomicsAdd(ia, index, value);
} }
...@@ -89,7 +90,7 @@ function AtomicsSubJS(ia, index, value) { ...@@ -89,7 +90,7 @@ function AtomicsSubJS(ia, index, value) {
if (index < 0 || index >= %_TypedArrayGetLength(ia)) { if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
return UNDEFINED; return UNDEFINED;
} }
value = $toNumber(value); value = ToNumber(value);
return %_AtomicsSub(ia, index, value); return %_AtomicsSub(ia, index, value);
} }
...@@ -99,7 +100,7 @@ function AtomicsAndJS(ia, index, value) { ...@@ -99,7 +100,7 @@ function AtomicsAndJS(ia, index, value) {
if (index < 0 || index >= %_TypedArrayGetLength(ia)) { if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
return UNDEFINED; return UNDEFINED;
} }
value = $toNumber(value); value = ToNumber(value);
return %_AtomicsAnd(ia, index, value); return %_AtomicsAnd(ia, index, value);
} }
...@@ -109,7 +110,7 @@ function AtomicsOrJS(ia, index, value) { ...@@ -109,7 +110,7 @@ function AtomicsOrJS(ia, index, value) {
if (index < 0 || index >= %_TypedArrayGetLength(ia)) { if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
return UNDEFINED; return UNDEFINED;
} }
value = $toNumber(value); value = ToNumber(value);
return %_AtomicsOr(ia, index, value); return %_AtomicsOr(ia, index, value);
} }
...@@ -119,7 +120,7 @@ function AtomicsXorJS(ia, index, value) { ...@@ -119,7 +120,7 @@ function AtomicsXorJS(ia, index, value) {
if (index < 0 || index >= %_TypedArrayGetLength(ia)) { if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
return UNDEFINED; return UNDEFINED;
} }
value = $toNumber(value); value = ToNumber(value);
return %_AtomicsXor(ia, index, value); return %_AtomicsXor(ia, index, value);
} }
...@@ -129,7 +130,7 @@ function AtomicsExchangeJS(ia, index, value) { ...@@ -129,7 +130,7 @@ function AtomicsExchangeJS(ia, index, value) {
if (index < 0 || index >= %_TypedArrayGetLength(ia)) { if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
return UNDEFINED; return UNDEFINED;
} }
value = $toNumber(value); value = ToNumber(value);
return %_AtomicsExchange(ia, index, value); return %_AtomicsExchange(ia, index, value);
} }
...@@ -148,7 +149,7 @@ function AtomicsFutexWaitJS(ia, index, value, timeout) { ...@@ -148,7 +149,7 @@ function AtomicsFutexWaitJS(ia, index, value, timeout) {
if (IS_UNDEFINED(timeout)) { if (IS_UNDEFINED(timeout)) {
timeout = INFINITY; timeout = INFINITY;
} else { } else {
timeout = $toNumber(timeout); timeout = ToNumber(timeout);
if (NUMBER_IS_NAN(timeout)) { if (NUMBER_IS_NAN(timeout)) {
timeout = INFINITY; timeout = INFINITY;
} else { } else {
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
// Imports // Imports
var GlobalObject = global.Object; var GlobalObject = global.Object;
var OwnPropertyKeys; var OwnPropertyKeys;
utils.Import(function(from) { utils.Import(function(from) {
......
...@@ -8,7 +8,15 @@ ...@@ -8,7 +8,15 @@
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalRegExp = global.RegExp; var GlobalRegExp = global.RegExp;
var ToString;
utils.Import(function(from) {
ToString = from.ToString;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -16,7 +24,7 @@ var GlobalRegExp = global.RegExp; ...@@ -16,7 +24,7 @@ var GlobalRegExp = global.RegExp;
// + https://bugs.ecmascript.org/show_bug.cgi?id=3423 // + https://bugs.ecmascript.org/show_bug.cgi?id=3423
function RegExpGetFlags() { function RegExpGetFlags() {
if (!IS_SPEC_OBJECT(this)) { if (!IS_SPEC_OBJECT(this)) {
throw MakeTypeError(kFlagsGetterNonObject, $toString(this)); throw MakeTypeError(kFlagsGetterNonObject, ToString(this));
} }
var result = ''; var result = '';
if (this.global) result += 'g'; if (this.global) result += 'g';
......
...@@ -51,6 +51,7 @@ var IsNaN; ...@@ -51,6 +51,7 @@ var IsNaN;
var MathMax; var MathMax;
var MathMin; var MathMin;
var PackedArrayReverse; var PackedArrayReverse;
var ToNumber;
utils.Import(function(from) { utils.Import(function(from) {
ArrayFrom = from.ArrayFrom; ArrayFrom = from.ArrayFrom;
...@@ -75,6 +76,7 @@ utils.Import(function(from) { ...@@ -75,6 +76,7 @@ utils.Import(function(from) {
MathMax = from.MathMax; MathMax = from.MathMax;
MathMin = from.MathMin; MathMin = from.MathMin;
PackedArrayReverse = from.PackedArrayReverse; PackedArrayReverse = from.PackedArrayReverse;
ToNumber = from.ToNumber;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -17,21 +17,18 @@ ...@@ -17,21 +17,18 @@
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
var ArrayIndexOf;
var ArrayJoin;
var IsFinite;
var IsNaN;
var GlobalBoolean = global.Boolean; var GlobalBoolean = global.Boolean;
var GlobalDate = global.Date; var GlobalDate = global.Date;
var GlobalNumber = global.Number; var GlobalNumber = global.Number;
var GlobalRegExp = global.RegExp; var GlobalRegExp = global.RegExp;
var GlobalString = global.String; var GlobalString = global.String;
var ObjectDefineProperties = utils.ObjectDefineProperties;
var ObjectDefineProperty = utils.ObjectDefineProperty;
var SetFunctionName = utils.SetFunctionName;
var ArrayIndexOf;
var ArrayJoin;
var IsFinite;
var IsNaN;
var MathFloor; var MathFloor;
var RegExpTest; var RegExpTest;
var SetFunctionName = utils.SetFunctionName;
var StringIndexOf; var StringIndexOf;
var StringLastIndexOf; var StringLastIndexOf;
var StringMatch; var StringMatch;
...@@ -54,6 +51,12 @@ utils.Import(function(from) { ...@@ -54,6 +51,12 @@ utils.Import(function(from) {
StringSplit = from.StringSplit; StringSplit = from.StringSplit;
StringSubstr = from.StringSubstr; StringSubstr = from.StringSubstr;
StringSubstring = from.StringSubstring; StringSubstring = from.StringSubstring;
ToNumber = from.ToNumber;
});
utils.ImportNow(function(from) {
ObjectDefineProperties = from.ObjectDefineProperties;
ObjectDefineProperty = from.ObjectDefineProperty;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -1276,7 +1279,7 @@ SetFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf'); ...@@ -1276,7 +1279,7 @@ SetFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf');
*/ */
function formatNumber(formatter, value) { function formatNumber(formatter, value) {
// Spec treats -0 and +0 as 0. // Spec treats -0 and +0 as 0.
var number = $toNumber(value) + 0; var number = ToNumber(value) + 0;
return %InternalNumberFormat(%GetImplFromInitializedIntlObject(formatter), return %InternalNumberFormat(%GetImplFromInitializedIntlObject(formatter),
number); number);
...@@ -1701,7 +1704,7 @@ function formatDate(formatter, dateValue) { ...@@ -1701,7 +1704,7 @@ function formatDate(formatter, dateValue) {
if (IS_UNDEFINED(dateValue)) { if (IS_UNDEFINED(dateValue)) {
dateMs = %DateCurrentTime(); dateMs = %DateCurrentTime();
} else { } else {
dateMs = $toNumber(dateValue); dateMs = ToNumber(dateValue);
} }
if (!IsFinite(dateMs)) throw MakeRangeError(kDateRange); if (!IsFinite(dateMs)) throw MakeRangeError(kDateRange);
......
...@@ -13,15 +13,18 @@ ...@@ -13,15 +13,18 @@
var GlobalJSON = global.JSON; var GlobalJSON = global.JSON;
var InternalArray = utils.InternalArray; var InternalArray = utils.InternalArray;
var MathMax; var MathMax;
var MathMin; var MathMin;
var ObjectHasOwnProperty; var ObjectHasOwnProperty;
var ToNumber;
var ToString;
utils.Import(function(from) { utils.Import(function(from) {
MathMax = from.MathMax; MathMax = from.MathMax;
MathMin = from.MathMin; MathMin = from.MathMin;
ObjectHasOwnProperty = from.ObjectHasOwnProperty; ObjectHasOwnProperty = from.ObjectHasOwnProperty;
ToNumber = from.ToNumber;
ToString = from.ToString;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -162,10 +165,10 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) { ...@@ -162,10 +165,10 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) {
if (IS_ARRAY(value)) { if (IS_ARRAY(value)) {
return SerializeArray(value, replacer, stack, indent, gap); return SerializeArray(value, replacer, stack, indent, gap);
} else if (IS_NUMBER_WRAPPER(value)) { } else if (IS_NUMBER_WRAPPER(value)) {
value = $toNumber(value); value = ToNumber(value);
return JSON_NUMBER_TO_STRING(value); return JSON_NUMBER_TO_STRING(value);
} else if (IS_STRING_WRAPPER(value)) { } else if (IS_STRING_WRAPPER(value)) {
return %QuoteJSONString($toString(value)); return %QuoteJSONString(ToString(value));
} else if (IS_BOOLEAN_WRAPPER(value)) { } else if (IS_BOOLEAN_WRAPPER(value)) {
return %_ValueOf(value) ? "true" : "false"; return %_ValueOf(value) ? "true" : "false";
} else { } else {
...@@ -194,7 +197,7 @@ function JSONStringify(value, replacer, space) { ...@@ -194,7 +197,7 @@ function JSONStringify(value, replacer, space) {
} else if (IS_NUMBER(v)) { } else if (IS_NUMBER(v)) {
item = %_NumberToString(v); item = %_NumberToString(v);
} else if (IS_STRING_WRAPPER(v) || IS_NUMBER_WRAPPER(v)) { } else if (IS_STRING_WRAPPER(v) || IS_NUMBER_WRAPPER(v)) {
item = $toString(v); item = ToString(v);
} else { } else {
continue; continue;
} }
...@@ -208,9 +211,9 @@ function JSONStringify(value, replacer, space) { ...@@ -208,9 +211,9 @@ function JSONStringify(value, replacer, space) {
if (IS_OBJECT(space)) { if (IS_OBJECT(space)) {
// Unwrap 'space' if it is wrapped // Unwrap 'space' if it is wrapped
if (IS_NUMBER_WRAPPER(space)) { if (IS_NUMBER_WRAPPER(space)) {
space = $toNumber(space); space = ToNumber(space);
} else if (IS_STRING_WRAPPER(space)) { } else if (IS_STRING_WRAPPER(space)) {
space = $toString(space); space = ToString(space);
} }
} }
var gap; var gap;
......
...@@ -145,9 +145,9 @@ define kBoundArgumentsStartIndex = 2; ...@@ -145,9 +145,9 @@ define kBoundArgumentsStartIndex = 2;
# Inline macros. Use %IS_VAR to make sure arg is evaluated only once. # Inline macros. Use %IS_VAR to make sure arg is evaluated only once.
macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg)); macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg));
macro NUMBER_IS_FINITE(arg) = (%_IsSmi(%IS_VAR(arg)) || ((arg == arg) && (arg != 1/0) && (arg != -1/0))); macro NUMBER_IS_FINITE(arg) = (%_IsSmi(%IS_VAR(arg)) || ((arg == arg) && (arg != 1/0) && (arg != -1/0)));
macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToInteger($toNumber(arg))); macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToInteger(ToNumber(arg)));
macro TO_INTEGER_FOR_SIDE_EFFECT(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : $toNumber(arg)); macro TO_INTEGER_FOR_SIDE_EFFECT(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : ToNumber(arg));
macro TO_INTEGER_MAP_MINUS_ZERO(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToIntegerMapMinusZero($toNumber(arg))); macro TO_INTEGER_MAP_MINUS_ZERO(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToIntegerMapMinusZero(ToNumber(arg)));
macro TO_INT32(arg) = (arg | 0); macro TO_INT32(arg) = (arg | 0);
macro TO_UINT32(arg) = (arg >>> 0); macro TO_UINT32(arg) = (arg >>> 0);
macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : $nonStringToString(arg)); macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : $nonStringToString(arg));
......
...@@ -22,38 +22,43 @@ var MakeURIError; ...@@ -22,38 +22,43 @@ var MakeURIError;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
var ArrayJoin;
var Bool16x8ToString;
var Bool32x4ToString;
var Bool8x16ToString;
var Float32x4ToString;
var FunctionSourceString
var GlobalObject = global.Object; var GlobalObject = global.Object;
var Int16x8ToString;
var Int32x4ToString;
var Int8x16ToString;
var InternalArray = utils.InternalArray; var InternalArray = utils.InternalArray;
var ObjectDefineProperty = utils.ObjectDefineProperty; var ObjectDefineProperty;
var ArrayJoin;
var ObjectToString; var ObjectToString;
var StringCharAt; var StringCharAt;
var StringIndexOf; var StringIndexOf;
var StringSubstring; var StringSubstring;
var ToString;
var Float32x4ToString;
var Int32x4ToString;
var Bool32x4ToString;
var Int16x8ToString;
var Bool16x8ToString;
var Int8x16ToString;
var Bool8x16ToString;
utils.Import(function(from) { utils.Import(function(from) {
ArrayJoin = from.ArrayJoin; ArrayJoin = from.ArrayJoin;
Bool16x8ToString = from.Bool16x8ToString;
Bool32x4ToString = from.Bool32x4ToString;
Bool8x16ToString = from.Bool8x16ToString;
Float32x4ToString = from.Float32x4ToString;
FunctionSourceString = from.FunctionSourceString;
Int16x8ToString = from.Int16x8ToString;
Int32x4ToString = from.Int32x4ToString;
Int8x16ToString = from.Int8x16ToString;
ObjectDefineProperty = from.ObjectDefineProperty;
ObjectToString = from.ObjectToString; ObjectToString = from.ObjectToString;
StringCharAt = from.StringCharAt; StringCharAt = from.StringCharAt;
StringIndexOf = from.StringIndexOf; StringIndexOf = from.StringIndexOf;
StringSubstring = from.StringSubstring; StringSubstring = from.StringSubstring;
Float32x4ToString = from.Float32x4ToString; });
Int32x4ToString = from.Int32x4ToString;
Bool32x4ToString = from.Bool32x4ToString; utils.ImportNow(function(from) {
Int16x8ToString = from.Int16x8ToString; ToString = from.ToString;
Bool16x8ToString = from.Bool16x8ToString;
Int8x16ToString = from.Int8x16ToString;
Bool8x16ToString = from.Bool8x16ToString;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -81,7 +86,7 @@ function NoSideEffectToString(obj) { ...@@ -81,7 +86,7 @@ function NoSideEffectToString(obj) {
if (IS_UNDEFINED(obj)) return 'undefined'; if (IS_UNDEFINED(obj)) return 'undefined';
if (IS_NULL(obj)) return 'null'; if (IS_NULL(obj)) return 'null';
if (IS_FUNCTION(obj)) { if (IS_FUNCTION(obj)) {
var str = %_CallFunction(obj, obj, $functionSourceString); var str = %_CallFunction(obj, obj, FunctionSourceString);
if (str.length > 128) { if (str.length > 128) {
str = %_SubString(str, 0, 111) + "...<omitted>..." + str = %_SubString(str, 0, 111) + "...<omitted>..." +
%_SubString(str, str.length - 2, str.length); %_SubString(str, str.length - 2, str.length);
...@@ -147,7 +152,7 @@ function ToStringCheckErrorObject(obj) { ...@@ -147,7 +152,7 @@ function ToStringCheckErrorObject(obj) {
if (CanBeSafelyTreatedAsAnErrorObject(obj)) { if (CanBeSafelyTreatedAsAnErrorObject(obj)) {
return %_CallFunction(obj, ErrorToString); return %_CallFunction(obj, ErrorToString);
} else { } else {
return $toString(obj); return ToString(obj);
} }
} }
...@@ -968,7 +973,7 @@ function DefineError(global, f) { ...@@ -968,7 +973,7 @@ function DefineError(global, f) {
// object. This avoids going through getters and setters defined // object. This avoids going through getters and setters defined
// on prototype objects. // on prototype objects.
if (!IS_UNDEFINED(m)) { if (!IS_UNDEFINED(m)) {
%AddNamedProperty(this, 'message', $toString(m), DONT_ENUM); %AddNamedProperty(this, 'message', ToString(m), DONT_ENUM);
} }
} else { } else {
return new f(m); return new f(m);
......
...@@ -12,17 +12,16 @@ ...@@ -12,17 +12,16 @@
// Utils // Utils
var imports = UNDEFINED; var imports = UNDEFINED;
var exports = UNDEFINED;
var imports_from_experimental = UNDEFINED; var imports_from_experimental = UNDEFINED;
var exports_to_runtime = UNDEFINED; var exports_to_runtime = UNDEFINED;
var exports_container = {};
// Export to other scripts. // Export to other scripts.
// In normal natives, this exports functions to other normal natives. // In normal natives, this exports functions to other normal natives.
// In experimental natives, this exports to other experimental natives and // In experimental natives, this exports to other experimental natives and
// to normal natives that import using utils.ImportFromExperimental. // to normal natives that import using utils.ImportFromExperimental.
function Export(f) { function Export(f) {
f.next = exports; f(exports_container);
exports = f;
} }
...@@ -32,7 +31,11 @@ function ExportToRuntime(f) { ...@@ -32,7 +31,11 @@ function ExportToRuntime(f) {
exports_to_runtime = f; exports_to_runtime = f;
} }
// Import from other scripts.
// Import from other scripts. The actual importing happens in PostNatives and
// PostExperimental so that we can import from scripts executed later. However,
// that means that the import is not available until the very end. If the
// import needs to be available immediate, use ImportNow.
// In normal natives, this imports from other normal natives. // In normal natives, this imports from other normal natives.
// In experimental natives, this imports from other experimental natives and // In experimental natives, this imports from other experimental natives and
// whitelisted exports from normal natives. // whitelisted exports from normal natives.
...@@ -41,6 +44,13 @@ function Import(f) { ...@@ -41,6 +44,13 @@ function Import(f) {
imports = f; imports = f;
} }
// Import immediately from exports of previous scripts. We need this for
// functions called during bootstrapping. Hooking up imports in PostNatives
// would be too late.
function ImportNow(f) {
f(exports_container);
}
// In normal natives, import from experimental natives. // In normal natives, import from experimental natives.
// Not callable from experimental natives. // Not callable from experimental natives.
...@@ -149,14 +159,12 @@ function SetUpLockedPrototype( ...@@ -149,14 +159,12 @@ function SetUpLockedPrototype(
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// To be called by bootstrapper // To be called by bootstrapper
var experimental_exports = UNDEFINED;
function PostNatives(utils) { function PostNatives(utils) {
%CheckIsBootstrapping(); %CheckIsBootstrapping();
var container = {}; for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
for ( ; !IS_UNDEFINED(exports); exports = exports.next) exports(container); imports(exports_container);
for ( ; !IS_UNDEFINED(imports); imports = imports.next) imports(container); }
var runtime_container = {}; var runtime_container = {};
for ( ; !IS_UNDEFINED(exports_to_runtime); for ( ; !IS_UNDEFINED(exports_to_runtime);
...@@ -165,9 +173,10 @@ function PostNatives(utils) { ...@@ -165,9 +173,10 @@ function PostNatives(utils) {
} }
%ImportToRuntime(runtime_container); %ImportToRuntime(runtime_container);
// Whitelist of exports from normal natives to experimental natives. // Whitelist of exports from normal natives to experimental natives and debug.
var expose_to_experimental = [ var expose_list = [
"ArrayToString", "ArrayToString",
"FunctionSourceString",
"GetIterator", "GetIterator",
"GetMethod", "GetMethod",
"InnerArrayEvery", "InnerArrayEvery",
...@@ -190,15 +199,19 @@ function PostNatives(utils) { ...@@ -190,15 +199,19 @@ function PostNatives(utils) {
"ObjectDefineProperty", "ObjectDefineProperty",
"OwnPropertyKeys", "OwnPropertyKeys",
"ToNameArray", "ToNameArray",
"ToBoolean",
"ToNumber",
"ToString",
]; ];
experimental_exports = {};
var filtered_exports = {};
%OptimizeObjectForAddingMultipleProperties( %OptimizeObjectForAddingMultipleProperties(
experimental_exports, expose_to_experimental.length); filtered_exports, expose_list.length);
for (var key of expose_to_experimental) { for (var key of expose_list) {
experimental_exports[key] = container[key]; filtered_exports[key] = exports_container[key];
} }
%ToFastProperties(experimental_exports); %ToFastProperties(filtered_exports);
container = UNDEFINED; exports_container = filtered_exports;
utils.PostNatives = UNDEFINED; utils.PostNatives = UNDEFINED;
utils.ImportFromExperimental = UNDEFINED; utils.ImportFromExperimental = UNDEFINED;
...@@ -208,15 +221,12 @@ function PostNatives(utils) { ...@@ -208,15 +221,12 @@ function PostNatives(utils) {
function PostExperimentals(utils) { function PostExperimentals(utils) {
%CheckIsBootstrapping(); %CheckIsBootstrapping();
for ( ; !IS_UNDEFINED(exports); exports = exports.next) {
exports(experimental_exports);
}
for ( ; !IS_UNDEFINED(imports); imports = imports.next) { for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
imports(experimental_exports); imports(exports_container);
} }
for ( ; !IS_UNDEFINED(imports_from_experimental); for ( ; !IS_UNDEFINED(imports_from_experimental);
imports_from_experimental = imports_from_experimental.next) { imports_from_experimental = imports_from_experimental.next) {
imports_from_experimental(experimental_exports); imports_from_experimental(exports_container);
} }
var runtime_container = {}; var runtime_container = {};
for ( ; !IS_UNDEFINED(exports_to_runtime); for ( ; !IS_UNDEFINED(exports_to_runtime);
...@@ -225,7 +235,7 @@ function PostExperimentals(utils) { ...@@ -225,7 +235,7 @@ function PostExperimentals(utils) {
} }
%ImportExperimentalToRuntime(runtime_container); %ImportExperimentalToRuntime(runtime_container);
experimental_exports = UNDEFINED; exports_container = UNDEFINED;
utils.PostExperimentals = UNDEFINED; utils.PostExperimentals = UNDEFINED;
utils.PostDebug = UNDEFINED; utils.PostDebug = UNDEFINED;
...@@ -235,13 +245,12 @@ function PostExperimentals(utils) { ...@@ -235,13 +245,12 @@ function PostExperimentals(utils) {
function PostDebug(utils) { function PostDebug(utils) {
for ( ; !IS_UNDEFINED(exports); exports = exports.next) {
exports(experimental_exports);
}
for ( ; !IS_UNDEFINED(imports); imports = imports.next) { for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
imports(experimental_exports); imports(exports_container);
} }
exports_container = UNDEFINED;
utils.PostDebug = UNDEFINED; utils.PostDebug = UNDEFINED;
utils.PostExperimentals = UNDEFINED; utils.PostExperimentals = UNDEFINED;
utils.Import = UNDEFINED; utils.Import = UNDEFINED;
...@@ -250,9 +259,10 @@ function PostDebug(utils) { ...@@ -250,9 +259,10 @@ function PostDebug(utils) {
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
%OptimizeObjectForAddingMultipleProperties(utils, 13); %OptimizeObjectForAddingMultipleProperties(utils, 14);
utils.Import = Import; utils.Import = Import;
utils.ImportNow = ImportNow;
utils.Export = Export; utils.Export = Export;
utils.ExportToRuntime = ExportToRuntime; utils.ExportToRuntime = ExportToRuntime;
utils.ImportFromExperimental = ImportFromExperimental; utils.ImportFromExperimental = ImportFromExperimental;
......
...@@ -16,6 +16,10 @@ var harmony_unicode_regexps = false; ...@@ -16,6 +16,10 @@ var harmony_unicode_regexps = false;
var GlobalRegExp = global.RegExp; var GlobalRegExp = global.RegExp;
var InternalPackedArray = utils.InternalPackedArray; var InternalPackedArray = utils.InternalPackedArray;
utils.Import(function(from) {
ToNumber = from.ToNumber;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Property of the builtins object for recording the result of the last // Property of the builtins object for recording the result of the last
......
...@@ -66,7 +66,6 @@ var $nonNumberToNumber; ...@@ -66,7 +66,6 @@ var $nonNumberToNumber;
var $nonStringToString; var $nonStringToString;
var $sameValue; var $sameValue;
var $sameValueZero; var $sameValueZero;
var $toBoolean;
var $toInteger; var $toInteger;
var $toLength; var $toLength;
var $toName; var $toName;
...@@ -907,7 +906,6 @@ $nonNumberToNumber = NonNumberToNumber; ...@@ -907,7 +906,6 @@ $nonNumberToNumber = NonNumberToNumber;
$nonStringToString = NonStringToString; $nonStringToString = NonStringToString;
$sameValue = SameValue; $sameValue = SameValue;
$sameValueZero = SameValueZero; $sameValueZero = SameValueZero;
$toBoolean = ToBoolean;
$toInteger = ToInteger; $toInteger = ToInteger;
$toLength = ToLength; $toLength = ToLength;
$toName = ToName; $toName = ToName;
...@@ -917,10 +915,16 @@ $toPrimitive = ToPrimitive; ...@@ -917,10 +915,16 @@ $toPrimitive = ToPrimitive;
$toString = ToString; $toString = ToString;
utils.ExportToRuntime(function(to) { utils.ExportToRuntime(function(to) {
to.ToNumber = $toNumber; to.ToNumber = ToNumber;
to.ToString = $toString; to.ToString = ToString;
to.ToInteger = $toInteger; to.ToInteger = ToInteger;
to.ToLength = $toLength; to.ToLength = ToLength;
}); });
utils.Export(function(to) {
to.ToBoolean = ToBoolean;
to.ToNumber = ToNumber;
to.ToString = ToString;
})
}) })
...@@ -9,18 +9,19 @@ ...@@ -9,18 +9,19 @@
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
var ArrayIndexOf;
var ArrayJoin;
var GlobalRegExp = global.RegExp; var GlobalRegExp = global.RegExp;
var GlobalString = global.String; var GlobalString = global.String;
var InternalArray = utils.InternalArray; var InternalArray = utils.InternalArray;
var InternalPackedArray = utils.InternalPackedArray; var InternalPackedArray = utils.InternalPackedArray;
var ArrayIndexOf;
var ArrayJoin;
var MathMax; var MathMax;
var MathMin; var MathMin;
var RegExpExec; var RegExpExec;
var RegExpExecNoTests; var RegExpExecNoTests;
var RegExpLastMatchInfo; var RegExpLastMatchInfo;
var ToNumber;
var ToString;
utils.Import(function(from) { utils.Import(function(from) {
ArrayIndexOf = from.ArrayIndexOf; ArrayIndexOf = from.ArrayIndexOf;
...@@ -30,6 +31,8 @@ utils.Import(function(from) { ...@@ -30,6 +31,8 @@ utils.Import(function(from) {
RegExpExec = from.RegExpExec; RegExpExec = from.RegExpExec;
RegExpExecNoTests = from.RegExpExecNoTests; RegExpExecNoTests = from.RegExpExecNoTests;
RegExpLastMatchInfo = from.RegExpLastMatchInfo; RegExpLastMatchInfo = from.RegExpLastMatchInfo;
ToNumber = from.ToNumber;
ToString = from.ToString;
}); });
//------------------------------------------------------------------- //-------------------------------------------------------------------
...@@ -132,7 +135,7 @@ function StringLastIndexOfJS(pat /* position */) { // length == 1 ...@@ -132,7 +135,7 @@ function StringLastIndexOfJS(pat /* position */) { // length == 1
var patLength = pat.length; var patLength = pat.length;
var index = subLength - patLength; var index = subLength - patLength;
if (%_ArgumentsLength() > 1) { if (%_ArgumentsLength() > 1) {
var position = $toNumber(%_Arguments(1)); var position = ToNumber(%_Arguments(1));
if (!NUMBER_IS_NAN(position)) { if (!NUMBER_IS_NAN(position)) {
position = TO_INTEGER(position); position = TO_INTEGER(position);
if (position < 0) { if (position < 0) {
...@@ -823,7 +826,7 @@ function StringTrimRight() { ...@@ -823,7 +826,7 @@ function StringTrimRight() {
function StringFromCharCode(code) { function StringFromCharCode(code) {
var n = %_ArgumentsLength(); var n = %_ArgumentsLength();
if (n == 1) { if (n == 1) {
if (!%_IsSmi(code)) code = $toNumber(code); if (!%_IsSmi(code)) code = ToNumber(code);
return %_StringCharFromCode(code & 0xffff); return %_StringCharFromCode(code & 0xffff);
} }
...@@ -831,7 +834,7 @@ function StringFromCharCode(code) { ...@@ -831,7 +834,7 @@ function StringFromCharCode(code) {
var i; var i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
var code = %_Arguments(i); var code = %_Arguments(i);
if (!%_IsSmi(code)) code = $toNumber(code) & 0xffff; if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff;
if (code < 0) code = code & 0xffff; if (code < 0) code = code & 0xffff;
if (code > 0xff) break; if (code > 0xff) break;
%_OneByteSeqStringSetChar(i, code, one_byte); %_OneByteSeqStringSetChar(i, code, one_byte);
...@@ -842,7 +845,7 @@ function StringFromCharCode(code) { ...@@ -842,7 +845,7 @@ function StringFromCharCode(code) {
var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING); var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING);
for (var j = 0; i < n; i++, j++) { for (var j = 0; i < n; i++, j++) {
var code = %_Arguments(i); var code = %_Arguments(i);
if (!%_IsSmi(code)) code = $toNumber(code) & 0xffff; if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff;
%_TwoByteSeqStringSetChar(j, code, two_byte); %_TwoByteSeqStringSetChar(j, code, two_byte);
} }
return one_byte + two_byte; return one_byte + two_byte;
...@@ -1088,7 +1091,7 @@ function StringFromCodePoint(_) { // length = 1 ...@@ -1088,7 +1091,7 @@ function StringFromCodePoint(_) { // length = 1
for (index = 0; index < length; index++) { for (index = 0; index < length; index++) {
code = %_Arguments(index); code = %_Arguments(index);
if (!%_IsSmi(code)) { if (!%_IsSmi(code)) {
code = $toNumber(code); code = ToNumber(code);
} }
if (code < 0 || code > 0x10FFFF || code !== TO_INTEGER(code)) { if (code < 0 || code > 0x10FFFF || code !== TO_INTEGER(code)) {
throw MakeRangeError(kInvalidCodePoint, code); throw MakeRangeError(kInvalidCodePoint, code);
...@@ -1117,13 +1120,13 @@ function StringRaw(callSite) { ...@@ -1117,13 +1120,13 @@ function StringRaw(callSite) {
var literalSegments = $toLength(raw.length); var literalSegments = $toLength(raw.length);
if (literalSegments <= 0) return ""; if (literalSegments <= 0) return "";
var result = $toString(raw[0]); var result = ToString(raw[0]);
for (var i = 1; i < literalSegments; ++i) { for (var i = 1; i < literalSegments; ++i) {
if (i < numberOfSubstitutions) { if (i < numberOfSubstitutions) {
result += $toString(%_Arguments(i)); result += ToString(%_Arguments(i));
} }
result += $toString(raw[i]); result += ToString(raw[i]);
} }
return result; return result;
......
...@@ -23,11 +23,12 @@ var $symbolToString; ...@@ -23,11 +23,12 @@ var $symbolToString;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var GlobalSymbol = global.Symbol; var GlobalSymbol = global.Symbol;
var ObjectGetOwnPropertyKeys; var ObjectGetOwnPropertyKeys;
var ToString;
utils.Import(function(from) { utils.Import(function(from) {
ObjectGetOwnPropertyKeys = from.ObjectGetOwnPropertyKeys; ObjectGetOwnPropertyKeys = from.ObjectGetOwnPropertyKeys;
ToString = from.ToString;
}); });
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -35,7 +36,7 @@ utils.Import(function(from) { ...@@ -35,7 +36,7 @@ utils.Import(function(from) {
function SymbolConstructor(x) { function SymbolConstructor(x) {
if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Symbol"); if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Symbol");
// NOTE: Passing in a Symbol value will throw on ToString(). // NOTE: Passing in a Symbol value will throw on ToString().
return %CreateSymbol(IS_UNDEFINED(x) ? x : $toString(x)); return %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x));
} }
......
...@@ -37,10 +37,12 @@ TYPED_ARRAYS(DECLARE_GLOBALS) ...@@ -37,10 +37,12 @@ TYPED_ARRAYS(DECLARE_GLOBALS)
var MathMax; var MathMax;
var MathMin; var MathMin;
var ToNumber;
utils.Import(function(from) { utils.Import(function(from) {
MathMax = from.MathMax; MathMax = from.MathMax;
MathMin = from.MathMin; MathMin = from.MathMin;
ToNumber = from.ToNumber;
}); });
var InternalArray = utils.InternalArray; var InternalArray = utils.InternalArray;
......
...@@ -17,6 +17,11 @@ ...@@ -17,6 +17,11 @@
var GlobalObject = global.Object; var GlobalObject = global.Object;
var GlobalArray = global.Array; var GlobalArray = global.Array;
var InternalArray = utils.InternalArray; var InternalArray = utils.InternalArray;
var ToString;
utils.Import(function(from) {
ToString = from.ToString;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Define internal helper functions. // Define internal helper functions.
...@@ -274,13 +279,13 @@ function Decode(uri, reserved) { ...@@ -274,13 +279,13 @@ function Decode(uri, reserved) {
// ECMA-262 - B.2.1. // ECMA-262 - B.2.1.
function URIEscapeJS(str) { function URIEscapeJS(str) {
var s = $toString(str); var s = ToString(str);
return %URIEscape(s); return %URIEscape(s);
} }
// ECMA-262 - B.2.2. // ECMA-262 - B.2.2.
function URIUnescapeJS(str) { function URIUnescapeJS(str) {
var s = $toString(str); var s = ToString(str);
return %URIUnescape(s); return %URIUnescape(s);
} }
...@@ -304,14 +309,14 @@ function URIDecode(uri) { ...@@ -304,14 +309,14 @@ function URIDecode(uri) {
return false; return false;
}; };
var string = $toString(uri); var string = ToString(uri);
return Decode(string, reservedPredicate); return Decode(string, reservedPredicate);
} }
// ECMA-262 - 15.1.3.2. // ECMA-262 - 15.1.3.2.
function URIDecodeComponent(component) { function URIDecodeComponent(component) {
var reservedPredicate = function(cc) { return false; }; var reservedPredicate = function(cc) { return false; };
var string = $toString(component); var string = ToString(component);
return Decode(string, reservedPredicate); return Decode(string, reservedPredicate);
} }
...@@ -338,7 +343,7 @@ function URIEncode(uri) { ...@@ -338,7 +343,7 @@ function URIEncode(uri) {
return false; return false;
}; };
var string = $toString(uri); var string = ToString(uri);
return Encode(string, unescapePredicate); return Encode(string, unescapePredicate);
} }
...@@ -359,7 +364,7 @@ function URIEncodeComponent(component) { ...@@ -359,7 +364,7 @@ function URIEncodeComponent(component) {
return false; return false;
}; };
var string = $toString(component); var string = ToString(component);
return Encode(string, unescapePredicate); return Encode(string, unescapePredicate);
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +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 $functionSourceString;
(function(global, utils) { (function(global, utils) {
%CheckIsBootstrapping(); %CheckIsBootstrapping();
...@@ -17,16 +15,24 @@ var GlobalFunction = global.Function; ...@@ -17,16 +15,24 @@ var GlobalFunction = global.Function;
var GlobalNumber = global.Number; var GlobalNumber = global.Number;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var InternalArray = utils.InternalArray; var InternalArray = utils.InternalArray;
var MathAbs; var MathAbs;
var ProxyDelegateCallAndConstruct; var ProxyDelegateCallAndConstruct;
var ProxyDerivedHasOwnTrap; var ProxyDerivedHasOwnTrap;
var ProxyDerivedKeysTrap; var ProxyDerivedKeysTrap;
var StringIndexOf; var StringIndexOf;
var ToBoolean;
var ToNumber;
var ToString;
utils.Import(function(from) { utils.Import(function(from) {
MathAbs = from.MathAbs; MathAbs = from.MathAbs;
StringIndexOf = from.StringIndexOf; StringIndexOf = from.StringIndexOf;
ToString = from.ToString;
});
utils.ImportNow(function(from) {
ToBoolean = from.ToBoolean;
ToNumber = from.ToNumber;
}); });
utils.ImportFromExperimental(function(from) { utils.ImportFromExperimental(function(from) {
...@@ -346,11 +352,11 @@ function ToPropertyDescriptor(obj) { ...@@ -346,11 +352,11 @@ function ToPropertyDescriptor(obj) {
var desc = new PropertyDescriptor(); var desc = new PropertyDescriptor();
if ("enumerable" in obj) { if ("enumerable" in obj) {
desc.setEnumerable($toBoolean(obj.enumerable)); desc.setEnumerable(ToBoolean(obj.enumerable));
} }
if ("configurable" in obj) { if ("configurable" in obj) {
desc.setConfigurable($toBoolean(obj.configurable)); desc.setConfigurable(ToBoolean(obj.configurable));
} }
if ("value" in obj) { if ("value" in obj) {
...@@ -358,7 +364,7 @@ function ToPropertyDescriptor(obj) { ...@@ -358,7 +364,7 @@ function ToPropertyDescriptor(obj) {
} }
if ("writable" in obj) { if ("writable" in obj) {
desc.setWritable($toBoolean(obj.writable)); desc.setWritable(ToBoolean(obj.writable));
} }
if ("get" in obj) { if ("get" in obj) {
...@@ -612,7 +618,7 @@ function DefineProxyProperty(obj, p, attributes, should_throw) { ...@@ -612,7 +618,7 @@ function DefineProxyProperty(obj, p, attributes, should_throw) {
var handler = %GetHandler(obj); var handler = %GetHandler(obj);
var result = CallTrap2(handler, "defineProperty", UNDEFINED, p, attributes); var result = CallTrap2(handler, "defineProperty", UNDEFINED, p, attributes);
if (!$toBoolean(result)) { if (!ToBoolean(result)) {
if (should_throw) { if (should_throw) {
throw MakeTypeError(kProxyHandlerReturned, throw MakeTypeError(kProxyHandlerReturned,
handler, "false", "defineProperty"); handler, "false", "defineProperty");
...@@ -801,7 +807,7 @@ function DefineArrayProperty(obj, p, desc, should_throw) { ...@@ -801,7 +807,7 @@ function DefineArrayProperty(obj, p, desc, should_throw) {
if (!IS_SYMBOL(p)) { if (!IS_SYMBOL(p)) {
var index = TO_UINT32(p); var index = TO_UINT32(p);
var emit_splice = false; var emit_splice = false;
if ($toString(index) == p && index != 4294967295) { if (ToString(index) == p && index != 4294967295) {
var length = obj.length; var length = obj.length;
if (index >= length && %IsObserved(obj)) { if (index >= length && %IsObserved(obj)) {
emit_splice = true; emit_splice = true;
...@@ -969,7 +975,7 @@ function ObjectGetOwnPropertyKeys(obj, filter) { ...@@ -969,7 +975,7 @@ function ObjectGetOwnPropertyKeys(obj, filter) {
} }
} else { } else {
if (filter & PROPERTY_ATTRIBUTES_STRING) continue; if (filter & PROPERTY_ATTRIBUTES_STRING) continue;
name = $toString(name); name = ToString(name);
} }
if (seenKeys[name]) continue; if (seenKeys[name]) continue;
seenKeys[name] = true; seenKeys[name] = true;
...@@ -1337,9 +1343,9 @@ utils.InstallFunctions(GlobalObject, DONT_ENUM, [ ...@@ -1337,9 +1343,9 @@ utils.InstallFunctions(GlobalObject, DONT_ENUM, [
function BooleanConstructor(x) { function BooleanConstructor(x) {
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
%_SetValueOf(this, $toBoolean(x)); %_SetValueOf(this, ToBoolean(x));
} else { } else {
return $toBoolean(x); return ToBoolean(x);
} }
} }
...@@ -1385,7 +1391,7 @@ utils.InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [ ...@@ -1385,7 +1391,7 @@ utils.InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [
// Number // Number
function NumberConstructor(x) { function NumberConstructor(x) {
var value = %_ArgumentsLength() == 0 ? 0 : $toNumber(x); var value = %_ArgumentsLength() == 0 ? 0 : ToNumber(x);
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
%_SetValueOf(this, value); %_SetValueOf(this, value);
} else { } else {
...@@ -1498,7 +1504,7 @@ function NumberToPrecisionJS(precision) { ...@@ -1498,7 +1504,7 @@ function NumberToPrecisionJS(precision) {
// Get the value of this number in case it's an object. // Get the value of this number in case it's an object.
x = %_ValueOf(this); x = %_ValueOf(this);
} }
if (IS_UNDEFINED(precision)) return $toString(%_ValueOf(this)); if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this));
var p = TO_INTEGER(precision); var p = TO_INTEGER(precision);
if (NUMBER_IS_NAN(x)) return "NaN"; if (NUMBER_IS_NAN(x)) return "NaN";
...@@ -1718,9 +1724,9 @@ function NewFunctionString(args, function_token) { ...@@ -1718,9 +1724,9 @@ function NewFunctionString(args, function_token) {
var n = args.length; var n = args.length;
var p = ''; var p = '';
if (n > 1) { if (n > 1) {
p = $toString(args[0]); p = ToString(args[0]);
for (var i = 1; i < n - 1; i++) { for (var i = 1; i < n - 1; i++) {
p += ',' + $toString(args[i]); p += ',' + ToString(args[i]);
} }
// If the formal parameters string include ) - an illegal // If the formal parameters string include ) - an illegal
// character - it may make the combined function expression // character - it may make the combined function expression
...@@ -1733,7 +1739,7 @@ function NewFunctionString(args, function_token) { ...@@ -1733,7 +1739,7 @@ function NewFunctionString(args, function_token) {
// comments we can include a trailing block comment to catch this. // comments we can include a trailing block comment to catch this.
p += '\n/' + '**/'; p += '\n/' + '**/';
} }
var body = (n > 0) ? $toString(args[n - 1]) : ''; var body = (n > 0) ? ToString(args[n - 1]) : '';
return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; return '(' + function_token + '(' + p + ') {\n' + body + '\n})';
} }
...@@ -1782,19 +1788,16 @@ function GetIterator(obj, method) { ...@@ -1782,19 +1788,16 @@ function GetIterator(obj, method) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Exports // Exports
$functionSourceString = FunctionSourceString;
utils.ObjectDefineProperties = ObjectDefineProperties;
utils.ObjectDefineProperty = ObjectDefineProperty;
utils.Export(function(to) { utils.Export(function(to) {
to.Delete = Delete; to.Delete = Delete;
to.FunctionSourceString = FunctionSourceString;
to.GetIterator = GetIterator; to.GetIterator = GetIterator;
to.GetMethod = GetMethod; to.GetMethod = GetMethod;
to.IsFinite = GlobalIsFinite; to.IsFinite = GlobalIsFinite;
to.IsNaN = GlobalIsNaN; to.IsNaN = GlobalIsNaN;
to.NewFunctionString = NewFunctionString; to.NewFunctionString = NewFunctionString;
to.NumberIsNaN = NumberIsNaN; to.NumberIsNaN = NumberIsNaN;
to.ObjectDefineProperties = ObjectDefineProperties;
to.ObjectDefineProperty = ObjectDefineProperty; to.ObjectDefineProperty = ObjectDefineProperty;
to.ObjectFreeze = ObjectFreezeJS; to.ObjectFreeze = ObjectFreezeJS;
to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys; to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys;
......
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