From: mstarzinger@chromium.org Date: Mon, 26 May 2014 11:42:56 +0000 (+0000) Subject: Make 'name' property on functions configurable. X-Git-Tag: upstream/4.7.83~8976 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=82b3b2a36711eee4dbb5414b1c37bbdf2d27daef;p=platform%2Fupstream%2Fv8.git Make 'name' property on functions configurable. R=rossberg@chromium.org BUG=v8:3333 LOG=N Review URL: https://codereview.chromium.org/296413003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21492 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 0243a3a..76b693d 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -386,45 +386,47 @@ void Genesis::SetFunctionInstanceDescriptor( int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; Map::EnsureDescriptorSlack(map, size); - PropertyAttributes attribs = static_cast( - DONT_ENUM | DONT_DELETE | READ_ONLY); + PropertyAttributes ro_attribs = + static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); + PropertyAttributes roc_attribs = + static_cast(DONT_ENUM | READ_ONLY); Handle length = - Accessors::FunctionLengthInfo(isolate(), attribs); + Accessors::FunctionLengthInfo(isolate(), ro_attribs); { // Add length. CallbacksDescriptor d(Handle(Name::cast(length->name())), - length, attribs); + length, ro_attribs); map->AppendDescriptor(&d); } Handle name = - Accessors::FunctionNameInfo(isolate(), attribs); + Accessors::FunctionNameInfo(isolate(), roc_attribs); { // Add name. CallbacksDescriptor d(Handle(Name::cast(name->name())), - name, attribs); + name, roc_attribs); map->AppendDescriptor(&d); } Handle args = - Accessors::FunctionArgumentsInfo(isolate(), attribs); + Accessors::FunctionArgumentsInfo(isolate(), ro_attribs); { // Add arguments. CallbacksDescriptor d(Handle(Name::cast(args->name())), - args, attribs); + args, ro_attribs); map->AppendDescriptor(&d); } Handle caller = - Accessors::FunctionCallerInfo(isolate(), attribs); + Accessors::FunctionCallerInfo(isolate(), ro_attribs); { // Add caller. CallbacksDescriptor d(Handle(Name::cast(caller->name())), - caller, attribs); + caller, ro_attribs); map->AppendDescriptor(&d); } if (prototypeMode != DONT_ADD_PROTOTYPE) { if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { - attribs = static_cast(attribs & ~READ_ONLY); + ro_attribs = static_cast(ro_attribs & ~READ_ONLY); } Handle prototype = - Accessors::FunctionPrototypeInfo(isolate(), attribs); + Accessors::FunctionPrototypeInfo(isolate(), ro_attribs); CallbacksDescriptor d(Handle(Name::cast(prototype->name())), - prototype, attribs); + prototype, ro_attribs); map->AppendDescriptor(&d); } } @@ -533,6 +535,8 @@ void Genesis::SetStrictFunctionInstanceDescriptor( static_cast(DONT_ENUM | DONT_DELETE); PropertyAttributes ro_attribs = static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); + PropertyAttributes roc_attribs = + static_cast(DONT_ENUM | READ_ONLY); Handle length = Accessors::FunctionLengthInfo(isolate(), ro_attribs); @@ -542,10 +546,10 @@ void Genesis::SetStrictFunctionInstanceDescriptor( map->AppendDescriptor(&d); } Handle name = - Accessors::FunctionNameInfo(isolate(), ro_attribs); + Accessors::FunctionNameInfo(isolate(), roc_attribs); { // Add name. CallbacksDescriptor d(Handle(Name::cast(name->name())), - name, ro_attribs); + name, roc_attribs); map->AppendDescriptor(&d); } { // Add arguments. diff --git a/test/mjsunit/es7/object-observe.js b/test/mjsunit/es7/object-observe.js index 7bb579f..20a2d16 100644 --- a/test/mjsunit/es7/object-observe.js +++ b/test/mjsunit/es7/object-observe.js @@ -1142,7 +1142,8 @@ var properties = ["a", "1", 1, "length", "setPrototype", "name", "caller"]; function blacklisted(obj, prop) { return (obj instanceof Int32Array && prop == 1) || (obj instanceof Int32Array && prop === "length") || - (obj instanceof ArrayBuffer && prop == 1) + (obj instanceof ArrayBuffer && prop == 1) || + (obj instanceof Function && prop === "name") } for (var i in objects) for (var j in properties) { diff --git a/test/mjsunit/regress/regress-1530.js b/test/mjsunit/regress/regress-1530.js index db21144..3d40177 100644 --- a/test/mjsunit/regress/regress-1530.js +++ b/test/mjsunit/regress/regress-1530.js @@ -62,8 +62,9 @@ assertSame(new f().foo, 'other'); assertSame(Object.getPrototypeOf(new f()), z); assertSame(Object.getOwnPropertyDescriptor(f, 'prototype').value, z); -// Verify that non-writability of other properties is respected. -assertThrows("Object.defineProperty(f, 'name', { value: {} })"); +// Verify that non-configurability of other properties is respected, but +// non-writability is ignored by Object.defineProperty(). +assertDoesNotThrow("Object.defineProperty(f, 'name', { value: {} })"); assertThrows("Object.defineProperty(f, 'length', { value: {} })"); assertThrows("Object.defineProperty(f, 'caller', { value: {} })"); assertThrows("Object.defineProperty(f, 'arguments', { value: {} })"); diff --git a/test/mjsunit/regress/regress-270142.js b/test/mjsunit/regress/regress-270142.js index 6e0865c..63f4d14 100644 --- a/test/mjsunit/regress/regress-270142.js +++ b/test/mjsunit/regress/regress-270142.js @@ -39,7 +39,7 @@ function g(x) { function checkNameDescriptor(f) { var descriptor = Object.getOwnPropertyDescriptor(f, "name"); - assertFalse(descriptor.configurable); + assertTrue(descriptor.configurable); assertFalse(descriptor.enumerable); assertFalse(descriptor.writable); }