Replace AddProperty by AddNamedProperty to speed up the common case
BUG= R=ishell@chromium.org Review URL: https://codereview.chromium.org/384003003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22381 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
3fade8e4af
commit
1d55a634a9
@ -110,8 +110,8 @@ function SetUpArrayIterator() {
|
||||
'next', ArrayIteratorNext
|
||||
));
|
||||
%FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]');
|
||||
%AddProperty(ArrayIterator.prototype, symbolIterator, ArrayIteratorIterator,
|
||||
DONT_ENUM);
|
||||
%AddNamedProperty(ArrayIterator.prototype, symbolIterator,
|
||||
ArrayIteratorIterator, DONT_ENUM);
|
||||
}
|
||||
SetUpArrayIterator();
|
||||
|
||||
@ -125,7 +125,7 @@ function ExtendArrayPrototype() {
|
||||
'keys', ArrayKeys
|
||||
));
|
||||
|
||||
%AddProperty($Array.prototype, symbolIterator, ArrayValues, DONT_ENUM);
|
||||
%AddNamedProperty($Array.prototype, symbolIterator, ArrayValues, DONT_ENUM);
|
||||
}
|
||||
ExtendArrayPrototype();
|
||||
|
||||
@ -146,10 +146,10 @@ macro TYPED_ARRAYS(FUNCTION)
|
||||
endmacro
|
||||
|
||||
macro EXTEND_TYPED_ARRAY(NAME)
|
||||
%AddProperty($NAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
|
||||
%AddProperty($NAME.prototype, 'values', ArrayValues, DONT_ENUM);
|
||||
%AddProperty($NAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
|
||||
%AddProperty($NAME.prototype, symbolIterator, ArrayValues, DONT_ENUM);
|
||||
%AddNamedProperty($NAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
|
||||
%AddNamedProperty($NAME.prototype, 'values', ArrayValues, DONT_ENUM);
|
||||
%AddNamedProperty($NAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
|
||||
%AddNamedProperty($NAME.prototype, symbolIterator, ArrayValues, DONT_ENUM);
|
||||
endmacro
|
||||
|
||||
TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
|
||||
|
@ -1460,7 +1460,7 @@ function SetUpArray() {
|
||||
|
||||
// Set up non-enumerable constructor property on the Array.prototype
|
||||
// object.
|
||||
%AddProperty($Array.prototype, "constructor", $Array, DONT_ENUM);
|
||||
%AddNamedProperty($Array.prototype, "constructor", $Array, DONT_ENUM);
|
||||
|
||||
// Set up non-enumerable functions on the Array object.
|
||||
InstallFunctions($Array, DONT_ENUM, $Array(
|
||||
|
@ -74,7 +74,8 @@ function SetUpArrayBuffer() {
|
||||
%FunctionSetPrototype($ArrayBuffer, new $Object());
|
||||
|
||||
// Set up the constructor property on the ArrayBuffer prototype object.
|
||||
%AddProperty($ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM);
|
||||
%AddNamedProperty(
|
||||
$ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM);
|
||||
|
||||
InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
|
||||
|
||||
|
@ -75,7 +75,7 @@ function SetUpSetIterator() {
|
||||
));
|
||||
|
||||
%FunctionSetName(SetIteratorSymbolIterator, '[Symbol.iterator]');
|
||||
%AddProperty(SetIterator.prototype, symbolIterator,
|
||||
%AddNamedProperty(SetIterator.prototype, symbolIterator,
|
||||
SetIteratorSymbolIterator, DONT_ENUM);
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ function ExtendSetPrototype() {
|
||||
'values', SetValues
|
||||
));
|
||||
|
||||
%AddProperty($Set.prototype, symbolIterator, SetValues, DONT_ENUM);
|
||||
%AddNamedProperty($Set.prototype, symbolIterator, SetValues, DONT_ENUM);
|
||||
}
|
||||
|
||||
ExtendSetPrototype();
|
||||
@ -172,7 +172,7 @@ function SetUpMapIterator() {
|
||||
));
|
||||
|
||||
%FunctionSetName(MapIteratorSymbolIterator, '[Symbol.iterator]');
|
||||
%AddProperty(MapIterator.prototype, symbolIterator,
|
||||
%AddNamedProperty(MapIterator.prototype, symbolIterator,
|
||||
MapIteratorSymbolIterator, DONT_ENUM);
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ function ExtendMapPrototype() {
|
||||
'values', MapValues
|
||||
));
|
||||
|
||||
%AddProperty($Map.prototype, symbolIterator, MapEntries, DONT_ENUM);
|
||||
%AddNamedProperty($Map.prototype, symbolIterator, MapEntries, DONT_ENUM);
|
||||
}
|
||||
|
||||
ExtendMapPrototype();
|
||||
|
@ -147,7 +147,7 @@ function SetUpSet() {
|
||||
|
||||
%SetCode($Set, SetConstructor);
|
||||
%FunctionSetPrototype($Set, new $Object());
|
||||
%AddProperty($Set.prototype, "constructor", $Set, DONT_ENUM);
|
||||
%AddNamedProperty($Set.prototype, "constructor", $Set, DONT_ENUM);
|
||||
|
||||
%FunctionSetLength(SetForEach, 1);
|
||||
|
||||
@ -282,7 +282,7 @@ function SetUpMap() {
|
||||
|
||||
%SetCode($Map, MapConstructor);
|
||||
%FunctionSetPrototype($Map, new $Object());
|
||||
%AddProperty($Map.prototype, "constructor", $Map, DONT_ENUM);
|
||||
%AddNamedProperty($Map.prototype, "constructor", $Map, DONT_ENUM);
|
||||
|
||||
%FunctionSetLength(MapForEach, 1);
|
||||
|
||||
|
@ -763,7 +763,7 @@ function SetUpDate() {
|
||||
));
|
||||
|
||||
// Set up non-enumerable constructor property of the Date prototype object.
|
||||
%AddProperty($Date.prototype, "constructor", $Date, DONT_ENUM);
|
||||
%AddNamedProperty($Date.prototype, "constructor", $Date, DONT_ENUM);
|
||||
|
||||
// Set up non-enumerable functions of the Date prototype object and
|
||||
// set their names.
|
||||
|
@ -63,13 +63,13 @@ function SetUpGenerators() {
|
||||
["next", GeneratorObjectNext,
|
||||
"throw", GeneratorObjectThrow]);
|
||||
%FunctionSetName(GeneratorObjectIterator, '[Symbol.iterator]');
|
||||
%AddProperty(GeneratorObjectPrototype, symbolIterator,
|
||||
%AddNamedProperty(GeneratorObjectPrototype, symbolIterator,
|
||||
GeneratorObjectIterator, DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
%AddProperty(GeneratorObjectPrototype, "constructor",
|
||||
%AddNamedProperty(GeneratorObjectPrototype, "constructor",
|
||||
GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
%SetPrototype(GeneratorFunctionPrototype, $Function.prototype);
|
||||
%SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor);
|
||||
%AddProperty(GeneratorFunctionPrototype, "constructor",
|
||||
%AddNamedProperty(GeneratorFunctionPrototype, "constructor",
|
||||
GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
%SetPrototype(GeneratorFunction, $Function);
|
||||
%SetCode(GeneratorFunction, GeneratorFunctionConstructor);
|
||||
|
26
src/i18n.js
26
src/i18n.js
@ -942,7 +942,7 @@ function initializeCollator(collator, locales, options) {
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
%AddProperty(Intl, 'Collator', function() {
|
||||
%AddNamedProperty(Intl, 'Collator', function() {
|
||||
var locales = %_Arguments(0);
|
||||
var options = %_Arguments(1);
|
||||
|
||||
@ -960,7 +960,7 @@ function initializeCollator(collator, locales, options) {
|
||||
/**
|
||||
* Collator resolvedOptions method.
|
||||
*/
|
||||
%AddProperty(Intl.Collator.prototype, 'resolvedOptions', function() {
|
||||
%AddNamedProperty(Intl.Collator.prototype, 'resolvedOptions', function() {
|
||||
if (%_IsConstructCall()) {
|
||||
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
|
||||
}
|
||||
@ -997,7 +997,7 @@ function initializeCollator(collator, locales, options) {
|
||||
* order in the returned list as in the input list.
|
||||
* Options are optional parameter.
|
||||
*/
|
||||
%AddProperty(Intl.Collator, 'supportedLocalesOf', function(locales) {
|
||||
%AddNamedProperty(Intl.Collator, 'supportedLocalesOf', function(locales) {
|
||||
if (%_IsConstructCall()) {
|
||||
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
|
||||
}
|
||||
@ -1169,7 +1169,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
%AddProperty(Intl, 'NumberFormat', function() {
|
||||
%AddNamedProperty(Intl, 'NumberFormat', function() {
|
||||
var locales = %_Arguments(0);
|
||||
var options = %_Arguments(1);
|
||||
|
||||
@ -1187,7 +1187,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
||||
/**
|
||||
* NumberFormat resolvedOptions method.
|
||||
*/
|
||||
%AddProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
|
||||
%AddNamedProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
|
||||
if (%_IsConstructCall()) {
|
||||
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
|
||||
}
|
||||
@ -1243,7 +1243,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
||||
* order in the returned list as in the input list.
|
||||
* Options are optional parameter.
|
||||
*/
|
||||
%AddProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) {
|
||||
%AddNamedProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) {
|
||||
if (%_IsConstructCall()) {
|
||||
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
|
||||
}
|
||||
@ -1562,7 +1562,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
%AddProperty(Intl, 'DateTimeFormat', function() {
|
||||
%AddNamedProperty(Intl, 'DateTimeFormat', function() {
|
||||
var locales = %_Arguments(0);
|
||||
var options = %_Arguments(1);
|
||||
|
||||
@ -1580,7 +1580,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
|
||||
/**
|
||||
* DateTimeFormat resolvedOptions method.
|
||||
*/
|
||||
%AddProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
|
||||
%AddNamedProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
|
||||
if (%_IsConstructCall()) {
|
||||
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
|
||||
}
|
||||
@ -1636,7 +1636,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
|
||||
* order in the returned list as in the input list.
|
||||
* Options are optional parameter.
|
||||
*/
|
||||
%AddProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) {
|
||||
%AddNamedProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) {
|
||||
if (%_IsConstructCall()) {
|
||||
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
|
||||
}
|
||||
@ -1768,7 +1768,7 @@ function initializeBreakIterator(iterator, locales, options) {
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
%AddProperty(Intl, 'v8BreakIterator', function() {
|
||||
%AddNamedProperty(Intl, 'v8BreakIterator', function() {
|
||||
var locales = %_Arguments(0);
|
||||
var options = %_Arguments(1);
|
||||
|
||||
@ -1786,7 +1786,8 @@ function initializeBreakIterator(iterator, locales, options) {
|
||||
/**
|
||||
* BreakIterator resolvedOptions method.
|
||||
*/
|
||||
%AddProperty(Intl.v8BreakIterator.prototype, 'resolvedOptions', function() {
|
||||
%AddNamedProperty(Intl.v8BreakIterator.prototype, 'resolvedOptions',
|
||||
function() {
|
||||
if (%_IsConstructCall()) {
|
||||
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
|
||||
}
|
||||
@ -1819,7 +1820,8 @@ function initializeBreakIterator(iterator, locales, options) {
|
||||
* order in the returned list as in the input list.
|
||||
* Options are optional parameter.
|
||||
*/
|
||||
%AddProperty(Intl.v8BreakIterator, 'supportedLocalesOf', function(locales) {
|
||||
%AddNamedProperty(Intl.v8BreakIterator, 'supportedLocalesOf',
|
||||
function(locales) {
|
||||
if (%_IsConstructCall()) {
|
||||
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ function SetUpMath() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
%SetPrototype($Math, $Object.prototype);
|
||||
%AddProperty(global, "Math", $Math, DONT_ENUM);
|
||||
%AddNamedProperty(global, "Math", $Math, DONT_ENUM);
|
||||
%FunctionSetInstanceClassName(MathConstructor, 'Math');
|
||||
|
||||
// Set up math constants.
|
||||
|
@ -286,8 +286,8 @@ function MakeGenericError(constructor, type, args) {
|
||||
* Set up the Script function and constructor.
|
||||
*/
|
||||
%FunctionSetInstanceClassName(Script, 'Script');
|
||||
%AddProperty(Script.prototype, 'constructor', Script,
|
||||
DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
%AddNamedProperty(Script.prototype, 'constructor', Script,
|
||||
DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
%SetCode(Script, function(x) {
|
||||
// Script objects can only be created by the VM.
|
||||
throw new $Error("Not supported");
|
||||
@ -1160,9 +1160,9 @@ function SetUpError() {
|
||||
// effects when overwriting the error functions from
|
||||
// user code.
|
||||
var name = f.name;
|
||||
%AddProperty(global, name, f, DONT_ENUM);
|
||||
%AddProperty(builtins, '$' + name, f,
|
||||
DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
%AddNamedProperty(global, name, f, DONT_ENUM);
|
||||
%AddNamedProperty(builtins, '$' + name, f,
|
||||
DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
// Configure the error function.
|
||||
if (name == 'Error') {
|
||||
// The prototype of the Error object must itself be an error.
|
||||
@ -1177,16 +1177,16 @@ function SetUpError() {
|
||||
%FunctionSetPrototype(f, new $Error());
|
||||
}
|
||||
%FunctionSetInstanceClassName(f, 'Error');
|
||||
%AddProperty(f.prototype, 'constructor', f, DONT_ENUM);
|
||||
%AddProperty(f.prototype, "name", name, DONT_ENUM);
|
||||
%AddNamedProperty(f.prototype, 'constructor', f, DONT_ENUM);
|
||||
%AddNamedProperty(f.prototype, "name", name, DONT_ENUM);
|
||||
%SetCode(f, function(m) {
|
||||
if (%_IsConstructCall()) {
|
||||
// Define all the expected properties directly on the error
|
||||
// object. This avoids going through getters and setters defined
|
||||
// on prototype objects.
|
||||
%AddProperty(this, 'stack', UNDEFINED, DONT_ENUM);
|
||||
%AddNamedProperty(this, 'stack', UNDEFINED, DONT_ENUM);
|
||||
if (!IS_UNDEFINED(m)) {
|
||||
%AddProperty(this, 'message', ToString(m), DONT_ENUM);
|
||||
%AddNamedProperty(this, 'message', ToString(m), DONT_ENUM);
|
||||
}
|
||||
try { captureStackTrace(this, f); } catch (e) { }
|
||||
} else {
|
||||
@ -1209,7 +1209,7 @@ SetUpError();
|
||||
|
||||
$Error.captureStackTrace = captureStackTrace;
|
||||
|
||||
%AddProperty($Error.prototype, 'message', '', DONT_ENUM);
|
||||
%AddNamedProperty($Error.prototype, 'message', '', DONT_ENUM);
|
||||
|
||||
// Global list of error objects visited during ErrorToString. This is
|
||||
// used to detect cycles in error toString formatting.
|
||||
|
@ -450,7 +450,8 @@ function ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, type) {
|
||||
|
||||
for (var prop in changeRecord) {
|
||||
if (prop === 'object' || (hasType && prop === 'type')) continue;
|
||||
%AddProperty(newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE);
|
||||
%DefineDataPropertyUnchecked(
|
||||
newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE);
|
||||
}
|
||||
ObjectFreezeJS(newRecord);
|
||||
|
||||
|
@ -325,7 +325,7 @@ var lastMicrotaskId = 0;
|
||||
// Install exported functions.
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
%AddProperty(global, 'Promise', $Promise, DONT_ENUM);
|
||||
%AddNamedProperty(global, 'Promise', $Promise, DONT_ENUM);
|
||||
InstallFunctions($Promise, DONT_ENUM, [
|
||||
"defer", PromiseDeferred,
|
||||
"accept", PromiseResolved,
|
||||
|
@ -381,7 +381,7 @@ var lastMatchInfoOverride = null;
|
||||
function SetUpRegExp() {
|
||||
%CheckIsBootstrapping();
|
||||
%FunctionSetInstanceClassName($RegExp, 'RegExp');
|
||||
%AddProperty($RegExp.prototype, 'constructor', $RegExp, DONT_ENUM);
|
||||
%AddNamedProperty($RegExp.prototype, 'constructor', $RegExp, DONT_ENUM);
|
||||
%SetCode($RegExp, RegExpConstructor);
|
||||
|
||||
InstallFunctions($RegExp.prototype, DONT_ENUM, $Array(
|
||||
|
@ -5195,12 +5195,12 @@ RUNTIME_FUNCTION(Runtime_SetHiddenProperty) {
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_AddProperty) {
|
||||
RUNTIME_FUNCTION(Runtime_AddNamedProperty) {
|
||||
HandleScope scope(isolate);
|
||||
RUNTIME_ASSERT(args.length() == 4);
|
||||
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
|
||||
CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
|
||||
RUNTIME_ASSERT(
|
||||
@ -5210,27 +5210,17 @@ RUNTIME_FUNCTION(Runtime_AddProperty) {
|
||||
static_cast<PropertyAttributes>(unchecked_attributes);
|
||||
|
||||
#ifdef DEBUG
|
||||
bool duplicate;
|
||||
uint32_t index = 0;
|
||||
if (key->IsName() || !key->ToArrayIndex(&index)) {
|
||||
if (key->IsNumber()) {
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key,
|
||||
Execution::ToString(isolate, key));
|
||||
}
|
||||
LookupIterator it(object, Handle<Name>::cast(key),
|
||||
LookupIterator::CHECK_OWN_REAL);
|
||||
JSReceiver::GetPropertyAttributes(&it);
|
||||
duplicate = it.IsFound();
|
||||
} else {
|
||||
duplicate = JSReceiver::HasOwnElement(object, index);
|
||||
}
|
||||
RUNTIME_ASSERT(!duplicate);
|
||||
ASSERT(!key->ToArrayIndex(&index));
|
||||
LookupIterator it(object, key, LookupIterator::CHECK_OWN_REAL);
|
||||
JSReceiver::GetPropertyAttributes(&it);
|
||||
RUNTIME_ASSERT(!it.IsFound());
|
||||
#endif
|
||||
|
||||
Handle<Object> result;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, result,
|
||||
Runtime::DefineObjectProperty(object, key, value, attributes));
|
||||
JSObject::SetOwnPropertyIgnoreAttributes(object, key, value, attributes));
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ namespace internal {
|
||||
F(GlobalProxy, 1, 1) \
|
||||
F(IsAttachedGlobal, 1, 1) \
|
||||
\
|
||||
F(AddProperty, 4, 1) \
|
||||
F(AddNamedProperty, 4, 1) \
|
||||
F(AddPropertyForTemplate, 4, 1) \
|
||||
F(SetProperty, 4, 1) \
|
||||
F(DefineDataPropertyUnchecked, 4, 1) \
|
||||
|
@ -84,8 +84,8 @@ function SetUpStringIterator() {
|
||||
'next', StringIteratorNext
|
||||
));
|
||||
%FunctionSetName(StringIteratorIterator, '[Symbol.iterator]');
|
||||
%AddProperty(StringIterator.prototype, symbolIterator, StringIteratorIterator,
|
||||
DONT_ENUM);
|
||||
%AddNamedProperty(StringIterator.prototype, symbolIterator,
|
||||
StringIteratorIterator, DONT_ENUM);
|
||||
}
|
||||
SetUpStringIterator();
|
||||
|
||||
@ -100,7 +100,7 @@ function ExtendStringPrototypeWithIterator() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
%FunctionSetName(StringPrototypeIterator, '[Symbol.iterator]');
|
||||
%AddProperty($String.prototype, symbolIterator, StringPrototypeIterator,
|
||||
DONT_ENUM);
|
||||
%AddNamedProperty($String.prototype, symbolIterator,
|
||||
StringPrototypeIterator, DONT_ENUM);
|
||||
}
|
||||
ExtendStringPrototypeWithIterator();
|
||||
|
@ -915,7 +915,7 @@ function SetUpString() {
|
||||
%FunctionSetPrototype($String, new $String());
|
||||
|
||||
// Set up the constructor property on the String prototype object.
|
||||
%AddProperty($String.prototype, "constructor", $String, DONT_ENUM);
|
||||
%AddNamedProperty($String.prototype, "constructor", $String, DONT_ENUM);
|
||||
|
||||
// Set up the non-enumerable functions on the String object.
|
||||
InstallFunctions($String, DONT_ENUM, $Array(
|
||||
|
@ -113,7 +113,7 @@ function SetUpSymbol() {
|
||||
"keyFor", SymbolKeyFor
|
||||
));
|
||||
|
||||
%AddProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM);
|
||||
%AddNamedProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM);
|
||||
InstallFunctions($Symbol.prototype, DONT_ENUM, $Array(
|
||||
"toString", SymbolToString,
|
||||
"valueOf", SymbolValueOf
|
||||
|
@ -299,13 +299,13 @@ macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
|
||||
%SetCode(global.NAME, NAMEConstructor);
|
||||
%FunctionSetPrototype(global.NAME, new $Object());
|
||||
|
||||
%AddProperty(global.NAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
|
||||
READ_ONLY | DONT_ENUM | DONT_DELETE);
|
||||
%AddProperty(global.NAME.prototype,
|
||||
"constructor", global.NAME, DONT_ENUM);
|
||||
%AddProperty(global.NAME.prototype,
|
||||
"BYTES_PER_ELEMENT", ELEMENT_SIZE,
|
||||
READ_ONLY | DONT_ENUM | DONT_DELETE);
|
||||
%AddNamedProperty(global.NAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
|
||||
READ_ONLY | DONT_ENUM | DONT_DELETE);
|
||||
%AddNamedProperty(global.NAME.prototype,
|
||||
"constructor", global.NAME, DONT_ENUM);
|
||||
%AddNamedProperty(global.NAME.prototype,
|
||||
"BYTES_PER_ELEMENT", ELEMENT_SIZE,
|
||||
READ_ONLY | DONT_ENUM | DONT_DELETE);
|
||||
InstallGetter(global.NAME.prototype, "buffer", NAME_GetBuffer);
|
||||
InstallGetter(global.NAME.prototype, "byteOffset", NAME_GetByteOffset);
|
||||
InstallGetter(global.NAME.prototype, "byteLength", NAME_GetByteLength);
|
||||
@ -436,7 +436,7 @@ function SetupDataView() {
|
||||
%FunctionSetPrototype($DataView, new $Object);
|
||||
|
||||
// Set up constructor property on the DataView prototype.
|
||||
%AddProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM);
|
||||
%AddNamedProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM);
|
||||
|
||||
InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS);
|
||||
InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset);
|
||||
|
@ -28,7 +28,7 @@ function InstallFunctions(object, attributes, functions) {
|
||||
var f = functions[i + 1];
|
||||
%FunctionSetName(f, key);
|
||||
%FunctionRemovePrototype(f);
|
||||
%AddProperty(object, key, f, attributes);
|
||||
%AddNamedProperty(object, key, f, attributes);
|
||||
%SetNativeFlag(f);
|
||||
}
|
||||
%ToFastProperties(object);
|
||||
@ -65,7 +65,7 @@ function InstallConstants(object, constants) {
|
||||
for (var i = 0; i < constants.length; i += 2) {
|
||||
var name = constants[i];
|
||||
var k = constants[i + 1];
|
||||
%AddProperty(object, name, k, attributes);
|
||||
%AddNamedProperty(object, name, k, attributes);
|
||||
}
|
||||
%ToFastProperties(object);
|
||||
}
|
||||
@ -86,13 +86,14 @@ function SetUpLockedPrototype(constructor, fields, methods) {
|
||||
}
|
||||
if (fields) {
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
%AddProperty(prototype, fields[i], UNDEFINED, DONT_ENUM | DONT_DELETE);
|
||||
%AddNamedProperty(prototype, fields[i],
|
||||
UNDEFINED, DONT_ENUM | DONT_DELETE);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < methods.length; i += 2) {
|
||||
var key = methods[i];
|
||||
var f = methods[i + 1];
|
||||
%AddProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
%AddNamedProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
%SetNativeFlag(f);
|
||||
}
|
||||
%SetPrototype(prototype, null);
|
||||
@ -190,13 +191,13 @@ function SetUpGlobal() {
|
||||
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
|
||||
|
||||
// ECMA 262 - 15.1.1.1.
|
||||
%AddProperty(global, "NaN", NAN, attributes);
|
||||
%AddNamedProperty(global, "NaN", NAN, attributes);
|
||||
|
||||
// ECMA-262 - 15.1.1.2.
|
||||
%AddProperty(global, "Infinity", INFINITY, attributes);
|
||||
%AddNamedProperty(global, "Infinity", INFINITY, attributes);
|
||||
|
||||
// ECMA-262 - 15.1.1.3.
|
||||
%AddProperty(global, "undefined", UNDEFINED, attributes);
|
||||
%AddNamedProperty(global, "undefined", UNDEFINED, attributes);
|
||||
|
||||
// Set up non-enumerable function on the global object.
|
||||
InstallFunctions(global, DONT_ENUM, $Array(
|
||||
@ -386,22 +387,22 @@ function FromGenericPropertyDescriptor(desc) {
|
||||
var obj = new $Object();
|
||||
|
||||
if (desc.hasValue()) {
|
||||
%AddProperty(obj, "value", desc.getValue(), NONE);
|
||||
%AddNamedProperty(obj, "value", desc.getValue(), NONE);
|
||||
}
|
||||
if (desc.hasWritable()) {
|
||||
%AddProperty(obj, "writable", desc.isWritable(), NONE);
|
||||
%AddNamedProperty(obj, "writable", desc.isWritable(), NONE);
|
||||
}
|
||||
if (desc.hasGetter()) {
|
||||
%AddProperty(obj, "get", desc.getGet(), NONE);
|
||||
%AddNamedProperty(obj, "get", desc.getGet(), NONE);
|
||||
}
|
||||
if (desc.hasSetter()) {
|
||||
%AddProperty(obj, "set", desc.getSet(), NONE);
|
||||
%AddNamedProperty(obj, "set", desc.getSet(), NONE);
|
||||
}
|
||||
if (desc.hasEnumerable()) {
|
||||
%AddProperty(obj, "enumerable", desc.isEnumerable(), NONE);
|
||||
%AddNamedProperty(obj, "enumerable", desc.isEnumerable(), NONE);
|
||||
}
|
||||
if (desc.hasConfigurable()) {
|
||||
%AddProperty(obj, "configurable", desc.isConfigurable(), NONE);
|
||||
%AddNamedProperty(obj, "configurable", desc.isConfigurable(), NONE);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
@ -1407,7 +1408,7 @@ function SetUpObject() {
|
||||
%SetNativeFlag($Object);
|
||||
%SetCode($Object, ObjectConstructor);
|
||||
|
||||
%AddProperty($Object.prototype, "constructor", $Object, DONT_ENUM);
|
||||
%AddNamedProperty($Object.prototype, "constructor", $Object, DONT_ENUM);
|
||||
|
||||
// Set up non-enumerable functions on the Object.prototype object.
|
||||
InstallFunctions($Object.prototype, DONT_ENUM, $Array(
|
||||
@ -1494,7 +1495,7 @@ function SetUpBoolean () {
|
||||
|
||||
%SetCode($Boolean, BooleanConstructor);
|
||||
%FunctionSetPrototype($Boolean, new $Boolean(false));
|
||||
%AddProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM);
|
||||
%AddNamedProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM);
|
||||
|
||||
InstallFunctions($Boolean.prototype, DONT_ENUM, $Array(
|
||||
"toString", BooleanToString,
|
||||
@ -1677,7 +1678,7 @@ function SetUpNumber() {
|
||||
|
||||
%OptimizeObjectForAddingMultipleProperties($Number.prototype, 8);
|
||||
// Set up the constructor property on the Number prototype object.
|
||||
%AddProperty($Number.prototype, "constructor", $Number, DONT_ENUM);
|
||||
%AddNamedProperty($Number.prototype, "constructor", $Number, DONT_ENUM);
|
||||
|
||||
InstallConstants($Number, $Array(
|
||||
// ECMA-262 section 15.7.3.1.
|
||||
@ -1860,7 +1861,7 @@ function SetUpFunction() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
%SetCode($Function, FunctionConstructor);
|
||||
%AddProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
|
||||
%AddNamedProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
|
||||
|
||||
InstallFunctions($Function.prototype, DONT_ENUM, $Array(
|
||||
"bind", FunctionBind,
|
||||
|
@ -89,7 +89,7 @@ function SetUpWeakMap() {
|
||||
|
||||
%SetCode($WeakMap, WeakMapConstructor);
|
||||
%FunctionSetPrototype($WeakMap, new $Object());
|
||||
%AddProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM);
|
||||
%AddNamedProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM);
|
||||
|
||||
// Set up the non-enumerable functions on the WeakMap prototype object.
|
||||
InstallFunctions($WeakMap.prototype, DONT_ENUM, $Array(
|
||||
@ -169,7 +169,7 @@ function SetUpWeakSet() {
|
||||
|
||||
%SetCode($WeakSet, WeakSetConstructor);
|
||||
%FunctionSetPrototype($WeakSet, new $Object());
|
||||
%AddProperty($WeakSet.prototype, "constructor", $WeakSet, DONT_ENUM);
|
||||
%AddNamedProperty($WeakSet.prototype, "constructor", $WeakSet, DONT_ENUM);
|
||||
|
||||
// Set up the non-enumerable functions on the WeakSet prototype object.
|
||||
InstallFunctions($WeakSet.prototype, DONT_ENUM, $Array(
|
||||
|
@ -21634,7 +21634,7 @@ TEST(AccessCheckThrows) {
|
||||
CheckCorrectThrow("has_own_property(other, 'x')");
|
||||
CheckCorrectThrow("%GetProperty(other, 'x')");
|
||||
CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 0)");
|
||||
CheckCorrectThrow("%AddProperty(other, 'x', 'foo', 1)");
|
||||
CheckCorrectThrow("%AddNamedProperty(other, 'x', 'foo', 1)");
|
||||
CheckCorrectThrow("%DeleteProperty(other, 'x', 0)");
|
||||
CheckCorrectThrow("%DeleteProperty(other, '1', 0)");
|
||||
CheckCorrectThrow("%HasOwnProperty(other, 'x')");
|
||||
|
@ -34,43 +34,43 @@ const NONE = 0;
|
||||
const READ_ONLY = 1;
|
||||
|
||||
// Use DeclareGlobal...
|
||||
%AddProperty(this.__proto__, "a", 1234, NONE);
|
||||
%AddNamedProperty(this.__proto__, "a", 1234, NONE);
|
||||
assertEquals(1234, a);
|
||||
eval("var a = 5678;");
|
||||
assertEquals(5678, a);
|
||||
|
||||
%AddProperty(this.__proto__, "b", 1234, NONE);
|
||||
%AddNamedProperty(this.__proto__, "b", 1234, NONE);
|
||||
assertEquals(1234, b);
|
||||
eval("const b = 5678;");
|
||||
assertEquals(5678, b);
|
||||
|
||||
%AddProperty(this.__proto__, "c", 1234, READ_ONLY);
|
||||
%AddNamedProperty(this.__proto__, "c", 1234, READ_ONLY);
|
||||
assertEquals(1234, c);
|
||||
eval("var c = 5678;");
|
||||
assertEquals(5678, c);
|
||||
|
||||
%AddProperty(this.__proto__, "d", 1234, READ_ONLY);
|
||||
%AddNamedProperty(this.__proto__, "d", 1234, READ_ONLY);
|
||||
assertEquals(1234, d);
|
||||
eval("const d = 5678;");
|
||||
assertEquals(5678, d);
|
||||
|
||||
// Use DeclareContextSlot...
|
||||
%AddProperty(this.__proto__, "x", 1234, NONE);
|
||||
%AddNamedProperty(this.__proto__, "x", 1234, NONE);
|
||||
assertEquals(1234, x);
|
||||
eval("with({}) { var x = 5678; }");
|
||||
assertEquals(5678, x);
|
||||
|
||||
%AddProperty(this.__proto__, "y", 1234, NONE);
|
||||
%AddNamedProperty(this.__proto__, "y", 1234, NONE);
|
||||
assertEquals(1234, y);
|
||||
eval("with({}) { const y = 5678; }");
|
||||
assertEquals(5678, y);
|
||||
|
||||
%AddProperty(this.__proto__, "z", 1234, READ_ONLY);
|
||||
%AddNamedProperty(this.__proto__, "z", 1234, READ_ONLY);
|
||||
assertEquals(1234, z);
|
||||
eval("with({}) { var z = 5678; }");
|
||||
assertEquals(5678, z);
|
||||
|
||||
%AddProperty(this.__proto__, "w", 1234, READ_ONLY);
|
||||
%AddNamedProperty(this.__proto__, "w", 1234, READ_ONLY);
|
||||
assertEquals(1234, w);
|
||||
eval("with({}) { const w = 5678; }");
|
||||
assertEquals(5678, w);
|
||||
|
@ -37,10 +37,10 @@ function func1(){}
|
||||
function func2(){}
|
||||
|
||||
var object = {__proto__:{}};
|
||||
%AddProperty(object, "foo", func1, DONT_ENUM | DONT_DELETE);
|
||||
%AddProperty(object, "bar", func1, DONT_ENUM | READ_ONLY);
|
||||
%AddProperty(object, "baz", func1, DONT_DELETE | READ_ONLY);
|
||||
%AddProperty(object.__proto__, "bif", func1, DONT_ENUM | DONT_DELETE);
|
||||
%AddNamedProperty(object, "foo", func1, DONT_ENUM | DONT_DELETE);
|
||||
%AddNamedProperty(object, "bar", func1, DONT_ENUM | READ_ONLY);
|
||||
%AddNamedProperty(object, "baz", func1, DONT_DELETE | READ_ONLY);
|
||||
%AddNamedProperty(object.__proto__, "bif", func1, DONT_ENUM | DONT_DELETE);
|
||||
object.bif = func2;
|
||||
|
||||
function enumerable(obj) {
|
||||
|
@ -30,10 +30,10 @@
|
||||
DontEnum = 2;
|
||||
|
||||
var o = {};
|
||||
%AddProperty(o, "a", 0, DontEnum);
|
||||
%AddNamedProperty(o, "a", 0, DontEnum);
|
||||
|
||||
var o2 = {};
|
||||
%AddProperty(o2, "a", 0, DontEnum);
|
||||
%AddNamedProperty(o2, "a", 0, DontEnum);
|
||||
|
||||
assertTrue(%HaveSameMap(o, o2));
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY
|
||||
// Flags: --allow-natives-syntax --harmony
|
||||
var _object = new Object();
|
||||
var arg1 = 10;
|
||||
var arg1 = "bla";
|
||||
var _value = new Object();
|
||||
var _unchecked_attributes = 1;
|
||||
%AddProperty(_object, arg1, _value, _unchecked_attributes);
|
||||
%AddNamedProperty(_object, arg1, _value, _unchecked_attributes);
|
@ -211,7 +211,7 @@ _NUMBER_FORMAT = (
|
||||
# Format: "FunctionName": ["arg0", "arg1", ..., argslength].
|
||||
# None means "fall back to autodetected value".
|
||||
CUSTOM_KNOWN_GOOD_INPUT = {
|
||||
"AddProperty": [None, 10, None, None, None],
|
||||
"AddNamedProperty": [None, "\"bla\"", None, None, None],
|
||||
"AddPropertyForTemplate": [None, 10, None, None, None],
|
||||
"Apply": ["function() {}", None, None, None, None, None],
|
||||
"ArrayBufferSliceImpl": [None, None, 0, None],
|
||||
|
Loading…
Reference in New Issue
Block a user