From: mike Date: Tue, 26 May 2015 18:31:35 +0000 (-0700) Subject: [es6] Define generator prototype as writable prop X-Git-Tag: upstream/4.7.83~2399 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f7b5912276dbb13dbd6fade196ad37207a4cb730;p=platform%2Fupstream%2Fv8.git [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 R=arv@chromium.org Review URL: https://codereview.chromium.org/1153633003 Cr-Commit-Position: refs/heads/master@{#28641} --- diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index eee9bd3..dd6310b0 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -2205,9 +2205,11 @@ 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 strict_function_map(native_context()->strict_function_map()); + // maps in the native context. The "prototype" property descriptor is + // writable, non-enumerable, and non-configurable (as per ES6 draft + // 04-14-15, section 25.2.4.3). + Handle strict_function_map(strict_function_map_writable_prototype_); + // Generator functions do not have "caller" or "arguments" accessors. Handle sloppy_generator_function_map = Map::Copy(strict_function_map, "SloppyGeneratorFunction"); Map::SetPrototype(sloppy_generator_function_map, diff --git a/test/mjsunit/es6/generators-runtime.js b/test/mjsunit/es6/generators-runtime.js index 72a47d0..98015b7 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(); @@ -156,6 +149,13 @@ function TestGeneratorFunction() { assertTrue((new GeneratorFunction()) instanceof GeneratorFunction); assertTrue(GeneratorFunction() instanceof GeneratorFunction); + + // ES6 draft 04-14-15, section 25.2.2.2 + var prototype_desc = Object.getOwnPropertyDescriptor(GeneratorFunction, + "prototype"); + assertFalse(prototype_desc.writable); + assertFalse(prototype_desc.enumerable); + assertFalse(prototype_desc.configurable); } TestGeneratorFunction(); diff --git a/test/mjsunit/harmony/object-literals-method.js b/test/mjsunit/harmony/object-literals-method.js index 535231e..d2879ad 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() {}