From 63431b23d14b287dd8e54bc96b1551ca82aecc87 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Fri, 27 Jun 2014 13:48:37 +0000 Subject: [PATCH] Split SetProperty(...attributes, strictmode) into DefineProperty(...attributes) and SetProperty(...strictmode) BUG= R=rossberg@chromium.org Review URL: https://codereview.chromium.org/351853005 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22064 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 13 +- src/apinatives.js | 22 ++- src/arm/full-codegen-arm.cc | 4 +- src/arm/ic-arm.cc | 3 +- src/arm64/full-codegen-arm64.cc | 4 +- src/array-iterator.js | 12 +- src/array.js | 4 +- src/arraybuffer.js | 2 +- src/bootstrapper.cc | 36 ++--- src/collection-iterator.js | 10 +- src/collection.js | 4 +- src/date.js | 2 +- src/generator.js | 12 +- src/i18n.js | 24 +-- src/ia32/full-codegen-ia32.cc | 4 +- src/ia32/ic-ia32.cc | 6 +- src/ic.cc | 10 +- src/math.js | 2 +- src/messages.js | 30 ++-- src/mips/full-codegen-mips.cc | 4 +- src/object-observe.js | 3 +- src/promise.js | 2 +- src/regexp.js | 66 ++++---- src/runtime.cc | 169 +++++++++------------ src/runtime.h | 21 +-- src/scopeinfo.cc | 6 +- src/string-iterator.js | 4 +- src/string.js | 2 +- src/symbol.js | 2 +- src/typedarray.js | 8 +- src/v8natives.js | 46 +++--- src/weak_collection.js | 4 +- src/x64/full-codegen-x64.cc | 4 +- src/x87/full-codegen-x87.cc | 4 +- test/cctest/test-api.cc | 6 +- test/cctest/test-compiler.cc | 2 +- test/cctest/test-debug.cc | 6 +- test/mjsunit/object-define-property.js | 18 +-- test/mjsunit/regress/regress-1199637.js | 16 +- test/mjsunit/regress/regress-334.js | 8 +- .../regress/regress-cntl-descriptors-enum.js | 4 +- ...eattributesandsetproperty.js => addproperty.js} | 6 +- ...perty.js => defineaccessorpropertyunchecked.js} | 2 +- ...aproperty.js => definedatapropertyunchecked.js} | 2 +- test/mjsunit/runtime-gen/setaccessorproperty.js | 9 -- test/mjsunit/runtime-gen/setproperty.js | 3 +- tools/generate-runtime-tests.py | 11 +- 47 files changed, 298 insertions(+), 344 deletions(-) rename test/mjsunit/runtime-gen/{ignoreattributesandsetproperty.js => addproperty.js} (65%) rename test/mjsunit/runtime-gen/{defineorredefineaccessorproperty.js => defineaccessorpropertyunchecked.js} (81%) rename test/mjsunit/runtime-gen/{defineorredefinedataproperty.js => definedatapropertyunchecked.js} (78%) delete mode 100644 test/mjsunit/runtime-gen/setaccessorproperty.js diff --git a/src/api.cc b/src/api.cc index 92aa745..cd23d93 100644 --- a/src/api.cc +++ b/src/api.cc @@ -3030,6 +3030,9 @@ uint32_t Value::Uint32Value() const { } +// TODO(verwaest): Remove the attribs argument, since it doesn't make sense for +// existing properties. Use ForceSet instead to define or redefine properties +// with specific attributes. bool v8::Object::Set(v8::Handle key, v8::Handle value, v8::PropertyAttribute attribs) { i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); @@ -3041,12 +3044,8 @@ bool v8::Object::Set(v8::Handle key, v8::Handle value, i::Handle value_obj = Utils::OpenHandle(*value); EXCEPTION_PREAMBLE(isolate); has_pending_exception = i::Runtime::SetObjectProperty( - isolate, - self, - key_obj, - value_obj, - static_cast(attribs), - i::SLOPPY).is_null(); + isolate, self, key_obj, value_obj, i::SLOPPY, + static_cast(attribs)).is_null(); EXCEPTION_BAILOUT_CHECK(isolate, false); return true; } @@ -3078,7 +3077,7 @@ bool v8::Object::ForceSet(v8::Handle key, i::Handle key_obj = Utils::OpenHandle(*key); i::Handle value_obj = Utils::OpenHandle(*value); EXCEPTION_PREAMBLE(isolate); - has_pending_exception = i::Runtime::ForceSetObjectProperty( + has_pending_exception = i::Runtime::DefineObjectProperty( self, key_obj, value_obj, diff --git a/src/apinatives.js b/src/apinatives.js index 9bb52e2..50c753e 100644 --- a/src/apinatives.js +++ b/src/apinatives.js @@ -30,10 +30,16 @@ function Instantiate(data, name) { var Constructor = %GetTemplateField(data, kApiConstructorOffset); // Note: Do not directly use a function template as a condition, our // internal ToBoolean doesn't handle that! - var result = typeof Constructor === 'undefined' ? - {} : new (Instantiate(Constructor))(); - ConfigureTemplateInstance(result, data); - result = %ToFastProperties(result); + var result; + if (typeof Constructor === 'undefined') { + result = {}; + ConfigureTemplateInstance(result, data); + } else { + // ConfigureTemplateInstance is implicitly called before calling the API + // constructor in HandleApiCall. + result = new (Instantiate(Constructor))(); + result = %ToFastProperties(result); + } return result; default: throw 'Unknown API tag <' + tag + '>'; @@ -93,15 +99,15 @@ function ConfigureTemplateInstance(obj, data) { var prop_data = properties[i + 2]; var attributes = properties[i + 3]; var value = Instantiate(prop_data, name); - %SetProperty(obj, name, value, attributes); + %AddProperty(obj, name, value, attributes); } else if (length == 4 || length == 5) { // TODO(verwaest): The 5th value used to be access_control. Remove once // the bindings are updated. var name = properties[i + 1]; - var getter = properties[i + 2]; - var setter = properties[i + 3]; + var getter = Instantiate(properties[i + 2]); + var setter = Instantiate(properties[i + 3]); var attribute = properties[i + 4]; - %SetAccessorProperty(obj, name, getter, setter, attribute); + %DefineAccessorPropertyUnchecked(obj, name, getter, setter, attribute); } else { throw "Bad properties array"; } diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index 1f9273b..f1e6380 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -1696,7 +1696,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { if (property->emit_store()) { __ mov(r0, Operand(Smi::FromInt(NONE))); // PropertyAttributes __ push(r0); - __ CallRuntime(Runtime::kSetProperty, 4); + __ CallRuntime(Runtime::kAddProperty, 4); } else { __ Drop(3); } @@ -1734,7 +1734,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { EmitAccessor(it->second->setter); __ mov(r0, Operand(Smi::FromInt(NONE))); __ push(r0); - __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); + __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); } if (expr->has_function()) { diff --git a/src/arm/ic-arm.cc b/src/arm/ic-arm.cc index 85a7cf5..d1cd088 100644 --- a/src/arm/ic-arm.cc +++ b/src/arm/ic-arm.cc @@ -872,11 +872,10 @@ void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, // Push receiver, key and value for runtime call. __ Push(r2, r1, r0); - __ mov(r1, Operand(Smi::FromInt(NONE))); // PropertyAttributes __ mov(r0, Operand(Smi::FromInt(strict_mode))); // Strict mode. __ Push(r1, r0); - __ TailCallRuntime(Runtime::kSetProperty, 5, 1); + __ TailCallRuntime(Runtime::kSetProperty, 4, 1); } diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc index 14c1302..6401d31 100644 --- a/src/arm64/full-codegen-arm64.cc +++ b/src/arm64/full-codegen-arm64.cc @@ -1698,7 +1698,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); __ Mov(x0, Smi::FromInt(NONE)); // PropertyAttributes __ Push(x0); - __ CallRuntime(Runtime::kSetProperty, 4); + __ CallRuntime(Runtime::kAddProperty, 4); } else { VisitForEffect(key); VisitForEffect(value); @@ -1736,7 +1736,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { EmitAccessor(it->second->setter); __ Mov(x10, Smi::FromInt(NONE)); __ Push(x10); - __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); + __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); } if (expr->has_function()) { diff --git a/src/array-iterator.js b/src/array-iterator.js index f1939ea..fb18789 100644 --- a/src/array-iterator.js +++ b/src/array-iterator.js @@ -110,7 +110,7 @@ function SetUpArrayIterator() { 'next', ArrayIteratorNext )); %FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]'); - %SetProperty(ArrayIterator.prototype, symbolIterator, ArrayIteratorIterator, + %AddProperty(ArrayIterator.prototype, symbolIterator, ArrayIteratorIterator, DONT_ENUM); } SetUpArrayIterator(); @@ -125,7 +125,7 @@ function ExtendArrayPrototype() { 'keys', ArrayKeys )); - %SetProperty($Array.prototype, symbolIterator, ArrayValues, DONT_ENUM); + %AddProperty($Array.prototype, symbolIterator, ArrayValues, DONT_ENUM); } ExtendArrayPrototype(); @@ -146,10 +146,10 @@ macro TYPED_ARRAYS(FUNCTION) endmacro macro EXTEND_TYPED_ARRAY(NAME) - %SetProperty($NAME.prototype, 'entries', ArrayEntries, DONT_ENUM); - %SetProperty($NAME.prototype, 'values', ArrayValues, DONT_ENUM); - %SetProperty($NAME.prototype, 'keys', ArrayKeys, DONT_ENUM); - %SetProperty($NAME.prototype, symbolIterator, ArrayValues, DONT_ENUM); + %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); endmacro TYPED_ARRAYS(EXTEND_TYPED_ARRAY) diff --git a/src/array.js b/src/array.js index a16f430..46dbb87 100644 --- a/src/array.js +++ b/src/array.js @@ -445,7 +445,7 @@ function ArrayPush() { for (var i = 0; i < m; i++) { // Use SetProperty rather than a direct keyed store to ensure that the store // site doesn't become poisened with an elements transition KeyedStoreIC. - %SetProperty(array, i+n, %_Arguments(i), 0, kStrictMode); + %SetProperty(array, i+n, %_Arguments(i), kStrictMode); } var new_length = n + m; @@ -1462,7 +1462,7 @@ function SetUpArray() { // Set up non-enumerable constructor property on the Array.prototype // object. - %SetProperty($Array.prototype, "constructor", $Array, DONT_ENUM); + %AddProperty($Array.prototype, "constructor", $Array, DONT_ENUM); // Set up non-enumerable functions on the Array object. InstallFunctions($Array, DONT_ENUM, $Array( diff --git a/src/arraybuffer.js b/src/arraybuffer.js index d1324bb..a34469c 100644 --- a/src/arraybuffer.js +++ b/src/arraybuffer.js @@ -74,7 +74,7 @@ function SetUpArrayBuffer() { %FunctionSetPrototype($ArrayBuffer, new $Object()); // Set up the constructor property on the ArrayBuffer prototype object. - %SetProperty($ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM); + %AddProperty($ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM); InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen); diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 6b4a4f1..8909e25 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -855,11 +855,11 @@ void Genesis::HookUpInnerGlobal(Handle inner_global) { native_context()->set_security_token(*inner_global); static const PropertyAttributes attributes = static_cast(READ_ONLY | DONT_DELETE); - Runtime::ForceSetObjectProperty(builtins_global, - factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("global")), - inner_global, - attributes).Assert(); + Runtime::DefineObjectProperty(builtins_global, + factory()->InternalizeOneByteString( + STATIC_ASCII_VECTOR("global")), + inner_global, + attributes).Assert(); // Set up the reference from the global object to the builtins object. JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); TransferNamedProperties(inner_global_from_snapshot, inner_global); @@ -2669,11 +2669,11 @@ Genesis::Genesis(Isolate* isolate, Utils::OpenHandle(*buffer)->set_should_be_freed(true); v8::Local ta = v8::Uint32Array::New(buffer, 0, num_elems); Handle builtins(native_context()->builtins()); - Runtime::ForceSetObjectProperty(builtins, - factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("rngstate")), - Utils::OpenHandle(*ta), - NONE).Assert(); + Runtime::DefineObjectProperty(builtins, + factory()->InternalizeOneByteString( + STATIC_ASCII_VECTOR("rngstate")), + Utils::OpenHandle(*ta), + NONE).Assert(); // Initialize trigonometric lookup tables and constants. const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); @@ -2688,25 +2688,25 @@ Genesis::Genesis(Isolate* isolate, v8::Local cos_table = v8::Float64Array::New( cos_buffer, 0, TrigonometricLookupTable::table_size()); - Runtime::ForceSetObjectProperty(builtins, - factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("kSinTable")), - Utils::OpenHandle(*sin_table), - NONE).Assert(); - Runtime::ForceSetObjectProperty( + Runtime::DefineObjectProperty(builtins, + factory()->InternalizeOneByteString( + STATIC_ASCII_VECTOR("kSinTable")), + Utils::OpenHandle(*sin_table), + NONE).Assert(); + Runtime::DefineObjectProperty( builtins, factory()->InternalizeOneByteString( STATIC_ASCII_VECTOR("kCosXIntervalTable")), Utils::OpenHandle(*cos_table), NONE).Assert(); - Runtime::ForceSetObjectProperty( + Runtime::DefineObjectProperty( builtins, factory()->InternalizeOneByteString( STATIC_ASCII_VECTOR("kSamples")), factory()->NewHeapNumber( TrigonometricLookupTable::samples()), NONE).Assert(); - Runtime::ForceSetObjectProperty( + Runtime::DefineObjectProperty( builtins, factory()->InternalizeOneByteString( STATIC_ASCII_VECTOR("kIndexConvert")), diff --git a/src/collection-iterator.js b/src/collection-iterator.js index 545a345..b8b304e 100644 --- a/src/collection-iterator.js +++ b/src/collection-iterator.js @@ -75,7 +75,7 @@ function SetUpSetIterator() { )); %FunctionSetName(SetIteratorSymbolIterator, '[Symbol.iterator]'); - %SetProperty(SetIterator.prototype, symbolIterator, + %AddProperty(SetIterator.prototype, symbolIterator, SetIteratorSymbolIterator, DONT_ENUM); } @@ -90,8 +90,7 @@ function ExtendSetPrototype() { 'values', SetValues )); - %SetProperty($Set.prototype, symbolIterator, SetValues, - DONT_ENUM); + %AddProperty($Set.prototype, symbolIterator, SetValues, DONT_ENUM); } ExtendSetPrototype(); @@ -172,7 +171,7 @@ function SetUpMapIterator() { )); %FunctionSetName(MapIteratorSymbolIterator, '[Symbol.iterator]'); - %SetProperty(MapIterator.prototype, symbolIterator, + %AddProperty(MapIterator.prototype, symbolIterator, MapIteratorSymbolIterator, DONT_ENUM); } @@ -188,8 +187,7 @@ function ExtendMapPrototype() { 'values', MapValues )); - %SetProperty($Map.prototype, symbolIterator, MapEntries, - DONT_ENUM); + %AddProperty($Map.prototype, symbolIterator, MapEntries, DONT_ENUM); } ExtendMapPrototype(); diff --git a/src/collection.js b/src/collection.js index 01e7c53..ac12331 100644 --- a/src/collection.js +++ b/src/collection.js @@ -147,7 +147,7 @@ function SetUpSet() { %SetCode($Set, SetConstructor); %FunctionSetPrototype($Set, new $Object()); - %SetProperty($Set.prototype, "constructor", $Set, DONT_ENUM); + %AddProperty($Set.prototype, "constructor", $Set, DONT_ENUM); %FunctionSetLength(SetForEach, 1); @@ -282,7 +282,7 @@ function SetUpMap() { %SetCode($Map, MapConstructor); %FunctionSetPrototype($Map, new $Object()); - %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM); + %AddProperty($Map.prototype, "constructor", $Map, DONT_ENUM); %FunctionSetLength(MapForEach, 1); diff --git a/src/date.js b/src/date.js index c58903c..c4c7f6e 100644 --- a/src/date.js +++ b/src/date.js @@ -763,7 +763,7 @@ function SetUpDate() { )); // Set up non-enumerable constructor property of the Date prototype object. - %SetProperty($Date.prototype, "constructor", $Date, DONT_ENUM); + %AddProperty($Date.prototype, "constructor", $Date, DONT_ENUM); // Set up non-enumerable functions of the Date prototype object and // set their names. diff --git a/src/generator.js b/src/generator.js index a0c2aff..14df131 100644 --- a/src/generator.js +++ b/src/generator.js @@ -63,14 +63,14 @@ function SetUpGenerators() { ["next", GeneratorObjectNext, "throw", GeneratorObjectThrow]); %FunctionSetName(GeneratorObjectIterator, '[Symbol.iterator]'); - %SetProperty(GeneratorObjectPrototype, symbolIterator, GeneratorObjectIterator, - DONT_ENUM | DONT_DELETE | READ_ONLY); - %SetProperty(GeneratorObjectPrototype, "constructor", - GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); + %AddProperty(GeneratorObjectPrototype, symbolIterator, + GeneratorObjectIterator, DONT_ENUM | DONT_DELETE | READ_ONLY); + %AddProperty(GeneratorObjectPrototype, "constructor", + GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY); %SetPrototype(GeneratorFunctionPrototype, $Function.prototype); %SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor); - %SetProperty(GeneratorFunctionPrototype, "constructor", - GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); + %AddProperty(GeneratorFunctionPrototype, "constructor", + GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY); %SetPrototype(GeneratorFunction, $Function); %SetCode(GeneratorFunction, GeneratorFunctionConstructor); } diff --git a/src/i18n.js b/src/i18n.js index 076845b..6dcb86f 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -942,7 +942,7 @@ function initializeCollator(collator, locales, options) { * * @constructor */ -%SetProperty(Intl, 'Collator', function() { +%AddProperty(Intl, 'Collator', function() { var locales = %_Arguments(0); var options = %_Arguments(1); @@ -960,7 +960,7 @@ function initializeCollator(collator, locales, options) { /** * Collator resolvedOptions method. */ -%SetProperty(Intl.Collator.prototype, 'resolvedOptions', function() { +%AddProperty(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. */ -%SetProperty(Intl.Collator, 'supportedLocalesOf', function(locales) { +%AddProperty(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 */ -%SetProperty(Intl, 'NumberFormat', function() { +%AddProperty(Intl, 'NumberFormat', function() { var locales = %_Arguments(0); var options = %_Arguments(1); @@ -1187,7 +1187,7 @@ function initializeNumberFormat(numberFormat, locales, options) { /** * NumberFormat resolvedOptions method. */ -%SetProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() { +%AddProperty(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. */ -%SetProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) { +%AddProperty(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 */ -%SetProperty(Intl, 'DateTimeFormat', function() { +%AddProperty(Intl, 'DateTimeFormat', function() { var locales = %_Arguments(0); var options = %_Arguments(1); @@ -1580,7 +1580,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) { /** * DateTimeFormat resolvedOptions method. */ -%SetProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() { +%AddProperty(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. */ -%SetProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) { +%AddProperty(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 */ -%SetProperty(Intl, 'v8BreakIterator', function() { +%AddProperty(Intl, 'v8BreakIterator', function() { var locales = %_Arguments(0); var options = %_Arguments(1); @@ -1786,7 +1786,7 @@ function initializeBreakIterator(iterator, locales, options) { /** * BreakIterator resolvedOptions method. */ -%SetProperty(Intl.v8BreakIterator.prototype, 'resolvedOptions', function() { +%AddProperty(Intl.v8BreakIterator.prototype, 'resolvedOptions', function() { if (%_IsConstructCall()) { throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); } @@ -1819,7 +1819,7 @@ function initializeBreakIterator(iterator, locales, options) { * order in the returned list as in the input list. * Options are optional parameter. */ -%SetProperty(Intl.v8BreakIterator, 'supportedLocalesOf', function(locales) { +%AddProperty(Intl.v8BreakIterator, 'supportedLocalesOf', function(locales) { if (%_IsConstructCall()) { throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); } diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index 31066f0..89f8dad 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -1647,7 +1647,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); if (property->emit_store()) { __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes - __ CallRuntime(Runtime::kSetProperty, 4); + __ CallRuntime(Runtime::kAddProperty, 4); } else { __ Drop(3); } @@ -1680,7 +1680,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { EmitAccessor(it->second->getter); EmitAccessor(it->second->setter); __ push(Immediate(Smi::FromInt(NONE))); - __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); + __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); } if (expr->has_function()) { diff --git a/src/ia32/ic-ia32.cc b/src/ia32/ic-ia32.cc index f289996..8474432 100644 --- a/src/ia32/ic-ia32.cc +++ b/src/ia32/ic-ia32.cc @@ -1132,12 +1132,11 @@ void StoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, __ push(edx); __ push(ecx); __ push(eax); - __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes __ push(Immediate(Smi::FromInt(strict_mode))); __ push(ebx); // return address // Do tail-call to runtime routine. - __ TailCallRuntime(Runtime::kSetProperty, 5, 1); + __ TailCallRuntime(Runtime::kSetProperty, 4, 1); } @@ -1154,12 +1153,11 @@ void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, __ push(edx); __ push(ecx); __ push(eax); - __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes __ push(Immediate(Smi::FromInt(strict_mode))); // Strict mode. __ push(ebx); // return address // Do tail-call to runtime routine. - __ TailCallRuntime(Runtime::kSetProperty, 5, 1); + __ TailCallRuntime(Runtime::kSetProperty, 4, 1); } diff --git a/src/ic.cc b/src/ic.cc index dff2a1d..b4ef2b8 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -1743,7 +1743,7 @@ MaybeHandle KeyedStoreIC::Store(Handle object, isolate(), result, Runtime::SetObjectProperty( - isolate(), object, key, value, NONE, strict_mode()), + isolate(), object, key, value, strict_mode()), Object); return result; } @@ -1811,7 +1811,7 @@ MaybeHandle KeyedStoreIC::Store(Handle object, isolate(), store_handle, Runtime::SetObjectProperty( - isolate(), object, key, value, NONE, strict_mode()), + isolate(), object, key, value, strict_mode()), Object); } @@ -2143,7 +2143,7 @@ RUNTIME_FUNCTION(StoreIC_Slow) { ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, result, Runtime::SetObjectProperty( - isolate, object, key, value, NONE, strict_mode)); + isolate, object, key, value, strict_mode)); return *result; } @@ -2160,7 +2160,7 @@ RUNTIME_FUNCTION(KeyedStoreIC_Slow) { ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, result, Runtime::SetObjectProperty( - isolate, object, key, value, NONE, strict_mode)); + isolate, object, key, value, strict_mode)); return *result; } @@ -2184,7 +2184,7 @@ RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss) { ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, result, Runtime::SetObjectProperty( - isolate, object, key, value, NONE, strict_mode)); + isolate, object, key, value, strict_mode)); return *result; } diff --git a/src/math.js b/src/math.js index d231c22..679fc5f 100644 --- a/src/math.js +++ b/src/math.js @@ -260,7 +260,7 @@ function SetUpMath() { %CheckIsBootstrapping(); %SetPrototype($Math, $Object.prototype); - %SetProperty(global, "Math", $Math, DONT_ENUM); + %AddProperty(global, "Math", $Math, DONT_ENUM); %FunctionSetInstanceClassName(MathConstructor, 'Math'); // Set up math constants. diff --git a/src/messages.js b/src/messages.js index fd94cc0..8f83a62 100644 --- a/src/messages.js +++ b/src/messages.js @@ -286,7 +286,7 @@ function MakeGenericError(constructor, type, args) { * Set up the Script function and constructor. */ %FunctionSetInstanceClassName(Script, 'Script'); -%SetProperty(Script.prototype, 'constructor', Script, +%AddProperty(Script.prototype, 'constructor', Script, DONT_ENUM | DONT_DELETE | READ_ONLY); %SetCode(Script, function(x) { // Script objects can only be created by the VM. @@ -1148,7 +1148,7 @@ function captureStackTrace(obj, cons_opt) { // holder of this setter, the accessor pair is turned into a data property. var setter = function(v) { // Set data property on the receiver (not necessarily holder). - %DefineOrRedefineDataProperty(this, 'stack', v, NONE); + %DefineDataPropertyUnchecked(this, 'stack', v, NONE); if (this === obj) { // Release context values if holder is the same as the receiver. stack = error_string = UNDEFINED; @@ -1163,14 +1163,14 @@ function captureStackTrace(obj, cons_opt) { // Stack is still a raw array awaiting to be formatted. var result = FormatStackTrace(obj, error_string, GetStackFrames(stack)); // Replace this accessor to return result directly. - %DefineOrRedefineAccessorProperty( + %DefineAccessorPropertyUnchecked( obj, 'stack', function() { return result }, setter, DONT_ENUM); // Release context values. stack = error_string = UNDEFINED; return result; }; - %DefineOrRedefineAccessorProperty(obj, 'stack', getter, setter, DONT_ENUM); + %DefineAccessorPropertyUnchecked(obj, 'stack', getter, setter, DONT_ENUM); } @@ -1185,8 +1185,9 @@ function SetUpError() { // effects when overwriting the error functions from // user code. var name = f.name; - %SetProperty(global, name, f, DONT_ENUM); - %SetProperty(builtins, '$' + name, f, DONT_ENUM | DONT_DELETE | READ_ONLY); + %AddProperty(global, name, f, DONT_ENUM); + %AddProperty(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. @@ -1201,17 +1202,16 @@ function SetUpError() { %FunctionSetPrototype(f, new $Error()); } %FunctionSetInstanceClassName(f, 'Error'); - %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); - %SetProperty(f.prototype, "name", name, DONT_ENUM); + %AddProperty(f.prototype, 'constructor', f, DONT_ENUM); + %AddProperty(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. - %IgnoreAttributesAndSetProperty(this, 'stack', UNDEFINED, DONT_ENUM); + %AddProperty(this, 'stack', UNDEFINED, DONT_ENUM); if (!IS_UNDEFINED(m)) { - %IgnoreAttributesAndSetProperty( - this, 'message', ToString(m), DONT_ENUM); + %AddProperty(this, 'message', ToString(m), DONT_ENUM); } captureStackTrace(this, f); } else { @@ -1234,7 +1234,7 @@ SetUpError(); $Error.captureStackTrace = captureStackTrace; -%SetProperty($Error.prototype, 'message', '', DONT_ENUM); +%AddProperty($Error.prototype, 'message', '', DONT_ENUM); // Global list of error objects visited during ErrorToString. This is // used to detect cycles in error toString formatting. @@ -1311,7 +1311,7 @@ function SetUpStackOverflowBoilerplate() { // Set the 'stack' property on the receiver. If the receiver is the same as // holder of this setter, the accessor pair is turned into a data property. var setter = function(v) { - %DefineOrRedefineDataProperty(this, 'stack', v, NONE); + %DefineDataPropertyUnchecked(this, 'stack', v, NONE); // Tentatively clear the hidden property. If the receiver is the same as // holder, we release the raw stack trace this way. %GetAndClearOverflowedStackTrace(this); @@ -1333,12 +1333,12 @@ function SetUpStackOverflowBoilerplate() { var result = FormatStackTrace(holder, error_string, GetStackFrames(stack)); // Replace this accessor to return result directly. - %DefineOrRedefineAccessorProperty( + %DefineAccessorPropertyUnchecked( holder, 'stack', function() { return result }, setter, DONT_ENUM); return result; }; - %DefineOrRedefineAccessorProperty( + %DefineAccessorPropertyUnchecked( boilerplate, 'stack', getter, setter, DONT_ENUM); return boilerplate; diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index 3a0c256..3c25522 100644 --- a/src/mips/full-codegen-mips.cc +++ b/src/mips/full-codegen-mips.cc @@ -1707,7 +1707,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { if (property->emit_store()) { __ li(a0, Operand(Smi::FromInt(NONE))); // PropertyAttributes. __ push(a0); - __ CallRuntime(Runtime::kSetProperty, 4); + __ CallRuntime(Runtime::kAddProperty, 4); } else { __ Drop(3); } @@ -1744,7 +1744,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { EmitAccessor(it->second->setter); __ li(a0, Operand(Smi::FromInt(NONE))); __ push(a0); - __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); + __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); } if (expr->has_function()) { diff --git a/src/object-observe.js b/src/object-observe.js index 2dfc752..a627757 100644 --- a/src/object-observe.js +++ b/src/object-observe.js @@ -438,8 +438,7 @@ function ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, type) { for (var prop in changeRecord) { if (prop === 'object' || (hasType && prop === 'type')) continue; - %DefineOrRedefineDataProperty(newRecord, prop, changeRecord[prop], - READ_ONLY + DONT_DELETE); + %AddProperty(newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE); } ObjectFreezeJS(newRecord); diff --git a/src/promise.js b/src/promise.js index 710abad..819074e 100644 --- a/src/promise.js +++ b/src/promise.js @@ -299,7 +299,7 @@ var promiseRaw = GLOBAL_PRIVATE("Promise#raw"); // Install exported functions. %CheckIsBootstrapping(); - %SetProperty(global, 'Promise', $Promise, DONT_ENUM); + %AddProperty(global, 'Promise', $Promise, DONT_ENUM); InstallFunctions($Promise, DONT_ENUM, [ "defer", PromiseDeferred, "accept", PromiseResolved, diff --git a/src/regexp.js b/src/regexp.js index 8a805b0..556ca37 100644 --- a/src/regexp.js +++ b/src/regexp.js @@ -381,7 +381,7 @@ var lastMatchInfoOverride = null; function SetUpRegExp() { %CheckIsBootstrapping(); %FunctionSetInstanceClassName($RegExp, 'RegExp'); - %SetProperty($RegExp.prototype, 'constructor', $RegExp, DONT_ENUM); + %AddProperty($RegExp.prototype, 'constructor', $RegExp, DONT_ENUM); %SetCode($RegExp, RegExpConstructor); InstallFunctions($RegExp.prototype, DONT_ENUM, $Array( @@ -406,12 +406,12 @@ function SetUpRegExp() { }; %OptimizeObjectForAddingMultipleProperties($RegExp, 22); - %DefineOrRedefineAccessorProperty($RegExp, 'input', RegExpGetInput, - RegExpSetInput, DONT_DELETE); - %DefineOrRedefineAccessorProperty($RegExp, '$_', RegExpGetInput, - RegExpSetInput, DONT_ENUM | DONT_DELETE); - %DefineOrRedefineAccessorProperty($RegExp, '$input', RegExpGetInput, - RegExpSetInput, DONT_ENUM | DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, 'input', RegExpGetInput, + RegExpSetInput, DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, '$_', RegExpGetInput, + RegExpSetInput, DONT_ENUM | DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, '$input', RegExpGetInput, + RegExpSetInput, DONT_ENUM | DONT_DELETE); // The properties multiline and $* are aliases for each other. When this // value is set in SpiderMonkey, the value it is set to is coerced to a @@ -425,40 +425,40 @@ function SetUpRegExp() { var RegExpGetMultiline = function() { return multiline; }; var RegExpSetMultiline = function(flag) { multiline = flag ? true : false; }; - %DefineOrRedefineAccessorProperty($RegExp, 'multiline', RegExpGetMultiline, - RegExpSetMultiline, DONT_DELETE); - %DefineOrRedefineAccessorProperty($RegExp, '$*', RegExpGetMultiline, - RegExpSetMultiline, - DONT_ENUM | DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, 'multiline', RegExpGetMultiline, + RegExpSetMultiline, DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, '$*', RegExpGetMultiline, + RegExpSetMultiline, + DONT_ENUM | DONT_DELETE); var NoOpSetter = function(ignored) {}; // Static properties set by a successful match. - %DefineOrRedefineAccessorProperty($RegExp, 'lastMatch', RegExpGetLastMatch, - NoOpSetter, DONT_DELETE); - %DefineOrRedefineAccessorProperty($RegExp, '$&', RegExpGetLastMatch, - NoOpSetter, DONT_ENUM | DONT_DELETE); - %DefineOrRedefineAccessorProperty($RegExp, 'lastParen', RegExpGetLastParen, - NoOpSetter, DONT_DELETE); - %DefineOrRedefineAccessorProperty($RegExp, '$+', RegExpGetLastParen, - NoOpSetter, DONT_ENUM | DONT_DELETE); - %DefineOrRedefineAccessorProperty($RegExp, 'leftContext', - RegExpGetLeftContext, NoOpSetter, - DONT_DELETE); - %DefineOrRedefineAccessorProperty($RegExp, '$`', RegExpGetLeftContext, - NoOpSetter, DONT_ENUM | DONT_DELETE); - %DefineOrRedefineAccessorProperty($RegExp, 'rightContext', - RegExpGetRightContext, NoOpSetter, - DONT_DELETE); - %DefineOrRedefineAccessorProperty($RegExp, "$'", RegExpGetRightContext, - NoOpSetter, DONT_ENUM | DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, 'lastMatch', RegExpGetLastMatch, + NoOpSetter, DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, '$&', RegExpGetLastMatch, + NoOpSetter, DONT_ENUM | DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, 'lastParen', RegExpGetLastParen, + NoOpSetter, DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, '$+', RegExpGetLastParen, + NoOpSetter, DONT_ENUM | DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, 'leftContext', + RegExpGetLeftContext, NoOpSetter, + DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, '$`', RegExpGetLeftContext, + NoOpSetter, DONT_ENUM | DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, 'rightContext', + RegExpGetRightContext, NoOpSetter, + DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, "$'", RegExpGetRightContext, + NoOpSetter, DONT_ENUM | DONT_DELETE); for (var i = 1; i < 10; ++i) { - %DefineOrRedefineAccessorProperty($RegExp, '$' + i, - RegExpMakeCaptureGetter(i), NoOpSetter, - DONT_DELETE); + %DefineAccessorPropertyUnchecked($RegExp, '$' + i, + RegExpMakeCaptureGetter(i), NoOpSetter, + DONT_DELETE); } %ToFastProperties($RegExp); } diff --git a/src/runtime.cc b/src/runtime.cc index 831f76d..53f88f1 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -273,8 +273,12 @@ MUST_USE_RESULT static MaybeHandle CreateObjectLiteralBoilerplate( if (key->IsInternalizedString()) { if (Handle::cast(key)->AsArrayIndex(&element_index)) { // Array index as string (uint32). - maybe_result = JSObject::SetOwnElement( - boilerplate, element_index, value, SLOPPY); + if (value->IsUninitialized()) { + maybe_result = value; + } else { + maybe_result = JSObject::SetOwnElement( + boilerplate, element_index, value, SLOPPY); + } } else { Handle name(String::cast(*key)); ASSERT(!name->AsArrayIndex(&element_index)); @@ -284,8 +288,12 @@ MUST_USE_RESULT static MaybeHandle CreateObjectLiteralBoilerplate( } } else if (key->ToArrayIndex(&element_index)) { // Array index (uint32). - maybe_result = JSObject::SetOwnElement( - boilerplate, element_index, value, SLOPPY); + if (value->IsUninitialized()) { + maybe_result = value; + } else { + maybe_result = JSObject::SetOwnElement( + boilerplate, element_index, value, SLOPPY); + } } else { // Non-uint32 number. ASSERT(key->IsNumber()); @@ -2097,37 +2105,6 @@ RUNTIME_FUNCTION(Runtime_EnableAccessChecks) { } -// Transform getter or setter into something DefineAccessor can handle. -static Handle InstantiateAccessorComponent(Isolate* isolate, - Handle component) { - if (component->IsUndefined()) return isolate->factory()->null_value(); - Handle info = - Handle::cast(component); - return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); -} - - -RUNTIME_FUNCTION(Runtime_SetAccessorProperty) { - HandleScope scope(isolate); - ASSERT(args.length() == 5); - CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); - CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); - CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); - CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); - CONVERT_SMI_ARG_CHECKED(attribute, 4); - RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo()); - RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo()); - RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid( - static_cast(attribute))); - JSObject::DefineAccessor(object, - name, - InstantiateAccessorComponent(isolate, getter), - InstantiateAccessorComponent(isolate, setter), - static_cast(attribute)); - return isolate->heap()->undefined_value(); -} - - static Object* ThrowRedeclarationError(Isolate* isolate, Handle name) { HandleScope scope(isolate); Handle args[1] = { name }; @@ -5039,7 +5016,7 @@ static bool IsValidAccessor(Handle obj) { // Steps 9c & 12 - replace an existing data property with an accessor property. // Step 12 - update an existing accessor property with an accessor or generic // descriptor. -RUNTIME_FUNCTION(Runtime_DefineOrRedefineAccessorProperty) { +RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) { HandleScope scope(isolate); ASSERT(args.length() == 5); CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); @@ -5068,7 +5045,7 @@ RUNTIME_FUNCTION(Runtime_DefineOrRedefineAccessorProperty) { // Steps 9b & 12 - replace an existing accessor property with a data property. // Step 12 - update an existing data property with a data or generic // descriptor. -RUNTIME_FUNCTION(Runtime_DefineOrRedefineDataProperty) { +RUNTIME_FUNCTION(Runtime_DefineDataPropertyUnchecked) { HandleScope scope(isolate); ASSERT(args.length() == 4); CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0); @@ -5126,7 +5103,7 @@ RUNTIME_FUNCTION(Runtime_DefineOrRedefineDataProperty) { Handle result; ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, result, - Runtime::ForceSetObjectProperty( + Runtime::DefineObjectProperty( js_object, name, obj_value, attr, JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED)); return *result; @@ -5147,10 +5124,8 @@ MaybeHandle Runtime::SetObjectProperty(Isolate* isolate, Handle object, Handle key, Handle value, - PropertyAttributes attr, - StrictMode strict_mode) { - SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY; - + StrictMode strict_mode, + PropertyAttributes attrs) { if (object->IsUndefined() || object->IsNull()) { Handle args[2] = { key, object }; Handle error = @@ -5169,8 +5144,7 @@ MaybeHandle Runtime::SetObjectProperty(Isolate* isolate, } Handle name = Handle::cast(name_object); return JSReceiver::SetProperty(Handle::cast(object), name, value, - attr, - strict_mode); + attrs, strict_mode); } // If the object isn't a JavaScript object, we ignore the store. @@ -5202,7 +5176,7 @@ MaybeHandle Runtime::SetObjectProperty(Isolate* isolate, } MaybeHandle result = JSObject::SetElement( - js_object, index, value, attr, strict_mode, true, set_mode); + js_object, index, value, attrs, strict_mode, true, SET_PROPERTY); JSObject::ValidateElements(js_object); return result.is_null() ? result : value; @@ -5217,11 +5191,12 @@ MaybeHandle Runtime::SetObjectProperty(Isolate* isolate, isolate, value, Execution::ToNumber(isolate, value), Object); } } - return JSObject::SetElement(js_object, index, value, attr, - strict_mode, true, set_mode); + return JSObject::SetElement(js_object, index, value, attrs, + strict_mode, true, SET_PROPERTY); } else { if (name->IsString()) name = String::Flatten(Handle::cast(name)); - return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); + return JSReceiver::SetProperty( + js_object, name, value, attrs, strict_mode); } } @@ -5232,15 +5207,15 @@ MaybeHandle Runtime::SetObjectProperty(Isolate* isolate, Handle name = Handle::cast(converted); if (name->AsArrayIndex(&index)) { - return JSObject::SetElement(js_object, index, value, attr, - strict_mode, true, set_mode); + return JSObject::SetElement(js_object, index, value, attrs, + strict_mode, true, SET_PROPERTY); } else { - return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); + return JSReceiver::SetProperty(js_object, name, value, attrs, strict_mode); } } -MaybeHandle Runtime::ForceSetObjectProperty( +MaybeHandle Runtime::DefineObjectProperty( Handle js_object, Handle key, Handle value, @@ -5345,11 +5320,11 @@ RUNTIME_FUNCTION(Runtime_SetHiddenProperty) { } -RUNTIME_FUNCTION(Runtime_SetProperty) { +RUNTIME_FUNCTION(Runtime_AddProperty) { HandleScope scope(isolate); - RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); + RUNTIME_ASSERT(args.length() == 4); - CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); + CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); @@ -5359,17 +5334,41 @@ RUNTIME_FUNCTION(Runtime_SetProperty) { PropertyAttributes attributes = static_cast(unchecked_attributes); - StrictMode strict_mode = SLOPPY; - if (args.length() == 5) { - CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 4); - strict_mode = strict_mode_arg; +#ifdef DEBUG + if (key->IsName()) { + LookupIterator it(object, Handle::cast(key), + LookupIterator::CHECK_OWN); + JSReceiver::GetPropertyAttributes(&it); + RUNTIME_ASSERT(!it.IsFound()); + } else { + uint32_t index = 0; + RUNTIME_ASSERT(key->ToArrayIndex(&index)); + RUNTIME_ASSERT(!JSReceiver::HasOwnElement(object, index)); } +#endif Handle result; ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, result, - Runtime::SetObjectProperty( - isolate, object, key, value, attributes, strict_mode)); + Runtime::DefineObjectProperty(object, key, value, attributes)); + return *result; +} + + +RUNTIME_FUNCTION(Runtime_SetProperty) { + HandleScope scope(isolate); + RUNTIME_ASSERT(args.length() == 4); + + CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); + CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); + CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); + CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 3); + StrictMode strict_mode = strict_mode_arg; + + Handle result; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, result, + Runtime::SetObjectProperty(isolate, object, key, value, strict_mode)); return *result; } @@ -5523,32 +5522,6 @@ RUNTIME_FUNCTION(Runtime_DebugPromiseHandleEpilogue) { } -// Set an own property, even if it is READ_ONLY. If the property does not -// exist, it will be added with attributes NONE. -RUNTIME_FUNCTION(Runtime_IgnoreAttributesAndSetProperty) { - HandleScope scope(isolate); - RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); - CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); - CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); - CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); - // Compute attributes. - PropertyAttributes attributes = NONE; - if (args.length() == 4) { - CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); - // Only attribute bits should be set. - RUNTIME_ASSERT( - (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); - attributes = static_cast(unchecked_value); - } - Handle result; - ASSIGN_RETURN_FAILURE_ON_EXCEPTION( - isolate, result, - JSObject::SetOwnPropertyIgnoreAttributes( - object, name, value, attributes)); - return *result; -} - - RUNTIME_FUNCTION(Runtime_DeleteProperty) { HandleScope scope(isolate); ASSERT(args.length() == 3); @@ -11418,7 +11391,7 @@ static MaybeHandle MaterializeStackLocalsWithFrameInspector( RETURN_ON_EXCEPTION( isolate, - Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), + Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY), JSObject); } @@ -11431,7 +11404,7 @@ static MaybeHandle MaterializeStackLocalsWithFrameInspector( RETURN_ON_EXCEPTION( isolate, - Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), + Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY), JSObject); } @@ -11520,8 +11493,7 @@ MUST_USE_RESULT static MaybeHandle MaterializeLocalContext( isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); RETURN_ON_EXCEPTION( isolate, - Runtime::SetObjectProperty( - isolate, target, key, value, NONE, SLOPPY), + Runtime::SetObjectProperty(isolate, target, key, value, SLOPPY), JSObject); } } @@ -11626,7 +11598,7 @@ static bool SetLocalVariableValue(Isolate* isolate, // We don't expect this to do anything except replacing // property value. Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, - NONE, SLOPPY).Assert(); + SLOPPY).Assert(); return true; } } @@ -11677,8 +11649,7 @@ MUST_USE_RESULT static MaybeHandle MaterializeClosure( isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); RETURN_ON_EXCEPTION( isolate, - Runtime::SetObjectProperty( - isolate, closure_scope, key, value, NONE, SLOPPY), + Runtime::DefineObjectProperty(closure_scope, key, value, NONE), JSObject); } } @@ -11709,8 +11680,8 @@ static bool SetClosureVariableValue(Isolate* isolate, Handle ext(JSObject::cast(context->extension())); if (JSReceiver::HasProperty(ext, variable_name)) { // We don't expect this to do anything except replacing property value. - Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, - NONE, SLOPPY).Assert(); + Runtime::DefineObjectProperty( + ext, variable_name, new_value, NONE).Assert(); return true; } } @@ -11732,8 +11703,7 @@ MUST_USE_RESULT static MaybeHandle MaterializeCatchScope( isolate->factory()->NewJSObject(isolate->object_function()); RETURN_ON_EXCEPTION( isolate, - Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object, - NONE, SLOPPY), + Runtime::DefineObjectProperty(catch_scope, name, thrown_object, NONE), JSObject); return catch_scope; } @@ -12796,8 +12766,7 @@ MUST_USE_RESULT static MaybeHandle MaterializeArgumentsObject( Handle arguments_str = isolate->factory()->arguments_string(); RETURN_ON_EXCEPTION( isolate, - Runtime::SetObjectProperty( - isolate, target, arguments_str, arguments, ::NONE, SLOPPY), + Runtime::DefineObjectProperty(target, arguments_str, arguments, NONE), JSObject); return target; } diff --git a/src/runtime.h b/src/runtime.h index 43a362b..1bd087b 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -206,7 +206,6 @@ namespace internal { F(GetTemplateField, 2, 1) \ F(DisableAccessChecks, 1, 1) \ F(EnableAccessChecks, 1, 1) \ - F(SetAccessorProperty, 5, 1) \ \ /* Dates */ \ F(DateCurrentTime, 0, 1) \ @@ -224,10 +223,10 @@ namespace internal { F(GlobalReceiver, 1, 1) \ F(IsAttachedGlobal, 1, 1) \ \ - F(SetProperty, -1 /* 4 or 5 */, 1) \ - F(DefineOrRedefineDataProperty, 4, 1) \ - F(DefineOrRedefineAccessorProperty, 5, 1) \ - F(IgnoreAttributesAndSetProperty, -1 /* 3 or 4 */, 1) \ + F(AddProperty, 4, 1) \ + F(SetProperty, 4, 1) \ + F(DefineDataPropertyUnchecked, 4, 1) \ + F(DefineAccessorPropertyUnchecked, 5, 1) \ F(GetDataProperty, 2, 1) \ F(SetHiddenProperty, 3, 1) \ \ @@ -800,21 +799,23 @@ class Runtime : public AllStatic { Handle object, uint32_t index); + // Do not use SetObjectProperty to configure a property with specific + // attributes. The argument will be removed once the API is adapted. MUST_USE_RESULT static MaybeHandle SetObjectProperty( Isolate* isolate, Handle object, Handle key, Handle value, - PropertyAttributes attr, - StrictMode strict_mode); + StrictMode strict_mode, + PropertyAttributes attributes = NONE); - MUST_USE_RESULT static MaybeHandle ForceSetObjectProperty( + MUST_USE_RESULT static MaybeHandle DefineObjectProperty( Handle object, Handle key, Handle value, PropertyAttributes attr, - JSReceiver::StoreFromKeyed store_from_keyed - = JSReceiver::MAY_BE_STORE_FROM_KEYED); + JSReceiver::StoreFromKeyed store_from_keyed = + JSReceiver::MAY_BE_STORE_FROM_KEYED); MUST_USE_RESULT static MaybeHandle DeleteObjectProperty( Isolate* isolate, diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc index bce8244..787e647 100644 --- a/src/scopeinfo.cc +++ b/src/scopeinfo.cc @@ -368,13 +368,11 @@ bool ScopeInfo::CopyContextLocalsToScopeObject(Handle scope_info, int context_index = Context::MIN_CONTEXT_SLOTS + i; RETURN_ON_EXCEPTION_VALUE( isolate, - Runtime::SetObjectProperty( - isolate, + Runtime::DefineObjectProperty( scope_object, Handle(String::cast(scope_info->get(i + start))), Handle(context->get(context_index), isolate), - ::NONE, - SLOPPY), + ::NONE), false); } return true; diff --git a/src/string-iterator.js b/src/string-iterator.js index 728f484..7a2309d 100644 --- a/src/string-iterator.js +++ b/src/string-iterator.js @@ -84,7 +84,7 @@ function SetUpStringIterator() { 'next', StringIteratorNext )); %FunctionSetName(StringIteratorIterator, '[Symbol.iterator]'); - %SetProperty(StringIterator.prototype, symbolIterator, StringIteratorIterator, + %AddProperty(StringIterator.prototype, symbolIterator, StringIteratorIterator, DONT_ENUM); } SetUpStringIterator(); @@ -100,7 +100,7 @@ function ExtendStringPrototypeWithIterator() { %CheckIsBootstrapping(); %FunctionSetName(StringPrototypeIterator, '[Symbol.iterator]'); - %SetProperty($String.prototype, symbolIterator, StringPrototypeIterator, + %AddProperty($String.prototype, symbolIterator, StringPrototypeIterator, DONT_ENUM); } ExtendStringPrototypeWithIterator(); diff --git a/src/string.js b/src/string.js index 07cdcc0..d949c644 100644 --- a/src/string.js +++ b/src/string.js @@ -915,7 +915,7 @@ function SetUpString() { %FunctionSetPrototype($String, new $String()); // Set up the constructor property on the String prototype object. - %SetProperty($String.prototype, "constructor", $String, DONT_ENUM); + %AddProperty($String.prototype, "constructor", $String, DONT_ENUM); // Set up the non-enumerable functions on the String object. InstallFunctions($String, DONT_ENUM, $Array( diff --git a/src/symbol.js b/src/symbol.js index 1c48302..c3e2aec 100644 --- a/src/symbol.js +++ b/src/symbol.js @@ -113,7 +113,7 @@ function SetUpSymbol() { "keyFor", SymbolKeyFor )); - %SetProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM); + %AddProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM); InstallFunctions($Symbol.prototype, DONT_ENUM, $Array( "toString", SymbolToString, "valueOf", SymbolValueOf diff --git a/src/typedarray.js b/src/typedarray.js index d2f5ae8..ab5fc5c 100644 --- a/src/typedarray.js +++ b/src/typedarray.js @@ -299,11 +299,11 @@ macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) %SetCode(global.NAME, NAMEConstructor); %FunctionSetPrototype(global.NAME, new $Object()); - %SetProperty(global.NAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, + %AddProperty(global.NAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, READ_ONLY | DONT_ENUM | DONT_DELETE); - %SetProperty(global.NAME.prototype, + %AddProperty(global.NAME.prototype, "constructor", global.NAME, DONT_ENUM); - %SetProperty(global.NAME.prototype, + %AddProperty(global.NAME.prototype, "BYTES_PER_ELEMENT", ELEMENT_SIZE, READ_ONLY | DONT_ENUM | DONT_DELETE); InstallGetter(global.NAME.prototype, "buffer", NAME_GetBuffer); @@ -436,7 +436,7 @@ function SetupDataView() { %FunctionSetPrototype($DataView, new $Object); // Set up constructor property on the DataView prototype. - %SetProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM); + %AddProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM); InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS); InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset); diff --git a/src/v8natives.js b/src/v8natives.js index 1d05338..4f12eec 100644 --- a/src/v8natives.js +++ b/src/v8natives.js @@ -28,7 +28,7 @@ function InstallFunctions(object, attributes, functions) { var f = functions[i + 1]; %FunctionSetName(f, key); %FunctionRemovePrototype(f); - %SetProperty(object, key, f, attributes); + %AddProperty(object, key, f, attributes); %SetNativeFlag(f); } %ToFastProperties(object); @@ -39,7 +39,7 @@ function InstallFunctions(object, attributes, functions) { function InstallGetter(object, name, getter) { %FunctionSetName(getter, name); %FunctionRemovePrototype(getter); - %DefineOrRedefineAccessorProperty(object, name, getter, null, DONT_ENUM); + %DefineAccessorPropertyUnchecked(object, name, getter, null, DONT_ENUM); %SetNativeFlag(getter); } @@ -50,7 +50,7 @@ function InstallGetterSetter(object, name, getter, setter) { %FunctionSetName(setter, name); %FunctionRemovePrototype(getter); %FunctionRemovePrototype(setter); - %DefineOrRedefineAccessorProperty(object, name, getter, setter, DONT_ENUM); + %DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM); %SetNativeFlag(getter); %SetNativeFlag(setter); } @@ -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]; - %SetProperty(object, name, k, attributes); + %AddProperty(object, name, k, attributes); } %ToFastProperties(object); } @@ -86,13 +86,13 @@ function SetUpLockedPrototype(constructor, fields, methods) { } if (fields) { for (var i = 0; i < fields.length; i++) { - %SetProperty(prototype, fields[i], UNDEFINED, DONT_ENUM | DONT_DELETE); + %AddProperty(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]; - %SetProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY); + %AddProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY); %SetNativeFlag(f); } %SetPrototype(prototype, null); @@ -190,13 +190,13 @@ function SetUpGlobal() { var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; // ECMA 262 - 15.1.1.1. - %SetProperty(global, "NaN", NAN, attributes); + %AddProperty(global, "NaN", NAN, attributes); // ECMA-262 - 15.1.1.2. - %SetProperty(global, "Infinity", INFINITY, attributes); + %AddProperty(global, "Infinity", INFINITY, attributes); // ECMA-262 - 15.1.1.3. - %SetProperty(global, "undefined", UNDEFINED, attributes); + %AddProperty(global, "undefined", UNDEFINED, attributes); // Set up non-enumerable function on the global object. InstallFunctions(global, DONT_ENUM, $Array( @@ -386,24 +386,22 @@ function FromGenericPropertyDescriptor(desc) { var obj = new $Object(); if (desc.hasValue()) { - %IgnoreAttributesAndSetProperty(obj, "value", desc.getValue(), NONE); + %AddProperty(obj, "value", desc.getValue(), NONE); } if (desc.hasWritable()) { - %IgnoreAttributesAndSetProperty(obj, "writable", desc.isWritable(), NONE); + %AddProperty(obj, "writable", desc.isWritable(), NONE); } if (desc.hasGetter()) { - %IgnoreAttributesAndSetProperty(obj, "get", desc.getGet(), NONE); + %AddProperty(obj, "get", desc.getGet(), NONE); } if (desc.hasSetter()) { - %IgnoreAttributesAndSetProperty(obj, "set", desc.getSet(), NONE); + %AddProperty(obj, "set", desc.getSet(), NONE); } if (desc.hasEnumerable()) { - %IgnoreAttributesAndSetProperty(obj, "enumerable", - desc.isEnumerable(), NONE); + %AddProperty(obj, "enumerable", desc.isEnumerable(), NONE); } if (desc.hasConfigurable()) { - %IgnoreAttributesAndSetProperty(obj, "configurable", - desc.isConfigurable(), NONE); + %AddProperty(obj, "configurable", desc.isConfigurable(), NONE); } return obj; } @@ -833,7 +831,7 @@ function DefineObjectProperty(obj, p, desc, should_throw) { value = current.getValue(); } - %DefineOrRedefineDataProperty(obj, p, value, flag); + %DefineDataPropertyUnchecked(obj, p, value, flag); } else { // There are 3 cases that lead here: // Step 4b - defining a new accessor property. @@ -843,7 +841,7 @@ function DefineObjectProperty(obj, p, desc, should_throw) { // descriptor. var getter = desc.hasGetter() ? desc.getGet() : null; var setter = desc.hasSetter() ? desc.getSet() : null; - %DefineOrRedefineAccessorProperty(obj, p, getter, setter, flag); + %DefineAccessorPropertyUnchecked(obj, p, getter, setter, flag); } return true; } @@ -901,7 +899,7 @@ function DefineArrayProperty(obj, p, desc, should_throw) { // Make sure the below call to DefineObjectProperty() doesn't overwrite // any magic "length" property by removing the value. // TODO(mstarzinger): This hack should be removed once we have addressed the - // respective TODO in Runtime_DefineOrRedefineDataProperty. + // respective TODO in Runtime_DefineDataPropertyUnchecked. // For the time being, we need a hack to prevent Object.observe from // generating two change records. obj.length = new_length; @@ -1397,7 +1395,7 @@ function SetUpObject() { %SetNativeFlag($Object); %SetCode($Object, ObjectConstructor); - %SetProperty($Object.prototype, "constructor", $Object, DONT_ENUM); + %AddProperty($Object.prototype, "constructor", $Object, DONT_ENUM); // Set up non-enumerable functions on the Object.prototype object. InstallFunctions($Object.prototype, DONT_ENUM, $Array( @@ -1484,7 +1482,7 @@ function SetUpBoolean () { %SetCode($Boolean, BooleanConstructor); %FunctionSetPrototype($Boolean, new $Boolean(false)); - %SetProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM); + %AddProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM); InstallFunctions($Boolean.prototype, DONT_ENUM, $Array( "toString", BooleanToString, @@ -1667,7 +1665,7 @@ function SetUpNumber() { %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8); // Set up the constructor property on the Number prototype object. - %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); + %AddProperty($Number.prototype, "constructor", $Number, DONT_ENUM); InstallConstants($Number, $Array( // ECMA-262 section 15.7.3.1. @@ -1850,7 +1848,7 @@ function SetUpFunction() { %CheckIsBootstrapping(); %SetCode($Function, FunctionConstructor); - %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM); + %AddProperty($Function.prototype, "constructor", $Function, DONT_ENUM); InstallFunctions($Function.prototype, DONT_ENUM, $Array( "bind", FunctionBind, diff --git a/src/weak_collection.js b/src/weak_collection.js index 4c26d25..d61243a 100644 --- a/src/weak_collection.js +++ b/src/weak_collection.js @@ -89,7 +89,7 @@ function SetUpWeakMap() { %SetCode($WeakMap, WeakMapConstructor); %FunctionSetPrototype($WeakMap, new $Object()); - %SetProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM); + %AddProperty($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()); - %SetProperty($WeakSet.prototype, "constructor", $WeakSet, DONT_ENUM); + %AddProperty($WeakSet.prototype, "constructor", $WeakSet, DONT_ENUM); // Set up the non-enumerable functions on the WeakSet prototype object. InstallFunctions($WeakSet.prototype, DONT_ENUM, $Array( diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index 67c959f..b9c26a3 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -1680,7 +1680,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); if (property->emit_store()) { __ Push(Smi::FromInt(NONE)); // PropertyAttributes - __ CallRuntime(Runtime::kSetProperty, 4); + __ CallRuntime(Runtime::kAddProperty, 4); } else { __ Drop(3); } @@ -1713,7 +1713,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { EmitAccessor(it->second->getter); EmitAccessor(it->second->setter); __ Push(Smi::FromInt(NONE)); - __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); + __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); } if (expr->has_function()) { diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc index 37d4c1e..6837483 100644 --- a/src/x87/full-codegen-x87.cc +++ b/src/x87/full-codegen-x87.cc @@ -1644,7 +1644,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); if (property->emit_store()) { __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes - __ CallRuntime(Runtime::kSetProperty, 4); + __ CallRuntime(Runtime::kAddProperty, 4); } else { __ Drop(3); } @@ -1677,7 +1677,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { EmitAccessor(it->second->getter); EmitAccessor(it->second->setter); __ push(Immediate(Smi::FromInt(NONE))); - __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); + __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); } if (expr->has_function()) { diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 4837cff..7d251f2 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -21719,8 +21719,8 @@ TEST(AccessCheckThrows) { CheckCorrectThrow("JSON.stringify(other)"); CheckCorrectThrow("has_own_property(other, 'x')"); CheckCorrectThrow("%GetProperty(other, 'x')"); - CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 1, 0)"); - CheckCorrectThrow("%IgnoreAttributesAndSetProperty(other, 'x', 'foo')"); + CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 0)"); + CheckCorrectThrow("%AddProperty(other, 'x', 'foo', 1)"); CheckCorrectThrow("%DeleteProperty(other, 'x', 0)"); CheckCorrectThrow("%DeleteProperty(other, '1', 0)"); CheckCorrectThrow("%HasOwnProperty(other, 'x')"); @@ -21730,7 +21730,7 @@ TEST(AccessCheckThrows) { CheckCorrectThrow("%GetPropertyNames(other)"); // PROPERTY_ATTRIBUTES_NONE = 0 CheckCorrectThrow("%GetOwnPropertyNames(other, 0)"); - CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" + CheckCorrectThrow("%DefineAccessorPropertyUnchecked(" "other, 'x', null, null, 1)"); // Reset the failed access check callback so it does not influence diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc index cd537b5..5384dcc 100644 --- a/test/cctest/test-compiler.cc +++ b/test/cctest/test-compiler.cc @@ -49,7 +49,7 @@ static void SetGlobalProperty(const char* name, Object* value) { Handle internalized_name = isolate->factory()->InternalizeUtf8String(name); Handle global(isolate->context()->global_object()); - Runtime::SetObjectProperty(isolate, global, internalized_name, object, NONE, + Runtime::SetObjectProperty(isolate, global, internalized_name, object, SLOPPY).Check(); } diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index 364229c..a539d73 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -109,10 +109,8 @@ class DebugLocalContext { v8::Utils::OpenHandle(*context_->Global()))); Handle debug_string = factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug")); - v8::internal::Runtime::SetObjectProperty(isolate, global, debug_string, - Handle(debug_context->global_proxy(), isolate), - DONT_ENUM, - ::v8::internal::SLOPPY).Check(); + v8::internal::Runtime::DefineObjectProperty(global, debug_string, + handle(debug_context->global_proxy(), isolate), DONT_ENUM).Check(); } private: diff --git a/test/mjsunit/object-define-property.js b/test/mjsunit/object-define-property.js index cbb2d21..ebdf899 100644 --- a/test/mjsunit/object-define-property.js +++ b/test/mjsunit/object-define-property.js @@ -467,35 +467,35 @@ try { } -// Test runtime calls to DefineOrRedefineDataProperty and -// DefineOrRedefineAccessorProperty - make sure we don't +// Test runtime calls to DefineDataPropertyUnchecked and +// DefineAccessorPropertyUnchecked - make sure we don't // crash. try { - %DefineOrRedefineAccessorProperty(0, 0, 0, 0, 0); + %DefineAccessorPropertyUnchecked(0, 0, 0, 0, 0); } catch (e) { assertTrue(/illegal access/.test(e)); } try { - %DefineOrRedefineDataProperty(0, 0, 0, 0); + %DefineDataPropertyUnchecked(0, 0, 0, 0); } catch (e) { assertTrue(/illegal access/.test(e)); } try { - %DefineOrRedefineDataProperty(null, null, null, null); + %DefineDataPropertyUnchecked(null, null, null, null); } catch (e) { assertTrue(/illegal access/.test(e)); } try { - %DefineOrRedefineAccessorProperty(null, null, null, null, null); + %DefineAccessorPropertyUnchecked(null, null, null, null, null); } catch (e) { assertTrue(/illegal access/.test(e)); } try { - %DefineOrRedefineDataProperty({}, null, null, null); + %DefineDataPropertyUnchecked({}, null, null, null); } catch (e) { assertTrue(/illegal access/.test(e)); } @@ -503,13 +503,13 @@ try { // Defining properties null should fail even when we have // other allowed values try { - %DefineOrRedefineAccessorProperty(null, 'foo', func, null, 0); + %DefineAccessorPropertyUnchecked(null, 'foo', func, null, 0); } catch (e) { assertTrue(/illegal access/.test(e)); } try { - %DefineOrRedefineDataProperty(null, 'foo', 0, 0); + %DefineDataPropertyUnchecked(null, 'foo', 0, 0); } catch (e) { assertTrue(/illegal access/.test(e)); } diff --git a/test/mjsunit/regress/regress-1199637.js b/test/mjsunit/regress/regress-1199637.js index 8b02a65..3db4855 100644 --- a/test/mjsunit/regress/regress-1199637.js +++ b/test/mjsunit/regress/regress-1199637.js @@ -34,43 +34,43 @@ const NONE = 0; const READ_ONLY = 1; // Use DeclareGlobal... -%SetProperty(this.__proto__, "a", 1234, NONE); +%AddProperty(this.__proto__, "a", 1234, NONE); assertEquals(1234, a); eval("var a = 5678;"); assertEquals(5678, a); -%SetProperty(this.__proto__, "b", 1234, NONE); +%AddProperty(this.__proto__, "b", 1234, NONE); assertEquals(1234, b); eval("const b = 5678;"); assertEquals(5678, b); -%SetProperty(this.__proto__, "c", 1234, READ_ONLY); +%AddProperty(this.__proto__, "c", 1234, READ_ONLY); assertEquals(1234, c); eval("var c = 5678;"); assertEquals(5678, c); -%SetProperty(this.__proto__, "d", 1234, READ_ONLY); +%AddProperty(this.__proto__, "d", 1234, READ_ONLY); assertEquals(1234, d); eval("const d = 5678;"); assertEquals(5678, d); // Use DeclareContextSlot... -%SetProperty(this.__proto__, "x", 1234, NONE); +%AddProperty(this.__proto__, "x", 1234, NONE); assertEquals(1234, x); eval("with({}) { var x = 5678; }"); assertEquals(5678, x); -%SetProperty(this.__proto__, "y", 1234, NONE); +%AddProperty(this.__proto__, "y", 1234, NONE); assertEquals(1234, y); eval("with({}) { const y = 5678; }"); assertEquals(5678, y); -%SetProperty(this.__proto__, "z", 1234, READ_ONLY); +%AddProperty(this.__proto__, "z", 1234, READ_ONLY); assertEquals(1234, z); eval("with({}) { var z = 5678; }"); assertEquals(5678, z); -%SetProperty(this.__proto__, "w", 1234, READ_ONLY); +%AddProperty(this.__proto__, "w", 1234, READ_ONLY); assertEquals(1234, w); eval("with({}) { const w = 5678; }"); assertEquals(5678, w); diff --git a/test/mjsunit/regress/regress-334.js b/test/mjsunit/regress/regress-334.js index 37dd299..2a001d3 100644 --- a/test/mjsunit/regress/regress-334.js +++ b/test/mjsunit/regress/regress-334.js @@ -37,10 +37,10 @@ function func1(){} function func2(){} var object = {__proto__:{}}; -%SetProperty(object, "foo", func1, DONT_ENUM | DONT_DELETE); -%SetProperty(object, "bar", func1, DONT_ENUM | READ_ONLY); -%SetProperty(object, "baz", func1, DONT_DELETE | READ_ONLY); -%SetProperty(object.__proto__, "bif", func1, DONT_ENUM | DONT_DELETE); +%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); object.bif = func2; function enumerable(obj) { diff --git a/test/mjsunit/regress/regress-cntl-descriptors-enum.js b/test/mjsunit/regress/regress-cntl-descriptors-enum.js index ee72faf..861ab27 100644 --- a/test/mjsunit/regress/regress-cntl-descriptors-enum.js +++ b/test/mjsunit/regress/regress-cntl-descriptors-enum.js @@ -30,10 +30,10 @@ DontEnum = 2; var o = {}; -%SetProperty(o, "a", 0, DontEnum); +%AddProperty(o, "a", 0, DontEnum); var o2 = {}; -%SetProperty(o2, "a", 0, DontEnum); +%AddProperty(o2, "a", 0, DontEnum); assertTrue(%HaveSameMap(o, o2)); diff --git a/test/mjsunit/runtime-gen/ignoreattributesandsetproperty.js b/test/mjsunit/runtime-gen/addproperty.js similarity index 65% rename from test/mjsunit/runtime-gen/ignoreattributesandsetproperty.js rename to test/mjsunit/runtime-gen/addproperty.js index 0c82809..48b985d 100644 --- a/test/mjsunit/runtime-gen/ignoreattributesandsetproperty.js +++ b/test/mjsunit/runtime-gen/addproperty.js @@ -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 _name = "name"; +var arg1 = 10; var _value = new Object(); -var _unchecked_value = 1; -%IgnoreAttributesAndSetProperty(_object, _name, _value, _unchecked_value); +var _unchecked_attributes = 1; +%AddProperty(_object, arg1, _value, _unchecked_attributes); diff --git a/test/mjsunit/runtime-gen/defineorredefineaccessorproperty.js b/test/mjsunit/runtime-gen/defineaccessorpropertyunchecked.js similarity index 81% rename from test/mjsunit/runtime-gen/defineorredefineaccessorproperty.js rename to test/mjsunit/runtime-gen/defineaccessorpropertyunchecked.js index 5eb6f24..0155ee9 100644 --- a/test/mjsunit/runtime-gen/defineorredefineaccessorproperty.js +++ b/test/mjsunit/runtime-gen/defineaccessorpropertyunchecked.js @@ -6,4 +6,4 @@ var _name = "name"; var arg2 = function() {}; var arg3 = function() {}; var arg4 = 2; -%DefineOrRedefineAccessorProperty(_obj, _name, arg2, arg3, arg4); +%DefineAccessorPropertyUnchecked(_obj, _name, arg2, arg3, arg4); diff --git a/test/mjsunit/runtime-gen/defineorredefinedataproperty.js b/test/mjsunit/runtime-gen/definedatapropertyunchecked.js similarity index 78% rename from test/mjsunit/runtime-gen/defineorredefinedataproperty.js rename to test/mjsunit/runtime-gen/definedatapropertyunchecked.js index 64f8b98..ffa88aa 100644 --- a/test/mjsunit/runtime-gen/defineorredefinedataproperty.js +++ b/test/mjsunit/runtime-gen/definedatapropertyunchecked.js @@ -5,4 +5,4 @@ var _js_object = new Object(); var _name = "name"; var _obj_value = new Object(); var _unchecked = 1; -%DefineOrRedefineDataProperty(_js_object, _name, _obj_value, _unchecked); +%DefineDataPropertyUnchecked(_js_object, _name, _obj_value, _unchecked); diff --git a/test/mjsunit/runtime-gen/setaccessorproperty.js b/test/mjsunit/runtime-gen/setaccessorproperty.js deleted file mode 100644 index bcf2a34..0000000 --- a/test/mjsunit/runtime-gen/setaccessorproperty.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony -var _object = new Object(); -var _name = "name"; -var arg2 = undefined; -var arg3 = undefined; -var _attribute = 1; -%SetAccessorProperty(_object, _name, arg2, arg3, _attribute); diff --git a/test/mjsunit/runtime-gen/setproperty.js b/test/mjsunit/runtime-gen/setproperty.js index bec3ad8..396b0e7 100644 --- a/test/mjsunit/runtime-gen/setproperty.js +++ b/test/mjsunit/runtime-gen/setproperty.js @@ -4,6 +4,5 @@ var _object = new Object(); var _key = new Object(); var _value = new Object(); -var _unchecked_attributes = 1; var _strict_mode_arg = 1; -%SetProperty(_object, _key, _value, _unchecked_attributes, _strict_mode_arg); +%SetProperty(_object, _key, _value, _strict_mode_arg); diff --git a/tools/generate-runtime-tests.py b/tools/generate-runtime-tests.py index 6c6503e..9740b37 100755 --- a/tools/generate-runtime-tests.py +++ b/tools/generate-runtime-tests.py @@ -47,8 +47,8 @@ EXPAND_MACROS = [ # that the parser doesn't bit-rot. Change the values as needed when you add, # remove or change runtime functions, but make sure we don't lose our ability # to parse them! -EXPECTED_FUNCTION_COUNT = 415 -EXPECTED_FUZZABLE_COUNT = 330 +EXPECTED_FUNCTION_COUNT = 414 +EXPECTED_FUZZABLE_COUNT = 329 EXPECTED_CCTEST_COUNT = 6 EXPECTED_UNKNOWN_COUNT = 4 EXPECTED_BUILTINS_COUNT = 806 @@ -211,6 +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], "Apply": ["function() {}", None, None, None, None, None], "ArrayBufferSliceImpl": [None, None, 0, None], "ArrayConcat": ["[1, 'a']", None], @@ -225,8 +226,8 @@ CUSTOM_KNOWN_GOOD_INPUT = { "CreatePrivateSymbol": ["\"foo\"", None], "CreateSymbol": ["\"foo\"", None], "DateParseString": [None, "new Array(8)", None], - "DefineOrRedefineAccessorProperty": [None, None, "function() {}", - "function() {}", 2, None], + "DefineAccessorPropertyUnchecked": [None, None, "function() {}", + "function() {}", 2, None], "FunctionBindArguments": [None, None, "undefined", None, None], "GetBreakLocations": [None, 0, None], "GetDefaultReceiver": ["function() {}", None], @@ -242,7 +243,7 @@ CUSTOM_KNOWN_GOOD_INPUT = { "NumberToRadixString": [None, "2", None], "ParseJson": ["\"{}\"", 1], "RegExpExecMultiple": [None, None, "['a']", "['a']", None], - "SetAccessorProperty": [None, None, "undefined", "undefined", None, None], + "DefineAccessorProperty": [None, None, "undefined", "undefined", None, None], "SetIteratorInitialize": [None, None, "2", None], "SetDebugEventListener": ["undefined", None, None], "SetFunctionBreakPoint": [None, 200, None, None], -- 2.7.4