"src/macros.py",
"src/messages.h",
"src/runtime.js",
- "src/prologue.js",
"src/v8natives.js",
"src/symbol.js",
"src/array.js",
var $iteratorCreateResultObject;
var $arrayValues;
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
var $innerArrayReverse;
var $innerArraySort;
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
// Imports
var GlobalArray = global.Array;
-var InternalArray = utils.InternalArray;
-var InternalPackedArray = utils.InternalPackedArray;
-
-var MathMin;
-
-utils.Import(function(from) {
- MathMin = from.MathMin;
-});
+var InternalArray = exports.InternalArray;
+var InternalPackedArray = exports.InternalPackedArray;
// -------------------------------------------------------------------
// Move data to new array.
var new_array = new InternalArray(
// Clamp array length to 2^32-1 to avoid early RangeError.
- MathMin(len - del_count + num_additional_args, 0xffffffff));
+ $min(len - del_count + num_additional_args, 0xffffffff));
var big_indices;
var indices = %GetArrayKeys(array, len);
if (IS_NUMBER(indices)) {
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
%CheckIsBootstrapping();
-
-// -------------------------------------------------------------------
-// Imports
-
var GlobalArrayBuffer = global.ArrayBuffer;
var GlobalObject = global.Object;
-var MathMax;
-var MathMin;
-
-utils.Import(function(from) {
- MathMax = from.MathMax;
- MathMin = from.MathMin;
-});
-
// -------------------------------------------------------------------
function ArrayBufferConstructor(length) { // length = 1
var first;
var byte_length = %_ArrayBufferGetByteLength(this);
if (relativeStart < 0) {
- first = MathMax(byte_length + relativeStart, 0);
+ first = $max(byte_length + relativeStart, 0);
} else {
- first = MathMin(relativeStart, byte_length);
+ first = $min(relativeStart, byte_length);
}
var relativeEnd = IS_UNDEFINED(end) ? byte_length : end;
var fin;
if (relativeEnd < 0) {
- fin = MathMax(byte_length + relativeEnd, 0);
+ fin = $max(byte_length + relativeEnd, 0);
} else {
- fin = MathMin(relativeEnd, byte_length);
+ fin = $min(relativeEnd, byte_length);
}
if (fin < first) {
FunctionMode function_mode);
void SetStrongFunctionInstanceDescriptor(Handle<Map> map);
- static bool CompileBuiltin(Isolate* isolate, int index);
+ static bool CompileBuiltin(Isolate* isolate, int index,
+ Handle<JSObject> shared);
static bool CompileExperimentalBuiltin(Isolate* isolate, int index);
static bool CompileExtraBuiltin(Isolate* isolate, int index);
static bool CompileNative(Isolate* isolate, Vector<const char> name,
Handle<String> source, int argc,
Handle<Object> argv[]);
- static bool CallUtilsFunction(Isolate* isolate, const char* name);
-
static bool CompileExtension(Isolate* isolate, v8::Extension* extension);
Isolate* isolate_;
}
-bool Genesis::CompileBuiltin(Isolate* isolate, int index) {
+bool Genesis::CompileBuiltin(Isolate* isolate, int index,
+ Handle<JSObject> shared) {
Vector<const char> name = Natives::GetScriptName(index);
Handle<String> source_code =
isolate->bootstrapper()->SourceLookup<Natives>(index);
Handle<Object> global = isolate->global_object();
- Handle<Object> utils = isolate->natives_utils_object();
- Handle<Object> args[] = {global, utils};
+ Handle<Object> exports = isolate->builtin_exports_object();
+ Handle<Object> args[] = {global, shared, exports};
return CompileNative(isolate, name, source_code, arraysize(args), args);
}
Handle<String> source_code =
isolate->bootstrapper()->SourceLookup<ExperimentalNatives>(index);
Handle<Object> global = isolate->global_object();
- Handle<Object> utils = isolate->natives_utils_object();
- Handle<Object> args[] = {global, utils};
+ Handle<Object> exports = isolate->builtin_exports_object();
+ Handle<Object> args[] = {global, exports};
return CompileNative(isolate, name, source_code, arraysize(args), args);
}
}
-bool Genesis::CallUtilsFunction(Isolate* isolate, const char* name) {
- Handle<JSObject> utils =
- Handle<JSObject>::cast(isolate->natives_utils_object());
- Handle<String> name_string =
- isolate->factory()->NewStringFromAsciiChecked(name);
- Handle<Object> fun = JSObject::GetDataProperty(utils, name_string);
- Handle<Object> receiver = isolate->factory()->undefined_value();
- return !Execution::Call(isolate, fun, receiver, 0, NULL).is_null();
-}
-
-
bool Genesis::CompileExtension(Isolate* isolate, v8::Extension* extension) {
Factory* factory = isolate->factory();
HandleScope scope(isolate);
native_context()->set_runtime_context(*context);
- // Set up the utils object as shared container between native scripts.
- Handle<JSObject> utils = factory()->NewJSObject(isolate()->object_function());
- JSObject::NormalizeProperties(utils, CLEAR_INOBJECT_PROPERTIES, 16,
- "utils container for native scripts");
- native_context()->set_natives_utils_object(*utils);
+ // Set up shared object to set up cross references between native scripts.
+ // "shared" is used for cross references between native scripts that are part
+ // of the snapshot. "builtin_exports" is used for experimental natives.
+ Handle<JSObject> shared =
+ factory()->NewJSObject(isolate()->object_function());
+ JSObject::NormalizeProperties(shared, CLEAR_INOBJECT_PROPERTIES, 16,
+ "container to share between native scripts");
+
+ Handle<JSObject> builtin_exports =
+ factory()->NewJSObject(isolate()->object_function());
+ JSObject::NormalizeProperties(builtin_exports, CLEAR_INOBJECT_PROPERTIES, 16,
+ "container to export to experimental natives");
+ native_context()->set_builtin_exports_object(*builtin_exports);
Handle<JSObject> extras_exports =
factory()->NewJSObject(isolate()->object_function());
native_context()->set_extras_exports_object(*extras_exports);
if (FLAG_expose_natives_as != NULL) {
- Handle<String> utils_key = factory()->NewStringFromAsciiChecked("utils");
- JSObject::AddProperty(builtins, utils_key, utils, NONE);
+ Handle<String> shared_key = factory()->NewStringFromAsciiChecked("shared");
+ JSObject::AddProperty(builtins, shared_key, shared, NONE);
}
{ // -- S c r i p t
// transition easy to trap. Moreover, they rarely are smi-only.
{
HandleScope scope(isolate());
- Handle<JSObject> utils =
- Handle<JSObject>::cast(isolate()->natives_utils_object());
- Handle<JSFunction> array_function =
- InstallInternalArray(utils, "InternalArray", FAST_HOLEY_ELEMENTS);
+ Handle<JSObject> builtin_exports =
+ Handle<JSObject>::cast(isolate()->builtin_exports_object());
+ Handle<JSFunction> array_function = InstallInternalArray(
+ builtin_exports, "InternalArray", FAST_HOLEY_ELEMENTS);
native_context()->set_internal_array_function(*array_function);
- InstallInternalArray(utils, "InternalPackedArray", FAST_ELEMENTS);
+ InstallInternalArray(builtin_exports, "InternalPackedArray", FAST_ELEMENTS);
}
{ // -- S e t I t e r a t o r
#undef INSTALL_PUBLIC_SYMBOL
}
+ // Install natives. Everything exported to experimental natives is also
+ // shared to regular natives.
+ TransferNamedProperties(builtin_exports, shared);
int i = Natives::GetDebuggerCount();
- if (!CompileBuiltin(isolate(), i)) return false;
+ if (!CompileBuiltin(isolate(), i, shared)) return false;
if (!InstallJSBuiltins(builtins)) return false;
for (++i; i < Natives::GetBuiltinsCount(); ++i) {
- if (!CompileBuiltin(isolate(), i)) return false;
+ if (!CompileBuiltin(isolate(), i, shared)) return false;
}
- if (!CallUtilsFunction(isolate(), "PostNatives")) return false;
-
InstallNativeFunctions();
auto function_cache =
Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate);
JSObject::AddProperty(Error, name, stack_trace_limit, NONE);
- // By now the utils object is useless and can be removed.
- native_context->set_natives_utils_object(*factory->undefined_value());
+ Handle<Object> builtin_exports(native_context->builtin_exports_object(),
+ isolate);
+ native_context->set_builtin_exports_object(Smi::FromInt(0));
// Expose the natives in global if a name for it is specified.
if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
if (natives_key->AsArrayIndex(&dummy_index)) return true;
Handle<JSBuiltinsObject> natives(global->builtins());
JSObject::AddProperty(global, natives_key, natives, DONT_ENUM);
+ Handle<String> builtin_exports_key =
+ factory->NewStringFromAsciiChecked("builtin_exports");
+ JSObject::AddProperty(natives, builtin_exports_key, builtin_exports, NONE);
}
// Expose the stack trace symbol to native JS.
var $setIteratorNext;
var $setValues;
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
V(SET_ITERATOR_MAP_INDEX, Map, set_iterator_map) \
V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \
V(SCRIPT_CONTEXT_TABLE_INDEX, ScriptContextTable, script_context_table) \
- V(NATIVES_UTILS_OBJECT_INDEX, Object, natives_utils_object) \
+ V(BUILTIN_EXPORTS_OBJECT_INDEX, Object, builtin_exports_object) \
V(EXTRAS_EXPORTS_OBJECT_INDEX, JSObject, extras_exports_object)
SCRIPT_CONTEXT_TABLE_INDEX,
MAP_CACHE_INDEX,
TO_LENGTH_FUN_INDEX,
- NATIVES_UTILS_OBJECT_INDEX,
+ BUILTIN_EXPORTS_OBJECT_INDEX,
EXTRAS_EXPORTS_OBJECT_INDEX,
// Properties from here are treated as weak references by the full GC.
// -------------------------------------------------------------------
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
// Imports
var GlobalDate = global.Date;
-var InternalArray = utils.InternalArray;
-
-var MathAbs;
-var MathFloor;
-
-utils.Import(function(from) {
- MathAbs = from.MathAbs;
- MathFloor = from.MathFloor;
-});
+var InternalArray = shared.InternalArray;
// -------------------------------------------------------------------
// 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 ($abs(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 ($abs(time) > MAX_TIME_MS) return NAN;
return TO_INTEGER(time);
}
var timezoneOffset = -TIMEZONE_OFFSET(date);
var sign = (timezoneOffset >= 0) ? 1 : -1;
- var hours = MathFloor((sign * timezoneOffset)/60);
- var min = MathFloor((sign * timezoneOffset)%60);
+ var hours = $floor((sign * timezoneOffset)/60);
+ var min = $floor((sign * timezoneOffset)%60);
var gmt = ' GMT' + ((sign == 1) ? '+' : '-') +
TwoDigitString(hours) + TwoDigitString(min);
return gmt + ' (' + timezone + ')';
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+(function(global, exports) {
'use strict';
var $innerArrayFindIndex;
var $arrayFrom;
-(function(global, utils) {
+(function(global, exports) {
'use strict';
%CheckIsBootstrapping();
-// -------------------------------------------------------------------
-// Imports
-
var GlobalArray = global.Array;
var GlobalSymbol = global.Symbol;
-var MathMax;
-var MathMin;
-
-utils.Import(function(from) {
- MathMax = from.MathMax;
- MathMin = from.MathMin;
-});
-
// -------------------------------------------------------------------
function InnerArrayCopyWithin(target, start, end, array, length) {
target = TO_INTEGER(target);
var to;
if (target < 0) {
- to = MathMax(length + target, 0);
+ to = $max(length + target, 0);
} else {
- to = MathMin(target, length);
+ to = $min(target, length);
}
start = TO_INTEGER(start);
var from;
if (start < 0) {
- from = MathMax(length + start, 0);
+ from = $max(length + start, 0);
} else {
- from = MathMin(start, length);
+ from = $min(start, length);
}
end = IS_UNDEFINED(end) ? length : TO_INTEGER(end);
var final;
if (end < 0) {
- final = MathMax(length + end, 0);
+ final = $max(length + end, 0);
} else {
- final = MathMin(end, length);
+ final = $min(end, length);
}
- var count = MathMin(final - from, length - to);
+ var count = $min(final - from, length - to);
var direction = 1;
if (from < to && to < (from + count)) {
direction = -1;
// found in the LICENSE file.
//
-(function(global, utils) {
+(function(global, exports) {
"use strict";
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+(function(global, exports) {
'use strict';
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+(function(global, exports) {
'use strict';
var $spreadArguments;
var $spreadIterable;
-(function(global, utils) {
+(function(global, exports) {
'use strict';
// -------------------------------------------------------------------
// Imports
-var InternalArray = utils.InternalArray;
+var InternalArray = exports.InternalArray;
// -------------------------------------------------------------------
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+(function(global, exports) {
"use strict";
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+(function(global, exports) {
"use strict";
* Intl object is a single object that has some named properties,
* all of which are constructors.
*/
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
%CheckIsBootstrapping();
-// -------------------------------------------------------------------
-// Imports
-
var GlobalBoolean = global.Boolean;
var GlobalDate = global.Date;
var GlobalNumber = global.Number;
var GlobalRegExp = global.RegExp;
var GlobalString = global.String;
-var MathFloor;
-
-utils.Import(function(from) {
- MathFloor = from.MathFloor;
-});
-
-// -------------------------------------------------------------------
+var undefined = global.undefined;
var Intl = {};
* Caches available locales for each service.
*/
var AVAILABLE_LOCALES = {
- 'collator': UNDEFINED,
- 'numberformat': UNDEFINED,
- 'dateformat': UNDEFINED,
- 'breakiterator': UNDEFINED
+ 'collator': undefined,
+ 'numberformat': undefined,
+ 'dateformat': undefined,
+ 'breakiterator': undefined
};
/**
* Caches default ICU locale.
*/
-var DEFAULT_ICU_LOCALE = UNDEFINED;
+var DEFAULT_ICU_LOCALE = undefined;
/**
* Unicode extension regular expression.
*/
-var UNICODE_EXTENSION_RE = UNDEFINED;
+var UNICODE_EXTENSION_RE = undefined;
function GetUnicodeExtensionRE() {
- if (IS_UNDEFINED(UNDEFINED)) {
+ if (UNICODE_EXTENSION_RE === undefined) {
UNICODE_EXTENSION_RE = new GlobalRegExp('-u(-[a-z0-9]{2,8})+', 'g');
}
return UNICODE_EXTENSION_RE;
/**
* Matches any Unicode extension.
*/
-var ANY_EXTENSION_RE = UNDEFINED;
+var ANY_EXTENSION_RE = undefined;
function GetAnyExtensionRE() {
- if (IS_UNDEFINED(ANY_EXTENSION_RE)) {
+ if (ANY_EXTENSION_RE === undefined) {
ANY_EXTENSION_RE = new GlobalRegExp('-[a-z0-9]{1}-.*', 'g');
}
return ANY_EXTENSION_RE;
/**
* Replace quoted text (single quote, anything but the quote and quote again).
*/
-var QUOTED_STRING_RE = UNDEFINED;
+var QUOTED_STRING_RE = undefined;
function GetQuotedStringRE() {
- if (IS_UNDEFINED(QUOTED_STRING_RE)) {
+ if (QUOTED_STRING_RE === undefined) {
QUOTED_STRING_RE = new GlobalRegExp("'[^']+'", 'g');
}
return QUOTED_STRING_RE;
/**
* Matches valid service name.
*/
-var SERVICE_RE = UNDEFINED;
+var SERVICE_RE = undefined;
function GetServiceRE() {
- if (IS_UNDEFINED(SERVICE_RE)) {
+ if (SERVICE_RE === undefined) {
SERVICE_RE =
new GlobalRegExp('^(collator|numberformat|dateformat|breakiterator)$');
}
* Validates a language tag against bcp47 spec.
* Actual value is assigned on first run.
*/
-var LANGUAGE_TAG_RE = UNDEFINED;
+var LANGUAGE_TAG_RE = undefined;
function GetLanguageTagRE() {
- if (IS_UNDEFINED(LANGUAGE_TAG_RE)) {
+ if (LANGUAGE_TAG_RE === undefined) {
BuildLanguageTagREs();
}
return LANGUAGE_TAG_RE;
/**
* Helps find duplicate variants in the language tag.
*/
-var LANGUAGE_VARIANT_RE = UNDEFINED;
+var LANGUAGE_VARIANT_RE = undefined;
function GetLanguageVariantRE() {
- if (IS_UNDEFINED(LANGUAGE_VARIANT_RE)) {
+ if (LANGUAGE_VARIANT_RE === undefined) {
BuildLanguageTagREs();
}
return LANGUAGE_VARIANT_RE;
/**
* Helps find duplicate singletons in the language tag.
*/
-var LANGUAGE_SINGLETON_RE = UNDEFINED;
+var LANGUAGE_SINGLETON_RE = undefined;
function GetLanguageSingletonRE() {
- if (IS_UNDEFINED(LANGUAGE_SINGLETON_RE)) {
+ if (LANGUAGE_SINGLETON_RE === undefined) {
BuildLanguageTagREs();
}
return LANGUAGE_SINGLETON_RE;
/**
* Matches valid IANA time zone names.
*/
-var TIMEZONE_NAME_CHECK_RE = UNDEFINED;
+var TIMEZONE_NAME_CHECK_RE = undefined;
function GetTimezoneNameCheckRE() {
- if (IS_UNDEFINED(TIMEZONE_NAME_CHECK_RE)) {
+ if (TIMEZONE_NAME_CHECK_RE === undefined) {
TIMEZONE_NAME_CHECK_RE =
new GlobalRegExp('^([A-Za-z]+)/([A-Za-z]+)(?:_([A-Za-z]+))*$');
}
throw MakeTypeError(kMethodCalledOnWrongObject, methodName);
}
var internalName = '__bound' + methodName + '__';
- if (IS_UNDEFINED(this[internalName])) {
+ if (this[internalName] === undefined) {
var that = this;
var boundMethod;
- if (IS_UNDEFINED(length) || length === 2) {
+ if (length === undefined || length === 2) {
boundMethod = function(x, y) {
if (%_IsConstructCall()) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
// Provide defaults if matcher was not specified.
- if (IS_UNDEFINED(options)) {
+ if (options === undefined) {
options = {};
} else {
options = $toObject(options);
}
var matcher = options.localeMatcher;
- if (!IS_UNDEFINED(matcher)) {
+ if (matcher !== undefined) {
matcher = GlobalString(matcher);
if (matcher !== 'lookup' && matcher !== 'best fit') {
throw MakeRangeError(kLocaleMatcher, matcher);
var requestedLocales = initializeLocaleList(locales);
// Cache these, they don't ever change per service.
- if (IS_UNDEFINED(AVAILABLE_LOCALES[service])) {
+ if (AVAILABLE_LOCALES[service] === undefined) {
AVAILABLE_LOCALES[service] = getAvailableLocalesOf(service);
}
// Remove -u- extension.
var locale = requestedLocales[i].replace(GetUnicodeExtensionRE(), '');
do {
- if (!IS_UNDEFINED(availableLocales[locale])) {
+ if (availableLocales[locale] !== undefined) {
// Push requested locale not the resolved one.
matchedLocales.push(requestedLocales[i]);
break;
* is out of range for that property it throws RangeError.
*/
function getGetOption(options, caller) {
- if (IS_UNDEFINED(options)) throw MakeError(kDefaultOptionsMissing, caller);
+ if (options === undefined) throw MakeError(kDefaultOptionsMissing, caller);
var getOption = function getOption(property, type, values, defaultValue) {
- if (!IS_UNDEFINED(options[property])) {
+ if (options[property] !== undefined) {
var value = options[property];
switch (type) {
case 'boolean':
default:
throw MakeError(kWrongValueType);
}
- if (!IS_UNDEFINED(values) && values.indexOf(value) === -1) {
+ if (values !== undefined && values.indexOf(value) === -1) {
throw MakeRangeError(kValueOutOfRange, value, caller, property);
}
}
// Cache these, they don't ever change per service.
- if (IS_UNDEFINED(AVAILABLE_LOCALES[service])) {
+ if (AVAILABLE_LOCALES[service] === undefined) {
AVAILABLE_LOCALES[service] = getAvailableLocalesOf(service);
}
// Remove all extensions.
var locale = requestedLocales[i].replace(GetAnyExtensionRE(), '');
do {
- if (!IS_UNDEFINED(AVAILABLE_LOCALES[service][locale])) {
+ if (AVAILABLE_LOCALES[service][locale] !== undefined) {
// Return the resolved locale and extension.
var extensionMatch = requestedLocales[i].match(GetUnicodeExtensionRE());
var extension = IS_NULL(extensionMatch) ? '' : extensionMatch[0];
}
// Didn't find a match, return default.
- if (IS_UNDEFINED(DEFAULT_ICU_LOCALE)) {
+ if (DEFAULT_ICU_LOCALE === undefined) {
DEFAULT_ICU_LOCALE = %GetDefaultICULocale();
}
// Key is {2}alphanum, value is {3,8}alphanum.
// Some keys may not have explicit values (booleans).
var extensionMap = {};
- var previousKey = UNDEFINED;
+ var previousKey = undefined;
for (var i = 2; i < extensionSplit.length; ++i) {
var length = extensionSplit[i].length;
var element = extensionSplit[i];
if (length === 2) {
- extensionMap[element] = UNDEFINED;
+ extensionMap[element] = undefined;
previousKey = element;
- } else if (length >= 3 && length <=8 && !IS_UNDEFINED(previousKey)) {
+ } else if (length >= 3 && length <=8 && previousKey !== undefined) {
extensionMap[previousKey] = element;
- previousKey = UNDEFINED;
+ previousKey = undefined;
} else {
// There is a value that's too long, or that doesn't have a key.
return {};
value = (value === 'true') ? true : false;
}
- if (!IS_UNDEFINED(property)) {
+ if (property !== undefined) {
defineWEProperty(outOptions, property, value);
}
}
for (var key in keyValues) {
if (keyValues.hasOwnProperty(key)) {
- var value = UNDEFINED;
+ var value = undefined;
var map = keyValues[key];
- if (!IS_UNDEFINED(map.property)) {
+ if (map.property !== undefined) {
// This may return true if user specifies numeric: 'false', since
// Boolean('nonempty') === true.
value = getOption(map.property, map.type, map.values);
}
- if (!IS_UNDEFINED(value)) {
+ if (value !== undefined) {
updateProperty(map.property, map.type, value);
extension += updateExtension(key, value);
continue;
// values (not a user error).
if (extensionMap.hasOwnProperty(key)) {
value = extensionMap[key];
- if (!IS_UNDEFINED(value)) {
+ if (value !== undefined) {
updateProperty(map.property, map.type, value);
extension += updateExtension(key, value);
} else if (map.type === 'boolean') {
* Sets configurable descriptor to false.
*/
function addWEPropertyIfDefined(object, property, value) {
- if (!IS_UNDEFINED(value)) {
+ if (value !== undefined) {
defineWEProperty(object, property, value);
}
}
* Sets all descriptors to true.
*/
function addWECPropertyIfDefined(object, property, value) {
- if (!IS_UNDEFINED(value)) {
+ if (value !== undefined) {
defineWECProperty(object, property, value);
}
}
*/
function initializeLocaleList(locales) {
var seen = [];
- if (IS_UNDEFINED(locales)) {
+ if (locales === undefined) {
// Constructor is called without arguments.
seen = [];
} else {
throw MakeTypeError(kReinitializeIntl, "Collator");
}
- if (IS_UNDEFINED(options)) {
+ if (options === undefined) {
options = {};
}
var sensitivity = getOption('sensitivity', 'string',
['base', 'accent', 'case', 'variant']);
- if (IS_UNDEFINED(sensitivity) && internalOptions.usage === 'sort') {
+ if (sensitivity === undefined && internalOptions.usage === 'sort') {
sensitivity = 'variant';
}
defineWEProperty(internalOptions, 'sensitivity', sensitivity);
defineWEProperty(internalOptions, 'ignorePunctuation', getOption(
- 'ignorePunctuation', 'boolean', UNDEFINED, false));
+ 'ignorePunctuation', 'boolean', undefined, false));
var locale = resolveLocale('collator', locales, options);
*/
function getNumberOption(options, property, min, max, fallback) {
var value = options[property];
- if (!IS_UNDEFINED(value)) {
+ if (value !== undefined) {
value = GlobalNumber(value);
if ($isNaN(value) || value < min || value > max) {
throw MakeRangeError(kPropertyValueOutOfRange, property);
}
- return MathFloor(value);
+ return $floor(value);
}
return fallback;
throw MakeTypeError(kReinitializeIntl, "NumberFormat");
}
- if (IS_UNDEFINED(options)) {
+ if (options === undefined) {
options = {};
}
'style', 'string', ['decimal', 'percent', 'currency'], 'decimal'));
var currency = getOption('currency', 'string');
- if (!IS_UNDEFINED(currency) && !isWellFormedCurrencyCode(currency)) {
+ if (currency !== undefined && !isWellFormedCurrencyCode(currency)) {
throw MakeRangeError(kInvalidCurrencyCode, currency);
}
- if (internalOptions.style === 'currency' && IS_UNDEFINED(currency)) {
+ if (internalOptions.style === 'currency' && currency === undefined) {
throw MakeTypeError(kCurrencyCode);
}
var mnsd = options['minimumSignificantDigits'];
var mxsd = options['maximumSignificantDigits'];
- if (!IS_UNDEFINED(mnsd) || !IS_UNDEFINED(mxsd)) {
+ if (mnsd !== undefined || mxsd !== undefined) {
mnsd = getNumberOption(options, 'minimumSignificantDigits', 1, 21, 0);
defineWEProperty(internalOptions, 'minimumSignificantDigits', mnsd);
// Grouping.
defineWEProperty(internalOptions, 'useGrouping', getOption(
- 'useGrouping', 'boolean', UNDEFINED, true));
+ 'useGrouping', 'boolean', undefined, true));
// ICU prefers options to be passed using -u- extension key/values for
// number format, so we need to build that.
* for a number format.
*/
var NUMBER_FORMAT_KEY_MAP = {
- 'nu': {'property': UNDEFINED, 'type': 'string'}
+ 'nu': {'property': undefined, 'type': 'string'}
};
var extension = setOptions(options, extensionMap, NUMBER_FORMAT_KEY_MAP,
useGrouping: {writable: true}
});
if (internalOptions.hasOwnProperty('minimumSignificantDigits')) {
- defineWEProperty(resolved, 'minimumSignificantDigits', UNDEFINED);
+ defineWEProperty(resolved, 'minimumSignificantDigits', undefined);
}
if (internalOptions.hasOwnProperty('maximumSignificantDigits')) {
- defineWEProperty(resolved, 'maximumSignificantDigits', UNDEFINED);
+ defineWEProperty(resolved, 'maximumSignificantDigits', undefined);
}
var formatter = %CreateNumberFormat(requestedLocale,
internalOptions,
var hr12 = getOption('hour12', 'boolean');
option = getOption('hour', 'string', ['2-digit', 'numeric']);
- if (IS_UNDEFINED(hr12)) {
+ if (hr12 === undefined) {
ldmlString += appendToLDMLString(option, {'2-digit': 'jj', 'numeric': 'j'});
} else if (hr12 === true) {
ldmlString += appendToLDMLString(option, {'2-digit': 'hh', 'numeric': 'h'});
* Returns either LDML equivalent of the current option or empty string.
*/
function appendToLDMLString(option, pairs) {
- if (!IS_UNDEFINED(option)) {
+ if (option !== undefined) {
return pairs[option];
} else {
return '';
function appendToDateTimeObject(options, option, match, pairs) {
if (IS_NULL(match)) {
if (!options.hasOwnProperty(option)) {
- defineWEProperty(options, option, UNDEFINED);
+ defineWEProperty(options, option, undefined);
}
return options;
}
* Returns options with at least default values in it.
*/
function toDateTimeOptions(options, required, defaults) {
- if (IS_UNDEFINED(options)) {
+ if (options === undefined) {
options = {};
} else {
options = TO_OBJECT_INLINE(options);
var needsDefault = true;
if ((required === 'date' || required === 'any') &&
- (!IS_UNDEFINED(options.weekday) || !IS_UNDEFINED(options.year) ||
- !IS_UNDEFINED(options.month) || !IS_UNDEFINED(options.day))) {
+ (options.weekday !== undefined || options.year !== undefined ||
+ options.month !== undefined || options.day !== undefined)) {
needsDefault = false;
}
if ((required === 'time' || required === 'any') &&
- (!IS_UNDEFINED(options.hour) || !IS_UNDEFINED(options.minute) ||
- !IS_UNDEFINED(options.second))) {
+ (options.hour !== undefined || options.minute !== undefined ||
+ options.second !== undefined)) {
needsDefault = false;
}
throw MakeTypeError(kReinitializeIntl, "DateTimeFormat");
}
- if (IS_UNDEFINED(options)) {
+ if (options === undefined) {
options = {};
}
* for a date/time format.
*/
var DATETIME_FORMAT_KEY_MAP = {
- 'ca': {'property': UNDEFINED, 'type': 'string'},
- 'nu': {'property': UNDEFINED, 'type': 'string'}
+ 'ca': {'property': undefined, 'type': 'string'},
+ 'nu': {'property': undefined, 'type': 'string'}
};
var extension = setOptions(options, extensionMap, DATETIME_FORMAT_KEY_MAP,
var formatter = %CreateDateTimeFormat(
requestedLocale, {skeleton: ldmlString, timeZone: tz}, resolved);
- if (!IS_UNDEFINED(tz) && tz !== resolved.timeZone) {
+ if (tz !== undefined && tz !== resolved.timeZone) {
throw MakeRangeError(kUnsupportedTimeZone, tz);
}
var format = this;
var fromPattern = fromLDMLString(format.resolved.pattern);
var userCalendar = ICU_CALENDAR_MAP[format.resolved.calendar];
- if (IS_UNDEFINED(userCalendar)) {
+ if (userCalendar === undefined) {
// Use ICU name if we don't have a match. It shouldn't happen, but
// it would be too strict to throw for this.
userCalendar = format.resolved.calendar;
*/
function formatDate(formatter, dateValue) {
var dateMs;
- if (IS_UNDEFINED(dateValue)) {
+ if (dateValue === undefined) {
dateMs = GlobalDate.now();
} else {
dateMs = $toNumber(dateValue);
*/
function canonicalizeTimeZoneID(tzID) {
// Skip undefined zones.
- if (IS_UNDEFINED(tzID)) {
+ if (tzID === undefined) {
return tzID;
}
var result = toTitleCaseWord(match[1]) + '/' + toTitleCaseWord(match[2]);
var i = 3;
- while (!IS_UNDEFINED(match[i]) && i < match.length) {
+ while (match[i] !== undefined && i < match.length) {
result = result + '_' + toTitleCaseWord(match[i]);
i++;
}
throw MakeTypeError(kReinitializeIntl, "v8BreakIterator");
}
- if (IS_UNDEFINED(options)) {
+ if (options === undefined) {
options = {};
}
// Default (created with undefined locales and options parameters) collator,
// number and date format instances. They'll be created as needed.
var defaultObjects = {
- 'collator': UNDEFINED,
- 'numberformat': UNDEFINED,
- 'dateformatall': UNDEFINED,
- 'dateformatdate': UNDEFINED,
- 'dateformattime': UNDEFINED,
+ 'collator': undefined,
+ 'numberformat': undefined,
+ 'dateformatall': undefined,
+ 'dateformatdate': undefined,
+ 'dateformattime': undefined,
};
* We cache only default instances (where no locales or options are provided).
*/
function cachedOrNewService(service, locales, options, defaults) {
- var useOptions = (IS_UNDEFINED(defaults)) ? options : defaults;
- if (IS_UNDEFINED(locales) && IS_UNDEFINED(options)) {
- if (IS_UNDEFINED(defaultObjects[service])) {
+ var useOptions = (defaults === undefined) ? options : defaults;
+ if (locales === undefined && options === undefined) {
+ if (defaultObjects[service] === undefined) {
defaultObjects[service] = new savedObjects[service](locales, useOptions);
}
return defaultObjects[service];
var $iteratorPrototype;
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
%CheckIsBootstrapping();
var $jsonSerializeAdapter;
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
// Imports
var GlobalJSON = global.JSON;
-var InternalArray = utils.InternalArray;
-
-var MathMax;
-var MathMin;
-
-utils.Import(function(from) {
- MathMax = from.MathMax;
- MathMin = from.MathMin;
-});
+var InternalArray = shared.InternalArray;
// -------------------------------------------------------------------
}
var gap;
if (IS_NUMBER(space)) {
- space = MathMax(0, MathMin($toInteger(space), 10));
+ space = $max(0, $min($toInteger(space), 10));
gap = %_SubString(" ", 0, space);
} else if (IS_STRING(space)) {
if (space.length > 10) {
var rngstate; // Initialized to a Uint32Array during genesis.
-(function(global, utils) {
+var $abs;
+var $exp;
+var $floor;
+var $max;
+var $min;
+
+(function(global, shared, exports) {
"use strict";
// Imports
var GlobalObject = global.Object;
-var InternalArray = utils.InternalArray;
+var InternalArray = shared.InternalArray;
//-------------------------------------------------------------------
%SetForceInlineFlag(MathSqrtJS);
%SetForceInlineFlag(MathTrunc);
-// -------------------------------------------------------------------
-// Exports
-
-utils.Export(function(to) {
- to.MathAbs = MathAbs;
- to.MathExp = MathExp;
- to.MathFloor = MathFloorJS;
- to.MathMax = MathMax;
- to.MathMin = MathMin;
-});
+// Expose to the global scope.
+$abs = MathAbs;
+$exp = MathExp;
+$floor = MathFloorJS;
+$max = MathMax;
+$min = MathMin;
})
var MakeSyntaxErrorEmbedded;
var MakeTypeErrorEmbedded;
-(function(global, utils) {
+(function(global, shared, exports) {
%CheckIsBootstrapping();
// Imports
var GlobalObject = global.Object;
-var InternalArray = utils.InternalArray;
-
-var StringCharAt;
-var StringIndexOf;
-var StringSubstring;
-
-utils.Import(function(from) {
- StringCharAt = from.StringCharAt;
- StringIndexOf = from.StringIndexOf;
- StringSubstring = from.StringSubstring;
-});
+var InternalArray = shared.InternalArray;
// -------------------------------------------------------------------
var line_ends = this.line_ends;
var start = line == 0 ? 0 : line_ends[line - 1] + 1;
var end = line_ends[line];
- if (end > 0 && %_CallFunction(this.source, end - 1, StringCharAt) == '\r') {
+ if (end > 0 && %_CallFunction(this.source, end - 1, $stringCharAt) == '\r') {
end--;
}
var column = position - start;
var line_ends = this.line_ends;
var start = line == 0 ? 0 : line_ends[line - 1] + 1;
var end = line_ends[line];
- return %_CallFunction(this.source, start, end, StringSubstring);
+ return %_CallFunction(this.source, start, end, $stringSubstring);
}
return %_CallFunction(this.script.source,
this.start,
this.end,
- StringSubstring);
+ $stringSubstring);
}
return %_CallFunction(this.script.source,
this.from_position,
this.to_position,
- StringSubstring);
+ $stringSubstring);
}
$setUpLockedPrototype(SourceSlice,
var methodName = this.getMethodName();
if (functionName) {
if (typeName &&
- %_CallFunction(functionName, typeName, StringIndexOf) != 0) {
+ %_CallFunction(functionName, typeName, $stringIndexOf) != 0) {
line += typeName + ".";
}
line += functionName;
if (methodName &&
- (%_CallFunction(functionName, "." + methodName, StringIndexOf) !=
+ (%_CallFunction(functionName, "." + methodName, $stringIndexOf) !=
functionName.length - methodName.length - 1)) {
line += " [as " + methodName + "]";
}
var $observeNativeObjectGetNotifier;
var $observeNativeObjectNotifierPerformChange;
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
var GlobalArray = global.Array;
var GlobalObject = global.Object;
-var InternalArray = utils.InternalArray;
+var InternalArray = shared.InternalArray;
// -------------------------------------------------------------------
+++ /dev/null
-// Copyright 2015 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-(function(global, utils) {
-
-"use strict";
-
-%CheckIsBootstrapping();
-
-// -----------------------------------------------------------------------
-// Utils
-
-var imports = UNDEFINED;
-var exports = UNDEFINED;
-
-
-utils.Export = function Export(f) {
- f.next = exports;
- exports = f;
-};
-
-
-utils.Import = function Import(f) {
- f.next = imports;
- imports = f;
-};
-
-// -----------------------------------------------------------------------
-// To be called by bootstrapper
-
-utils.PostNatives = function() {
- %CheckIsBootstrapping();
-
- var container = {};
- for ( ; !IS_UNDEFINED(exports); exports = exports.next) exports(container);
- for ( ; !IS_UNDEFINED(imports); imports = imports.next) imports(container);
-
- var expose_to_experimental = [
- "MathMax",
- "MathMin",
- ];
- var experimental = {};
- %OptimizeObjectForAddingMultipleProperties(
- experimental, expose_to_experimental.length);
- for (var key of expose_to_experimental) experimental[key] = container[key];
- %ToFastProperties(experimental);
- container = UNDEFINED;
-
- utils.Export = UNDEFINED;
- utils.PostNatives = UNDEFINED;
- utils.Import = function ImportFromExperimental(f) {
- f(experimental);
- };
-};
-
-})
var $promiseStatus;
var $promiseValue;
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
// -------------------------------------------------------------------
// Imports
-var InternalArray = utils.InternalArray;
+var InternalArray = shared.InternalArray;
// -------------------------------------------------------------------
var $proxyDerivedSetTrap;
var $proxyEnumerate;
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
var harmony_regexps = false;
var harmony_unicode_regexps = false;
-(function(global, utils) {
+(function(global, shared, exports) {
%CheckIsBootstrapping();
// Imports
var GlobalRegExp = global.RegExp;
-var InternalPackedArray = utils.InternalPackedArray;
+var InternalPackedArray = shared.InternalPackedArray;
// -------------------------------------------------------------------
var $toString;
var $toUint32;
-(function(global, utils) {
+(function(global, shared, exports) {
%CheckIsBootstrapping();
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+var $stringCharAt;
+var $stringIndexOf;
+var $stringSubstring;
+
+(function(global, shared, exports) {
%CheckIsBootstrapping();
var GlobalRegExp = global.RegExp;
var GlobalString = global.String;
-var InternalArray = utils.InternalArray;
-var InternalPackedArray = utils.InternalPackedArray;
-
-var MathMax;
-var MathMin;
-
-utils.Import(function(from) {
- MathMax = from.MathMax;
- MathMin = from.MathMin;
-});
+var InternalArray = shared.InternalArray;
+var InternalPackedArray = shared.InternalPackedArray;
//-------------------------------------------------------------------
}
var s_len = s.length;
- var start = MathMin(MathMax(pos, 0), s_len);
+ var start = $min($max(pos, 0), s_len);
var ss_len = ss.length;
if (ss_len + start > s_len) {
return false;
}
}
- var end = MathMin(MathMax(pos, 0), s_len);
+ var end = $min($max(pos, 0), s_len);
var ss_len = ss.length;
var start = end - ss_len;
if (start < 0) {
}
var s_len = s.length;
- var start = MathMin(MathMax(pos, 0), s_len);
+ var start = $min($max(pos, 0), s_len);
var ss_len = ss.length;
if (ss_len + start > s_len) {
return false;
"sup", StringSup
]);
-// -------------------------------------------------------------------
-// Exports
-
-utils.Export(function(to) {
- to.StringCharAt = StringCharAtJS;
- to.StringIndexOf = StringIndexOfJS;
- to.StringSubstring = StringSubstring;
-});
+$stringCharAt = StringCharAtJS;
+$stringIndexOf = StringIndexOfJS;
+$stringSubstring = StringSubstring;
})
var $symbolToString;
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
var $getTemplateCallSite;
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
// Imports
var GlobalMap = global.Map;
-var InternalArray = utils.InternalArray;
+var InternalArray = shared.InternalArray;
// -------------------------------------------------------------------
var kMath;
var rempio2result;
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
%CheckIsBootstrapping();
-// -------------------------------------------------------------------
-// Imports
-
var GlobalMath = global.Math;
-var MathAbs;
-var MathExp;
-
-utils.Import(function(from) {
- MathAbs = from.MathAbs;
- MathExp = from.MathExp;
-});
-
-// -------------------------------------------------------------------
+//-------------------------------------------------------------------
define INVPIO2 = kMath[0];
define PIO2_1 = kMath[1];
}
} else if (ix <= 0x413921fb) {
// |X| ~<= 2^19*(pi/2), medium size
- var t = MathAbs(X);
+ var t = $abs(X);
n = (t * INVPIO2 + 0.5) | 0;
var r = t - n * PIO2_1;
var w = n * PIO2_1T;
if (ix < 0x3e300000) { // |x| < 2^-28
if (((ix | %_DoubleLo(x)) | (returnTan + 1)) == 0) {
// x == 0 && returnTan = -1
- return 1 / MathAbs(x);
+ return 1 / $abs(x);
} else {
if (returnTan == 1) {
return x;
x = x * 1; // Convert to number.
var h = (x < 0) ? -0.5 : 0.5;
// |x| in [0, 22]. return sign(x)*0.5*(E+E/(E+1))
- var ax = MathAbs(x);
+ var ax = $abs(x);
if (ax < 22) {
// For |x| < 2^-28, sinh(x) = x
if (ax < TWO_M28) return x;
return h * (t + t / (t + 1));
}
// |x| in [22, log(maxdouble)], return 0.5 * exp(|x|)
- if (ax < LOG_MAXD) return h * MathExp(ax);
+ if (ax < LOG_MAXD) return h * $exp(ax);
// |x| in [log(maxdouble), overflowthreshold]
// overflowthreshold = 710.4758600739426
if (ax <= KSINH_OVERFLOW) {
- var w = MathExp(0.5 * ax);
+ var w = $exp(0.5 * ax);
var t = h * w;
return t * w;
}
var ix = %_DoubleHi(x) & 0x7fffffff;
// |x| in [0,0.5*log2], return 1+expm1(|x|)^2/(2*exp(|x|))
if (ix < 0x3fd62e43) {
- var t = MathExpm1(MathAbs(x));
+ var t = MathExpm1($abs(x));
var w = 1 + t;
// For |x| < 2^-55, cosh(x) = 1
if (ix < 0x3c800000) return w;
}
// |x| in [0.5*log2, 22], return (exp(|x|)+1/exp(|x|)/2
if (ix < 0x40360000) {
- var t = MathExp(MathAbs(x));
+ var t = $exp($abs(x));
return 0.5 * t + 0.5 / t;
}
// |x| in [22, log(maxdouble)], return half*exp(|x|)
- if (ix < 0x40862e42) return 0.5 * MathExp(MathAbs(x));
+ if (ix < 0x40862e42) return 0.5 * $exp($abs(x));
// |x| in [log(maxdouble), overflowthreshold]
- if (MathAbs(x) <= KCOSH_OVERFLOW) {
- var w = MathExp(0.5 * MathAbs(x));
+ if ($abs(x) <= KCOSH_OVERFLOW) {
+ var w = $exp(0.5 * $abs(x));
var t = 0.5 * w;
return t * w;
}
function MathLog2(x) {
x = x * 1; // Convert to number.
- var ax = MathAbs(x);
+ var ax = $abs(x);
var hx = %_DoubleHi(x);
var lx = %_DoubleLo(x);
var ix = hx & 0x7fffffff;
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
%CheckIsBootstrapping();
-// -------------------------------------------------------------------
-// Imports
-
var GlobalArray = global.Array;
var GlobalArrayBuffer = global.ArrayBuffer;
var GlobalDataView = global.DataView;
var GlobalObject = global.Object;
-var MathMax;
-var MathMin;
-
-utils.Import(function(from) {
- MathMax = from.MathMax;
- MathMin = from.MathMin;
-});
-
-// -------------------------------------------------------------------
-
-
macro TYPED_ARRAYS(FUNCTION)
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
FUNCTION(1, Uint8Array, 1)
var srcLength = %_TypedArrayGetLength(this);
if (beginInt < 0) {
- beginInt = MathMax(0, srcLength + beginInt);
+ beginInt = $max(0, srcLength + beginInt);
} else {
- beginInt = MathMin(srcLength, beginInt);
+ beginInt = $min(srcLength, beginInt);
}
var endInt = IS_UNDEFINED(end) ? srcLength : end;
if (endInt < 0) {
- endInt = MathMax(0, srcLength + endInt);
+ endInt = $max(0, srcLength + endInt);
} else {
- endInt = MathMin(endInt, srcLength);
+ endInt = $min(endInt, srcLength);
}
if (endInt < beginInt) {
endInt = beginInt;
// This file contains support for URI manipulations written in
// JavaScript.
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
var GlobalObject = global.Object;
var GlobalArray = global.Array;
-var InternalArray = utils.InternalArray;
+var InternalArray = shared.InternalArray;
// -------------------------------------------------------------------
// Define internal helper functions.
var $toCompletePropertyDescriptor;
var $toNameArray;
-(function(global, utils) {
+(function(global, shared, exports) {
%CheckIsBootstrapping();
var GlobalFunction = global.Function;
var GlobalNumber = global.Number;
var GlobalObject = global.Object;
-var InternalArray = utils.InternalArray;
-
-var MathAbs;
-var StringIndexOf;
-
-utils.Import(function(from) {
- MathAbs = from.MathAbs;
- StringIndexOf = from.StringIndexOf;
-});
+var InternalArray = shared.InternalArray;
// ----------------------------------------------------------------------------
if (NumberIsFinite(number)) {
var integral = TO_INTEGER(number);
if (integral == number) {
- return MathAbs(integral) <= GlobalNumber.MAX_SAFE_INTEGER;
+ return $abs(integral) <= GlobalNumber.MAX_SAFE_INTEGER;
}
}
return false;
// If the formal parameters string include ) - an illegal
// character - it may make the combined function expression
// compile. We avoid this problem by checking for this early on.
- if (%_CallFunction(p, ')', StringIndexOf) != -1) {
+ if (%_CallFunction(p, ')', $stringIndexOf) != -1) {
throw MakeSyntaxError(kParenthesisInArgString);
}
// If the formal parameters include an unbalanced block comment, the
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function(global, utils) {
+(function(global, shared, exports) {
"use strict";
}
-static bool utils_has_been_collected = false;
+static bool shared_has_been_collected = false;
+static bool builtin_exports_has_been_collected = false;
-static void UtilsHasBeenCollected(
+static void SharedHasBeenCollected(
const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
- utils_has_been_collected = true;
+ shared_has_been_collected = true;
+ data.GetParameter()->Reset();
+}
+
+
+static void BuiltinExportsHasBeenCollected(
+ const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
+ builtin_exports_has_been_collected = true;
data.GetParameter()->Reset();
}
if (Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) return;
- utils_has_been_collected = false;
+ shared_has_been_collected = false;
+ builtin_exports_has_been_collected = false;
- v8::Persistent<v8::Object> utils;
+ v8::Persistent<v8::Object> shared;
+ v8::Persistent<v8::Object> builtin_exports;
{
v8::HandleScope scope(isolate);
v8::Handle<v8::Object> natives =
CcTest::global()->Get(v8_str("natives"))->ToObject(isolate);
- utils.Reset(isolate, natives->Get(v8_str("utils"))->ToObject(isolate));
- natives->Delete(v8_str("utils"));
+ shared.Reset(isolate, natives->Get(v8_str("shared"))->ToObject(isolate));
+ natives->Delete(v8_str("shared"));
+ builtin_exports.Reset(
+ isolate, natives->Get(v8_str("builtin_exports"))->ToObject(isolate));
+ natives->Delete(v8_str("builtin_exports"));
}
- utils.SetWeak(&utils, UtilsHasBeenCollected,
- v8::WeakCallbackType::kParameter);
+ shared.SetWeak(&shared, SharedHasBeenCollected,
+ v8::WeakCallbackType::kParameter);
+ builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected,
+ v8::WeakCallbackType::kParameter);
CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks");
- CHECK(utils_has_been_collected);
-}
-
-
-TEST(Regress1878) {
- FLAG_allow_natives_syntax = true;
- CcTest::InitializeVM();
- v8::Isolate* isolate = CcTest::isolate();
- v8::HandleScope scope(isolate);
- v8::Local<v8::Function> constructor =
- v8::Utils::ToLocal(CcTest::i_isolate()->internal_array_function());
- CcTest::global()->Set(v8_str("InternalArray"), constructor);
-
- v8::TryCatch try_catch;
-
- CompileRun(
- "var a = Array();"
- "for (var i = 0; i < 1000; i++) {"
- " var ai = new InternalArray(10000);"
- " if (%HaveSameMap(ai, a)) throw Error();"
- " if (!%HasFastObjectElements(ai)) throw Error();"
- "}"
- "for (var i = 0; i < 1000; i++) {"
- " var ai = new InternalArray(10000);"
- " if (%HaveSameMap(ai, a)) throw Error();"
- " if (!%HasFastObjectElements(ai)) throw Error();"
- "}");
-
- CHECK(!try_catch.HasCaught());
+ CHECK(shared_has_been_collected);
+ CHECK(builtin_exports_has_been_collected);
}
--- /dev/null
+// Copyright 2012 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// See: http://code.google.com/p/v8/issues/detail?id=1878
+
+// Flags: --allow-natives-syntax --expose-natives-as=natives
+
+var a = Array();
+
+for (var i = 0; i < 1000; i++) {
+ var ai = natives.builtin_exports.InternalArray(10000);
+ assertFalse(%HaveSameMap(ai, a));
+ assertTrue(%HasFastObjectElements(ai));
+}
+
+for (var i = 0; i < 1000; i++) {
+ var ai = new natives.builtin_exports.InternalArray(10000);
+ assertFalse(%HaveSameMap(ai, a));
+ assertTrue(%HasFastObjectElements(ai));
+}
'../../src/macros.py',
'../../src/messages.h',
'../../src/runtime.js',
- '../../src/prologue.js',
'../../src/v8natives.js',
'../../src/symbol.js',
'../../src/array.js',