Title: [206738] trunk
Revision
206738
Author
[email protected]
Date
2016-10-03 11:36:12 -0700 (Mon, 03 Oct 2016)

Log Message

[ES6] GeneratorFunction (a.k.a. GeneratorWrapperFunction)'s prototype object does not have constructor property
https://bugs.webkit.org/show_bug.cgi?id=162849

Reviewed by Geoffrey Garen.

JSTests:

* test262.yaml:

Source/_javascript_Core:

Since GeneratorFunction is not constructible, GeneratorFunction.prototype does not have "constructor" property.

    function* generatorFunction() { }
    generatorFunction.prototype.constructor // undefined

* runtime/JSFunction.cpp:
(JSC::JSFunction::getOwnPropertySlot):

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (206737 => 206738)


--- trunk/JSTests/ChangeLog	2016-10-03 17:57:27 UTC (rev 206737)
+++ trunk/JSTests/ChangeLog	2016-10-03 18:36:12 UTC (rev 206738)
@@ -1,3 +1,12 @@
+2016-10-03  Yusuke Suzuki  <[email protected]>
+
+        [ES6] GeneratorFunction (a.k.a. GeneratorWrapperFunction)'s prototype object does not have constructor property
+        https://bugs.webkit.org/show_bug.cgi?id=162849
+
+        Reviewed by Geoffrey Garen.
+
+        * test262.yaml:
+
 2016-10-01  Yusuke Suzuki  <[email protected]>
 
         [ES6] Align attributes of Generator related properties to spec

Modified: trunk/JSTests/test262.yaml (206737 => 206738)


--- trunk/JSTests/test262.yaml	2016-10-03 17:57:27 UTC (rev 206737)
+++ trunk/JSTests/test262.yaml	2016-10-03 18:36:12 UTC (rev 206738)
@@ -63034,9 +63034,9 @@
 - path: test262/test/language/expressions/generators/params-trailing-comma.js
   cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/expressions/generators/prototype-own-properties.js
-  cmd: runTest262 :fail, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
 - path: test262/test/language/expressions/generators/prototype-own-properties.js
-  cmd: runTest262 :fail, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/expressions/generators/prototype-property-descriptor.js
   cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js", "../../../../harness/propertyHelper.js"], []
 - path: test262/test/language/expressions/generators/prototype-property-descriptor.js
@@ -76522,9 +76522,9 @@
 - path: test262/test/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-name.js
   cmd: runTest262 :normal, "NoException", ["../../../../../../../harness/assert.js", "../../../../../../../harness/sta.js", "../../../../../../../harness/propertyHelper.js"], [:strict]
 - path: test262/test/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-prototype.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../../../harness/assert.js", "../../../../../../../harness/sta.js", "../../../../../../../harness/propertyHelper.js"], []
+  cmd: runTest262 :normal, "NoException", ["../../../../../../../harness/assert.js", "../../../../../../../harness/sta.js", "../../../../../../../harness/propertyHelper.js"], []
 - path: test262/test/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-prototype.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../../../harness/assert.js", "../../../../../../../harness/sta.js", "../../../../../../../harness/propertyHelper.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../../../../harness/assert.js", "../../../../../../../harness/sta.js", "../../../../../../../harness/propertyHelper.js"], [:strict]
 - path: test262/test/language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.js
   cmd: runTest262 :normal, "NoException", ["../../../../../../../harness/assert.js", "../../../../../../../harness/sta.js"], []
 - path: test262/test/language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.js
@@ -84194,9 +84194,9 @@
 - path: test262/test/language/statements/generators/params-trailing-comma.js
   cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/statements/generators/prototype-own-properties.js
-  cmd: runTest262 :fail, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
 - path: test262/test/language/statements/generators/prototype-own-properties.js
-  cmd: runTest262 :fail, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/statements/generators/prototype-property-descriptor.js
   cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js", "../../../../harness/propertyHelper.js"], []
 - path: test262/test/language/statements/generators/prototype-property-descriptor.js

Modified: trunk/Source/_javascript_Core/ChangeLog (206737 => 206738)


--- trunk/Source/_javascript_Core/ChangeLog	2016-10-03 17:57:27 UTC (rev 206737)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-10-03 18:36:12 UTC (rev 206738)
@@ -1,3 +1,18 @@
+2016-10-03  Yusuke Suzuki  <[email protected]>
+
+        [ES6] GeneratorFunction (a.k.a. GeneratorWrapperFunction)'s prototype object does not have constructor property
+        https://bugs.webkit.org/show_bug.cgi?id=162849
+
+        Reviewed by Geoffrey Garen.
+
+        Since GeneratorFunction is not constructible, GeneratorFunction.prototype does not have "constructor" property.
+
+            function* generatorFunction() { }
+            generatorFunction.prototype.constructor // undefined
+
+        * runtime/JSFunction.cpp:
+        (JSC::JSFunction::getOwnPropertySlot):
+
 2016-10-03  Nicolas Breidinger  <[email protected]>
 
         JSStringRef should define JSChar without platform checks

Modified: trunk/Source/_javascript_Core/runtime/JSFunction.cpp (206737 => 206738)


--- trunk/Source/_javascript_Core/runtime/JSFunction.cpp	2016-10-03 17:57:27 UTC (rev 206737)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.cpp	2016-10-03 18:36:12 UTC (rev 206738)
@@ -357,12 +357,16 @@
         PropertyOffset offset = thisObject->getDirectOffset(vm, propertyName, attributes);
         if (!isValidOffset(offset)) {
             JSObject* prototype = nullptr;
-            if (thisObject->jsExecutable()->parseMode() == SourceParseMode::GeneratorWrapperFunctionMode)
+            if (thisObject->jsExecutable()->parseMode() == SourceParseMode::GeneratorWrapperFunctionMode) {
+                // Unlike function instances, the object that is the value of the a GeneratorFunction's prototype
+                // property does not have a constructor property whose value is the GeneratorFunction instance.
+                // https://tc39.github.io/ecma262/#sec-generatorfunction-instances-prototype
                 prototype = constructEmptyObject(exec, thisObject->globalObject(vm)->generatorPrototype());
-            else
+            } else {
                 prototype = constructEmptyObject(exec);
+                prototype->putDirect(vm, vm.propertyNames->constructor, thisObject, DontEnum);
+            }
 
-            prototype->putDirect(vm, vm.propertyNames->constructor, thisObject, DontEnum);
             thisObject->putDirect(vm, vm.propertyNames->prototype, prototype, DontDelete | DontEnum);
             offset = thisObject->getDirectOffset(vm, vm.propertyNames->prototype, attributes);
             ASSERT(isValidOffset(offset));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to