Reviewers: arv,

Message:
Hi Erik, could you please take a look?

Description:
[es6] Define generator prototype as writable prop

The April 14 2015 final draft of the ES6 specification states that the
`prototype` property of generator function instances should be writable.

BUG=v8:4140, v8:4140
LOG=N
[email protected]

Please review this at https://codereview.chromium.org/1153633003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+20, -13 lines):
  M src/bootstrapper.cc
  M test/mjsunit/es6/generators-runtime.js
  M test/mjsunit/harmony/object-literals-method.js


Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 30c6755b42deda493e429ab90cff06d9f173ff68..7d092b8c0952e08a3a5a57782484ec1ed370288d 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -2177,9 +2177,9 @@ bool Genesis::InstallNatives() {
                     Builtins::kIllegal, kUseStrictFunctionMap);

// Create maps for generator functions and their prototypes. Store those
-    // maps in the native context. Generator functions do not have writable
-    // prototypes, nor do they have "caller" or "arguments" accessors.
- Handle<Map> strict_function_map(native_context()->strict_function_map()); + // maps in the native context. Generator functions do not have "caller" or
+    // "arguments" accessors.
+ Handle<Map> strict_function_map(strict_function_map_writable_prototype_);
     Handle<Map> sloppy_generator_function_map =
         Map::Copy(strict_function_map, "SloppyGeneratorFunction");
     Map::SetPrototype(sloppy_generator_function_map,
Index: test/mjsunit/es6/generators-runtime.js
diff --git a/test/mjsunit/es6/generators-runtime.js b/test/mjsunit/es6/generators-runtime.js index 72a47d0fb093c567641ad3b80d07796a5bdcaf94..747236d5c54b122bceb945e9cb33a05cd9514c8c 100644
--- a/test/mjsunit/es6/generators-runtime.js
+++ b/test/mjsunit/es6/generators-runtime.js
@@ -52,16 +52,9 @@ function TestGeneratorFunctionInstance() {
     var prop = f_own_property_names[i];
     var f_desc = Object.getOwnPropertyDescriptor(f, prop);
     var g_desc = Object.getOwnPropertyDescriptor(g, prop);
-    if (prop === "prototype") {
-      // ES6 draft 03-17-2015 section 25.2.2.2
-      assertFalse(g_desc.writable, prop);
-      assertFalse(g_desc.enumerable, prop);
-      assertFalse(g_desc.configurable, prop);
-    } else {
-      assertEquals(f_desc.configurable, g_desc.configurable, prop);
-      assertEquals(f_desc.writable, g_desc.writable, prop);
-      assertEquals(f_desc.enumerable, g_desc.enumerable, prop);
-    }
+    assertEquals(f_desc.configurable, g_desc.configurable, prop);
+    assertEquals(f_desc.writable, g_desc.writable, prop);
+    assertEquals(f_desc.enumerable, g_desc.enumerable, prop);
   }
 }
 TestGeneratorFunctionInstance();
Index: test/mjsunit/harmony/object-literals-method.js
diff --git a/test/mjsunit/harmony/object-literals-method.js b/test/mjsunit/harmony/object-literals-method.js index 535231ea62f3bf642074eba74c516d48ea2626aa..d2879ada8f7ca59d8ecb7ea515cdfb8459ac4243 100644
--- a/test/mjsunit/harmony/object-literals-method.js
+++ b/test/mjsunit/harmony/object-literals-method.js
@@ -156,6 +156,7 @@


 var GeneratorFunction = function*() {}.__proto__.constructor;
+var GeneratorPrototype = Object.getPrototypeOf(function*() {}).prototype;


 function assertIteratorResult(value, done, result) {
@@ -215,6 +216,19 @@ function assertIteratorResult(value, done, result) {
 })();


+(function TestGeneratorPrototypeDescriptor() {
+  var object = {
+    *method() {}
+  };
+
+  var desc = Object.getOwnPropertyDescriptor(object.method, 'prototype');
+  assertFalse(desc.enumerable);
+  assertFalse(desc.configurable);
+  assertTrue(desc.writable);
+  assertEquals(GeneratorPrototype, Object.getPrototypeOf(desc.value));
+})();
+
+
 (function TestGeneratorProto() {
   var object = {
     *method() {}


--
--
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