Revert of Reland "Wrap v8natives.js into a function." (patchset #2 id:20001 of https://codereview.chromium.org/1123703002/)

Reason for revert:
[Sheriff] Speculative revert for braking arm64 nosnap:
http://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20arm64%20-%20sim%20-%20nosnap%20-%20debug%20-%202/builds/2314

(reverted already titzer's CL which didn't help)

Original issue's description:
> Reland "Wrap v8natives.js into a function."
>
> Committed: https://crrev.com/72ab42172979b60a1b784ea0c6a495d7ee2bba67
> Cr-Commit-Position: refs/heads/master@{#28193}

TBR=jkummerow@chromium.org,yangguo@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

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

Cr-Commit-Position: refs/heads/master@{#28208}
This commit is contained in:
machenbach 2015-05-04 09:49:53 -07:00 committed by Commit bot
parent 17dca16df3
commit 6afc0dcbfc
34 changed files with 363 additions and 426 deletions

View File

@ -3589,7 +3589,7 @@ MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context,
i::Handle<i::Object> args[] = { obj, key_name }; i::Handle<i::Object> args[] = { obj, key_name };
i::Handle<i::Object> result; i::Handle<i::Object> result;
has_pending_exception = has_pending_exception =
!CallV8HeapFunction(isolate, "$objectGetOwnPropertyDescriptor", !CallV8HeapFunction(isolate, "ObjectGetOwnPropertyDescriptor",
isolate->factory()->undefined_value(), isolate->factory()->undefined_value(),
arraysize(args), args).ToHandle(&result); arraysize(args), args).ToHandle(&result);
RETURN_ON_FAILED_EXECUTION(Value); RETURN_ON_FAILED_EXECUTION(Value);

View File

@ -125,16 +125,16 @@ function ArrayKeys() {
%FunctionSetPrototype(ArrayIterator, new GlobalObject()); %FunctionSetPrototype(ArrayIterator, new GlobalObject());
%FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator'); %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
$installFunctions(ArrayIterator.prototype, DONT_ENUM, [ InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
'next', ArrayIteratorNext 'next', ArrayIteratorNext
]); ]);
$setFunctionName(ArrayIteratorIterator, symbolIterator); SetFunctionName(ArrayIteratorIterator, symbolIterator);
%AddNamedProperty(ArrayIterator.prototype, symbolIterator, %AddNamedProperty(ArrayIterator.prototype, symbolIterator,
ArrayIteratorIterator, DONT_ENUM); ArrayIteratorIterator, DONT_ENUM);
%AddNamedProperty(ArrayIterator.prototype, symbolToStringTag, %AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
"Array Iterator", READ_ONLY | DONT_ENUM); "Array Iterator", READ_ONLY | DONT_ENUM);
$installFunctions(GlobalArray.prototype, DONT_ENUM, [ InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
// No 'values' since it breaks webcompat: http://crbug.com/409858 // No 'values' since it breaks webcompat: http://crbug.com/409858
'entries', ArrayEntries, 'entries', ArrayEntries,
'keys', ArrayKeys 'keys', ArrayKeys

View File

@ -372,7 +372,7 @@ function ArrayToString() {
func = array.join; func = array.join;
} }
if (!IS_SPEC_FUNCTION(func)) { if (!IS_SPEC_FUNCTION(func)) {
return %_CallFunction(array, $objectToString); return %_CallFunction(array, ObjectToString);
} }
return %_CallFunction(array, func); return %_CallFunction(array, func);
} }
@ -447,7 +447,7 @@ function ArrayPop() {
n--; n--;
var value = array[n]; var value = array[n];
$delete(array, ToName(n), true); Delete(array, ToName(n), true);
array.length = n; array.length = n;
return value; return value;
} }
@ -620,7 +620,7 @@ function ArrayShift() {
return; return;
} }
if ($objectIsSealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed); if (ObjectIsSealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed);
if (%IsObserved(array)) if (%IsObserved(array))
return ObservedArrayShift.call(array, len); return ObservedArrayShift.call(array, len);
@ -671,7 +671,7 @@ function ArrayUnshift(arg1) { // length == 1
var num_arguments = %_ArgumentsLength(); var num_arguments = %_ArgumentsLength();
if (len > 0 && UseSparseVariant(array, len, IS_ARRAY(array), len) && if (len > 0 && UseSparseVariant(array, len, IS_ARRAY(array), len) &&
!$objectIsSealed(array)) { !ObjectIsSealed(array)) {
SparseMove(array, 0, 0, len, num_arguments); SparseMove(array, 0, 0, len, num_arguments);
} else { } else {
SimpleMove(array, 0, 0, len, num_arguments); SimpleMove(array, 0, 0, len, num_arguments);
@ -817,9 +817,9 @@ function ArraySplice(start, delete_count) {
deleted_elements.length = del_count; deleted_elements.length = del_count;
var num_elements_to_add = num_arguments > 2 ? num_arguments - 2 : 0; var num_elements_to_add = num_arguments > 2 ? num_arguments - 2 : 0;
if (del_count != num_elements_to_add && $objectIsSealed(array)) { if (del_count != num_elements_to_add && ObjectIsSealed(array)) {
throw MakeTypeError(kArrayFunctionsOnSealed); throw MakeTypeError(kArrayFunctionsOnSealed);
} else if (del_count > 0 && $objectIsFrozen(array)) { } else if (del_count > 0 && ObjectIsFrozen(array)) {
throw MakeTypeError(kArrayFunctionsOnFrozen); throw MakeTypeError(kArrayFunctionsOnFrozen);
} }
@ -1523,7 +1523,7 @@ var unscopables = {
DONT_ENUM | READ_ONLY); DONT_ENUM | READ_ONLY);
// Set up non-enumerable functions on the Array object. // Set up non-enumerable functions on the Array object.
$installFunctions(GlobalArray, DONT_ENUM, [ InstallFunctions(GlobalArray, DONT_ENUM, [
"isArray", ArrayIsArray "isArray", ArrayIsArray
]); ]);
@ -1544,7 +1544,7 @@ var getFunction = function(name, jsBuiltin, len) {
// set their names. // set their names.
// Manipulate the length of some of the functions to meet // Manipulate the length of some of the functions to meet
// expectations set by ECMA-262 or Mozilla. // expectations set by ECMA-262 or Mozilla.
$installFunctions(GlobalArray.prototype, DONT_ENUM, [ InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"toString", getFunction("toString", ArrayToString), "toString", getFunction("toString", ArrayToString),
"toLocaleString", getFunction("toLocaleString", ArrayToLocaleString), "toLocaleString", getFunction("toLocaleString", ArrayToLocaleString),
"join", getFunction("join", ArrayJoin), "join", getFunction("join", ArrayJoin),
@ -1573,7 +1573,7 @@ $installFunctions(GlobalArray.prototype, DONT_ENUM, [
// The internal Array prototype doesn't need to be fancy, since it's never // The internal Array prototype doesn't need to be fancy, since it's never
// exposed to user code. // exposed to user code.
// Adding only the functions that are actually used. // Adding only the functions that are actually used.
$setUpLockedPrototype(InternalArray, GlobalArray(), [ SetUpLockedPrototype(InternalArray, GlobalArray(), [
"concat", getFunction("concat", ArrayConcatJS), "concat", getFunction("concat", ArrayConcatJS),
"indexOf", getFunction("indexOf", ArrayIndexOf), "indexOf", getFunction("indexOf", ArrayIndexOf),
"join", getFunction("join", ArrayJoin), "join", getFunction("join", ArrayJoin),
@ -1583,7 +1583,7 @@ $setUpLockedPrototype(InternalArray, GlobalArray(), [
"splice", getFunction("splice", ArraySplice) "splice", getFunction("splice", ArraySplice)
]); ]);
$setUpLockedPrototype(InternalPackedArray, GlobalArray(), [ SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [
"join", getFunction("join", ArrayJoin), "join", getFunction("join", ArrayJoin),
"pop", getFunction("pop", ArrayPop), "pop", getFunction("pop", ArrayPop),
"push", getFunction("push", ArrayPush), "push", getFunction("push", ArrayPush),

View File

@ -83,13 +83,13 @@ function ArrayBufferIsViewJS(obj) {
%AddNamedProperty(GlobalArrayBuffer.prototype, %AddNamedProperty(GlobalArrayBuffer.prototype,
symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY); symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY);
$installGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen); InstallGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
$installFunctions(GlobalArrayBuffer, DONT_ENUM, [ InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
"isView", ArrayBufferIsViewJS "isView", ArrayBufferIsViewJS
]); ]);
$installFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [ InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
"slice", ArrayBufferSlice "slice", ArrayBufferSlice
]); ]);

View File

@ -1573,9 +1573,9 @@ void Genesis::InstallNativeFunctions() {
INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun); INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun);
INSTALL_NATIVE(JSFunction, "ToLength", to_length_fun); INSTALL_NATIVE(JSFunction, "ToLength", to_length_fun);
INSTALL_NATIVE(JSFunction, "$globalEval", global_eval_fun); INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun);
INSTALL_NATIVE(JSFunction, "$getStackTraceLine", get_stack_trace_line_fun); INSTALL_NATIVE(JSFunction, "$getStackTraceLine", get_stack_trace_line_fun);
INSTALL_NATIVE(JSFunction, "$toCompletePropertyDescriptor", INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor",
to_complete_property_descriptor); to_complete_property_descriptor);
INSTALL_NATIVE(Symbol, "$promiseStatus", promise_status); INSTALL_NATIVE(Symbol, "$promiseStatus", promise_status);

View File

@ -76,17 +76,17 @@ function SetValues() {
%SetCode(SetIterator, SetIteratorConstructor); %SetCode(SetIterator, SetIteratorConstructor);
%FunctionSetPrototype(SetIterator, new GlobalObject()); %FunctionSetPrototype(SetIterator, new GlobalObject());
%FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); %FunctionSetInstanceClassName(SetIterator, 'Set Iterator');
$installFunctions(SetIterator.prototype, DONT_ENUM, [ InstallFunctions(SetIterator.prototype, DONT_ENUM, [
'next', SetIteratorNextJS 'next', SetIteratorNextJS
]); ]);
$setFunctionName(SetIteratorSymbolIterator, symbolIterator); SetFunctionName(SetIteratorSymbolIterator, symbolIterator);
%AddNamedProperty(SetIterator.prototype, symbolIterator, %AddNamedProperty(SetIterator.prototype, symbolIterator,
SetIteratorSymbolIterator, DONT_ENUM); SetIteratorSymbolIterator, DONT_ENUM);
%AddNamedProperty(SetIterator.prototype, symbolToStringTag, %AddNamedProperty(SetIterator.prototype, symbolToStringTag,
"Set Iterator", READ_ONLY | DONT_ENUM); "Set Iterator", READ_ONLY | DONT_ENUM);
$installFunctions(GlobalSet.prototype, DONT_ENUM, [ InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
'entries', SetEntries, 'entries', SetEntries,
'keys', SetValues, 'keys', SetValues,
'values', SetValues 'values', SetValues
@ -166,18 +166,18 @@ function MapValues() {
%SetCode(MapIterator, MapIteratorConstructor); %SetCode(MapIterator, MapIteratorConstructor);
%FunctionSetPrototype(MapIterator, new GlobalObject()); %FunctionSetPrototype(MapIterator, new GlobalObject());
%FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); %FunctionSetInstanceClassName(MapIterator, 'Map Iterator');
$installFunctions(MapIterator.prototype, DONT_ENUM, [ InstallFunctions(MapIterator.prototype, DONT_ENUM, [
'next', MapIteratorNextJS 'next', MapIteratorNextJS
]); ]);
$setFunctionName(MapIteratorSymbolIterator, symbolIterator); SetFunctionName(MapIteratorSymbolIterator, symbolIterator);
%AddNamedProperty(MapIterator.prototype, symbolIterator, %AddNamedProperty(MapIterator.prototype, symbolIterator,
MapIteratorSymbolIterator, DONT_ENUM); MapIteratorSymbolIterator, DONT_ENUM);
%AddNamedProperty(MapIterator.prototype, symbolToStringTag, %AddNamedProperty(MapIterator.prototype, symbolToStringTag,
"Map Iterator", READ_ONLY | DONT_ENUM); "Map Iterator", READ_ONLY | DONT_ENUM);
$installFunctions(GlobalMap.prototype, DONT_ENUM, [ InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
'entries', MapEntries, 'entries', MapEntries,
'keys', MapKeys, 'keys', MapKeys,
'values', MapValues 'values', MapValues

View File

@ -22,7 +22,7 @@ function HashToEntry(table, hash, numBuckets) {
function SetFindEntry(table, numBuckets, key, hash) { function SetFindEntry(table, numBuckets, key, hash) {
var keyIsNaN = $numberIsNaN(key); var keyIsNaN = NumberIsNaN(key);
for (var entry = HashToEntry(table, hash, numBuckets); for (var entry = HashToEntry(table, hash, numBuckets);
entry !== NOT_FOUND; entry !== NOT_FOUND;
entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) { entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) {
@ -30,7 +30,7 @@ function SetFindEntry(table, numBuckets, key, hash) {
if (key === candidate) { if (key === candidate) {
return entry; return entry;
} }
if (keyIsNaN && $numberIsNaN(candidate)) { if (keyIsNaN && NumberIsNaN(candidate)) {
return entry; return entry;
} }
} }
@ -40,7 +40,7 @@ function SetFindEntry(table, numBuckets, key, hash) {
function MapFindEntry(table, numBuckets, key, hash) { function MapFindEntry(table, numBuckets, key, hash) {
var keyIsNaN = $numberIsNaN(key); var keyIsNaN = NumberIsNaN(key);
for (var entry = HashToEntry(table, hash, numBuckets); for (var entry = HashToEntry(table, hash, numBuckets);
entry !== NOT_FOUND; entry !== NOT_FOUND;
entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) { entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) {
@ -48,7 +48,7 @@ function MapFindEntry(table, numBuckets, key, hash) {
if (key === candidate) { if (key === candidate) {
return entry; return entry;
} }
if (keyIsNaN && $numberIsNaN(candidate)) { if (keyIsNaN && NumberIsNaN(candidate)) {
return entry; return entry;
} }
} }
@ -239,8 +239,8 @@ function SetForEach(f, receiver) {
%FunctionSetLength(SetForEach, 1); %FunctionSetLength(SetForEach, 1);
// Set up the non-enumerable functions on the Set prototype object. // Set up the non-enumerable functions on the Set prototype object.
$installGetter(GlobalSet.prototype, "size", SetGetSize); InstallGetter(GlobalSet.prototype, "size", SetGetSize);
$installFunctions(GlobalSet.prototype, DONT_ENUM, [ InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
"add", SetAdd, "add", SetAdd,
"has", SetHas, "has", SetHas,
"delete", SetDelete, "delete", SetDelete,
@ -427,8 +427,8 @@ function MapForEach(f, receiver) {
%FunctionSetLength(MapForEach, 1); %FunctionSetLength(MapForEach, 1);
// Set up the non-enumerable functions on the Map prototype object. // Set up the non-enumerable functions on the Map prototype object.
$installGetter(GlobalMap.prototype, "size", MapGetSize); InstallGetter(GlobalMap.prototype, "size", MapGetSize);
$installFunctions(GlobalMap.prototype, DONT_ENUM, [ InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
"get", MapGet, "get", MapGet,
"set", MapSet, "set", MapSet,
"has", MapHas, "has", MapHas,

View File

@ -760,7 +760,7 @@ function CreateDate(time) {
%FunctionSetPrototype(GlobalDate, new GlobalDate(NAN)); %FunctionSetPrototype(GlobalDate, new GlobalDate(NAN));
// Set up non-enumerable properties of the Date object itself. // Set up non-enumerable properties of the Date object itself.
$installFunctions(GlobalDate, DONT_ENUM, [ InstallFunctions(GlobalDate, DONT_ENUM, [
"UTC", DateUTC, "UTC", DateUTC,
"parse", DateParse, "parse", DateParse,
"now", DateNow "now", DateNow
@ -771,7 +771,7 @@ $installFunctions(GlobalDate, DONT_ENUM, [
// Set up non-enumerable functions of the Date prototype object and // Set up non-enumerable functions of the Date prototype object and
// set their names. // set their names.
$installFunctions(GlobalDate.prototype, DONT_ENUM, [ InstallFunctions(GlobalDate.prototype, DONT_ENUM, [
"toString", DateToString, "toString", DateToString,
"toDateString", DateToDateString, "toDateString", DateToDateString,
"toTimeString", DateToTimeString, "toTimeString", DateToTimeString,

View File

@ -72,7 +72,7 @@ function GeneratorObjectIterator() {
function GeneratorFunctionConstructor(arg1) { // length == 1 function GeneratorFunctionConstructor(arg1) { // length == 1
var source = $newFunctionString(arguments, 'function*'); var source = NewFunctionString(arguments, 'function*');
var global_proxy = %GlobalProxy(global); var global_proxy = %GlobalProxy(global);
// Compile the string in the constructor and not a helper so that errors // Compile the string in the constructor and not a helper so that errors
// appear to come from here. // appear to come from here.
@ -90,12 +90,12 @@ function GeneratorFunctionConstructor(arg1) { // length == 1
// Set up non-enumerable functions on the generator prototype object. // Set up non-enumerable functions on the generator prototype object.
var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype;
$installFunctions(GeneratorObjectPrototype, InstallFunctions(GeneratorObjectPrototype,
DONT_ENUM, DONT_ENUM,
["next", GeneratorObjectNext, ["next", GeneratorObjectNext,
"throw", GeneratorObjectThrow]); "throw", GeneratorObjectThrow]);
$setFunctionName(GeneratorObjectIterator, symbolIterator); SetFunctionName(GeneratorObjectIterator, symbolIterator);
%AddNamedProperty(GeneratorObjectPrototype, symbolIterator, %AddNamedProperty(GeneratorObjectPrototype, symbolIterator,
GeneratorObjectIterator, DONT_ENUM | DONT_DELETE | READ_ONLY); GeneratorObjectIterator, DONT_ENUM | DONT_DELETE | READ_ONLY);
%AddNamedProperty(GeneratorObjectPrototype, "constructor", %AddNamedProperty(GeneratorObjectPrototype, "constructor",

View File

@ -52,7 +52,7 @@ function ArrayIncludes(searchElement, fromIndex) {
%FunctionSetLength(ArrayIncludes, 1); %FunctionSetLength(ArrayIncludes, 1);
// Set up the non-enumerable functions on the Array prototype object. // Set up the non-enumerable functions on the Array prototype object.
$installFunctions(GlobalArray.prototype, DONT_ENUM, [ InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"includes", ArrayIncludes "includes", ArrayIncludes
]); ]);

View File

@ -173,7 +173,7 @@ function ArrayFill(value /* [, start [, end ] ] */) { // length == 1
if (end > length) end = length; if (end > length) end = length;
} }
if ((end - i) > 0 && $objectIsFrozen(array)) { if ((end - i) > 0 && ObjectIsFrozen(array)) {
throw MakeTypeError(kArrayFunctionsOnFrozen); throw MakeTypeError(kArrayFunctionsOnFrozen);
} }
@ -197,7 +197,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
} }
} }
var iterable = $getMethod(items, symbolIterator); var iterable = GetMethod(items, symbolIterator);
var k; var k;
var result; var result;
var mappedValue; var mappedValue;
@ -206,7 +206,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
if (!IS_UNDEFINED(iterable)) { if (!IS_UNDEFINED(iterable)) {
result = %IsConstructor(this) ? new this() : []; result = %IsConstructor(this) ? new this() : [];
var iterator = $getIterator(items, iterable); var iterator = GetIterator(items, iterable);
k = 0; k = 0;
while (true) { while (true) {
@ -263,7 +263,7 @@ function ArrayOf() {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
$installConstants(GlobalSymbol, [ InstallConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping // TODO(dslomov, caitp): Move to symbol.js when shipping
"isConcatSpreadable", symbolIsConcatSpreadable "isConcatSpreadable", symbolIsConcatSpreadable
]); ]);
@ -272,13 +272,13 @@ $installConstants(GlobalSymbol, [
%FunctionSetLength(ArrayFrom, 1); %FunctionSetLength(ArrayFrom, 1);
// Set up non-enumerable functions on the Array object. // Set up non-enumerable functions on the Array object.
$installFunctions(GlobalArray, DONT_ENUM, [ InstallFunctions(GlobalArray, DONT_ENUM, [
"from", ArrayFrom, "from", ArrayFrom,
"of", ArrayOf "of", ArrayOf
]); ]);
// Set up the non-enumerable functions on the Array prototype object. // Set up the non-enumerable functions on the Array prototype object.
$installFunctions(GlobalArray.prototype, DONT_ENUM, [ InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"copyWithin", ArrayCopyWithin, "copyWithin", ArrayCopyWithin,
"find", ArrayFind, "find", ArrayFind,
"findIndex", ArrayFindIndex, "findIndex", ArrayFindIndex,

View File

@ -10,7 +10,7 @@
var GlobalReflect = global.Reflect; var GlobalReflect = global.Reflect;
$installFunctions(GlobalReflect, DONT_ENUM, [ InstallFunctions(GlobalReflect, DONT_ENUM, [
"apply", $reflectApply, "apply", $reflectApply,
"construct", $reflectConstruct "construct", $reflectConstruct
]); ]);

View File

@ -10,7 +10,7 @@
var GlobalSymbol = global.Symbol; var GlobalSymbol = global.Symbol;
$installConstants(GlobalSymbol, [ InstallConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping // TODO(dslomov, caitp): Move to symbol.js when shipping
"toStringTag", symbolToStringTag "toStringTag", symbolToStringTag
]); ]);

View File

@ -8,6 +8,8 @@
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
macro TYPED_ARRAYS(FUNCTION) macro TYPED_ARRAYS(FUNCTION)
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize. // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
FUNCTION(1, Uint8Array, 1) FUNCTION(1, Uint8Array, 1)
@ -21,13 +23,6 @@ FUNCTION(8, Float64Array, 8)
FUNCTION(9, Uint8ClampedArray, 1) FUNCTION(9, Uint8ClampedArray, 1)
endmacro endmacro
macro DECLARE_GLOBALS(INDEX, NAME, SIZE)
var GlobalNAME = global.NAME;
endmacro
TYPED_ARRAYS(DECLARE_GLOBALS)
// -------------------------------------------------------------------
macro TYPED_ARRAY_HARMONY_ADDITIONS(ARRAY_ID, NAME, ELEMENT_SIZE) macro TYPED_ARRAY_HARMONY_ADDITIONS(ARRAY_ID, NAME, ELEMENT_SIZE)
@ -79,12 +74,12 @@ TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS)
macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
// Set up non-enumerable functions on the object. // Set up non-enumerable functions on the object.
$installFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [ InstallFunctions(global.NAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [
"of", NAMEOf "of", NAMEOf
]); ]);
// Set up non-enumerable functions on the prototype object. // Set up non-enumerable functions on the prototype object.
$installFunctions(GlobalNAME.prototype, DONT_ENUM, [ InstallFunctions(global.NAME.prototype, DONT_ENUM, [
"forEach", NAMEForEach "forEach", NAMEForEach
]); ]);
endmacro endmacro

View File

@ -254,7 +254,7 @@ function addBoundMethod(obj, methodName, implementation, length) {
} }
} }
} }
$setFunctionName(boundMethod, internalName); SetFunctionName(boundMethod, internalName);
%FunctionRemovePrototype(boundMethod); %FunctionRemovePrototype(boundMethod);
%SetNativeFlag(boundMethod); %SetNativeFlag(boundMethod);
this[internalName] = boundMethod; this[internalName] = boundMethod;
@ -262,11 +262,11 @@ function addBoundMethod(obj, methodName, implementation, length) {
return this[internalName]; return this[internalName];
} }
$setFunctionName(getter, methodName); SetFunctionName(getter, methodName);
%FunctionRemovePrototype(getter); %FunctionRemovePrototype(getter);
%SetNativeFlag(getter); %SetNativeFlag(getter);
$objectDefineProperty(obj.prototype, methodName, { ObjectDefineProperty(obj.prototype, methodName, {
get: getter, get: getter,
enumerable: false, enumerable: false,
configurable: true configurable: true
@ -585,14 +585,14 @@ function setOptions(inOptions, extensionMap, keyValues, getOption, outOptions) {
*/ */
function freezeArray(array) { function freezeArray(array) {
array.forEach(function(element, index) { array.forEach(function(element, index) {
$objectDefineProperty(array, index, {value: element, ObjectDefineProperty(array, index, {value: element,
configurable: false, configurable: false,
writable: false, writable: false,
enumerable: true}); enumerable: true});
}); });
$objectDefineProperty(array, 'length', {value: array.length, ObjectDefineProperty(array, 'length', {value: array.length,
writable: false}); writable: false});
return array; return array;
} }
@ -653,8 +653,8 @@ function getAvailableLocalesOf(service) {
* Configurable is false by default. * Configurable is false by default.
*/ */
function defineWEProperty(object, property, value) { function defineWEProperty(object, property, value) {
$objectDefineProperty(object, property, ObjectDefineProperty(object, property,
{value: value, writable: true, enumerable: true}); {value: value, writable: true, enumerable: true});
} }
@ -673,10 +673,11 @@ function addWEPropertyIfDefined(object, property, value) {
* Defines a property and sets writable, enumerable and configurable to true. * Defines a property and sets writable, enumerable and configurable to true.
*/ */
function defineWECProperty(object, property, value) { function defineWECProperty(object, property, value) {
$objectDefineProperty(object, property, {value: value, ObjectDefineProperty(object, property,
writable: true, {value: value,
enumerable: true, writable: true,
configurable: true}); enumerable: true,
configurable: true});
} }
@ -916,7 +917,7 @@ function initializeCollator(collator, locales, options) {
// problems. If malicious user decides to redefine Object.prototype.locale // problems. If malicious user decides to redefine Object.prototype.locale
// we can't just use plain x.locale = 'us' or in C++ Set("locale", "us"). // we can't just use plain x.locale = 'us' or in C++ Set("locale", "us").
// ObjectDefineProperties will either succeed defining or throw an error. // ObjectDefineProperties will either succeed defining or throw an error.
var resolved = $objectDefineProperties({}, { var resolved = ObjectDefineProperties({}, {
caseFirst: {writable: true}, caseFirst: {writable: true},
collation: {value: internalOptions.collation, writable: true}, collation: {value: internalOptions.collation, writable: true},
ignorePunctuation: {writable: true}, ignorePunctuation: {writable: true},
@ -934,7 +935,7 @@ function initializeCollator(collator, locales, options) {
// Writable, configurable and enumerable are set to false by default. // Writable, configurable and enumerable are set to false by default.
%MarkAsInitializedIntlObjectOfType(collator, 'collator', internalCollator); %MarkAsInitializedIntlObjectOfType(collator, 'collator', internalCollator);
$objectDefineProperty(collator, 'resolved', {value: resolved}); ObjectDefineProperty(collator, 'resolved', {value: resolved});
return collator; return collator;
} }
@ -989,7 +990,7 @@ function initializeCollator(collator, locales, options) {
}, },
DONT_ENUM DONT_ENUM
); );
$setFunctionName(Intl.Collator.prototype.resolvedOptions, 'resolvedOptions'); SetFunctionName(Intl.Collator.prototype.resolvedOptions, 'resolvedOptions');
%FunctionRemovePrototype(Intl.Collator.prototype.resolvedOptions); %FunctionRemovePrototype(Intl.Collator.prototype.resolvedOptions);
%SetNativeFlag(Intl.Collator.prototype.resolvedOptions); %SetNativeFlag(Intl.Collator.prototype.resolvedOptions);
@ -1009,7 +1010,7 @@ $setFunctionName(Intl.Collator.prototype.resolvedOptions, 'resolvedOptions');
}, },
DONT_ENUM DONT_ENUM
); );
$setFunctionName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf'); SetFunctionName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf');
%FunctionRemovePrototype(Intl.Collator.supportedLocalesOf); %FunctionRemovePrototype(Intl.Collator.supportedLocalesOf);
%SetNativeFlag(Intl.Collator.supportedLocalesOf); %SetNativeFlag(Intl.Collator.supportedLocalesOf);
@ -1130,7 +1131,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
getOption, internalOptions); getOption, internalOptions);
var requestedLocale = locale.locale + extension; var requestedLocale = locale.locale + extension;
var resolved = $objectDefineProperties({}, { var resolved = ObjectDefineProperties({}, {
currency: {writable: true}, currency: {writable: true},
currencyDisplay: {writable: true}, currencyDisplay: {writable: true},
locale: {writable: true}, locale: {writable: true},
@ -1155,12 +1156,12 @@ function initializeNumberFormat(numberFormat, locales, options) {
// We can't get information about number or currency style from ICU, so we // We can't get information about number or currency style from ICU, so we
// assume user request was fulfilled. // assume user request was fulfilled.
if (internalOptions.style === 'currency') { if (internalOptions.style === 'currency') {
$objectDefineProperty(resolved, 'currencyDisplay', {value: currencyDisplay, ObjectDefineProperty(resolved, 'currencyDisplay', {value: currencyDisplay,
writable: true}); writable: true});
} }
%MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter); %MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter);
$objectDefineProperty(numberFormat, 'resolved', {value: resolved}); ObjectDefineProperty(numberFormat, 'resolved', {value: resolved});
return numberFormat; return numberFormat;
} }
@ -1233,7 +1234,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
}, },
DONT_ENUM DONT_ENUM
); );
$setFunctionName(Intl.NumberFormat.prototype.resolvedOptions, SetFunctionName(Intl.NumberFormat.prototype.resolvedOptions,
'resolvedOptions'); 'resolvedOptions');
%FunctionRemovePrototype(Intl.NumberFormat.prototype.resolvedOptions); %FunctionRemovePrototype(Intl.NumberFormat.prototype.resolvedOptions);
%SetNativeFlag(Intl.NumberFormat.prototype.resolvedOptions); %SetNativeFlag(Intl.NumberFormat.prototype.resolvedOptions);
@ -1254,7 +1255,7 @@ $setFunctionName(Intl.NumberFormat.prototype.resolvedOptions,
}, },
DONT_ENUM DONT_ENUM
); );
$setFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf'); SetFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf');
%FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf); %FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf);
%SetNativeFlag(Intl.NumberFormat.supportedLocalesOf); %SetNativeFlag(Intl.NumberFormat.supportedLocalesOf);
@ -1450,33 +1451,33 @@ function toDateTimeOptions(options, required, defaults) {
} }
if (needsDefault && (defaults === 'date' || defaults === 'all')) { if (needsDefault && (defaults === 'date' || defaults === 'all')) {
$objectDefineProperty(options, 'year', {value: 'numeric', ObjectDefineProperty(options, 'year', {value: 'numeric',
writable: true,
enumerable: true,
configurable: true});
$objectDefineProperty(options, 'month', {value: 'numeric',
writable: true,
enumerable: true,
configurable: true});
$objectDefineProperty(options, 'day', {value: 'numeric',
writable: true, writable: true,
enumerable: true, enumerable: true,
configurable: true}); configurable: true});
} ObjectDefineProperty(options, 'month', {value: 'numeric',
if (needsDefault && (defaults === 'time' || defaults === 'all')) {
$objectDefineProperty(options, 'hour', {value: 'numeric',
writable: true, writable: true,
enumerable: true, enumerable: true,
configurable: true}); configurable: true});
$objectDefineProperty(options, 'minute', {value: 'numeric', ObjectDefineProperty(options, 'day', {value: 'numeric',
writable: true, writable: true,
enumerable: true, enumerable: true,
configurable: true}); configurable: true});
$objectDefineProperty(options, 'second', {value: 'numeric', }
writable: true,
enumerable: true, if (needsDefault && (defaults === 'time' || defaults === 'all')) {
configurable: true}); ObjectDefineProperty(options, 'hour', {value: 'numeric',
writable: true,
enumerable: true,
configurable: true});
ObjectDefineProperty(options, 'minute', {value: 'numeric',
writable: true,
enumerable: true,
configurable: true});
ObjectDefineProperty(options, 'second', {value: 'numeric',
writable: true,
enumerable: true,
configurable: true});
} }
return options; return options;
@ -1524,7 +1525,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
getOption, internalOptions); getOption, internalOptions);
var requestedLocale = locale.locale + extension; var requestedLocale = locale.locale + extension;
var resolved = $objectDefineProperties({}, { var resolved = ObjectDefineProperties({}, {
calendar: {writable: true}, calendar: {writable: true},
day: {writable: true}, day: {writable: true},
era: {writable: true}, era: {writable: true},
@ -1552,7 +1553,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
} }
%MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter); %MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter);
$objectDefineProperty(dateFormat, 'resolved', {value: resolved}); ObjectDefineProperty(dateFormat, 'resolved', {value: resolved});
return dateFormat; return dateFormat;
} }
@ -1625,7 +1626,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
}, },
DONT_ENUM DONT_ENUM
); );
$setFunctionName(Intl.DateTimeFormat.prototype.resolvedOptions, SetFunctionName(Intl.DateTimeFormat.prototype.resolvedOptions,
'resolvedOptions'); 'resolvedOptions');
%FunctionRemovePrototype(Intl.DateTimeFormat.prototype.resolvedOptions); %FunctionRemovePrototype(Intl.DateTimeFormat.prototype.resolvedOptions);
%SetNativeFlag(Intl.DateTimeFormat.prototype.resolvedOptions); %SetNativeFlag(Intl.DateTimeFormat.prototype.resolvedOptions);
@ -1646,7 +1647,7 @@ $setFunctionName(Intl.DateTimeFormat.prototype.resolvedOptions,
}, },
DONT_ENUM DONT_ENUM
); );
$setFunctionName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf'); SetFunctionName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf');
%FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf); %FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf);
%SetNativeFlag(Intl.DateTimeFormat.supportedLocalesOf); %SetNativeFlag(Intl.DateTimeFormat.supportedLocalesOf);
@ -1741,7 +1742,7 @@ function initializeBreakIterator(iterator, locales, options) {
'type', 'string', ['character', 'word', 'sentence', 'line'], 'word')); 'type', 'string', ['character', 'word', 'sentence', 'line'], 'word'));
var locale = resolveLocale('breakiterator', locales, options); var locale = resolveLocale('breakiterator', locales, options);
var resolved = $objectDefineProperties({}, { var resolved = ObjectDefineProperties({}, {
requestedLocale: {value: locale.locale, writable: true}, requestedLocale: {value: locale.locale, writable: true},
type: {value: internalOptions.type, writable: true}, type: {value: internalOptions.type, writable: true},
locale: {writable: true} locale: {writable: true}
@ -1753,7 +1754,7 @@ function initializeBreakIterator(iterator, locales, options) {
%MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator', %MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator',
internalIterator); internalIterator);
$objectDefineProperty(iterator, 'resolved', {value: resolved}); ObjectDefineProperty(iterator, 'resolved', {value: resolved});
return iterator; return iterator;
} }
@ -1804,7 +1805,7 @@ function initializeBreakIterator(iterator, locales, options) {
}, },
DONT_ENUM DONT_ENUM
); );
$setFunctionName(Intl.v8BreakIterator.prototype.resolvedOptions, SetFunctionName(Intl.v8BreakIterator.prototype.resolvedOptions,
'resolvedOptions'); 'resolvedOptions');
%FunctionRemovePrototype(Intl.v8BreakIterator.prototype.resolvedOptions); %FunctionRemovePrototype(Intl.v8BreakIterator.prototype.resolvedOptions);
%SetNativeFlag(Intl.v8BreakIterator.prototype.resolvedOptions); %SetNativeFlag(Intl.v8BreakIterator.prototype.resolvedOptions);
@ -1826,7 +1827,7 @@ $setFunctionName(Intl.v8BreakIterator.prototype.resolvedOptions,
}, },
DONT_ENUM DONT_ENUM
); );
$setFunctionName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf'); SetFunctionName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf');
%FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf); %FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf);
%SetNativeFlag(Intl.v8BreakIterator.supportedLocalesOf); %SetNativeFlag(Intl.v8BreakIterator.supportedLocalesOf);
@ -1920,7 +1921,7 @@ function cachedOrNewService(service, locales, options, defaults) {
* Compares this and that, and returns less than 0, 0 or greater than 0 value. * Compares this and that, and returns less than 0, 0 or greater than 0 value.
* Overrides the built-in method. * Overrides the built-in method.
*/ */
$overrideFunction(GlobalString.prototype, 'localeCompare', function(that) { OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
} }
@ -1944,7 +1945,7 @@ $overrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
* If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw
* a RangeError Exception. * a RangeError Exception.
*/ */
$overrideFunction(GlobalString.prototype, 'normalize', function(that) { OverrideFunction(GlobalString.prototype, 'normalize', function(that) {
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
} }
@ -1967,7 +1968,7 @@ $overrideFunction(GlobalString.prototype, 'normalize', function(that) {
* Formats a Number object (this) using locale and options values. * Formats a Number object (this) using locale and options values.
* If locale or options are omitted, defaults are used. * If locale or options are omitted, defaults are used.
*/ */
$overrideFunction(GlobalNumber.prototype, 'toLocaleString', function() { OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() {
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
} }
@ -2010,7 +2011,7 @@ function toLocaleDateTime(date, locales, options, required, defaults, service) {
* If locale or options are omitted, defaults are used - both date and time are * If locale or options are omitted, defaults are used - both date and time are
* present in the output. * present in the output.
*/ */
$overrideFunction(GlobalDate.prototype, 'toLocaleString', function() { OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
} }
@ -2028,7 +2029,7 @@ $overrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
* If locale or options are omitted, defaults are used - only date is present * If locale or options are omitted, defaults are used - only date is present
* in the output. * in the output.
*/ */
$overrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() { OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
} }
@ -2046,7 +2047,7 @@ $overrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
* If locale or options are omitted, defaults are used - only time is present * If locale or options are omitted, defaults are used - only time is present
* in the output. * in the output.
*/ */
$overrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() { OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
} }

View File

@ -25,7 +25,7 @@ function Revive(holder, name, reviver) {
} }
} else { } else {
for (var p in val) { for (var p in val) {
if (%_CallFunction(val, p, $objectHasOwnProperty)) { if (%_CallFunction(val, p, ObjectHasOwnProperty)) {
var newElement = Revive(val, p, reviver); var newElement = Revive(val, p, reviver);
if (IS_UNDEFINED(newElement)) { if (IS_UNDEFINED(newElement)) {
delete val[p]; delete val[p];
@ -91,7 +91,7 @@ function SerializeObject(value, replacer, stack, indent, gap) {
if (IS_ARRAY(replacer)) { if (IS_ARRAY(replacer)) {
var length = replacer.length; var length = replacer.length;
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
if (%_CallFunction(replacer, i, $objectHasOwnProperty)) { if (%_CallFunction(replacer, i, ObjectHasOwnProperty)) {
var p = replacer[i]; var p = replacer[i];
var strP = JSONSerialize(p, value, replacer, stack, indent, gap); var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
if (!IS_UNDEFINED(strP)) { if (!IS_UNDEFINED(strP)) {
@ -104,7 +104,7 @@ function SerializeObject(value, replacer, stack, indent, gap) {
} }
} else { } else {
for (var p in value) { for (var p in value) {
if (%_CallFunction(value, p, $objectHasOwnProperty)) { if (%_CallFunction(value, p, ObjectHasOwnProperty)) {
var strP = JSONSerialize(p, value, replacer, stack, indent, gap); var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
if (!IS_UNDEFINED(strP)) { if (!IS_UNDEFINED(strP)) {
var member = %QuoteJSONString(p) + ":"; var member = %QuoteJSONString(p) + ":";
@ -224,7 +224,7 @@ function JSONStringify(value, replacer, space) {
%AddNamedProperty(GlobalJSON, symbolToStringTag, "JSON", READ_ONLY | DONT_ENUM); %AddNamedProperty(GlobalJSON, symbolToStringTag, "JSON", READ_ONLY | DONT_ENUM);
// Set up non-enumerable properties of the JSON object. // Set up non-enumerable properties of the JSON object.
$installFunctions(GlobalJSON, DONT_ENUM, [ InstallFunctions(GlobalJSON, DONT_ENUM, [
"parse", JSONParse, "parse", JSONParse,
"stringify", JSONStringify "stringify", JSONStringify
]); ]);

View File

@ -152,7 +152,7 @@ macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : NonStringToString
macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : NonNumberToNumber(arg)); macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : NonNumberToNumber(arg));
macro TO_OBJECT_INLINE(arg) = (IS_SPEC_OBJECT(%IS_VAR(arg)) ? arg : ToObject(arg)); macro TO_OBJECT_INLINE(arg) = (IS_SPEC_OBJECT(%IS_VAR(arg)) ? arg : ToObject(arg));
macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null"); macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null");
macro HAS_OWN_PROPERTY(arg, index) = (%_CallFunction(arg, index, $objectHasOwnProperty)); macro HAS_OWN_PROPERTY(obj, index) = (%_CallFunction(obj, index, ObjectHasOwnProperty));
macro SHOULD_CREATE_WRAPPER(functionName, receiver) = (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(functionName)); macro SHOULD_CREATE_WRAPPER(functionName, receiver) = (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(functionName));
macro HAS_INDEX(array, index, is_array) = ((is_array && %_HasFastPackedElements(%IS_VAR(array))) ? (index < array.length) : (index in array)); macro HAS_INDEX(array, index, is_array) = ((is_array && %_HasFastPackedElements(%IS_VAR(array))) ? (index < array.length) : (index in array));

View File

@ -294,7 +294,7 @@ var Math = new MathConstructor();
%AddNamedProperty(Math, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM); %AddNamedProperty(Math, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM);
// Set up math constants. // Set up math constants.
$installConstants(Math, [ InstallConstants(Math, [
// ECMA-262, section 15.8.1.1. // ECMA-262, section 15.8.1.1.
"E", 2.7182818284590452354, "E", 2.7182818284590452354,
// ECMA-262, section 15.8.1.2. // ECMA-262, section 15.8.1.2.
@ -311,7 +311,7 @@ $installConstants(Math, [
// Set up non-enumerable functions of the Math object and // Set up non-enumerable functions of the Math object and
// set their names. // set their names.
$installFunctions(Math, DONT_ENUM, [ InstallFunctions(Math, DONT_ENUM, [
"random", MathRandom, "random", MathRandom,
"abs", MathAbs, "abs", MathAbs,
"acos", MathAcosJS, "acos", MathAcosJS,

View File

@ -238,13 +238,6 @@ function FormatString(format, args) {
} }
function NoSideEffectsObjectToString() {
if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
if (IS_NULL(this)) return "[object Null]";
return "[object " + %_ClassOf(TO_OBJECT_INLINE(this)) + "]";
}
function NoSideEffectToString(obj) { function NoSideEffectToString(obj) {
if (IS_STRING(obj)) return obj; if (IS_STRING(obj)) return obj;
if (IS_NUMBER(obj)) return %_NumberToString(obj); if (IS_NUMBER(obj)) return %_NumberToString(obj);
@ -252,7 +245,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, FunctionToString);
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);
@ -261,7 +254,7 @@ function NoSideEffectToString(obj) {
} }
if (IS_SYMBOL(obj)) return %_CallFunction(obj, $symbolToString); if (IS_SYMBOL(obj)) return %_CallFunction(obj, $symbolToString);
if (IS_OBJECT(obj) if (IS_OBJECT(obj)
&& %GetDataProperty(obj, "toString") === $objectToString) { && %GetDataProperty(obj, "toString") === ObjectToString) {
var constructor = %GetDataProperty(obj, "constructor"); var constructor = %GetDataProperty(obj, "constructor");
if (typeof constructor == "function") { if (typeof constructor == "function") {
var constructorName = constructor.name; var constructorName = constructor.name;
@ -313,7 +306,7 @@ function ToStringCheckErrorObject(obj) {
function ToDetailString(obj) { function ToDetailString(obj) {
if (obj != null && IS_OBJECT(obj) && obj.toString === $objectToString) { if (obj != null && IS_OBJECT(obj) && obj.toString === ObjectToString) {
var constructor = obj.constructor; var constructor = obj.constructor;
if (typeof constructor == "function") { if (typeof constructor == "function") {
var constructorName = constructor.name; var constructorName = constructor.name;
@ -591,7 +584,7 @@ function ScriptNameOrSourceURL() {
} }
$setUpLockedPrototype(Script, [ SetUpLockedPrototype(Script, [
"source", "source",
"name", "name",
"source_url", "source_url",
@ -655,7 +648,7 @@ function SourceLocationSourceText() {
} }
$setUpLockedPrototype(SourceLocation, SetUpLockedPrototype(SourceLocation,
["script", "position", "line", "column", "start", "end"], ["script", "position", "line", "column", "start", "end"],
["sourceText", SourceLocationSourceText] ["sourceText", SourceLocationSourceText]
); );
@ -699,7 +692,7 @@ function SourceSliceSourceText() {
$stringSubstring); $stringSubstring);
} }
$setUpLockedPrototype(SourceSlice, SetUpLockedPrototype(SourceSlice,
["script", "from_line", "to_line", "from_position", "to_position"], ["script", "from_line", "to_line", "from_position", "to_position"],
["sourceText", SourceSliceSourceText] ["sourceText", SourceSliceSourceText]
); );
@ -794,8 +787,8 @@ function CallSiteGetMethodName() {
var fun = GET_PRIVATE(this, CallSiteFunctionKey); var fun = GET_PRIVATE(this, CallSiteFunctionKey);
var ownName = fun.name; var ownName = fun.name;
if (ownName && receiver && if (ownName && receiver &&
(%_CallFunction(receiver, ownName, $objectLookupGetter) === fun || (%_CallFunction(receiver, ownName, ObjectLookupGetter) === fun ||
%_CallFunction(receiver, ownName, $objectLookupSetter) === fun || %_CallFunction(receiver, ownName, ObjectLookupSetter) === fun ||
(IS_OBJECT(receiver) && %GetDataProperty(receiver, ownName) === fun))) { (IS_OBJECT(receiver) && %GetDataProperty(receiver, ownName) === fun))) {
// To handle DontEnum properties we guess that the method has // To handle DontEnum properties we guess that the method has
// the same name as the function. // the same name as the function.
@ -803,8 +796,8 @@ function CallSiteGetMethodName() {
} }
var name = null; var name = null;
for (var prop in receiver) { for (var prop in receiver) {
if (%_CallFunction(receiver, prop, $objectLookupGetter) === fun || if (%_CallFunction(receiver, prop, ObjectLookupGetter) === fun ||
%_CallFunction(receiver, prop, $objectLookupSetter) === fun || %_CallFunction(receiver, prop, ObjectLookupSetter) === fun ||
(IS_OBJECT(receiver) && %GetDataProperty(receiver, prop) === fun)) { (IS_OBJECT(receiver) && %GetDataProperty(receiver, prop) === fun)) {
// If we find more than one match bail out to avoid confusion. // If we find more than one match bail out to avoid confusion.
if (name) { if (name) {
@ -921,7 +914,7 @@ function CallSiteToString() {
return line; return line;
} }
$setUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [ SetUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
"getThis", CallSiteGetThis, "getThis", CallSiteGetThis,
"getTypeName", CallSiteGetTypeName, "getTypeName", CallSiteGetTypeName,
"isToplevel", CallSiteIsToplevel, "isToplevel", CallSiteIsToplevel,
@ -1110,9 +1103,9 @@ var StackTraceSetter = function(v) {
// when constructing the initial Error prototytpes. // when constructing the initial Error prototytpes.
var captureStackTrace = function captureStackTrace(obj, cons_opt) { var captureStackTrace = function captureStackTrace(obj, cons_opt) {
// Define accessors first, as this may fail and throw. // Define accessors first, as this may fail and throw.
$objectDefineProperty(obj, 'stack', { get: StackTraceGetter, ObjectDefineProperty(obj, 'stack', { get: StackTraceGetter,
set: StackTraceSetter, set: StackTraceSetter,
configurable: true }); configurable: true });
%CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace); %CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace);
} }
@ -1236,8 +1229,7 @@ function ErrorToString() {
} }
} }
$installFunctions(GlobalError.prototype, DONT_ENUM, InstallFunctions(GlobalError.prototype, DONT_ENUM, ['toString', ErrorToString]);
['toString', ErrorToString]);
$errorToString = ErrorToString; $errorToString = ErrorToString;
$formatMessage = FormatMessage; $formatMessage = FormatMessage;

View File

@ -1008,7 +1008,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 builtins.FunctionSourceString(this.value_);
} }
}; };

View File

@ -377,7 +377,7 @@ function ObjectObserve(object, callback, acceptList) {
throw MakeTypeError("observe_global_proxy", ["observe"]); throw MakeTypeError("observe_global_proxy", ["observe"]);
if (!IS_SPEC_FUNCTION(callback)) if (!IS_SPEC_FUNCTION(callback))
throw MakeTypeError("observe_non_function", ["observe"]); throw MakeTypeError("observe_non_function", ["observe"]);
if ($objectIsFrozen(callback)) if (ObjectIsFrozen(callback))
throw MakeTypeError("observe_callback_frozen"); throw MakeTypeError("observe_callback_frozen");
var objectObserveFn = %GetObjectContextObjectObserve(object); var objectObserveFn = %GetObjectContextObjectObserve(object);
@ -470,7 +470,7 @@ function ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, type) {
%DefineDataPropertyUnchecked( %DefineDataPropertyUnchecked(
newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE); newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE);
} }
$objectFreeze(newRecord); ObjectFreezeJS(newRecord);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, newRecord); ObjectInfoEnqueueInternalChangeRecord(objectInfo, newRecord);
} }
@ -522,8 +522,8 @@ function EnqueueSpliceRecord(array, index, removed, addedCount) {
addedCount: addedCount addedCount: addedCount
}; };
$objectFreeze(changeRecord); ObjectFreezeJS(changeRecord);
$objectFreeze(changeRecord.removed); ObjectFreezeJS(changeRecord.removed);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord); ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
} }
@ -547,7 +547,7 @@ function NotifyChange(type, object, name, oldValue) {
}; };
} }
$objectFreeze(changeRecord); ObjectFreezeJS(changeRecord);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord); ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
} }
@ -604,7 +604,7 @@ function ObjectGetNotifier(object) {
if (%IsJSGlobalProxy(object)) if (%IsJSGlobalProxy(object))
throw MakeTypeError("observe_global_proxy", ["getNotifier"]); throw MakeTypeError("observe_global_proxy", ["getNotifier"]);
if ($objectIsFrozen(object)) return null; if (ObjectIsFrozen(object)) return null;
if (!%ObjectWasCreatedInCurrentOrigin(object)) return null; if (!%ObjectWasCreatedInCurrentOrigin(object)) return null;
@ -662,17 +662,17 @@ function ObserveMicrotaskRunner() {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
$installFunctions(GlobalObject, DONT_ENUM, [ InstallFunctions(GlobalObject, DONT_ENUM, [
"deliverChangeRecords", ObjectDeliverChangeRecords, "deliverChangeRecords", ObjectDeliverChangeRecords,
"getNotifier", ObjectGetNotifier, "getNotifier", ObjectGetNotifier,
"observe", ObjectObserve, "observe", ObjectObserve,
"unobserve", ObjectUnobserve "unobserve", ObjectUnobserve
]); ]);
$installFunctions(GlobalArray, DONT_ENUM, [ InstallFunctions(GlobalArray, DONT_ENUM, [
"observe", ArrayObserve, "observe", ArrayObserve,
"unobserve", ArrayUnobserve "unobserve", ArrayUnobserve
]); ]);
$installFunctions(notifierPrototype, DONT_ENUM, [ InstallFunctions(notifierPrototype, DONT_ENUM, [
"notify", ObjectNotifierNotify, "notify", ObjectNotifierNotify,
"performChange", ObjectNotifierPerformChange "performChange", ObjectNotifierPerformChange
]); ]);

View File

@ -366,7 +366,7 @@ function PromiseHasUserDefinedRejectHandler() {
%AddNamedProperty(GlobalPromise.prototype, symbolToStringTag, "Promise", %AddNamedProperty(GlobalPromise.prototype, symbolToStringTag, "Promise",
DONT_ENUM | READ_ONLY); DONT_ENUM | READ_ONLY);
$installFunctions(GlobalPromise, DONT_ENUM, [ InstallFunctions(GlobalPromise, DONT_ENUM, [
"defer", PromiseDeferred, "defer", PromiseDeferred,
"accept", PromiseResolved, "accept", PromiseResolved,
"reject", PromiseRejected, "reject", PromiseRejected,
@ -375,7 +375,7 @@ $installFunctions(GlobalPromise, DONT_ENUM, [
"resolve", PromiseCast "resolve", PromiseCast
]); ]);
$installFunctions(GlobalPromise.prototype, DONT_ENUM, [ InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
"chain", PromiseChain, "chain", PromiseChain,
"then", PromiseThen, "then", PromiseThen,
"catch", PromiseCatch "catch", PromiseCatch

View File

@ -176,7 +176,7 @@ function ProxyEnumerate(proxy) {
if (IS_UNDEFINED(handler.enumerate)) { if (IS_UNDEFINED(handler.enumerate)) {
return %Apply(DerivedEnumerateTrap, handler, [], 0, 0) return %Apply(DerivedEnumerateTrap, handler, [], 0, 0)
} else { } else {
return $toNameArray(handler.enumerate(), "enumerate", false) return ToNameArray(handler.enumerate(), "enumerate", false)
} }
} }
@ -186,7 +186,7 @@ var Proxy = new GlobalObject();
%AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM); %AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM);
//Set up non-enumerable properties of the Proxy object. //Set up non-enumerable properties of the Proxy object.
$installFunctions(Proxy, DONT_ENUM, [ InstallFunctions(Proxy, DONT_ENUM, [
"create", ProxyCreate, "create", ProxyCreate,
"createFunction", ProxyCreateFunction "createFunction", ProxyCreateFunction
]) ])

View File

@ -363,7 +363,7 @@ function RegExpMakeCaptureGetter(n) {
GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
%SetCode(GlobalRegExp, RegExpConstructor); %SetCode(GlobalRegExp, RegExpConstructor);
$installFunctions(GlobalRegExp.prototype, DONT_ENUM, [ InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
"exec", RegExpExecJS, "exec", RegExpExecJS,
"test", RegExpTest, "test", RegExpTest,
"toString", RegExpToString, "toString", RegExpToString,

View File

@ -88,16 +88,16 @@ function StringPrototypeIterator() {
%FunctionSetPrototype(StringIterator, new GlobalObject()); %FunctionSetPrototype(StringIterator, new GlobalObject());
%FunctionSetInstanceClassName(StringIterator, 'String Iterator'); %FunctionSetInstanceClassName(StringIterator, 'String Iterator');
$installFunctions(StringIterator.prototype, DONT_ENUM, [ InstallFunctions(StringIterator.prototype, DONT_ENUM, [
'next', StringIteratorNext 'next', StringIteratorNext
]); ]);
$setFunctionName(StringIteratorIterator, symbolIterator); SetFunctionName(StringIteratorIterator, symbolIterator);
%AddNamedProperty(StringIterator.prototype, symbolIterator, %AddNamedProperty(StringIterator.prototype, symbolIterator,
StringIteratorIterator, DONT_ENUM); StringIteratorIterator, DONT_ENUM);
%AddNamedProperty(StringIterator.prototype, symbolToStringTag, %AddNamedProperty(StringIterator.prototype, symbolToStringTag,
"String Iterator", READ_ONLY | DONT_ENUM); "String Iterator", READ_ONLY | DONT_ENUM);
$setFunctionName(StringPrototypeIterator, symbolIterator); SetFunctionName(StringPrototypeIterator, symbolIterator);
%AddNamedProperty(GlobalString.prototype, symbolIterator, %AddNamedProperty(GlobalString.prototype, symbolIterator,
StringPrototypeIterator, DONT_ENUM); StringPrototypeIterator, DONT_ENUM);

View File

@ -1118,14 +1118,14 @@ function StringRaw(callSite) {
GlobalString.prototype, "constructor", GlobalString, DONT_ENUM); GlobalString.prototype, "constructor", GlobalString, DONT_ENUM);
// Set up the non-enumerable functions on the String object. // Set up the non-enumerable functions on the String object.
$installFunctions(GlobalString, DONT_ENUM, [ InstallFunctions(GlobalString, DONT_ENUM, [
"fromCharCode", StringFromCharCode, "fromCharCode", StringFromCharCode,
"fromCodePoint", StringFromCodePoint, "fromCodePoint", StringFromCodePoint,
"raw", StringRaw "raw", StringRaw
]); ]);
// Set up the non-enumerable functions on the String prototype object. // Set up the non-enumerable functions on the String prototype object.
$installFunctions(GlobalString.prototype, DONT_ENUM, [ InstallFunctions(GlobalString.prototype, DONT_ENUM, [
"valueOf", StringValueOf, "valueOf", StringValueOf,
"toString", StringToString, "toString", StringToString,
"charAt", StringCharAtJS, "charAt", StringCharAtJS,

View File

@ -73,7 +73,7 @@ function ObjectGetOwnPropertySymbols(obj) {
// TODO(arv): Proxies use a shared trap for String and Symbol keys. // TODO(arv): Proxies use a shared trap for String and Symbol keys.
return $objectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING); return ObjectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
@ -81,7 +81,7 @@ function ObjectGetOwnPropertySymbols(obj) {
%SetCode(GlobalSymbol, SymbolConstructor); %SetCode(GlobalSymbol, SymbolConstructor);
%FunctionSetPrototype(GlobalSymbol, new GlobalObject()); %FunctionSetPrototype(GlobalSymbol, new GlobalObject());
$installConstants(GlobalSymbol, [ InstallConstants(GlobalSymbol, [
// TODO(rossberg): expose when implemented. // TODO(rossberg): expose when implemented.
// "hasInstance", symbolHasInstance, // "hasInstance", symbolHasInstance,
// "isConcatSpreadable", symbolIsConcatSpreadable, // "isConcatSpreadable", symbolIsConcatSpreadable,
@ -93,7 +93,7 @@ $installConstants(GlobalSymbol, [
"unscopables", symbolUnscopables "unscopables", symbolUnscopables
]); ]);
$installFunctions(GlobalSymbol, DONT_ENUM, [ InstallFunctions(GlobalSymbol, DONT_ENUM, [
"for", SymbolFor, "for", SymbolFor,
"keyFor", SymbolKeyFor "keyFor", SymbolKeyFor
]); ]);
@ -103,12 +103,12 @@ $installFunctions(GlobalSymbol, DONT_ENUM, [
%AddNamedProperty( %AddNamedProperty(
GlobalSymbol.prototype, symbolToStringTag, "Symbol", DONT_ENUM | READ_ONLY); GlobalSymbol.prototype, symbolToStringTag, "Symbol", DONT_ENUM | READ_ONLY);
$installFunctions(GlobalSymbol.prototype, DONT_ENUM, [ InstallFunctions(GlobalSymbol.prototype, DONT_ENUM, [
"toString", SymbolToString, "toString", SymbolToString,
"valueOf", SymbolValueOf "valueOf", SymbolValueOf
]); ]);
$installFunctions(GlobalObject, DONT_ENUM, [ InstallFunctions(GlobalObject, DONT_ENUM, [
"getOwnPropertySymbols", ObjectGetOwnPropertySymbols "getOwnPropertySymbols", ObjectGetOwnPropertySymbols
]); ]);

View File

@ -1012,7 +1012,7 @@ function MathLog2(x) {
//------------------------------------------------------------------- //-------------------------------------------------------------------
$installFunctions(GlobalMath, DONT_ENUM, [ InstallFunctions(GlobalMath, DONT_ENUM, [
"cos", MathCos, "cos", MathCos,
"sin", MathSin, "sin", MathSin,
"tan", MathTan, "tan", MathTan,

View File

@ -10,9 +10,8 @@
var GlobalArray = global.Array; var GlobalArray = global.Array;
var GlobalArrayBuffer = global.ArrayBuffer; var GlobalArrayBuffer = global.ArrayBuffer;
var GlobalDataView = global.DataView;
var GlobalObject = global.Object;
// --------------- Typed Arrays ---------------------
macro TYPED_ARRAYS(FUNCTION) macro TYPED_ARRAYS(FUNCTION)
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize. // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
FUNCTION(1, Uint8Array, 1) FUNCTION(1, Uint8Array, 1)
@ -26,14 +25,6 @@ FUNCTION(8, Float64Array, 8)
FUNCTION(9, Uint8ClampedArray, 1) FUNCTION(9, Uint8ClampedArray, 1)
endmacro endmacro
macro DECLARE_GLOBALS(INDEX, NAME, SIZE)
var GlobalNAME = global.NAME;
endmacro
TYPED_ARRAYS(DECLARE_GLOBALS)
// --------------- Typed Arrays ---------------------
macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
if (!IS_UNDEFINED(byteOffset)) { if (!IS_UNDEFINED(byteOffset)) {
@ -154,6 +145,8 @@ function NAME_GetLength() {
return %_TypedArrayGetLength(this); return %_TypedArrayGetLength(this);
} }
var $NAME = global.NAME;
function NAMESubArray(begin, end) { function NAMESubArray(begin, end) {
if (!(%_ClassOf(this) === 'NAME')) { if (!(%_ClassOf(this) === 'NAME')) {
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.subarray", this); throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.subarray", this);
@ -182,8 +175,8 @@ function NAMESubArray(begin, end) {
var newLength = endInt - beginInt; var newLength = endInt - beginInt;
var beginByteOffset = var beginByteOffset =
%_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE;
return new GlobalNAME(%TypedArrayGetBuffer(this), return new $NAME(%TypedArrayGetBuffer(this),
beginByteOffset, newLength); beginByteOffset, newLength);
} }
endmacro endmacro
@ -304,26 +297,26 @@ function TypedArrayGetToStringTag() {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
%SetCode(GlobalNAME, NAMEConstructor); %SetCode(global.NAME, NAMEConstructor);
%FunctionSetPrototype(GlobalNAME, new GlobalObject()); %FunctionSetPrototype(global.NAME, new $Object());
%AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, %AddNamedProperty(global.NAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
READ_ONLY | DONT_ENUM | DONT_DELETE); READ_ONLY | DONT_ENUM | DONT_DELETE);
%AddNamedProperty(GlobalNAME.prototype, %AddNamedProperty(global.NAME.prototype,
"constructor", global.NAME, DONT_ENUM); "constructor", global.NAME, DONT_ENUM);
%AddNamedProperty(GlobalNAME.prototype, %AddNamedProperty(global.NAME.prototype,
"BYTES_PER_ELEMENT", ELEMENT_SIZE, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
READ_ONLY | DONT_ENUM | DONT_DELETE); READ_ONLY | DONT_ENUM | DONT_DELETE);
$installGetter(GlobalNAME.prototype, "buffer", NAME_GetBuffer); InstallGetter(global.NAME.prototype, "buffer", NAME_GetBuffer);
$installGetter(GlobalNAME.prototype, "byteOffset", NAME_GetByteOffset, InstallGetter(global.NAME.prototype, "byteOffset", NAME_GetByteOffset,
DONT_ENUM | DONT_DELETE); DONT_ENUM | DONT_DELETE);
$installGetter(GlobalNAME.prototype, "byteLength", NAME_GetByteLength, InstallGetter(global.NAME.prototype, "byteLength", NAME_GetByteLength,
DONT_ENUM | DONT_DELETE); DONT_ENUM | DONT_DELETE);
$installGetter(GlobalNAME.prototype, "length", NAME_GetLength, InstallGetter(global.NAME.prototype, "length", NAME_GetLength,
DONT_ENUM | DONT_DELETE); DONT_ENUM | DONT_DELETE);
$installGetter(GlobalNAME.prototype, symbolToStringTag, InstallGetter(global.NAME.prototype, symbolToStringTag,
TypedArrayGetToStringTag); TypedArrayGetToStringTag);
$installFunctions(GlobalNAME.prototype, DONT_ENUM, [ InstallFunctions(global.NAME.prototype, DONT_ENUM, [
"subarray", NAMESubArray, "subarray", NAMESubArray,
"set", TypedArraySet "set", TypedArraySet
]); ]);
@ -333,6 +326,8 @@ TYPED_ARRAYS(SETUP_TYPED_ARRAY)
// --------------------------- DataView ----------------------------- // --------------------------- DataView -----------------------------
var $DataView = global.DataView;
function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
if (!IS_ARRAYBUFFER(buffer)) { if (!IS_ARRAYBUFFER(buffer)) {
@ -435,20 +430,19 @@ endmacro
DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER) DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
// Setup the DataView constructor. // Setup the DataView constructor.
%SetCode(GlobalDataView, DataViewConstructor); %SetCode($DataView, DataViewConstructor);
%FunctionSetPrototype(GlobalDataView, new GlobalObject); %FunctionSetPrototype($DataView, new $Object);
// Set up constructor property on the DataView prototype. // Set up constructor property on the DataView prototype.
%AddNamedProperty(GlobalDataView.prototype, "constructor", GlobalDataView, %AddNamedProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM);
DONT_ENUM); %AddNamedProperty(
%AddNamedProperty(GlobalDataView.prototype, symbolToStringTag, "DataView", $DataView.prototype, symbolToStringTag, "DataView", READ_ONLY|DONT_ENUM);
READ_ONLY|DONT_ENUM);
$installGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS); InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS);
$installGetter(GlobalDataView.prototype, "byteOffset", DataViewGetByteOffset); InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset);
$installGetter(GlobalDataView.prototype, "byteLength", DataViewGetByteLength); InstallGetter($DataView.prototype, "byteLength", DataViewGetByteLength);
$installFunctions(GlobalDataView.prototype, DONT_ENUM, [ InstallFunctions($DataView.prototype, DONT_ENUM, [
"getInt8", DataViewGetInt8JS, "getInt8", DataViewGetInt8JS,
"setInt8", DataViewSetInt8JS, "setInt8", DataViewSetInt8JS,

View File

@ -356,7 +356,7 @@ function URIEncodeComponent(component) {
// Set up non-enumerable URI functions on the global object and set // Set up non-enumerable URI functions on the global object and set
// their names. // their names.
$installFunctions(global, DONT_ENUM, [ InstallFunctions(global, DONT_ENUM, [
"escape", URIEscapeJS, "escape", URIEscapeJS,
"unescape", URIUnescapeJS, "unescape", URIUnescapeJS,
"decodeURI", URIDecode, "decodeURI", URIDecode,

View File

@ -2,44 +2,16 @@
// 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 $delete; // This file relies on the fact that the following declarations have been made
var $functionSourceString; // in runtime.js:
var $getIterator; // var $Object = global.Object;
var $getMethod; // var $Boolean = global.Boolean;
var $globalEval; // var $Number = global.Number;
var $installConstants; // var $Function = global.Function;
var $installFunctions; // var $Array = global.Array;
var $installGetter;
var $isFinite;
var $isNaN;
var $newFunctionString;
var $numberIsNaN;
var $objectDefineProperties;
var $objectDefineProperty;
var $objectFreeze;
var $objectGetOwnPropertyDescriptor;
var $objectGetOwnPropertyKeys;
var $objectHasOwnProperty;
var $objectIsFrozen;
var $objectIsSealed;
var $objectLookupGetter;
var $objectLookupSetter;
var $objectToString;
var $overrideFunction;
var $setFunctionName;
var $setUpLockedPrototype;
var $toCompletePropertyDescriptor;
var $toNameArray;
(function() { var $isNaN = GlobalIsNaN;
var $isFinite = GlobalIsFinite;
%CheckIsBootstrapping();
var GlobalArray = global.Array;
var GlobalBoolean = global.Boolean;
var GlobalFunction = global.Function;
var GlobalNumber = global.Number;
var GlobalObject = global.Object;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -223,31 +195,44 @@ function GlobalEval(x) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Set up global object. // Set up global object.
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; function SetUpGlobal() {
%CheckIsBootstrapping();
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
InstallConstants(global, [
// ECMA 262 - 15.1.1.1. // ECMA 262 - 15.1.1.1.
"NaN", NAN, %AddNamedProperty(global, "NaN", NAN, attributes);
// ECMA-262 - 15.1.1.2.
"Infinity", INFINITY,
// ECMA-262 - 15.1.1.2.
"undefined", UNDEFINED,
]);
// Set up non-enumerable function on the global object. // ECMA-262 - 15.1.1.2.
InstallFunctions(global, DONT_ENUM, [ %AddNamedProperty(global, "Infinity", INFINITY, attributes);
"isNaN", GlobalIsNaN,
"isFinite", GlobalIsFinite, // ECMA-262 - 15.1.1.3.
"parseInt", GlobalParseInt, %AddNamedProperty(global, "undefined", UNDEFINED, attributes);
"parseFloat", GlobalParseFloat,
"eval", GlobalEval // Set up non-enumerable function on the global object.
]); InstallFunctions(global, DONT_ENUM, [
"isNaN", GlobalIsNaN,
"isFinite", GlobalIsFinite,
"parseInt", GlobalParseInt,
"parseFloat", GlobalParseFloat,
"eval", GlobalEval
]);
}
SetUpGlobal();
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Object // Object
// ECMA-262 - 15.2.4.2 // ECMA-262 - 15.2.4.2
function NoSideEffectsObjectToString() {
if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
if (IS_NULL(this)) return "[object Null]";
return "[object " + %_ClassOf(TO_OBJECT_INLINE(this)) + "]";
}
function ObjectToString() { function ObjectToString() {
if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
if (IS_NULL(this)) return "[object Null]"; if (IS_NULL(this)) return "[object Null]";
@ -257,7 +242,7 @@ function ObjectToString() {
// TODO(caitp): cannot wait to get rid of this flag :> // TODO(caitp): cannot wait to get rid of this flag :>
if (harmony_tostring) { if (harmony_tostring) {
tag = O[symbolToStringTag]; var tag = O[symbolToStringTag];
if (!IS_STRING(tag)) { if (!IS_STRING(tag)) {
tag = builtinTag; tag = builtinTag;
} }
@ -426,7 +411,7 @@ function FromPropertyDescriptor(desc) {
// Harmony Proxies // Harmony Proxies
function FromGenericPropertyDescriptor(desc) { function FromGenericPropertyDescriptor(desc) {
if (IS_UNDEFINED(desc)) return desc; if (IS_UNDEFINED(desc)) return desc;
var obj = new GlobalObject(); var obj = new $Object();
if (desc.hasValue()) { if (desc.hasValue()) {
%AddNamedProperty(obj, "value", desc.getValue(), NONE); %AddNamedProperty(obj, "value", desc.getValue(), NONE);
@ -1055,7 +1040,7 @@ function ToNameArray(obj, trap, includeSymbols) {
throw MakeTypeError(kProxyNonObjectPropNames, trap, obj); throw MakeTypeError(kProxyNonObjectPropNames, trap, obj);
} }
var n = ToUint32(obj.length); var n = ToUint32(obj.length);
var array = new GlobalArray(n); var array = new $Array(n);
var realLength = 0; var realLength = 0;
var names = { __proto__: null }; // TODO(rossberg): use sets once ready. var names = { __proto__: null }; // TODO(rossberg): use sets once ready.
for (var index = 0; index < n; index++) { for (var index = 0; index < n; index++) {
@ -1264,8 +1249,8 @@ function ProxyFix(obj) {
%SetCode(obj, code); %SetCode(obj, code);
// TODO(rossberg): What about length and other properties? Not specified. // TODO(rossberg): What about length and other properties? Not specified.
// We just put in some half-reasonable defaults for now. // We just put in some half-reasonable defaults for now.
var prototype = new GlobalObject(); var prototype = new $Object();
ObjectDefineProperty(prototype, "constructor", $Object.defineProperty(prototype, "constructor",
{value: obj, writable: true, enumerable: false, configurable: true}); {value: obj, writable: true, enumerable: false, configurable: true});
// TODO(v8:1530): defineProperty does not handle prototype and length. // TODO(v8:1530): defineProperty does not handle prototype and length.
%FunctionSetPrototype(obj, prototype); %FunctionSetPrototype(obj, prototype);
@ -1430,49 +1415,54 @@ function ObjectConstructor(x) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Object // Object
%SetNativeFlag(GlobalObject); function SetUpObject() {
%SetCode(GlobalObject, ObjectConstructor); %CheckIsBootstrapping();
%AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject, %SetNativeFlag($Object);
DONT_ENUM); %SetCode($Object, ObjectConstructor);
// Set up non-enumerable functions on the Object.prototype object. %AddNamedProperty($Object.prototype, "constructor", $Object, DONT_ENUM);
InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
"toString", ObjectToString,
"toLocaleString", ObjectToLocaleString,
"valueOf", ObjectValueOf,
"hasOwnProperty", ObjectHasOwnProperty,
"isPrototypeOf", ObjectIsPrototypeOf,
"propertyIsEnumerable", ObjectPropertyIsEnumerable,
"__defineGetter__", ObjectDefineGetter,
"__lookupGetter__", ObjectLookupGetter,
"__defineSetter__", ObjectDefineSetter,
"__lookupSetter__", ObjectLookupSetter
]);
InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto,
ObjectSetProto);
// Set up non-enumerable functions in the Object object. // Set up non-enumerable functions on the Object.prototype object.
InstallFunctions(GlobalObject, DONT_ENUM, [ InstallFunctions($Object.prototype, DONT_ENUM, [
"keys", ObjectKeys, "toString", ObjectToString,
"create", ObjectCreate, "toLocaleString", ObjectToLocaleString,
"defineProperty", ObjectDefineProperty, "valueOf", ObjectValueOf,
"defineProperties", ObjectDefineProperties, "hasOwnProperty", ObjectHasOwnProperty,
"freeze", ObjectFreezeJS, "isPrototypeOf", ObjectIsPrototypeOf,
"getPrototypeOf", ObjectGetPrototypeOf, "propertyIsEnumerable", ObjectPropertyIsEnumerable,
"setPrototypeOf", ObjectSetPrototypeOf, "__defineGetter__", ObjectDefineGetter,
"getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, "__lookupGetter__", ObjectLookupGetter,
"getOwnPropertyNames", ObjectGetOwnPropertyNames, "__defineSetter__", ObjectDefineSetter,
// getOwnPropertySymbols is added in symbol.js. "__lookupSetter__", ObjectLookupSetter
"is", ObjectIs, ]);
"isExtensible", ObjectIsExtensible, InstallGetterSetter($Object.prototype, "__proto__",
"isFrozen", ObjectIsFrozen, ObjectGetProto, ObjectSetProto);
"isSealed", ObjectIsSealed,
"preventExtensions", ObjectPreventExtension, // Set up non-enumerable functions in the Object object.
"seal", ObjectSealJS InstallFunctions($Object, DONT_ENUM, [
// deliverChangeRecords, getNotifier, observe and unobserve are added "keys", ObjectKeys,
// in object-observe.js. "create", ObjectCreate,
]); "defineProperty", ObjectDefineProperty,
"defineProperties", ObjectDefineProperties,
"freeze", ObjectFreezeJS,
"getPrototypeOf", ObjectGetPrototypeOf,
"setPrototypeOf", ObjectSetPrototypeOf,
"getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
"getOwnPropertyNames", ObjectGetOwnPropertyNames,
// getOwnPropertySymbols is added in symbol.js.
"is", ObjectIs,
"isExtensible", ObjectIsExtensible,
"isFrozen", ObjectIsFrozen,
"isSealed", ObjectIsSealed,
"preventExtensions", ObjectPreventExtension,
"seal", ObjectSealJS
// deliverChangeRecords, getNotifier, observe and unobserve are added
// in object-observe.js.
]);
}
SetUpObject();
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1513,15 +1503,20 @@ function BooleanValueOf() {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
%SetCode(GlobalBoolean, BooleanConstructor); function SetUpBoolean () {
%FunctionSetPrototype(GlobalBoolean, new GlobalBoolean(false)); %CheckIsBootstrapping();
%AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean,
DONT_ENUM);
InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [ %SetCode($Boolean, BooleanConstructor);
"toString", BooleanToString, %FunctionSetPrototype($Boolean, new $Boolean(false));
"valueOf", BooleanValueOf %AddNamedProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM);
]);
InstallFunctions($Boolean.prototype, DONT_ENUM, [
"toString", BooleanToString,
"valueOf", BooleanValueOf
]);
}
SetUpBoolean();
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1677,9 +1672,7 @@ function NumberIsNaN(number) {
function NumberIsSafeInteger(number) { function NumberIsSafeInteger(number) {
if (NumberIsFinite(number)) { if (NumberIsFinite(number)) {
var integral = TO_INTEGER(number); var integral = TO_INTEGER(number);
if (integral == number) { if (integral == number) return $abs(integral) <= $Number.MAX_SAFE_INTEGER;
return $abs(integral) <= GlobalNumber.MAX_SAFE_INTEGER;
}
} }
return false; return false;
} }
@ -1687,54 +1680,59 @@ function NumberIsSafeInteger(number) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
%SetCode(GlobalNumber, NumberConstructor); function SetUpNumber() {
%FunctionSetPrototype(GlobalNumber, new GlobalNumber(0)); %CheckIsBootstrapping();
%OptimizeObjectForAddingMultipleProperties(GlobalNumber.prototype, 8); %SetCode($Number, NumberConstructor);
// Set up the constructor property on the Number prototype object. %FunctionSetPrototype($Number, new $Number(0));
%AddNamedProperty(GlobalNumber.prototype, "constructor", GlobalNumber,
DONT_ENUM);
InstallConstants(GlobalNumber, [ %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8);
// ECMA-262 section 15.7.3.1. // Set up the constructor property on the Number prototype object.
"MAX_VALUE", 1.7976931348623157e+308, %AddNamedProperty($Number.prototype, "constructor", $Number, DONT_ENUM);
// ECMA-262 section 15.7.3.2.
"MIN_VALUE", 5e-324,
// ECMA-262 section 15.7.3.3.
"NaN", NAN,
// ECMA-262 section 15.7.3.4.
"NEGATIVE_INFINITY", -INFINITY,
// ECMA-262 section 15.7.3.5.
"POSITIVE_INFINITY", INFINITY,
// --- Harmony constants (no spec refs until settled.) InstallConstants($Number, [
// ECMA-262 section 15.7.3.1.
"MAX_VALUE", 1.7976931348623157e+308,
// ECMA-262 section 15.7.3.2.
"MIN_VALUE", 5e-324,
// ECMA-262 section 15.7.3.3.
"NaN", NAN,
// ECMA-262 section 15.7.3.4.
"NEGATIVE_INFINITY", -INFINITY,
// ECMA-262 section 15.7.3.5.
"POSITIVE_INFINITY", INFINITY,
"MAX_SAFE_INTEGER", %_MathPow(2, 53) - 1, // --- Harmony constants (no spec refs until settled.)
"MIN_SAFE_INTEGER", -%_MathPow(2, 53) + 1,
"EPSILON", %_MathPow(2, -52)
]);
// Set up non-enumerable functions on the Number prototype object. "MAX_SAFE_INTEGER", %_MathPow(2, 53) - 1,
InstallFunctions(GlobalNumber.prototype, DONT_ENUM, [ "MIN_SAFE_INTEGER", -%_MathPow(2, 53) + 1,
"toString", NumberToStringJS, "EPSILON", %_MathPow(2, -52)
"toLocaleString", NumberToLocaleString, ]);
"valueOf", NumberValueOf,
"toFixed", NumberToFixedJS,
"toExponential", NumberToExponentialJS,
"toPrecision", NumberToPrecisionJS
]);
// Harmony Number constructor additions // Set up non-enumerable functions on the Number prototype object.
InstallFunctions(GlobalNumber, DONT_ENUM, [ InstallFunctions($Number.prototype, DONT_ENUM, [
"isFinite", NumberIsFinite, "toString", NumberToStringJS,
"isInteger", NumberIsInteger, "toLocaleString", NumberToLocaleString,
"isNaN", NumberIsNaN, "valueOf", NumberValueOf,
"isSafeInteger", NumberIsSafeInteger, "toFixed", NumberToFixedJS,
"parseInt", GlobalParseInt, "toExponential", NumberToExponentialJS,
"parseFloat", GlobalParseFloat "toPrecision", NumberToPrecisionJS
]); ]);
%SetInlineBuiltinFlag(NumberIsNaN); // Harmony Number constructor additions
InstallFunctions($Number, DONT_ENUM, [
"isFinite", NumberIsFinite,
"isInteger", NumberIsInteger,
"isNaN", NumberIsNaN,
"isSafeInteger", NumberIsSafeInteger,
"parseInt", GlobalParseInt,
"parseFloat", GlobalParseFloat
]);
%SetInlineBuiltinFlag(NumberIsNaN);
}
SetUpNumber();
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1852,13 +1850,13 @@ function FunctionBind(this_arg) { // Length is 1.
} }
function NewFunctionString(args, function_token) { function NewFunctionString(arguments, function_token) {
var n = args.length; var n = arguments.length;
var p = ''; var p = '';
if (n > 1) { if (n > 1) {
p = ToString(args[0]); p = ToString(arguments[0]);
for (var i = 1; i < n - 1; i++) { for (var i = 1; i < n - 1; i++) {
p += ',' + ToString(args[i]); p += ',' + ToString(arguments[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
@ -1871,7 +1869,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(arguments[n - 1]) : '';
return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; return '(' + function_token + '(' + p + ') {\n' + body + '\n})';
} }
@ -1889,14 +1887,20 @@ function FunctionConstructor(arg1) { // length == 1
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
%SetCode(GlobalFunction, FunctionConstructor); function SetUpFunction() {
%AddNamedProperty(GlobalFunction.prototype, "constructor", GlobalFunction, %CheckIsBootstrapping();
DONT_ENUM);
%SetCode($Function, FunctionConstructor);
%AddNamedProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
InstallFunctions($Function.prototype, DONT_ENUM, [
"bind", FunctionBind,
"toString", FunctionToString
]);
}
SetUpFunction();
InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [
"bind", FunctionBind,
"toString", FunctionToString
]);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Iterator related spec functions. // Iterator related spec functions.
@ -1916,36 +1920,3 @@ function GetIterator(obj, method) {
} }
return iterator; return iterator;
} }
//----------------------------------------------------------------------------
$delete = Delete;
$functionSourceString = FunctionSourceString;
$getIterator = GetIterator;
$getMethod = GetMethod;
$globalEval = GlobalEval;
$installConstants = InstallConstants;
$installFunctions = InstallFunctions;
$installGetter = InstallGetter;
$isFinite = GlobalIsFinite;
$isNaN = GlobalIsNaN;
$newFunctionString = NewFunctionString;
$numberIsNaN = NumberIsNaN;
$objectDefineProperties = ObjectDefineProperties;
$objectDefineProperty = ObjectDefineProperty;
$objectFreeze = ObjectFreezeJS;
$objectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor;
$objectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys;
$objectHasOwnProperty = ObjectHasOwnProperty;
$objectIsFrozen = ObjectIsFrozen;
$objectIsSealed = ObjectIsSealed;
$objectLookupGetter = ObjectLookupGetter;
$objectLookupSetter = ObjectLookupSetter;
$objectToString = ObjectToString;
$overrideFunction = OverrideFunction;
$setFunctionName = SetFunctionName;
$setUpLockedPrototype = SetUpLockedPrototype;
$toCompletePropertyDescriptor = ToCompletePropertyDescriptor;
$toNameArray = ToNameArray;
})();

View File

@ -90,7 +90,7 @@ function WeakMapDelete(key) {
DONT_ENUM | READ_ONLY); DONT_ENUM | READ_ONLY);
// Set up the non-enumerable functions on the WeakMap prototype object. // Set up the non-enumerable functions on the WeakMap prototype object.
$installFunctions(GlobalWeakMap.prototype, DONT_ENUM, [ InstallFunctions(GlobalWeakMap.prototype, DONT_ENUM, [
"get", WeakMapGet, "get", WeakMapGet,
"set", WeakMapSet, "set", WeakMapSet,
"has", WeakMapHas, "has", WeakMapHas,
@ -162,7 +162,7 @@ function WeakSetDelete(value) {
DONT_ENUM | READ_ONLY); DONT_ENUM | READ_ONLY);
// Set up the non-enumerable functions on the WeakSet prototype object. // Set up the non-enumerable functions on the WeakSet prototype object.
$installFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [
"add", WeakSetAdd, "add", WeakSetAdd,
"has", WeakSetHas, "has", WeakSetHas,
"delete", WeakSetDelete "delete", WeakSetDelete

View File

@ -29,5 +29,5 @@
// Test call of JS runtime functions. // Test call of JS runtime functions.
var a = %$isNaN(0/0); var a = %GlobalParseInt("21", 16);
assertEquals(true, a); assertEquals(33, a);

View File

@ -100,12 +100,6 @@ class JavaScriptMinifier(object):
The string that should replace the match in the rewritten program. The string that should replace the match in the rewritten program.
""" """
matched_text = m.group(0) matched_text = m.group(0)
if matched_text.startswith("`") and matched_text.endswith("`"):
return re.sub(r"\$\{([\w$%]+)\}",
lambda m: '${' + self.FindNewName(m.group(1)) + '}',
matched_text)
if matched_text == "{": if matched_text == "{":
self.Push() self.Push()
return matched_text return matched_text
@ -158,9 +152,6 @@ class JavaScriptMinifier(object):
return self.map[var_name] return self.map[var_name]
if self.nesting == 0: if self.nesting == 0:
return var_name return var_name
# Do not rename arguments object.
if var_name == 'arguments':
return 'arguments'
while True: while True:
identifier_first_char = self.identifier_counter % 52 identifier_first_char = self.identifier_counter % 52
identifier_second_char = self.identifier_counter // 52 identifier_second_char = self.identifier_counter // 52
@ -193,8 +184,6 @@ class JavaScriptMinifier(object):
return entire_match return entire_match
if re.match(r'".*"$', entire_match): if re.match(r'".*"$', entire_match):
return entire_match return entire_match
if re.match(r"`.*`$", entire_match):
return entire_match
if re.match(r"/.+/$", entire_match): if re.match(r"/.+/$", entire_match):
return entire_match return entire_match
return replacement return replacement
@ -238,10 +227,8 @@ class JavaScriptMinifier(object):
# This regexp can handle embedded backslash-escaped characters including # This regexp can handle embedded backslash-escaped characters including
# embedded backslash-escaped double quotes. # embedded backslash-escaped double quotes.
double_quoted_string = r'"(?:[^"\\]|\\.)*"' double_quoted_string = r'"(?:[^"\\]|\\.)*"'
# A regexp that matches a literal string surrounded by 'single quotes'. # A regexp that matches a literal string surrounded by 'double quotes'.
single_quoted_string = r"'(?:[^'\\]|\\.)*'" single_quoted_string = r"'(?:[^'\\]|\\.)*'"
# A regexp that matches a template string
template_string = r"`(?:[^'\\]|\\.)*`"
# A regexp that matches a regexp literal surrounded by /slashes/. # A regexp that matches a regexp literal surrounded by /slashes/.
# Don't allow a regexp to have a ) before the first ( since that's a # Don't allow a regexp to have a ) before the first ( since that's a
# syntax error and it's probably just two unrelated slashes. # syntax error and it's probably just two unrelated slashes.
@ -251,7 +238,6 @@ class JavaScriptMinifier(object):
# Replace multiple spaces with a single space. # Replace multiple spaces with a single space.
line = re.sub("|".join([double_quoted_string, line = re.sub("|".join([double_quoted_string,
single_quoted_string, single_quoted_string,
template_string,
slash_quoted_regexp, slash_quoted_regexp,
"( )+"]), "( )+"]),
self.RemoveSpaces, self.RemoveSpaces,
@ -260,7 +246,6 @@ class JavaScriptMinifier(object):
# and after the space. % and $ are counted as identifier characters. # and after the space. % and $ are counted as identifier characters.
line = re.sub("|".join([double_quoted_string, line = re.sub("|".join([double_quoted_string,
single_quoted_string, single_quoted_string,
template_string,
slash_quoted_regexp, slash_quoted_regexp,
r"(?<![a-zA-Z_0-9$%]) | (?![a-zA-Z_0-9$%])()"]), r"(?<![a-zA-Z_0-9$%]) | (?![a-zA-Z_0-9$%])()"]),
self.RemoveSpaces, self.RemoveSpaces,
@ -284,7 +269,6 @@ class JavaScriptMinifier(object):
variable_use_regexp = r"(?<![.\w$%])[\w$%]+" + block_trailing_colon variable_use_regexp = r"(?<![.\w$%])[\w$%]+" + block_trailing_colon
line = re.sub("|".join([double_quoted_string, line = re.sub("|".join([double_quoted_string,
single_quoted_string, single_quoted_string,
template_string,
slash_quoted_regexp, slash_quoted_regexp,
r"\{", # Curly braces. r"\{", # Curly braces.
r"\}", r"\}",