Revision: 21609
Author:   [email protected]
Date:     Mon Jun  2 13:35:26 2014 UTC
Log:      Reland "Make 'name' property on functions configurable."

[email protected]
BUG=v8:3333
LOG=N

Review URL: https://codereview.chromium.org/303463006
http://code.google.com/p/v8/source/detail?r=21609

Modified:
 /branches/bleeding_edge/src/bootstrapper.cc
 /branches/bleeding_edge/test/mjsunit/es7/object-observe.js
 /branches/bleeding_edge/test/mjsunit/regress/regress-1530.js
 /branches/bleeding_edge/test/mjsunit/regress/regress-270142.js

=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Mon Jun  2 11:41:50 2014 UTC
+++ /branches/bleeding_edge/src/bootstrapper.cc Mon Jun  2 13:35:26 2014 UTC
@@ -386,45 +386,47 @@
   int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
   Map::EnsureDescriptorSlack(map, size);

-  PropertyAttributes attribs = static_cast<PropertyAttributes>(
-      DONT_ENUM | DONT_DELETE | READ_ONLY);
+  PropertyAttributes ro_attribs =
+      static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
+  PropertyAttributes roc_attribs =
+      static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);

   Handle<AccessorInfo> length =
-      Accessors::FunctionLengthInfo(isolate(), attribs);
+      Accessors::FunctionLengthInfo(isolate(), ro_attribs);
   {  // Add length.
     CallbacksDescriptor d(Handle<Name>(Name::cast(length->name())),
-                          length, attribs);
+                          length, ro_attribs);
     map->AppendDescriptor(&d);
   }
   Handle<AccessorInfo> name =
-      Accessors::FunctionNameInfo(isolate(), attribs);
+      Accessors::FunctionNameInfo(isolate(), roc_attribs);
   {  // Add name.
     CallbacksDescriptor d(Handle<Name>(Name::cast(name->name())),
-                          name, attribs);
+                          name, roc_attribs);
     map->AppendDescriptor(&d);
   }
   Handle<AccessorInfo> args =
-      Accessors::FunctionArgumentsInfo(isolate(), attribs);
+      Accessors::FunctionArgumentsInfo(isolate(), ro_attribs);
   {  // Add arguments.
     CallbacksDescriptor d(Handle<Name>(Name::cast(args->name())),
-                          args, attribs);
+                          args, ro_attribs);
     map->AppendDescriptor(&d);
   }
   Handle<AccessorInfo> caller =
-      Accessors::FunctionCallerInfo(isolate(), attribs);
+      Accessors::FunctionCallerInfo(isolate(), ro_attribs);
   {  // Add caller.
     CallbacksDescriptor d(Handle<Name>(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<PropertyAttributes>(attribs & ~READ_ONLY);
+ ro_attribs = static_cast<PropertyAttributes>(ro_attribs & ~READ_ONLY);
     }
     Handle<AccessorInfo> prototype =
-        Accessors::FunctionPrototypeInfo(isolate(), attribs);
+        Accessors::FunctionPrototypeInfo(isolate(), ro_attribs);
     CallbacksDescriptor d(Handle<Name>(Name::cast(prototype->name())),
-                          prototype, attribs);
+                          prototype, ro_attribs);
     map->AppendDescriptor(&d);
   }
 }
@@ -533,6 +535,8 @@
       static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
   PropertyAttributes ro_attribs =
       static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
+  PropertyAttributes roc_attribs =
+      static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);

   Handle<AccessorInfo> length =
       Accessors::FunctionLengthInfo(isolate(), ro_attribs);
@@ -542,10 +546,10 @@
     map->AppendDescriptor(&d);
   }
   Handle<AccessorInfo> name =
-      Accessors::FunctionNameInfo(isolate(), ro_attribs);
+      Accessors::FunctionNameInfo(isolate(), roc_attribs);
   {  // Add name.
     CallbacksDescriptor d(Handle<Name>(Name::cast(name->name())),
-                          name, ro_attribs);
+                          name, roc_attribs);
     map->AppendDescriptor(&d);
   }
   {  // Add arguments.
=======================================
--- /branches/bleeding_edge/test/mjsunit/es7/object-observe.js Tue May 27 15:00:26 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/es7/object-observe.js Mon Jun 2 13:35:26 2014 UTC
@@ -1142,7 +1142,8 @@
 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) {
=======================================
--- /branches/bleeding_edge/test/mjsunit/regress/regress-1530.js Tue May 27 15:00:26 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/regress/regress-1530.js Mon Jun 2 13:35:26 2014 UTC
@@ -62,8 +62,9 @@
 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: {} })");
=======================================
--- /branches/bleeding_edge/test/mjsunit/regress/regress-270142.js Tue May 27 15:00:26 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/regress/regress-270142.js Mon Jun 2 13:35:26 2014 UTC
@@ -39,7 +39,7 @@

 function checkNameDescriptor(f) {
   var descriptor = Object.getOwnPropertyDescriptor(f, "name");
-  assertFalse(descriptor.configurable);
+  assertTrue(descriptor.configurable);
   assertFalse(descriptor.enumerable);
   assertFalse(descriptor.writable);
 }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to