diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc index b33e41fcbc..2c1322adf1 100644 --- a/src/runtime/runtime-object.cc +++ b/src/runtime/runtime-object.cc @@ -543,59 +543,6 @@ RUNTIME_FUNCTION(Runtime_GetProperty) { isolate, Runtime::GetObjectProperty(isolate, receiver_obj, key_obj)); } -RUNTIME_FUNCTION(Runtime_AddNamedProperty) { - HandleScope scope(isolate); - DCHECK_EQ(4, args.length()); - - CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); - CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); - CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); - CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); - -#ifdef DEBUG - uint32_t index = 0; - DCHECK(!name->ToArrayIndex(&index)); - LookupIterator it(object, name, object, LookupIterator::OWN_SKIP_INTERCEPTOR); - Maybe maybe = JSReceiver::GetPropertyAttributes(&it); - if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception(); - DCHECK(!it.IsFound()); -#endif - - RETURN_RESULT_OR_FAILURE(isolate, JSObject::SetOwnPropertyIgnoreAttributes( - object, name, value, attrs)); -} - - -// Adds an element to an array. -// This is used to create an indexed data property into an array. -RUNTIME_FUNCTION(Runtime_AddElement) { - HandleScope scope(isolate); - DCHECK_EQ(3, args.length()); - - CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); - CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); - CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); - - uint32_t index = 0; - CHECK(key->ToArrayIndex(&index)); - -#ifdef DEBUG - LookupIterator it(isolate, object, index, object, - LookupIterator::OWN_SKIP_INTERCEPTOR); - Maybe maybe = JSReceiver::GetPropertyAttributes(&it); - if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception(); - DCHECK(!it.IsFound()); - - if (object->IsJSArray()) { - Handle array = Handle::cast(object); - DCHECK(!JSArray::WouldChangeReadOnlyLength(array, index)); - } -#endif - - RETURN_RESULT_OR_FAILURE(isolate, JSObject::SetOwnElementIgnoreAttributes( - object, index, value, NONE)); -} - RUNTIME_FUNCTION(Runtime_SetKeyedProperty) { HandleScope scope(isolate); DCHECK_EQ(4, args.length()); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 2cafec50b1..60352f9f59 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -277,8 +277,6 @@ namespace internal { #define FOR_EACH_INTRINSIC_OBJECT(F, I) \ F(AddDictionaryProperty, 3, 1) \ - F(AddElement, 3, 1) \ - F(AddNamedProperty, 4, 1) \ F(AddPrivateField, 3, 1) \ F(AllocateHeapNumber, 0, 1) \ F(ClassOf, 1, 1) \ diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index fa6997b7e9..02ab9308d9 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -23503,7 +23503,6 @@ TEST(AccessCheckThrows) { CheckCorrectThrow("has_own_property(other, 'x')"); CheckCorrectThrow("%GetProperty(other, 'x')"); CheckCorrectThrow("%SetKeyedProperty(other, 'x', 'foo', 0)"); - CheckCorrectThrow("%AddNamedProperty(other, 'x', 'foo', 1)"); CheckCorrectThrow("%SetNamedProperty(other, 'y', 'foo', 1)"); STATIC_ASSERT(static_cast(i::LanguageMode::kSloppy) == 0); STATIC_ASSERT(static_cast(i::LanguageMode::kStrict) == 1); diff --git a/test/mjsunit/regress/regress-1199637.js b/test/mjsunit/regress/regress-1199637.js index ae7c5e03f0..763484d850 100644 --- a/test/mjsunit/regress/regress-1199637.js +++ b/test/mjsunit/regress/regress-1199637.js @@ -32,44 +32,53 @@ var NONE = 0; var READ_ONLY = 1; +function AddNamedProperty(object, name, value, attrs) { + Object.defineProperty(object, name, { + value, + configurable: true, + enumerable: true, + writable: (attrs & READ_ONLY) === 0 + }); +} + // Use DeclareGlobal... -%AddNamedProperty(this.__proto__, "a", 1234, NONE); +AddNamedProperty(this.__proto__, "a", 1234, NONE); assertEquals(1234, a); eval("var a = 5678;"); assertEquals(5678, a); -%AddNamedProperty(this.__proto__, "b", 1234, NONE); +AddNamedProperty(this.__proto__, "b", 1234, NONE); assertEquals(1234, b); eval("var b = 5678;"); assertEquals(5678, b); -%AddNamedProperty(this.__proto__, "c", 1234, READ_ONLY); +AddNamedProperty(this.__proto__, "c", 1234, READ_ONLY); assertEquals(1234, c); eval("var c = 5678;"); assertEquals(5678, c); -%AddNamedProperty(this.__proto__, "d", 1234, READ_ONLY); +AddNamedProperty(this.__proto__, "d", 1234, READ_ONLY); assertEquals(1234, d); eval("var d = 5678;"); assertEquals(5678, d); // Use DeclareContextSlot... -%AddNamedProperty(this.__proto__, "x", 1234, NONE); +AddNamedProperty(this.__proto__, "x", 1234, NONE); assertEquals(1234, x); eval("with({}) { var x = 5678; }"); assertEquals(5678, x); -%AddNamedProperty(this.__proto__, "y", 1234, NONE); +AddNamedProperty(this.__proto__, "y", 1234, NONE); assertEquals(1234, y); eval("with({}) { var y = 5678; }"); assertEquals(5678, y); -%AddNamedProperty(this.__proto__, "z", 1234, READ_ONLY); +AddNamedProperty(this.__proto__, "z", 1234, READ_ONLY); assertEquals(1234, z); eval("with({}) { var z = 5678; }"); assertEquals(5678, z); -%AddNamedProperty(this.__proto__, "w", 1234, READ_ONLY); +AddNamedProperty(this.__proto__, "w", 1234, READ_ONLY); assertEquals(1234, w); eval("with({}) { var w = 5678; }"); assertEquals(5678, w); diff --git a/test/mjsunit/regress/regress-334.js b/test/mjsunit/regress/regress-334.js index c52c72aa90..9a20c6ae76 100644 --- a/test/mjsunit/regress/regress-334.js +++ b/test/mjsunit/regress/regress-334.js @@ -33,14 +33,23 @@ var READ_ONLY = 1; var DONT_ENUM = 2; var DONT_DELETE = 4; +function AddNamedProperty(object, name, value, attrs) { + Object.defineProperty(object, name, { + value, + configurable: (attrs & DONT_DELETE) === 0, + enumerable: (attrs & DONT_ENUM) === 0, + writable: (attrs & READ_ONLY) === 0 + }); +} + function func1(){} function func2(){} var object = {__proto__:{}}; -%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); +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) { diff --git a/test/mjsunit/regress/regress-cntl-descriptors-enum.js b/test/mjsunit/regress/regress-cntl-descriptors-enum.js index fd4ac6d6c0..ee30d071db 100644 --- a/test/mjsunit/regress/regress-cntl-descriptors-enum.js +++ b/test/mjsunit/regress/regress-cntl-descriptors-enum.js @@ -27,13 +27,16 @@ // Flags: --allow-natives-syntax --expose-gc -DontEnum = 2; - var o = {}; -%AddNamedProperty(o, "a", 0, DontEnum); +Object.defineProperty(o, "a", { + value: 0, configurable: true, writable: true, enumerable: false +}); var o2 = {}; -%AddNamedProperty(o2, "a", 0, DontEnum); +Object.defineProperty(o2, "a", { + value: 0, configurable: true, writable: true, enumerable: false +}); + assertTrue(%HaveSameMap(o, o2));